Commit 24425de7 authored by michael's avatar michael

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>))


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@2780 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 91ce0997
...@@ -545,9 +545,10 @@ static void adaptive_quantization(MpegEncContext *s, double q){ ...@@ -545,9 +545,10 @@ static void adaptive_quantization(MpegEncContext *s, double q){
/* handle qmin/qmax cliping */ /* handle qmin/qmax cliping */
if(s->flags&CODEC_FLAG_NORMALIZE_AQP){ if(s->flags&CODEC_FLAG_NORMALIZE_AQP){
float factor= bits_sum/cplx_sum;
for(i=0; i<s->mb_num; i++){ for(i=0; i<s->mb_num; i++){
float newq= q*cplx_tab[i]/bits_tab[i]; float newq= q*cplx_tab[i]/bits_tab[i];
newq*= bits_sum/cplx_sum; newq*= factor;
if (newq > qmax){ if (newq > qmax){
bits_sum -= bits_tab[i]; bits_sum -= bits_tab[i];
...@@ -558,6 +559,8 @@ static void adaptive_quantization(MpegEncContext *s, double q){ ...@@ -558,6 +559,8 @@ static void adaptive_quantization(MpegEncContext *s, double q){
cplx_sum -= cplx_tab[i]*q/qmin; 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++){ 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