[xiph-commits] r17346 - experimental/derf/theora-ptalarbvorm/lib

tterribe at svn.xiph.org tterribe at svn.xiph.org
Fri Jul 23 08:30:44 PDT 2010


Author: tterribe
Date: 2010-07-23 08:30:43 -0700 (Fri, 23 Jul 2010)
New Revision: 17346

Modified:
   experimental/derf/theora-ptalarbvorm/lib/analyze.c
Log:
Improved version of the fix in r17345.
This adds the min check to intra analysis as well, and bumps up the minimum to
 avoid the divide by zero check.


Modified: experimental/derf/theora-ptalarbvorm/lib/analyze.c
===================================================================
--- experimental/derf/theora-ptalarbvorm/lib/analyze.c	2010-07-23 13:58:46 UTC (rev 17345)
+++ experimental/derf/theora-ptalarbvorm/lib/analyze.c	2010-07-23 15:30:43 UTC (rev 17346)
@@ -1193,6 +1193,12 @@
   return OC_MAXI(y0+(dy*dx>>OC_SAD_SHIFT),0);
 }
 
+/*activity_avg must be positive, or flat regions could get a zero weight, which
+   confounds analysis.
+  We set the minimum to this value so that it also avoids the need for divide
+   by zero checks in oc_mb_masking().*/
+# define OC_ACTIVITY_AVG_MIN (1<<OC_RD_SCALE_BITS)
+
 static unsigned oc_mb_activity(oc_enc_ctx *_enc,unsigned _mbi,
  unsigned _activity[4]){
   const unsigned char   *src;
@@ -1374,7 +1380,7 @@
     /*Apply activity masking.*/
     a=_activity[bi]+4*_activity_avg;
     b=4*_activity[bi]+_activity_avg;
-    d=OC_MAXI(OC_RD_SCALE(b,1),1);
+    d=OC_RD_SCALE(b,1);
     /*And luminance masking.*/
     d=(a+(d>>1))/d;
     _rd_scale[bi]=(d*la+(lb>>1))/lb;
@@ -1790,8 +1796,9 @@
     notstart=1;
   }
   /*Compute the average block activity and MB luma score for the frame.*/
-  _enc->activity_avg=
-   (unsigned)((activity_sum+(_enc->state.fplanes[0].nfrags>>1))/_enc->state.fplanes[0].nfrags);
+  _enc->activity_avg=OC_MAXI(OC_ACTIVITY_AVG_MIN,
+   (unsigned)((activity_sum+(_enc->state.fplanes[0].nfrags>>1))/
+   _enc->state.fplanes[0].nfrags));
   _enc->luma_avg=(unsigned)((luma_sum+(_enc->state.nmbs>>1))/_enc->state.nmbs);
   /*Finish filling in the reference frame borders.*/
   refi=_enc->state.ref_frame_idx[OC_FRAME_SELF];
@@ -2702,12 +2709,9 @@
   /*Update the average block activity and MB luma score for the frame.
     We could use a Bessel follower here, but fast reaction is probably almost
      always best.*/
-  _enc->activity_avg=
+  _enc->activity_avg=OC_MAXI(OC_ACTIVITY_AVG_MIN,
    (unsigned)((activity_sum+(_enc->state.fplanes[0].nfrags>>1))/
-   _enc->state.fplanes[0].nfrags);
-  /*activity_avg must be positive, or flat regions will get an rd_scale of 0
-     in the next frame, which breaks analysis.*/
-  if(_enc->activity_avg<=0)_enc->activity_avg=1;
+   _enc->state.fplanes[0].nfrags));
   _enc->luma_avg=(unsigned)((luma_sum+(_enc->state.nmbs>>1))/_enc->state.nmbs);
   /*Finish filling in the reference frame borders.*/
   refi=_enc->state.ref_frame_idx[OC_FRAME_SELF];



More information about the commits mailing list