aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dxva2.c
diff options
context:
space:
mode:
authorWu Jianhua <toqsxw@outlook.com>2023-12-05 14:46:44 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2023-12-21 16:15:23 +0800
commit349ce30e4ea3ded1e776270976d291d2adec608d (patch)
treefa26217b10e857ac39ee6447b86b1e3c84e8f50f /libavcodec/dxva2.c
parent142f727b9ca21c95414536074e3f89c687271dd4 (diff)
downloadffmpeg-349ce30e4ea3ded1e776270976d291d2adec608d.tar.gz
avcodec: add D3D12VA hardware accelerated H264 decoding
The implementation is based on: https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12-video-overview With the Direct3D 12 video decoding support, we can render or process the decoded images by the pixel shaders or compute shaders directly without the extra copy overhead, which is beneficial especially if you are trying to render or post-process a 4K or 8K video. The command below is how to enable d3d12va: ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4 Signed-off-by: Wu Jianhua <toqsxw@outlook.com> Signed-off-by: Tong Wu <tong1.wu@intel.com>
Diffstat (limited to 'libavcodec/dxva2.c')
-rw-r--r--libavcodec/dxva2.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index d7bc587562..7160a0008b 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -768,12 +768,17 @@ static void *get_surface(const AVCodecContext *avctx, const AVFrame *frame)
}
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
- const AVDXVAContext *ctx,
- const AVFrame *frame)
+ AVDXVAContext *ctx, const AVFrame *frame,
+ int curr)
{
void *surface = get_surface(avctx, frame);
unsigned i;
+#if CONFIG_D3D12VA
+ if (avctx->pix_fmt == AV_PIX_FMT_D3D12) {
+ return ff_d3d12va_get_surface_index(avctx, (D3D12VADecodeContext *)ctx, frame, curr);
+ }
+#endif
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11)
return (intptr_t)frame->data[1];
@@ -1056,3 +1061,23 @@ int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
else
return 0;
}
+
+unsigned *ff_dxva2_get_report_id(const AVCodecContext *avctx, AVDXVAContext *ctx)
+{
+ unsigned *report_id = NULL;
+
+#if CONFIG_D3D12VA
+ if (avctx->pix_fmt == AV_PIX_FMT_D3D12)
+ report_id = &ctx->d3d12va.report_id;
+#endif
+#if CONFIG_D3D11VA
+ if (ff_dxva2_is_d3d11(avctx))
+ report_id = &ctx->d3d11va.report_id;
+#endif
+#if CONFIG_DXVA2
+ if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
+ report_id = &ctx->dxva2.report_id;
+#endif
+
+ return report_id;
+}