mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
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
This commit is contained in:
parent
fafbc7c8c8
commit
e9a4834a7d
@ -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){
|
|||||||
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++){
|
||||||
|
Loading…
Reference in New Issue
Block a user