28 DXVA_PicParams_H264
pp;
38 unsigned index,
unsigned flag)
40 assert((index&0x7f) == index && (flag&0x01) == flag);
41 pic->bPicEntry = index | (flag << 7);
45 DXVA_PicParams_H264 *pp)
51 memset(pp, 0,
sizeof(*pp));
57 pp->UsedForReferenceFlags = 0;
58 pp->NonExistingFrameFlags = 0;
61 if (j < h->short_ref_count) {
65 while (!r && j < h->short_ref_count + 16)
74 pp->FieldOrderCntList[i][0] = r->
field_poc[0];
76 pp->FieldOrderCntList[i][1] = r->
field_poc[1];
80 pp->UsedForReferenceFlags |= 1 << (2*i + 0);
82 pp->UsedForReferenceFlags |= 1 << (2*i + 1);
84 pp->RefFrameList[i].bPicEntry = 0xff;
85 pp->FieldOrderCntList[i][0] = 0;
86 pp->FieldOrderCntList[i][1] = 0;
87 pp->FrameNumList[i] = 0;
91 pp->wFrameWidthInMbsMinus1 = s->
mb_width - 1;
92 pp->wFrameHeightInMbsMinus1 = s->
mb_height - 1;
117 pp->Reserved16Bits = 0;
119 pp->Reserved16Bits = 3;
120 pp->StatusReportFeedbackNumber = 1 + ctx->
report_id++;
121 pp->CurrFieldOrderCnt[0] = 0;
123 current_picture->
field_poc[0] != INT_MAX)
124 pp->CurrFieldOrderCnt[0] = current_picture->
field_poc[0];
125 pp->CurrFieldOrderCnt[1] = 0;
127 current_picture->
field_poc[1] != INT_MAX)
128 pp->CurrFieldOrderCnt[1] = current_picture->
field_poc[1];
129 pp->pic_init_qs_minus26 = h->
pps.
init_qs - 26;
132 pp->ContinuationFlag = 1;
133 pp->pic_init_qp_minus26 = h->
pps.
init_qp - 26;
134 pp->num_ref_idx_l0_active_minus1 = h->
pps.
ref_count[0] - 1;
135 pp->num_ref_idx_l1_active_minus1 = h->
pps.
ref_count[1] - 1;
136 pp->Reserved8BitsA = 0;
145 pp->entropy_coding_mode_flag = h->
pps.
cabac;
151 pp->Reserved8BitsB = 0;
152 pp->slice_group_change_rate_minus1= 0;
159 memset(qm, 0,
sizeof(*qm));
161 for (i = 0; i < 6; i++)
162 for (j = 0; j < 16; j++)
165 for (i = 0; i < 64; i++) {
170 for (i = 0; i < 6; i++)
171 for (j = 0; j < 16; j++)
174 for (i = 0; i < 64; i++) {
183 assert(ctx->
cfg->ConfigBitstreamRaw == 1 ||
184 ctx->
cfg->ConfigBitstreamRaw == 2);
185 return ctx->
cfg->ConfigBitstreamRaw == 2;
189 unsigned position,
unsigned size)
191 memset(slice, 0,
sizeof(*slice));
192 slice->BSNALunitDataLocation = position;
193 slice->SliceBytesInBuffer =
size;
194 slice->wBadSliceChopping = 0;
198 unsigned position,
unsigned size)
205 memset(slice, 0,
sizeof(*slice));
206 slice->BSNALunitDataLocation = position;
207 slice->SliceBytesInBuffer =
size;
208 slice->wBadSliceChopping = 0;
211 slice->NumMbsForSlice = 0;
215 slice->slice_type += 5;
219 slice->num_ref_idx_l0_active_minus1 = h->
ref_count[0] - 1;
221 slice->num_ref_idx_l1_active_minus1 = h->
ref_count[1] - 1;
224 slice->Reserved8Bits = 0;
226 for (list = 0; list < 2; list++) {
229 if (list < h->list_count && i < h->ref_count[list]) {
235 for (plane = 0; plane < 3; plane++) {
248 slice->Weights[list][i][plane][0] = w;
249 slice->Weights[list][i][plane][1] = o;
253 slice->RefPicList[list][i].bPicEntry = 0xff;
254 for (plane = 0; plane < 3; plane++) {
255 slice->Weights[list][i][plane][0] = 0;
256 slice->Weights[list][i][plane][1] = 0;
261 slice->slice_qs_delta = 0;
275 DXVA2_DecodeBufferDesc *bs,
276 DXVA2_DecodeBufferDesc *sc)
285 uint8_t *dxva_data, *current, *end;
293 if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->
decoder,
294 DXVA2_BitStreamDateBufferType,
295 &dxva_data, &dxva_size)))
298 end = dxva_data + dxva_size;
301 static const uint8_t start_code[] = { 0, 0, 1 };
302 static const unsigned start_code_size =
sizeof(start_code);
303 unsigned position,
size;
305 assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
306 offsetof(DXVA_Slice_H264_Long, BSNALunitDataLocation));
307 assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
308 offsetof(DXVA_Slice_H264_Long, SliceBytesInBuffer));
313 slice = (DXVA_Slice_H264_Short*)&ctx_pic->
slice_long[i];
315 position = slice->BSNALunitDataLocation;
316 size = slice->SliceBytesInBuffer;
317 if (start_code_size + size > end - current) {
322 slice->BSNALunitDataLocation = current - dxva_data;
323 slice->SliceBytesInBuffer = start_code_size +
size;
326 DXVA_Slice_H264_Long *
slice_long = (DXVA_Slice_H264_Long*)slice;
328 slice_long->NumMbsForSlice =
329 slice_long[1].first_mb_in_slice - slice_long[0].first_mb_in_slice;
331 slice_long->NumMbsForSlice = mb_count - slice_long->first_mb_in_slice;
334 memcpy(current, start_code, start_code_size);
335 current += start_code_size;
337 memcpy(current, &ctx_pic->
bitstream[position], size);
340 padding =
FFMIN(128 - ((current - dxva_data) & 127), end - current);
341 if (slice && padding > 0) {
342 memset(current, 0, padding);
345 slice->SliceBytesInBuffer += padding;
347 if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(ctx->
decoder,
348 DXVA2_BitStreamDateBufferType)))
353 memset(bs, 0,
sizeof(*bs));
354 bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
355 bs->DataSize = current - dxva_data;
356 bs->NumMBsInBuffer = mb_count;
365 assert((bs->DataSize & 127) == 0);
367 DXVA2_SliceControlBufferType,
368 slice_data, slice_size, mb_count);
422 ctx_pic->
pp.wBitFields &= ~(1 << 15);
436 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
437 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
442 .
name =
"h264_dxva2",