]> granicus.if.org Git - libvpx/commitdiff
Migrate bitwriter to the interface in aom/master
authorAlex Converse <aconverse@google.com>
Tue, 20 Sep 2016 23:39:01 +0000 (16:39 -0700)
committerAlex Converse <aconverse@google.com>
Wed, 21 Sep 2016 18:17:08 +0000 (11:17 -0700)
Change-Id: I73d46229f0feea43cbe933e51da997833cce032b

aom_dsp/bitwriter.h
av1/encoder/bitstream.c
av1/encoder/bitwriter.h
av1/encoder/treewriter.h
test/av1_ans_test.cc
test/test.mk

index 550893a4252776740feae2031a7ec3631ee0d53b..d3e4ae9c66a518f2b20244cf85558332b8cef0ac 100644 (file)
 #ifndef AOM_DSP_BITWRITER_H_
 #define AOM_DSP_BITWRITER_H_
 
+#include <assert.h>
+#include "./aom_config.h"
+#if CONFIG_ANS
+#include "aom_dsp/buf_ans.h"
+#elif CONFIG_DAALA_EC
+#include "aom_dsp/daalaboolwriter.h"
+#else
 #include "aom_dsp/dkboolwriter.h"
+#endif
 #include "aom_dsp/prob.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#if CONFIG_ANS
+typedef struct BufAnsCoder aom_writer;
+#else
 typedef struct aom_dk_writer aom_writer;
+#endif
 
 static INLINE void aom_start_encode(aom_writer *bc, uint8_t *buffer) {
+#if CONFIG_ANS
+  (void)bc;
+  (void)buffer;
+  assert(0 && "buf_ans requires a more complicated startup procedure");
+#else
   aom_dk_start_encode(bc, buffer);
+#endif
 }
 
-static INLINE void aom_stop_encode(aom_writer *bc) { aom_dk_stop_encode(bc); }
+static INLINE void aom_stop_encode(aom_writer *bc) {
+#if CONFIG_ANS
+  (void)bc;
+  assert(0 && "buf_ans requires a more complicated shutdown procedure");
+#else
+  aom_dk_stop_encode(bc);
+#endif
+}
 
 static INLINE void aom_write(aom_writer *br, int bit, int probability) {
+#if CONFIG_ANS
+  buf_uabs_write(br, bit, probability);
+#else
   aom_dk_write(br, bit, probability);
+#endif
 }
 
 static INLINE void aom_write_bit(aom_writer *w, int bit) {
-  aom_dk_write_bit(w, bit);
+  aom_write(w, bit, 128);  // aom_prob_half
 }
 
 static INLINE void aom_write_literal(aom_writer *w, int data, int bits) {
-  aom_dk_write_literal(w, data, bits);
+  int bit;
+
+  for (bit = bits - 1; bit >= 0; bit--) aom_write_bit(w, 1 & (data >> bit));
 }
 
 #ifdef __cplusplus
index fedc26390bf0aff8c46bb8f99f79b23992eceee1..82f60facc165de8b4c819b743632885cfc736411 100644 (file)
@@ -2890,7 +2890,7 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
   const int have_tiles = tile_cols * tile_rows > 1;
 #endif  // CONFIG_EXT_TILE
 #if CONFIG_ANS
-  BufAnsCoder *buf_ans = &cpi->buf_ans;
+  struct BufAnsCoder *buf_ans = &cpi->buf_ans;
 #endif  // CONFIG_ANS
 
   *max_tile_size = 0;
index e4e72502aab58b4d28fe9c91e84ef161835f3d02..21cc6a3a8e72bb735307f8bbf2803848dc8d94ae 100644 (file)
 #ifndef AOM10_ENCODER_BITWRITER_H_
 #define AOM10_ENCODER_BITWRITER_H_
 
-#include "./aom_config.h"
-#include "aom_dsp/prob.h"
-// Include bitwriter.h in the CONFIG_ANS to keep ANS building while
-// porting from VP10 style entropy coder abstraction to the aom/master style
-// entropy coder abstractions.
 #include "aom_dsp/bitwriter.h"
 
-#if CONFIG_ANS
-typedef struct BufAnsCoder BufAnsCoder;
-#include "aom_dsp/buf_ans.h"
-#define aom_writer BufAnsCoder
-#define aom_write buf_uabs_write
-#define aom_write_bit buf_uabs_write_bit
-#define aom_write_literal buf_uabs_write_literal
-#else
-#define aom_writer aom_writer
-#define aom_write aom_write
-#define aom_write_bit aom_write_bit
-#define aom_write_literal aom_write_literal
-#endif
-
 #endif  // AOM10_ENCODER_BITWRITER_H_
index 7a5c702ed5bb18400226bcf199a91b82e5995186..eb7f0a7c8b965486a3cb7de3431ccb97c9fca35b 100644 (file)
@@ -13,9 +13,9 @@
 #define AV1_ENCODER_TREEWRITER_H_
 
 #ifdef AV1_FORCE_AOMBOOL_TREEWRITER
-#include "aom_dsp/bitwriter.h"
-#define tree_writer aom_writer
-#define tree_bit_write aom_write
+#include "aom_dsp/dkboolwriter.h"
+#define tree_writer aom_dk_writer
+#define tree_bit_write aom_dk_write
 #else
 #include "av1/encoder/bitwriter.h"
 #define tree_writer aom_writer
index 29a1cf5d519988c435800f7498ae84f4d3ab257e..b0cec902351d580574c1aa5a221bb75051462627 100644 (file)
 
 #include "third_party/googletest/src/include/gtest/gtest.h"
 
-#include "test/acm_random.h"
 #include "aom_dsp/ans.h"
-#include "av1/encoder/treewriter.h"
 #include "aom_dsp/bitreader.h"
 #include "aom_dsp/bitwriter.h"
+#include "aom_dsp/dkboolwriter.h"
+#include "av1/encoder/treewriter.h"
+#include "test/acm_random.h"
 
 namespace {
 typedef std::vector<std::pair<uint8_t, bool> > PvVec;
@@ -125,16 +126,16 @@ bool check_uabs(const PvVec &pv_vec, uint8_t *buf) {
 }
 
 bool check_aombool(const PvVec &pv_vec, uint8_t *buf) {
-  aom_writer w;
+  aom_dk_writer w;
   aom_reader r;
-  aom_start_encode(&w, buf);
+  aom_dk_start_encode(&w, buf);
 
   std::clock_t start = std::clock();
   for (PvVec::const_iterator it = pv_vec.begin(); it != pv_vec.end(); ++it) {
-    aom_write(&w, it->second, 256 - it->first);
+    aom_dk_write(&w, it->second, 256 - it->first);
   }
   std::clock_t enc_time = std::clock() - start;
-  aom_stop_encode(&w);
+  aom_dk_stop_encode(&w);
   bool okay = true;
   aom_reader_init(&r, buf, w.pos, NULL, NULL);
   start = std::clock();
@@ -274,9 +275,9 @@ void build_tpb(aom_prob probs[/*num_syms*/],
 
 bool check_aomtree(const std::vector<int> &sym_vec, const rans_sym *sym_tab,
                    uint8_t *buf) {
-  aom_writer w;
+  aom_dk_writer w;
   aom_reader r;
-  aom_start_encode(&w, buf);
+  aom_dk_start_encode(&w, buf);
 
   aom_prob probs[kDistinctSyms];
   aom_tree_index tree[2 * kDistinctSyms];
@@ -289,7 +290,7 @@ bool check_aomtree(const std::vector<int> &sym_vec, const rans_sym *sym_tab,
     av1_write_tree(&w, tree, probs, bit_len[*it].bits, bit_len[*it].len, 0);
   }
   std::clock_t enc_time = std::clock() - start;
-  aom_stop_encode(&w);
+  aom_dk_stop_encode(&w);
   aom_reader_init(&r, buf, w.pos, NULL, NULL);
   start = std::clock();
   for (std::vector<int>::const_iterator it = sym_vec.begin();
index 30b1b6813423d2a70d28b484699f8b387d27e798..ce9e342e93dbf2c86371dcec37ca37d70bb1e286 100644 (file)
@@ -101,7 +101,11 @@ LIBAOM_TEST_SRCS-yes                   += idct8x8_test.cc
 LIBAOM_TEST_SRCS-yes                   += partial_idct_test.cc
 LIBAOM_TEST_SRCS-yes                   += superframe_test.cc
 LIBAOM_TEST_SRCS-yes                   += tile_independence_test.cc
+ifeq ($(CONFIG_ANS),yes)
+LIBAOM_TEST_SRCS-yes                   += av1_ans_test.cc
+else
 LIBAOM_TEST_SRCS-yes                   += boolcoder_test.cc
+endif
 LIBAOM_TEST_SRCS-yes                   += divu_small_test.cc
 #LIBAOM_TEST_SRCS-yes                   += encoder_parms_get_to_decoder.cc
 endif
@@ -136,7 +140,6 @@ ifeq ($(CONFIG_EXT_TX),yes)
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_fht8x16_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += av1_fht16x8_test.cc
 endif
-LIBAOM_TEST_SRCS-$(CONFIG_ANS)          += av1_ans_test.cc
 LIBAOM_TEST_SRCS-$(CONFIG_EXT_TILE)     += av1_ext_tile_test.cc
 
 LIBAOM_TEST_SRCS-$(CONFIG_AV1_ENCODER) += sum_squares_test.cc