23 #include "config_components.h"
32 #define MAX_SLICES 1024
34 DXVA_PictureParameters
pp;
45 DXVA_PictureParameters *pp)
51 memset(pp, 0,
sizeof(*pp));
52 pp->wDeblockedPictureIndex = 0;
56 pp->wForwardRefPictureIndex = 0xffff;
60 pp->wBackwardRefPictureIndex = 0xffff;
62 pp->wPicWidthInMBminus1 =
s->mb_width - 1;
63 pp->wPicHeightInMBminus1 = (
s->mb_height >> is_field) - 1;
64 pp->bMacroblockWidthMinus1 = 15;
65 pp->bMacroblockHeightMinus1 = 15;
66 pp->bBlockWidthMinus1 = 7;
67 pp->bBlockHeightMinus1 = 7;
69 pp->bPicStructure =
s->picture_structure;
70 pp->bSecondField = is_field && !
s->first_field;
73 pp->bBidirectionalAveragingMode = 0;
74 pp->bMVprecisionAndChromaRelation= 0;
75 pp->bChromaFormat =
s->chroma_format;
76 pp->bPicScanFixed = 1;
77 pp->bPicScanMethod =
s->alternate_scan ? 1 : 0;
78 pp->bPicReadbackRequests = 0;
80 pp->bPicSpatialResid8 = 0;
81 pp->bPicOverflowBlocks = 0;
82 pp->bPicExtrapolation = 0;
83 pp->bPicDeblocked = 0;
84 pp->bPicDeblockConfined = 0;
85 pp->bPic4MVallowed = 0;
89 pp->bReservedBits = 0;
90 pp->wBitstreamFcodes = (
s->mpeg_f_code[0][0] << 12) |
91 (
s->mpeg_f_code[0][1] << 8) |
92 (
s->mpeg_f_code[1][0] << 4) |
93 (
s->mpeg_f_code[1][1] );
94 pp->wBitstreamPCEelements = (
s->intra_dc_precision << 14) |
95 (
s->picture_structure << 12) |
96 (
s->top_field_first << 11) |
97 (
s->frame_pred_frame_dct << 10) |
98 (
s->concealment_motion_vectors << 9) |
99 (
s->q_scale_type << 8) |
100 (
s->intra_vlc_format << 7) |
101 (
s->alternate_scan << 6) |
102 (
s->repeat_first_field << 5) |
103 (
s->chroma_420_type << 4) |
104 (
s->progressive_frame << 3);
105 pp->bBitstreamConcealmentNeed = 0;
106 pp->bBitstreamConcealmentMethod = 0;
111 DXVA_QmatrixData *qm)
115 for (
i = 0;
i < 4;
i++)
116 qm->bNewQmatrix[
i] = 1;
117 for (
i = 0;
i < 64;
i++) {
119 qm->Qmatrix[0][
i] =
s->intra_matrix[n];
120 qm->Qmatrix[1][
i] =
s->inter_matrix[n];
121 qm->Qmatrix[2][
i] =
s->chroma_intra_matrix[n];
122 qm->Qmatrix[3][
i] =
s->chroma_inter_matrix[n];
127 DXVA_SliceInfo *slice,
135 memset(slice, 0,
sizeof(*slice));
136 slice->wHorizontalPosition =
s->mb_x;
137 slice->wVerticalPosition =
s->mb_y >> is_field;
138 slice->dwSliceBitsInBuffer = 8 *
size;
139 slice->dwSliceDataLocation = position;
140 slice->bStartCodeBitOffset = 0;
141 slice->bReservedBits = 0;
143 slice->wNumberMBsInSlice = (
s->mb_y >> is_field) *
s->mb_width +
s->mb_x;
144 slice->wBadSliceChopping = 0;
148 slice->wQuantizerScaleCode =
get_bits(&
gb, 5);
160 s->current_picture_ptr->hwaccel_picture_private;
161 const int is_field =
s->picture_structure !=
PICT_FRAME;
162 const unsigned mb_count =
s->mb_width * (
s->mb_height >> is_field);
164 uint8_t *dxva_data, *current, *end;
171 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
175 &dxva_size, &dxva_data_ptr)))
181 type = DXVA2_BitStreamDateBufferType;
184 &dxva_data_ptr, &dxva_size)))
189 dxva_data = dxva_data_ptr;
191 end = dxva_data + dxva_size;
195 unsigned position =
slice->dwSliceDataLocation;
196 unsigned size =
slice->dwSliceBitsInBuffer / 8;
197 if (
size > end - current) {
201 slice->dwSliceDataLocation = current - dxva_data;
204 slice->wNumberMBsInSlice =
205 slice[1].wNumberMBsInSlice -
slice[0].wNumberMBsInSlice;
207 slice->wNumberMBsInSlice =
208 mb_count -
slice[0].wNumberMBsInSlice;
228 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
229 memset(dsc11, 0,
sizeof(*dsc11));
230 dsc11->BufferType =
type;
231 dsc11->DataSize = current - dxva_data;
232 dsc11->NumMBsInBuffer = mb_count;
234 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
239 DXVA2_DecodeBufferDesc *dsc2 = bs;
240 memset(dsc2, 0,
sizeof(*dsc2));
241 dsc2->CompressedBufferType =
type;
242 dsc2->DataSize = current - dxva_data;
243 dsc2->NumMBsInBuffer = mb_count;
245 type = DXVA2_SliceControlBufferType;
263 s->current_picture_ptr->hwaccel_picture_private;
283 s->current_picture_ptr->hwaccel_picture_private;
305 s->current_picture_ptr->hwaccel_picture_private;
311 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
312 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
319 #if CONFIG_MPEG2_DXVA2_HWACCEL
321 .
p.
name =
"mpeg2_dxva2",
336 #if CONFIG_MPEG2_D3D11VA_HWACCEL
338 .
p.
name =
"mpeg2_d3d11va",
353 #if CONFIG_MPEG2_D3D11VA2_HWACCEL
355 .
p.
name =
"mpeg2_d3d11va2",