34 return frame->
data[3];
46 D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
47 ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) surface, &viewDesc);
48 return viewDesc.Texture2D.ArraySlice;
52 for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
75 hr = ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
78 &dxva_size, &dxva_data);
82 hr = IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->
decoder, type,
83 &dxva_data, &dxva_size);
90 if (size <= dxva_size) {
91 memcpy(dxva_data, data, size);
95 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = dsc;
96 memset(dsc11, 0,
sizeof(*dsc11));
97 dsc11->BufferType =
type;
98 dsc11->DataSize =
size;
99 dsc11->NumMBsInBuffer = mb_count;
104 DXVA2_DecodeBufferDesc *dsc2 = dsc;
105 memset(dsc2, 0,
sizeof(*dsc2));
106 dsc2->CompressedBufferType =
type;
107 dsc2->DataSize =
size;
108 dsc2->NumMBsInBuffer = mb_count;
120 hr = ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder, type);
124 hr = IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->
decoder, type);
128 "Failed to release buffer type %u: 0x%lx\n",
136 const void *pp,
unsigned pp_size,
137 const void *qm,
unsigned qm_size,
143 unsigned buffer_count = 0;
145 D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4];
148 DXVA2_DecodeBufferDesc buffer2[4];
151 int result, runs = 0;
159 WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE,
FALSE);
160 hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder,
167 hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->
decoder,
171 if (hr != E_PENDING || ++runs > 50)
176 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
186 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
193 buffer = &buffer11[buffer_count];
194 type = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS;
199 buffer = &buffer2[buffer_count];
200 type = DXVA2_PictureParametersBufferType;
208 "Failed to add picture parameter buffer\n");
216 buffer = &buffer11[buffer_count];
217 type = D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX;
222 buffer = &buffer2[buffer_count];
223 type = DXVA2_InverseQuantizationMatrixBufferType;
231 "Failed to add inverse quantization matrix buffer\n");
239 buffer = &buffer11[buffer_count + 0];
240 buffer_slice = &buffer11[buffer_count + 1];
245 buffer = &buffer2[buffer_count + 0];
246 buffer_slice = &buffer2[buffer_count + 1];
250 result = commit_bs_si(avctx,
255 "Failed to add bitstream or slice control buffer\n");
262 assert(buffer_count == 1 + (qm_size > 0) + 2);
266 hr = ID3D11VideoContext_SubmitDecoderBuffers(D3D11VA_CONTEXT(ctx)->video_context,
268 buffer_count, buffer11);
272 DXVA2_DecodeExecuteParams exec = {
273 .NumCompBuffers = buffer_count,
274 .pCompressedBuffers = buffer2,
275 .pExtensionData =
NULL,
277 hr = IDirectXVideoDecoder_Execute(DXVA2_CONTEXT(ctx)->
decoder, &exec);
288 hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->
decoder);
290 ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
295 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 * 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.
static void * get_surface(const AVFrame *frame)
HW decoding through Direct3D11, Picture.data[3] contains a ID3D11VideoDecoderOutputView pointer...
#define INVALID_HANDLE_VALUE