34 return frame->
data[3];
44 for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
48 D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
49 ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], &viewDesc);
50 return viewDesc.Texture2D.ArraySlice;
76 hr = ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
79 &dxva_size, &dxva_data);
83 hr = IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->
decoder, type,
84 &dxva_data, &dxva_size);
91 if (size <= dxva_size) {
92 memcpy(dxva_data, data, size);
96 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = dsc;
97 memset(dsc11, 0,
sizeof(*dsc11));
98 dsc11->BufferType =
type;
99 dsc11->DataSize =
size;
100 dsc11->NumMBsInBuffer = mb_count;
105 DXVA2_DecodeBufferDesc *dsc2 = dsc;
106 memset(dsc2, 0,
sizeof(*dsc2));
107 dsc2->CompressedBufferType =
type;
108 dsc2->DataSize =
size;
109 dsc2->NumMBsInBuffer = mb_count;
121 hr = ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder, type);
125 hr = IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->
decoder, type);
129 "Failed to release buffer type %u: 0x%lx\n",
137 const void *pp,
unsigned pp_size,
138 const void *qm,
unsigned qm_size,
144 unsigned buffer_count = 0;
146 D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4];
149 DXVA2_DecodeBufferDesc buffer2[4];
152 int result, runs = 0;
160 WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE,
FALSE);
161 hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder,
168 hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->
decoder,
172 if (hr != E_PENDING || ++runs > 50)
177 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
187 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
194 buffer = &buffer11[buffer_count];
195 type = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS;
200 buffer = &buffer2[buffer_count];
201 type = DXVA2_PictureParametersBufferType;
209 "Failed to add picture parameter buffer\n");
217 buffer = &buffer11[buffer_count];
218 type = D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX;
223 buffer = &buffer2[buffer_count];
224 type = DXVA2_InverseQuantizationMatrixBufferType;
232 "Failed to add inverse quantization matrix buffer\n");
240 buffer = &buffer11[buffer_count + 0];
241 buffer_slice = &buffer11[buffer_count + 1];
246 buffer = &buffer2[buffer_count + 0];
247 buffer_slice = &buffer2[buffer_count + 1];
251 result = commit_bs_si(avctx,
256 "Failed to add bitstream or slice control buffer\n");
263 assert(buffer_count == 1 + (qm_size > 0) + 2);
267 hr = ID3D11VideoContext_SubmitDecoderBuffers(D3D11VA_CONTEXT(ctx)->video_context,
269 buffer_count, buffer11);
273 DXVA2_DecodeExecuteParams exec = {
274 .NumCompBuffers = buffer_count,
275 .pCompressedBuffers = buffer2,
276 .pExtensionData =
NULL,
278 hr = IDirectXVideoDecoder_Execute(DXVA2_CONTEXT(ctx)->
decoder, &exec);
289 hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder);
291 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
296 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