]> granicus.if.org Git - libvpx/commitdiff
Moved vp8_encode_bool into boolhuff.h
authorScott LaVarnway <slavarnway@google.com>
Tue, 19 Jul 2011 13:17:25 +0000 (09:17 -0400)
committerScott LaVarnway <slavarnway@google.com>
Tue, 19 Jul 2011 13:17:25 +0000 (09:17 -0400)
allowing the compiler to inline this function.  For real-time
encodes, this gave a boost of 1% to 2.5%, depending on the
speed setting.

Change-Id: I3929d176cca086b4261267b848419d5bcff21c02

vp8/common/entropy.c
vp8/decoder/dboolhuff.c
vp8/decoder/dboolhuff.h
vp8/decoder/detokenize.c
vp8/encoder/bitstream.c
vp8/encoder/boolhuff.c
vp8/encoder/boolhuff.h

index fba7a07ffe95906ac07c448d98ec11cf8a17b106..0eee60ec8b0907a47700497d6f988a9cd2a4cb39 100644 (file)
@@ -26,8 +26,32 @@ typedef vp8_prob Prob;
 
 #include "coefupdateprobs.h"
 
-DECLARE_ALIGNED(16, cuchar, vp8_coef_bands[16]) = { 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7};
-DECLARE_ALIGNED(16, cuchar, vp8_prev_token_class[MAX_ENTROPY_TOKENS]) = { 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0};
+DECLARE_ALIGNED(16, const unsigned char, vp8_norm[256]) =
+{
+    0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
+    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+DECLARE_ALIGNED(16, cuchar, vp8_coef_bands[16]) =
+{ 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7};
+
+DECLARE_ALIGNED(16, cuchar, vp8_prev_token_class[MAX_ENTROPY_TOKENS]) =
+{ 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0};
+
 DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]) =
 {
     0,  1,  4,  8,
index 8527d51e85e720d1f8339a72317674eb6ea2ab46..7e7b05aa62c8c71a78ca943a5a52d909bbb35ac9 100644 (file)
 #include "vpx_ports/mem.h"
 #include "vpx_mem/vpx_mem.h"
 
-DECLARE_ALIGNED(16, const unsigned char, vp8dx_bitreader_norm[256]) =
-{
-    0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-
 int vp8dx_start_decode(BOOL_DECODER *br,
                        const unsigned char *source,
                        unsigned int source_sz)
index f729837f902f449a9adf4101b2e24aa19cf38f54..853c10f145234c20a44e409c91739886eb9e4c0a 100644 (file)
@@ -34,7 +34,7 @@ typedef struct
     unsigned int         range;
 } BOOL_DECODER;
 
-DECLARE_ALIGNED(16, extern const unsigned char, vp8dx_bitreader_norm[256]);
+DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
 
 int vp8dx_start_decode(BOOL_DECODER *br,
                        const unsigned char *source,
@@ -101,7 +101,7 @@ static int vp8dx_decode_bool(BOOL_DECODER *br, int probability) {
     }
 
     {
-        register unsigned int shift = vp8dx_bitreader_norm[range];
+        register unsigned int shift = vp8_norm[range];
         range <<= shift;
         value <<= shift;
         count -= shift;
index c22e0f28c2c763353c738b42188e177b5fb14ac9..166be9ef9c60be9ade3556dd92dbf518e3d3111c 100644 (file)
@@ -80,7 +80,7 @@ void vp8_reset_mb_tokens_context(MACROBLOCKD *x)
     }
 }
 
-DECLARE_ALIGNED(16, extern const unsigned char, vp8dx_bitreader_norm[256]);
+DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
 #define FILL \
     if(count < 0) \
         VP8DX_BOOL_DECODER_FILL(count, value, bufptr, bufend);
@@ -88,7 +88,7 @@ DECLARE_ALIGNED(16, extern const unsigned char, vp8dx_bitreader_norm[256]);
 #define NORMALIZE \
     /*if(range < 0x80)*/                            \
     { \
-        shift = vp8dx_bitreader_norm[range]; \
+        shift = vp8_norm[range]; \
         range <<= shift; \
         value <<= shift; \
         count -= shift; \
index 134e8488180426c863d97aa6edd476079f23d66f..b3c24398c1a6daa4381407224b7bbbc7b6b45400 100644 (file)
@@ -158,18 +158,6 @@ static void write_split(vp8_writer *bc, int x)
     );
 }
 
-static const unsigned int norm[256] =
-{
-    0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
 static void pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount)
 {
     const TOKENEXTRA *const stop = p + xcount;
@@ -211,7 +199,7 @@ static void pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount)
                 range = split;
             }
 
-            shift = norm[range];
+            shift = vp8_norm[range];
             range <<= shift;
             count += shift;
 
@@ -271,7 +259,7 @@ static void pack_tokens_c(vp8_writer *w, const TOKENEXTRA *p, int xcount)
                         range = split;
                     }
 
-                    shift = norm[range];
+                    shift = vp8_norm[range];
                     range <<= shift;
                     count += shift;
 
@@ -427,7 +415,7 @@ static void pack_tokens_into_partitions_c(VP8_COMP *cpi, unsigned char *cx_data,
                             range = split;
                         }
 
-                        shift = norm[range];
+                        shift = vp8_norm[range];
                         range <<= shift;
                         count += shift;
 
@@ -487,7 +475,7 @@ static void pack_tokens_into_partitions_c(VP8_COMP *cpi, unsigned char *cx_data,
                                     range = split;
                                 }
 
-                                shift = norm[range];
+                                shift = vp8_norm[range];
                                 range <<= shift;
                                 count += shift;
 
@@ -634,7 +622,7 @@ static void pack_mb_row_tokens_c(VP8_COMP *cpi, vp8_writer *w)
                     range = split;
                 }
 
-                shift = norm[range];
+                shift = vp8_norm[range];
                 range <<= shift;
                 count += shift;
 
@@ -694,7 +682,7 @@ static void pack_mb_row_tokens_c(VP8_COMP *cpi, vp8_writer *w)
                             range = split;
                         }
 
-                        shift = norm[range];
+                        shift = vp8_norm[range];
                         range <<= shift;
                         count += shift;
 
index 788d2b05f2f4e0b610cacc371c80c63ab1370b15..08ae66b8da04bcd59915d1c04ee2650c0df3243a 100644 (file)
@@ -10,9 +10,6 @@
 
 
 #include "boolhuff.h"
-#include "vp8/common/blockd.h"
-
-
 
 #if defined(SECTIONBITS_OUTPUT)
 unsigned __int64 Sectionbits[500];
@@ -62,81 +59,6 @@ void vp8_stop_encode(BOOL_CODER *br)
         vp8_encode_bool(br, 0, 128);
 }
 
-DECLARE_ALIGNED(16, static const unsigned int, norm[256]) =
-{
-    0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-void vp8_encode_bool(BOOL_CODER *br, int bit, int probability)
-{
-    unsigned int split;
-    int count = br->count;
-    unsigned int range = br->range;
-    unsigned int lowvalue = br->lowvalue;
-    register unsigned int shift;
-
-#ifdef ENTROPY_STATS
-#if defined(SECTIONBITS_OUTPUT)
-
-    if (bit)
-        Sectionbits[active_section] += vp8_prob_cost[255-probability];
-    else
-        Sectionbits[active_section] += vp8_prob_cost[probability];
-
-#endif
-#endif
-
-    split = 1 + (((range - 1) * probability) >> 8);
-
-    range = split;
-
-    if (bit)
-    {
-        lowvalue += split;
-        range = br->range - split;
-    }
-
-    shift = norm[range];
-
-    range <<= shift;
-    count += shift;
-
-    if (count >= 0)
-    {
-        int offset = shift - count;
-
-        if ((lowvalue << (offset - 1)) & 0x80000000)
-        {
-            int x = br->pos - 1;
-
-            while (x >= 0 && br->buffer[x] == 0xff)
-            {
-                br->buffer[x] = (unsigned char)0;
-                x--;
-            }
-
-            br->buffer[x] += 1;
-        }
-
-        br->buffer[br->pos++] = (lowvalue >> (24 - offset));
-        lowvalue <<= offset;
-        shift = count;
-        lowvalue &= 0xffffff;
-        count -= 8 ;
-    }
-
-    lowvalue <<= shift;
-    br->count = count;
-    br->lowvalue = lowvalue;
-    br->range = range;
-}
 
 void vp8_encode_value(BOOL_CODER *br, int data, int bits)
 {
index f723da3f001582116da3f48fd6e8ead6f3ed05ac..04755f5329bb53f6885504d26d07ceace329edb2 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef __INC_BOOLHUFF_H
 #define __INC_BOOLHUFF_H
 
+#include "vpx_ports/mem.h"
 
 typedef struct
 {
@@ -35,9 +36,77 @@ typedef struct
 } BOOL_CODER;
 
 extern void vp8_start_encode(BOOL_CODER *bc, unsigned char *buffer);
-extern void vp8_encode_bool(BOOL_CODER *bc, int x, int context);
+
 extern void vp8_encode_value(BOOL_CODER *br, int data, int bits);
 extern void vp8_stop_encode(BOOL_CODER *bc);
 extern const unsigned int vp8_prob_cost[256];
 
+
+DECLARE_ALIGNED(16, extern const unsigned char, vp8_norm[256]);
+
+
+static void vp8_encode_bool(BOOL_CODER *br, int bit, int probability)
+{
+    unsigned int split;
+    int count = br->count;
+    unsigned int range = br->range;
+    unsigned int lowvalue = br->lowvalue;
+    register unsigned int shift;
+
+#ifdef ENTROPY_STATS
+#if defined(SECTIONBITS_OUTPUT)
+
+    if (bit)
+        Sectionbits[active_section] += vp8_prob_cost[255-probability];
+    else
+        Sectionbits[active_section] += vp8_prob_cost[probability];
+
+#endif
+#endif
+
+    split = 1 + (((range - 1) * probability) >> 8);
+
+    range = split;
+
+    if (bit)
+    {
+        lowvalue += split;
+        range = br->range - split;
+    }
+
+    shift = vp8_norm[range];
+
+    range <<= shift;
+    count += shift;
+
+    if (count >= 0)
+    {
+        int offset = shift - count;
+
+        if ((lowvalue << (offset - 1)) & 0x80000000)
+        {
+            int x = br->pos - 1;
+
+            while (x >= 0 && br->buffer[x] == 0xff)
+            {
+                br->buffer[x] = (unsigned char)0;
+                x--;
+            }
+
+            br->buffer[x] += 1;
+        }
+
+        br->buffer[br->pos++] = (lowvalue >> (24 - offset));
+        lowvalue <<= offset;
+        shift = count;
+        lowvalue &= 0xffffff;
+        count -= 8 ;
+    }
+
+    lowvalue <<= shift;
+    br->count = count;
+    br->lowvalue = lowvalue;
+    br->range = range;
+}
+
 #endif