MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / commit_bitstream_and_slice_buffer

Function commit_bitstream_and_slice_buffer

libavcodec/dxva2_vc1.c:157–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
158 DXVA2_DecodeBufferDesc *bs,
159 DXVA2_DecodeBufferDesc *sc)
160{
161 const VC1Context *v = avctx->priv_data;
162 struct dxva_context *ctx = avctx->hwaccel_context;
163 const MpegEncContext *s = &v->s;
164 struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private;
165
166 DXVA_SliceInfo *slice = &ctx_pic->si;
167
168 static const uint8_t start_code[] = { 0, 0, 1, 0x0d };
169 const unsigned start_code_size = avctx->codec_id == CODEC_ID_VC1 ? sizeof(start_code) : 0;
170 const unsigned slice_size = slice->dwSliceBitsInBuffer / 8;
171 const unsigned padding = 128 - ((start_code_size + slice_size) & 127);
172 const unsigned data_size = start_code_size + slice_size + padding;
173
174 uint8_t *dxva_data;
175 unsigned dxva_size;
176 int result;
177
178 if (FAILED(IDirectXVideoDecoder_GetBuffer(ctx->decoder,
179 DXVA2_BitStreamDateBufferType,
180 &dxva_data, &dxva_size)))
181 return -1;
182
183 result = data_size <= dxva_size ? 0 : -1;
184 if (!result) {
185 if (start_code_size > 0)
186 memcpy(dxva_data, start_code, start_code_size);
187 memcpy(dxva_data + start_code_size,
188 ctx_pic->bitstream + slice->dwSliceDataLocation, slice_size);
189 if (padding > 0)
190 memset(dxva_data + start_code_size + slice_size, 0, padding);
191 slice->dwSliceBitsInBuffer = 8 * data_size;
192 }
193 if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(ctx->decoder,
194 DXVA2_BitStreamDateBufferType)))
195 return -1;
196 if (result)
197 return result;
198
199 memset(bs, 0, sizeof(*bs));
200 bs->CompressedBufferType = DXVA2_BitStreamDateBufferType;
201 bs->DataSize = data_size;
202 bs->NumMBsInBuffer = s->mb_width * s->mb_height;
203 assert((bs->DataSize & 127) == 0);
204
205 return ff_dxva2_commit_buffer(avctx, ctx, sc,
206 DXVA2_SliceControlBufferType,
207 slice, sizeof(*slice), bs->NumMBsInBuffer);
208}
209
210static int start_frame(AVCodecContext *avctx,
211 av_unused const uint8_t *buffer,

Callers

nothing calls this directly

Calls 1

ff_dxva2_commit_bufferFunction · 0.85

Tested by

no test coverage detected