23 #include "config_components.h"
31 #define MAX_SLICES 1024
33 DXVA_PictureParameters
pp;
45 DXVA_PictureParameters *pp)
47 const Picture *current_picture =
s->current_picture_ptr;
50 memset(pp, 0,
sizeof(*pp));
52 pp->wDeblockedPictureIndex = 0;
56 pp->wForwardRefPictureIndex = 0xffff;
60 pp->wBackwardRefPictureIndex = 0xffff;
61 pp->wPicWidthInMBminus1 =
s->mb_width - 1;
62 pp->wPicHeightInMBminus1 = (
s->mb_height >> is_field) - 1;
63 pp->bMacroblockWidthMinus1 = 15;
64 pp->bMacroblockHeightMinus1 = 15;
65 pp->bBlockWidthMinus1 = 7;
66 pp->bBlockHeightMinus1 = 7;
68 pp->bPicStructure =
s->picture_structure;
69 pp->bSecondField = is_field && !
s->first_field;
72 pp->bBidirectionalAveragingMode = 0;
73 pp->bMVprecisionAndChromaRelation= 0;
74 pp->bChromaFormat =
s->chroma_format;
75 pp->bPicScanFixed = 1;
76 pp->bPicScanMethod =
s->alternate_scan ? 1 : 0;
77 pp->bPicReadbackRequests = 0;
79 pp->bPicSpatialResid8 = 0;
80 pp->bPicOverflowBlocks = 0;
81 pp->bPicExtrapolation = 0;
82 pp->bPicDeblocked = 0;
83 pp->bPicDeblockConfined = 0;
84 pp->bPic4MVallowed = 0;
88 pp->bReservedBits = 0;
89 pp->wBitstreamFcodes = (
s->mpeg_f_code[0][0] << 12) |
90 (
s->mpeg_f_code[0][1] << 8) |
91 (
s->mpeg_f_code[1][0] << 4) |
92 (
s->mpeg_f_code[1][1] );
93 pp->wBitstreamPCEelements = (
s->intra_dc_precision << 14) |
94 (
s->picture_structure << 12) |
95 (
s->top_field_first << 11) |
96 (
s->frame_pred_frame_dct << 10) |
97 (
s->concealment_motion_vectors << 9) |
98 (
s->q_scale_type << 8) |
99 (
s->intra_vlc_format << 7) |
100 (
s->alternate_scan << 6) |
101 (
s->repeat_first_field << 5) |
102 (
s->chroma_420_type << 4) |
103 (
s->progressive_frame << 3);
104 pp->bBitstreamConcealmentNeed = 0;
105 pp->bBitstreamConcealmentMethod = 0;
111 DXVA_QmatrixData *qm)
114 for (
i = 0;
i < 4;
i++)
115 qm->bNewQmatrix[
i] = 1;
116 for (
i = 0;
i < 64;
i++) {
118 qm->Qmatrix[0][
i] =
s->intra_matrix[n];
119 qm->Qmatrix[1][
i] =
s->inter_matrix[n];
120 qm->Qmatrix[2][
i] =
s->chroma_intra_matrix[n];
121 qm->Qmatrix[3][
i] =
s->chroma_inter_matrix[n];
127 DXVA_SliceInfo *slice,
134 memset(slice, 0,
sizeof(*slice));
135 slice->wHorizontalPosition =
s->mb_x;
136 slice->wVerticalPosition =
s->mb_y >> is_field;
137 slice->dwSliceBitsInBuffer = 8 *
size;
138 slice->dwSliceDataLocation = position;
139 slice->bStartCodeBitOffset = 0;
140 slice->bReservedBits = 0;
142 slice->wNumberMBsInSlice = (
s->mb_y >> is_field) *
s->mb_width +
s->mb_x;
143 slice->wBadSliceChopping = 0;
147 slice->wQuantizerScaleCode =
get_bits(&gb, 5);
159 s->current_picture_ptr->hwaccel_picture_private;
160 const int is_field =
s->picture_structure !=
PICT_FRAME;
161 const unsigned mb_count =
s->mb_width * (
s->mb_height >> is_field);
163 uint8_t *dxva_data, *current, *end;
170 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
174 &dxva_size, &dxva_data_ptr)))
180 type = DXVA2_BitStreamDateBufferType;
183 &dxva_data_ptr, &dxva_size)))
188 dxva_data = dxva_data_ptr;
190 end = dxva_data + dxva_size;
194 unsigned position =
slice->dwSliceDataLocation;
195 unsigned size =
slice->dwSliceBitsInBuffer / 8;
196 if (
size > end - current) {
200 slice->dwSliceDataLocation = current - dxva_data;
203 slice->wNumberMBsInSlice =
204 slice[1].wNumberMBsInSlice -
slice[0].wNumberMBsInSlice;
206 slice->wNumberMBsInSlice =
207 mb_count -
slice[0].wNumberMBsInSlice;
227 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
228 memset(dsc11, 0,
sizeof(*dsc11));
229 dsc11->BufferType =
type;
230 dsc11->DataSize = current - dxva_data;
231 dsc11->NumMBsInBuffer = mb_count;
233 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
238 DXVA2_DecodeBufferDesc *dsc2 = bs;
239 memset(dsc2, 0,
sizeof(*dsc2));
240 dsc2->CompressedBufferType =
type;
241 dsc2->DataSize = current - dxva_data;
242 dsc2->NumMBsInBuffer = mb_count;
244 type = DXVA2_SliceControlBufferType;
262 s->current_picture_ptr->hwaccel_picture_private;
264 if (!DXVA_CONTEXT_VALID(avctx,
ctx))
282 s->current_picture_ptr->hwaccel_picture_private;
304 s->current_picture_ptr->hwaccel_picture_private;
310 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
311 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
318 #if CONFIG_MPEG2_DXVA2_HWACCEL
320 .
name =
"mpeg2_dxva2",
335 #if CONFIG_MPEG2_D3D11VA_HWACCEL
337 .
name =
"mpeg2_d3d11va",
352 #if CONFIG_MPEG2_D3D11VA2_HWACCEL
354 .
name =
"mpeg2_d3d11va2",