shithub: libvpx

Download patch

ref: 0256a7595091ce1f459284a70a2693132d91eaf1
parent: bd756699b9785eeca5e6ed9d4a0985e41f88cbea
author: Alex Converse <[email protected]>
date: Tue Jul 1 12:54:41 EDT 2014

Allow lossless skipping in RD mode decision.

Change-Id: I2fc4ecfc2dd3ff1dd241a68c9ed4c280291b41f2

--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2791,39 +2791,43 @@
     *rate2 += vp9_get_switchable_rate(cpi);
 
   if (!is_comp_pred) {
-    if (cpi->allow_encode_breakout && x->encode_breakout) {
+    if (cpi->allow_encode_breakout) {
       const BLOCK_SIZE y_size = get_plane_block_size(bsize, &xd->plane[0]);
       const BLOCK_SIZE uv_size = get_plane_block_size(bsize, &xd->plane[1]);
       unsigned int var, sse;
       // Skipping threshold for ac.
       unsigned int thresh_ac;
-      // Set a maximum for threshold to avoid big PSNR loss in low bitrate case.
-      // Use extreme low threshold for static frames to limit skipping.
-      const unsigned int max_thresh = (cpi->allow_encode_breakout ==
-                                      ENCODE_BREAKOUT_LIMITED) ? 128 : 36000;
-      // The encode_breakout input
-      const unsigned int min_thresh =
-          MIN(((unsigned int)x->encode_breakout << 4), max_thresh);
+      // Skipping threshold for dc
+      unsigned int thresh_dc;
 
-      // Calculate threshold according to dequant value.
-      thresh_ac = (xd->plane[0].dequant[1] * xd->plane[0].dequant[1]) / 9;
-      thresh_ac = clamp(thresh_ac, min_thresh, max_thresh);
-
       var = cpi->fn_ptr[y_size].vf(x->plane[0].src.buf, x->plane[0].src.stride,
                                    xd->plane[0].dst.buf,
                                    xd->plane[0].dst.stride, &sse);
 
-      // Adjust threshold according to partition size.
-      thresh_ac >>= 8 - (b_width_log2_lookup[bsize] +
-          b_height_log2_lookup[bsize]);
+      if (x->encode_breakout > 0) {
+        // Set a maximum for threshold to avoid big PSNR loss in low bitrate
+        // case. Use extreme low threshold for static frames to limit skipping.
+        const unsigned int max_thresh = (cpi->allow_encode_breakout ==
+                                        ENCODE_BREAKOUT_LIMITED) ? 128 : 36000;
+        // The encode_breakout input
+        const unsigned int min_thresh =
+            MIN(((unsigned int)x->encode_breakout << 4), max_thresh);
 
-      // Y skipping condition checking
-      if (sse < thresh_ac || sse == 0) {
-        // Skipping threshold for dc
-        unsigned int thresh_dc;
+        // Calculate threshold according to dequant value.
+        thresh_ac = (xd->plane[0].dequant[1] * xd->plane[0].dequant[1]) / 9;
+        thresh_ac = clamp(thresh_ac, min_thresh, max_thresh);
 
+        // Adjust threshold according to partition size.
+        thresh_ac >>= 8 - (b_width_log2_lookup[bsize] +
+            b_height_log2_lookup[bsize]);
         thresh_dc = (xd->plane[0].dequant[0] * xd->plane[0].dequant[0] >> 6);
+      } else {
+        thresh_ac = 0;
+        thresh_dc = 0;
+      }
 
+      // Y skipping condition checking
+      if (sse < thresh_ac || sse == 0) {
         // dc skipping checking
         if ((sse - var) < thresh_dc || sse == var) {
           unsigned int sse_u, sse_v;