[FFmpeg-devel] [PATCH v2 2/9] avcodec: add D3D12VA hardware accelerated H264 decoding

Wu, Tong1 tong1.wu at intel.com
Thu Jun 1 14:23:32 EEST 2023


>
>On Wed, May 31, 2023 at 11:07:15AM +0800, Tong Wu wrote:
>> From: Wu Jianhua <toqsxw at outlook.com>
>>
>> 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 at outlook.com>
>> Signed-off-by: Tong Wu <tong1.wu at intel.com>
>> ---
>>  configure                   |   2 +
>>  libavcodec/Makefile         |   3 +
>>  libavcodec/d3d11va.h        |   3 -
>>  libavcodec/d3d12va.c        | 552 ++++++++++++++++++++++++++++++++++++
>>  libavcodec/d3d12va.h        | 184 ++++++++++++
>>  libavcodec/d3d12va_h264.c   | 210 ++++++++++++++
>>  libavcodec/dxva2.c          |  24 ++
>>  libavcodec/dxva2.h          |   3 -
>>  libavcodec/dxva2_h264.c     |  12 +-
>>  libavcodec/dxva2_internal.h |  69 +++--
>>  libavcodec/h264_slice.c     |   4 +
>>  libavcodec/h264dec.c        |   3 +
>>  libavcodec/hwaccels.h       |   1 +
>>  libavcodec/hwconfig.h       |   2 +
>>  14 files changed, 1030 insertions(+), 42 deletions(-)
>>  create mode 100644 libavcodec/d3d12va.c
>>  create mode 100644 libavcodec/d3d12va.h
>>  create mode 100644 libavcodec/d3d12va_h264.c
>
>seems to break build on mingw64 here

Thanks, will fix in V3.


> make
>CC	libavcodec/dxva2.o
>In file included from src/libavcodec/dxva2.c:33:0:
>src/libavcodec/dxva2.c: In function ‘ff_dxva2_get_surface_index’:
>src/libavcodec/dxva2_internal.h:48:43: error: pasting "." and "surface_count"
>does not give a valid preprocessing token
> #define D3D11VA_VAR(ctx, var) ctx->d3d11va.##var
>                                           ^
>src/libavcodec/dxva2_internal.h:123:114: note: in expansion of macro
>‘D3D11VA_VAR’
> #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)))
>                                                                                                                  ^~~~~~~~~~~
>src/libavcodec/dxva2_internal.h:127:49: note: in expansion of macro
>‘DXVA2_CONTEXT_VAR’
> #define DXVA_CONTEXT_COUNT(avctx, ctx)          DXVA2_CONTEXT_VAR(avctx,
>ctx, surface_count)
>                                                 ^~~~~~~~~~~~~~~~~
>src/libavcodec/dxva2.c:791:21: note: in expansion of macro
>‘DXVA_CONTEXT_COUNT’
>     for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
>                     ^
>In file included from src/libavcodec/dxva2.c:33:0:
>src/libavcodec/dxva2_internal.h:40:39: error: pasting "." and "surface_count"
>does not give a valid preprocessing token
> #define DXVA2_VAR(ctx, var) ctx->dxva2.##var
>                                       ^
>src/libavcodec/dxva2_internal.h:123:139: note: in expansion of macro
>‘DXVA2_VAR’
> #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)))
>
>^~~~~~~~~
>src/libavcodec/dxva2_internal.h:127:49: note: in expansion of macro
>‘DXVA2_CONTEXT_VAR’
> #define DXVA_CONTEXT_COUNT(avctx, ctx)          DXVA2_CONTEXT_VAR(avctx,
>ctx, surface_count)
>                                                 ^~~~~~~~~~~~~~~~~
>src/libavcodec/dxva2.c:791:21: note: in expansion of macro
>‘DXVA_CONTEXT_COUNT’
>     for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
>                     ^
>src/ffbuild/common.mak:81: recipe for target 'libavcodec/dxva2.o' failed
>make: *** [libavcodec/dxva2.o] Error 1
>
>[...]
>
>--
>Michael     GnuPG fingerprint:
>9FF2128B147EF6730BADF133611EC787040B0FAB
>
>There will always be a question for which you do not know the correct answer.


More information about the ffmpeg-devel mailing list