From: Alex Converse Date: Sat, 17 Sep 2016 22:11:16 +0000 (-0700) Subject: Move ANS to aom_dsp. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ac1ae73dc818906e1853af9f97c122d95f279b8;p=libvpx Move ANS to aom_dsp. That's where it lives in aom/master. Change-Id: I38f405827d9c2d0b06ef5f3bfd7cadc35d5991ef --- diff --git a/av1/common/ans.h b/aom_dsp/ans.h similarity index 99% rename from av1/common/ans.h rename to aom_dsp/ans.h index 1a632ee6b..c526e275d 100644 --- a/av1/common/ans.h +++ b/aom_dsp/ans.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef AV1_COMMON_ANS_H_ -#define AV1_COMMON_ANS_H_ +#ifndef AOM_DSP_ANS_H_ +#define AOM_DSP_ANS_H_ // An implementation of Asymmetric Numeral Systems // http://arxiv.org/abs/1311.2540v2 @@ -21,7 +21,7 @@ #define ANS_DIVIDE_BY_MULTIPLY 1 #if ANS_DIVIDE_BY_MULTIPLY -#include "av1/common/divide.h" +#include "aom_dsp/divide.h" #define ANS_DIVREM(quotient, remainder, dividend, divisor) \ do { \ quotient = fastdiv(dividend, divisor); \ @@ -411,4 +411,4 @@ static INLINE int ans_reader_has_error(const struct AnsDecoder *const ans) { #ifdef __cplusplus } // extern "C" #endif // __cplusplus -#endif // AV1_COMMON_ANS_H_ +#endif // AOM_DSP_ANS_H_ diff --git a/aom_dsp/aom_dsp.mk b/aom_dsp/aom_dsp.mk index 5bebb26f3..25e7d8f96 100644 --- a/aom_dsp/aom_dsp.mk +++ b/aom_dsp/aom_dsp.mk @@ -19,6 +19,7 @@ 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_ENCODERS),yes) DSP_SRCS-yes += bitwriter.h @@ -26,6 +27,10 @@ DSP_SRCS-yes += dkboolwriter.h DSP_SRCS-yes += dkboolwriter.c DSP_SRCS-yes += bitwriter_buffer.c DSP_SRCS-yes += bitwriter_buffer.h +DSP_SRCS-$(CONFIG_ANS) += buf_ans.h +DSP_SRCS-$(CONFIG_ANS) += buf_ans.c +DSP_SRCS-$(CONFIG_ANS) += divide.h +DSP_SRCS-$(CONFIG_ANS) += divide.c DSP_SRCS-yes += psnr.c DSP_SRCS-yes += psnr.h DSP_SRCS-$(CONFIG_INTERNAL_STATS) += ssim.c diff --git a/av1/encoder/buf_ans.c b/aom_dsp/buf_ans.c similarity index 62% rename from av1/encoder/buf_ans.c rename to aom_dsp/buf_ans.c index d20edc3ca..a62aaba6c 100644 --- a/av1/encoder/buf_ans.c +++ b/aom_dsp/buf_ans.c @@ -10,30 +10,30 @@ #include -#include "av1/common/common.h" -#include "av1/encoder/buf_ans.h" -#include "av1/encoder/encoder.h" +#include "aom_dsp/buf_ans.h" #include "aom_mem/aom_mem.h" +#include "aom/internal/aom_codec_internal.h" -void av1_buf_ans_alloc(struct BufAnsCoder *c, struct AV1Common *cm, - int size_hint) { - c->cm = cm; +void aom_buf_ans_alloc(struct BufAnsCoder *c, + struct aom_internal_error_info *error, int size_hint) { + c->error = error; c->size = size_hint; - CHECK_MEM_ERROR(cm, c->buf, aom_malloc(c->size * sizeof(*c->buf))); + AOM_CHECK_MEM_ERROR(error, 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) { +void aom_buf_ans_free(struct BufAnsCoder *c) { aom_free(c->buf); c->buf = NULL; c->size = 0; } -void av1_buf_ans_grow(struct BufAnsCoder *c) { +void aom_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))); + AOM_CHECK_MEM_ERROR(c->error, 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; diff --git a/av1/encoder/buf_ans.h b/aom_dsp/buf_ans.h similarity index 87% rename from av1/encoder/buf_ans.h rename to aom_dsp/buf_ans.h index 1ba6e6c25..b3fdad9de 100644 --- a/av1/encoder/buf_ans.h +++ b/aom_dsp/buf_ans.h @@ -8,8 +8,8 @@ * 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_ +#ifndef AOM_DSP_BUF_ANS_H_ +#define AOM_DSP_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. @@ -17,7 +17,7 @@ #include #include "./aom_config.h" #include "aom/aom_integer.h" -#include "av1/common/ans.h" +#include "aom_dsp/ans.h" #ifdef __cplusplus extern "C" { @@ -34,18 +34,18 @@ struct buffered_ans_symbol { }; struct BufAnsCoder { - struct AV1Common *cm; + struct aom_internal_error_info *error; struct buffered_ans_symbol *buf; int size; int offset; }; -void av1_buf_ans_alloc(struct BufAnsCoder *c, struct AV1Common *cm, - int size_hint); +void aom_buf_ans_alloc(struct BufAnsCoder *c, + struct aom_internal_error_info *error, int size_hint); -void av1_buf_ans_free(struct BufAnsCoder *c); +void aom_buf_ans_free(struct BufAnsCoder *c); -void av1_buf_ans_grow(struct BufAnsCoder *c); +void aom_buf_ans_grow(struct BufAnsCoder *c); static INLINE void buf_ans_write_reset(struct BufAnsCoder *const c) { c->offset = 0; @@ -55,7 +55,7 @@ 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); + aom_buf_ans_grow(c); } c->buf[c->offset].method = ANS_METHOD_UABS; c->buf[c->offset].val_start = val; @@ -67,7 +67,7 @@ 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); + aom_buf_ans_grow(c); } c->buf[c->offset].method = ANS_METHOD_RANS; c->buf[c->offset].val_start = sym->cum_prob; @@ -106,4 +106,4 @@ static INLINE void buf_uabs_write_literal(struct BufAnsCoder *c, int literal, #ifdef __cplusplus } // extern "C" #endif // __cplusplus -#endif // AV1_ENCODER_BUF_ANS_H_ +#endif // AOM_DSP_BUF_ANS_H_ diff --git a/av1/common/divide.c b/aom_dsp/divide.c similarity index 99% rename from av1/common/divide.c rename to aom_dsp/divide.c index 3c82be8b8..3e58da5e9 100644 --- a/av1/common/divide.c +++ b/aom_dsp/divide.c @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "av1/common/divide.h" +#include "aom_dsp/divide.h" /* Constants for divide by multiply for small divisors generated with: void init_fastdiv() { diff --git a/av1/common/divide.h b/aom_dsp/divide.h similarity index 91% rename from av1/common/divide.h rename to aom_dsp/divide.h index b96ad4cc8..c92a58f39 100644 --- a/av1/common/divide.h +++ b/aom_dsp/divide.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef AV1_COMMON_DIVIDE_H_ -#define AV1_COMMON_DIVIDE_H_ +#ifndef AOM_DSP_DIVIDE_H_ +#define AOM_DSP_DIVIDE_H_ // An implemntation of the divide by multiply alogrithm // https://gmplib.org/~tege/divcnst-pldi94.pdf @@ -37,4 +37,4 @@ static INLINE unsigned fastdiv(unsigned x, int y) { #ifdef __cplusplus } // extern "C" #endif // __cplusplus -#endif // AV1_COMMON_DIVIDE_H_ +#endif // AOM_DSP_DIVIDE_H_ diff --git a/av1/av1_common.mk b/av1/av1_common.mk index cd3e1d13e..9976e7aab 100644 --- a/av1/av1_common.mk +++ b/av1/av1_common.mk @@ -11,11 +11,9 @@ AV1_COMMON_SRCS-yes += av1_common.mk AV1_COMMON_SRCS-yes += av1_iface_common.h -AV1_COMMON_SRCS-yes += common/ans.h AV1_COMMON_SRCS-yes += common/alloccommon.c AV1_COMMON_SRCS-yes += common/blockd.c AV1_COMMON_SRCS-yes += common/debugmodes.c -AV1_COMMON_SRCS-yes += common/divide.h AV1_COMMON_SRCS-yes += common/entropy.c AV1_COMMON_SRCS-yes += common/entropymode.c AV1_COMMON_SRCS-yes += common/entropymv.c @@ -82,9 +80,6 @@ AV1_COMMON_SRCS-$(HAVE_SSE4_1) += common/x86/av1_highbd_convolve_filters_sse4.c endif AV1_COMMON_SRCS-yes += common/av1_convolve.c AV1_COMMON_SRCS-yes += common/av1_convolve.h -AV1_COMMON_SRCS-$(CONFIG_ANS) += common/ans.h -AV1_COMMON_SRCS-$(CONFIG_ANS) += common/divide.h -AV1_COMMON_SRCS-$(CONFIG_ANS) += common/divide.c AV1_COMMON_SRCS-$(CONFIG_LOOP_RESTORATION) += common/restoration.h AV1_COMMON_SRCS-$(CONFIG_LOOP_RESTORATION) += common/restoration.c ifeq (yes,$(filter yes,$(CONFIG_GLOBAL_MOTION) $(CONFIG_WARPED_MOTION))) diff --git a/av1/av1_cx.mk b/av1/av1_cx.mk index c4df1a56b..ecbe2b32b 100644 --- a/av1/av1_cx.mk +++ b/av1/av1_cx.mk @@ -86,8 +86,6 @@ AV1_CX_SRCS-yes += encoder/subexp.h AV1_CX_SRCS-yes += encoder/resize.c AV1_CX_SRCS-yes += encoder/resize.h AV1_CX_SRCS-$(CONFIG_INTERNAL_STATS) += encoder/blockiness.c -AV1_CX_SRCS-$(CONFIG_ANS) += encoder/buf_ans.h -AV1_CX_SRCS-$(CONFIG_ANS) += encoder/buf_ans.c AV1_CX_SRCS-yes += encoder/tokenize.c AV1_CX_SRCS-yes += encoder/treewriter.c diff --git a/av1/common/entropy.h b/av1/common/entropy.h index ac47b3b44..4ce502be6 100644 --- a/av1/common/entropy.h +++ b/av1/common/entropy.h @@ -16,7 +16,7 @@ #include "aom_dsp/prob.h" #if CONFIG_ANS -#include "av1/common/ans.h" +#include "aom_dsp/ans.h" #endif // CONFIG_ANS #include "av1/common/common.h" #include "av1/common/enums.h" diff --git a/av1/decoder/bitreader.h b/av1/decoder/bitreader.h index aaf1bb865..4d77664cc 100644 --- a/av1/decoder/bitreader.h +++ b/av1/decoder/bitreader.h @@ -17,7 +17,7 @@ #include "./aom_config.h" #if CONFIG_ANS -#include "av1/common/ans.h" +#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 diff --git a/av1/decoder/detokenize.c b/av1/decoder/detokenize.c index 778bf129e..fbcf8fe05 100644 --- a/av1/decoder/detokenize.c +++ b/av1/decoder/detokenize.c @@ -12,7 +12,9 @@ #include "aom_mem/aom_mem.h" #include "aom_ports/mem.h" -#include "av1/common/ans.h" +#if CONFIG_ANS +#include "aom_dsp/ans.h" +#endif // CONFIG_ANS #include "av1/common/blockd.h" #include "av1/common/common.h" #include "av1/common/entropy.h" diff --git a/av1/decoder/detokenize.h b/av1/decoder/detokenize.h index de9ded99d..69d6fabfb 100644 --- a/av1/decoder/detokenize.h +++ b/av1/decoder/detokenize.h @@ -13,7 +13,9 @@ #define AV1_DECODER_DETOKENIZE_H_ #include "av1/decoder/decoder.h" -#include "av1/common/ans.h" +#if CONFIG_ANS +#include "aom_dsp/ans.h" +#endif // CONFIG_ANS #include "av1/common/scan.h" #ifdef __cplusplus diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c index 0f2daa169..2cdc82fcb 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 2247e30ad..e4e72502a 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/cost.c b/av1/encoder/cost.c index f6636ecdb..8acb341e3 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 4e4d9bbcc..87652cd15 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 b6facfafc..a5dcfc6ff 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 @@ static void dealloc_compressor_data(AV1_COMP *cpi) { 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 @@ void av1_alloc_compressor_data(AV1_COMP *cpi) { 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 86503d729..8120e895f 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 42c37e3f6..54c10b27c 100644 --- a/av1/encoder/rd.h +++ b/av1/encoder/rd.h @@ -15,7 +15,7 @@ #include #if CONFIG_ANS -#include "av1/common/ans.h" +#include "aom_dsp/ans.h" #endif // CONFIG_ANS #include "av1/common/blockd.h" diff --git a/test/av1_ans_test.cc b/test/av1_ans_test.cc index 20fc223e9..29a1cf5d5 100644 --- a/test/av1_ans_test.cc +++ b/test/av1_ans_test.cc @@ -20,7 +20,7 @@ #include "third_party/googletest/src/include/gtest/gtest.h" #include "test/acm_random.h" -#include "av1/common/ans.h" +#include "aom_dsp/ans.h" #include "av1/encoder/treewriter.h" #include "aom_dsp/bitreader.h" #include "aom_dsp/bitwriter.h"