+typedef struct FFDXVASharedContext {
+ AVBufferRef *decoder_ref;
+
+ // FF_DXVA2_WORKAROUND_* flags
+ uint64_t workaround;
+
+ // E.g. AV_PIX_FMT_D3D11 (same as AVCodecContext.pix_fmt, except during init)
+ enum AVPixelFormat pix_fmt;
+
+ AVHWDeviceContext *device_ctx;
+
+#if CONFIG_D3D11VA
+ ID3D11VideoDecoder *d3d11_decoder;
+ D3D11_VIDEO_DECODER_CONFIG d3d11_config;
+ ID3D11VideoDecoderOutputView **d3d11_views;
+ int nb_d3d11_views;
+ ID3D11Texture2D *d3d11_texture;
+#endif
+
+#if CONFIG_DXVA2
+ IDirectXVideoDecoder *dxva2_decoder;
+ IDirectXVideoDecoderService *dxva2_service;
+ DXVA2_ConfigPictureDecode dxva2_config;
+#endif
+
+ // Legacy (but used by code outside of setup)
+ // In generic mode, DXVA_CONTEXT() will return a pointer to this.
+ AVDXVAContext ctx;
+} FFDXVASharedContext;
+
+#define DXVA_SHARED_CONTEXT(avctx) ((FFDXVASharedContext *)((avctx)->internal->hwaccel_priv_data))
+
+#define DXVA_CONTEXT(avctx) (AVDXVAContext *)((avctx)->hwaccel_context ? (avctx)->hwaccel_context : (&(DXVA_SHARED_CONTEXT(avctx)->ctx)))
+