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->cur_pic.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);
163 void *dxva_data_ptr =
NULL;
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)))
192 dxva_data = dxva_data_ptr;
194 end = dxva_data + dxva_size;
198 unsigned position =
slice->dwSliceDataLocation;
199 unsigned size =
slice->dwSliceBitsInBuffer / 8;
200 if (
size > end - current) {
204 slice->dwSliceDataLocation = current - dxva_data;
207 slice->wNumberMBsInSlice =
208 slice[1].wNumberMBsInSlice -
slice[0].wNumberMBsInSlice;
210 slice->wNumberMBsInSlice =
211 mb_count -
slice[0].wNumberMBsInSlice;
231 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
232 memset(dsc11, 0,
sizeof(*dsc11));
233 dsc11->BufferType =
type;
234 dsc11->DataSize = current - dxva_data;
235 dsc11->NumMBsInBuffer = mb_count;
237 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
242 DXVA2_DecodeBufferDesc *dsc2 = bs;
243 memset(dsc2, 0,
sizeof(*dsc2));
244 dsc2->CompressedBufferType =
type;
245 dsc2->DataSize = current - dxva_data;
246 dsc2->NumMBsInBuffer = mb_count;
248 type = DXVA2_SliceControlBufferType;
266 s->cur_pic.ptr->hwaccel_picture_private;
286 s->cur_pic.ptr->hwaccel_picture_private;
308 s->cur_pic.ptr->hwaccel_picture_private;
314 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
315 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
322 #if CONFIG_MPEG2_DXVA2_HWACCEL
324 .
p.
name =
"mpeg2_dxva2",
339 #if CONFIG_MPEG2_D3D11VA_HWACCEL
341 .
p.
name =
"mpeg2_d3d11va",
356 #if CONFIG_MPEG2_D3D11VA2_HWACCEL
358 .
p.
name =
"mpeg2_d3d11va2",