The branch, release/8.0 has been updated
       via  b9dd25b80aa52ba93f17827015688edd686194b8 (commit)
       via  0ca188e0d683d857a8d2815b4efc7ab5cb1c3bf7 (commit)
       via  d3265e15eef9522f11c44e68063ecf157eb12e8b (commit)
       via  a2179be5e9ee20cafd81d07bd7e98d5bd2532a00 (commit)
      from  4f8b3891ee0f3a9ed1d6064ebce1305f190d42ed (commit)


- Log -----------------------------------------------------------------
commit b9dd25b80aa52ba93f17827015688edd686194b8
Author:     Zhao Zhili <[email protected]>
AuthorDate: Wed Sep 10 20:29:47 2025 +0800
Commit:     Marvin Scholz <[email protected]>
CommitDate: Mon Sep 15 12:25:00 2025 +0000

    avcodec/videotoolboxenc: ensure bitrate is set in low_delay mode
    
    VideoToolbox doesn't support automatic bitrate in low delay mode.
    Check bitrate and show error message so user knows what's going
    wrong.
    
    (cherry picked from commit c1dc2e2b7cc8df8a40b616793d1204be0e71103c)
    Signed-off-by: Marvin Scholz <[email protected]>

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index f0d3a15897..729072c0b9 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1711,6 +1711,12 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)
     // low-latency mode: eliminate frame reordering, follow a one-in-one-out 
encoding mode
     if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) &&
         ((avctx->codec_id == AV_CODEC_ID_H264) || (TARGET_CPU_ARM64 && 
avctx->codec_id == AV_CODEC_ID_HEVC))) {
+        if (!avctx->bit_rate) {
+            av_log(avctx, AV_LOG_ERROR, "Doesn't support automatic bitrate in 
low_delay mode, "
+                                        "please specify bitrate explicitly\n");
+            status = AVERROR(EINVAL);
+            goto init_cleanup;
+        }
         CFDictionarySetValue(enc_info,
                              
compat_keys.kVTVideoEncoderSpecification_EnableLowLatencyRateControl,
                              kCFBooleanTrue);

commit 0ca188e0d683d857a8d2815b4efc7ab5cb1c3bf7
Author:     Cameron Gutman <[email protected]>
AuthorDate: Fri Sep 5 23:42:52 2025 -0500
Commit:     Marvin Scholz <[email protected]>
CommitDate: Mon Sep 15 12:25:00 2025 +0000

    avcodec/videotoolboxenc: allow low latency RC with HEVC
    
    It is supported only for H.264 on Intel Macs, but it can be used with
    both H.264 and HEVC on Apple Silicon.
    
    Signed-off-by: Cameron Gutman <[email protected]>
    (cherry picked from commit d87210745e09f6d55a7e43f70bf9d8f81b5f739a)
    Signed-off-by: Marvin Scholz <[email protected]>

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index e423da6933..f0d3a15897 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1709,7 +1709,8 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)
 #endif
 
     // low-latency mode: eliminate frame reordering, follow a one-in-one-out 
encoding mode
-    if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) && avctx->codec_id == 
AV_CODEC_ID_H264) {
+    if ((avctx->flags & AV_CODEC_FLAG_LOW_DELAY) &&
+        ((avctx->codec_id == AV_CODEC_ID_H264) || (TARGET_CPU_ARM64 && 
avctx->codec_id == AV_CODEC_ID_HEVC))) {
         CFDictionarySetValue(enc_info,
                              
compat_keys.kVTVideoEncoderSpecification_EnableLowLatencyRateControl,
                              kCFBooleanTrue);

commit d3265e15eef9522f11c44e68063ecf157eb12e8b
Author:     Zhao Zhili <[email protected]>
AuthorDate: Mon Sep 1 01:36:25 2025 +0800
Commit:     Marvin Scholz <[email protected]>
CommitDate: Mon Sep 15 12:25:00 2025 +0000

    avcodec/videotoolboxenc: support global_quality without qscale
    
    (cherry picked from commit fc45127bcc79731a2e3ec5858a00c35c6cfbc1c0)
    Signed-off-by: Marvin Scholz <[email protected]>

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index c3704810d2..e423da6933 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1245,8 +1245,10 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
         return AVERROR_EXTERNAL;
     }
 
-    if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
-        Float32 quality = fminf(avctx->global_quality / 100.0f / FF_QP2LAMBDA, 
1.0f);
+    if (avctx->flags & AV_CODEC_FLAG_QSCALE || avctx->global_quality > 0) {
+        float factor = (avctx->flags & AV_CODEC_FLAG_QSCALE) ?
+                       FF_QP2LAMBDA * 100.0f : 100.0f;
+        Float32 quality = fminf(avctx->global_quality / factor, 1.0f);
         CFNumberRef quality_num = CFNumberCreate(kCFAllocatorDefault,
                                                  kCFNumberFloat32Type,
                                                  &quality);

commit a2179be5e9ee20cafd81d07bd7e98d5bd2532a00
Author:     Zhao Zhili <[email protected]>
AuthorDate: Mon Sep 1 01:17:08 2025 +0800
Commit:     Marvin Scholz <[email protected]>
CommitDate: Mon Sep 15 12:25:00 2025 +0000

    avcodec/videotoolboxenc: fix the loss of precision when calculating quality
    
    (cherry picked from commit 73750489a67dcf99a6142009edfe45f504d55e8e)
    Signed-off-by: Marvin Scholz <[email protected]>

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index b748ecda61..c3704810d2 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1185,9 +1185,7 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
     VTEncContext *vtctx = avctx->priv_data;
     SInt32       bit_rate = avctx->bit_rate;
     SInt32       max_rate = avctx->rc_max_rate;
-    Float32      quality = avctx->global_quality / FF_QP2LAMBDA;
     CFNumberRef  bit_rate_num;
-    CFNumberRef  quality_num;
     CFNumberRef  bytes_per_second;
     CFNumberRef  one_second;
     CFArrayRef   data_rate_limits;
@@ -1248,10 +1246,10 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
     }
 
     if (avctx->flags & AV_CODEC_FLAG_QSCALE) {
-        quality = quality >= 100 ? 1.0 : quality / 100;
-        quality_num = CFNumberCreate(kCFAllocatorDefault,
-                                     kCFNumberFloat32Type,
-                                     &quality);
+        Float32 quality = fminf(avctx->global_quality / 100.0f / FF_QP2LAMBDA, 
1.0f);
+        CFNumberRef quality_num = CFNumberCreate(kCFAllocatorDefault,
+                                                 kCFNumberFloat32Type,
+                                                 &quality);
         if (!quality_num) return AVERROR(ENOMEM);
 
         status = VTSessionSetProperty(vtctx->session,

-----------------------------------------------------------------------

Summary of changes:
 libavcodec/videotoolboxenc.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)


hooks/post-receive
-- 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to