[FFmpeg-cvslog] avcodec/libvpxenc: enable dynamic max quantizer reconfiguration

Danil Chapovalov git at videolan.org
Wed Apr 6 04:04:11 EEST 2022


ffmpeg | branch: master | Danil Chapovalov <danilchap-at-google.com at ffmpeg.org> | Wed Mar 30 20:24:32 2022 +0200| [706f12992dbe22617ba0406cfff09201bc905b4e] | committer: James Zern

avcodec/libvpxenc: enable dynamic max quantizer reconfiguration

Signed-off-by: James Zern <jzern at google.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=706f12992dbe22617ba0406cfff09201bc905b4e
---

 doc/encoders.texi      |  3 +++
 libavcodec/libvpxenc.c | 10 ++++++++++
 libavcodec/version.h   |  2 +-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 4b8cc69c0d..a304f865a6 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1996,8 +1996,11 @@ kilobits/s.
 @item keyint_min (@emph{kf-min-dist})
 
 @item qmin (@emph{min-q})
+Minimum (Best Quality) Quantizer.
 
 @item qmax (@emph{max-q})
+Maximum (Worst Quality) Quantizer.
+Can be changed per-frame.
 
 @item bufsize (@emph{buf-sz}, @emph{buf-optimal-sz})
 Set ratecontrol buffer size (in bits). Note @command{vpxenc}'s options are
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 7438ad87a3..e35b47b87e 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -1629,6 +1629,16 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt,
     vpx_svc_layer_id_t layer_id;
     int layer_id_valid = 0;
 
+    if (avctx->qmax >= 0 && enccfg->rc_max_quantizer != avctx->qmax) {
+        struct vpx_codec_enc_cfg cfg = *enccfg;
+        cfg.rc_max_quantizer = avctx->qmax;
+        res = vpx_codec_enc_config_set(&ctx->encoder, &cfg);
+        if (res != VPX_CODEC_OK) {
+            log_encoder_error(avctx, "Error reconfiguring encoder");
+            return AVERROR_INVALIDDATA;
+        }
+    }
+
     if (frame) {
         const AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_REGIONS_OF_INTEREST);
         rawimg                      = &ctx->rawimg;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index a744e7469f..aa3a484c51 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 #include "version_major.h"
 
 #define LIBAVCODEC_VERSION_MINOR  25
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list