From: Mark Thompson <sw@jkqxz.net> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH v5 4/9] avcodec/vaapi_encode: extract rc parameter configuration to base layer Date: Thu, 22 Feb 2024 19:22:08 +0000 Message-ID: <2cc1de88-09a9-41ff-b6fb-686e81027254@jkqxz.net> (raw) In-Reply-To: <CH3PR11MB8659C0AA30EFA2B0DCDCF070C0562@CH3PR11MB8659.namprd11.prod.outlook.com> On 22/02/2024 10:10, Wu, Tong1 wrote: >> On 18/02/2024 08:45, tong1.wu-at-intel.com@ffmpeg.org wrote: >>> From: Tong Wu <tong1.wu@intel.com> >>> >>> VAAPI and D3D12VA can share rate control configuration codes. Hence, it >>> can be moved to base layer for simplification. >>> >>> Signed-off-by: Tong Wu <tong1.wu@intel.com> >>> --- >>> libavcodec/hw_base_encode.c | 151 ++++++++++++++++++++++++ >>> libavcodec/hw_base_encode.h | 34 ++++++ >>> libavcodec/vaapi_encode.c | 210 ++++++--------------------------- >>> libavcodec/vaapi_encode.h | 14 +-- >>> libavcodec/vaapi_encode_av1.c | 2 +- >>> libavcodec/vaapi_encode_h264.c | 2 +- >>> libavcodec/vaapi_encode_vp9.c | 2 +- >>> 7 files changed, 227 insertions(+), 188 deletions(-) >>> >>> ... >>> diff --git a/libavcodec/hw_base_encode.h b/libavcodec/hw_base_encode.h >>> index b836b22e6b..4072b514d3 100644 >>> --- a/libavcodec/hw_base_encode.h >>> +++ b/libavcodec/hw_base_encode.h >>> @@ -72,6 +72,37 @@ enum { >>> RC_MODE_MAX = RC_MODE_AVBR, >>> }; >>> >>> +typedef struct HWBaseEncodeRCMode { >>> + // Mode from above enum (RC_MODE_*). >>> + int mode; >>> + // Name. >>> + const char *name; >>> + // Uses bitrate parameters. >>> + int bitrate; >>> + // Supports maxrate distinct from bitrate. >>> + int maxrate; >>> + // Uses quality value. >>> + int quality; >>> + // Supports HRD/VBV parameters. >>> + int hrd; >>> +} HWBaseEncodeRCMode; >>> + >>> +typedef struct HWBaseEncodeRCConfigure >>> +{ >>> + int64_t rc_bits_per_second; >>> + int rc_target_percentage; >>> + int rc_window_size; >>> + >>> + int rc_quality; >>> + >>> + int64_t hrd_buffer_size; >>> + int64_t hrd_initial_buffer_fullness; >>> + >>> + int fr_num; >>> + int fr_den; >>> +} HWBaseEncodeRCConfigure; >> >> The set of fields here needs more thought to match up the common parts of >> the APIs. >> >> Just have target rate and maxrate and let VAAPI deal with the percentage stuff >> maybe? Not sure what to do with window_size which isn't present at all in >> D3D12. The convergence/accuracy stuff for VAAPI AVBR is also unclear. >> > > Could you please explain more about your thoughts on why the percentage stuff should not be in the common part? I think D3D12 can share the same code in terms of percentage stuff and hrd stuff. I can let VAAPI do the AVBR stuff and remove window_size from common part and keep everything else as-is. The libavcodec API is a better match for D3D12 than VAAPI is: e.g. for D3D12 VBR you have TargetAvgBitRate = AVCodecContext.bit_rate, PeakBitRate = AVCodecContext.rc_max_rate etc. with all fields nicely matching. If you use the VAAPI fields here then you are translating the rate into a percentage (with rounding error because it's an integer) and then back again for no reason, hence I think you should prefer the libavcodec/D3D12 fields and do the conversion for VAAPI in its own code. >> (Do you know why QVBR is missing the VBV parameters in D3D12? On the face >> of it that doesn't make any sense, but maybe I'm missing something.) >> > > It is presented in QVBR1 structure(defined in DirectX-header but not yet in Windows SDK). > I can add this support afterwards maybe along with AV1 implementation. Ah, so it was a bug and has been fixed. That's good! >>> + >>> + >>> typedef struct HWBaseEncodePicture { >>> struct HWBaseEncodePicture *next; >>> >>> @@ -242,6 +273,9 @@ int >> ff_hw_base_encode_set_output_property(AVCodecContext *avctx, >> HWBaseEncodePic >>> >>> int ff_hw_base_encode_receive_packet(AVCodecContext *avctx, AVPacket >> *pkt); >>> >>> +int ff_hw_base_rc_mode_configure(AVCodecContext *avctx, const >> HWBaseEncodeRCMode *rc_mode, >>> + int default_quality, HWBaseEncodeRCConfigure *rc_conf); >>> + >>> int ff_hw_base_encode_init(AVCodecContext *avctx); >>> >>> int ff_hw_base_encode_close(AVCodecContext *avctx); >>> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c >>> ... >> >> Thanks, >> >> - Mark > > Thanks for your review and I'll reply to your comments regarding D3D12 HEVC encoder patch later since there're indeed a lot of stuff you pointed out that I need to take care of again. Sure, thank you! - Mark _______________________________________________ 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-22 19:21 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-02-18 8:45 [FFmpeg-devel] [PATCH v5 1/9] avcodec/vaapi_encode: move pic->input_surface initialization to encode_alloc tong1.wu-at-intel.com 2024-02-18 8:45 ` [FFmpeg-devel] [PATCH v5 2/9] avcodec/vaapi_encode: introduce a base layer for vaapi encode tong1.wu-at-intel.com 2024-02-18 19:34 ` Mark Thompson 2024-02-22 9:53 ` Wu, Tong1 2024-02-18 8:45 ` [FFmpeg-devel] [PATCH v5 3/9] avcodec/vaapi_encode: extract set_output_property to base layer tong1.wu-at-intel.com 2024-02-18 8:45 ` [FFmpeg-devel] [PATCH v5 4/9] avcodec/vaapi_encode: extract rc parameter configuration " tong1.wu-at-intel.com 2024-02-18 19:50 ` Mark Thompson 2024-02-22 10:10 ` Wu, Tong1 2024-02-22 19:22 ` Mark Thompson [this message] 2024-02-26 9:06 ` Wu, Tong1 2024-02-18 8:45 ` [FFmpeg-devel] [PATCH v5 5/9] avcodec/vaapi_encode: extract gop " tong1.wu-at-intel.com 2024-02-18 8:45 ` [FFmpeg-devel] [PATCH v5 6/9] avcodec/vaapi_encode: extract a get_recon_format function " tong1.wu-at-intel.com 2024-02-18 8:45 ` [FFmpeg-devel] [PATCH v5 7/9] avutil/hwcontext_d3d12va: add Flags for resource creation tong1.wu-at-intel.com 2024-02-18 8:45 ` [FFmpeg-devel] [PATCH v5 8/9] avcodec: add D3D12VA hardware HEVC encoder tong1.wu-at-intel.com 2024-02-18 21:22 ` Mark Thompson 2024-02-26 10:21 ` Wu, Tong1 2024-02-18 8:45 ` [FFmpeg-devel] [PATCH v5 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=2cc1de88-09a9-41ff-b6fb-686e81027254@jkqxz.net \ --to=sw@jkqxz.net \ --cc=ffmpeg-devel@ffmpeg.org \ /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