Commit cefb4094 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Nathan Egge

Move from Daala accounting to AOM accounting.

Replace all instances of Daala's OD_ACCOUNTING with those specified by
 CONFIG_ACCOUNTING.

Change-Id: Ibb59fc5df0ce4b0528b15296bf2f14029c414bc0
parent cceac33a
......@@ -19,21 +19,12 @@
# define GENERIC_TABLES 12
#if OD_ACCOUNTING
# define generic_decode(r, model, max, ex_q16, integration, str) \
generic_decode_(r, model, max, ex_q16, integration, str)
# define aom_decode_cdf_adapt_q15(r, cdf, n, count, rate, str) \
aom_decode_cdf_adapt_q15_(r, cdf, n, count, rate, str)
# define aom_decode_cdf_adapt(r, cdf, n, increment, str) \
aom_decode_cdf_adapt_(r, cdf, n, increment, str)
#else
# define generic_decode(r, model, max, ex_q16, integration, str) \
generic_decode_(r, model, max, ex_q16, integration)
# define aom_decode_cdf_adapt_q15(r, cdf, n, count, rate, str) \
aom_decode_cdf_adapt_q15_(r, cdf, n, count, rate)
# define aom_decode_cdf_adapt(r, cdf, n, increment, str) \
aom_decode_cdf_adapt_(r, cdf, n, increment)
#endif
#define generic_decode(r, model, max, ex_q16, integration, ACCT_STR_NAME) \
generic_decode_(r, model, max, ex_q16, integration ACCT_STR_ARG(ACCT_STR_NAME))
#define aom_decode_cdf_adapt_q15(r, cdf, n, count, rate, ACCT_STR_NAME) \
aom_decode_cdf_adapt_q15_(r, cdf, n, count, rate ACCT_STR_ARG(ACCT_STR_NAME))
#define aom_decode_cdf_adapt(r, cdf, n, increment, ACCT_STR_NAME) \
aom_decode_cdf_adapt_(r, cdf, n, increment ACCT_STR_ARG(ACCT_STR_NAME))
typedef struct {
/** cdf for multiple expectations of x */
......@@ -69,7 +60,7 @@ void aom_encode_cdf_adapt(aom_writer *w, int val, uint16_t *cdf, int n,
int increment);
int aom_decode_cdf_adapt_(aom_reader *r, uint16_t *cdf, int n,
int increment OD_ACC_STR);
int increment ACCT_STR_PARAM);
void generic_encode(aom_writer *w, generic_encoder *model, int x, int max,
int *ex_q16, int integration);
......@@ -79,10 +70,10 @@ double generic_encode_cost(generic_encoder *model, int x, int max,
double od_encode_cdf_cost(int val, uint16_t *cdf, int n);
int aom_decode_cdf_adapt_q15_(aom_reader *r, uint16_t *cdf, int n,
int *count, int rate OD_ACC_STR);
int *count, int rate ACCT_STR_PARAM);
int generic_decode_(aom_reader *r, generic_encoder *model, int max,
int *ex_q16, int integration OD_ACC_STR);
int *ex_q16, int integration ACCT_STR_PARAM);
int log_ex(int ex_q16);
......
......@@ -22,8 +22,6 @@
#include "av1/common/odintrin.h"
#include "pvq_decoder.h"
#define ACCT_STR __func__
/** Decodes a value from 0 to N-1 (with N up to 16) based on a cdf and adapts
* the cdf accordingly.
*
......@@ -35,7 +33,7 @@
* @return decoded variable
*/
int aom_decode_cdf_adapt_q15_(aom_reader *r, uint16_t *cdf, int n,
int *count, int rate OD_ACC_STR) {
int *count, int rate ACCT_STR_PARAM) {
int val;
int i;
if (*count == 0) {
......@@ -45,7 +43,7 @@ int aom_decode_cdf_adapt_q15_(aom_reader *r, uint16_t *cdf, int n,
cdf[i] = cdf[i]*32768/ft;
}
}
val = aom_read_cdf(r, cdf, n, ACCT_STR);
val = aom_read_cdf(r, cdf, n, ACCT_STR_NAME);
aom_cdf_adapt_q15(val, cdf, n, count, rate);
return val;
}
......@@ -61,10 +59,10 @@ int aom_decode_cdf_adapt_q15_(aom_reader *r, uint16_t *cdf, int n,
* @retval decoded variable
*/
int aom_decode_cdf_adapt_(aom_reader *r, uint16_t *cdf, int n,
int increment OD_ACC_STR) {
int increment ACCT_STR_PARAM) {
int i;
int val;
val = aom_read_cdf_unscaled(r, cdf, n, ACCT_STR);
val = aom_read_cdf_unscaled(r, cdf, n, ACCT_STR_NAME);
if (cdf[n-1] + increment > 32767) {
for (i = 0; i < n; i++) {
/* Second term ensures that the pdf is non-null */
......@@ -89,7 +87,7 @@ int aom_decode_cdf_adapt_(aom_reader *r, uint16_t *cdf, int n,
* @retval decoded variable x
*/
int generic_decode_(aom_reader *r, generic_encoder *model, int max,
int *ex_q16, int integration OD_ACC_STR) {
int *ex_q16, int integration ACCT_STR_PARAM) {
int lg_q1;
int shift;
int id;
......@@ -109,8 +107,8 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
id = OD_MINI(GENERIC_TABLES - 1, lg_q1);
cdf = model->cdf[id];
ms = (max + (1 << shift >> 1)) >> shift;
if (max == -1) xs = aom_read_cdf_unscaled(r, cdf, 16, ACCT_STR);
else xs = aom_read_cdf_unscaled(r, cdf, OD_MINI(ms + 1, 16), ACCT_STR);
if (max == -1) xs = aom_read_cdf_unscaled(r, cdf, 16, ACCT_STR_NAME);
else xs = aom_read_cdf_unscaled(r, cdf, OD_MINI(ms + 1, 16), ACCT_STR_NAME);
if (xs == 15) {
int e;
unsigned decay;
......@@ -121,7 +119,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
OD_ASSERT(*ex_q16 < INT_MAX >> 1);
e = ((2**ex_q16 >> 8) + (1 << shift >> 1)) >> shift;
decay = OD_MAXI(2, OD_MINI(254, 256*e/(e + 256)));
xs += aom_laplace_decode_special(r, decay, (max == -1) ? -1 : ms - 15, ACCT_STR);
xs += aom_laplace_decode_special(r, decay, (max == -1) ? -1 : ms - 15, ACCT_STR_NAME);
}
if (shift != 0) {
int special;
......@@ -129,7 +127,7 @@ int generic_decode_(aom_reader *r, generic_encoder *model, int max,
for xs=0 */
special = xs == 0;
if (shift - special > 0) {
lsb = aom_read_literal(r, shift - special, ACCT_STR);
lsb = aom_read_literal(r, shift - special, ACCT_STR_NAME);
}
lsb -= !special << (shift - 1);
}
......
......@@ -20,18 +20,11 @@
#include "av1/common/pvq.h"
#include "pvq_decoder.h"
#if OD_ACCOUNTING
# define aom_decode_pvq_split(r, adapt, sum, ctx, str) \
aom_decode_pvq_split_(r, adapt, sum, ctx, str)
#else
# define aom_decode_pvq_split(r, adapt, sum, ctx, str) \
aom_decode_pvq_split_(r, adapt, sum, ctx)
#endif
#define ACCT_STR __func__
#define aom_decode_pvq_split(r, adapt, sum, ctx, ACCT_STR_NAME) \
aom_decode_pvq_split_(r, adapt, sum, ctx ACCT_STR_ARG(ACCT_STR_NAME))
static int aom_decode_pvq_split_(aom_reader *r, od_pvq_codeword_ctx *adapt,
int sum, int ctx OD_ACC_STR) {
int sum, int ctx ACCT_STR_PARAM) {
int shift;
int count;
int msbs;
......@@ -41,8 +34,8 @@ static int aom_decode_pvq_split_(aom_reader *r, od_pvq_codeword_ctx *adapt,
shift = OD_MAXI(0, OD_ILOG(sum) - 3);
fctx = 7*ctx + (sum >> shift) - 1;
msbs = aom_decode_cdf_adapt(r, adapt->pvq_split_cdf[fctx],
(sum >> shift) + 1, adapt->pvq_split_increment, ACCT_STR);
if (shift) count = aom_read_literal(r, shift, ACCT_STR);
(sum >> shift) + 1, adapt->pvq_split_increment, ACCT_STR_NAME);
if (shift) count = aom_read_literal(r, shift, ACCT_STR_NAME);
count += msbs << shift;
if (count > sum) {
count = sum;
......@@ -94,7 +87,7 @@ void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt,
* @retval decoded variable x
*/
int aom_laplace_decode_special_(aom_reader *r, unsigned decay,
int max OD_ACC_STR) {
int max ACCT_STR_PARAM) {
int pos;
int shift;
int xs;
......@@ -127,14 +120,14 @@ int aom_laplace_decode_special_(aom_reader *r, unsigned decay,
}
if (ms > 0 && ms < 15) {
/* Simple way of truncating the pdf when we have a bound. */
sym = aom_read_cdf_unscaled(r, cdf, ms + 1, ACCT_STR);
sym = aom_read_cdf_unscaled(r, cdf, ms + 1, ACCT_STR_NAME);
}
else sym = aom_read_cdf(r, cdf, 16, ACCT_STR);
else sym = aom_read_cdf(r, cdf, 16, ACCT_STR_NAME);
xs += sym;
ms -= 15;
}
while (sym >= 15 && ms != 0);
if (shift) pos = (xs << shift) + aom_read_literal(r, shift, ACCT_STR);
if (shift) pos = (xs << shift) + aom_read_literal(r, shift, ACCT_STR_NAME);
else pos = xs;
OD_ASSERT(pos >> shift <= max >> shift || max == -1);
if (max != -1 && pos > max) {
......
......@@ -21,14 +21,11 @@
void aom_decode_band_pvq_splits(aom_reader *r, od_pvq_codeword_ctx *adapt,
od_coeff *y, int n, int k, int level);
#if OD_ACCOUNTING
# define aom_laplace_decode_special(r, decay, max, str) aom_laplace_decode_special_(r, decay, max, str)
#else
# define aom_laplace_decode_special(r, decay, max, str) aom_laplace_decode_special_(r, decay, max)
#endif
#define aom_laplace_decode_special(r, decay, max, ACCT_STR_NAME) \
aom_laplace_decode_special_(r, decay, max ACCT_STR_ARG(ACCT_STR_NAME))
int aom_laplace_decode_special_(aom_reader *r, unsigned decay,
int max OD_ACC_STR);
int max ACCT_STR_PARAM);
void od_pvq_decode(daala_dec_ctx *dec, od_coeff *ref, od_coeff *out, int q0,
int pli, int bs, const od_val16 *beta, int robust, int is_keyframe,
......
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