Another overflow fix.
authorTim Terriberry <tterribe@xiph.org>
Wed, 4 May 2011 19:27:58 +0000 (19:27 +0000)
committerTim Terriberry <tterribe@xiph.org>
Wed, 4 May 2011 19:27:58 +0000 (19:27 +0000)
This extends the fix from r17276 dealing with the removal of the DC
 skip-prevention flag in r17174.
If we allow SKIPing even when the cost is right near the maximum
 representable SSD, then the cost of other blocks can push it over
 the edge, causing us to randomly skip a block halfway through the
 macroblock.

svn path=/trunk/theora/; revision=17959

lib/analyze.c

index d0d42f4..19d7612 100644 (file)
@@ -1866,7 +1866,7 @@ static void oc_analyze_mb_mode_luma(oc_enc_ctx *_enc,
         best_qii=qii;
       }
     }
-    if(_skip_ssd[bi]<(UINT_MAX>>OC_BIT_SCALE)&&nskipped<3){
+    if(_skip_ssd[bi]<(UINT_MAX>>OC_BIT_SCALE+2)&&nskipped<3){
       *(ft+1)=*&fr;
       oc_fr_skip_block(ft+1);
       cur_overhead=ft[1].bits-fr.bits<<OC_BIT_SCALE;
@@ -1947,7 +1947,7 @@ static void oc_analyze_mb_mode_chroma(oc_enc_ctx *_enc,
           best_qii=qii;
         }
       }
-      if(_skip_ssd[bi]<(UINT_MAX>>OC_BIT_SCALE)){
+      if(_skip_ssd[bi]<(UINT_MAX>>OC_BIT_SCALE+2)){
         cur_ssd=_skip_ssd[bi]<<OC_BIT_SCALE;
         cur_cost=OC_MODE_RD_COST(ssd+cur_ssd,rate,lambda);
         if(cur_cost<=best_cost){