Commit 383f62fd authored by Loren Merritt's avatar Loren Merritt

Snow: 10l. 1pass ratecontrol failed to set snow's internal quant.

Originally committed as revision 5426 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent b29183a1
...@@ -3912,6 +3912,11 @@ static int common_init(AVCodecContext *avctx){ ...@@ -3912,6 +3912,11 @@ static int common_init(AVCodecContext *avctx){
return 0; 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) static void ratecontrol_1pass(SnowContext *s, AVFrame *pict)
{ {
/* estimate the frame's complexity as a sum of weighted dwt coefs. /* estimate the frame's complexity as a sum of weighted dwt coefs.
...@@ -3955,6 +3960,7 @@ static void ratecontrol_1pass(SnowContext *s, AVFrame *pict) ...@@ -3955,6 +3960,7 @@ static void ratecontrol_1pass(SnowContext *s, AVFrame *pict)
pict->quality= ff_rate_estimate_qscale(&s->m, 1); pict->quality= ff_rate_estimate_qscale(&s->m, 1);
s->lambda= pict->quality * 3/2; s->lambda= pict->quality * 3/2;
s->qlog= qscale2qlog(pict->quality);
} }
static void calculate_vissual_weight(SnowContext *s, Plane *p){ static void calculate_vissual_weight(SnowContext *s, Plane *p){
...@@ -4016,7 +4022,7 @@ static int encode_init(AVCodecContext *avctx) ...@@ -4016,7 +4022,7 @@ static int encode_init(AVCodecContext *avctx)
if(!avctx->stats_out) if(!avctx->stats_out)
avctx->stats_out = av_mallocz(256); 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) if(ff_rate_control_init(&s->m) < 0)
return -1; return -1;
} }
...@@ -4138,9 +4144,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, ...@@ -4138,9 +4144,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
if(s->pass1_rc && avctx->frame_number == 0) if(s->pass1_rc && avctx->frame_number == 0)
pict->quality= 2*FF_QP2LAMBDA; pict->quality= 2*FF_QP2LAMBDA;
if(pict->quality){ if(pict->quality){
s->qlog= rint(QROOT*log(pict->quality / (float)FF_QP2LAMBDA)/log(2)); s->qlog= qscale2qlog(pict->quality);
//<64 >60
s->qlog += 61*QROOT/8;
s->lambda = pict->quality * 3/2; s->lambda = pict->quality * 3/2;
} }
if(s->qlog < 0 || (!pict->quality && (avctx->flags & CODEC_FLAG_QSCALE))){ if(s->qlog < 0 || (!pict->quality && (avctx->flags & CODEC_FLAG_QSCALE))){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment