Commit 346440bd authored by Alex Converse's avatar Alex Converse

Use the standard aom_reader_init() interface for ans

Change-Id: I4a0f0a775362e6e43cd28ed29bf83c912cdc7df5
parent 8f110572
......@@ -135,9 +135,6 @@ static INLINE int rans_read(struct AnsDecoder *ans, const aom_cdf_prob *tab) {
}
static INLINE int ans_read_init(struct AnsDecoder *const ans,
#if ANS_MAX_SYMBOLS
int window_size,
#endif
const uint8_t *const buf, int offset) {
unsigned x;
if (offset < 1) return 1;
......@@ -180,19 +177,14 @@ static INLINE int ans_read_init(struct AnsDecoder *const ans,
ans->state += L_BASE;
if (ans->state >= L_BASE * IO_BASE) return 1;
#if ANS_MAX_SYMBOLS
ans->window_size = window_size;
ans->symbols_left = window_size;
ans->symbols_left = ans->window_size;
#endif
return 0;
}
#if ANS_REVERSE
static INLINE int ans_read_reinit(struct AnsDecoder *const ans) {
return ans_read_init(ans,
#if ANS_MAX_SYMBOLS
ans->window_size,
#endif
ans->buf + ans->buf_offset, -ans->buf_offset);
return ans_read_init(ans, ans->buf + ans->buf_offset, -ans->buf_offset);
}
#endif
......
......@@ -72,21 +72,13 @@ typedef struct aom_dk_reader aom_reader;
#endif
static INLINE int aom_reader_init(aom_reader *r, const uint8_t *buffer,
size_t size,
#if CONFIG_ANS && ANS_MAX_SYMBOLS
size_t window_size,
#endif
aom_decrypt_cb decrypt_cb,
size_t size, aom_decrypt_cb decrypt_cb,
void *decrypt_state) {
#if CONFIG_ANS
(void)decrypt_cb;
(void)decrypt_state;
if (size > INT_MAX) return 1;
return ans_read_init(r,
#if ANS_MAX_SYMBOLS
(int)window_size,
#endif
buffer, (int)size);
return ans_read_init(r, buffer, (int)size);
#elif CONFIG_DAALA_EC
(void)decrypt_cb;
(void)decrypt_state;
......
......@@ -2202,11 +2202,10 @@ static void setup_bool_decoder(const uint8_t *data, const uint8_t *data_end,
aom_internal_error(error_info, AOM_CODEC_CORRUPT_FRAME,
"Truncated packet or corrupt tile length");
if (aom_reader_init(r, data, read_size,
#if CONFIG_ANS && ANS_MAX_SYMBOLS
ANS_MAX_SYMBOLS,
r->window_size = ANS_MAX_SYMBOLS;
#endif
decrypt_cb, decrypt_state))
if (aom_reader_init(r, data, read_size, decrypt_cb, decrypt_state))
aom_internal_error(error_info, AOM_CODEC_MEM_ERROR,
"Failed to allocate bool decoder %d", 1);
}
......@@ -4212,11 +4211,11 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
int j;
#endif
if (aom_reader_init(&r, data, partition_size,
#if CONFIG_ANS && ANS_MAX_SYMBOLS
ANS_MAX_SYMBOLS,
r.window_size = ANS_MAX_SYMBOLS;
#endif
pbi->decrypt_cb, pbi->decrypt_state))
if (aom_reader_init(&r, data, partition_size, pbi->decrypt_cb,
pbi->decrypt_state))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate bool decoder 0");
......
......@@ -35,11 +35,10 @@ TEST(AV1, TestAccounting) {
}
aom_stop_encode(&bw);
aom_reader br;
aom_reader_init(&br, bw_buffer, bw.pos,
#if CONFIG_ANS && ANS_MAX_SYMBOLS
1 << 16,
br.window_size = 1 << 16;
#endif
NULL, NULL);
aom_reader_init(&br, bw_buffer, bw.pos, NULL, NULL);
Accounting accounting;
aom_accounting_init(&accounting);
......
......@@ -65,12 +65,10 @@ bool check_uabs(const PvVec &pv_vec, uint8_t *buf) {
aom_buf_ans_free(&a);
bool okay = true;
AnsDecoder d;
if (ans_read_init(&d,
#if ANS_MAX_SYMBOLS
kBufAnsSize,
d.window_size = kBufAnsSize;
#endif
buf, offset))
return false;
if (ans_read_init(&d, buf, offset)) return false;
start = std::clock();
for (PvVec::const_iterator it = pv_vec.begin(); it != pv_vec.end(); ++it) {
okay = okay && (uabs_read(&d, 256 - it->first) != 0) == it->second;
......@@ -139,12 +137,10 @@ bool check_rans(const std::vector<int> &sym_vec, const rans_sym *const tab,
aom_buf_ans_free(&a);
bool okay = true;
AnsDecoder d;
if (ans_read_init(&d,
#if ANS_MAX_SYMBOLS
kBufAnsSize,
d.window_size = kBufAnsSize;
#endif
buf, offset))
return false;
if (ans_read_init(&d, buf, offset)) return false;
start = std::clock();
for (std::vector<int>::const_iterator it = sym_vec.begin();
it != sym_vec.end(); ++it) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment