[FFmpeg-devel] [PATCH 1/2] libvpx: allow setting 0 for min quantizer
slhck
werner.robitza at gmail.com
Mon Feb 25 13:34:29 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
>From 4bd1d4cac81932cde4c3388f9013ddb3d491f14b Mon Sep 17 00:00:00 2001
From: slhck <werner.robitza at gmail.com>
Date: Mon, 25 Feb 2013 13:32:31 +0100
Subject: [PATCH 2/2] libvpx: only check CQ level in CQ mode
---
libavcodec/libvpxenc.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 8d5a7ee..a5df6ee 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -289,11 +289,13 @@ static av_cold int vpx_init(AVCodecContext *avctx,
enccfg.rc_min_quantizer = avctx->qmin;
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);
+ if (enccfg.rc_end_usage == VPX_CQ) {
+ 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;
--
1.8.1.4
More information about the ffmpeg-devel
mailing list