Commit c8b22977 authored by Alex Converse's avatar Alex Converse Committed by Gerrit Code Review

Merge changes I13eed9cb,I3b213790,I7232f9ae into nextgenv2

* changes:
  Remove VP10 style bitreader and bitwriter wrappers
  Rename av1_ans_test to match aom/master.
  Migrate bitreader to the interface from aom/master
parents c7d6eaa5 4fb213f3
......@@ -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
......
......@@ -19,7 +19,6 @@ AV1_CX_SRCS_REMOVE-no += $(AV1_COMMON_SRCS_REMOVE-no)
AV1_CX_SRCS-yes += av1_cx_iface.c
AV1_CX_SRCS-yes += encoder/bitstream.c
AV1_CX_SRCS-yes += encoder/bitwriter.h
AV1_CX_SRCS-yes += encoder/context_tree.c
AV1_CX_SRCS-yes += encoder/context_tree.h
AV1_CX_SRCS-yes += encoder/variance_tree.c
......
......@@ -30,6 +30,5 @@ AV1_DX_SRCS-yes += decoder/decoder.c
AV1_DX_SRCS-yes += decoder/decoder.h
AV1_DX_SRCS-yes += decoder/dsubexp.c
AV1_DX_SRCS-yes += decoder/dsubexp.h
AV1_DX_SRCS-yes += decoder/bitreader.h
AV1_DX_SRCS-yes := $(filter-out $(AV1_DX_SRCS_REMOVE-yes),$(AV1_DX_SRCS-yes))
/*
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/* The purpose of this header is to provide compile time pluggable bit reader
* implementations with a common interface. */
#ifndef AOM10_DECODER_BITREADER_H_
#define AOM10_DECODER_BITREADER_H_
#include "./aom_config.h"
#if CONFIG_ANS
#include "aom_dsp/ans.h"
#include "aom/aomdx.h" // for av1_decrypt_cb
#define aom_reader struct AnsDecoder
#define aom_reader_has_error ans_reader_has_error
#define aom_read uabs_read
#define aom_read_bit uabs_read_bit
#define aom_read_literal uabs_read_literal
#define aom_read_tree uabs_read_tree
#else
#include "aom_dsp/bitreader.h"
#define aom_reader aom_reader
#define aom_reader_has_error aom_reader_has_error
#define aom_read aom_read
#define aom_read_bit aom_read_bit
#define aom_read_literal aom_read_literal
#define aom_read_tree aom_read_tree
#endif
#endif // AOM10_DECODER_BITREADER_H_
......@@ -12,7 +12,7 @@
#ifndef AV1_DECODER_DECODEMV_H_
#define AV1_DECODER_DECODEMV_H_
#include "av1/decoder/bitreader.h"
#include "aom_dsp/bitreader.h"
#include "av1/decoder/decoder.h"
......
......@@ -15,7 +15,7 @@
#include "./aom_config.h"
#include "aom/aom_codec.h"
#include "av1/decoder/bitreader.h"
#include "aom_dsp/bitreader.h"
#include "aom_scale/yv12config.h"
#include "aom_util/aom_thread.h"
......
......@@ -12,7 +12,7 @@
#ifndef AV1_DECODER_DSUBEXP_H_
#define AV1_DECODER_DSUBEXP_H_
#include "av1/decoder/bitreader.h"
#include "aom_dsp/bitreader.h"
#ifdef __cplusplus
extern "C" {
......
/*
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/* The purpose of this header is to provide compile time pluggable bit writer
* implementations with a common interface. */
#ifndef AOM10_ENCODER_BITWRITER_H_
#define AOM10_ENCODER_BITWRITER_H_
#include "aom_dsp/bitwriter.h"
#endif // AOM10_ENCODER_BITWRITER_H_
......@@ -8,7 +8,7 @@
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include "av1/encoder/bitwriter.h"
#include "aom_dsp/bitwriter.h"
#include "av1/common/common.h"
#include "av1/common/entropy.h"
......
......@@ -17,7 +17,7 @@
#define tree_writer aom_dk_writer
#define tree_bit_write aom_dk_write
#else
#include "av1/encoder/bitwriter.h"
#include "aom_dsp/bitwriter.h"
#define tree_writer aom_writer
#define tree_bit_write aom_write
#endif
......
......@@ -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,
......@@ -304,7 +305,7 @@ bool check_aomtree(const std::vector<int> &sym_vec, const rans_sym *sym_tab,
return true;
}
class Av1AbsTest : public ::testing::Test {
class AbsTest : public ::testing::Test {
protected:
static void SetUpTestCase() { pv_vec_ = abs_encode_build_vals(kNumBools); }
virtual void SetUp() { buf_ = new uint8_t[kNumBools / 8]; }
......@@ -313,9 +314,9 @@ class Av1AbsTest : public ::testing::Test {
static PvVec pv_vec_;
uint8_t *buf_;
};
PvVec Av1AbsTest::pv_vec_;
PvVec AbsTest::pv_vec_;
class Av1AnsTest : public ::testing::Test {
class AnsTest : public ::testing::Test {
protected:
static void SetUpTestCase() {
sym_vec_ = ans_encode_build_vals(rans_sym_tab, kNumSyms);
......@@ -326,17 +327,15 @@ class Av1AnsTest : public ::testing::Test {
static std::vector<int> sym_vec_;
uint8_t *buf_;
};
std::vector<int> Av1AnsTest::sym_vec_;
std::vector<int> AnsTest::sym_vec_;
TEST_F(Av1AbsTest, Avxbool) { EXPECT_TRUE(check_aombool(pv_vec_, buf_)); }
TEST_F(Av1AbsTest, Rabs) { EXPECT_TRUE(check_rabs(pv_vec_, buf_)); }
TEST_F(Av1AbsTest, RabsAsc) { EXPECT_TRUE(check_rabs_asc(pv_vec_, buf_)); }
TEST_F(Av1AbsTest, Uabs) { EXPECT_TRUE(check_uabs(pv_vec_, buf_)); }
TEST_F(AbsTest, Avxbool) { EXPECT_TRUE(check_aombool(pv_vec_, buf_)); }
TEST_F(AbsTest, Rabs) { EXPECT_TRUE(check_rabs(pv_vec_, buf_)); }
TEST_F(AbsTest, RabsAsc) { EXPECT_TRUE(check_rabs_asc(pv_vec_, buf_)); }
TEST_F(AbsTest, Uabs) { EXPECT_TRUE(check_uabs(pv_vec_, buf_)); }
TEST_F(Av1AnsTest, Rans) {
EXPECT_TRUE(check_rans(sym_vec_, rans_sym_tab, buf_));
}
TEST_F(Av1AnsTest, Avxtree) {
TEST_F(AnsTest, Rans) { EXPECT_TRUE(check_rans(sym_vec_, rans_sym_tab, buf_)); }
TEST_F(AnsTest, Avxtree) {
EXPECT_TRUE(check_aomtree(sym_vec_, rans_sym_tab, buf_));
}
} // namespace
......@@ -102,7 +102,7 @@ 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
LIBAOM_TEST_SRCS-yes += ans_test.cc
else
LIBAOM_TEST_SRCS-yes += boolcoder_test.cc
endif
......
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