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;
118 pp->Reserved16Bits = 0;
120 pp->Reserved16Bits = 3;
121 pp->StatusReportFeedbackNumber = 1 + ctx->
report_id++;
122 pp->CurrFieldOrderCnt[0] = 0;
124 current_picture->
field_poc[0] != INT_MAX)
125 pp->CurrFieldOrderCnt[0] = current_picture->
field_poc[0];
126 pp->CurrFieldOrderCnt[1] = 0;
128 current_picture->
field_poc[1] != INT_MAX)
129 pp->CurrFieldOrderCnt[1] = current_picture->
field_poc[1];
130 pp->pic_init_qs_minus26 = h->
pps.
init_qs - 26;
133 pp->ContinuationFlag = 1;
134 pp->pic_init_qp_minus26 = h->
pps.
init_qp - 26;
135 pp->num_ref_idx_l0_active_minus1 = h->
pps.
ref_count[0] - 1;
136 pp->num_ref_idx_l1_active_minus1 = h->
pps.
ref_count[1] - 1;
137 pp->Reserved8BitsA = 0;
146 pp->entropy_coding_mode_flag = h->
pps.
cabac;
152 pp->Reserved8BitsB = 0;
153 pp->slice_group_change_rate_minus1= 0;
160 memset(qm, 0,
sizeof(*qm));
162 for (i = 0; i < 6; i++)
163 for (j = 0; j < 16; j++)
166 for (i = 0; i < 64; i++) {
171 for (i = 0; i < 6; i++)
172 for (j = 0; j < 16; j++)
175 for (i = 0; i < 64; i++) {
184 assert(ctx->
cfg->ConfigBitstreamRaw == 1 ||
185 ctx->
cfg->ConfigBitstreamRaw == 2);
186 return ctx->
cfg->ConfigBitstreamRaw == 2;
190 unsigned position,
unsigned size)
192 memset(slice, 0,
sizeof(*slice));
193 slice->BSNALunitDataLocation = position;
194 slice->SliceBytesInBuffer =
size;
195 slice->wBadSliceChopping = 0;
199 unsigned position,
unsigned size)
206 memset(slice, 0,
sizeof(*slice));
207 slice->BSNALunitDataLocation = position;
208 slice->SliceBytesInBuffer =
size;
209 slice->wBadSliceChopping = 0;
212 slice->NumMbsForSlice = 0;
216 slice->slice_type += 5;
220 slice->num_ref_idx_l0_active_minus1 = h->
ref_count[0] - 1;
222 slice->num_ref_idx_l1_active_minus1 = h->
ref_count[1] - 1;
225 slice->Reserved8Bits = 0;
227 for (list = 0; list < 2; list++) {
230 if (list < h->list_count && i < h->ref_count[list]) {
236 for (plane = 0; plane < 3; plane++) {
249 slice->Weights[list][i][plane][0] = w;
250 slice->Weights[list][i][plane][1] = o;
254 slice->RefPicList[list][i].bPicEntry = 0xff;
255 for (plane = 0; plane < 3; plane++) {
256 slice->Weights[list][i][plane][0] = 0;
257 slice->Weights[list][i][plane][1] = 0;
262 slice->slice_qs_delta = 0;
276 DXVA2_DecodeBufferDesc *bs,
277 DXVA2_DecodeBufferDesc *sc)
294 if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->
decoder,
295 DXVA2_BitStreamDateBufferType,
296 (
void **)&dxva_data, &dxva_size)))
299 end = dxva_data + dxva_size;
302 static const uint8_t start_code[] = { 0, 0, 1 };
303 static const unsigned start_code_size =
sizeof(start_code);
304 unsigned position,
size;
306 assert(offsetof(DXVA_Slice_H264_Short, BSNALunitDataLocation) ==
307 offsetof(DXVA_Slice_H264_Long, BSNALunitDataLocation));
308 assert(offsetof(DXVA_Slice_H264_Short, SliceBytesInBuffer) ==
309 offsetof(DXVA_Slice_H264_Long, SliceBytesInBuffer));
314 slice = (DXVA_Slice_H264_Short*)&ctx_pic->
slice_long[i];
316 position = slice->BSNALunitDataLocation;
317 size = slice->SliceBytesInBuffer;
318 if (start_code_size + size > end - current) {
323 slice->BSNALunitDataLocation = current - dxva_data;
324 slice->SliceBytesInBuffer = start_code_size +
size;
327 DXVA_Slice_H264_Long *
slice_long = (DXVA_Slice_H264_Long*)slice;
329 slice_long->NumMbsForSlice =
330 slice_long[1].first_mb_in_slice - slice_long[0].first_mb_in_slice;
332 slice_long->NumMbsForSlice = mb_count - slice_long->first_mb_in_slice;
335 memcpy(current, start_code, start_code_size);
336 current += start_code_size;
338 memcpy(current, &ctx_pic->
bitstream[position], size);
341 padding =
FFMIN(128 - ((current - dxva_data) & 127), end - current);
342 if (slice && padding > 0) {
343 memset(current, 0, padding);
346 slice->SliceBytesInBuffer += padding;
348 if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(ctx->
decoder,
349 DXVA2_BitStreamDateBufferType)))
354 memset(bs, 0,
sizeof(*bs));
355 bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
356 bs->DataSize = current - dxva_data;
357 bs->NumMBsInBuffer = mb_count;
366 assert((bs->DataSize & 127) == 0);
368 DXVA2_SliceControlBufferType,
369 slice_data, slice_size, mb_count);
423 ctx_pic->
pp.wBitFields &= ~(1 << 15);
437 &ctx_pic->
pp,
sizeof(ctx_pic->
pp),
438 &ctx_pic->
qm,
sizeof(ctx_pic->
qm),
443 .
name =
"h264_dxva2",