changeset 3322:0b4f548dfb44 libavcodec

Snow: 10l. 1pass ratecontrol failed to set snow's internal quant.
author lorenm
date Tue, 30 May 2006 04:51:58 +0000
parents 8869b4dd2ffe
children 87c54a3f8d19
files snow.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/snow.c	Mon May 29 22:44:16 2006 +0000
+++ b/snow.c	Tue May 30 04:51:58 2006 +0000
@@ -3912,6 +3912,11 @@
     return 0;
 }
 
+static int qscale2qlog(int qscale){
+    return rint(QROOT*log(qscale / (float)FF_QP2LAMBDA)/log(2))
+           + 61*QROOT/8; //<64 >60
+}
+
 static void ratecontrol_1pass(SnowContext *s, AVFrame *pict)
 {
     /* estimate the frame's complexity as a sum of weighted dwt coefs.
@@ -3955,6 +3960,7 @@
 
     pict->quality= ff_rate_estimate_qscale(&s->m, 1);
     s->lambda= pict->quality * 3/2;
+    s->qlog= qscale2qlog(pict->quality);
 }
 
 static void calculate_vissual_weight(SnowContext *s, Plane *p){
@@ -4016,7 +4022,7 @@
         if(!avctx->stats_out)
             avctx->stats_out = av_mallocz(256);
     }
-    if(!(avctx->flags&CODEC_FLAG_QSCALE)){
+    if((avctx->flags&CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){
         if(ff_rate_control_init(&s->m) < 0)
             return -1;
     }
@@ -4138,9 +4144,7 @@
     if(s->pass1_rc && avctx->frame_number == 0)
         pict->quality= 2*FF_QP2LAMBDA;
     if(pict->quality){
-        s->qlog= rint(QROOT*log(pict->quality / (float)FF_QP2LAMBDA)/log(2));
-        //<64 >60
-        s->qlog += 61*QROOT/8;
+        s->qlog= qscale2qlog(pict->quality);
         s->lambda = pict->quality * 3/2;
     }
     if(s->qlog < 0 || (!pict->quality && (avctx->flags & CODEC_FLAG_QSCALE))){