]> granicus.if.org Git - libvpx/commitdiff
Refactor bitreader and bitwriter wrapper.
authorNathan E. Egge <negge@mozilla.com>
Thu, 16 Jun 2016 13:00:39 +0000 (09:00 -0400)
committerAlex Converse <aconverse@google.com>
Wed, 28 Sep 2016 19:07:00 +0000 (12:07 -0700)
Move code for reading and writing literals and reading trees to use
just the aom_read_bit() and aom_write_bit() function calls.

Change-Id: Id2bced5f0125a5558030a813c51c3d79e5701873
(cherry picked from aom/master commit bc1ac15846a200272551699d45457039535e56b2)

aom_dsp/bitreader.h
aom_dsp/dkboolreader.c
aom_dsp/dkboolreader.h
aom_dsp/dkboolwriter.c
aom_dsp/dkboolwriter.h

index d189e745df7b3fe0aa23073e2d47c9289878f910..86c517339bb3cb403a495858fd5554118061095d 100644 (file)
@@ -77,25 +77,25 @@ static INLINE int aom_read_bit(aom_reader *r) {
 #if CONFIG_ANS
   return uabs_read_bit(r);  // Non trivial optimization at half probability
 #else
-  return aom_dk_read_bit(r);
+  return aom_read(r, 128);  // aom_prob_half
 #endif
 }
 
 static INLINE int aom_read_literal(aom_reader *r, int bits) {
-#if CONFIG_ANS
-  return uabs_read_literal(r, bits);
-#else
-  return aom_dk_read_literal(r, bits);
-#endif
+  int literal = 0, bit;
+
+  for (bit = bits - 1; bit >= 0; bit--) literal |= aom_read_bit(r) << bit;
+
+  return literal;
 }
 
 static INLINE int aom_read_tree(aom_reader *r, const aom_tree_index *tree,
                                 const aom_prob *probs) {
-#if CONFIG_ANS
-  return uabs_read_tree(r, tree, probs);
-#else
-  return aom_dk_read_tree(r, tree, probs);
-#endif
+  aom_tree_index i = 0;
+
+  while ((i = tree[i + aom_read(r, probs[i >> 1])]) > 0) continue;
+
+  return -i;
 }
 
 #ifdef __cplusplus
index c26d90baa056788250dcee6971f3fe53e88a93b3..8ec7ffc40651f2763d1aab61d8c70e3cf0ae265c 100644 (file)
 #include "aom_mem/aom_mem.h"
 #include "aom_util/endian_inl.h"
 
+static INLINE int aom_dk_read_bit(struct aom_dk_reader *r) {
+  return aom_dk_read(r, 128);  // aom_prob_half
+}
+
 int aom_dk_reader_init(struct aom_dk_reader *r, const uint8_t *buffer,
                        size_t size, aom_decrypt_cb decrypt_cb,
                        void *decrypt_state) {
index 531c5dc73cee2552c9de6ae951d3573e2fb2d3bf..fe68ecc0f6a3e3ce41dcb1c3da38ed798625274a 100644 (file)
@@ -135,28 +135,6 @@ static INLINE int aom_dk_read(struct aom_dk_reader *r, int prob) {
   return bit;
 }
 
-static INLINE int aom_dk_read_bit(struct aom_dk_reader *r) {
-  return aom_dk_read(r, 128);  // aom_prob_half
-}
-
-static INLINE int aom_dk_read_literal(struct aom_dk_reader *r, int bits) {
-  int literal = 0, bit;
-
-  for (bit = bits - 1; bit >= 0; bit--) literal |= aom_dk_read_bit(r) << bit;
-
-  return literal;
-}
-
-static INLINE int aom_dk_read_tree(struct aom_dk_reader *r,
-                                   const aom_tree_index *tree,
-                                   const aom_prob *probs) {
-  aom_tree_index i = 0;
-
-  while ((i = tree[i + aom_dk_read(r, probs[i >> 1])]) > 0) continue;
-
-  return -i;
-}
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif
index 259316c9352a83a80d625ce455390e31ba494447..238f37cd475279ecf2e2b6dd9b8b3f62a3b67f22 100644 (file)
 
 #include "./dkboolwriter.h"
 
+static INLINE void aom_dk_write_bit(aom_dk_writer *w, int bit) {
+  aom_dk_write(w, bit, 128);  // aom_prob_half
+}
+
 void aom_dk_start_encode(aom_dk_writer *br, uint8_t *source) {
   br->lowvalue = 0;
   br->range = 255;
index 8475238eeaa1d7edb17a7f08b766d30b20ffce09..835436885b07dcf269bf3fabf309ec8cd088a976 100644 (file)
@@ -97,16 +97,6 @@ static INLINE void aom_dk_write(aom_dk_writer *br, int bit, int probability) {
   br->range = range;
 }
 
-static INLINE void aom_dk_write_bit(aom_dk_writer *w, int bit) {
-  aom_dk_write(w, bit, 128);  // aom_prob_half
-}
-
-static INLINE void aom_dk_write_literal(aom_dk_writer *w, int data, int bits) {
-  int bit;
-
-  for (bit = bits - 1; bit >= 0; bit--) aom_dk_write_bit(w, 1 & (data >> bit));
-}
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif