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 8/9] avcodec: add D3D12VA hardware HEVC encoder
Date: Tue, 23 Jan 2024 05:52:16 +0000
Message-ID: <CH3PR11MB865909DEF762A9340A8C54FCC0742@CH3PR11MB8659.namprd11.prod.outlook.com> (raw)
In-Reply-To: <TYWP286MB2172C563CC4A1BE6D2F31CF2CA752@TYWP286MB2172.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      |  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?
>

Will update in V2 thanks for the review.

Thanks,
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-01-23  5:52 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   ` [FFmpeg-devel] 回复: " Wu Jianhua
2024-01-23  5:52     ` Wu, Tong1 [this message]
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=CH3PR11MB865909DEF762A9340A8C54FCC0742@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