shithub: libvpx

Download patch

ref: 29beeff11dd957af3f28d52fea9433ec43603bc7
parent: 05a3d8c90ffd6a1f802b9f815756b3e67f556229
parent: d8c9288465aabefaa0193b2e17ff6a198204c262
author: Dmitry Kovalev <[email protected]>
date: Mon Mar 10 08:29:28 EDT 2014

Merge "Cleaning up select_tx_mode() function."

--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -2229,7 +2229,7 @@
   }
 }
 
-static MV_REFERENCE_FRAME get_frame_type(VP9_COMP *cpi) {
+static MV_REFERENCE_FRAME get_frame_type(const VP9_COMP *cpi) {
   if (frame_is_intra_only(&cpi->common))
     return INTRA_FRAME;
   else if (cpi->rc.is_src_frame_alt_ref && cpi->refresh_golden_frame)
@@ -2240,30 +2240,31 @@
     return GOLDEN_FRAME;
 }
 
-static void select_tx_mode(VP9_COMP *cpi) {
+static TX_MODE select_tx_mode(const VP9_COMP *cpi) {
   if (cpi->oxcf.lossless) {
-    cpi->common.tx_mode = ONLY_4X4;
+    return ONLY_4X4;
   } else if (cpi->common.current_video_frame == 0) {
-    cpi->common.tx_mode = TX_MODE_SELECT;
+    return TX_MODE_SELECT;
   } else {
     if (cpi->sf.tx_size_search_method == USE_LARGESTALL) {
-      cpi->common.tx_mode = ALLOW_32X32;
+      return ALLOW_32X32;
     } else if (cpi->sf.tx_size_search_method == USE_FULL_RD) {
-      int frame_type = get_frame_type(cpi);
-      cpi->common.tx_mode =
-          cpi->rd_tx_select_threshes[frame_type][ALLOW_32X32]
-          > cpi->rd_tx_select_threshes[frame_type][TX_MODE_SELECT] ?
-          ALLOW_32X32 : TX_MODE_SELECT;
+      const int frame_type = get_frame_type(cpi);
+      return cpi->rd_tx_select_threshes[frame_type][ALLOW_32X32] >
+                 cpi->rd_tx_select_threshes[frame_type][TX_MODE_SELECT] ?
+                     ALLOW_32X32 : TX_MODE_SELECT;
     } else {
       unsigned int total = 0;
       int i;
       for (i = 0; i < TX_SIZES; ++i)
         total += cpi->tx_stepdown_count[i];
+
       if (total) {
-        double fraction = (double)cpi->tx_stepdown_count[0] / total;
-        cpi->common.tx_mode = fraction > 0.90 ? ALLOW_32X32 : TX_MODE_SELECT;
-        // printf("fraction = %f\n", fraction);
-      }  // else keep unchanged
+        const double fraction = (double)cpi->tx_stepdown_count[0] / total;
+        return fraction > 0.90 ? ALLOW_32X32 : TX_MODE_SELECT;
+      } else {
+        return cpi->common.tx_mode;
+      }
     }
   }
 }
@@ -2402,7 +2403,7 @@
   vp9_zero(cm->counts.eob_branch);
 
   // Set frame level transform size use case
-  select_tx_mode(cpi);
+  cm->tx_mode = select_tx_mode(cpi);
 
   cpi->mb.e_mbd.lossless = cm->base_qindex == 0 && cm->y_dc_delta_q == 0
       && cm->uv_dc_delta_q == 0 && cm->uv_ac_delta_q == 0;
@@ -2570,7 +2571,6 @@
     }
 
     cpi->mb.e_mbd.lossless = cpi->oxcf.lossless;
-
     cm->reference_mode = reference_mode;
 
     encode_frame_internal(cpi);