Commit 837262bf authored by Thomas Daede's avatar Thomas Daede
Browse files

Allow CDF precision to be configured with CDF_PROB_BITS.

This does not change the precision used for od_ec_enc_bool_q15
(used by aom_write and aom_write_bit), which means these two
paths will use different CDF precision for now.

The test that verifies that q15's code identically to CDFs
is disabled.

Change-Id: I4cd40a60d472eb58f37ac4fda1056b5dfe8b39a5
parent 79c763bf
......@@ -14,6 +14,7 @@
#include <limits.h>
#include <stddef.h>
#include "av1/common/odintrin.h"
#include "aom_dsp/prob.h"
#define EC_PROB_SHIFT 6
#define EC_MIN_PROB 4 // must be <= (1<<EC_PROB_SHIFT)/16
......@@ -31,11 +32,7 @@ typedef uint32_t od_ec_window;
3 => 1/8th bits.*/
#define OD_BITRES (3)
/*The value stored in an iCDF is 32768 minus the actual Q15 cumulative
probability (an "inverse" CDF).
This function converts from one representation to the other (and is its own
inverse).*/
#define OD_ICDF(x) (32768U - (x))
#define OD_ICDF AOM_ICDF
/*See entcode.c for further documentation.*/
......
......@@ -14,6 +14,7 @@
#endif
#include "aom_dsp/entdec.h"
#include "aom_dsp/prob.h"
/*A range decoder.
This is an entropy decoder based upon \cite{Mar79}, which is itself a
......@@ -171,8 +172,8 @@ int od_ec_decode_bool_q15(od_ec_dec *dec, unsigned f) {
/*Decodes a symbol given an inverse cumulative distribution function (CDF)
table in Q15.
icdf: 32768 minus the CDF, such that symbol s falls in the range
[s > 0 ? (32768 - icdf[s - 1]) : 0, 32768 - icdf[s]).
icdf: CDF_PROB_TOP minus the CDF, such that symbol s falls in the range
[s > 0 ? (CDF_PROB_TOP - icdf[s - 1]) : 0, CDF_PROB_TOP - icdf[s]).
The values must be monotonically non-increasing, and icdf[nsyms - 1]
must be 0.
nsyms: The number of symbols in the alphabet.
......@@ -191,15 +192,16 @@ int od_ec_decode_cdf_q15(od_ec_dec *dec, const uint16_t *icdf, int nsyms) {
const int N = nsyms - 1;
OD_ASSERT(dif >> (OD_EC_WINDOW_SIZE - 16) < r);
OD_ASSERT(icdf[nsyms - 1] == OD_ICDF(32768U));
OD_ASSERT(icdf[nsyms - 1] == OD_ICDF(CDF_PROB_TOP));
OD_ASSERT(32768U <= r);
OD_ASSERT(7 - EC_PROB_SHIFT - CDF_SHIFT >= 0);
c = (unsigned)(dif >> (OD_EC_WINDOW_SIZE - 16));
v = r;
ret = -1;
do {
u = v;
v = ((r >> 8) * (uint32_t)(icdf[++ret] >> EC_PROB_SHIFT) >>
(7 - EC_PROB_SHIFT));
(7 - EC_PROB_SHIFT - CDF_SHIFT));
v += EC_MIN_PROB * (N - ret);
} while (c < v);
OD_ASSERT(v < u);
......
......@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <string.h>
#include "aom_dsp/entenc.h"
#include "aom_dsp/prob.h"
/*A range encoder.
See entdec.c and the references for implementation details \cite{Mar79,MNW98}.
......@@ -143,9 +144,11 @@ void od_ec_enc_clear(od_ec_enc *enc) {
}
/*Encodes a symbol given its frequency in Q15.
fl: 32768 minus the cumulative frequency of all symbols that come before the
fl: CDF_PROB_TOP minus the cumulative frequency of all symbols that come
before the
one to be encoded.
fh: 32768 minus the cumulative frequency of all symbols up to and including
fh: CDF_PROB_TOP minus the cumulative frequency of all symbols up to and
including
the one to be encoded.*/
static void od_ec_encode_q15(od_ec_enc *enc, unsigned fl, unsigned fh, int s,
int nsyms) {
......@@ -158,21 +161,25 @@ static void od_ec_encode_q15(od_ec_enc *enc, unsigned fl, unsigned fh, int s,
OD_ASSERT(32768U <= r);
OD_ASSERT(fh <= fl);
OD_ASSERT(fl <= 32768U);
OD_ASSERT(7 - EC_PROB_SHIFT - CDF_SHIFT >= 0);
const int N = nsyms - 1;
if (fl < 32768U) {
u = ((r >> 8) * (uint32_t)(fl >> EC_PROB_SHIFT) >> (7 - EC_PROB_SHIFT)) +
if (fl < CDF_PROB_TOP) {
u = ((r >> 8) * (uint32_t)(fl >> EC_PROB_SHIFT) >>
(7 - EC_PROB_SHIFT - CDF_SHIFT)) +
EC_MIN_PROB * (N - (s - 1));
v = ((r >> 8) * (uint32_t)(fh >> EC_PROB_SHIFT) >> (7 - EC_PROB_SHIFT)) +
v = ((r >> 8) * (uint32_t)(fh >> EC_PROB_SHIFT) >>
(7 - EC_PROB_SHIFT - CDF_SHIFT)) +
EC_MIN_PROB * (N - (s + 0));
l += r - u;
r = u - v;
} else {
r -= ((r >> 8) * (uint32_t)(fh >> EC_PROB_SHIFT) >> (7 - EC_PROB_SHIFT)) +
r -= ((r >> 8) * (uint32_t)(fh >> EC_PROB_SHIFT) >>
(7 - EC_PROB_SHIFT - CDF_SHIFT)) +
EC_MIN_PROB * (N - (s + 0));
}
od_ec_enc_normalize(enc, l, r);
#if OD_MEASURE_EC_OVERHEAD
enc->entropy -= OD_LOG2((double)(OD_ICDF(fh) - OD_ICDF(fl)) / 32768.);
enc->entropy -= OD_LOG2((double)(OD_ICDF(fh) - OD_ICDF(fl)) / CDF_PROB_TOP.);
enc->nb_symbols++;
#endif
}
......@@ -195,8 +202,7 @@ void od_ec_encode_bool_q15(od_ec_enc *enc, int val, unsigned f) {
r = val ? v : r - v;
od_ec_enc_normalize(enc, l, r);
#if OD_MEASURE_EC_OVERHEAD
enc->entropy -=
OD_LOG2((double)(val ? 32768 - OD_ICDF(f) : OD_ICDF(f)) / 32768.);
enc->entropy -= OD_LOG2((double)(val ? f : (32768 - f)) / 32768.);
enc->nb_symbols++;
#endif
}
......@@ -214,7 +220,7 @@ void od_ec_encode_cdf_q15(od_ec_enc *enc, int s, const uint16_t *icdf,
(void)nsyms;
OD_ASSERT(s >= 0);
OD_ASSERT(s < nsyms);
OD_ASSERT(icdf[nsyms - 1] == OD_ICDF(32768U));
OD_ASSERT(icdf[nsyms - 1] == OD_ICDF(CDF_PROB_TOP));
od_ec_encode_q15(enc, s > 0 ? icdf[s - 1] : OD_ICDF(0), icdf[s], s, nsyms);
}
......
......@@ -36,8 +36,15 @@ typedef uint16_t aom_cdf_prob;
#define CDF_PROB_BITS 15
#define CDF_PROB_TOP (1 << CDF_PROB_BITS)
#define CDF_INIT_TOP 32768
#define CDF_SHIFT (15 - CDF_PROB_BITS)
/*The value stored in an iCDF is CDF_PROB_TOP minus the actual cumulative
probability (an "inverse" CDF).
This function converts from one representation to the other (and is its own
inverse).*/
#define AOM_ICDF(x) (CDF_PROB_TOP - (x))
#define AOM_ICDF OD_ICDF
#if CDF_SHIFT == 0
#define AOM_CDF2(a0) AOM_ICDF(a0), AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF3(a0, a1) AOM_ICDF(a0), AOM_ICDF(a1), AOM_ICDF(CDF_PROB_TOP), 0
......@@ -99,6 +106,521 @@ typedef uint16_t aom_cdf_prob;
AOM_ICDF(a11), AOM_ICDF(a12), AOM_ICDF(a13), AOM_ICDF(a14), \
AOM_ICDF(CDF_PROB_TOP), 0
#else
#define AOM_CDF2(a0) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 2) + \
((CDF_INIT_TOP - 2) >> 1)) / \
((CDF_INIT_TOP - 2)) + \
1) \
, AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF3(a0, a1) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 3) + \
((CDF_INIT_TOP - 3) >> 1)) / \
((CDF_INIT_TOP - 3)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 3) + \
((CDF_INIT_TOP - 3) >> 1)) / \
((CDF_INIT_TOP - 3)) + \
2), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF4(a0, a1, a2) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 4) + \
((CDF_INIT_TOP - 4) >> 1)) / \
((CDF_INIT_TOP - 4)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 4) + \
((CDF_INIT_TOP - 4) >> 1)) / \
((CDF_INIT_TOP - 4)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 4) + \
((CDF_INIT_TOP - 4) >> 1)) / \
((CDF_INIT_TOP - 4)) + \
3), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF5(a0, a1, a2, a3) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 5) + \
((CDF_INIT_TOP - 5) >> 1)) / \
((CDF_INIT_TOP - 5)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 5) + \
((CDF_INIT_TOP - 5) >> 1)) / \
((CDF_INIT_TOP - 5)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 5) + \
((CDF_INIT_TOP - 5) >> 1)) / \
((CDF_INIT_TOP - 5)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 5) + \
((CDF_INIT_TOP - 5) >> 1)) / \
((CDF_INIT_TOP - 5)) + \
4), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF6(a0, a1, a2, a3, a4) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 6) + \
((CDF_INIT_TOP - 6) >> 1)) / \
((CDF_INIT_TOP - 6)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 6) + \
((CDF_INIT_TOP - 6) >> 1)) / \
((CDF_INIT_TOP - 6)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 6) + \
((CDF_INIT_TOP - 6) >> 1)) / \
((CDF_INIT_TOP - 6)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 6) + \
((CDF_INIT_TOP - 6) >> 1)) / \
((CDF_INIT_TOP - 6)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 6) + \
((CDF_INIT_TOP - 6) >> 1)) / \
((CDF_INIT_TOP - 6)) + \
5), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF7(a0, a1, a2, a3, a4, a5) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 7) + \
((CDF_INIT_TOP - 7) >> 1)) / \
((CDF_INIT_TOP - 7)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 7) + \
((CDF_INIT_TOP - 7) >> 1)) / \
((CDF_INIT_TOP - 7)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 7) + \
((CDF_INIT_TOP - 7) >> 1)) / \
((CDF_INIT_TOP - 7)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 7) + \
((CDF_INIT_TOP - 7) >> 1)) / \
((CDF_INIT_TOP - 7)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 7) + \
((CDF_INIT_TOP - 7) >> 1)) / \
((CDF_INIT_TOP - 7)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 7) + \
((CDF_INIT_TOP - 7) >> 1)) / \
((CDF_INIT_TOP - 7)) + \
6), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF8(a0, a1, a2, a3, a4, a5, a6) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 8) + \
((CDF_INIT_TOP - 8) >> 1)) / \
((CDF_INIT_TOP - 8)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 8) + \
((CDF_INIT_TOP - 8) >> 1)) / \
((CDF_INIT_TOP - 8)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 8) + \
((CDF_INIT_TOP - 8) >> 1)) / \
((CDF_INIT_TOP - 8)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 8) + \
((CDF_INIT_TOP - 8) >> 1)) / \
((CDF_INIT_TOP - 8)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 8) + \
((CDF_INIT_TOP - 8) >> 1)) / \
((CDF_INIT_TOP - 8)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 8) + \
((CDF_INIT_TOP - 8) >> 1)) / \
((CDF_INIT_TOP - 8)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 8) + \
((CDF_INIT_TOP - 8) >> 1)) / \
((CDF_INIT_TOP - 8)) + \
7), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF9(a0, a1, a2, a3, a4, a5, a6, a7) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 9) + \
((CDF_INIT_TOP - 9) >> 1)) / \
((CDF_INIT_TOP - 9)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 9) + \
((CDF_INIT_TOP - 9) >> 1)) / \
((CDF_INIT_TOP - 9)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 9) + \
((CDF_INIT_TOP - 9) >> 1)) / \
((CDF_INIT_TOP - 9)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 9) + \
((CDF_INIT_TOP - 9) >> 1)) / \
((CDF_INIT_TOP - 9)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 9) + \
((CDF_INIT_TOP - 9) >> 1)) / \
((CDF_INIT_TOP - 9)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 9) + \
((CDF_INIT_TOP - 9) >> 1)) / \
((CDF_INIT_TOP - 9)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 9) + \
((CDF_INIT_TOP - 9) >> 1)) / \
((CDF_INIT_TOP - 9)) + \
7), \
AOM_ICDF((((a7)-8) * ((CDF_INIT_TOP >> CDF_SHIFT) - 9) + \
((CDF_INIT_TOP - 9) >> 1)) / \
((CDF_INIT_TOP - 9)) + \
8), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF10(a0, a1, a2, a3, a4, a5, a6, a7, a8) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
7), \
AOM_ICDF((((a7)-8) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
8), \
AOM_ICDF((((a8)-9) * ((CDF_INIT_TOP >> CDF_SHIFT) - 10) + \
((CDF_INIT_TOP - 10) >> 1)) / \
((CDF_INIT_TOP - 10)) + \
9), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF11(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
7), \
AOM_ICDF((((a7)-8) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
8), \
AOM_ICDF((((a8)-9) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
9), \
AOM_ICDF((((a9)-10) * ((CDF_INIT_TOP >> CDF_SHIFT) - 11) + \
((CDF_INIT_TOP - 11) >> 1)) / \
((CDF_INIT_TOP - 11)) + \
10), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF12(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
7), \
AOM_ICDF((((a7)-8) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
8), \
AOM_ICDF((((a8)-9) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
9), \
AOM_ICDF((((a9)-10) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
10), \
AOM_ICDF((((a10)-11) * ((CDF_INIT_TOP >> CDF_SHIFT) - 12) + \
((CDF_INIT_TOP - 12) >> 1)) / \
((CDF_INIT_TOP - 12)) + \
11), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF13(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
7), \
AOM_ICDF((((a7)-8) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
8), \
AOM_ICDF((((a8)-9) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
9), \
AOM_ICDF((((a9)-10) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
10), \
AOM_ICDF((((a10)-11) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
11), \
AOM_ICDF((((a11)-12) * ((CDF_INIT_TOP >> CDF_SHIFT) - 13) + \
((CDF_INIT_TOP - 13) >> 1)) / \
((CDF_INIT_TOP - 13)) + \
12), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF14(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
7), \
AOM_ICDF((((a7)-8) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
8), \
AOM_ICDF((((a8)-9) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
9), \
AOM_ICDF((((a9)-10) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
10), \
AOM_ICDF((((a10)-11) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
11), \
AOM_ICDF((((a11)-12) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
12), \
AOM_ICDF((((a12)-13) * ((CDF_INIT_TOP >> CDF_SHIFT) - 14) + \
((CDF_INIT_TOP - 14) >> 1)) / \
((CDF_INIT_TOP - 14)) + \
13), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF15(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
7), \
AOM_ICDF((((a7)-8) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
8), \
AOM_ICDF((((a8)-9) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
9), \
AOM_ICDF((((a9)-10) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
10), \
AOM_ICDF((((a10)-11) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
11), \
AOM_ICDF((((a11)-12) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
12), \
AOM_ICDF((((a12)-13) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
13), \
AOM_ICDF((((a13)-14) * ((CDF_INIT_TOP >> CDF_SHIFT) - 15) + \
((CDF_INIT_TOP - 15) >> 1)) / \
((CDF_INIT_TOP - 15)) + \
14), \
AOM_ICDF(CDF_PROB_TOP), 0
#define AOM_CDF16(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, \
a14) \
AOM_ICDF((((a0)-1) * ((CDF_INIT_TOP >> CDF_SHIFT) - 16) + \
((CDF_INIT_TOP - 16) >> 1)) / \
((CDF_INIT_TOP - 16)) + \
1) \
, AOM_ICDF((((a1)-2) * ((CDF_INIT_TOP >> CDF_SHIFT) - 16) + \
((CDF_INIT_TOP - 16) >> 1)) / \
((CDF_INIT_TOP - 16)) + \
2), \
AOM_ICDF((((a2)-3) * ((CDF_INIT_TOP >> CDF_SHIFT) - 16) + \
((CDF_INIT_TOP - 16) >> 1)) / \
((CDF_INIT_TOP - 16)) + \
3), \
AOM_ICDF((((a3)-4) * ((CDF_INIT_TOP >> CDF_SHIFT) - 16) + \
((CDF_INIT_TOP - 16) >> 1)) / \
((CDF_INIT_TOP - 16)) + \
4), \
AOM_ICDF((((a4)-5) * ((CDF_INIT_TOP >> CDF_SHIFT) - 16) + \
((CDF_INIT_TOP - 16) >> 1)) / \
((CDF_INIT_TOP - 16)) + \
5), \
AOM_ICDF((((a5)-6) * ((CDF_INIT_TOP >> CDF_SHIFT) - 16) + \
((CDF_INIT_TOP - 16) >> 1)) / \
((CDF_INIT_TOP - 16)) + \
6), \
AOM_ICDF((((a6)-7) * ((CDF_INIT_TOP >> CDF_SHIFT) - 16) + \
((CDF_INIT_TOP - 16) >> 1)) / \
((CDF_INIT_TOP - 16)) + \
7), \
AOM_ICDF((((a7)-8) * ((CDF_INIT_TOP >> CDF_SHIFT) - 16) + \
((CDF_INIT_TOP - 16) >> 1)) / \
((CDF_INIT_TOP - 16)) + \
8), \