From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 82A2C48C40 for ; Thu, 22 Feb 2024 19:21:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7000668BF87; Thu, 22 Feb 2024 21:21:49 +0200 (EET) Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4133B68BECE for ; Thu, 22 Feb 2024 21:21:42 +0200 (EET) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-41275855dc4so640845e9.0 for ; Thu, 22 Feb 2024 11:21:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20230601.gappssmtp.com; s=20230601; t=1708629701; x=1709234501; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Rr4eis9U/04ELtj9d/TMtqWNfwAelUFL73UUk4s4Bak=; b=ti0y/vbVbwBGNzoNtRR0k3B5Ui68Z3aumfuqygf9GecWIxq/ZQ+oMp3uKIT8GJf7Uc RADje0LmBToQM2AQaixIK/jRIwjEPl4KCXjdzE+IOsWF3mpIvnyXi8+PJta0E8c55ias IfS+0gfvssXiVa47L57aNtJ1XDCNKwK1gXjGSs489r/sVF7OBYCajLeMwXViIs1IWEB/ 2Z2bSlEfcsFYJBn6MODLV11NK+XTPY8CwhGXuRbIHzntPmqnZKtjmc6OPHwwNPGSP1a9 ikcd6yFLR/JrMMsrnnvPq3cBwNRq47p7+gNAp/WdWhwlpQyC2Tm/eBMYeXNobuE9IPHD l7og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708629701; x=1709234501; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Rr4eis9U/04ELtj9d/TMtqWNfwAelUFL73UUk4s4Bak=; b=K7Vl7hDiYMspMkSL8o35CNvTer1wudwBm4FwrX0myOU+yo4rg/YFlQanJaux6w+ige ZWJCO7FCAmlCdbNWGfwGuKn1bTQmNfZYIgl0nXhTxm/Q3L6F5s1TZJbITWF+9e9JZDY3 jAR+W1d1HNRbfhLpYbHNDvE18c0gH68NU4jqOiq5iP32xFUFqepLTRoM84Eha30gPYaU am6sWZuB5FdFWuwHhnZ+RgOCV2QvKVoaPuKaXbvDL81AobwbQCTPHUjYUhkpaWILAz47 NySK3XMt7SH9JkuqOXJu8kBensJlou7PNIF8sfodHW8KZ0otTcqecWbMuk5q5cp7Zd1L lPtw== X-Gm-Message-State: AOJu0YzdvcsVynPRCeLiAacroaTEK5gsoaR7WgrTgucfhv+XJExtj0nS prNbhQwRA06unqXuHSvOgg/9b8JAlwdNfmx4S2xvEL296rbw2A6M05KxJduUgspwunjg/1dT2A8 N X-Google-Smtp-Source: AGHT+IFZB1gxLH5QXL9jO+refqy2qI+6g4RigxPzYUD+o2VmrBqU3R06B69Z2xxsfrwGuGXRkocjZA== X-Received: by 2002:a05:600c:1910:b0:412:8fef:9947 with SMTP id j16-20020a05600c191000b004128fef9947mr490978wmq.41.1708629701256; Thu, 22 Feb 2024 11:21:41 -0800 (PST) Received: from [192.168.0.15] (cpc92302-cmbg19-2-0-cust1183.5-4.cable.virginm.net. [82.1.212.160]) by smtp.gmail.com with ESMTPSA id t12-20020a5d460c000000b0033b48190e5esm21322594wrq.67.2024.02.22.11.21.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 11:21:40 -0800 (PST) Message-ID: <2cc1de88-09a9-41ff-b6fb-686e81027254@jkqxz.net> Date: Thu, 22 Feb 2024 19:22:08 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240218084529.554-1-tong1.wu@intel.com> <20240218084529.554-4-tong1.wu@intel.com> From: Mark Thompson In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH v5 4/9] avcodec/vaapi_encode: extract rc parameter configuration to base layer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 >>> >>> VAAPI and D3D12VA can share rate control configuration codes. Hence, it >>> can be moved to base layer for simplification. >>> >>> Signed-off-by: Tong Wu >>> --- >>> 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".