From 9ed1a2ff446c51b933bc3f2d1898d98fbb1b058b Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Sun, 4 Sep 2016 13:30:43 +0200 Subject: [PATCH] Remove custom rans types (cherry picked from aom/master commit 11206c60d930be9d29100567aa67f2a65463852a) Includes renames in a bunch of places not handled by the original due to differing tree states. Change-Id: Ic74d9d8850b8c80a51e55e425bbf472a67e2653f --- aom_dsp/ans.c | 7 +- aom_dsp/ans.h | 15 +- aom_dsp/ansreader.h | 12 +- aom_dsp/answriter.h | 6 +- av1/common/entropy.c | 518 ++++++++++++++++++++------------------- av1/common/entropy.h | 8 +- av1/decoder/detokenize.c | 4 +- av1/encoder/tokenize.c | 8 +- av1/encoder/tokenize.h | 2 +- test/ans_test.cc | 11 +- 10 files changed, 295 insertions(+), 296 deletions(-) diff --git a/aom_dsp/ans.c b/aom_dsp/ans.c index e1aaa0a38..30f115c06 100644 --- a/aom_dsp/ans.c +++ b/aom_dsp/ans.c @@ -15,7 +15,7 @@ #include "aom_dsp/ans.h" #include "aom_dsp/prob.h" -static int find_largest(const AnsP10 *const pdf_tab, int num_syms) { +static int find_largest(const aom_cdf_prob *const pdf_tab, int num_syms) { int largest_idx = -1; int largest_p = -1; int i; @@ -29,8 +29,9 @@ static int find_largest(const AnsP10 *const pdf_tab, int num_syms) { return largest_idx; } -void aom_rans_merge_prob8_pdf(AnsP10 *const out_pdf, const AnsP8 node_prob, - const AnsP10 *const src_pdf, int in_syms) { +void aom_rans_merge_prob8_pdf(aom_cdf_prob *const out_pdf, + const AnsP8 node_prob, + const aom_cdf_prob *const src_pdf, int in_syms) { int i; int adjustment = RANS_PRECISION; const int round_fact = ANS_P8_PRECISION >> 1; diff --git a/aom_dsp/ans.h b/aom_dsp/ans.h index dd244cffd..5927e58ea 100644 --- a/aom_dsp/ans.h +++ b/aom_dsp/ans.h @@ -26,21 +26,16 @@ extern "C" { typedef uint8_t AnsP8; #define ANS_P8_PRECISION 256u #define ANS_P8_SHIFT 8 -typedef uint16_t AnsP10; -#define ANS_P10_PRECISION 1024u +#define RANS_PRECISION 1024u #define RANS_PROB_BITS 10 -#define RANS_PRECISION ANS_P10_PRECISION - -#define L_BASE (ANS_P10_PRECISION * 4) // L_BASE % precision must be 0 +#define L_BASE (RANS_PRECISION * 4) // L_BASE % precision must be 0 #define IO_BASE 256 // Range I = { L_BASE, L_BASE + 1, ..., L_BASE * IO_BASE - 1 } -// This is now just a boring cdf. -typedef uint16_t rans_lut[16]; - -void aom_rans_merge_prob8_pdf(AnsP10 *const out_pdf, const AnsP8 node_prob, - const AnsP10 *const src_pdf, int in_syms); +void aom_rans_merge_prob8_pdf(aom_cdf_prob *const out_pdf, + const AnsP8 node_prob, + const aom_cdf_prob *const src_pdf, int in_syms); #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/aom_dsp/ansreader.h b/aom_dsp/ansreader.h index 57301008b..1f6653145 100644 --- a/aom_dsp/ansreader.h +++ b/aom_dsp/ansreader.h @@ -62,14 +62,14 @@ static INLINE int uabs_read_bit(struct AnsDecoder *ans) { struct rans_dec_sym { uint8_t val; - AnsP10 prob; - AnsP10 cum_prob; // not-inclusive + aom_cdf_prob prob; + aom_cdf_prob cum_prob; // not-inclusive }; -static INLINE void fetch_sym(struct rans_dec_sym *out, const rans_lut cdf, - AnsP10 rem) { +static INLINE void fetch_sym(struct rans_dec_sym *out, const aom_cdf_prob *cdf, + aom_cdf_prob rem) { int i; - AnsP10 cum_prob = 0, top_prob; + aom_cdf_prob cum_prob = 0, top_prob; // TODO(skal): if critical, could be a binary search. // Or, better, an O(1) alias-table. for (i = 0; rem >= (top_prob = cdf[i]); ++i) { @@ -80,7 +80,7 @@ static INLINE void fetch_sym(struct rans_dec_sym *out, const rans_lut cdf, out->cum_prob = cum_prob; } -static INLINE int rans_read(struct AnsDecoder *ans, const rans_lut tab) { +static INLINE int rans_read(struct AnsDecoder *ans, const aom_cdf_prob *tab) { unsigned rem; unsigned quo; struct rans_dec_sym sym; diff --git a/aom_dsp/answriter.h b/aom_dsp/answriter.h index 5a82d35a9..0ac1bda66 100644 --- a/aom_dsp/answriter.h +++ b/aom_dsp/answriter.h @@ -75,8 +75,8 @@ static INLINE void uabs_write(struct AnsCoder *ans, int val, AnsP8 p0) { } struct rans_sym { - AnsP10 prob; - AnsP10 cum_prob; // not-inclusive + aom_cdf_prob prob; + aom_cdf_prob cum_prob; // not-inclusive }; // rANS with normalization @@ -84,7 +84,7 @@ struct rans_sym { // ANS_P10_PRECISION is m static INLINE void rans_write(struct AnsCoder *ans, const struct rans_sym *const sym) { - const AnsP10 p = sym->prob; + const aom_cdf_prob p = sym->prob; while (ans->state >= L_BASE / RANS_PRECISION * IO_BASE * p) { ans->buf[ans->buf_offset++] = ans->state % IO_BASE; ans->state /= IO_BASE; diff --git a/av1/common/entropy.c b/av1/common/entropy.c index 0313f92f0..1defc5333 100644 --- a/av1/common/entropy.c +++ b/av1/common/entropy.c @@ -418,263 +418,264 @@ const aom_prob av1_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES] = { // beta = 8 // Values for tokens ONE_TOKEN through CATEGORY6_TOKEN included here. // ZERO_TOKEN and EOB_TOKEN are coded as flags outside this coder. -const AnsP10 av1_pareto8_token_probs[COEFF_PROB_MODELS][ENTROPY_TOKENS - 2] = { - { 4, 4, 4, 4, 8, 15, 30, 57, 103, 795 }, - { 8, 8, 8, 8, 15, 30, 57, 103, 168, 619 }, - { 12, 12, 12, 12, 23, 43, 80, 138, 205, 487 }, - { 16, 16, 15, 15, 30, 56, 101, 165, 225, 385 }, - { 20, 20, 19, 19, 36, 68, 119, 186, 231, 306 }, - { 24, 23, 23, 22, 43, 79, 135, 201, 230, 244 }, - { 28, 27, 26, 26, 49, 89, 149, 211, 223, 196 }, - { 32, 31, 30, 29, 55, 98, 160, 218, 212, 159 }, - { 36, 35, 33, 32, 60, 107, 171, 221, 200, 129 }, - { 40, 38, 37, 35, 66, 115, 179, 222, 187, 105 }, - { 44, 42, 40, 38, 71, 122, 186, 221, 174, 86 }, - { 48, 45, 43, 41, 76, 129, 192, 219, 160, 71 }, - { 52, 49, 46, 44, 80, 136, 196, 215, 148, 58 }, - { 56, 53, 49, 46, 85, 142, 200, 210, 135, 48 }, - { 60, 56, 52, 49, 89, 147, 203, 204, 124, 40 }, - { 64, 60, 55, 52, 93, 151, 205, 198, 113, 33 }, - { 68, 63, 58, 54, 97, 156, 205, 192, 103, 28 }, - { 72, 66, 61, 57, 100, 160, 206, 185, 94, 23 }, - { 76, 70, 64, 59, 104, 163, 205, 178, 85, 20 }, - { 80, 73, 67, 61, 107, 166, 205, 171, 77, 17 }, - { 84, 76, 69, 63, 110, 169, 204, 164, 71, 14 }, - { 88, 80, 72, 65, 113, 171, 202, 157, 64, 12 }, - { 92, 83, 75, 67, 116, 173, 200, 150, 58, 10 }, - { 96, 86, 77, 69, 118, 175, 198, 143, 53, 9 }, - { 100, 89, 80, 71, 121, 176, 195, 137, 48, 7 }, - { 104, 92, 82, 73, 123, 178, 192, 130, 44, 6 }, - { 108, 96, 84, 75, 125, 178, 189, 124, 40, 5 }, - { 112, 98, 87, 76, 127, 179, 186, 118, 36, 5 }, - { 116, 101, 89, 78, 129, 179, 183, 112, 33, 4 }, - { 120, 104, 91, 80, 131, 180, 179, 106, 30, 3 }, - { 124, 107, 93, 81, 132, 180, 176, 101, 27, 3 }, - { 128, 110, 95, 82, 134, 179, 172, 96, 25, 3 }, - { 132, 113, 97, 84, 135, 179, 168, 91, 23, 2 }, - { 136, 116, 99, 85, 136, 179, 164, 86, 21, 2 }, - { 140, 119, 101, 86, 137, 178, 160, 82, 19, 2 }, - { 144, 122, 103, 88, 138, 177, 157, 77, 17, 1 }, - { 148, 124, 105, 89, 139, 176, 153, 73, 16, 1 }, - { 152, 127, 107, 90, 140, 175, 149, 69, 14, 1 }, - { 156, 130, 108, 91, 141, 173, 145, 66, 13, 1 }, - { 160, 133, 110, 92, 141, 172, 141, 62, 12, 1 }, - { 164, 135, 111, 93, 142, 171, 137, 59, 11, 1 }, - { 168, 138, 113, 94, 142, 169, 133, 56, 10, 1 }, - { 172, 140, 115, 94, 142, 168, 130, 53, 9, 1 }, - { 176, 143, 116, 95, 143, 166, 126, 50, 8, 1 }, - { 180, 145, 118, 96, 143, 164, 122, 47, 8, 1 }, - { 184, 147, 119, 96, 143, 163, 119, 45, 7, 1 }, - { 188, 150, 120, 97, 143, 161, 116, 42, 6, 1 }, - { 192, 152, 121, 98, 143, 159, 112, 40, 6, 1 }, - { 196, 155, 123, 98, 142, 157, 109, 38, 5, 1 }, - { 200, 157, 124, 99, 142, 155, 105, 36, 5, 1 }, - { 204, 159, 125, 99, 142, 153, 102, 34, 5, 1 }, - { 208, 161, 126, 100, 142, 151, 99, 32, 4, 1 }, - { 212, 164, 127, 100, 141, 149, 96, 30, 4, 1 }, - { 216, 166, 129, 100, 141, 147, 93, 28, 3, 1 }, - { 220, 168, 130, 101, 140, 144, 90, 27, 3, 1 }, - { 224, 170, 131, 101, 140, 142, 87, 25, 3, 1 }, - { 228, 172, 132, 101, 139, 140, 84, 24, 3, 1 }, - { 232, 174, 132, 101, 139, 138, 81, 23, 3, 1 }, - { 236, 176, 133, 101, 138, 136, 79, 22, 2, 1 }, - { 240, 178, 134, 102, 137, 134, 76, 20, 2, 1 }, - { 244, 180, 135, 102, 136, 131, 74, 19, 2, 1 }, - { 248, 182, 135, 102, 136, 129, 71, 18, 2, 1 }, - { 252, 184, 136, 101, 135, 127, 69, 17, 2, 1 }, - { 256, 186, 137, 102, 134, 124, 66, 16, 2, 1 }, - { 260, 188, 138, 102, 133, 122, 64, 15, 1, 1 }, - { 264, 190, 138, 101, 132, 120, 62, 15, 1, 1 }, - { 268, 191, 139, 101, 131, 118, 60, 14, 1, 1 }, - { 272, 193, 139, 101, 130, 116, 58, 13, 1, 1 }, - { 276, 195, 139, 101, 129, 114, 56, 12, 1, 1 }, - { 280, 196, 140, 101, 128, 111, 54, 12, 1, 1 }, - { 284, 198, 140, 101, 127, 109, 52, 11, 1, 1 }, - { 288, 200, 141, 100, 126, 107, 50, 10, 1, 1 }, - { 292, 201, 141, 100, 125, 105, 48, 10, 1, 1 }, - { 296, 203, 141, 100, 123, 103, 47, 9, 1, 1 }, - { 300, 204, 142, 99, 122, 101, 45, 9, 1, 1 }, - { 304, 206, 142, 99, 121, 99, 43, 8, 1, 1 }, - { 308, 207, 142, 99, 119, 97, 42, 8, 1, 1 }, - { 312, 209, 142, 99, 118, 95, 40, 7, 1, 1 }, - { 316, 210, 142, 98, 117, 93, 39, 7, 1, 1 }, - { 320, 211, 142, 98, 116, 91, 37, 7, 1, 1 }, - { 324, 213, 142, 97, 115, 89, 36, 6, 1, 1 }, - { 328, 214, 142, 97, 113, 87, 35, 6, 1, 1 }, - { 332, 215, 143, 96, 112, 85, 33, 6, 1, 1 }, - { 336, 216, 143, 96, 111, 83, 32, 5, 1, 1 }, - { 340, 218, 143, 95, 109, 81, 31, 5, 1, 1 }, - { 344, 219, 142, 95, 108, 79, 30, 5, 1, 1 }, - { 348, 220, 142, 94, 107, 78, 29, 4, 1, 1 }, - { 352, 221, 142, 94, 105, 76, 28, 4, 1, 1 }, - { 356, 222, 142, 93, 104, 74, 27, 4, 1, 1 }, - { 360, 223, 142, 92, 103, 72, 26, 4, 1, 1 }, - { 364, 224, 142, 92, 101, 70, 25, 4, 1, 1 }, - { 368, 225, 142, 91, 100, 69, 24, 3, 1, 1 }, - { 372, 226, 141, 91, 99, 67, 23, 3, 1, 1 }, - { 376, 227, 141, 90, 97, 66, 22, 3, 1, 1 }, - { 380, 228, 141, 89, 96, 64, 21, 3, 1, 1 }, - { 384, 229, 140, 89, 95, 62, 20, 3, 1, 1 }, - { 388, 229, 140, 88, 93, 61, 20, 3, 1, 1 }, - { 392, 230, 140, 87, 92, 60, 19, 2, 1, 1 }, - { 396, 231, 140, 86, 91, 58, 18, 2, 1, 1 }, - { 400, 232, 139, 86, 89, 57, 17, 2, 1, 1 }, - { 404, 232, 139, 85, 88, 55, 17, 2, 1, 1 }, - { 408, 233, 138, 84, 87, 54, 16, 2, 1, 1 }, - { 412, 234, 138, 84, 85, 52, 15, 2, 1, 1 }, - { 416, 234, 137, 83, 84, 51, 15, 2, 1, 1 }, - { 420, 235, 137, 82, 82, 50, 14, 2, 1, 1 }, - { 424, 236, 136, 81, 81, 48, 14, 2, 1, 1 }, - { 428, 236, 136, 81, 80, 47, 13, 1, 1, 1 }, - { 432, 236, 135, 80, 79, 46, 13, 1, 1, 1 }, - { 436, 237, 135, 79, 77, 45, 12, 1, 1, 1 }, - { 440, 238, 134, 78, 76, 43, 12, 1, 1, 1 }, - { 444, 238, 134, 77, 75, 42, 11, 1, 1, 1 }, - { 448, 238, 133, 77, 73, 41, 11, 1, 1, 1 }, - { 452, 239, 132, 76, 72, 40, 10, 1, 1, 1 }, - { 456, 239, 131, 75, 71, 39, 10, 1, 1, 1 }, - { 460, 239, 131, 74, 70, 38, 9, 1, 1, 1 }, - { 464, 240, 130, 73, 68, 37, 9, 1, 1, 1 }, - { 468, 240, 129, 72, 67, 36, 9, 1, 1, 1 }, - { 472, 240, 128, 72, 66, 35, 8, 1, 1, 1 }, - { 476, 240, 127, 71, 65, 34, 8, 1, 1, 1 }, - { 480, 240, 127, 70, 63, 33, 8, 1, 1, 1 }, - { 484, 241, 126, 69, 62, 32, 7, 1, 1, 1 }, - { 488, 241, 125, 68, 61, 31, 7, 1, 1, 1 }, - { 492, 241, 124, 67, 60, 30, 7, 1, 1, 1 }, - { 496, 241, 124, 66, 59, 29, 6, 1, 1, 1 }, - { 500, 240, 123, 66, 58, 28, 6, 1, 1, 1 }, - { 504, 240, 122, 65, 57, 27, 6, 1, 1, 1 }, - { 508, 240, 121, 64, 55, 27, 6, 1, 1, 1 }, - { 512, 241, 120, 63, 54, 26, 5, 1, 1, 1 }, - { 516, 241, 119, 62, 53, 25, 5, 1, 1, 1 }, - { 520, 240, 118, 62, 52, 24, 5, 1, 1, 1 }, - { 524, 240, 117, 60, 51, 24, 5, 1, 1, 1 }, - { 528, 239, 116, 60, 50, 23, 5, 1, 1, 1 }, - { 532, 239, 116, 59, 49, 22, 4, 1, 1, 1 }, - { 536, 239, 115, 58, 48, 21, 4, 1, 1, 1 }, - { 540, 239, 113, 57, 47, 21, 4, 1, 1, 1 }, - { 544, 238, 113, 56, 46, 20, 4, 1, 1, 1 }, - { 548, 238, 112, 55, 45, 19, 4, 1, 1, 1 }, - { 552, 238, 110, 55, 44, 19, 3, 1, 1, 1 }, - { 556, 237, 110, 54, 43, 18, 3, 1, 1, 1 }, - { 560, 237, 108, 53, 42, 18, 3, 1, 1, 1 }, - { 564, 236, 108, 52, 41, 17, 3, 1, 1, 1 }, - { 568, 236, 106, 51, 40, 17, 3, 1, 1, 1 }, - { 572, 235, 105, 51, 39, 16, 3, 1, 1, 1 }, - { 576, 235, 104, 50, 38, 15, 3, 1, 1, 1 }, - { 580, 234, 103, 49, 37, 15, 3, 1, 1, 1 }, - { 584, 234, 102, 48, 37, 14, 2, 1, 1, 1 }, - { 588, 233, 101, 47, 36, 14, 2, 1, 1, 1 }, - { 592, 233, 100, 46, 35, 13, 2, 1, 1, 1 }, - { 596, 231, 99, 46, 34, 13, 2, 1, 1, 1 }, - { 600, 230, 98, 45, 33, 13, 2, 1, 1, 1 }, - { 604, 230, 97, 44, 32, 12, 2, 1, 1, 1 }, - { 608, 229, 96, 43, 31, 12, 2, 1, 1, 1 }, - { 612, 228, 95, 42, 31, 11, 2, 1, 1, 1 }, - { 616, 227, 93, 42, 30, 11, 2, 1, 1, 1 }, - { 620, 227, 92, 41, 29, 10, 2, 1, 1, 1 }, - { 624, 226, 92, 40, 28, 10, 1, 1, 1, 1 }, - { 628, 225, 90, 39, 28, 10, 1, 1, 1, 1 }, - { 632, 224, 89, 39, 27, 9, 1, 1, 1, 1 }, - { 636, 223, 88, 38, 26, 9, 1, 1, 1, 1 }, - { 640, 222, 87, 37, 25, 9, 1, 1, 1, 1 }, - { 644, 221, 86, 36, 25, 8, 1, 1, 1, 1 }, - { 648, 220, 84, 36, 24, 8, 1, 1, 1, 1 }, - { 652, 219, 83, 35, 23, 8, 1, 1, 1, 1 }, - { 656, 218, 82, 34, 23, 7, 1, 1, 1, 1 }, - { 660, 217, 81, 33, 22, 7, 1, 1, 1, 1 }, - { 664, 215, 80, 33, 21, 7, 1, 1, 1, 1 }, - { 668, 214, 78, 32, 21, 7, 1, 1, 1, 1 }, - { 672, 213, 78, 31, 20, 6, 1, 1, 1, 1 }, - { 676, 211, 76, 31, 20, 6, 1, 1, 1, 1 }, - { 680, 210, 75, 30, 19, 6, 1, 1, 1, 1 }, - { 684, 209, 74, 29, 18, 6, 1, 1, 1, 1 }, - { 688, 208, 73, 28, 18, 5, 1, 1, 1, 1 }, - { 692, 206, 72, 28, 17, 5, 1, 1, 1, 1 }, - { 696, 205, 70, 27, 17, 5, 1, 1, 1, 1 }, - { 700, 203, 69, 27, 16, 5, 1, 1, 1, 1 }, - { 704, 201, 68, 26, 16, 5, 1, 1, 1, 1 }, - { 708, 201, 67, 25, 15, 4, 1, 1, 1, 1 }, - { 712, 198, 66, 25, 15, 4, 1, 1, 1, 1 }, - { 716, 197, 65, 24, 14, 4, 1, 1, 1, 1 }, - { 720, 196, 63, 23, 14, 4, 1, 1, 1, 1 }, - { 724, 194, 62, 23, 13, 4, 1, 1, 1, 1 }, - { 728, 193, 61, 22, 13, 3, 1, 1, 1, 1 }, - { 732, 191, 60, 22, 12, 3, 1, 1, 1, 1 }, - { 736, 189, 59, 21, 12, 3, 1, 1, 1, 1 }, - { 740, 188, 58, 20, 11, 3, 1, 1, 1, 1 }, - { 744, 186, 56, 20, 11, 3, 1, 1, 1, 1 }, - { 748, 184, 55, 19, 11, 3, 1, 1, 1, 1 }, - { 752, 182, 54, 19, 10, 3, 1, 1, 1, 1 }, - { 756, 181, 53, 18, 10, 2, 1, 1, 1, 1 }, - { 760, 179, 52, 18, 9, 2, 1, 1, 1, 1 }, - { 764, 177, 51, 17, 9, 2, 1, 1, 1, 1 }, - { 768, 174, 50, 17, 9, 2, 1, 1, 1, 1 }, - { 772, 173, 49, 16, 8, 2, 1, 1, 1, 1 }, - { 776, 171, 47, 16, 8, 2, 1, 1, 1, 1 }, - { 780, 169, 46, 15, 8, 2, 1, 1, 1, 1 }, - { 784, 167, 45, 15, 7, 2, 1, 1, 1, 1 }, - { 788, 165, 44, 14, 7, 2, 1, 1, 1, 1 }, - { 792, 162, 43, 14, 7, 2, 1, 1, 1, 1 }, - { 796, 161, 42, 13, 7, 1, 1, 1, 1, 1 }, - { 800, 159, 41, 13, 6, 1, 1, 1, 1, 1 }, - { 804, 157, 40, 12, 6, 1, 1, 1, 1, 1 }, - { 808, 154, 39, 12, 6, 1, 1, 1, 1, 1 }, - { 812, 153, 38, 11, 5, 1, 1, 1, 1, 1 }, - { 816, 150, 37, 11, 5, 1, 1, 1, 1, 1 }, - { 820, 148, 36, 10, 5, 1, 1, 1, 1, 1 }, - { 824, 145, 35, 10, 5, 1, 1, 1, 1, 1 }, - { 828, 143, 34, 10, 4, 1, 1, 1, 1, 1 }, - { 832, 141, 33, 9, 4, 1, 1, 1, 1, 1 }, - { 836, 138, 32, 9, 4, 1, 1, 1, 1, 1 }, - { 840, 136, 30, 9, 4, 1, 1, 1, 1, 1 }, - { 844, 133, 30, 8, 4, 1, 1, 1, 1, 1 }, - { 848, 131, 29, 8, 3, 1, 1, 1, 1, 1 }, - { 852, 129, 28, 7, 3, 1, 1, 1, 1, 1 }, - { 856, 126, 27, 7, 3, 1, 1, 1, 1, 1 }, - { 860, 123, 26, 7, 3, 1, 1, 1, 1, 1 }, - { 864, 121, 25, 6, 3, 1, 1, 1, 1, 1 }, - { 868, 118, 24, 6, 3, 1, 1, 1, 1, 1 }, - { 872, 116, 23, 6, 2, 1, 1, 1, 1, 1 }, - { 876, 113, 22, 6, 2, 1, 1, 1, 1, 1 }, - { 880, 111, 21, 5, 2, 1, 1, 1, 1, 1 }, - { 884, 108, 20, 5, 2, 1, 1, 1, 1, 1 }, - { 888, 105, 19, 5, 2, 1, 1, 1, 1, 1 }, - { 892, 102, 19, 4, 2, 1, 1, 1, 1, 1 }, - { 896, 99, 18, 4, 2, 1, 1, 1, 1, 1 }, - { 900, 97, 17, 4, 1, 1, 1, 1, 1, 1 }, - { 904, 94, 16, 4, 1, 1, 1, 1, 1, 1 }, - { 908, 92, 15, 3, 1, 1, 1, 1, 1, 1 }, - { 912, 89, 14, 3, 1, 1, 1, 1, 1, 1 }, - { 916, 85, 14, 3, 1, 1, 1, 1, 1, 1 }, - { 920, 82, 13, 3, 1, 1, 1, 1, 1, 1 }, - { 924, 79, 12, 3, 1, 1, 1, 1, 1, 1 }, - { 928, 77, 11, 2, 1, 1, 1, 1, 1, 1 }, - { 932, 73, 11, 2, 1, 1, 1, 1, 1, 1 }, - { 936, 70, 10, 2, 1, 1, 1, 1, 1, 1 }, - { 940, 67, 9, 2, 1, 1, 1, 1, 1, 1 }, - { 944, 64, 8, 2, 1, 1, 1, 1, 1, 1 }, - { 948, 60, 8, 2, 1, 1, 1, 1, 1, 1 }, - { 952, 58, 7, 1, 1, 1, 1, 1, 1, 1 }, - { 956, 54, 7, 1, 1, 1, 1, 1, 1, 1 }, - { 960, 51, 6, 1, 1, 1, 1, 1, 1, 1 }, - { 964, 48, 5, 1, 1, 1, 1, 1, 1, 1 }, - { 968, 44, 5, 1, 1, 1, 1, 1, 1, 1 }, - { 972, 41, 4, 1, 1, 1, 1, 1, 1, 1 }, - { 976, 37, 4, 1, 1, 1, 1, 1, 1, 1 }, - { 980, 34, 3, 1, 1, 1, 1, 1, 1, 1 }, - { 984, 30, 3, 1, 1, 1, 1, 1, 1, 1 }, - { 988, 27, 2, 1, 1, 1, 1, 1, 1, 1 }, - { 992, 23, 2, 1, 1, 1, 1, 1, 1, 1 }, - { 996, 19, 2, 1, 1, 1, 1, 1, 1, 1 }, - { 1000, 16, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 1004, 12, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 1008, 8, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 1012, 4, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 1015, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, - { 1015, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, -}; +const aom_cdf_prob + av1_pareto8_token_probs[COEFF_PROB_MODELS][ENTROPY_TOKENS - 2] = { + { 4, 4, 4, 4, 8, 15, 30, 57, 103, 795 }, + { 8, 8, 8, 8, 15, 30, 57, 103, 168, 619 }, + { 12, 12, 12, 12, 23, 43, 80, 138, 205, 487 }, + { 16, 16, 15, 15, 30, 56, 101, 165, 225, 385 }, + { 20, 20, 19, 19, 36, 68, 119, 186, 231, 306 }, + { 24, 23, 23, 22, 43, 79, 135, 201, 230, 244 }, + { 28, 27, 26, 26, 49, 89, 149, 211, 223, 196 }, + { 32, 31, 30, 29, 55, 98, 160, 218, 212, 159 }, + { 36, 35, 33, 32, 60, 107, 171, 221, 200, 129 }, + { 40, 38, 37, 35, 66, 115, 179, 222, 187, 105 }, + { 44, 42, 40, 38, 71, 122, 186, 221, 174, 86 }, + { 48, 45, 43, 41, 76, 129, 192, 219, 160, 71 }, + { 52, 49, 46, 44, 80, 136, 196, 215, 148, 58 }, + { 56, 53, 49, 46, 85, 142, 200, 210, 135, 48 }, + { 60, 56, 52, 49, 89, 147, 203, 204, 124, 40 }, + { 64, 60, 55, 52, 93, 151, 205, 198, 113, 33 }, + { 68, 63, 58, 54, 97, 156, 205, 192, 103, 28 }, + { 72, 66, 61, 57, 100, 160, 206, 185, 94, 23 }, + { 76, 70, 64, 59, 104, 163, 205, 178, 85, 20 }, + { 80, 73, 67, 61, 107, 166, 205, 171, 77, 17 }, + { 84, 76, 69, 63, 110, 169, 204, 164, 71, 14 }, + { 88, 80, 72, 65, 113, 171, 202, 157, 64, 12 }, + { 92, 83, 75, 67, 116, 173, 200, 150, 58, 10 }, + { 96, 86, 77, 69, 118, 175, 198, 143, 53, 9 }, + { 100, 89, 80, 71, 121, 176, 195, 137, 48, 7 }, + { 104, 92, 82, 73, 123, 178, 192, 130, 44, 6 }, + { 108, 96, 84, 75, 125, 178, 189, 124, 40, 5 }, + { 112, 98, 87, 76, 127, 179, 186, 118, 36, 5 }, + { 116, 101, 89, 78, 129, 179, 183, 112, 33, 4 }, + { 120, 104, 91, 80, 131, 180, 179, 106, 30, 3 }, + { 124, 107, 93, 81, 132, 180, 176, 101, 27, 3 }, + { 128, 110, 95, 82, 134, 179, 172, 96, 25, 3 }, + { 132, 113, 97, 84, 135, 179, 168, 91, 23, 2 }, + { 136, 116, 99, 85, 136, 179, 164, 86, 21, 2 }, + { 140, 119, 101, 86, 137, 178, 160, 82, 19, 2 }, + { 144, 122, 103, 88, 138, 177, 157, 77, 17, 1 }, + { 148, 124, 105, 89, 139, 176, 153, 73, 16, 1 }, + { 152, 127, 107, 90, 140, 175, 149, 69, 14, 1 }, + { 156, 130, 108, 91, 141, 173, 145, 66, 13, 1 }, + { 160, 133, 110, 92, 141, 172, 141, 62, 12, 1 }, + { 164, 135, 111, 93, 142, 171, 137, 59, 11, 1 }, + { 168, 138, 113, 94, 142, 169, 133, 56, 10, 1 }, + { 172, 140, 115, 94, 142, 168, 130, 53, 9, 1 }, + { 176, 143, 116, 95, 143, 166, 126, 50, 8, 1 }, + { 180, 145, 118, 96, 143, 164, 122, 47, 8, 1 }, + { 184, 147, 119, 96, 143, 163, 119, 45, 7, 1 }, + { 188, 150, 120, 97, 143, 161, 116, 42, 6, 1 }, + { 192, 152, 121, 98, 143, 159, 112, 40, 6, 1 }, + { 196, 155, 123, 98, 142, 157, 109, 38, 5, 1 }, + { 200, 157, 124, 99, 142, 155, 105, 36, 5, 1 }, + { 204, 159, 125, 99, 142, 153, 102, 34, 5, 1 }, + { 208, 161, 126, 100, 142, 151, 99, 32, 4, 1 }, + { 212, 164, 127, 100, 141, 149, 96, 30, 4, 1 }, + { 216, 166, 129, 100, 141, 147, 93, 28, 3, 1 }, + { 220, 168, 130, 101, 140, 144, 90, 27, 3, 1 }, + { 224, 170, 131, 101, 140, 142, 87, 25, 3, 1 }, + { 228, 172, 132, 101, 139, 140, 84, 24, 3, 1 }, + { 232, 174, 132, 101, 139, 138, 81, 23, 3, 1 }, + { 236, 176, 133, 101, 138, 136, 79, 22, 2, 1 }, + { 240, 178, 134, 102, 137, 134, 76, 20, 2, 1 }, + { 244, 180, 135, 102, 136, 131, 74, 19, 2, 1 }, + { 248, 182, 135, 102, 136, 129, 71, 18, 2, 1 }, + { 252, 184, 136, 101, 135, 127, 69, 17, 2, 1 }, + { 256, 186, 137, 102, 134, 124, 66, 16, 2, 1 }, + { 260, 188, 138, 102, 133, 122, 64, 15, 1, 1 }, + { 264, 190, 138, 101, 132, 120, 62, 15, 1, 1 }, + { 268, 191, 139, 101, 131, 118, 60, 14, 1, 1 }, + { 272, 193, 139, 101, 130, 116, 58, 13, 1, 1 }, + { 276, 195, 139, 101, 129, 114, 56, 12, 1, 1 }, + { 280, 196, 140, 101, 128, 111, 54, 12, 1, 1 }, + { 284, 198, 140, 101, 127, 109, 52, 11, 1, 1 }, + { 288, 200, 141, 100, 126, 107, 50, 10, 1, 1 }, + { 292, 201, 141, 100, 125, 105, 48, 10, 1, 1 }, + { 296, 203, 141, 100, 123, 103, 47, 9, 1, 1 }, + { 300, 204, 142, 99, 122, 101, 45, 9, 1, 1 }, + { 304, 206, 142, 99, 121, 99, 43, 8, 1, 1 }, + { 308, 207, 142, 99, 119, 97, 42, 8, 1, 1 }, + { 312, 209, 142, 99, 118, 95, 40, 7, 1, 1 }, + { 316, 210, 142, 98, 117, 93, 39, 7, 1, 1 }, + { 320, 211, 142, 98, 116, 91, 37, 7, 1, 1 }, + { 324, 213, 142, 97, 115, 89, 36, 6, 1, 1 }, + { 328, 214, 142, 97, 113, 87, 35, 6, 1, 1 }, + { 332, 215, 143, 96, 112, 85, 33, 6, 1, 1 }, + { 336, 216, 143, 96, 111, 83, 32, 5, 1, 1 }, + { 340, 218, 143, 95, 109, 81, 31, 5, 1, 1 }, + { 344, 219, 142, 95, 108, 79, 30, 5, 1, 1 }, + { 348, 220, 142, 94, 107, 78, 29, 4, 1, 1 }, + { 352, 221, 142, 94, 105, 76, 28, 4, 1, 1 }, + { 356, 222, 142, 93, 104, 74, 27, 4, 1, 1 }, + { 360, 223, 142, 92, 103, 72, 26, 4, 1, 1 }, + { 364, 224, 142, 92, 101, 70, 25, 4, 1, 1 }, + { 368, 225, 142, 91, 100, 69, 24, 3, 1, 1 }, + { 372, 226, 141, 91, 99, 67, 23, 3, 1, 1 }, + { 376, 227, 141, 90, 97, 66, 22, 3, 1, 1 }, + { 380, 228, 141, 89, 96, 64, 21, 3, 1, 1 }, + { 384, 229, 140, 89, 95, 62, 20, 3, 1, 1 }, + { 388, 229, 140, 88, 93, 61, 20, 3, 1, 1 }, + { 392, 230, 140, 87, 92, 60, 19, 2, 1, 1 }, + { 396, 231, 140, 86, 91, 58, 18, 2, 1, 1 }, + { 400, 232, 139, 86, 89, 57, 17, 2, 1, 1 }, + { 404, 232, 139, 85, 88, 55, 17, 2, 1, 1 }, + { 408, 233, 138, 84, 87, 54, 16, 2, 1, 1 }, + { 412, 234, 138, 84, 85, 52, 15, 2, 1, 1 }, + { 416, 234, 137, 83, 84, 51, 15, 2, 1, 1 }, + { 420, 235, 137, 82, 82, 50, 14, 2, 1, 1 }, + { 424, 236, 136, 81, 81, 48, 14, 2, 1, 1 }, + { 428, 236, 136, 81, 80, 47, 13, 1, 1, 1 }, + { 432, 236, 135, 80, 79, 46, 13, 1, 1, 1 }, + { 436, 237, 135, 79, 77, 45, 12, 1, 1, 1 }, + { 440, 238, 134, 78, 76, 43, 12, 1, 1, 1 }, + { 444, 238, 134, 77, 75, 42, 11, 1, 1, 1 }, + { 448, 238, 133, 77, 73, 41, 11, 1, 1, 1 }, + { 452, 239, 132, 76, 72, 40, 10, 1, 1, 1 }, + { 456, 239, 131, 75, 71, 39, 10, 1, 1, 1 }, + { 460, 239, 131, 74, 70, 38, 9, 1, 1, 1 }, + { 464, 240, 130, 73, 68, 37, 9, 1, 1, 1 }, + { 468, 240, 129, 72, 67, 36, 9, 1, 1, 1 }, + { 472, 240, 128, 72, 66, 35, 8, 1, 1, 1 }, + { 476, 240, 127, 71, 65, 34, 8, 1, 1, 1 }, + { 480, 240, 127, 70, 63, 33, 8, 1, 1, 1 }, + { 484, 241, 126, 69, 62, 32, 7, 1, 1, 1 }, + { 488, 241, 125, 68, 61, 31, 7, 1, 1, 1 }, + { 492, 241, 124, 67, 60, 30, 7, 1, 1, 1 }, + { 496, 241, 124, 66, 59, 29, 6, 1, 1, 1 }, + { 500, 240, 123, 66, 58, 28, 6, 1, 1, 1 }, + { 504, 240, 122, 65, 57, 27, 6, 1, 1, 1 }, + { 508, 240, 121, 64, 55, 27, 6, 1, 1, 1 }, + { 512, 241, 120, 63, 54, 26, 5, 1, 1, 1 }, + { 516, 241, 119, 62, 53, 25, 5, 1, 1, 1 }, + { 520, 240, 118, 62, 52, 24, 5, 1, 1, 1 }, + { 524, 240, 117, 60, 51, 24, 5, 1, 1, 1 }, + { 528, 239, 116, 60, 50, 23, 5, 1, 1, 1 }, + { 532, 239, 116, 59, 49, 22, 4, 1, 1, 1 }, + { 536, 239, 115, 58, 48, 21, 4, 1, 1, 1 }, + { 540, 239, 113, 57, 47, 21, 4, 1, 1, 1 }, + { 544, 238, 113, 56, 46, 20, 4, 1, 1, 1 }, + { 548, 238, 112, 55, 45, 19, 4, 1, 1, 1 }, + { 552, 238, 110, 55, 44, 19, 3, 1, 1, 1 }, + { 556, 237, 110, 54, 43, 18, 3, 1, 1, 1 }, + { 560, 237, 108, 53, 42, 18, 3, 1, 1, 1 }, + { 564, 236, 108, 52, 41, 17, 3, 1, 1, 1 }, + { 568, 236, 106, 51, 40, 17, 3, 1, 1, 1 }, + { 572, 235, 105, 51, 39, 16, 3, 1, 1, 1 }, + { 576, 235, 104, 50, 38, 15, 3, 1, 1, 1 }, + { 580, 234, 103, 49, 37, 15, 3, 1, 1, 1 }, + { 584, 234, 102, 48, 37, 14, 2, 1, 1, 1 }, + { 588, 233, 101, 47, 36, 14, 2, 1, 1, 1 }, + { 592, 233, 100, 46, 35, 13, 2, 1, 1, 1 }, + { 596, 231, 99, 46, 34, 13, 2, 1, 1, 1 }, + { 600, 230, 98, 45, 33, 13, 2, 1, 1, 1 }, + { 604, 230, 97, 44, 32, 12, 2, 1, 1, 1 }, + { 608, 229, 96, 43, 31, 12, 2, 1, 1, 1 }, + { 612, 228, 95, 42, 31, 11, 2, 1, 1, 1 }, + { 616, 227, 93, 42, 30, 11, 2, 1, 1, 1 }, + { 620, 227, 92, 41, 29, 10, 2, 1, 1, 1 }, + { 624, 226, 92, 40, 28, 10, 1, 1, 1, 1 }, + { 628, 225, 90, 39, 28, 10, 1, 1, 1, 1 }, + { 632, 224, 89, 39, 27, 9, 1, 1, 1, 1 }, + { 636, 223, 88, 38, 26, 9, 1, 1, 1, 1 }, + { 640, 222, 87, 37, 25, 9, 1, 1, 1, 1 }, + { 644, 221, 86, 36, 25, 8, 1, 1, 1, 1 }, + { 648, 220, 84, 36, 24, 8, 1, 1, 1, 1 }, + { 652, 219, 83, 35, 23, 8, 1, 1, 1, 1 }, + { 656, 218, 82, 34, 23, 7, 1, 1, 1, 1 }, + { 660, 217, 81, 33, 22, 7, 1, 1, 1, 1 }, + { 664, 215, 80, 33, 21, 7, 1, 1, 1, 1 }, + { 668, 214, 78, 32, 21, 7, 1, 1, 1, 1 }, + { 672, 213, 78, 31, 20, 6, 1, 1, 1, 1 }, + { 676, 211, 76, 31, 20, 6, 1, 1, 1, 1 }, + { 680, 210, 75, 30, 19, 6, 1, 1, 1, 1 }, + { 684, 209, 74, 29, 18, 6, 1, 1, 1, 1 }, + { 688, 208, 73, 28, 18, 5, 1, 1, 1, 1 }, + { 692, 206, 72, 28, 17, 5, 1, 1, 1, 1 }, + { 696, 205, 70, 27, 17, 5, 1, 1, 1, 1 }, + { 700, 203, 69, 27, 16, 5, 1, 1, 1, 1 }, + { 704, 201, 68, 26, 16, 5, 1, 1, 1, 1 }, + { 708, 201, 67, 25, 15, 4, 1, 1, 1, 1 }, + { 712, 198, 66, 25, 15, 4, 1, 1, 1, 1 }, + { 716, 197, 65, 24, 14, 4, 1, 1, 1, 1 }, + { 720, 196, 63, 23, 14, 4, 1, 1, 1, 1 }, + { 724, 194, 62, 23, 13, 4, 1, 1, 1, 1 }, + { 728, 193, 61, 22, 13, 3, 1, 1, 1, 1 }, + { 732, 191, 60, 22, 12, 3, 1, 1, 1, 1 }, + { 736, 189, 59, 21, 12, 3, 1, 1, 1, 1 }, + { 740, 188, 58, 20, 11, 3, 1, 1, 1, 1 }, + { 744, 186, 56, 20, 11, 3, 1, 1, 1, 1 }, + { 748, 184, 55, 19, 11, 3, 1, 1, 1, 1 }, + { 752, 182, 54, 19, 10, 3, 1, 1, 1, 1 }, + { 756, 181, 53, 18, 10, 2, 1, 1, 1, 1 }, + { 760, 179, 52, 18, 9, 2, 1, 1, 1, 1 }, + { 764, 177, 51, 17, 9, 2, 1, 1, 1, 1 }, + { 768, 174, 50, 17, 9, 2, 1, 1, 1, 1 }, + { 772, 173, 49, 16, 8, 2, 1, 1, 1, 1 }, + { 776, 171, 47, 16, 8, 2, 1, 1, 1, 1 }, + { 780, 169, 46, 15, 8, 2, 1, 1, 1, 1 }, + { 784, 167, 45, 15, 7, 2, 1, 1, 1, 1 }, + { 788, 165, 44, 14, 7, 2, 1, 1, 1, 1 }, + { 792, 162, 43, 14, 7, 2, 1, 1, 1, 1 }, + { 796, 161, 42, 13, 7, 1, 1, 1, 1, 1 }, + { 800, 159, 41, 13, 6, 1, 1, 1, 1, 1 }, + { 804, 157, 40, 12, 6, 1, 1, 1, 1, 1 }, + { 808, 154, 39, 12, 6, 1, 1, 1, 1, 1 }, + { 812, 153, 38, 11, 5, 1, 1, 1, 1, 1 }, + { 816, 150, 37, 11, 5, 1, 1, 1, 1, 1 }, + { 820, 148, 36, 10, 5, 1, 1, 1, 1, 1 }, + { 824, 145, 35, 10, 5, 1, 1, 1, 1, 1 }, + { 828, 143, 34, 10, 4, 1, 1, 1, 1, 1 }, + { 832, 141, 33, 9, 4, 1, 1, 1, 1, 1 }, + { 836, 138, 32, 9, 4, 1, 1, 1, 1, 1 }, + { 840, 136, 30, 9, 4, 1, 1, 1, 1, 1 }, + { 844, 133, 30, 8, 4, 1, 1, 1, 1, 1 }, + { 848, 131, 29, 8, 3, 1, 1, 1, 1, 1 }, + { 852, 129, 28, 7, 3, 1, 1, 1, 1, 1 }, + { 856, 126, 27, 7, 3, 1, 1, 1, 1, 1 }, + { 860, 123, 26, 7, 3, 1, 1, 1, 1, 1 }, + { 864, 121, 25, 6, 3, 1, 1, 1, 1, 1 }, + { 868, 118, 24, 6, 3, 1, 1, 1, 1, 1 }, + { 872, 116, 23, 6, 2, 1, 1, 1, 1, 1 }, + { 876, 113, 22, 6, 2, 1, 1, 1, 1, 1 }, + { 880, 111, 21, 5, 2, 1, 1, 1, 1, 1 }, + { 884, 108, 20, 5, 2, 1, 1, 1, 1, 1 }, + { 888, 105, 19, 5, 2, 1, 1, 1, 1, 1 }, + { 892, 102, 19, 4, 2, 1, 1, 1, 1, 1 }, + { 896, 99, 18, 4, 2, 1, 1, 1, 1, 1 }, + { 900, 97, 17, 4, 1, 1, 1, 1, 1, 1 }, + { 904, 94, 16, 4, 1, 1, 1, 1, 1, 1 }, + { 908, 92, 15, 3, 1, 1, 1, 1, 1, 1 }, + { 912, 89, 14, 3, 1, 1, 1, 1, 1, 1 }, + { 916, 85, 14, 3, 1, 1, 1, 1, 1, 1 }, + { 920, 82, 13, 3, 1, 1, 1, 1, 1, 1 }, + { 924, 79, 12, 3, 1, 1, 1, 1, 1, 1 }, + { 928, 77, 11, 2, 1, 1, 1, 1, 1, 1 }, + { 932, 73, 11, 2, 1, 1, 1, 1, 1, 1 }, + { 936, 70, 10, 2, 1, 1, 1, 1, 1, 1 }, + { 940, 67, 9, 2, 1, 1, 1, 1, 1, 1 }, + { 944, 64, 8, 2, 1, 1, 1, 1, 1, 1 }, + { 948, 60, 8, 2, 1, 1, 1, 1, 1, 1 }, + { 952, 58, 7, 1, 1, 1, 1, 1, 1, 1 }, + { 956, 54, 7, 1, 1, 1, 1, 1, 1, 1 }, + { 960, 51, 6, 1, 1, 1, 1, 1, 1, 1 }, + { 964, 48, 5, 1, 1, 1, 1, 1, 1, 1 }, + { 968, 44, 5, 1, 1, 1, 1, 1, 1, 1 }, + { 972, 41, 4, 1, 1, 1, 1, 1, 1, 1 }, + { 976, 37, 4, 1, 1, 1, 1, 1, 1, 1 }, + { 980, 34, 3, 1, 1, 1, 1, 1, 1, 1 }, + { 984, 30, 3, 1, 1, 1, 1, 1, 1, 1 }, + { 988, 27, 2, 1, 1, 1, 1, 1, 1, 1 }, + { 992, 23, 2, 1, 1, 1, 1, 1, 1, 1 }, + { 996, 19, 2, 1, 1, 1, 1, 1, 1, 1 }, + { 1000, 16, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1004, 12, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1008, 8, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1012, 4, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1015, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + { 1015, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, + }; #endif // CONFIG_ANS /* clang-format off */ @@ -2801,7 +2802,8 @@ void av1_model_to_full_probs(const aom_prob *model, aom_prob *full) { } #if CONFIG_ANS -static void build_token_cdfs(const aom_prob *pdf_model, rans_lut cdf) { +static void build_token_cdfs(const aom_prob *pdf_model, + aom_cdf_prob cdf[ENTROPY_TOKENS]) { int i, sum = 0; assert(pdf_model[2] != 0); for (i = 0; i < ENTROPY_TOKENS - 2; ++i) { diff --git a/av1/common/entropy.h b/av1/common/entropy.h index f0727c00d..fd68e825d 100644 --- a/av1/common/entropy.h +++ b/av1/common/entropy.h @@ -191,10 +191,10 @@ static INLINE const uint8_t *get_band_translate(TX_SIZE tx_size) { extern const aom_tree_index av1_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)]; extern const aom_prob av1_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES]; #if CONFIG_ANS -extern const AnsP10 av1_pareto8_token_probs[COEFF_PROB_MODELS] - [ENTROPY_TOKENS - 2]; - -typedef rans_lut coeff_cdf_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS]; +typedef aom_cdf_prob coeff_cdf_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] + [ENTROPY_TOKENS]; +extern const aom_cdf_prob av1_pareto8_token_probs[COEFF_PROB_MODELS] + [ENTROPY_TOKENS - 2]; #endif // CONFIG_ANS typedef aom_prob av1_coeff_probs_model[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] diff --git a/av1/decoder/detokenize.c b/av1/decoder/detokenize.c index f8e286742..9a40f698d 100644 --- a/av1/decoder/detokenize.c +++ b/av1/decoder/detokenize.c @@ -75,9 +75,9 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type, fc->coef_probs[tx_size_ctx][type][ref]; const aom_prob *prob; #if CONFIG_ANS - const rans_lut(*coef_cdfs)[COEFF_CONTEXTS] = + const aom_cdf_prob(*const coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] = fc->coef_cdfs[tx_size_ctx][type][ref]; - const rans_lut *cdf; + const aom_cdf_prob(*cdf)[ENTROPY_TOKENS]; #endif // CONFIG_ANS unsigned int(*coef_counts)[COEFF_CONTEXTS][UNCONSTRAINED_NODES + 1]; unsigned int(*eob_branch_count)[COEFF_CONTEXTS]; diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c index 9def62d88..809568107 100644 --- a/av1/encoder/tokenize.c +++ b/av1/encoder/tokenize.c @@ -387,7 +387,7 @@ static void set_entropy_context_b(int plane, int block, int blk_row, static INLINE void add_token(TOKENEXTRA **t, const aom_prob *context_tree, #if CONFIG_ANS - const rans_lut *token_cdf, + const aom_cdf_prob (*token_cdf)[ENTROPY_TOKENS], #endif // CONFIG_ANS int32_t extra, uint8_t token, uint8_t skip_eob_node, unsigned int *counts) { @@ -487,8 +487,8 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col, cpi->common.fc->coef_probs[txsize_sqr_map[tx_size]][type][ref]; #endif // CONFIG_ENTROPY #if CONFIG_ANS - rans_lut(*const coef_cdfs)[COEFF_CONTEXTS] = - cpi->common.fc->coef_cdfs[txsize_sqr_map[tx_size]][type][ref]; + aom_cdf_prob(*const coef_cdfs)[COEFF_CONTEXTS][ENTROPY_TOKENS] = + cpi->common.fc->coef_cdfs[tx_size][type][ref]; #endif // CONFIG_ANS unsigned int(*const eob_branch)[COEFF_CONTEXTS] = td->counts->eob_branch[txsize_sqr_map[tx_size]][type][ref]; @@ -511,7 +511,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col, add_token(&t, coef_probs[band[c]][pt], #if CONFIG_ANS - (const rans_lut *)&coef_cdfs[band[c]][pt], + (const aom_cdf_prob(*)[ENTROPY_TOKENS]) & coef_cdfs[band[c]][pt], #endif // CONFIG_ANS extra, (uint8_t)token, (uint8_t)skip_eob, counts[band[c]][pt]); diff --git a/av1/encoder/tokenize.h b/av1/encoder/tokenize.h index 520e1b676..f20848aab 100644 --- a/av1/encoder/tokenize.h +++ b/av1/encoder/tokenize.h @@ -37,7 +37,7 @@ typedef struct { typedef struct { const aom_prob *context_tree; #if CONFIG_ANS - const rans_lut *token_cdf; + const aom_cdf_prob (*token_cdf)[ENTROPY_TOKENS]; #endif // CONFIG_ANS EXTRABIT extra; uint8_t token; diff --git a/test/ans_test.cc b/test/ans_test.cc index 4c4aff2e1..5860d4418 100644 --- a/test/ans_test.cc +++ b/test/ans_test.cc @@ -79,13 +79,13 @@ bool check_uabs(const PvVec &pv_vec, uint8_t *buf) { const rans_sym rans_sym_tab[] = { { 67, 0 }, { 99, 67 }, { 575, 166 }, { 283, 741 }, }; +const int kRansSymbols = + static_cast(sizeof(rans_sym_tab) / sizeof(rans_sym_tab[0])); std::vector ans_encode_build_vals(const rans_sym *tab, int iters) { std::vector p_to_sym; - int i = 0; - while (p_to_sym.size() < RANS_PRECISION) { + for (int i = 0; i < kRansSymbols; ++i) { p_to_sym.insert(p_to_sym.end(), tab[i].prob, i); - ++i; } assert(p_to_sym.size() == RANS_PRECISION); std::vector ret; @@ -97,7 +97,8 @@ std::vector ans_encode_build_vals(const rans_sym *tab, int iters) { return ret; } -void rans_build_dec_tab(const struct rans_sym sym_tab[], rans_lut dec_tab) { +void rans_build_dec_tab(const struct rans_sym sym_tab[], + aom_cdf_prob *dec_tab) { unsigned int sum = 0; for (int i = 0; sum < RANS_PRECISION; ++i) { dec_tab[i] = sum += sym_tab[i].prob; @@ -108,7 +109,7 @@ bool check_rans(const std::vector &sym_vec, const rans_sym *const tab, uint8_t *buf) { AnsCoder a; ans_write_init(&a, buf); - rans_lut dec_tab; + aom_cdf_prob dec_tab[kRansSymbols]; rans_build_dec_tab(tab, dec_tab); std::clock_t start = std::clock();