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 6180644143 for ; Mon, 29 Aug 2022 12:58:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A948D68BA36; Mon, 29 Aug 2022 15:58:42 +0300 (EEST) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D97268B889 for ; Mon, 29 Aug 2022 15:58:36 +0300 (EEST) Received: by mail-pj1-f47.google.com with SMTP id n65-20020a17090a5ac700b001fbb4fad865so8472318pji.1 for ; Mon, 29 Aug 2022 05:58:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc; bh=Sk9ZANgXKL22Nnexf6O4/cjV04kc5WxG95fc/mbKQZI=; b=CQTsuEeBSRbU8pvzPOvI0mTRjbJleDdLd9q+vRq3Cs/K6+Ifzqirx/j4NQtc0XIcUl 9rdtbbXjshMx5z+T4EbVDJrGsue9NJmrtpPl/q9WvaPNLa7KrjUFemuWfaQRy29U0ONz uHSMHvlfoeD3D1b6eWfTPC43Sshx3Q4C04R0zavoS3/6C/eo31KEv5ry7SUeBN7dwSMV peWhONAL/5uBcD1bf7ikgar3dUYDZ34L54Zrl1CeflQsxpYyoGFIyeB3y+cA2Fbdeaf4 2Rgug2ixMxn9UjcH+jWg68UWeYfKAjAcwWTbbmEb+aFrwszXeblcPFva70Ep9T1qOejS x3Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc; bh=Sk9ZANgXKL22Nnexf6O4/cjV04kc5WxG95fc/mbKQZI=; b=G87ohsV4a8scrIDTq+ptlPj2bRHI6wv3kTgr2l2vT3JubQzfevzhw7c01UETKLaAvH 8xPccsCgRSxJrXlGt3F+T5Kjdwwqo1AxwQ9PNT5f8i9AQ4vny43NwNbHJBe4Mb5pxByz 01QAqXn7qsT26PufzaQW7P4CS86BRDj5lNFxT1j94jysCYTFri69o5NyUwqqw+WeNd/F 3Xv5R/VQEXnY/njy65Kn1vLNbBwIeEuj0zi0HHrs2QlUjsU26Li/0yQwdm9hi5MUiwbh RNyuTBDlvQACaNf9v4gj7iMiwXrvQiRhxpipu3wDElYx42mPtIzOq+VGORP6ssssu9wq JiOg== X-Gm-Message-State: ACgBeo00UuVpdzfNDepJ62KSMtShcrkfnnz15iVCJBHFzE9+U76yVqXH +L1WfbhsO1ijVj/LGvhG9IR/VbYPC/ps0UOtV5mpKb62PvE= X-Google-Smtp-Source: AA6agR43Miwwo9ax9IDyW1Inmm6cvZkBfuLS6E2FBfQqU3gGsc8ENzr+mmulkFRS9UeKmk/pTG/KgU9AeaAT8X8fXsw= X-Received: by 2002:a17:90a:5d8a:b0:1f7:3c7a:9cc7 with SMTP id t10-20020a17090a5d8a00b001f73c7a9cc7mr18500562pji.207.1661777914487; Mon, 29 Aug 2022 05:58:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rick Kern Date: Mon, 29 Aug 2022 08:58:23 -0400 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH v3] avcodec/videotoolboxenc: Add CBR option to H264 and HEVC encoder 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, Aug 28, 2022 at 4:27 PM Sebastian Beckmann < beckmann.sebastian@outlook.de> wrote: > Adds an option to use constant bitrate instead of average bitrate to the > videotoolbox encoders. This is enabled via -constant_bit_rate true. > macOS 13 is required for this option to work. > > Signed-off-by: Sebastian Beckmann > --- > Removed the hard-coded check for Apple Silicon CPUs. > > libavcodec/videotoolboxenc.c | 27 ++++++++++++++++++++++++--- > 1 file changed, 24 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c > index 823e5ad94e..9de86cc4d9 100644 > --- a/libavcodec/videotoolboxenc.c > +++ b/libavcodec/videotoolboxenc.c > @@ -101,6 +101,7 @@ static struct{ > CFStringRef kVTCompressionPropertyKey_RealTime; > CFStringRef kVTCompressionPropertyKey_TargetQualityForAlpha; > CFStringRef > kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality; > + CFStringRef kVTCompressionPropertyKey_ConstantBitRate; > > CFStringRef > kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder; > CFStringRef > kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder; > @@ -164,6 +165,7 @@ static void loadVTEncSymbols(){ > "TargetQualityForAlpha"); > GET_SYM(kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality, > "PrioritizeEncodingSpeedOverQuality"); > + GET_SYM(kVTCompressionPropertyKey_ConstantBitRate, "ConstantBitRate"); > > > GET_SYM(kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, > "EnableHardwareAcceleratedVideoEncoder"); > @@ -236,6 +238,7 @@ typedef struct VTEncContext { > int realtime; > int frames_before; > int frames_after; > + bool constant_bit_rate; > > int allow_sw; > int require_sw; > @@ -1079,6 +1082,7 @@ static int vtenc_create_encoder(AVCodecContext > *avctx, > CFNumberRef gamma_level, > CFDictionaryRef enc_info, > CFDictionaryRef pixel_buffer_info, > + bool constant_bit_rate, > VTCompressionSessionRef *session) > { > VTEncContext *vtctx = avctx->priv_data; > @@ -1139,9 +1143,20 @@ static int vtenc_create_encoder(AVCodecContext > *avctx, > &bit_rate); > if (!bit_rate_num) return AVERROR(ENOMEM); > > - status = VTSessionSetProperty(vtctx->session, > - > kVTCompressionPropertyKey_AverageBitRate, > - bit_rate_num); > + if (constant_bit_rate) { > + status = VTSessionSetProperty(vtctx->session, > + > compat_keys.kVTCompressionPropertyKey_ConstantBitRate, > + bit_rate_num); > + if (status == kVTPropertyNotSupportedErr) { > + av_log(avctx, AV_LOG_ERROR, "Error: -constant_bit_rate > true is not supported by the encoder.\n"); > + return AVERROR_EXTERNAL; > + } > + } else { > + status = VTSessionSetProperty(vtctx->session, > + > kVTCompressionPropertyKey_AverageBitRate, > + bit_rate_num); > + } > + > CFRelease(bit_rate_num); > } > > @@ -1530,6 +1545,7 @@ static int vtenc_configure_encoder(AVCodecContext > *avctx) > gamma_level, > enc_info, > pixel_buffer_info, > + vtctx->constant_bit_rate, > &vtctx->session); > > init_cleanup: > @@ -2532,6 +2548,7 @@ static int vtenc_populate_extradata(AVCodecContext > *avctx, > gamma_level, > enc_info, > pixel_buffer_info, > + vtctx->constant_bit_rate, > &vtctx->session); > if (status) > goto pe_cleanup; > @@ -2727,6 +2744,8 @@ static const AVOption h264_options[] = { > > { "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc), > AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE }, > > + { "constant_bit_rate", "Require constant bit rate (macOS 13 or > newer)", OFFSET(constant_bit_rate), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, > VE }, > + > COMMON_OPTIONS > { NULL }, > }; > @@ -2760,6 +2779,8 @@ static const AVOption hevc_options[] = { > > { "alpha_quality", "Compression quality for the alpha channel", > OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE }, > > + { "constant_bit_rate", "Require constant bit rate (macOS 13 or > newer)", OFFSET(constant_bit_rate), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, > VE }, > + > COMMON_OPTIONS > { NULL }, > }; > -- > 2.37.0 (Apple Git-136) > The patch doesn't apply. Can you create a .patch file with git format-patch and send the file as an attachment? Sometimes email clients/providers corrupt inline patches. The error message is: git am ~/Downloads/\[FFmpeg-devel\]\ \[PATCH\ v3\]\ avcodec_videotoolboxenc_\ Add\ CBR\ option\ to\ H264\ and\ HEVC\ encoder.eml Applying: avcodec/videotoolboxenc: Add CBR option to H264 and HEVC encoder error: corrupt patch at line 41 Patch failed at 0001 avcodec/videotoolboxenc: Add CBR option to H264 and HEVC encoder hint: Use 'git am --show-current-patch' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". > > _______________________________________________ > 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". > _______________________________________________ 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".