vp8e - static threshold play
authorJim Bankoski <jimbankoski@google.com>
Tue, 7 Dec 2010 21:07:23 +0000 (16:07 -0500)
committerJim Bankoski <jimbankoski@google.com>
Tue, 7 Dec 2010 21:07:23 +0000 (16:07 -0500)
Realized no need for new assembly code sum is already
calculated.

Change-Id: Ie2d94feb4b7c1f77c5359bca29b66228e41638c9

vp8/encoder/onyx_if.c
vp8/encoder/rdopt.c

index 7e9a0f0..aad326c 100644 (file)
@@ -324,8 +324,15 @@ void vp8_dealloc_compressor_data(VP8_COMP *cpi)
 
     cpi->mb.pip = 0;
 
-    vpx_free(cpi->total_stats);
-    vpx_free(cpi->this_frame_stats);
+    if(cpi->total_stats)
+        vpx_free(cpi->total_stats);
+
+    cpi->total_stats = 0;
+
+    if(cpi->this_frame_stats)
+        vpx_free(cpi->this_frame_stats);
+
+    cpi->this_frame_stats = 0;
 }
 
 static void enable_segmentation(VP8_PTR ptr)
@@ -1326,6 +1333,9 @@ static void alloc_raw_frame_buffers(VP8_COMP *cpi)
 
 static int vp8_alloc_partition_data(VP8_COMP *cpi)
 {
+    if(cpi->mb.pip)
+        vpx_free(cpi->mb.pip);
+
     cpi->mb.pip = vpx_calloc((cpi->common.mb_cols + 1) *
                                 (cpi->common.mb_rows + 1),
                                 sizeof(PARTITION_INFO));
@@ -1393,8 +1403,16 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
 
     cpi->gf_active_count = cm->mb_rows * cm->mb_cols;
 
+    if(cpi->total_stats)
+        vpx_free(cpi->total_stats);
+
     cpi->total_stats = vpx_calloc(1, vp8_firstpass_stats_sz(cpi->common.MBs));
+
+    if(cpi->this_frame_stats)
+        vpx_free(cpi->this_frame_stats);
+
     cpi->this_frame_stats = vpx_calloc(1, vp8_firstpass_stats_sz(cpi->common.MBs));
+
     if(!cpi->total_stats || !cpi->this_frame_stats)
         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
                            "Failed to allocate firstpass stats");
index 74f7f46..0b902dc 100644 (file)
@@ -2200,8 +2200,7 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
             vp8_build_inter_predictors_mby(&x->e_mbd);
             VARIANCE_INVOKE(&cpi->rtcd.variance, get16x16var)(x->src.y_buffer, x->src.y_stride, x->e_mbd.predictor, 16, (unsigned int *)(&sse), &sum);
 
-            if (cpi->active_map_enabled && x->active_ptr[0] == 0)
-            {
+            if (cpi->active_map_enabled && x->active_ptr[0] == 0) {
                 x->skip = 1;
             }
             else if (sse < x->encode_breakout)
@@ -2209,21 +2208,23 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int
                 // Check u and v to make sure skip is ok
                 int sse2 = 0;
 
-                sse2 = VP8_UVSSE(x, IF_RTCD(&cpi->rtcd.variance));
-
-                if (sse2 * 2 < x->encode_breakout)
+                // add dc check
+                if (abs(sum) < (cpi->common.Y2dequant[0][0] << 2))
                 {
-                    x->skip = 1;
-                    distortion2 = sse;
-                    rate2 = 500;
+                    sse2 = VP8_UVSSE(x, IF_RTCD(&cpi->rtcd.variance));
 
-                    disable_skip = 1;    // We have no real rate data so trying to adjust for rate_y and rate_uv below will cause problems.
-                    this_rd = RDFUNC(x->rdmult, x->rddiv, rate2, distortion2, cpi->target_bits_per_mb);
+                    if (sse2 * 2 < x->encode_breakout)
+                    {
+                        x->skip = 1;
+                        distortion2 = sse;
+                        rate2 = 500;
+                        disable_skip = 1;
+                        this_rd = RDFUNC(x->rdmult, x->rddiv, rate2,
+                          distortion2, cpi->target_bits_per_mb);
 
-                    break;              // (PGW) Move break here from below - for now at least
+                        break;
+                    }
                 }
-                else
-                    x->skip = 0;
             }
 
             //intermodecost[mode_index] = vp8_cost_mv_ref(this_mode, mdcounts);   // Experimental debug code