diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-02-14 13:37:58 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-02-14 13:37:58 +0000 |
commit | e9a4834a7da195365b194b2f084f0d1654878628 (patch) | |
tree | a60f6cc888dca88fad406320f9e275b3c3b80ee1 | |
parent | fafbc7c8c8605ee25c9616ae19fec2eacd79d28f (diff) | |
download | ffmpeg-e9a4834a7da195365b194b2f084f0d1654878628.tar.gz |
normalize adaptive quantizatiuon fix (based upon a patch by (Jindrich Makovicka <makovick at kmlinux dot fjfi dot cvut dot cz>))
Originally committed as revision 2780 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/ratecontrol.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 6c90b1b6cd..473645def4 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -545,9 +545,10 @@ static void adaptive_quantization(MpegEncContext *s, double q){ /* handle qmin/qmax cliping */ if(s->flags&CODEC_FLAG_NORMALIZE_AQP){ + float factor= bits_sum/cplx_sum; for(i=0; i<s->mb_num; i++){ float newq= q*cplx_tab[i]/bits_tab[i]; - newq*= bits_sum/cplx_sum; + newq*= factor; if (newq > qmax){ bits_sum -= bits_tab[i]; @@ -558,6 +559,8 @@ static void adaptive_quantization(MpegEncContext *s, double q){ cplx_sum -= cplx_tab[i]*q/qmin; } } + if(bits_sum < 0.001) bits_sum= 0.001; + if(cplx_sum < 0.001) cplx_sum= 0.001; } for(i=0; i<s->mb_num; i++){ |