From: Wu Jianhua <toqsxw@outlook.com>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Cc: Tong Wu <tong1.wu@intel.com>
Subject: [FFmpeg-devel] 回复: [PATCH 8/9] avcodec: add D3D12VA hardware HEVC encoder
Date: Mon, 22 Jan 2024 15:51:25 +0000
Message-ID: <TYWP286MB2172C563CC4A1BE6D2F31CF2CA752@TYWP286MB2172.JPNP286.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240122055756.1142-8-tong1.wu@intel.com>
> 发件人: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> 代表 tong1.wu-at-intel.com@ffmpeg.org <tong1.wu-at-intel.com@ffmpeg.org>
> 发送时间: 2024年1月21日 21:57
> 收件人: ffmpeg-devel@ffmpeg.org
> 抄送: Tong Wu
> 主题: [FFmpeg-devel] [PATCH 8/9] avcodec: add D3D12VA hardware HEVC encoder
>
> From: Tong Wu <tong1.wu@intel.com>
>
> 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 <tong1.wu@intel.com>
> ---
> 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
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2024-01-22 15:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 5:57 [FFmpeg-devel] [PATCH 1/9] avcodec/vaapi_encode: move pic->input_surface initialization to encode_alloc tong1.wu-at-intel.com
2024-01-22 5:57 ` [FFmpeg-devel] [PATCH 2/9] avcodec/vaapi_encode: introduce a base layer for vaapi encode tong1.wu-at-intel.com
2024-01-22 5:57 ` [FFmpeg-devel] [PATCH 3/9] avcodec/vaapi_encode: extract set_output_property to base layer tong1.wu-at-intel.com
2024-01-22 5:57 ` [FFmpeg-devel] [PATCH 4/9] avcodec/vaapi_encode: extract rc parameter configuration " tong1.wu-at-intel.com
2024-01-22 5:57 ` [FFmpeg-devel] [PATCH 5/9] avcodec/vaapi_encode: extract gop " tong1.wu-at-intel.com
2024-01-22 5:57 ` [FFmpeg-devel] [PATCH 6/9] avcodec/vaapi_encode: extract a get_recon_format function " tong1.wu-at-intel.com
2024-01-22 5:57 ` [FFmpeg-devel] [PATCH 7/9] avutil/hwcontext_d3d12va: add Flags for resource creation tong1.wu-at-intel.com
2024-01-22 21:52 ` Mark Thompson
2024-01-23 5:40 ` Wu, Tong1
2024-01-22 5:57 ` [FFmpeg-devel] [PATCH 8/9] avcodec: add D3D12VA hardware HEVC encoder tong1.wu-at-intel.com
2024-01-22 15:51 ` Wu Jianhua [this message]
2024-01-23 5:52 ` Wu, Tong1
2024-01-22 5:57 ` [FFmpeg-devel] [PATCH 9/9] Changelog: add D3D12VA HEVC encoder changelog tong1.wu-at-intel.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=TYWP286MB2172C563CC4A1BE6D2F31CF2CA752@TYWP286MB2172.JPNP286.PROD.OUTLOOK.COM \
--to=toqsxw@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=tong1.wu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git