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 v3 8/9] avcodec: add D3D12VA hardware HEVC encoder
Date: Mon, 5 Feb 2024 13:37:02 +0000
Message-ID: <OSZP286MB217348658BAA3E168827B11FCA472@OSZP286MB2173.JPNP286.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20240202101615.382-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年2月2日 2:16
> 收件人: ffmpeg-devel@ffmpeg.org
> 抄送: Tong Wu
> 主题: [FFmpeg-devel] [PATCH v3 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 | 275 ++++++
> libavcodec/d3d12va_encode_hevc.c | 1011 +++++++++++++++++++++
> libavcodec/hw_base_encode.h | 2 +-
> 7 files changed, 2738 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
>
>
>+ min_cu_size = d3d12va_encode_hevc_map_cusize(ctx->codec_conf.pHEVCConfig->MinLumaCodingUnitSize);
>+ max_cu_size = d3d12va_encode_hevc_map_cusize(ctx->codec_conf.pHEVCConfig->MaxLumaCodingUnitSize);
>+ min_tu_size = d3d12va_encode_hevc_map_tusize(ctx->codec_conf.pHEVCConfig->MinLumaTransformUnitSize);
>+ max_tu_size = d3d12va_encode_hevc_map_tusize(ctx->codec_conf.pHEVCConfig->MaxLumaTransformUnitSize);
>+
>+ // VPS
>+
>+ vps->nal_unit_header = (H265RawNALUnitHeader) {
Should this blank line be removed, because the comment is for the codes below?
> + vps->vps_timing_info_present_flag = 0;
> +
> + // SPS
> +
> + sps->nal_unit_header = (H265RawNALUnitHeader) {
> + .nal_unit_type = HEVC_NAL_SPS,
> + .nuh_layer_id = 0,
> + .nuh_temporal_id_plus1 = 1,
> + };
The same as above.
> +static uint8_t d3d12va_encode_hevc_map_cusize(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE cusize)
> +{
> + switch (cusize) {
> + case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_8x8: return 8;
> + case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_16x16: return 16;
> + case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_32x32: return 32;
> + case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_64x64: return 64;
> + }
> + return 0;
> +}
> +
> +static uint8_t d3d12va_encode_hevc_map_tusize(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE tusize)
> +{
> + switch (tusize) {
> + case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_4x4: return 4;
> + case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_8x8: return 8;
> + case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_16x16: return 16;
> + case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_32x32: return 32;
> + }
> + return 0;
> +}
A default branch is needed or we can use 8 << cusize and 4 << tusize for simplification.
> + hr = ID3D12Device3_QueryInterface(ctx->device3, &IID_ID3D12VideoDevice3, (void **)&ctx->video_device3);
> + if (FAILED(hr)) {
> + err = AVERROR_UNKNOWN;
> + goto fail;
> + }
> +
> + if (FAILED(ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_FEATURE_AREA_SUPPORT,
> + &support, sizeof(support))) && !support.VideoEncodeSupport) {
> + av_log(avctx, AV_LOG_ERROR, "D3D12 video device has no video encoder support");
> + err = AVERROR(EINVAL);
> + goto fail;
> + }
We need to output the log for the ID3D12Device3_QueryInterface call, or the user will not know the error is resulting from that,
the OS and the driver don't support the ID3D12VideoDevice3 interface.
_______________________________________________
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-02-05 13:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 10:16 [FFmpeg-devel] [PATCH v3 1/9] avcodec/vaapi_encode: move pic->input_surface initialization to encode_alloc tong1.wu-at-intel.com
2024-02-02 10:16 ` [FFmpeg-devel] [PATCH v3 2/9] avcodec/vaapi_encode: introduce a base layer for vaapi encode tong1.wu-at-intel.com
2024-02-02 10:16 ` [FFmpeg-devel] [PATCH v3 3/9] avcodec/vaapi_encode: extract set_output_property to base layer tong1.wu-at-intel.com
2024-02-02 10:16 ` [FFmpeg-devel] [PATCH v3 4/9] avcodec/vaapi_encode: extract rc parameter configuration " tong1.wu-at-intel.com
2024-02-02 10:16 ` [FFmpeg-devel] [PATCH v3 5/9] avcodec/vaapi_encode: extract gop " tong1.wu-at-intel.com
2024-02-02 10:16 ` [FFmpeg-devel] [PATCH v3 6/9] avcodec/vaapi_encode: extract a get_recon_format function " tong1.wu-at-intel.com
2024-02-02 10:16 ` [FFmpeg-devel] [PATCH v3 7/9] avutil/hwcontext_d3d12va: add Flags for resource creation tong1.wu-at-intel.com
2024-02-02 10:16 ` [FFmpeg-devel] [PATCH v3 8/9] avcodec: add D3D12VA hardware HEVC encoder tong1.wu-at-intel.com
2024-02-05 13:37 ` Wu Jianhua [this message]
2024-02-08 7:40 ` Wu, Tong1
2024-02-02 10:16 ` [FFmpeg-devel] [PATCH v3 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=OSZP286MB217348658BAA3E168827B11FCA472@OSZP286MB2173.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