Go to the documentation of this file.
23 #ifndef AVCODEC_DXVA2_INTERNAL_H
24 #define AVCODEC_DXVA2_INTERNAL_H
29 #include "config_components.h"
34 #define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1
35 #define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2
40 #define DXVA2_VAR(ctx, var) ctx->dxva2.var
42 #define DXVA2_VAR(ctx, var) 0
48 #define D3D11VA_VAR(ctx, var) ctx->d3d11va.var
50 #define D3D11VA_VAR(ctx, var) 0
61 #define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
62 #undef _CRT_BUILD_DESKTOP_APP
63 #define _CRT_BUILD_DESKTOP_APP 0
98 ID3D11VideoDecoder *d3d11_decoder;
99 D3D11_VIDEO_DECODER_CONFIG d3d11_config;
100 ID3D11VideoDecoderOutputView **d3d11_views;
102 ID3D11Texture2D *d3d11_texture;
106 IDirectXVideoDecoder *dxva2_decoder;
107 IDirectXVideoDecoderService *dxva2_service;
108 DXVA2_ConfigPictureDecode dxva2_config;
116 #define DXVA_SHARED_CONTEXT(avctx) ((FFDXVASharedContext *)((avctx)->internal->hwaccel_priv_data))
118 #define DXVA_CONTEXT(avctx) (AVDXVAContext *)((avctx)->hwaccel_context ? (avctx)->hwaccel_context : (&(DXVA_SHARED_CONTEXT(avctx)->ctx)))
120 #define D3D11VA_CONTEXT(ctx) (&ctx->d3d11va)
121 #define DXVA2_CONTEXT(ctx) (&ctx->dxva2)
123 #define DXVA2_CONTEXT_VAR(avctx, ctx, var) (avctx->pix_fmt == AV_PIX_FMT_D3D12 ? 0 : (ff_dxva2_is_d3d11(avctx) ? D3D11VA_VAR(ctx, var) : DXVA2_VAR(ctx, var)))
125 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*ff_dxva2_get_report_id(avctx, ctx))
126 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) DXVA2_CONTEXT_VAR(avctx, ctx, workaround)
127 #define DXVA_CONTEXT_COUNT(avctx, ctx) DXVA2_CONTEXT_VAR(avctx, ctx, surface_count)
128 #define DXVA_CONTEXT_DECODER(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D12 ? 0 : (ff_dxva2_is_d3d11(avctx) ? (void *)D3D11VA_VAR(ctx, decoder) : (void *)DXVA2_VAR(ctx, decoder)))
129 #define DXVA_CONTEXT_CFG(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D12 ? 0 : (ff_dxva2_is_d3d11(avctx) ? (void *)D3D11VA_VAR(ctx, cfg) : (void *)DXVA2_VAR(ctx, cfg)))
130 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) DXVA2_CONTEXT_VAR(avctx, ctx, cfg->ConfigBitstreamRaw)
131 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) DXVA2_CONTEXT_VAR(avctx, ctx, cfg->ConfigIntraResidUnsigned)
132 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) DXVA2_CONTEXT_VAR(avctx, ctx, cfg->ConfigResidDiffAccelerator)
133 #define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \
134 DXVA_CONTEXT_CFG(avctx, ctx) && \
135 (ff_dxva2_is_d3d11(avctx) || DXVA2_VAR(ctx, surface_count)))
153 const void *pp,
unsigned pp_size,
154 const void *qm,
unsigned qm_size,
174 #if CONFIG_HEVC_D3D12VA_HWACCEL || CONFIG_HEVC_D3D11VA_HWACCEL || CONFIG_HEVC_D3D11VA2_HWACCEL || CONFIG_HEVC_DXVA2_HWACCEL
180 #if CONFIG_VP9_D3D12VA_HWACCEL || CONFIG_VP9_D3D11VA_HWACCEL || CONFIG_VP9_D3D11VA2_HWACCEL || CONFIG_VP9_DXVA2_HWACCEL
184 #if CONFIG_AV1_D3D12VA_HWACCEL || CONFIG_AV1_D3D11VA_HWACCEL || CONFIG_AV1_D3D11VA2_HWACCEL || CONFIG_AV1_DXVA2_HWACCEL
AVPixelFormat
Pixel format.
void ff_dxva2_hevc_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_HEVC *pp)
enum AVPixelFormat pix_fmt
This structure describes decoded (raw) audio or video data.
unsigned * ff_dxva2_get_report_id(const AVCodecContext *avctx, AVDXVAContext *ctx)
int ff_dxva2_common_end_frame(AVCodecContext *, AVFrame *, 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))
unsigned ff_d3d12va_get_surface_index(const AVCodecContext *avctx, D3D12VADecodeContext *ctx, const AVFrame *frame, int curr)
int ff_dxva2_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
AVHWDeviceContext * device_ctx
void ff_dxva2_mpeg2_fill_quantization_matrices(AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_QmatrixData *qm)
This structure is used to provides the necessary configurations and data to the Direct3D11 FFmpeg HWA...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
void ff_dxva2_mpeg2_fill_picture_parameters(AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PictureParameters *pp)
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
void ff_dxva2_vc1_fill_picture_parameters(AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PictureParameters *pp)
void ff_dxva2_h264_fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_Qmatrix_H264 *qm)
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, AVDXVAContext *, const AVFrame *frame, int curr)
int ff_dxva2_decode_init(AVCodecContext *avctx)
void ff_dxva2_hevc_fill_scaling_lists(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_Qmatrix_HEVC *qm)
This structure is used to provides the necessary configurations and data to the DXVA2 FFmpeg HWAccel ...
void ff_dxva2_vc1_fill_slice(AVCodecContext *avctx, DXVA_SliceInfo *slice, unsigned position, unsigned size)
void ff_dxva2_mpeg2_fill_slice(AVCodecContext *avctx, DXVA_SliceInfo *slice, unsigned position, const uint8_t *buffer, unsigned size)
int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
int ff_dxva2_commit_buffer(AVCodecContext *, AVDXVAContext *, DECODER_BUFFER_DESC *, unsigned type, const void *data, unsigned size, unsigned mb_count)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int ff_dxva2_vp9_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_VP9 *pp)
main external API structure.
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
void ff_dxva2_h264_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_H264 *pp)
int ff_dxva2_av1_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_AV1 *pp)
A reference to a data buffer.
This structure is used to provide the necessary configurations and data to the FFmpeg Direct3D 12 HWA...
AVBufferRef * decoder_ref
int ff_dxva2_decode_uninit(AVCodecContext *avctx)