From patchwork Mon May 9 18:47:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 35708 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp3049081pzb; Mon, 9 May 2022 11:47:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+FkjFd5WWhkvJtwOm5RsDq24Iwn2Etor0c7DHlT4SOQUz6g3B/TcVVdaC+GiTzmoJM2mP X-Received: by 2002:a17:906:d54b:b0:6f4:d14b:bb91 with SMTP id cr11-20020a170906d54b00b006f4d14bbb91mr15572430ejc.314.1652122065666; Mon, 09 May 2022 11:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652122065; cv=none; d=google.com; s=arc-20160816; b=xoNmJlg0DhKQWxpS2jgDXOPM45HZXqFL506R/YQ/crJfHd8rTTj1xsnKqkAf4X081f SkW1c1Q0KqKoYI/1mh+3RFo8gduyRmsRFup6j9mQXJOtajQZfk385JZSTvilX+2fISbC CTZAkq3lHeFi8tGTtA1GFEEJY5okvsKEBKvxIKK+tw/ppLr3ryxSJWLWcnL0bsLFBpia /Hwj+OUny/9HYZMlRfgEC6ZqD+blxgBUmEbalzCALCKGU706pbXlDNjFlcQwFt75aCMi tuC+aKNb9CiXHRU447EMIm3BUcEOx5Sfb1NCWD5qgun9mi/w7elcmFkchhe/ScXfLZCB op7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=ZtBPNlFOYAEKjeNgkJ2TkrbhaIcK0M7/VwVG9xOidm0=; b=m+KJfGuX+QwTzey5wO7VqsvxlTb52mbjTPeLaAW6RWcRZ/sZna0mIzxVKJjB2WeUCx FqeYA4Vzk67tp21PaIa/C2S8V3MLdLvkPCdVGn1cZgNCrZIucpBP0984bW6m50c9u9s1 6Q5dkfOxbcCTLgK7iL6eelO/e4QUqmi+bh6s5+j4leuBBJymgSpzH7ohwCbTEJZ1ugcS sLTncQJKRnaTwMskIjLz/jvUxuMpizbKNLJJO6SSAlCYMY2aT+0C50Kah6hQDQ9SPEGi 0MNCY88hjRoqjeEBRy0eX41QdFALWKgUB0fPJyK8rDwYDRnVOxoeyJLW+UmSe81KBsxN Fsfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=RZgicREf; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 3-20020a508e03000000b00427cfacfd62si12400169edw.142.2022.05.09.11.47.44; Mon, 09 May 2022 11:47:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=RZgicREf; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 543CF68B33C; Mon, 9 May 2022 21:47:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 864E668AC70 for ; Mon, 9 May 2022 21:47:35 +0300 (EEST) Received: by mail-lf1-f46.google.com with SMTP id w19so25384260lfu.11 for ; Mon, 09 May 2022 11:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=XHY3FzDFc8py62vBgrHW4WCPxWdmPJ7Y9oTjq5uOiSY=; b=RZgicREfKlDBhpeNlBVW0xTqw6nqty1SvJY7jv+5ajRWo5qUSO6mIrmvx2oSQ3t4O6 7y6ZkADusSvkqtmfuFplfZT4As0n3yRWiyWeP+sMbJtwMA1hnpelNpPHpmfKQzJUu5cc PKy1GNS218/Um+XQCIQoOljQb0vsQHupACk0tIQvhSm8s+WoCg4GyBA/x9jrrxR5kkRa Z+1pdCpVUIHTOI2MJfvNCpc5TaUBVrnvjXWrp/odDsTuC8w1Mp3XqvyaA6HxVWHHZAPu sqbith4xoA72O5PRQ2AVMKUZFNFGGBlMr3PqxwMzx75u9EmZUNvtpWXPNvHqxTweUy21 +0gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=XHY3FzDFc8py62vBgrHW4WCPxWdmPJ7Y9oTjq5uOiSY=; b=5gYRJIr1DjZFnL4JT3pIwN5+yyOBJHFINX7keE5Ih7JrWRR8a7Jh8WbPP+RHzgeBtE W1ReDhcuhe3it3y3y+StgeB0ghY+zyvGYQw/sn25ShzggRBozR3lHz7kzdWLtSqSyMXF jFPxPICkdlUh7qoQn/lfvuCcol4eCqWwuiOfJah/R0tKTXStTRnq1Vy0avN+D//yDFTu pxtUKrMVNarqeDLyljuUBkIJ88r16hsRtiLLeUKuuxZ5HSOC+Kf2JzjzJXcJkyJiCqHu td/H51TqeCYd5Wj2qVzADc9InE0mGy0ljtdrXXQyJ2yyny1WkYdBCKetpPo2khJyTUHh FeCw== X-Gm-Message-State: AOAM530TYNmJv+U1DgqPFM7jlX+NqljIB61D/deJr9d6KmiQFn9kqoOX uRbM7hclIlloMF8pFknRAZcKWLCuTE0= X-Received: by 2002:a05:6512:3f07:b0:464:f20b:a160 with SMTP id y7-20020a0565123f0700b00464f20ba160mr13721204lfa.653.1652122054806; Mon, 09 May 2022 11:47:34 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id 22-20020a05651c009600b0024f3d1dae99sm1893630ljq.33.2022.05.09.11.47.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 11:47:34 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 May 2022 21:47:27 +0300 Message-Id: <20220509184728.10265-1-jeebjp@gmail.com> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/2] avcodec/libsvtav1: update avctx bit rate according to RC mode 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: W2ro+gkJ/ZG6 This way we can filter out the default value for this member, which is nonzero. Bases on the current affairs that bit rate based rate control is nonzero in SVT-AV1. --- libavcodec/libsvtav1.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index b4112004ad..2c4ddd4641 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -297,7 +297,8 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, param->profile = FF_PROFILE_AV1_HIGH; } - avctx->bit_rate = param->target_bit_rate; + avctx->bit_rate = param->rate_control_mode > 0 ? + param->target_bit_rate : 0; return 0; } From patchwork Mon May 9 18:47:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 35709 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp3049128pzb; Mon, 9 May 2022 11:47:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHfIFAZd/XtYR3cUB33vsODyr4Uqga0O/WhpWLdTPA7Y9T/yFuEmzKHR6+T7GEPYG+T9q8 X-Received: by 2002:a17:906:314e:b0:6f0:659:963 with SMTP id e14-20020a170906314e00b006f006590963mr16192426eje.358.1652122074254; Mon, 09 May 2022 11:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652122074; cv=none; d=google.com; s=arc-20160816; b=ibFZyc05B+wUyB6/QOaceoM+koMfQAtim2KmhMsrVEvl1tsrBhGpqHIcUSm/HzUuk8 Ms+NYi950i9EkUmX8q02qUm6EBo63cUT/IliikMhMal9owOCH7iufG2l3QKd2YHfmjdd pnDVnl9R16cYYY/ufbwXlyEokeHNFdMRT52Xtf1EWnUWOsKn3jGhgVqRKRGfcMluzpV3 jBhSj76VAr4v2TkE7KRMAoBE/pfhM2ePkVQxD+KpdJv9qzfN3/0iJjA/OS24EUrpgxlc 2vCe+Km3OMujm4no91V0FClpcWypyvhJH/u8cT7lMti48dgYJog/rS5fcJ/KgotZ52VR FUvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=Sff+hG9Usz/wwu1/UJ99movinjadkkRWB19FAeLJAB4=; b=QRhRbMEf/FSpWlucK8lEp7fR3Tt6Xy+Hj/AUYxhEcBcOd+XuMJtHgg20xb2U81QGUT 2L7q0Vv9Ipzctd6mzOh3125dZRwHAKdUyPYv614N3lSIkveMFNYBEkmrws9RuoTwN8qL RBKal0lL2utBEm/y/PpWy5sw97gNvxcvKzLNvvIDbz7R9Jyvxni79s4FfyIKMkk9WlE6 dUjen9AzYYhX2fhJGSaBp42cKq/ASQ0xV95Lo6XRgAi/oSYQQO+983VKnKuHBVDU805X 678pVrDqAE4XlyzKtNkJY5mYZvTKOg1FtXHTQ96X9RLSguJjjKbeZqr3EM0SnhRGpKIg ShMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=kJbNVnRp; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hc17-20020a170907169100b006f861720e25si10393786ejc.280.2022.05.09.11.47.53; Mon, 09 May 2022 11:47:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=kJbNVnRp; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4D62968AC70; Mon, 9 May 2022 21:47:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EE00F68B33C for ; Mon, 9 May 2022 21:47:35 +0300 (EEST) Received: by mail-lf1-f54.google.com with SMTP id p10so25376942lfa.12 for ; Mon, 09 May 2022 11:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sOX/0vPrp2AxGVixFVtWiVhiw6TZ3PLPLnPjMWrmh6U=; b=kJbNVnRpMJI02xViblCacA69xIhdwB90zq0xsdk0TMJAG2kMh1V59BHu72sh+PO2/v ig9vWxVwZ1uU1YIqXzoQPsYPQLrgagCk+ngnMLE4IzFzInchftQgddkLVYRDefpmdloP MtT8M1vDU676LAD7JxbB07mUtquJRXYlaAGETrycwWo0jv7Mefo3UjDTJE6clfoJwI2i Qz+BmJ8/ndW5pFKWLPbBAONUsChJC5M8ZHOSMr0QLJyJL/dbTfIjqNRu5+LvKq9KYW4w d30j0oCVP2snZc2I+lCVPbEMOY8+2vDAkiRHyrQC85I15gxLKkMQTvc4oN7pbmArr2ws S9uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sOX/0vPrp2AxGVixFVtWiVhiw6TZ3PLPLnPjMWrmh6U=; b=H+4gG4IZJw5Kx1yx37oCRsGrCCKtAwosElP/QrF8bdAVIZhuHPgxP2vpw9t1RaxzeM qS7654EHb0X09Nx61ta5XJykjf4GkvyDDrAPbAYl1TZPMDhjuUB8BBpV7hF0VbeOv2i+ YsEs7YiyTkZjKCAIlIBv1aOr8DxAYtre5JdSrZoIueqktkMhw093sa5ynEeo4WndvcoC AiM0yMYXfbteB+fQW1iaAqrSS8XtlcSqHxUVNXjlSulWOV6CBcqAgVkZ9IRbmOBcrRaO phhCELaO501T6k2JpTyCwfN/PKbO3as2VpqYCIpJDZcCWA9zMscqOKXXRfeBsm/LxRbT l25A== X-Gm-Message-State: AOAM530crAmnazjDdXR0R3341d2xPGeXZBDe5PtQkCpDIKvi0g1Gz/YN Dd09GXbNPHwkl3Dd9duggAAumO7wGeQ= X-Received: by 2002:a05:6512:ace:b0:473:ba5b:8e06 with SMTP id n14-20020a0565120ace00b00473ba5b8e06mr13134836lfu.614.1652122055286; Mon, 09 May 2022 11:47:35 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id 22-20020a05651c009600b0024f3d1dae99sm1893630ljq.33.2022.05.09.11.47.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 11:47:34 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 May 2022 21:47:28 +0300 Message-Id: <20220509184728.10265-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220509184728.10265-1-jeebjp@gmail.com> References: <20220509184728.10265-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/2] avcodec/libsvtav1: signal CPB properties through side data 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 8Ky0D2wncB6i This way values such as maxrate/bufsize can be utilized further down the chain. First, syncs up the max_rate and buffer_size from SVT-AV1 back to avctx, and then in case at least one of the utilized values is nonzero, adds the CPB properties side data. --- libavcodec/libsvtav1.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 2c4ddd4641..d9ebb6aa56 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -297,8 +297,20 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, param->profile = FF_PROFILE_AV1_HIGH; } - avctx->bit_rate = param->rate_control_mode > 0 ? - param->target_bit_rate : 0; + avctx->bit_rate = param->rate_control_mode > 0 ? + param->target_bit_rate : 0; + avctx->rc_max_rate = param->max_bit_rate; + avctx->rc_buffer_size = param->vbv_bufsize; + + if (avctx->bit_rate || avctx->rc_max_rate || avctx->rc_buffer_size) { + AVCPBProperties *cpb_props = ff_add_cpb_side_data(avctx); + if (!cpb_props) + return AVERROR(ENOMEM); + + cpb_props->buffer_size = avctx->rc_buffer_size; + cpb_props->max_bitrate = avctx->rc_max_rate; + cpb_props->avg_bitrate = avctx->bit_rate; + } return 0; }