shithub: libvpx

Download patch

ref: 4ac5058afca24330d2bd5f438abec8574195f9ea
parent: 0e3f494b217bde5e1d47107cdfbb044e4d801cec
author: Alex Converse <[email protected]>
date: Thu Jul 30 07:52:28 EDT 2015

Give skip_txfm constants names.

This is using a define instead of an enum to keep byte packing.

Change-Id: I3abb07c8bfe377e19be4531b624af7b7b4207792

--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -122,6 +122,9 @@
 
   // skip forward transform and quantization
   uint8_t skip_txfm[MAX_MB_PLANE << 2];
+  #define SKIP_TXFM_NONE 0
+  #define SKIP_TXFM_AC_DC 1
+  #define SKIP_TXFM_AC_ONLY 2
 
   int64_t bsse[MAX_MB_PLANE << 2];
 
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -611,7 +611,7 @@
   if (!x->skip_recode) {
     if (x->quant_fp) {
       // Encoding process for rtc mode
-      if (x->skip_txfm[0] == 1 && plane == 0) {
+      if (x->skip_txfm[0] == SKIP_TXFM_AC_DC && plane == 0) {
         // skip forward transform
         p->eobs[block] = 0;
         *a = *l = 0;
@@ -622,10 +622,10 @@
     } else {
       if (max_txsize_lookup[plane_bsize] == tx_size) {
         int txfm_blk_index = (plane << 2) + (block >> (tx_size << 1));
-        if (x->skip_txfm[txfm_blk_index] == 0) {
+        if (x->skip_txfm[txfm_blk_index] == SKIP_TXFM_NONE) {
           // full forward transform and quantization
           vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
-        } else if (x->skip_txfm[txfm_blk_index]== 2) {
+        } else if (x->skip_txfm[txfm_blk_index] == SKIP_TXFM_AC_ONLY) {
           // fast path forward transform and quantization
           vp9_xform_quant_dc(x, plane, block, plane_bsize, tx_size);
         } else {
--- a/vp9/encoder/vp9_pickmode.c
+++ b/vp9/encoder/vp9_pickmode.c
@@ -341,7 +341,7 @@
                          sse32x32, sum32x32);
 
     // Skipping test
-    x->skip_txfm[0] = 0;
+    x->skip_txfm[0] = SKIP_TXFM_NONE;
     for (k = 0; k < num; k++)
       // Check if all ac coefficients can be quantized to zero.
       if (!(var_tx[k] < ac_thr || var == 0)) {
@@ -357,16 +357,16 @@
       }
 
     if (ac_test) {
-      x->skip_txfm[0] = 2;
+      x->skip_txfm[0] = SKIP_TXFM_AC_ONLY;
 
       if (dc_test)
-        x->skip_txfm[0] = 1;
+        x->skip_txfm[0] = SKIP_TXFM_AC_DC;
     } else if (dc_test) {
       skip_dc = 1;
     }
   }
 
-  if (x->skip_txfm[0] == 1) {
+  if (x->skip_txfm[0] == SKIP_TXFM_AC_DC) {
     int skip_uv[2] = {0};
     unsigned int var_uv[2];
     unsigned int sse_uv[2];
@@ -501,13 +501,13 @@
     const unsigned int sse_tx = sse >> num_blk_log2;
     const unsigned int var_tx = var >> num_blk_log2;
 
-    x->skip_txfm[0] = 0;
+    x->skip_txfm[0] = SKIP_TXFM_NONE;
     // Check if all ac coefficients can be quantized to zero.
     if (var_tx < ac_thr || var == 0) {
-      x->skip_txfm[0] = 2;
+      x->skip_txfm[0] = SKIP_TXFM_AC_ONLY;
       // Check if dc coefficient can be quantized to zero.
       if (sse_tx - var_tx < dc_thr || sse == var)
-        x->skip_txfm[0] = 1;
+        x->skip_txfm[0] = SKIP_TXFM_AC_DC;
     } else {
       if (sse_tx - var_tx < dc_thr || sse == var)
         skip_dc = 1;
@@ -514,7 +514,7 @@
     }
   }
 
-  if (x->skip_txfm[0] == 1) {
+  if (x->skip_txfm[0] == SKIP_TXFM_AC_DC) {
     *out_rate_sum = 0;
     *out_dist_sum = sse << 4;
     return;
@@ -1073,7 +1073,7 @@
   static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
                                     VP9_ALT_FLAG };
   RD_COST this_rdc, best_rdc;
-  uint8_t skip_txfm = 0, best_mode_skip_txfm = 0;
+  uint8_t skip_txfm = SKIP_TXFM_NONE, best_mode_skip_txfm = SKIP_TXFM_NONE;
   // var_y and sse_y are saved to be used in skipping checking
   unsigned int var_y = UINT_MAX;
   unsigned int sse_y = UINT_MAX;
@@ -1396,7 +1396,7 @@
         } else {
           this_rdc.rate = vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1);
           this_rdc.dist = this_sse;
-          x->skip_txfm[0] = 1;
+          x->skip_txfm[0] = SKIP_TXFM_AC_DC;
         }
       }
 
@@ -1881,7 +1881,7 @@
   mbmi->mode = xd->mi[0]->bmi[3].as_mode;
   ctx->mic = *(xd->mi[0]);
   ctx->mbmi_ext = *x->mbmi_ext;
-  ctx->skip_txfm[0] = 0;
+  ctx->skip_txfm[0] = SKIP_TXFM_NONE;
   ctx->skip = 0;
   // Dummy assignment for speed -5. No effect in speed -6.
   rd_cost->rdcost = best_rd;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -207,15 +207,15 @@
         x->bsse[(i << 2) + block_idx] = sse;
         sum_sse += sse;
 
-        x->skip_txfm[(i << 2) + block_idx] = 0;
+        x->skip_txfm[(i << 2) + block_idx] = SKIP_TXFM_NONE;
         if (!x->select_tx_size) {
           // Check if all ac coefficients can be quantized to zero.
           if (var < ac_thr || var == 0) {
-            x->skip_txfm[(i << 2) + block_idx] = 2;
+            x->skip_txfm[(i << 2) + block_idx] = SKIP_TXFM_AC_ONLY;
 
             // Check if dc coefficient can be quantized to zero.
             if (sse - var < dc_thr || sse == var) {
-              x->skip_txfm[(i << 2) + block_idx] = 1;
+              x->skip_txfm[(i << 2) + block_idx] = SKIP_TXFM_AC_DC;
 
               if (!sse || (var < low_ac_thr && sse - var < low_dc_thr))
                 low_err_skip = 1;
@@ -500,7 +500,8 @@
     dist_block(x, plane, block, tx_size, &dist, &sse);
 #endif  // CONFIG_VP9_HIGHBITDEPTH
   } else if (max_txsize_lookup[plane_bsize] == tx_size) {
-    if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 0) {
+    if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] ==
+        SKIP_TXFM_NONE) {
       // full forward transform and quantization
       vp9_xform_quant(x, plane, block, plane_bsize, tx_size);
 #if CONFIG_VP9_HIGHBITDEPTH
@@ -512,7 +513,8 @@
 #else
       dist_block(x, plane, block, tx_size, &dist, &sse);
 #endif  // CONFIG_VP9_HIGHBITDEPTH
-    } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] == 2) {
+    } else if (x->skip_txfm[(plane << 2) + (block >> (tx_size << 1))] ==
+               SKIP_TXFM_AC_ONLY) {
       // compute DC coefficient
       tran_low_t *const coeff   = BLOCK_OFFSET(x->plane[plane].coeff, block);
       tran_low_t *const dqcoeff = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block);
@@ -532,6 +534,7 @@
         dist = MAX(0, sse - dc_correct);
       }
     } else {
+      // SKIP_TXFM_AC_DC
       // skip forward transform
       x->plane[plane].eobs[block] = 0;
       sse  = x->bsse[(plane << 2) + (block >> (tx_size << 1))] << 4;
@@ -1064,7 +1067,7 @@
   const PREDICTION_MODE L = vp9_left_block_mode(mic, left_mi, 0);
   bmode_costs = cpi->y_mode_costs[A][L];
 
-  memset(x->skip_txfm, 0, sizeof(x->skip_txfm));
+  memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
   /* Y Search for intra prediction mode */
   for (mode = DC_PRED; mode <= TM_PRED; mode++) {
 
@@ -1170,7 +1173,7 @@
   int this_rate_tokenonly, this_rate, s;
   int64_t this_distortion, this_sse;
 
-  memset(x->skip_txfm, 0, sizeof(x->skip_txfm));
+  memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
   for (mode = DC_PRED; mode <= TM_PRED; ++mode) {
     if (!(cpi->sf.intra_uv_mode_mask[max_tx_size] & (1 << mode)))
       continue;
@@ -1208,7 +1211,7 @@
   int64_t unused;
 
   x->e_mbd.mi[0]->mbmi.uv_mode = DC_PRED;
-  memset(x->skip_txfm, 0, sizeof(x->skip_txfm));
+  memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
   super_block_uvrd(cpi, x, rate_tokenonly, distortion,
                    skippable, &unused, bsize, INT64_MAX);
   *rate = *rate_tokenonly + cpi->intra_uv_mode_cost[cm->frame_type][DC_PRED];
@@ -2673,7 +2676,7 @@
     if (is_comp_pred)
       if (single_skippable[this_mode][refs[0]] &&
           single_skippable[this_mode][refs[1]])
-        memset(skip_txfm, 1, sizeof(skip_txfm));
+        memset(skip_txfm, SKIP_TXFM_AC_DC, sizeof(skip_txfm));
 
   if (cpi->sf.use_rd_breakout && ref_best_rd < INT64_MAX) {
     // if current pred_error modeled rd is substantially more than the best
@@ -4077,7 +4080,7 @@
         // then dont bother looking at UV
         vp9_build_inter_predictors_sbuv(&x->e_mbd, mi_row, mi_col,
                                         BLOCK_8X8);
-        memset(x->skip_txfm, 0, sizeof(x->skip_txfm));
+        memset(x->skip_txfm, SKIP_TXFM_NONE, sizeof(x->skip_txfm));
         if (!super_block_uvrd(cpi, x, &rate_uv, &distortion_uv, &uv_skippable,
                               &uv_sse, BLOCK_8X8, tmp_best_rdu))
           continue;