Migrate bitwriter to the interface in aom/master

Change-Id: I73d46229f0feea43cbe933e51da997833cce032b
This commit is contained in:
Alex Converse 2016-09-20 16:39:01 -07:00
Родитель 8f71e396b1
Коммит 080a2cccba
6 изменённых файлов: 52 добавлений и 36 удалений

Просмотреть файл

@ -12,31 +12,62 @@
#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

Просмотреть файл

@ -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;

Просмотреть файл

@ -14,25 +14,6 @@
#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_

Просмотреть файл

@ -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

Просмотреть файл

@ -19,11 +19,12 @@
#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();

Просмотреть файл

@ -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