Commit acef60bd authored by Alex Converse's avatar Alex Converse

Migrate bitreader to the interface from aom/master

Change-Id: I7232f9ae3d97e730f66e4b80f550192e3ef7230b
parent d9470c20
......@@ -12,45 +12,90 @@
#ifndef AOM_DSP_BITREADER_H_
#define AOM_DSP_BITREADER_H_
#include <assert.h>
#include "./aom_config.h"
#include "aom/aomdx.h"
#include "aom/aom_integer.h"
#if CONFIG_ANS
#include "aom_dsp/ans.h"
#else
#include "aom_dsp/dkboolreader.h"
#endif
#include "aom_dsp/prob.h"
#ifdef __cplusplus
extern "C" {
#endif
#if CONFIG_ANS
typedef struct AnsDecoder aom_reader;
#else
typedef struct aom_dk_reader aom_reader;
#endif
static INLINE int aom_reader_init(aom_reader *r, const uint8_t *buffer,
size_t size, aom_decrypt_cb decrypt_cb,
void *decrypt_state) {
#if CONFIG_ANS
(void)decrypt_cb;
(void)decrypt_state;
assert(size <= INT_MAX);
return ans_read_init(r, buffer, size);
#else
return aom_dk_reader_init(r, buffer, size, decrypt_cb, decrypt_state);
#endif
}
static INLINE const uint8_t *aom_reader_find_end(aom_reader *r) {
#if CONFIG_ANS
(void)r;
assert(0 && "Use the raw buffer size with ANS");
return NULL;
#else
return aom_dk_reader_find_end(r);
#endif
}
static INLINE int aom_reader_has_error(aom_reader *r) {
#if CONFIG_ANS
return ans_reader_has_error(r);
#else
return aom_dk_reader_has_error(r);
#endif
}
static INLINE int aom_read(aom_reader *r, int prob) {
#if CONFIG_ANS
return uabs_read(r, prob);
#else
return aom_dk_read(r, prob);
#endif
}
static INLINE int aom_read_bit(aom_reader *r) { return aom_dk_read_bit(r); }
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);
#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
}
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
}
#ifdef __cplusplus
......
......@@ -22,6 +22,7 @@
#include "aom_dsp/ans.h"
#include "aom_dsp/bitreader.h"
#include "aom_dsp/bitwriter.h"
#include "aom_dsp/dkboolreader.h"
#include "aom_dsp/dkboolwriter.h"
#include "av1/encoder/treewriter.h"
#include "test/acm_random.h"
......@@ -127,7 +128,7 @@ bool check_uabs(const PvVec &pv_vec, uint8_t *buf) {
bool check_aombool(const PvVec &pv_vec, uint8_t *buf) {
aom_dk_writer w;
aom_reader r;
aom_dk_reader r;
aom_dk_start_encode(&w, buf);
std::clock_t start = std::clock();
......@@ -137,10 +138,10 @@ bool check_aombool(const PvVec &pv_vec, uint8_t *buf) {
std::clock_t enc_time = std::clock() - start;
aom_dk_stop_encode(&w);
bool okay = true;
aom_reader_init(&r, buf, w.pos, NULL, NULL);
aom_dk_reader_init(&r, buf, w.pos, NULL, NULL);
start = std::clock();
for (PvVec::const_iterator it = pv_vec.begin(); it != pv_vec.end(); ++it) {
okay &= aom_read(&r, 256 - it->first) == it->second;
okay &= aom_dk_read(&r, 256 - it->first) == it->second;
}
std::clock_t dec_time = std::clock() - start;
printf("AOM size %d enc_time %f dec_time %f\n", w.pos,
......@@ -276,7 +277,7 @@ 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_dk_writer w;
aom_reader r;
aom_dk_reader r;
aom_dk_start_encode(&w, buf);
aom_prob probs[kDistinctSyms];
......@@ -291,11 +292,11 @@ bool check_aomtree(const std::vector<int> &sym_vec, const rans_sym *sym_tab,
}
std::clock_t enc_time = std::clock() - start;
aom_dk_stop_encode(&w);
aom_reader_init(&r, buf, w.pos, NULL, NULL);
aom_dk_reader_init(&r, buf, w.pos, NULL, NULL);
start = std::clock();
for (std::vector<int>::const_iterator it = sym_vec.begin();
it != sym_vec.end(); ++it) {
if (aom_read_tree(&r, tree, probs) != *it) return false;
if (aom_dk_read_tree(&r, tree, probs) != *it) return false;
}
std::clock_t dec_time = std::clock() - start;
printf("AOMtree size %u enc_time %f dec_time %f\n", w.pos,
......
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