Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Wu, Tong1" <tong1.wu-at-intel.com@ffmpeg.org>
To: Wu Jianhua <toqsxw@outlook.com>,
	"ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v3 8/9] avcodec: add D3D12VA hardware HEVC encoder
Date: Thu, 8 Feb 2024 07:40:31 +0000
Message-ID: <CH3PR11MB8659349C851F6FA4AB010F57C0442@CH3PR11MB8659.namprd11.prod.outlook.com> (raw)
In-Reply-To: <OSZP286MB217348658BAA3E168827B11FCA472@OSZP286MB2173.JPNP286.PROD.OUTLOOK.COM>

>> 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_CONFI
>GURATION_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_CONFI
>GURATION_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.

Have updated in v4. Thanks for the review.

BRs,
Tong

_______________________________________________
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".

  reply	other threads:[~2024-02-08  7:41 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   ` [FFmpeg-devel] 回复: " Wu Jianhua
2024-02-08  7:40     ` Wu, Tong1 [this message]
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=CH3PR11MB8659349C851F6FA4AB010F57C0442@CH3PR11MB8659.namprd11.prod.outlook.com \
    --to=tong1.wu-at-intel.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=toqsxw@outlook.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