Commit e9a4834a authored by Michael Niedermayer's avatar Michael Niedermayer

normalize adaptive quantizatiuon fix (based upon a patch by (Jindrich...

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
parent fafbc7c8
......@@ -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++){
......
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