From b3c66f8a2f74cb67aee8548b01da0bf9e610f04d Mon Sep 17 00:00:00 2001 From: Jim Bankoski Date: Tue, 23 Dec 2014 15:06:17 -0800 Subject: [PATCH] WIP: Remove giant value cost table Change-Id: Iabe8a8868a747626c24bb13f1796f4c7827af367 --- vp9/common/vp9_entropy.h | 1 + vp9/encoder/vp9_encodemb.c | 31 ++- vp9/encoder/vp9_encoder.c | 1 - vp9/encoder/vp9_rdopt.c | 24 ++- vp9/encoder/vp9_tokenize.c | 429 ++++++++++++++++++++++++++++--------- vp9/encoder/vp9_tokenize.h | 28 ++- 6 files changed, 383 insertions(+), 131 deletions(-) diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h index 239c0494c..4eb2e6413 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -81,6 +81,7 @@ typedef struct { const vp9_prob *prob; int len; int base_val; + const int16_t *cost; } vp9_extra_bit; // indexed by token value diff --git a/vp9/encoder/vp9_encodemb.c b/vp9/encoder/vp9_encodemb.c index 9c29eb438..d016e9742 100644 --- a/vp9/encoder/vp9_encodemb.c +++ b/vp9/encoder/vp9_encodemb.c @@ -147,9 +147,15 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, int next = eob, sz = 0; int64_t rdmult = mb->rdmult * plane_rd_mult[type], rddiv = mb->rddiv; int64_t rd_cost0, rd_cost1; - int rate0, rate1, error0, error1, t0, t1; + int rate0, rate1, error0, error1; + int16_t t0, t1; + EXTRABIT e0; int best, band, pt, i, final_eob; - const int16_t *dct_value_cost; +#if CONFIG_VP9_HIGHBITDEPTH + const int16_t *cat6_high_cost = vp9_get_high_cost_table(xd->bd); +#else + const int16_t *cat6_high_cost = vp9_get_high_cost_table(8); +#endif assert((!type && !plane) || (type && plane)); assert(eob <= default_eob); @@ -166,17 +172,6 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, tokens[eob][0].qc = 0; tokens[eob][1] = tokens[eob][0]; -#if CONFIG_VP9_HIGHBITDEPTH - if (xd->bd == 12) { - dct_value_cost = vp9_dct_value_cost_high12_ptr; - } else if (xd->bd == 10) { - dct_value_cost = vp9_dct_value_cost_high10_ptr; - } else { - dct_value_cost = vp9_dct_value_cost_ptr; - } -#else - dct_value_cost = vp9_dct_value_cost_ptr; -#endif for (i = 0; i < eob; i++) token_cache[scan[i]] = vp9_pt_energy_class[vp9_get_token(qcoeff[scan[i]])]; @@ -193,7 +188,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, /* Evaluate the first possibility for this state. */ rate0 = tokens[next][0].rate; rate1 = tokens[next][1].rate; - t0 = vp9_get_token(x); + vp9_get_token_extra(x, &t0, &e0); /* Consider both possible successor states. */ if (next < default_eob) { band = band_translate[i + 1]; @@ -206,7 +201,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, UPDATE_RD_COST(); /* And pick the best. */ best = rd_cost1 < rd_cost0; - base_bits = dct_value_cost[x]; + base_bits = vp9_get_cost(t0, e0, cat6_high_cost); dx = mul * (dqcoeff[rc] - coeff[rc]); #if CONFIG_VP9_HIGHBITDEPTH if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { @@ -244,8 +239,10 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, */ t0 = tokens[next][0].token == EOB_TOKEN ? EOB_TOKEN : ZERO_TOKEN; t1 = tokens[next][1].token == EOB_TOKEN ? EOB_TOKEN : ZERO_TOKEN; + e0 = 0; } else { - t0 = t1 = vp9_get_token(x); + vp9_get_token_extra(x, &t0, &e0); + t1 = t0; } if (next < default_eob) { band = band_translate[i + 1]; @@ -264,7 +261,7 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block, UPDATE_RD_COST(); /* And pick the best. */ best = rd_cost1 < rd_cost0; - base_bits = dct_value_cost[x]; + base_bits = vp9_get_cost(t0, e0, cat6_high_cost); if (shortcut) { #if CONFIG_VP9_HIGHBITDEPTH diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 430ad17e0..78b61f0dc 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -186,7 +186,6 @@ void vp9_initialize_enc(void) { if (!init_done) { vp9_rtcd(); vp9_init_intra_predictors(); - vp9_tokenize_initialize(); vp9_init_me_luts(); vp9_rc_init_minq_luts(); vp9_entropy_mv_init(); diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index ded082f86..613fe660e 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -360,6 +360,12 @@ static INLINE int cost_coeffs(MACROBLOCK *x, uint8_t token_cache[32 * 32]; int pt = combine_entropy_contexts(*A, *L); int c, cost; +#if CONFIG_VP9_HIGHBITDEPTH + const int16_t *cat6_high_cost = vp9_get_high_cost_table(xd->bd); +#else + const int16_t *cat6_high_cost = vp9_get_high_cost_table(8); +#endif + // Check for consistency of tx_size with mode info assert(type == PLANE_TYPE_Y ? mbmi->tx_size == tx_size : get_uv_tx_size(mbmi, pd) == tx_size); @@ -373,23 +379,29 @@ static INLINE int cost_coeffs(MACROBLOCK *x, // dc token int v = qcoeff[0]; - int prev_t = vp9_get_token(v); - cost = (*token_costs)[0][pt][prev_t] + vp9_dct_value_cost_ptr[v]; + int16_t prev_t; + EXTRABIT e; + vp9_get_token_extra(v, &prev_t, &e); + cost = (*token_costs)[0][pt][prev_t] + + vp9_get_cost(prev_t, e, cat6_high_cost); + token_cache[0] = vp9_pt_energy_class[prev_t]; ++token_costs; // ac tokens for (c = 1; c < eob; c++) { const int rc = scan[c]; - int t; + int16_t t; v = qcoeff[rc]; - t = vp9_get_token(v); + vp9_get_token_extra(v, &t, &e); if (use_fast_coef_costing) { - cost += (*token_costs)[!prev_t][!prev_t][t] + vp9_dct_value_cost_ptr[v]; + cost += (*token_costs)[!prev_t][!prev_t][t] + + vp9_get_cost(t, e, cat6_high_cost); } else { pt = get_coef_context(nb, token_cache, c); - cost += (*token_costs)[!prev_t][pt][t] + vp9_dct_value_cost_ptr[v]; + cost += (*token_costs)[!prev_t][pt][t] + + vp9_get_cost(t, e, cat6_high_cost); token_cache[rc] = vp9_pt_energy_class[t]; } prev_t = t; diff --git a/vp9/encoder/vp9_tokenize.c b/vp9/encoder/vp9_tokenize.c index 54b2594e7..4c8995356 100644 --- a/vp9/encoder/vp9_tokenize.c +++ b/vp9/encoder/vp9_tokenize.c @@ -23,19 +23,6 @@ #include "vp9/encoder/vp9_encoder.h" #include "vp9/encoder/vp9_tokenize.h" -static int16_t dct_value_cost[DCT_MAX_VALUE * 2]; -const int16_t *vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; - -#if CONFIG_VP9_HIGHBITDEPTH -static int16_t dct_value_cost_high10[DCT_MAX_VALUE_HIGH10 * 2]; -const int16_t *vp9_dct_value_cost_high10_ptr = - dct_value_cost_high10 + DCT_MAX_VALUE_HIGH10; - -static int16_t dct_value_cost_high12[DCT_MAX_VALUE_HIGH12 * 2]; -const int16_t *vp9_dct_value_cost_high12_ptr = - dct_value_cost_high12 + DCT_MAX_VALUE_HIGH12; -#endif - static const TOKENVALUE dct_cat_lt_10_value_tokens[] = { {9, 63}, {9, 61}, {9, 59}, {9, 57}, {9, 55}, {9, 53}, {9, 51}, {9, 49}, {9, 47}, {9, 45}, {9, 43}, {9, 41}, {9, 39}, {9, 37}, {9, 35}, {9, 33}, @@ -98,6 +85,298 @@ static const vp9_tree_index cat5[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0}; static const vp9_tree_index cat6[28] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 0, 0}; +static const int16_t zero_cost[] = {0}; +static const int16_t one_cost[] = {255, 257}; +static const int16_t two_cost[] = {255, 257}; +static const int16_t three_cost[] = {255, 257}; +static const int16_t four_cost[] = {255, 257}; +static const int16_t cat1_cost[] = {429, 431, 616, 618}; +static const int16_t cat2_cost[] = {624, 626, 727, 729, 848, 850, 951, 953}; +static const int16_t cat3_cost[] = { + 820, 822, 893, 895, 940, 942, 1013, 1015, 1096, 1098, 1169, 1171, 1216, 1218, + 1289, 1291 +}; +static const int16_t cat4_cost[] = { + 1032, 1034, 1075, 1077, 1105, 1107, 1148, 1150, 1194, 1196, 1237, 1239, + 1267, 1269, 1310, 1312, 1328, 1330, 1371, 1373, 1401, 1403, 1444, 1446, + 1490, 1492, 1533, 1535, 1563, 1565, 1606, 1608 +}; +static const int16_t cat5_cost[] = { + 1269, 1271, 1283, 1285, 1306, 1308, 1320, + 1322, 1347, 1349, 1361, 1363, 1384, 1386, 1398, 1400, 1443, 1445, 1457, + 1459, 1480, 1482, 1494, 1496, 1521, 1523, 1535, 1537, 1558, 1560, 1572, + 1574, 1592, 1594, 1606, 1608, 1629, 1631, 1643, 1645, 1670, 1672, 1684, + 1686, 1707, 1709, 1721, 1723, 1766, 1768, 1780, 1782, 1803, 1805, 1817, + 1819, 1844, 1846, 1858, 1860, 1881, 1883, 1895, 1897 +}; +const int16_t vp9_cat6_low_cost[256] = { + 1638, 1640, 1646, 1648, 1652, 1654, 1660, 1662, + 1670, 1672, 1678, 1680, 1684, 1686, 1692, 1694, 1711, 1713, 1719, 1721, + 1725, 1727, 1733, 1735, 1743, 1745, 1751, 1753, 1757, 1759, 1765, 1767, + 1787, 1789, 1795, 1797, 1801, 1803, 1809, 1811, 1819, 1821, 1827, 1829, + 1833, 1835, 1841, 1843, 1860, 1862, 1868, 1870, 1874, 1876, 1882, 1884, + 1892, 1894, 1900, 1902, 1906, 1908, 1914, 1916, 1940, 1942, 1948, 1950, + 1954, 1956, 1962, 1964, 1972, 1974, 1980, 1982, 1986, 1988, 1994, 1996, + 2013, 2015, 2021, 2023, 2027, 2029, 2035, 2037, 2045, 2047, 2053, 2055, + 2059, 2061, 2067, 2069, 2089, 2091, 2097, 2099, 2103, 2105, 2111, 2113, + 2121, 2123, 2129, 2131, 2135, 2137, 2143, 2145, 2162, 2164, 2170, 2172, + 2176, 2178, 2184, 2186, 2194, 2196, 2202, 2204, 2208, 2210, 2216, 2218, + 2082, 2084, 2090, 2092, 2096, 2098, 2104, 2106, 2114, 2116, 2122, 2124, + 2128, 2130, 2136, 2138, 2155, 2157, 2163, 2165, 2169, 2171, 2177, 2179, + 2187, 2189, 2195, 2197, 2201, 2203, 2209, 2211, 2231, 2233, 2239, 2241, + 2245, 2247, 2253, 2255, 2263, 2265, 2271, 2273, 2277, 2279, 2285, 2287, + 2304, 2306, 2312, 2314, 2318, 2320, 2326, 2328, 2336, 2338, 2344, 2346, + 2350, 2352, 2358, 2360, 2384, 2386, 2392, 2394, 2398, 2400, 2406, 2408, + 2416, 2418, 2424, 2426, 2430, 2432, 2438, 2440, 2457, 2459, 2465, 2467, + 2471, 2473, 2479, 2481, 2489, 2491, 2497, 2499, 2503, 2505, 2511, 2513, + 2533, 2535, 2541, 2543, 2547, 2549, 2555, 2557, 2565, 2567, 2573, 2575, + 2579, 2581, 2587, 2589, 2606, 2608, 2614, 2616, 2620, 2622, 2628, 2630, + 2638, 2640, 2646, 2648, 2652, 2654, 2660, 2662 +}; +const int16_t vp9_cat6_high_cost[128] = { + 72, 892, 1183, 2003, 1448, 2268, 2559, 3379, + 1709, 2529, 2820, 3640, 3085, 3905, 4196, 5016, 2118, 2938, 3229, 4049, + 3494, 4314, 4605, 5425, 3755, 4575, 4866, 5686, 5131, 5951, 6242, 7062, + 2118, 2938, 3229, 4049, 3494, 4314, 4605, 5425, 3755, 4575, 4866, 5686, + 5131, 5951, 6242, 7062, 4164, 4984, 5275, 6095, 5540, 6360, 6651, 7471, + 5801, 6621, 6912, 7732, 7177, 7997, 8288, 9108, 2118, 2938, 3229, 4049, + 3494, 4314, 4605, 5425, 3755, 4575, 4866, 5686, 5131, 5951, 6242, 7062, + 4164, 4984, 5275, 6095, 5540, 6360, 6651, 7471, 5801, 6621, 6912, 7732, + 7177, 7997, 8288, 9108, 4164, 4984, 5275, 6095, 5540, 6360, 6651, 7471, + 5801, 6621, 6912, 7732, 7177, 7997, 8288, 9108, 6210, 7030, 7321, 8141, + 7586, 8406, 8697, 9517, 7847, 8667, 8958, 9778, 9223, 10043, 10334, 11154 +}; + +#if CONFIG_VP9_HIGHBITDEPTH +const int16_t vp9_cat6_high10_high_cost[512] = { + 74, 894, 1185, 2005, 1450, 2270, 2561, + 3381, 1711, 2531, 2822, 3642, 3087, 3907, 4198, 5018, 2120, 2940, 3231, + 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, 5688, 5133, 5953, 6244, + 7064, 2120, 2940, 3231, 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, + 5688, 5133, 5953, 6244, 7064, 4166, 4986, 5277, 6097, 5542, 6362, 6653, + 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 2120, 2940, 3231, + 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, 5688, 5133, 5953, 6244, + 7064, 4166, 4986, 5277, 6097, 5542, 6362, 6653, 7473, 5803, 6623, 6914, + 7734, 7179, 7999, 8290, 9110, 4166, 4986, 5277, 6097, 5542, 6362, 6653, + 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 6212, 7032, 7323, + 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, 10045, 10336, + 11156, 2120, 2940, 3231, 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, + 5688, 5133, 5953, 6244, 7064, 4166, 4986, 5277, 6097, 5542, 6362, 6653, + 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 4166, 4986, 5277, + 6097, 5542, 6362, 6653, 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, + 9110, 6212, 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, + 9780, 9225, 10045, 10336, 11156, 4166, 4986, 5277, 6097, 5542, 6362, 6653, + 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 6212, 7032, 7323, + 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, 10045, 10336, + 11156, 6212, 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, + 9780, 9225, 10045, 10336, 11156, 8258, 9078, 9369, 10189, 9634, 10454, + 10745, 11565, 9895, 10715, 11006, 11826, 11271, 12091, 12382, 13202, 2120, + 2940, 3231, 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, 5688, 5133, + 5953, 6244, 7064, 4166, 4986, 5277, 6097, 5542, 6362, 6653, 7473, 5803, + 6623, 6914, 7734, 7179, 7999, 8290, 9110, 4166, 4986, 5277, 6097, 5542, + 6362, 6653, 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 6212, + 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, + 10045, 10336, 11156, 4166, 4986, 5277, 6097, 5542, 6362, 6653, 7473, 5803, + 6623, 6914, 7734, 7179, 7999, 8290, 9110, 6212, 7032, 7323, 8143, 7588, + 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, 10045, 10336, 11156, 6212, + 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, + 10045, 10336, 11156, 8258, 9078, 9369, 10189, 9634, 10454, 10745, 11565, + 9895, 10715, 11006, 11826, 11271, 12091, 12382, 13202, 4166, 4986, 5277, + 6097, 5542, 6362, 6653, 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, + 9110, 6212, 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, + 9780, 9225, 10045, 10336, 11156, 6212, 7032, 7323, 8143, 7588, 8408, 8699, + 9519, 7849, 8669, 8960, 9780, 9225, 10045, 10336, 11156, 8258, 9078, 9369, + 10189, 9634, 10454, 10745, 11565, 9895, 10715, 11006, 11826, 11271, 12091, + 12382, 13202, 6212, 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, + 8960, 9780, 9225, 10045, 10336, 11156, 8258, 9078, 9369, 10189, 9634, 10454, + 10745, 11565, 9895, 10715, 11006, 11826, 11271, 12091, 12382, 13202, 8258, + 9078, 9369, 10189, 9634, 10454, 10745, 11565, 9895, 10715, 11006, 11826, + 11271, 12091, 12382, 13202, 10304, 11124, 11415, 12235, 11680, 12500, 12791, + 13611, 11941, 12761, 13052, 13872, 13317, 14137, 14428, 15248, +}; +const int16_t vp9_cat6_high12_high_cost[2048] = { + 76, 896, 1187, 2007, 1452, 2272, 2563, + 3383, 1713, 2533, 2824, 3644, 3089, 3909, 4200, 5020, 2122, 2942, 3233, + 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, 5690, 5135, 5955, 6246, + 7066, 2122, 2942, 3233, 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, + 5690, 5135, 5955, 6246, 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, + 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 2122, 2942, 3233, + 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, 5690, 5135, 5955, 6246, + 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, + 7736, 7181, 8001, 8292, 9112, 4168, 4988, 5279, 6099, 5544, 6364, 6655, + 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, + 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, + 11158, 2122, 2942, 3233, 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, + 5690, 5135, 5955, 6246, 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, + 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 4168, 4988, 5279, + 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, + 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, + 9782, 9227, 10047, 10338, 11158, 4168, 4988, 5279, 6099, 5544, 6364, 6655, + 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, + 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, + 11158, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, + 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, + 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 2122, + 2942, 3233, 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, 5690, 5135, + 5955, 6246, 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, + 6625, 6916, 7736, 7181, 8001, 8292, 9112, 4168, 4988, 5279, 6099, 5544, + 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, + 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, + 10047, 10338, 11158, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, + 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, + 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 6214, + 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, + 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, + 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 4168, 4988, 5279, + 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, + 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, + 9782, 9227, 10047, 10338, 11158, 6214, 7034, 7325, 8145, 7590, 8410, 8701, + 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, + 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, + 12384, 13204, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, + 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, + 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 8260, + 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, + 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, + 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 2122, 2942, + 3233, 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, 5690, 5135, 5955, + 6246, 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, + 6916, 7736, 7181, 8001, 8292, 9112, 4168, 4988, 5279, 6099, 5544, 6364, + 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, + 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, + 10338, 11158, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, + 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, + 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 6214, 7034, + 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, + 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, + 10717, 11008, 11828, 11273, 12093, 12384, 13204, 4168, 4988, 5279, 6099, + 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, + 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, + 9227, 10047, 10338, 11158, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, + 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, + 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, + 13204, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, + 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, + 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 8260, + 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, + 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, + 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 4168, 4988, + 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, + 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, + 8962, 9782, 9227, 10047, 10338, 11158, 6214, 7034, 7325, 8145, 7590, 8410, + 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, + 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, + 12093, 12384, 13204, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, + 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, + 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, + 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, + 11828, 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, + 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 6214, + 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, + 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, + 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 8260, 9080, 9371, + 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, + 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, + 12763, 13054, 13874, 13319, 14139, 14430, 15250, 8260, 9080, 9371, 10191, + 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, + 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, + 13054, 13874, 13319, 14139, 14430, 15250, 10306, 11126, 11417, 12237, 11682, + 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, + 12352, 13172, 13463, 14283, 13728, 14548, 14839, 15659, 13989, 14809, 15100, + 15920, 15365, 16185, 16476, 17296, 2122, 2942, 3233, 4053, 3498, 4318, 4609, + 5429, 3759, 4579, 4870, 5690, 5135, 5955, 6246, 7066, 4168, 4988, 5279, + 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, + 9112, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, + 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, + 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 4168, 4988, 5279, + 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, + 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, + 9782, 9227, 10047, 10338, 11158, 6214, 7034, 7325, 8145, 7590, 8410, 8701, + 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, + 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, + 12384, 13204, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, + 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, + 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 6214, 7034, + 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, + 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, + 10717, 11008, 11828, 11273, 12093, 12384, 13204, 6214, 7034, 7325, 8145, + 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, + 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, + 11828, 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, 9636, 10456, + 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, + 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, + 13319, 14139, 14430, 15250, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, + 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, + 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, + 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, + 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, + 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 6214, 7034, + 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, + 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, + 10717, 11008, 11828, 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, + 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, + 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, + 13054, 13874, 13319, 14139, 14430, 15250, 6214, 7034, 7325, 8145, 7590, + 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, + 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, + 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, 9636, 10456, 10747, + 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, 11126, + 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, + 14139, 14430, 15250, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, + 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, 11126, 11417, + 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, + 14430, 15250, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, + 12763, 13054, 13874, 13319, 14139, 14430, 15250, 12352, 13172, 13463, 14283, + 13728, 14548, 14839, 15659, 13989, 14809, 15100, 15920, 15365, 16185, 16476, + 17296, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, + 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, + 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 6214, 7034, 7325, + 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, + 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, + 11008, 11828, 11273, 12093, 12384, 13204, 6214, 7034, 7325, 8145, 7590, + 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, + 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, + 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, 9636, 10456, 10747, + 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, 11126, + 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, + 14139, 14430, 15250, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, + 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, + 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, + 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, + 11828, 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, + 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 8260, + 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, + 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, + 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 10306, 11126, + 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, + 14139, 14430, 15250, 12352, 13172, 13463, 14283, 13728, 14548, 14839, 15659, + 13989, 14809, 15100, 15920, 15365, 16185, 16476, 17296, 6214, 7034, 7325, + 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, + 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, + 11008, 11828, 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, 9636, + 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, + 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, + 13874, 13319, 14139, 14430, 15250, 8260, 9080, 9371, 10191, 9636, 10456, + 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, + 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, + 13319, 14139, 14430, 15250, 10306, 11126, 11417, 12237, 11682, 12502, 12793, + 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 12352, 13172, + 13463, 14283, 13728, 14548, 14839, 15659, 13989, 14809, 15100, 15920, 15365, + 16185, 16476, 17296, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, + 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, 11126, 11417, + 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, + 14430, 15250, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, + 12763, 13054, 13874, 13319, 14139, 14430, 15250, 12352, 13172, 13463, 14283, + 13728, 14548, 14839, 15659, 13989, 14809, 15100, 15920, 15365, 16185, 16476, + 17296, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, + 13054, 13874, 13319, 14139, 14430, 15250, 12352, 13172, 13463, 14283, 13728, + 14548, 14839, 15659, 13989, 14809, 15100, 15920, 15365, 16185, 16476, 17296, + 12352, 13172, 13463, 14283, 13728, 14548, 14839, 15659, 13989, 14809, 15100, + 15920, 15365, 16185, 16476, 17296, 14398, 15218, 15509, 16329, 15774, 16594, + 16885, 17705, 16035, 16855, 17146, 17966, 17411, 18231, 18522, 19342 +}; +#endif + #if CONFIG_VP9_HIGHBITDEPTH static const vp9_tree_index cat1_high10[2] = {0, 0}; static const vp9_tree_index cat2_high10[4] = {2, 2, 0, 0}; @@ -117,61 +396,49 @@ static const vp9_tree_index cat6_high12[36] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 30, 30, 32, 32, 34, 34, 0, 0}; #endif -static void init_bit_tree(vp9_tree_index *p, int n) { - int i = 0; - - while (++i < n) { - p[0] = p[1] = i << 1; - p += 2; - } - - p[0] = p[1] = 0; -} - - const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = { - {0, 0, 0, 0}, // ZERO_TOKEN - {0, 0, 0, 1}, // ONE_TOKEN - {0, 0, 0, 2}, // TWO_TOKEN - {0, 0, 0, 3}, // THREE_TOKEN - {0, 0, 0, 4}, // FOUR_TOKEN - {cat1, vp9_cat1_prob, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN - {cat2, vp9_cat2_prob, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN - {cat3, vp9_cat3_prob, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN - {cat4, vp9_cat4_prob, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN - {cat5, vp9_cat5_prob, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN - {cat6, vp9_cat6_prob, 14, CAT6_MIN_VAL}, // CATEGORY6_TOKEN - {0, 0, 0, 0} // EOB_TOKEN + {0, 0, 0, 0, zero_cost}, // ZERO_TOKEN + {0, 0, 0, 1, one_cost}, // ONE_TOKEN + {0, 0, 0, 2, two_cost}, // TWO_TOKEN + {0, 0, 0, 3, three_cost}, // THREE_TOKEN + {0, 0, 0, 4, four_cost}, // FOUR_TOKEN + {cat1, vp9_cat1_prob, 1, CAT1_MIN_VAL, cat1_cost}, // CATEGORY1_TOKEN + {cat2, vp9_cat2_prob, 2, CAT2_MIN_VAL, cat2_cost}, // CATEGORY2_TOKEN + {cat3, vp9_cat3_prob, 3, CAT3_MIN_VAL, cat3_cost}, // CATEGORY3_TOKEN + {cat4, vp9_cat4_prob, 4, CAT4_MIN_VAL, cat4_cost}, // CATEGORY4_TOKEN + {cat5, vp9_cat5_prob, 5, CAT5_MIN_VAL, cat5_cost}, // CATEGORY5_TOKEN + {cat6, vp9_cat6_prob, 14, CAT6_MIN_VAL, 0}, // CATEGORY6_TOKEN + {0, 0, 0, 0, zero_cost} // EOB_TOKEN }; #if CONFIG_VP9_HIGHBITDEPTH const vp9_extra_bit vp9_extra_bits_high10[ENTROPY_TOKENS] = { - {0, 0, 0, 0}, // ZERO_TOKEN - {0, 0, 0, 1}, // ONE_TOKEN - {0, 0, 0, 2}, // TWO_TOKEN - {0, 0, 0, 3}, // THREE_TOKEN - {0, 0, 0, 4}, // FOUR_TOKEN - {cat1_high10, vp9_cat1_prob_high10, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN - {cat2_high10, vp9_cat2_prob_high10, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN - {cat3_high10, vp9_cat3_prob_high10, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN - {cat4_high10, vp9_cat4_prob_high10, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN - {cat5_high10, vp9_cat5_prob_high10, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN - {cat6_high10, vp9_cat6_prob_high10, 16, CAT6_MIN_VAL}, // CATEGORY6_TOKEN - {0, 0, 0, 0} // EOB_TOKEN + {0, 0, 0, 0, zero_cost}, // ZERO + {0, 0, 0, 1, one_cost}, // ONE + {0, 0, 0, 2, two_cost}, // TWO + {0, 0, 0, 3, three_cost}, // THREE + {0, 0, 0, 4, four_cost}, // FOUR + {cat1_high10, vp9_cat1_prob_high10, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1 + {cat2_high10, vp9_cat2_prob_high10, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2 + {cat3_high10, vp9_cat3_prob_high10, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3 + {cat4_high10, vp9_cat4_prob_high10, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4 + {cat5_high10, vp9_cat5_prob_high10, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5 + {cat6_high10, vp9_cat6_prob_high10, 16, CAT6_MIN_VAL, 0}, // CAT6 + {0, 0, 0, 0, zero_cost} // EOB }; const vp9_extra_bit vp9_extra_bits_high12[ENTROPY_TOKENS] = { - {0, 0, 0, 0}, // ZERO_TOKEN - {0, 0, 0, 1}, // ONE_TOKEN - {0, 0, 0, 2}, // TWO_TOKEN - {0, 0, 0, 3}, // THREE_TOKEN - {0, 0, 0, 4}, // FOUR_TOKEN - {cat1_high12, vp9_cat1_prob_high12, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN - {cat2_high12, vp9_cat2_prob_high12, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN - {cat3_high12, vp9_cat3_prob_high12, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN - {cat4_high12, vp9_cat4_prob_high12, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN - {cat5_high12, vp9_cat5_prob_high12, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN - {cat6_high12, vp9_cat6_prob_high12, 18, CAT6_MIN_VAL}, // CATEGORY6_TOKEN - {0, 0, 0, 0} // EOB_TOKEN + {0, 0, 0, 0, zero_cost}, // ZERO + {0, 0, 0, 1, one_cost}, // ONE + {0, 0, 0, 2, two_cost}, // TWO + {0, 0, 0, 3, three_cost}, // THREE + {0, 0, 0, 4, four_cost}, // FOUR + {cat1_high12, vp9_cat1_prob_high12, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1 + {cat2_high12, vp9_cat2_prob_high12, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2 + {cat3_high12, vp9_cat3_prob_high12, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3 + {cat4_high12, vp9_cat4_prob_high12, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4 + {cat5_high12, vp9_cat5_prob_high12, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5 + {cat6_high12, vp9_cat6_prob_high12, 18, CAT6_MIN_VAL, 0}, // CAT6 + {0, 0, 0, 0, zero_cost} // EOB }; #endif @@ -180,46 +447,6 @@ const struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS] = { {125, 7}, {126, 7}, {127, 7}, {0, 1} }; -static void tokenize_init_one(const vp9_extra_bit *const e, - int16_t *value_cost, int max_value) { - int i = -max_value; - - TOKENVALUE t; - do { - - vp9_get_token_extra(i, &t.token, &t.extra); - // initialize the cost for extra bits for all possible coefficient value. - { - int cost = 0; - const vp9_extra_bit *p = &e[t.token]; - - if (p->base_val) { - const int extra = t.extra; - const int length = p->len; - - if (length) - cost += treed_cost(p->tree, p->prob, extra >> 1, length); - - cost += vp9_cost_bit(vp9_prob_half, extra & 1); /* sign */ - value_cost[i] = cost; - } - } - } while (++i < max_value); -} - -void vp9_tokenize_initialize() { - tokenize_init_one(vp9_extra_bits, - dct_value_cost + DCT_MAX_VALUE, DCT_MAX_VALUE); -#if CONFIG_VP9_HIGHBITDEPTH - tokenize_init_one(vp9_extra_bits_high10, - dct_value_cost_high10 + DCT_MAX_VALUE_HIGH10, - DCT_MAX_VALUE_HIGH10); - - tokenize_init_one(vp9_extra_bits_high12, - dct_value_cost_high12 + DCT_MAX_VALUE_HIGH12, - DCT_MAX_VALUE_HIGH12); -#endif -} struct tokenize_b_args { VP9_COMP *cpi; diff --git a/vp9/encoder/vp9_tokenize.h b/vp9/encoder/vp9_tokenize.h index 49dc4a718..5154a59ea 100644 --- a/vp9/encoder/vp9_tokenize.h +++ b/vp9/encoder/vp9_tokenize.h @@ -20,8 +20,6 @@ extern "C" { #endif -void vp9_tokenize_initialize(); - #define EOSB_TOKEN 127 // Not signalled, encoder only #if CONFIG_VP9_HIGHBITDEPTH @@ -63,11 +61,29 @@ extern const int16_t *vp9_dct_value_cost_ptr; */ extern const TOKENVALUE *vp9_dct_value_tokens_ptr; extern const TOKENVALUE *vp9_dct_cat_lt_10_value_tokens; +extern const int16_t vp9_cat6_low_cost[256]; +extern const int16_t vp9_cat6_high_cost[128]; +extern const int16_t vp9_cat6_high10_high_cost[512]; +extern const int16_t vp9_cat6_high12_high_cost[2048]; +static INLINE int16_t vp9_get_cost(uint8_t token, EXTRABIT extrabits, + const int16_t *cat6_high_table) { + if (token != CATEGORY6_TOKEN) + return vp9_extra_bits[token].cost[extrabits]; + return vp9_cat6_low_cost[extrabits & 0xff] + + cat6_high_table[extrabits >> 8]; +} + #if CONFIG_VP9_HIGHBITDEPTH -extern const int16_t *vp9_dct_value_cost_high10_ptr; -extern const TOKENVALUE *vp9_dct_value_tokens_high10_ptr; -extern const int16_t *vp9_dct_value_cost_high12_ptr; -extern const TOKENVALUE *vp9_dct_value_tokens_high12_ptr; +static INLINE const int16_t* vp9_get_high_cost_table(int bit_depth) { + return bit_depth == 8 ? vp9_cat6_high_cost + : (bit_depth == 10 ? vp9_cat6_high10_high_cost : + vp9_cat6_high12_high_cost); +} +#else +static INLINE const int16_t* vp9_get_high_cost_table(int bit_depth) { + (void) bit_depth; + return vp9_cat6_high_cost; +} #endif // CONFIG_VP9_HIGHBITDEPTH static INLINE void vp9_get_token_extra(int v, int16_t *token, EXTRABIT *extra) { -- 2.40.0