34 return frame->
data[3];
44 for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++)
45 if (DXVA_CONTEXT_SURFACE(avctx, ctx, i) == surface)
65 hr = ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
68 &dxva_size, &dxva_data);
72 hr = IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->
decoder, type,
73 &dxva_data, &dxva_size);
80 if (size <= dxva_size) {
81 memcpy(dxva_data, data, size);
85 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = dsc;
86 memset(dsc11, 0,
sizeof(*dsc11));
87 dsc11->BufferType =
type;
88 dsc11->DataSize =
size;
89 dsc11->NumMBsInBuffer = mb_count;
94 DXVA2_DecodeBufferDesc *dsc2 = dsc;
95 memset(dsc2, 0,
sizeof(*dsc2));
96 dsc2->CompressedBufferType =
type;
97 dsc2->DataSize =
size;
98 dsc2->NumMBsInBuffer = mb_count;
110 hr = ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder, type);
114 hr = IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->
decoder, type);
118 "Failed to release buffer type %u: 0x%lx\n",
126 const void *pp,
unsigned pp_size,
127 const void *qm,
unsigned qm_size,
133 unsigned buffer_count = 0;
135 D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4];
138 DXVA2_DecodeBufferDesc buffer2[4];
141 int result, runs = 0;
149 WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE,
FALSE);
150 hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder,
157 hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->
decoder,
161 if (hr != E_PENDING || ++runs > 50)
166 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
176 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
183 buffer = &buffer11[buffer_count];
184 type = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS;
189 buffer = &buffer2[buffer_count];
190 type = DXVA2_PictureParametersBufferType;
198 "Failed to add picture parameter buffer\n");
206 buffer = &buffer11[buffer_count];
207 type = D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX;
212 buffer = &buffer2[buffer_count];
213 type = DXVA2_InverseQuantizationMatrixBufferType;
221 "Failed to add inverse quantization matrix buffer\n");
229 buffer = &buffer11[buffer_count + 0];
230 buffer_slice = &buffer11[buffer_count + 1];
235 buffer = &buffer2[buffer_count + 0];
236 buffer_slice = &buffer2[buffer_count + 1];
240 result = commit_bs_si(avctx,
245 "Failed to add bitstream or slice control buffer\n");
252 assert(buffer_count == 1 + (qm_size > 0) + 2);
256 hr = ID3D11VideoContext_SubmitDecoderBuffers(D3D11VA_CONTEXT(ctx)->video_context,
258 buffer_count, buffer11);
262 DXVA2_DecodeExecuteParams exec = {
263 .NumCompBuffers = buffer_count,
264 .pCompressedBuffers = buffer2,
265 .pExtensionData =
NULL,
267 hr = IDirectXVideoDecoder_Execute(DXVA2_CONTEXT(ctx)->
decoder, &exec);
278 hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder);
280 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
285 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.
static const chunk_decoder decoder[8]
Libavcodec external API header.
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...
#define INVALID_HANDLE_VALUE