Commit 91e4e604 authored by Alex Converse's avatar Alex Converse Committed by Gerrit Code Review
Browse files

Merge changes I3ca2b674,I78afc587,I3ae62181,I5ed91556 into nextgenv2

* changes:
  Unfork ANS decode_coefs
  Remove ZERO_TOKEN from the ANS tokenset
  Drop costing ANS tokens from derived probabilities
  Unfork ANS pack_mb_tokens
parents 933bf08c 5e4d00c3
......@@ -2801,17 +2801,6 @@ void av1_model_to_full_probs(const aom_prob *model, aom_prob *full) {
}
#if CONFIG_ANS
void av1_build_token_cdfs(const aom_prob *pdf_model, rans_lut cdf) {
AnsP10 pdf_tab[ENTROPY_TOKENS - 1];
assert(pdf_model[2] != 0);
// TODO(aconverse): Investigate making the precision of the zero and EOB tree
// nodes 10-bits.
aom_rans_merge_prob8_pdf(pdf_tab, pdf_model[1],
av1_pareto8_token_probs[pdf_model[2] - 1],
ENTROPY_TOKENS - 2);
aom_rans_build_cdf_from_pdf(pdf_tab, cdf);
}
void av1_coef_pareto_cdfs(FRAME_CONTEXT *fc) {
TX_SIZE t;
int i, j, k, l;
......@@ -2819,9 +2808,13 @@ void av1_coef_pareto_cdfs(FRAME_CONTEXT *fc) {
for (i = 0; i < PLANE_TYPES; ++i)
for (j = 0; j < REF_TYPES; ++j)
for (k = 0; k < COEF_BANDS; ++k)
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l)
av1_build_token_cdfs(fc->coef_probs[t][i][j][k][l],
fc->coef_cdfs[t][i][j][k][l]);
for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
const aom_prob *const tree_probs = fc->coef_probs[t][i][j][k][l];
aom_prob pivot = tree_probs[PIVOT_NODE];
assert(pivot != 0);
aom_rans_build_cdf_from_pdf(av1_pareto8_token_probs[pivot - 1],
fc->coef_cdfs[t][i][j][k][l]);
}
}
#endif // CONFIG_ANS
......
......@@ -39,7 +39,6 @@
if (counts) ++coef_counts[band][ctx][token]; \
} while (0)
#if !CONFIG_ANS
static INLINE int read_coeff(const aom_prob *probs, int n, aom_reader *r) {
int i, val = 0;
for (i = 0; i < n; ++i) val = (val << 1) | aom_read(r, probs[i]);
......@@ -75,6 +74,11 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
const aom_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size_ctx][type][ref];
const aom_prob *prob;
#if CONFIG_ANS
const rans_lut(*coef_cdfs)[COEFF_CONTEXTS] =
fc->coef_cdfs[tx_size_ctx][type][ref];
const rans_lut *cdf;
#endif // CONFIG_ANS
unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
unsigned int(*eob_branch_count)[COEFF_CONTEXTS];
uint8_t token_cache[MAX_TX_SQUARE];
......@@ -160,7 +164,52 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
dqv_val = &dq_val[band][0];
#endif // CONFIG_NEW_QUANT
}
#if CONFIG_ANS
cdf = &coef_cdfs[band][ctx];
token = ONE_TOKEN + rans_read(r, *cdf);
INCREMENT_COUNT(ONE_TOKEN + (token > ONE_TOKEN));
switch (token) {
case ONE_TOKEN:
case TWO_TOKEN:
case THREE_TOKEN:
case FOUR_TOKEN: val = token; break;
case CATEGORY1_TOKEN:
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, r);
break;
case CATEGORY2_TOKEN:
val = CAT2_MIN_VAL + read_coeff(cat2_prob, 2, r);
break;
case CATEGORY3_TOKEN:
val = CAT3_MIN_VAL + read_coeff(cat3_prob, 3, r);
break;
case CATEGORY4_TOKEN:
val = CAT4_MIN_VAL + read_coeff(cat4_prob, 4, r);
break;
case CATEGORY5_TOKEN:
val = CAT5_MIN_VAL + read_coeff(cat5_prob, 5, r);
break;
case CATEGORY6_TOKEN: {
const int skip_bits = TX_SIZES - 1 - txsize_sqr_up_map[tx_size];
const uint8_t *cat6p = cat6_prob + skip_bits;
#if CONFIG_AOM_HIGHBITDEPTH
switch (xd->bd) {
case AOM_BITS_8:
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
break;
case AOM_BITS_10:
val = CAT6_MIN_VAL + read_coeff(cat6p, 16 - skip_bits, r);
break;
case AOM_BITS_12:
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, r);
break;
default: assert(0); return -1;
}
#else
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, r);
#endif
} break;
}
#else
if (!aom_read(r, prob[ONE_CONTEXT_NODE])) {
INCREMENT_COUNT(ONE_TOKEN);
token = ONE_TOKEN;
......@@ -211,8 +260,8 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
}
}
}
#endif // CONFIG_ANS
#if CONFIG_NEW_QUANT
v = av1_dequant_abscoeff_nuq(val, dqv, dqv_val);
v = dq_shift ? ROUND_POWER_OF_TWO(v, dq_shift) : v;
#else
......@@ -240,186 +289,6 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type,
return c;
}
#else // !CONFIG_ANS
static INLINE int read_coeff(const aom_prob *const probs, int n,
struct AnsDecoder *const ans) {
int i, val = 0;
for (i = 0; i < n; ++i) val = (val << 1) | uabs_read(ans, probs[i]);
return val;
}
static int decode_coefs_ans(const MACROBLOCKD *const xd, PLANE_TYPE type,
tran_low_t *dqcoeff, TX_SIZE tx_size,
TX_TYPE tx_type, const int16_t *dq,
#if CONFIG_NEW_QUANT
dequant_val_type_nuq *dq_val,
#endif // CONFIG_NEW_QUANT
int ctx, const int16_t *scan, const int16_t *nb,
struct AnsDecoder *const ans) {
FRAME_COUNTS *counts = xd->counts;
const int max_eob = get_tx2d_size(tx_size);
const FRAME_CONTEXT *const fc = xd->fc;
const int ref = is_inter_block(&xd->mi[0]->mbmi);
int band, c = 0;
int skip_eob = 0;
const int tx_size_ctx = txsize_sqr_map[tx_size];
const aom_prob(*coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size_ctx][type][ref];
const rans_lut(*coef_cdfs)[COEFF_CONTEXTS] =
fc->coef_cdfs[tx_size_ctx][type][ref];
const aom_prob *prob;
const rans_lut *cdf;
unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1];
unsigned int(*eob_branch_count)[COEFF_CONTEXTS];
uint8_t token_cache[MAX_TX_SQUARE];
const uint8_t *band_translate = get_band_translate(tx_size);
int dq_shift;
int v, token;
int16_t dqv = dq[0];
#if CONFIG_NEW_QUANT
const tran_low_t *dqv_val = &dq_val[0][0];
#endif // CONFIG_NEW_QUANT
const uint8_t *cat1_prob;
const uint8_t *cat2_prob;
const uint8_t *cat3_prob;
const uint8_t *cat4_prob;
const uint8_t *cat5_prob;
const uint8_t *cat6_prob;
dq_shift = get_tx_scale(xd, tx_type, tx_size);
if (counts) {
coef_counts = counts->coef[tx_size_ctx][type][ref];
eob_branch_count = counts->eob_branch[tx_size_ctx][type][ref];
}
#if CONFIG_AOM_HIGHBITDEPTH
if (xd->bd > AOM_BITS_8) {
if (xd->bd == AOM_BITS_10) {
cat1_prob = av1_cat1_prob_high10;
cat2_prob = av1_cat2_prob_high10;
cat3_prob = av1_cat3_prob_high10;
cat4_prob = av1_cat4_prob_high10;
cat5_prob = av1_cat5_prob_high10;
cat6_prob = av1_cat6_prob_high10;
} else {
cat1_prob = av1_cat1_prob_high12;
cat2_prob = av1_cat2_prob_high12;
cat3_prob = av1_cat3_prob_high12;
cat4_prob = av1_cat4_prob_high12;
cat5_prob = av1_cat5_prob_high12;
cat6_prob = av1_cat6_prob_high12;
}
} else {
cat1_prob = av1_cat1_prob;
cat2_prob = av1_cat2_prob;
cat3_prob = av1_cat3_prob;
cat4_prob = av1_cat4_prob;
cat5_prob = av1_cat5_prob;
cat6_prob = av1_cat6_prob;
}
#else
cat1_prob = av1_cat1_prob;
cat2_prob = av1_cat2_prob;
cat3_prob = av1_cat3_prob;
cat4_prob = av1_cat4_prob;
cat5_prob = av1_cat5_prob;
cat6_prob = av1_cat6_prob;
#endif
while (c < max_eob) {
int val = -1;
band = *band_translate++;
prob = coef_probs[band][ctx];
if (!skip_eob) {
if (counts) ++eob_branch_count[band][ctx];
if (!uabs_read(ans, prob[EOB_CONTEXT_NODE])) {
INCREMENT_COUNT(EOB_MODEL_TOKEN);
break;
}
}
#if CONFIG_NEW_QUANT
dqv_val = &dq_val[band][0];
#endif // CONFIG_NEW_QUANT
cdf = &coef_cdfs[band][ctx];
token = ZERO_TOKEN + rans_read(ans, *cdf);
if (token == ZERO_TOKEN) {
INCREMENT_COUNT(ZERO_TOKEN);
token_cache[scan[c]] = 0;
skip_eob = 1;
} else {
INCREMENT_COUNT(ONE_TOKEN + (token > ONE_TOKEN));
switch (token) {
case ONE_TOKEN:
case TWO_TOKEN:
case THREE_TOKEN:
case FOUR_TOKEN: val = token; break;
case CATEGORY1_TOKEN:
val = CAT1_MIN_VAL + read_coeff(cat1_prob, 1, ans);
break;
case CATEGORY2_TOKEN:
val = CAT2_MIN_VAL + read_coeff(cat2_prob, 2, ans);
break;
case CATEGORY3_TOKEN:
val = CAT3_MIN_VAL + read_coeff(cat3_prob, 3, ans);
break;
case CATEGORY4_TOKEN:
val = CAT4_MIN_VAL + read_coeff(cat4_prob, 4, ans);
break;
case CATEGORY5_TOKEN:
val = CAT5_MIN_VAL + read_coeff(cat5_prob, 5, ans);
break;
case CATEGORY6_TOKEN: {
const int skip_bits = TX_SIZES - 1 - txsize_sqr_up_map[tx_size];
const uint8_t *cat6p = cat6_prob + skip_bits;
#if CONFIG_AOM_HIGHBITDEPTH
switch (xd->bd) {
case AOM_BITS_8:
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, ans);
break;
case AOM_BITS_10:
val = CAT6_MIN_VAL + read_coeff(cat6p, 16 - skip_bits, ans);
break;
case AOM_BITS_12:
val = CAT6_MIN_VAL + read_coeff(cat6p, 18 - skip_bits, ans);
break;
default: assert(0); return -1;
}
#else
val = CAT6_MIN_VAL + read_coeff(cat6p, 14 - skip_bits, ans);
#endif
} break;
}
#if CONFIG_NEW_QUANT
v = av1_dequant_abscoeff_nuq(val, dqv, dqv_val);
v = dq_shift ? ROUND_POWER_OF_TWO(v, dq_shift) : v;
#else
v = (val * dqv) >> dq_shift;
#endif // CONFIG_NEW_QUANT
#if CONFIG_COEFFICIENT_RANGE_CHECKING
#if CONFIG_AOM_HIGHBITDEPTH
dqcoeff[scan[c]] =
highbd_check_range((uabs_read_bit(ans) ? -v : v), xd->bd);
#else
dqcoeff[scan[c]] = check_range(uabs_read_bit(ans) ? -v : v);
#endif // CONFIG_AOM_HIGHBITDEPTH
#else
dqcoeff[scan[c]] = uabs_read_bit(ans) ? -v : v;
#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
token_cache[scan[c]] = av1_pt_energy_class[token];
skip_eob = 0;
}
++c;
ctx = get_coef_context(nb, token_cache, c);
dqv = dq[1];
}
return c;
}
#endif // !CONFIG_ANS
// TODO(slavarnway): Decode version of av1_set_context. Modify
// av1_set_context
......@@ -510,7 +379,6 @@ int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
get_dq_profile_from_ctx(xd->qindex[seg_id], ctx, ref, pd->plane_type);
#endif // CONFIG_NEW_QUANT
#if !CONFIG_ANS
#if CONFIG_AOM_QM
const int eob =
decode_coefs(xd, pd->plane_type, pd->dqcoeff, tx_size, tx_type, dequant,
......@@ -523,14 +391,6 @@ int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
#endif // CONFIG_NEW_QUANT
ctx, sc->scan, sc->neighbors, r);
#endif // CONFIG_AOM_QM
#else
const int eob = decode_coefs_ans(xd, pd->plane_type, pd->dqcoeff, tx_size,
tx_type, dequant,
#if CONFIG_NEW_QUANT
pd->seg_dequant_nuq[seg_id][dq],
#endif // CONFIG_NEW_QUANT
ctx, sc->scan, sc->neighbors, r);
#endif // !CONFIG_ANS
dec_set_contexts(xd, pd, tx_size, eob > 0, x, y);
/*
av1_set_contexts(xd, pd,
......
......@@ -620,7 +620,6 @@ static void update_supertx_probs(AV1_COMMON *cm, aom_writer *w) {
}
#endif // CONFIG_SUPERTX
#if !CONFIG_ANS
static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
const TOKENEXTRA *const stop,
aom_bit_depth_t bit_depth, const TX_SIZE tx) {
......@@ -632,9 +631,11 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
while (p < stop && p->token != EOSB_TOKEN) {
const int t = p->token;
#if !CONFIG_ANS
const struct av1_token *const a = &av1_coef_encodings[t];
int v = a->value;
int n = a->len;
#endif // !CONFIG_ANS
#if CONFIG_AOM_HIGHBITDEPTH
const av1_extra_bit *b;
if (bit_depth == AOM_BITS_12)
......@@ -648,6 +649,22 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
(void)bit_depth;
#endif // CONFIG_AOM_HIGHBITDEPTH
#if CONFIG_ANS
/* skip one or two nodes */
if (!p->skip_eob_node) aom_write(w, t != EOB_TOKEN, p->context_tree[0]);
if (t != EOB_TOKEN) {
aom_write(w, t != ZERO_TOKEN, p->context_tree[1]);
if (t != ZERO_TOKEN) {
struct rans_sym s;
const rans_lut *token_cdf = p->token_cdf;
s.cum_prob = (*token_cdf)[t - ONE_TOKEN];
s.prob = (*token_cdf)[t - ONE_TOKEN + 1] - s.cum_prob;
buf_rans_write(w, &s);
}
}
#else
/* skip one or two nodes */
if (p->skip_eob_node)
n -= p->skip_eob_node;
......@@ -668,6 +685,7 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
}
}
}
#endif // CONFIG_ANS
if (b->base_val) {
const int e = p->extra, l = b->len;
......@@ -705,83 +723,6 @@ static void pack_mb_tokens(aom_writer *w, const TOKENEXTRA **tp,
*tp = p;
}
#else
// This function serializes the tokens in forward order using a buffered ans
// coder.
static void pack_mb_tokens(struct BufAnsCoder *ans, const TOKENEXTRA **tp,
const TOKENEXTRA *const stop,
aom_bit_depth_t bit_depth, const TX_SIZE tx) {
const TOKENEXTRA *p = *tp;
#if CONFIG_VAR_TX
int count = 0;
const int seg_eob = 16 << (tx << 1);
#endif // CONFIG_VAR_TX
while (p < stop && p->token != EOSB_TOKEN) {
const int t = p->token;
#if CONFIG_AOM_HIGHBITDEPTH
const av1_extra_bit *b;
if (bit_depth == AOM_BITS_12)
b = &av1_extra_bits_high12[t];
else if (bit_depth == AOM_BITS_10)
b = &av1_extra_bits_high10[t];
else
b = &av1_extra_bits[t];
#else
const av1_extra_bit *const b = &av1_extra_bits[t];
(void)bit_depth;
#endif // CONFIG_AOM_HIGHBITDEPTH
/* skip one or two nodes */
if (!p->skip_eob_node)
buf_uabs_write(ans, t != EOB_TOKEN, p->context_tree[0]);
if (t != EOB_TOKEN) {
struct rans_sym s;
const rans_lut *token_cdf = p->token_cdf;
assert(token_cdf);
s.cum_prob = (*token_cdf)[t - ZERO_TOKEN];
s.prob = (*token_cdf)[t - ZERO_TOKEN + 1] - s.cum_prob;
buf_rans_write(ans, &s);
if (b->base_val) {
const int e = p->extra, l = b->len;
int skip_bits = (b->base_val == CAT6_MIN_VAL)
? TX_SIZES - 1 - txsize_sqr_up_map[tx]
: 0;
if (l) {
const unsigned char *pb = b->prob;
int v = e >> 1;
int n = l; /* number of bits in v, assumed nonzero */
int i = 0;
do {
const int bb = (v >> --n) & 1;
if (skip_bits) {
skip_bits--;
assert(!bb);
} else {
buf_uabs_write(ans, bb, pb[i >> 1]);
}
i = b->tree[i + bb];
} while (n);
}
buf_uabs_write(ans, e & 1, 128);
}
}
++p;
#if CONFIG_VAR_TX
++count;
if (t == EOB_TOKEN || count == seg_eob) break;
#endif // CONFIG_VAR_TX
}
*tp = p;
}
#endif // !CONFIG_ANS
#if CONFIG_VAR_TX
static void pack_txb_tokens(aom_writer *w, const TOKENEXTRA **tp,
......
......@@ -11,9 +11,6 @@
#include <assert.h>
#include "av1/encoder/cost.h"
#if CONFIG_ANS
#include "aom_dsp/ans.h"
#endif // CONFIG_ANS
#include "av1/common/entropy.h"
/* round(-log2(i/256.) * (1 << AV1_PROB_COST_SHIFT))
......@@ -41,91 +38,6 @@ const uint16_t av1_prob_cost[256] = {
26, 23, 20, 18, 15, 12, 9, 6, 3
};
#if CONFIG_ANS
// round(-log2(i/1024.) * (1 << AV1_PROB_COST_SHIFT))
static const uint16_t av1_prob_cost10[1024] = {
5120, 5120, 4608, 4308, 4096, 3931, 3796, 3683, 3584, 3497, 3419, 3349, 3284,
3225, 3171, 3120, 3072, 3027, 2985, 2945, 2907, 2871, 2837, 2804, 2772, 2742,
2713, 2685, 2659, 2633, 2608, 2583, 2560, 2537, 2515, 2494, 2473, 2453, 2433,
2414, 2395, 2377, 2359, 2342, 2325, 2308, 2292, 2276, 2260, 2245, 2230, 2216,
2201, 2187, 2173, 2160, 2147, 2134, 2121, 2108, 2096, 2083, 2071, 2060, 2048,
2037, 2025, 2014, 2003, 1992, 1982, 1971, 1961, 1951, 1941, 1931, 1921, 1911,
1902, 1892, 1883, 1874, 1865, 1856, 1847, 1838, 1830, 1821, 1813, 1804, 1796,
1788, 1780, 1772, 1764, 1756, 1748, 1741, 1733, 1726, 1718, 1711, 1704, 1697,
1689, 1682, 1675, 1668, 1661, 1655, 1648, 1641, 1635, 1628, 1622, 1615, 1609,
1602, 1596, 1590, 1584, 1578, 1571, 1565, 1559, 1554, 1548, 1542, 1536, 1530,
1525, 1519, 1513, 1508, 1502, 1497, 1491, 1486, 1480, 1475, 1470, 1465, 1459,
1454, 1449, 1444, 1439, 1434, 1429, 1424, 1419, 1414, 1409, 1404, 1399, 1395,
1390, 1385, 1380, 1376, 1371, 1367, 1362, 1357, 1353, 1348, 1344, 1340, 1335,
1331, 1326, 1322, 1318, 1313, 1309, 1305, 1301, 1297, 1292, 1288, 1284, 1280,
1276, 1272, 1268, 1264, 1260, 1256, 1252, 1248, 1244, 1240, 1236, 1233, 1229,
1225, 1221, 1218, 1214, 1210, 1206, 1203, 1199, 1195, 1192, 1188, 1185, 1181,
1177, 1174, 1170, 1167, 1163, 1160, 1156, 1153, 1149, 1146, 1143, 1139, 1136,
1133, 1129, 1126, 1123, 1119, 1116, 1113, 1110, 1106, 1103, 1100, 1097, 1094,
1090, 1087, 1084, 1081, 1078, 1075, 1072, 1069, 1066, 1062, 1059, 1056, 1053,
1050, 1047, 1044, 1042, 1039, 1036, 1033, 1030, 1027, 1024, 1021, 1018, 1015,
1013, 1010, 1007, 1004, 1001, 998, 996, 993, 990, 987, 985, 982, 979,
977, 974, 971, 968, 966, 963, 960, 958, 955, 953, 950, 947, 945,
942, 940, 937, 934, 932, 929, 927, 924, 922, 919, 917, 914, 912,
909, 907, 904, 902, 899, 897, 895, 892, 890, 887, 885, 883, 880,
878, 876, 873, 871, 868, 866, 864, 861, 859, 857, 855, 852, 850,
848, 845, 843, 841, 839, 836, 834, 832, 830, 828, 825, 823, 821,
819, 817, 814, 812, 810, 808, 806, 804, 801, 799, 797, 795, 793,
791, 789, 787, 785, 783, 780, 778, 776, 774, 772, 770, 768, 766,
764, 762, 760, 758, 756, 754, 752, 750, 748, 746, 744, 742, 740,
738, 736, 734, 732, 730, 728, 726, 724, 723, 721, 719, 717, 715,
713, 711, 709, 707, 706, 704, 702, 700, 698, 696, 694, 693, 691,
689, 687, 685, 683, 682, 680, 678, 676, 674, 673, 671, 669, 667,
665, 664, 662, 660, 658, 657, 655, 653, 651, 650, 648, 646, 644,
643, 641, 639, 637, 636, 634, 632, 631, 629, 627, 626, 624, 622,
621, 619, 617, 616, 614, 612, 611, 609, 607, 606, 604, 602, 601,
599, 598, 596, 594, 593, 591, 590, 588, 586, 585, 583, 582, 580,
578, 577, 575, 574, 572, 571, 569, 567, 566, 564, 563, 561, 560,
558, 557, 555, 554, 552, 550, 549, 547, 546, 544, 543, 541, 540,
538, 537, 535, 534, 532, 531, 530, 528, 527, 525, 524, 522, 521,
519, 518, 516, 515, 513, 512, 511, 509, 508, 506, 505, 503, 502,
501, 499, 498, 496, 495, 493, 492, 491, 489, 488, 486, 485, 484,
482, 481, 480, 478, 477, 475, 474, 473, 471, 470, 469, 467, 466,
465, 463, 462, 460, 459, 458, 456, 455, 454, 452, 451, 450, 448,
447, 446, 444, 443, 442, 441, 439, 438, 437, 435, 434, 433, 431,
430, 429, 428, 426, 425, 424, 422, 421, 420, 419, 417, 416, 415,
414, 412, 411, 410, 409, 407, 406, 405, 404, 402, 401, 400, 399,
397, 396, 395, 394, 392, 391, 390, 389, 387, 386, 385, 384, 383,
381, 380, 379, 378, 377, 375, 374, 373, 372, 371, 369, 368, 367,
366, 365, 364, 362, 361, 360, 359, 358, 356, 355, 354, 353, 352,
351, 349, 348, 347, 346, 345, 344, 343, 341, 340, 339, 338, 337,
336, 335, 333, 332, 331, 330, 329, 328, 327, 326, 324, 323, 322,
321, 320, 319, 318, 317, 316, 314, 313, 312, 311, 310, 309, 308,
307, 306, 305, 303, 302, 301, 300, 299, 298, 297, 296, 295, 294,
293, 292, 291, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280,
279, 278, 277, 276, 275, 274, 273, 272, 271, 269, 268, 267, 266,
265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, 254, 253,
252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240,
239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227,
226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214,
213, 212, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202,
201, 200, 199, 198, 197, 196, 195, 194, 194, 193, 192, 191, 190,
189, 188, 187, 186, 185, 184, 183, 182, 181, 181, 180, 179, 178,
177, 176, 175, 174, 173, 172, 171, 170, 170, 169, 168, 167, 166,
165, 164, 163, 162, 161, 161, 160, 159, 158, 157, 156, 155, 154,
153, 152, 152, 151, 150, 149, 148, 147, 146, 145, 145, 144, 143,
142, 141, 140, 139, 138, 138, 137, 136, 135, 134, 133, 132, 132,
131, 130, 129, 128, 127, 126, 125, 125, 124, 123, 122, 121, 120,
120, 119, 118, 117, 116, 115, 114, 114, 113, 112, 111, 110, 109,
109, 108, 107, 106, 105, 104, 104, 103, 102, 101, 100, 99, 99,
98, 97, 96, 95, 95, 94, 93, 92, 91, 90, 90, 89, 88,
87, 86, 86, 85, 84, 83, 82, 82, 81, 80, 79, 78, 78,
77, 76, 75, 74, 74, 73, 72, 71, 70, 70, 69, 68, 67,
66, 66, 65, 64, 63, 62, 62, 61, 60, 59, 59, 58, 57,
56, 55, 55, 54, 53, 52, 52, 51, 50, 49, 48, 48, 47,
46, 45, 45, 44, 43, 42, 42, 41, 40, 39, 38, 38, 37,
36, 35, 35, 34, 33, 32, 32, 31, 30, 29, 29, 28, 27,
26, 26, 25, 24, 23, 23, 22, 21, 20, 20, 19, 18, 18,
17, 16, 15, 15, 14, 13, 12, 12, 11, 10, 9, 9, 8,
7, 7, 6, 5, 4, 4, 3, 2, 1, 1
};
#endif // CONFIG_ANS
static void cost(int *costs, aom_tree tree, const aom_prob *probs, int i,
int c) {
const aom_prob prob = probs[i / 2];
......@@ -143,20 +55,6 @@ static void cost(int *costs, aom_tree tree, const aom_prob *probs, int i,
}
}
#if CONFIG_ANS
void av1_cost_tokens_ans(int *costs, const aom_prob *tree_probs,
const rans_lut token_cdf, int skip_eob) {
int c_tree = 0; // Cost of the "tree" nodes EOB and ZERO.
int i;
costs[EOB_TOKEN] = av1_cost_bit(tree_probs[0], 0);
if (!skip_eob) c_tree = av1_cost_bit(tree_probs[0], 1);
for (i = ZERO_TOKEN; i <= CATEGORY6_TOKEN; ++i) {
const int p = token_cdf[i + 1] - token_cdf[i];
costs[i] = c_tree + av1_prob_cost10[p];
}
}
#endif // CONFIG_ANS
void av1_cost_tokens(int *costs, const aom_prob *probs, aom_tree tree) {
cost(costs,