> 发件人: ffmpeg-devel <[email protected]> 代表
> [email protected] <[email protected]>
> 发送时间: 2024年1月21日 21:57
> 收件人: [email protected]
> 抄送: Tong Wu
> 主题: [FFmpeg-devel] [PATCH 8/9] avcodec: add D3D12VA hardware HEVC encoder
>
> From: Tong Wu <[email protected]>
>
> This implementation is based on D3D12 Video Encoding Spec:
> https://microsoft.github.io/DirectX-Specs/d3d/D3D12VideoEncoding.html
>
> Sample command line for transcoding:
> ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4
> -c:v hevc_d3d12va output.mp4
>
> Signed-off-by: Tong Wu <[email protected]>
> ---
> configure | 6 +
> libavcodec/Makefile | 4 +-
> libavcodec/allcodecs.c | 1 +
> libavcodec/d3d12va_encode.c | 1441 ++++++++++++++++++++++++++++++
> libavcodec/d3d12va_encode.h | 200 +++++
> libavcodec/d3d12va_encode_hevc.c | 1016 +++++++++++++++++++++
> libavcodec/hw_base_encode.h | 2 +-
> 7 files changed, 2668 insertions(+), 2 deletions(-)
> create mode 100644 libavcodec/d3d12va_encode.c
> create mode 100644 libavcodec/d3d12va_encode.h
> create mode 100644 libavcodec/d3d12va_encode_hevc.c
> + D3D12_OBJECT_RELEASE(ctx->sync_ctx.fence);
> + if (ctx->sync_ctx.event)
> + CloseHandle(ctx->sync_ctx.event);
> +
> + D3D12_OBJECT_RELEASE(ctx->video_device3);
> + D3D12_OBJECT_RELEASE(ctx->device);
> + D3D12_OBJECT_RELEASE(ctx->encoder_heap);
> + D3D12_OBJECT_RELEASE(ctx->encoder);
We need to release all of the objects, including the encoder and encoder_heap,
created by the device before releasing the device.
> +
> +typedef struct D3D12VAEncodeProfile {
> + //lavc profile value (AV_PROFILE_*).
> + int av_profile;
> + //Supported bit depth.
> + int depth;
> + //Number of components.
> + int nb_components;
> + //Chroma subsampling in width dimension.
> + int log2_chroma_w;
> + //Chroma subsampling in height dimension.
> + int log2_chroma_h;
> + //D3D12 profile value.
> + D3D12_VIDEO_ENCODER_PROFILE_DESC d3d12_profile;
> +} D3D12VAEncodeProfile;
> +
> +typedef struct D3D12VAEncodeRCMode {
> + // Base.
> + HWBaseEncodeRCMode base;
> + // Supported by D3D12 HW.
> + int supported;
> + // D3D12 mode value.
> + D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE d3d12_mode;
> +} D3D12VAEncodeRCMode;
> +
> +typedef struct D3D12VAEncodeContext {
> + HWBaseEncodeContext base;
> +
> + //Codec-specific hooks.
> + const struct D3D12VAEncodeType *codec;
> +
> + //Chosen encoding profile details.
> + const D3D12VAEncodeProfile *profile;
> +
> + //Chosen rate control mode details.
> + const D3D12VAEncodeRCMode *rc_mode;
> +
> + AVD3D12VADeviceContext *hwctx;
> +
> + //Device3 interface.
> + ID3D12Device3 *device3;
> +
> + ID3D12VideoDevice3 *video_device3;
> +
> + //Pool of (reusable) bitstream output buffers.
> + AVBufferPool *output_buffer_pool;
> +
> + //D3D12 video encoder.
> + AVBufferRef *encoder_ref;
> +
> + ID3D12VideoEncoder *encoder;
> +
> + //D3D12 video encoder heap.
> + ID3D12VideoEncoderHeap *encoder_heap;
> +
> + //A cached queue for reusing the D3D12 command allocators.
> + //@see
> https://learn.microsoft.com/en-us/windows/win32/direct3d12/recording-command-lists-and-bundles#id3d12commandallocator
> + AVFifo *allocator_queue;
> +
> + //D3D12 command queue.
> + ID3D12CommandQueue *command_queue;
> +
> + //D3D12 video encode command list.
> + ID3D12VideoEncodeCommandList2 *command_list;
> +
> + //The sync context used to sync command queue.
> + AVD3D12VASyncContext sync_ctx;
> +
> + //bi_not_empty feature.
> + int bi_not_empty;
> +
> + //D3D12 hardware structures.
> + D3D12_VIDEO_ENCODER_PICTURE_RESOLUTION_DESC resolution;
> +
> + D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION codec_conf;
> +
> + D3D12_VIDEO_ENCODER_RATE_CONTROL rc;
> +
> + D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOURCE_REQUIREMENTS req;
> +
> + D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE GOP;
> +
> + D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOLUTION_SUPPORT_LIMITS res_limits;
> +
> + D3D12_VIDEO_ENCODER_LEVEL_SETTING level;
> +} D3D12VAEncodeContext;
> +
Can we use the comment style the same as D3D12VADecodeContext?
_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".