29 #define MAX_SLICES 1024
31 DXVA_PictureParameters
pp;
43 DXVA_PictureParameters *pp)
45 const Picture *current_picture =
s->current_picture_ptr;
48 memset(pp, 0,
sizeof(*pp));
50 pp->wDeblockedPictureIndex = 0;
54 pp->wForwardRefPictureIndex = 0xffff;
58 pp->wBackwardRefPictureIndex = 0xffff;
59 pp->wPicWidthInMBminus1 =
s->mb_width - 1;
60 pp->wPicHeightInMBminus1 = (
s->mb_height >> is_field) - 1;
61 pp->bMacroblockWidthMinus1 = 15;
62 pp->bMacroblockHeightMinus1 = 15;
63 pp->bBlockWidthMinus1 = 7;
64 pp->bBlockHeightMinus1 = 7;
66 pp->bPicStructure =
s->picture_structure;
67 pp->bSecondField = is_field && !
s->first_field;
70 pp->bBidirectionalAveragingMode = 0;
71 pp->bMVprecisionAndChromaRelation= 0;
72 pp->bChromaFormat =
s->chroma_format;
73 pp->bPicScanFixed = 1;
74 pp->bPicScanMethod =
s->alternate_scan ? 1 : 0;
75 pp->bPicReadbackRequests = 0;
77 pp->bPicSpatialResid8 = 0;
78 pp->bPicOverflowBlocks = 0;
79 pp->bPicExtrapolation = 0;
80 pp->bPicDeblocked = 0;
81 pp->bPicDeblockConfined = 0;
82 pp->bPic4MVallowed = 0;
86 pp->bReservedBits = 0;
87 pp->wBitstreamFcodes = (
s->mpeg_f_code[0][0] << 12) |
88 (
s->mpeg_f_code[0][1] << 8) |
89 (
s->mpeg_f_code[1][0] << 4) |
90 (
s->mpeg_f_code[1][1] );
91 pp->wBitstreamPCEelements = (
s->intra_dc_precision << 14) |
92 (
s->picture_structure << 12) |
93 (
s->top_field_first << 11) |
94 (
s->frame_pred_frame_dct << 10) |
95 (
s->concealment_motion_vectors << 9) |
96 (
s->q_scale_type << 8) |
97 (
s->intra_vlc_format << 7) |
98 (
s->alternate_scan << 6) |
99 (
s->repeat_first_field << 5) |
100 (
s->chroma_420_type << 4) |
101 (
s->progressive_frame << 3);
102 pp->bBitstreamConcealmentNeed = 0;
103 pp->bBitstreamConcealmentMethod = 0;
109 DXVA_QmatrixData *qm)
112 for (
i = 0;
i < 4;
i++)
113 qm->bNewQmatrix[
i] = 1;
114 for (
i = 0;
i < 64;
i++) {
116 qm->Qmatrix[0][
i] =
s->intra_matrix[
n];
117 qm->Qmatrix[1][
i] =
s->inter_matrix[
n];
118 qm->Qmatrix[2][
i] =
s->chroma_intra_matrix[
n];
119 qm->Qmatrix[3][
i] =
s->chroma_inter_matrix[
n];
125 DXVA_SliceInfo *slice,
132 memset(slice, 0,
sizeof(*slice));
133 slice->wHorizontalPosition =
s->mb_x;
134 slice->wVerticalPosition =
s->mb_y >> is_field;
135 slice->dwSliceBitsInBuffer = 8 *
size;
136 slice->dwSliceDataLocation = position;
137 slice->bStartCodeBitOffset = 0;
138 slice->bReservedBits = 0;
140 slice->wNumberMBsInSlice = (
s->mb_y >> is_field) *
s->mb_width +
s->mb_x;
141 slice->wBadSliceChopping = 0;
145 slice->wQuantizerScaleCode =
get_bits(&gb, 5);
157 s->current_picture_ptr->hwaccel_picture_private;
158 const int is_field =
s->picture_structure !=
PICT_FRAME;
159 const unsigned mb_count =
s->mb_width * (
s->mb_height >> is_field);
168 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
172 &dxva_size, &dxva_data_ptr)))
178 type = DXVA2_BitStreamDateBufferType;
181 &dxva_data_ptr, &dxva_size)))
186 dxva_data = dxva_data_ptr;
188 end = dxva_data + dxva_size;
192 unsigned position =
slice->dwSliceDataLocation;
193 unsigned size =
slice->dwSliceBitsInBuffer / 8;
198 slice->dwSliceDataLocation = current - dxva_data;
201 slice->wNumberMBsInSlice =
202 slice[1].wNumberMBsInSlice -
slice[0].wNumberMBsInSlice;
204 slice->wNumberMBsInSlice =
205 mb_count -
slice[0].wNumberMBsInSlice;
225 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
226 memset(dsc11, 0,
sizeof(*dsc11));
227 dsc11->BufferType =
type;
228 dsc11->DataSize = current - dxva_data;
229 dsc11->NumMBsInBuffer = mb_count;
231 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
236 DXVA2_DecodeBufferDesc *dsc2 = bs;
237 memset(dsc2, 0,
sizeof(*dsc2));
238 dsc2->CompressedBufferType =
type;
239 dsc2->DataSize = current - dxva_data;
240 dsc2->NumMBsInBuffer = mb_count;
242 type = DXVA2_SliceControlBufferType;
260 s->current_picture_ptr->hwaccel_picture_private;
262 if (!DXVA_CONTEXT_VALID(avctx,
ctx))
280 s->current_picture_ptr->hwaccel_picture_private;
302 s->current_picture_ptr->hwaccel_picture_private;
308 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
309 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
316 #if CONFIG_MPEG2_DXVA2_HWACCEL
318 .
name =
"mpeg2_dxva2",
333 #if CONFIG_MPEG2_D3D11VA_HWACCEL
335 .
name =
"mpeg2_d3d11va",
350 #if CONFIG_MPEG2_D3D11VA2_HWACCEL
352 .
name =
"mpeg2_d3d11va2",