changeset 4218:4f82f2aaff7f libavcodec

infiinit loop fix for CBR + adaptive quant
author michael
date Mon, 20 Nov 2006 11:53:02 +0000
parents 8e1cafaeb6a1
children 58dba449406c
files mpegvideo.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mpegvideo.c	Mon Nov 20 10:48:23 2006 +0000
+++ b/mpegvideo.c	Mon Nov 20 11:53:02 2006 +0000
@@ -2552,6 +2552,11 @@
 
             if(put_bits_count(&s->pb) > max_size && s->lambda < s->avctx->lmax){
                 s->next_lambda= FFMAX(s->lambda+1, s->lambda*(s->qscale+1) / s->qscale);
+                if(s->adaptive_quant){
+                    int i;
+                    for(i=0; i<s->mb_height*s->mb_width; i++)
+                        s->lambda_table[i]= FFMAX(s->lambda_table[i]+1, s->lambda_table[i]*(s->qscale+1) / s->qscale);
+                }
                 s->mb_skipped = 0;        //done in MPV_frame_start()
                 if(s->pict_type==P_TYPE){ //done in encode_picture() so we must undo it
                     if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)