diff mbox series

[FFmpeg-devel] Scale libFDK encoder VBR mode with FF_QP2LAMBDA

Message ID 20230222012152.2360157-1-JonHGee@gmail.com
State New
Headers show
Series [FFmpeg-devel] Scale libFDK encoder VBR mode with FF_QP2LAMBDA | expand

Checks

Context Check Description
yinshiyou/commit_msg_loongarch64 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/commit_msg_x86 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

JonHGee Feb. 22, 2023, 1:21 a.m. UTC
VBR mode currently does not account for scaling when using -aq options with libfdk, resulting in clamping to vbr mode 5 whenever a value >0 is provided.  Adjusting for the scaling factor for proper VBR support.

---
 libavcodec/libfdk-aacenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index 54549de473..da211baf51 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -230,7 +230,7 @@  static av_cold int aac_encode_init(AVCodecContext *avctx)
     }
 
     if (avctx->flags & AV_CODEC_FLAG_QSCALE || s->vbr) {
-        int mode = s->vbr ? s->vbr : avctx->global_quality;
+        int mode = s->vbr ? s->vbr : avctx->global_quality / FF_QP2LAMBDA;
         if (mode <  1 || mode > 5) {
             av_log(avctx, AV_LOG_WARNING,
                    "VBR quality %d out of range, should be 1-5\n", mode);