[FFmpeg-devel] [PATCH] libvpx: allow setting 0 for min quantizer

slhck werner.robitza at gmail.com
Mon Feb 25 13:27:46 CET 2013


Allow setting 0 for min quantizer in libvpx. Check whether CQ level is within correct
bounds and throw error if not. Fixes #2136.
---
 libavcodec/libvpxenc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index a749e07..8d5a7ee 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -285,10 +285,17 @@ static av_cold int vpx_init(AVCodecContext *avctx,
         }
     }
 
-    if (avctx->qmin > 0)
+    if (avctx->qmin >= 0)
         enccfg.rc_min_quantizer = avctx->qmin;
-    if (avctx->qmax > 0)
+    if (avctx->qmax > 0 && avctx->qmax > avctx->qmin)
         enccfg.rc_max_quantizer = avctx->qmax;
+    if (ctx->crf < enccfg.rc_min_quantizer || ctx->crf > enccfg.rc_max_quantizer) {
+        av_log(avctx, AV_LOG_ERROR,
+               "CQ level must be between minimum and maximum quantizer value (%d-%d)\n",
+               enccfg.rc_min_quantizer, enccfg.rc_max_quantizer);
+        return AVERROR(EINVAL);
+    }
+
     enccfg.rc_dropframe_thresh = avctx->frame_skip_threshold;
 
     //0-100 (0 => CBR, 100 => VBR)
-- 
1.8.1.4



More information about the ffmpeg-devel mailing list