Commit b0460fa9 authored by Sebastien Alaiwan's avatar Sebastien Alaiwan

Remove ANS experiment

This experiment has been abandonned for AV1.

Change-Id: I8110720cef1b56dbce4008a998d8f4281dd2fe44
parent b756d247
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* 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.
*/
#ifndef AOM_DSP_ANS_H_
#define AOM_DSP_ANS_H_
// Constants, types and utilities for Asymmetric Numeral Systems
// http://arxiv.org/abs/1311.2540v2
#include <assert.h>
#include "./aom_config.h"
#include "aom/aom_integer.h"
#include "aom_dsp/prob.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Use windowed ANS, size is passed in at initialization
#define ANS_MAX_SYMBOLS 1
#define ANS_REVERSE 1
typedef uint8_t AnsP8;
#define ANS_P8_PRECISION 256u
#define ANS_P8_SHIFT 8
#define RANS_PROB_BITS 15
#define RANS_PRECISION (1u << RANS_PROB_BITS)
// L_BASE is the ANS base state. L_BASE % PRECISION must be 0.
#define L_BASE (1u << 17)
#define IO_BASE 256
// Range I = { L_BASE, L_BASE + 1, ..., L_BASE * IO_BASE - 1 }
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // AOM_DSP_ANS_H_
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* 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.
*/
#ifndef AOM_DSP_ANSREADER_H_
#define AOM_DSP_ANSREADER_H_
// An implementation of Asymmetric Numeral Systems
// http://arxiv.org/abs/1311.2540v2
// Implements decoding of:
// * rABS (range Asymmetric Binary Systems), a boolean coder
// * rANS (range Asymmetric Numeral Systems), a multi-symbol coder
#include <assert.h>
#include "./aom_config.h"
#include "aom/aom_integer.h"
#include "aom_dsp/prob.h"
#include "aom_dsp/ans.h"
#include "aom_ports/mem_ops.h"
#if CONFIG_ACCOUNTING
#include "av1/decoder/accounting.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
struct AnsDecoder {
const uint8_t *buf;
int buf_offset;
uint32_t state;
#if ANS_MAX_SYMBOLS
int symbols_left;
int window_size;
#endif
#if CONFIG_ACCOUNTING
Accounting *accounting;
#endif
uint8_t allow_update_cdf;
};
static INLINE int ans_read_reinit(struct AnsDecoder *const ans);
static INLINE unsigned refill_state(struct AnsDecoder *const ans,
unsigned state) {
#if ANS_REVERSE
while (state < L_BASE && ans->buf_offset < 0) {
state = state * IO_BASE + ans->buf[ans->buf_offset++];
}
#else
while (state < L_BASE && ans->buf_offset > 0) {
state = state * IO_BASE + ans->buf[--ans->buf_offset];
}
#endif
return state;
}
// Decode one rABS encoded boolean where the probability of the value being zero
// is p0.
static INLINE int rabs_read(struct AnsDecoder *ans, AnsP8 p0) {
#if ANS_MAX_SYMBOLS
if (ans->symbols_left-- == 0) {
ans_read_reinit(ans);
ans->symbols_left--;
}
#endif
unsigned state = refill_state(ans, ans->state);
const unsigned quotient = state / ANS_P8_PRECISION;
const unsigned remainder = state % ANS_P8_PRECISION;
const int value = remainder >= p0;
const unsigned qp0 = quotient * p0;
if (value)
state = state - qp0 - p0;
else
state = qp0 + remainder;
ans->state = state;
return value;
}
// Decode one rABS encoded boolean where the probability of the value being zero
// is one half.
static INLINE int rabs_read_bit(struct AnsDecoder *ans) {
#if ANS_MAX_SYMBOLS
if (ans->symbols_left-- == 0) {
ans_read_reinit(ans);
ans->symbols_left--;
}
#endif
unsigned state = refill_state(ans, ans->state);
const int value = !!(state & 0x80);
ans->state = ((state >> 1) & ~0x7F) | (state & 0x7F);
return value;
}
struct rans_dec_sym {
uint8_t val;
aom_cdf_prob prob;
aom_cdf_prob cum_prob; // not-inclusive
};
static INLINE void fetch_sym(struct rans_dec_sym *out, const aom_cdf_prob *cdf,
aom_cdf_prob rem) {
int i;
aom_cdf_prob cum_prob = 0, top_prob;
// TODO(skal): if critical, could be a binary search.
// Or, better, an O(1) alias-table.
for (i = 0; rem >= (top_prob = cdf[i]); ++i) {
cum_prob = top_prob;
}
out->val = i;
out->prob = top_prob - cum_prob;
out->cum_prob = cum_prob;
}
static INLINE int rans_read(struct AnsDecoder *ans, const aom_cdf_prob *tab) {
unsigned rem;
unsigned quo;
struct rans_dec_sym sym;
#if ANS_MAX_SYMBOLS
if (ans->symbols_left-- == 0) {
ans_read_reinit(ans);
ans->symbols_left--;
}
#endif
ans->state = refill_state(ans, ans->state);
quo = ans->state / RANS_PRECISION;
rem = ans->state % RANS_PRECISION;
fetch_sym(&sym, tab, rem);
ans->state = quo * sym.prob + rem - sym.cum_prob;
return sym.val;
}
static INLINE int ans_read_init(struct AnsDecoder *const ans,
const uint8_t *const buf, int offset) {
unsigned x;
if (offset < 1) return 1;
#if ANS_REVERSE
ans->buf = buf + offset;
ans->buf_offset = -offset;
x = buf[0];
if ((x & 0x80) == 0) { // Marker is 0xxx xxxx
if (offset < 2) return 1;
ans->buf_offset += 2;
ans->state = mem_get_be16(buf) & 0x7FFF;
#if L_BASE * IO_BASE > (1 << 23)
} else if ((x & 0xC0) == 0x80) { // Marker is 10xx xxxx
if (offset < 3) return 1;
ans->buf_offset += 3;
ans->state = mem_get_be24(buf) & 0x3FFFFF;
} else { // Marker is 11xx xxxx
if (offset < 4) return 1;
ans->buf_offset += 4;
ans->state = mem_get_be32(buf) & 0x3FFFFFFF;
#else
} else { // Marker is 1xxx xxxx
if (offset < 3) return 1;
ans->buf_offset += 3;
ans->state = mem_get_be24(buf) & 0x7FFFFF;
#endif
}
#else
ans->buf = buf;
x = buf[offset - 1];
if ((x & 0x80) == 0) { // Marker is 0xxx xxxx
if (offset < 2) return 1;
ans->buf_offset = offset - 2;
ans->state = mem_get_le16(buf + offset - 2) & 0x7FFF;
} else if ((x & 0xC0) == 0x80) { // Marker is 10xx xxxx
if (offset < 3) return 1;
ans->buf_offset = offset - 3;
ans->state = mem_get_le24(buf + offset - 3) & 0x3FFFFF;
} else if ((x & 0xE0) == 0xE0) { // Marker is 111x xxxx
if (offset < 4) return 1;
ans->buf_offset = offset - 4;
ans->state = mem_get_le32(buf + offset - 4) & 0x1FFFFFFF;
} else {
// Marker 110x xxxx implies this byte is a superframe marker
return 1;
}
#endif // ANS_REVERSE
#if CONFIG_ACCOUNTING
ans->accounting = NULL;
#endif
ans->state += L_BASE;
if (ans->state >= L_BASE * IO_BASE) return 1;
#if ANS_MAX_SYMBOLS
assert(ans->window_size > 1);
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, ans->buf + ans->buf_offset, -ans->buf_offset);
}
#endif
static INLINE int ans_read_end(const struct AnsDecoder *const ans) {
return ans->buf_offset == 0 && ans->state < L_BASE;
}
static INLINE int ans_reader_has_error(const struct AnsDecoder *const ans) {
return ans->state < L_BASE / RANS_PRECISION;
}
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // AOM_DSP_ANSREADER_H_
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* 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.
*/
#ifndef AOM_DSP_ANSWRITER_H_
#define AOM_DSP_ANSWRITER_H_
// An implementation of Asymmetric Numeral Systems
// http://arxiv.org/abs/1311.2540v2
// Implements encoding of:
// * rABS (range Asymmetric Binary Systems), a boolean coder
// * rANS (range Asymmetric Numeral Systems), a multi-symbol coder
#include <assert.h>
#include "./aom_config.h"
#include "aom/aom_integer.h"
#include "aom_dsp/ans.h"
#include "aom_dsp/prob.h"
#include "aom_ports/mem_ops.h"
#include "av1/common/odintrin.h"
#if RANS_PRECISION <= OD_DIVU_DMAX
#define ANS_DIVREM(quotient, remainder, dividend, divisor) \
do { \
quotient = OD_DIVU_SMALL((dividend), (divisor)); \
remainder = (dividend) - (quotient) * (divisor); \
} while (0)
#else
#define ANS_DIVREM(quotient, remainder, dividend, divisor) \
do { \
quotient = (dividend) / (divisor); \
remainder = (dividend) % (divisor); \
} while (0)
#endif
#define ANS_DIV8(dividend, divisor) OD_DIVU_SMALL((dividend), (divisor))
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
struct AnsCoder {
uint8_t *buf;
int buf_offset;
uint32_t state;
};
static INLINE void ans_write_init(struct AnsCoder *const ans,
uint8_t *const buf) {
ans->buf = buf;
ans->buf_offset = 0;
ans->state = L_BASE;
}
static INLINE int ans_write_end(struct AnsCoder *const ans) {
uint32_t state;
int ans_size;
assert(ans->state >= L_BASE);
assert(ans->state < L_BASE * IO_BASE);
state = ans->state - L_BASE;
if (state < (1u << 15)) {
mem_put_le16(ans->buf + ans->buf_offset, (0x00u << 15) + state);
ans_size = ans->buf_offset + 2;
#if ANS_REVERSE
#if L_BASE * IO_BASE > (1 << 23)
} else if (state < (1u << 22)) {
mem_put_le24(ans->buf + ans->buf_offset, (0x02u << 22) + state);
ans_size = ans->buf_offset + 3;
} else if (state < (1u << 30)) {
mem_put_le32(ans->buf + ans->buf_offset, (0x03u << 30) + state);
ans_size = ans->buf_offset + 4;
#else
} else if (state < (1u << 23)) {
mem_put_le24(ans->buf + ans->buf_offset, (0x01u << 23) + state);
ans_size = ans->buf_offset + 3;
#endif
#else
} else if (state < (1u << 22)) {
mem_put_le24(ans->buf + ans->buf_offset, (0x02u << 22) + state);
ans_size = ans->buf_offset + 3;
} else if (state < (1u << 29)) {
mem_put_le32(ans->buf + ans->buf_offset, (0x07u << 29) + state);
ans_size = ans->buf_offset + 4;
#endif
} else {
assert(0 && "State is too large to be serialized");
return ans->buf_offset;
}
#if ANS_REVERSE
{
int i;
uint8_t tmp;
for (i = 0; i < (ans_size >> 1); i++) {
tmp = ans->buf[i];
ans->buf[i] = ans->buf[ans_size - 1 - i];
ans->buf[ans_size - 1 - i] = tmp;
}
ans->buf += ans_size;
ans->buf_offset = 0;
ans->state = L_BASE;
}
#endif
return ans_size;
}
// Write one boolean using rABS where p0 is the probability of the value being
// zero.
static INLINE void rabs_write(struct AnsCoder *ans, int value, AnsP8 p0) {
const AnsP8 p = ANS_P8_PRECISION - p0;
const unsigned l_s = value ? p : p0;
unsigned state = ans->state;
while (state >= L_BASE / ANS_P8_PRECISION * IO_BASE * l_s) {
ans->buf[ans->buf_offset++] = state % IO_BASE;
state /= IO_BASE;
}
const unsigned quotient = ANS_DIV8(state, l_s);
const unsigned remainder = state - quotient * l_s;
ans->state = quotient * ANS_P8_PRECISION + remainder + (value ? p0 : 0);
}
// Encode one symbol using rANS.
// cum_prob: The cumulative probability before this symbol (the offset of
// the symbol in the symbol cycle)
// prob: The probability of this symbol (l_s from the paper)
// RANS_PRECISION takes the place of m from the paper.
static INLINE void rans_write(struct AnsCoder *ans, aom_cdf_prob cum_prob,
aom_cdf_prob prob) {
unsigned quotient, remainder;
while (ans->state >= L_BASE / RANS_PRECISION * IO_BASE * prob) {
ans->buf[ans->buf_offset++] = ans->state % IO_BASE;
ans->state /= IO_BASE;
}
ANS_DIVREM(quotient, remainder, ans->state, prob);
ans->state = quotient * RANS_PRECISION + remainder + cum_prob;
}
#undef ANS_DIV8
#undef ANS_DIVREM
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // AOM_DSP_ANSWRITER_H_
......@@ -269,16 +269,10 @@ else ()
"${AOM_ROOT}/aom_dsp/mips/itrans8_dspr2.c")
endif ()
if (CONFIG_ANS)
set(AOM_DSP_COMMON_SOURCES
${AOM_DSP_COMMON_SOURCES}
"${AOM_ROOT}/aom_dsp/ans.h")
else ()
set(AOM_DSP_COMMON_SOURCES
${AOM_DSP_COMMON_SOURCES}
"${AOM_ROOT}/aom_dsp/entcode.c"
"${AOM_ROOT}/aom_dsp/entcode.h")
endif ()
set(AOM_DSP_COMMON_SOURCES
${AOM_DSP_COMMON_SOURCES}
"${AOM_ROOT}/aom_dsp/entcode.c"
"${AOM_ROOT}/aom_dsp/entcode.h")
if (CONFIG_AV1)
set(AOM_DSP_COMMON_SOURCES
......@@ -304,18 +298,12 @@ if (CONFIG_AV1_DECODER)
"${AOM_ROOT}/aom_dsp/bitreader_buffer.c"
"${AOM_ROOT}/aom_dsp/bitreader_buffer.h")
if (CONFIG_ANS)
set(AOM_DSP_DECODER_SOURCES
${AOM_DSP_DECODER_SOURCES}
"${AOM_ROOT}/aom_dsp/ansreader.h")
else ()
set(AOM_DSP_DECODER_SOURCES
${AOM_DSP_DECODER_SOURCES}
"${AOM_ROOT}/aom_dsp/daalaboolreader.c"
"${AOM_ROOT}/aom_dsp/daalaboolreader.h"
"${AOM_ROOT}/aom_dsp/entdec.c"
"${AOM_ROOT}/aom_dsp/entdec.h")
endif ()
set(AOM_DSP_DECODER_SOURCES
${AOM_DSP_DECODER_SOURCES}
"${AOM_ROOT}/aom_dsp/daalaboolreader.c"
"${AOM_ROOT}/aom_dsp/daalaboolreader.h"
"${AOM_ROOT}/aom_dsp/entdec.c"
"${AOM_ROOT}/aom_dsp/entdec.h")
endif ()
if (CONFIG_AV1_ENCODER)
......@@ -435,20 +423,12 @@ if (CONFIG_AV1_ENCODER)
"${AOM_ROOT}/aom_dsp/x86/sad_highbd_avx2.c")
endif ()
if (CONFIG_ANS)
set(AOM_DSP_ENCODER_SOURCES
${AOM_DSP_ENCODER_SOURCES}
"${AOM_ROOT}/aom_dsp/answriter.h"
"${AOM_ROOT}/aom_dsp/buf_ans.c"
"${AOM_ROOT}/aom_dsp/buf_ans.h")
else ()
set(AOM_DSP_ENCODER_SOURCES
${AOM_DSP_ENCODER_SOURCES}
"${AOM_ROOT}/aom_dsp/daalaboolwriter.c"
"${AOM_ROOT}/aom_dsp/daalaboolwriter.h"
"${AOM_ROOT}/aom_dsp/entenc.c"
"${AOM_ROOT}/aom_dsp/entenc.h")
endif ()
set(AOM_DSP_ENCODER_SOURCES
${AOM_DSP_ENCODER_SOURCES}
"${AOM_ROOT}/aom_dsp/daalaboolwriter.c"
"${AOM_ROOT}/aom_dsp/daalaboolwriter.h"
"${AOM_ROOT}/aom_dsp/entenc.c"
"${AOM_ROOT}/aom_dsp/entenc.h")
if (CONFIG_INTERNAL_STATS)
set(AOM_DSP_ENCODER_SOURCES
......
......@@ -20,19 +20,12 @@ DSP_SRCS-$(ARCH_X86)$(ARCH_X86_64) += x86/synonyms.h
# bit reader
DSP_SRCS-yes += prob.h
DSP_SRCS-yes += prob.c
DSP_SRCS-$(CONFIG_ANS) += ans.h
ifeq ($(CONFIG_AV1_ENCODER),yes)
ifeq ($(CONFIG_ANS),yes)
DSP_SRCS-yes += answriter.h
DSP_SRCS-yes += buf_ans.h
DSP_SRCS-yes += buf_ans.c
else
DSP_SRCS-yes += entenc.c
DSP_SRCS-yes += entenc.h
DSP_SRCS-yes += daalaboolwriter.c
DSP_SRCS-yes += daalaboolwriter.h
endif
DSP_SRCS-yes += bitwriter.h
DSP_SRCS-yes += bitwriter_buffer.c
DSP_SRCS-yes += bitwriter_buffer.h
......@@ -47,14 +40,10 @@ DSP_SRCS-$(CONFIG_INTERNAL_STATS) += fastssim.c
endif
ifeq ($(CONFIG_AV1_DECODER),yes)
ifeq ($(CONFIG_ANS),yes)
DSP_SRCS-yes += ansreader.h
else
DSP_SRCS-yes += entdec.c
DSP_SRCS-yes += entdec.h
DSP_SRCS-yes += daalaboolreader.c
DSP_SRCS-yes += daalaboolreader.h
endif
DSP_SRCS-yes += bitreader.h
DSP_SRCS-yes += bitreader_buffer.c
DSP_SRCS-yes += bitreader_buffer.h
......@@ -66,10 +55,8 @@ endif
DSP_SRCS-yes += intrapred.c
DSP_SRCS-yes += intrapred_common.h
ifneq ($(CONFIG_ANS),yes)
DSP_SRCS-yes += entcode.c
DSP_SRCS-yes += entcode.h
endif
DSP_SRCS-$(HAVE_SSE) += x86/intrapred_sse2.asm
DSP_SRCS-$(HAVE_SSE2) += x86/intrapred_sse2.asm
......
......@@ -19,11 +19,7 @@
#include "aom/aomdx.h"
#include "aom/aom_integer.h"
#if CONFIG_ANS
#include "aom_dsp/ansreader.h"
#else
#include "aom_dsp/daalaboolreader.h"
#endif
#include "aom_dsp/prob.h"
#include "av1/common/odintrin.h"
......@@ -63,63 +59,32 @@
extern "C" {
#endif
#if CONFIG_ANS
typedef struct AnsDecoder aom_reader;
#else
typedef struct daala_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) {
(void)decrypt_cb;
(void)decrypt_state;
#if CONFIG_ANS
if (size > INT_MAX) return 1;
return ans_read_init(r, buffer, (int)size);
#else
return aom_daala_reader_init(r, buffer, (int)size);
#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_daala_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_daala_reader_has_error(r);
#endif
}
// Returns the position in the bit reader in bits.
static INLINE uint32_t aom_reader_tell(const aom_reader *r) {
#if CONFIG_ANS
(void)r;
assert(0 && "aom_reader_tell() is unimplemented for ANS");
return 0;
#else
return aom_daala_reader_tell(r);
#endif
}
// Returns the position in the bit reader in 1/8th bits.
static INLINE uint32_t aom_reader_tell_frac(const aom_reader *r) {
#if CONFIG_ANS
(void)r;
assert(0 && "aom_reader_tell_frac() is unimplemented for ANS");
return 0;
#else
return aom_daala_reader_tell_frac(r);
#endif
}
#if CONFIG_ACCOUNTING
......@@ -143,11 +108,7 @@ static INLINE void aom_update_symb_counts(const aom_reader *r, int is_binary) {
static INLINE int aom_read_(aom_reader *r, int prob ACCT_STR_PARAM) {
int ret;
#if CONFIG_ANS
ret = rabs_read(r, prob);
#else
ret = aom_daala_read(r, prob);
#endif
#if CONFIG_ACCOUNTING
if (ACCT_STR_NAME) aom_process_accounting(r, ACCT_STR_NAME);
aom_update_symb_counts(r, 1);
......@@ -157,11 +118,7 @@ static INLINE int aom_read_(aom_reader *r, int prob ACCT_STR_PARAM) {
static INLINE int aom_read_bit_(aom_reader *r ACCT_STR_PARAM) {
int ret;
#if CONFIG_ANS
ret = rabs_read_bit(r); // Non trivial optimization at half probability
#else
ret = aom_read(r, 128, NULL); // aom_prob_half
#endif
#if CONFIG_ACCOUNTING
if (ACCT_STR_NAME) aom_process_accounting(r, ACCT_STR_NAME);
#endif
......@@ -181,12 +138,7 @@ static INLINE int aom_read_literal_(aom_reader *r, int bits ACCT_STR_PARAM) {
static INLINE int aom_read_cdf_(aom_reader *r, const aom_cdf_prob *cdf,
int nsymbs ACCT_STR_PARAM) {
int ret;
#if CONFIG_ANS
(void)nsymbs;
ret = rans_read(r, cdf);
#else
ret = daala_read_symbol(r, cdf, nsymbs);
#endif
#if CONFIG_ACCOUNTING
if (ACCT_STR_NAME) aom_process_accounting(r, ACCT_STR_NAME);
......
......@@ -15,11 +15,7 @@
#include <assert.h>
#include "./aom_config.h"
#if CONFIG_ANS
#include "aom_dsp/buf_ans.h"
#else
#include "aom_dsp/daalaboolwriter.h"
#endif
#include "aom_dsp/prob.h"
#if CONFIG_RD_DEBUG
......@@ -31,11 +27,7 @@
extern "C" {
#endif
#if CONFIG_ANS
typedef struct BufAnsCoder aom_writer;
#else
typedef struct daala_writer aom_writer;
#endif
typedef struct TOKEN_STATS {
int cost;
......@@ -57,29 +49,15 @@ static INLINE void init_token_stats(TOKEN_STATS *token_stats) {
}
static INLINE void aom_start_encode(aom_writer *bc, uint8_t *buffer) {
#if CONFIG_ANS
aom_buf_ans_alloc(bc, /* error context*/ NULL);
buf_ans_write_init(bc, buffer);
#else
aom_daala_start_encode(bc, buffer);
#endif
}
static INLINE void aom_stop_encode(aom_writer *bc) {
#if CONFIG_ANS
aom_buf_ans_flush(bc);
bc->pos = buf_ans_write_end(bc);
#else
aom_daala_stop_encode(bc);
#endif
}
static INLINE void aom_write(aom_writer *br, int bit, int probability) {
#if CONFIG_ANS
buf_rabs_write(br, bit, probability);
#else
aom_daala_write(br, bit, probability);
#endif
}
static INLINE void aom_write_record(aom_writer *br, int bit, int probability,
......@@ -93,11 +71,7 @@ static INLINE void aom_write_record(aom_writer *br, int bit, int probability,
}