shithub: libvpx

Download patch

ref: 2855d8aea1c8ac74f7459d2086c778227ff2ca14
parent: 0d59d6efcd5b3bcb60469b32ae309274a456f29e
parent: b2fc6fa9697eb9267c77af2716bbd44d126891ba
author: Dmitry Kovalev <[email protected]>
date: Tue Jul 23 09:57:59 EDT 2013

Merge "Adding update_tx_counts function."

--- a/vp9/common/vp9_pred_common.h
+++ b/vp9/common/vp9_pred_common.h
@@ -108,16 +108,31 @@
 
 unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd);
 
-static const vp9_prob *vp9_get_pred_probs_tx_size(const MACROBLOCKD *xd,
-                           const struct tx_probs *tx_probs) {
-  const MODE_INFO *const mi = xd->mode_info_context;
-  const int pred_context = vp9_get_pred_context_tx_size(xd);
-  if (mi->mbmi.sb_type < BLOCK_SIZE_MB16X16)
-    return tx_probs->p8x8[pred_context];
-  else if (mi->mbmi.sb_type < BLOCK_SIZE_SB32X32)
-    return tx_probs->p16x16[pred_context];
+static const vp9_prob *get_tx_probs(BLOCK_SIZE_TYPE bsize, uint8_t context,
+                                    const struct tx_probs *tx_probs) {
+  if (bsize < BLOCK_SIZE_MB16X16)
+    return tx_probs->p8x8[context];
+  else if (bsize < BLOCK_SIZE_SB32X32)
+    return tx_probs->p16x16[context];
   else
-    return tx_probs->p32x32[pred_context];
+    return tx_probs->p32x32[context];
+}
+
+static const vp9_prob *get_tx_probs2(const MACROBLOCKD *xd,
+                                     const struct tx_probs *tx_probs) {
+  const BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
+  const int context = vp9_get_pred_context_tx_size(xd);
+  return get_tx_probs(bsize, context, tx_probs);
+}
+
+static void update_tx_counts(BLOCK_SIZE_TYPE bsize, uint8_t context,
+                             TX_SIZE tx_size, struct tx_counts *tx_counts) {
+  if (bsize >= BLOCK_SIZE_SB32X32)
+    tx_counts->p32x32[context][tx_size]++;
+  else if (bsize >= BLOCK_SIZE_MB16X16)
+    tx_counts->p16x16[context][tx_size]++;
+  else
+    tx_counts->p8x8[context][tx_size]++;
 }
 
 #endif  // VP9_COMMON_VP9_PRED_COMMON_H_
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -38,35 +38,29 @@
   return treed_read(r, vp9_segment_tree, seg->tree_probs);
 }
 
-static TX_SIZE read_selected_txfm_size(VP9_COMMON *cm, MACROBLOCKD *xd,
-                                       BLOCK_SIZE_TYPE bsize, vp9_reader *r) {
-  const int context = vp9_get_pred_context_tx_size(xd);
-  const vp9_prob *tx_probs = vp9_get_pred_probs_tx_size(xd, &cm->fc.tx_probs);
-  TX_SIZE txfm_size = vp9_read(r, tx_probs[0]);
-  if (txfm_size != TX_4X4 && bsize >= BLOCK_SIZE_MB16X16) {
-    txfm_size += vp9_read(r, tx_probs[1]);
-    if (txfm_size != TX_8X8 && bsize >= BLOCK_SIZE_SB32X32)
-      txfm_size += vp9_read(r, tx_probs[2]);
+static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd,
+                                     BLOCK_SIZE_TYPE bsize, vp9_reader *r) {
+  const uint8_t context = vp9_get_pred_context_tx_size(xd);
+  const vp9_prob *tx_probs = get_tx_probs(bsize, context, &cm->fc.tx_probs);
+  TX_SIZE tx_size = vp9_read(r, tx_probs[0]);
+  if (tx_size != TX_4X4 && bsize >= BLOCK_SIZE_MB16X16) {
+    tx_size += vp9_read(r, tx_probs[1]);
+    if (tx_size != TX_8X8 && bsize >= BLOCK_SIZE_SB32X32)
+      tx_size += vp9_read(r, tx_probs[2]);
   }
 
-  if (bsize >= BLOCK_SIZE_SB32X32)
-    cm->fc.tx_counts.p32x32[context][txfm_size]++;
-  else if (bsize >= BLOCK_SIZE_MB16X16)
-    cm->fc.tx_counts.p16x16[context][txfm_size]++;
-  else
-    cm->fc.tx_counts.p8x8[context][txfm_size]++;
-
-  return txfm_size;
+  update_tx_counts(bsize, context, tx_size, &cm->fc.tx_counts);
+  return tx_size;
 }
 
-static TX_SIZE read_txfm_size(VP9D_COMP *pbi, TX_MODE tx_mode,
-                              BLOCK_SIZE_TYPE bsize, int select_cond,
-                              vp9_reader *r) {
+static TX_SIZE read_tx_size(VP9D_COMP *pbi, TX_MODE tx_mode,
+                            BLOCK_SIZE_TYPE bsize, int select_cond,
+                            vp9_reader *r) {
   VP9_COMMON *const cm = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;
 
   if (tx_mode == TX_MODE_SELECT && bsize >= BLOCK_SIZE_SB8X8 && select_cond)
-    return read_selected_txfm_size(cm, xd, bsize, r);
+    return read_selected_tx_size(cm, xd, bsize, r);
   else if (tx_mode >= ALLOW_32X32 && bsize >= BLOCK_SIZE_SB32X32)
     return TX_32X32;
   else if (tx_mode >= ALLOW_16X16 && bsize >= BLOCK_SIZE_MB16X16)
@@ -162,7 +156,7 @@
 
   mbmi->segment_id = read_intra_segment_id(pbi, mi_row, mi_col, r);
   mbmi->mb_skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
-  mbmi->txfm_size = read_txfm_size(pbi, cm->tx_mode, bsize, 1, r);
+  mbmi->txfm_size = read_tx_size(pbi, cm->tx_mode, bsize, 1, r);
   mbmi->ref_frame[0] = INTRA_FRAME;
 
   if (bsize >= BLOCK_SIZE_SB8X8) {
@@ -463,7 +457,7 @@
   mbmi->mb_skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
   mbmi->ref_frame[0] = read_reference_frame(pbi, mbmi->segment_id, r);
   mbmi->ref_frame[1] = NONE;
-  mbmi->txfm_size = read_txfm_size(pbi, cm->tx_mode, bsize,
+  mbmi->txfm_size = read_tx_size(pbi, cm->tx_mode, bsize,
      (!mbmi->mb_skip_coeff || mbmi->ref_frame[0] == INTRA_FRAME), r);
 
   if (mbmi->ref_frame[0] != INTRA_FRAME) {
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -202,9 +202,8 @@
 
 static void write_selected_txfm_size(const VP9_COMP *cpi, TX_SIZE tx_size,
                                      BLOCK_SIZE_TYPE bsize, vp9_writer *w) {
-  const VP9_COMMON *const cm = &cpi->common;
   const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
-  const vp9_prob *tx_probs = vp9_get_pred_probs_tx_size(xd, &cm->fc.tx_probs);
+  const vp9_prob *tx_probs = get_tx_probs2(xd, &cpi->common.fc.tx_probs);
   vp9_write(w, tx_size != TX_4X4, tx_probs[0]);
   if (bsize >= BLOCK_SIZE_MB16X16 && tx_size != TX_4X4) {
     vp9_write(w, tx_size != TX_8X8, tx_probs[1]);
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -2613,14 +2613,8 @@
         !(mbmi->ref_frame[0] != INTRA_FRAME &&
             (mbmi->mb_skip_coeff ||
              vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)))) {
-      const int context = vp9_get_pred_context_tx_size(xd);
-      if (bsize >= BLOCK_SIZE_SB32X32) {
-        cm->fc.tx_counts.p32x32[context][mbmi->txfm_size]++;
-      } else if (bsize >= BLOCK_SIZE_MB16X16) {
-        cm->fc.tx_counts.p16x16[context][mbmi->txfm_size]++;
-      } else {
-        cm->fc.tx_counts.p8x8[context][mbmi->txfm_size]++;
-      }
+      const uint8_t context = vp9_get_pred_context_tx_size(xd);
+      update_tx_counts(bsize, context, mbmi->txfm_size, &cm->fc.tx_counts);
     } else {
       int x, y;
       TX_SIZE sz = (cm->tx_mode == TX_MODE_SELECT) ? TX_32X32 : cm->tx_mode;
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -861,7 +861,7 @@
   int n, m;
   int s0, s1;
 
-  const vp9_prob *tx_probs = vp9_get_pred_probs_tx_size(xd, &cm->fc.tx_probs);
+  const vp9_prob *tx_probs = get_tx_probs2(xd, &cm->fc.tx_probs);
 
   for (n = TX_4X4; n <= max_txfm_size; n++) {
     r[n][1] = r[n][0];
@@ -968,7 +968,7 @@
   double scale_rd[TX_SIZE_MAX_SB] = {1.73, 1.44, 1.20, 1.00};
   // double scale_r[TX_SIZE_MAX_SB] = {2.82, 2.00, 1.41, 1.00};
 
-  const vp9_prob *tx_probs = vp9_get_pred_probs_tx_size(xd, &cm->fc.tx_probs);
+  const vp9_prob *tx_probs = get_tx_probs2(xd, &cm->fc.tx_probs);
 
   // for (n = TX_4X4; n <= max_txfm_size; n++)
   //   r[n][0] = (r[n][0] * scale_r[n]);