35 return frame->
data[3];
45 for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++)
46 if (DXVA_CONTEXT_SURFACE(avctx, ctx, i) == surface)
66 hr = ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
69 &dxva_size, &dxva_data);
73 hr = IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->
decoder, type,
74 &dxva_data, &dxva_size);
81 if (size <= dxva_size) {
82 memcpy(dxva_data, data, size);
86 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = dsc;
87 memset(dsc11, 0,
sizeof(*dsc11));
88 dsc11->BufferType =
type;
89 dsc11->DataSize =
size;
90 dsc11->NumMBsInBuffer = mb_count;
95 DXVA2_DecodeBufferDesc *dsc2 = dsc;
96 memset(dsc2, 0,
sizeof(*dsc2));
97 dsc2->CompressedBufferType =
type;
98 dsc2->DataSize =
size;
99 dsc2->NumMBsInBuffer = mb_count;
111 hr = ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder, type);
115 hr = IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->
decoder, type);
119 "Failed to release buffer type %u: 0x%lx\n",
127 const void *pp,
unsigned pp_size,
128 const void *qm,
unsigned qm_size,
134 unsigned buffer_count = 0;
136 D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4];
139 DXVA2_DecodeBufferDesc buffer2[4];
142 int result, runs = 0;
149 hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder,
155 hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->
decoder,
161 }
while (hr == E_PENDING && ++runs < 50);
170 buffer = &buffer11[buffer_count];
171 type = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS;
176 buffer = &buffer2[buffer_count];
177 type = DXVA2_PictureParametersBufferType;
185 "Failed to add picture parameter buffer\n");
193 buffer = &buffer11[buffer_count];
194 type = D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX;
199 buffer = &buffer2[buffer_count];
200 type = DXVA2_InverseQuantizationMatrixBufferType;
208 "Failed to add inverse quantization matrix buffer\n");
216 buffer = &buffer11[buffer_count + 0];
217 buffer_slice = &buffer11[buffer_count + 1];
222 buffer = &buffer2[buffer_count + 0];
223 buffer_slice = &buffer2[buffer_count + 1];
227 result = commit_bs_si(avctx,
232 "Failed to add bitstream or slice control buffer\n");
239 assert(buffer_count == 1 + (qm_size > 0) + 2);
243 hr = ID3D11VideoContext_SubmitDecoderBuffers(D3D11VA_CONTEXT(ctx)->video_context,
245 buffer_count, buffer11);
249 DXVA2_DecodeExecuteParams exec = {
250 .NumCompBuffers = buffer_count,
251 .pCompressedBuffers = buffer2,
252 .pExtensionData =
NULL,
254 hr = IDirectXVideoDecoder_Execute(DXVA2_CONTEXT(ctx)->
decoder, &exec);
265 hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder);
269 hr = IDirectXVideoDecoder_EndFrame(DXVA2_CONTEXT(ctx)->
decoder,
NULL);
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int av_usleep(unsigned usec)
Sleep for a period of time.
void * ff_dxva2_get_surface(const AVFrame *frame)
void * hwaccel_context
Hardware accelerator context.
static av_cold int end(AVCodecContext *avctx)
int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int(*commit_bs_si)(AVCodecContext *, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Libavcodec external API header.
static const chunk_decoder decoder[8]
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame)
main external API structure.
int ff_dxva2_commit_buffer(AVCodecContext *avctx, AVDXVAContext *ctx, DECODER_BUFFER_DESC *dsc, unsigned type, const void *data, unsigned size, unsigned mb_count)
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
HW decoding through Direct3D11, Picture.data[3] contains a ID3D11VideoDecoderOutputView pointer...