Move the uvlc read/write functions.

The functions are aom_read_bit_buffer/aom_write_bit_buffer
based utilities, and should be defined with the rest of
their respective helper functions.

Change-Id: I2cfc01095401c1a72db4b51402c8f9de983d9f39
diff --git a/aom_dsp/binary_codes_reader.c b/aom_dsp/binary_codes_reader.c
index d05c3ef..23e6121 100644
--- a/aom_dsp/binary_codes_reader.c
+++ b/aom_dsp/binary_codes_reader.c
@@ -121,13 +121,3 @@
   const uint16_t scaled_n = (n << 1) - 1;
   return aom_rb_read_primitive_refsubexpfin(rb, scaled_n, k, ref) - n + 1;
 }
-
-uint32_t aom_rb_read_uvlc(struct aom_read_bit_buffer *rb) {
-  int leading_zeros = 0;
-  while (!aom_rb_read_bit(rb)) ++leading_zeros;
-  // Maximum 32 bits.
-  if (leading_zeros >= 32) return UINT32_MAX;
-  const uint32_t base = (1u << leading_zeros) - 1;
-  const uint32_t value = aom_rb_read_literal(rb, leading_zeros);
-  return base + value;
-}
diff --git a/aom_dsp/binary_codes_reader.h b/aom_dsp/binary_codes_reader.h
index 5253c61..7b41885 100644
--- a/aom_dsp/binary_codes_reader.h
+++ b/aom_dsp/binary_codes_reader.h
@@ -40,8 +40,6 @@
 int16_t aom_rb_read_signed_primitive_refsubexpfin(
     struct aom_read_bit_buffer *rb, uint16_t n, uint16_t k, int16_t ref);
 
-uint32_t aom_rb_read_uvlc(struct aom_read_bit_buffer *rb);
-
 #ifdef __cplusplus
 }  // extern "C"
 #endif
diff --git a/aom_dsp/binary_codes_writer.c b/aom_dsp/binary_codes_writer.c
index 8f74f09..4e53b15 100644
--- a/aom_dsp/binary_codes_writer.c
+++ b/aom_dsp/binary_codes_writer.c
@@ -208,15 +208,3 @@
   const uint16_t scaled_n = (n << 1) - 1;
   return aom_count_primitive_refsubexpfin(scaled_n, k, ref, v);
 }
-
-void aom_wb_write_uvlc(struct aom_write_bit_buffer *wb, uint32_t v) {
-  int64_t shift_val = ++v;
-  int leading_zeroes = 1;
-
-  assert(shift_val > 0);
-
-  while (shift_val >>= 1) leading_zeroes += 2;
-
-  aom_wb_write_literal(wb, 0, leading_zeroes >> 1);
-  aom_wb_write_unsigned_literal(wb, v, (leading_zeroes + 1) >> 1);
-}
diff --git a/aom_dsp/binary_codes_writer.h b/aom_dsp/binary_codes_writer.h
index 784c721..b839171 100644
--- a/aom_dsp/binary_codes_writer.h
+++ b/aom_dsp/binary_codes_writer.h
@@ -61,7 +61,6 @@
                                      uint16_t v);
 int aom_count_signed_primitive_refsubexpfin(uint16_t n, uint16_t k, int16_t ref,
                                             int16_t v);
-void aom_wb_write_uvlc(struct aom_write_bit_buffer *wb, uint32_t v);
 #ifdef __cplusplus
 }  // extern "C"
 #endif
diff --git a/aom_dsp/bitreader_buffer.c b/aom_dsp/bitreader_buffer.c
index 02b5ef9..b532117 100644
--- a/aom_dsp/bitreader_buffer.c
+++ b/aom_dsp/bitreader_buffer.c
@@ -55,3 +55,13 @@
   const unsigned value = (unsigned)aom_rb_read_literal(rb, bits + 1) << nbits;
   return ((int)value) >> nbits;
 }
+
+uint32_t aom_rb_read_uvlc(struct aom_read_bit_buffer *rb) {
+  int leading_zeros = 0;
+  while (!aom_rb_read_bit(rb)) ++leading_zeros;
+  // Maximum 32 bits.
+  if (leading_zeros >= 32) return UINT32_MAX;
+  const uint32_t base = (1u << leading_zeros) - 1;
+  const uint32_t value = aom_rb_read_literal(rb, leading_zeros);
+  return base + value;
+}
diff --git a/aom_dsp/bitreader_buffer.h b/aom_dsp/bitreader_buffer.h
index 5c94ab8..38e7af3 100644
--- a/aom_dsp/bitreader_buffer.h
+++ b/aom_dsp/bitreader_buffer.h
@@ -41,6 +41,8 @@
 
 int aom_rb_read_inv_signed_literal(struct aom_read_bit_buffer *rb, int bits);
 
+uint32_t aom_rb_read_uvlc(struct aom_read_bit_buffer *rb);
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
diff --git a/aom_dsp/bitwriter_buffer.c b/aom_dsp/bitwriter_buffer.c
index a563bf6..596246d 100644
--- a/aom_dsp/bitwriter_buffer.c
+++ b/aom_dsp/bitwriter_buffer.c
@@ -73,3 +73,15 @@
                                      int bits) {
   aom_wb_write_literal(wb, data, bits + 1);
 }
+
+void aom_wb_write_uvlc(struct aom_write_bit_buffer *wb, uint32_t v) {
+  int64_t shift_val = ++v;
+  int leading_zeroes = 1;
+
+  assert(shift_val > 0);
+
+  while (shift_val >>= 1) leading_zeroes += 2;
+
+  aom_wb_write_literal(wb, 0, leading_zeroes >> 1);
+  aom_wb_write_unsigned_literal(wb, v, (leading_zeroes + 1) >> 1);
+}
diff --git a/aom_dsp/bitwriter_buffer.h b/aom_dsp/bitwriter_buffer.h
index f7f75a0..8159c7f 100644
--- a/aom_dsp/bitwriter_buffer.h
+++ b/aom_dsp/bitwriter_buffer.h
@@ -42,6 +42,8 @@
 void aom_wb_write_inv_signed_literal(struct aom_write_bit_buffer *wb, int data,
                                      int bits);
 
+void aom_wb_write_uvlc(struct aom_write_bit_buffer *wb, uint32_t v);
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif