shithub: libvpx

Download patch

ref: b5323ed89a27dcf57dc62190cca128e8ae8366b4
parent: 5875d7a4a4b4a17dd891f1da0a30a220e4d9f798
author: Jingning Han <[email protected]>
date: Mon Jul 29 10:54:31 EDT 2013

Skip redundant tokenization in rd loop

This commit makes the encoder skip the redundant tokenization process
in the rate-distortion optimization search loop, while updating the
entropy contexts accordingly. It makes the speed 0 encoding process
about 0.5% faster at no performance change.

Change-Id: I34a4155a0b5332afeb45c93a51c7f35a294d685c

--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -98,6 +98,28 @@
   int dry_run;
 };
 
+static void set_entropy_context_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
+                                  int ss_txfrm_size, void *arg) {
+  struct tokenize_b_args* const args = arg;
+  TX_SIZE tx_size = ss_txfrm_size >> 1;
+  MACROBLOCKD *xd = args->xd;
+  const int bwl = b_width_log2(bsize);
+  const int off = block >> (2 * tx_size);
+  const int mod = bwl - tx_size - xd->plane[plane].subsampling_x;
+  const int aoff = (off & ((1 << mod) - 1)) << tx_size;
+  const int loff = (off >> mod) << tx_size;
+  ENTROPY_CONTEXT *A = xd->plane[plane].above_context + aoff;
+  ENTROPY_CONTEXT *L = xd->plane[plane].left_context + loff;
+  const int eob = xd->plane[plane].eobs[block];
+
+  if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) {
+    set_contexts_on_border(xd, bsize, plane, tx_size, eob, aoff, loff, A, L);
+  } else {
+    vpx_memset(A, eob > 0, sizeof(ENTROPY_CONTEXT) * (1 << tx_size));
+    vpx_memset(L, eob > 0, sizeof(ENTROPY_CONTEXT) * (1 << tx_size));
+  }
+}
+
 static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
                        int ss_txfrm_size, void *arg) {
   struct tokenize_b_args* const args = arg;
@@ -269,13 +291,13 @@
     return;
   }
 
-  if (!dry_run)
+  if (!dry_run) {
     cm->counts.mbskip[mb_skip_context][0] += skip_inc;
-
-  foreach_transformed_block(xd, bsize, tokenize_b, &arg);
-
-  if (dry_run)
+    foreach_transformed_block(xd, bsize, tokenize_b, &arg);
+  } else {
+    foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg);
     *t = t_backup;
+  }
 }
 
 #ifdef ENTROPY_STATS