Move ANS to aom_dsp.
That's where it lives in aom/master.
Change-Id: I38f405827d9c2d0b06ef5f3bfd7cadc35d5991ef
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 0f2daa1..2cdc82f 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -37,7 +37,7 @@
#include "av1/common/tile_common.h"
#if CONFIG_ANS
-#include "av1/encoder/buf_ans.h"
+#include "aom_dsp/buf_ans.h"
#endif // CONFIG_ANS
#include "av1/encoder/bitstream.h"
#include "av1/encoder/cost.h"
diff --git a/av1/encoder/bitwriter.h b/av1/encoder/bitwriter.h
index 2247e30..e4e7250 100644
--- a/av1/encoder/bitwriter.h
+++ b/av1/encoder/bitwriter.h
@@ -23,7 +23,7 @@
#if CONFIG_ANS
typedef struct BufAnsCoder BufAnsCoder;
-#include "av1/encoder/buf_ans.h"
+#include "aom_dsp/buf_ans.h"
#define aom_writer BufAnsCoder
#define aom_write buf_uabs_write
#define aom_write_bit buf_uabs_write_bit
diff --git a/av1/encoder/buf_ans.c b/av1/encoder/buf_ans.c
deleted file mode 100644
index d20edc3..0000000
--- a/av1/encoder/buf_ans.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.
- */
-
-#include <string.h>
-
-#include "av1/common/common.h"
-#include "av1/encoder/buf_ans.h"
-#include "av1/encoder/encoder.h"
-#include "aom_mem/aom_mem.h"
-
-void av1_buf_ans_alloc(struct BufAnsCoder *c, struct AV1Common *cm,
- int size_hint) {
- c->cm = cm;
- c->size = size_hint;
- CHECK_MEM_ERROR(cm, c->buf, aom_malloc(c->size * sizeof(*c->buf)));
- // Initialize to overfull to trigger the assert in write.
- c->offset = c->size + 1;
-}
-
-void av1_buf_ans_free(struct BufAnsCoder *c) {
- aom_free(c->buf);
- c->buf = NULL;
- c->size = 0;
-}
-
-void av1_buf_ans_grow(struct BufAnsCoder *c) {
- struct buffered_ans_symbol *new_buf = NULL;
- int new_size = c->size * 2;
- CHECK_MEM_ERROR(c->cm, new_buf, aom_malloc(new_size * sizeof(*new_buf)));
- memcpy(new_buf, c->buf, c->size * sizeof(*c->buf));
- aom_free(c->buf);
- c->buf = new_buf;
- c->size = new_size;
-}
diff --git a/av1/encoder/buf_ans.h b/av1/encoder/buf_ans.h
deleted file mode 100644
index 1ba6e6c..0000000
--- a/av1/encoder/buf_ans.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef AV1_ENCODER_BUF_ANS_H_
-#define AV1_ENCODER_BUF_ANS_H_
-// Buffered forward ANS writer.
-// Symbols are written to the writer in forward (decode) order and serialzed
-// backwards due to ANS's stack like behavior.
-
-#include <assert.h>
-#include "./aom_config.h"
-#include "aom/aom_integer.h"
-#include "av1/common/ans.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-#define ANS_METHOD_UABS 0
-#define ANS_METHOD_RANS 1
-
-struct buffered_ans_symbol {
- uint8_t method; // one of ANS_METHOD_UABS or ANS_METHOD_RANS
- // TODO(aconverse): Should be possible to write this interms of start for ABS
- AnsP10 val_start; // Boolean value for ABS, start in symbol cycle for Rans
- AnsP10 prob; // Probability of this symbol
-};
-
-struct BufAnsCoder {
- struct AV1Common *cm;
- struct buffered_ans_symbol *buf;
- int size;
- int offset;
-};
-
-void av1_buf_ans_alloc(struct BufAnsCoder *c, struct AV1Common *cm,
- int size_hint);
-
-void av1_buf_ans_free(struct BufAnsCoder *c);
-
-void av1_buf_ans_grow(struct BufAnsCoder *c);
-
-static INLINE void buf_ans_write_reset(struct BufAnsCoder *const c) {
- c->offset = 0;
-}
-
-static INLINE void buf_uabs_write(struct BufAnsCoder *const c, uint8_t val,
- AnsP8 prob) {
- assert(c->offset <= c->size);
- if (c->offset == c->size) {
- av1_buf_ans_grow(c);
- }
- c->buf[c->offset].method = ANS_METHOD_UABS;
- c->buf[c->offset].val_start = val;
- c->buf[c->offset].prob = prob;
- ++c->offset;
-}
-
-static INLINE void buf_rans_write(struct BufAnsCoder *const c,
- const struct rans_sym *const sym) {
- assert(c->offset <= c->size);
- if (c->offset == c->size) {
- av1_buf_ans_grow(c);
- }
- c->buf[c->offset].method = ANS_METHOD_RANS;
- c->buf[c->offset].val_start = sym->cum_prob;
- c->buf[c->offset].prob = sym->prob;
- ++c->offset;
-}
-
-static INLINE void buf_ans_flush(const struct BufAnsCoder *const c,
- struct AnsCoder *ans) {
- int offset;
- for (offset = c->offset - 1; offset >= 0; --offset) {
- if (c->buf[offset].method == ANS_METHOD_RANS) {
- struct rans_sym sym;
- sym.prob = c->buf[offset].prob;
- sym.cum_prob = c->buf[offset].val_start;
- rans_write(ans, &sym);
- } else {
- uabs_write(ans, (uint8_t)c->buf[offset].val_start,
- (AnsP8)c->buf[offset].prob);
- }
- }
-}
-
-static INLINE void buf_uabs_write_bit(struct BufAnsCoder *c, int bit) {
- buf_uabs_write(c, bit, 128);
-}
-
-static INLINE void buf_uabs_write_literal(struct BufAnsCoder *c, int literal,
- int bits) {
- int bit;
-
- assert(bits < 31);
- for (bit = bits - 1; bit >= 0; bit--)
- buf_uabs_write_bit(c, 1 & (literal >> bit));
-}
-#ifdef __cplusplus
-} // extern "C"
-#endif // __cplusplus
-#endif // AV1_ENCODER_BUF_ANS_H_
diff --git a/av1/encoder/cost.c b/av1/encoder/cost.c
index f6636ec..8acb341 100644
--- a/av1/encoder/cost.c
+++ b/av1/encoder/cost.c
@@ -12,7 +12,7 @@
#include "av1/encoder/cost.h"
#if CONFIG_ANS
-#include "av1/common/ans.h"
+#include "aom_dsp/ans.h"
#endif // CONFIG_ANS
#include "av1/common/entropy.h"
diff --git a/av1/encoder/cost.h b/av1/encoder/cost.h
index 4e4d9bb..87652cd 100644
--- a/av1/encoder/cost.h
+++ b/av1/encoder/cost.h
@@ -14,7 +14,7 @@
#include "aom_dsp/prob.h"
#include "aom/aom_integer.h"
#if CONFIG_ANS
-#include "av1/common/ans.h"
+#include "aom_dsp/ans.h"
#endif // CONFIG_ANS
#ifdef __cplusplus
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index b6facfa..a5dcfc6 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -32,7 +32,7 @@
#include "av1/encoder/aq_variance.h"
#include "av1/encoder/bitstream.h"
#if CONFIG_ANS
-#include "av1/encoder/buf_ans.h"
+#include "aom_dsp/buf_ans.h"
#endif
#include "av1/encoder/context_tree.h"
#include "av1/encoder/encodeframe.h"
@@ -485,7 +485,7 @@
cpi->source_diff_var = NULL;
}
#if CONFIG_ANS
- av1_buf_ans_free(&cpi->buf_ans);
+ aom_buf_ans_free(&cpi->buf_ans);
#endif // CONFIG_ANS
}
@@ -811,7 +811,7 @@
CHECK_MEM_ERROR(cm, cpi->tile_tok[0][0],
aom_calloc(tokens, sizeof(*cpi->tile_tok[0][0])));
#if CONFIG_ANS
- av1_buf_ans_alloc(&cpi->buf_ans, cm, tokens);
+ aom_buf_ans_alloc(&cpi->buf_ans, &cm->error, tokens);
#endif // CONFIG_ANS
}
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 86503d7..8120e89 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -22,7 +22,7 @@
#include "av1/common/onyxc_int.h"
#include "av1/encoder/aq_cyclicrefresh.h"
#if CONFIG_ANS
-#include "av1/encoder/buf_ans.h"
+#include "aom_dsp/buf_ans.h"
#endif
#include "av1/encoder/context_tree.h"
#include "av1/encoder/encodemb.h"
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index 42c37e3..54c10b2 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -15,7 +15,7 @@
#include <limits.h>
#if CONFIG_ANS
-#include "av1/common/ans.h"
+#include "aom_dsp/ans.h"
#endif // CONFIG_ANS
#include "av1/common/blockd.h"