changeset 12352:f0ea08f4599b libavcodec

VP8: unroll partition type decoding tree ~34% faster partition type decoding.
author darkshikari
date Tue, 03 Aug 2010 11:10:58 +0000
parents 3e02e2306209
children eba266986930
files vp8.c vp8data.h
diffstat 2 files changed, 18 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/vp8.c	Tue Aug 03 10:37:14 2010 +0000
+++ b/vp8.c	Tue Aug 03 11:10:58 2010 +0000
@@ -644,19 +644,32 @@
 static av_always_inline
 int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb)
 {
-    int part_idx = mb->partitioning =
-        vp8_rac_get_tree(c, vp8_mbsplit_tree, vp8_mbsplit_prob);
-    int n, num = vp8_mbsplit_count[part_idx];
+    int part_idx;
+    int n, num;
     VP8Macroblock *top_mb  = &mb[2];
     VP8Macroblock *left_mb = &mb[-1];
     const uint8_t *mbsplits_left = vp8_mbsplits[left_mb->partitioning],
                   *mbsplits_top = vp8_mbsplits[top_mb->partitioning],
-                  *mbsplits_cur = vp8_mbsplits[part_idx],
-                  *firstidx = vp8_mbfirstidx[part_idx];
+                  *mbsplits_cur, *firstidx;
     VP56mv *top_mv  = top_mb->bmv;
     VP56mv *left_mv = left_mb->bmv;
     VP56mv *cur_mv  = mb->bmv;
 
+    if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[0])) {
+        if (vp56_rac_get_prob_branchy(c, vp8_mbsplit_prob[1])) {
+            part_idx = VP8_SPLITMVMODE_16x8 + vp56_rac_get_prob(c, vp8_mbsplit_prob[2]);
+        } else {
+            part_idx = VP8_SPLITMVMODE_8x8;
+        }
+    } else {
+        part_idx = VP8_SPLITMVMODE_4x4;
+    }
+
+    num = vp8_mbsplit_count[part_idx];
+    mbsplits_cur = vp8_mbsplits[part_idx],
+    firstidx = vp8_mbfirstidx[part_idx];
+    mb->partitioning = part_idx;
+
     for (n = 0; n < num; n++) {
         int k = firstidx[n];
         uint32_t left, above;
--- a/vp8data.h	Tue Aug 03 10:37:14 2010 +0000
+++ b/vp8data.h	Tue Aug 03 11:10:58 2010 +0000
@@ -115,12 +115,6 @@
        8,  9, 10, 11, 12, 13, 14, 15 }
 };
 
-static const int8_t vp8_mbsplit_tree[3][2] = {
-    { -VP8_SPLITMVMODE_4x4,  1 },           // '0' - 16 individual MVs
-     { -VP8_SPLITMVMODE_8x8,  2 },          // '10' - quarter-based MVs
-      { -VP8_SPLITMVMODE_16x8,              // '110' - top/bottom MVs
-        -VP8_SPLITMVMODE_8x16 }             // '111' - left/right MVs
-};
 static const uint8_t vp8_mbsplit_count[4] = {   2,   2,   4,  16 };
 static const uint8_t vp8_mbsplit_prob[3]  = { 110, 111, 150 };