OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <assert.h> | 11 #include <assert.h> |
12 #include <math.h> | 12 #include <math.h> |
13 #include <stdio.h> | 13 #include <stdio.h> |
14 #include <string.h> | 14 #include <string.h> |
15 | 15 |
16 #include "vpx_mem/vpx_mem.h" | 16 #include "vpx_mem/vpx_mem.h" |
17 | 17 |
18 #include "vp9/common/vp9_entropy.h" | 18 #include "vp9/common/vp9_entropy.h" |
19 #include "vp9/common/vp9_pred_common.h" | 19 #include "vp9/common/vp9_pred_common.h" |
20 #include "vp9/common/vp9_seg_common.h" | 20 #include "vp9/common/vp9_seg_common.h" |
21 | 21 |
22 #include "vp9/encoder/vp9_cost.h" | 22 #include "vp9/encoder/vp9_cost.h" |
23 #include "vp9/encoder/vp9_encoder.h" | 23 #include "vp9/encoder/vp9_encoder.h" |
24 #include "vp9/encoder/vp9_tokenize.h" | 24 #include "vp9/encoder/vp9_tokenize.h" |
25 | 25 |
26 static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2]; | 26 static const TOKENVALUE dct_cat_lt_10_value_tokens[] = { |
27 const TOKENVALUE *vp9_dct_value_tokens_ptr; | 27 {9, 63}, {9, 61}, {9, 59}, {9, 57}, {9, 55}, {9, 53}, {9, 51}, {9, 49}, |
28 static int16_t dct_value_cost[DCT_MAX_VALUE * 2]; | 28 {9, 47}, {9, 45}, {9, 43}, {9, 41}, {9, 39}, {9, 37}, {9, 35}, {9, 33}, |
29 const int16_t *vp9_dct_value_cost_ptr; | 29 {9, 31}, {9, 29}, {9, 27}, {9, 25}, {9, 23}, {9, 21}, {9, 19}, {9, 17}, |
30 | 30 {9, 15}, {9, 13}, {9, 11}, {9, 9}, {9, 7}, {9, 5}, {9, 3}, {9, 1}, |
31 #if CONFIG_VP9_HIGHBITDEPTH | 31 {8, 31}, {8, 29}, {8, 27}, {8, 25}, {8, 23}, {8, 21}, |
32 static TOKENVALUE dct_value_tokens_high10[DCT_MAX_VALUE_HIGH10 * 2]; | 32 {8, 19}, {8, 17}, {8, 15}, {8, 13}, {8, 11}, {8, 9}, |
33 const TOKENVALUE *vp9_dct_value_tokens_high10_ptr; | 33 {8, 7}, {8, 5}, {8, 3}, {8, 1}, |
34 static int16_t dct_value_cost_high10[DCT_MAX_VALUE_HIGH10 * 2]; | 34 {7, 15}, {7, 13}, {7, 11}, {7, 9}, {7, 7}, {7, 5}, {7, 3}, {7, 1}, |
35 const int16_t *vp9_dct_value_cost_high10_ptr; | 35 {6, 7}, {6, 5}, {6, 3}, {6, 1}, {5, 3}, {5, 1}, |
36 | 36 {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 0}, |
37 static TOKENVALUE dct_value_tokens_high12[DCT_MAX_VALUE_HIGH12 * 2]; | 37 {1, 0}, {2, 0}, {3, 0}, {4, 0}, |
38 const TOKENVALUE *vp9_dct_value_tokens_high12_ptr; | 38 {5, 0}, {5, 2}, {6, 0}, {6, 2}, {6, 4}, {6, 6}, |
39 static int16_t dct_value_cost_high12[DCT_MAX_VALUE_HIGH12 * 2]; | 39 {7, 0}, {7, 2}, {7, 4}, {7, 6}, {7, 8}, {7, 10}, {7, 12}, {7, 14}, |
40 const int16_t *vp9_dct_value_cost_high12_ptr; | 40 {8, 0}, {8, 2}, {8, 4}, {8, 6}, {8, 8}, {8, 10}, {8, 12}, |
41 #endif | 41 {8, 14}, {8, 16}, {8, 18}, {8, 20}, {8, 22}, {8, 24}, |
| 42 {8, 26}, {8, 28}, {8, 30}, {9, 0}, {9, 2}, |
| 43 {9, 4}, {9, 6}, {9, 8}, {9, 10}, {9, 12}, {9, 14}, {9, 16}, |
| 44 {9, 18}, {9, 20}, {9, 22}, {9, 24}, {9, 26}, {9, 28}, |
| 45 {9, 30}, {9, 32}, {9, 34}, {9, 36}, {9, 38}, {9, 40}, |
| 46 {9, 42}, {9, 44}, {9, 46}, {9, 48}, {9, 50}, {9, 52}, |
| 47 {9, 54}, {9, 56}, {9, 58}, {9, 60}, {9, 62} |
| 48 }; |
| 49 const TOKENVALUE *vp9_dct_cat_lt_10_value_tokens = dct_cat_lt_10_value_tokens + |
| 50 (sizeof(dct_cat_lt_10_value_tokens) / sizeof(*dct_cat_lt_10_value_tokens)) |
| 51 / 2; |
42 | 52 |
43 // Array indices are identical to previously-existing CONTEXT_NODE indices | 53 // Array indices are identical to previously-existing CONTEXT_NODE indices |
44 const vp9_tree_index vp9_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = { | 54 const vp9_tree_index vp9_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = { |
45 -EOB_TOKEN, 2, // 0 = EOB | 55 -EOB_TOKEN, 2, // 0 = EOB |
46 -ZERO_TOKEN, 4, // 1 = ZERO | 56 -ZERO_TOKEN, 4, // 1 = ZERO |
47 -ONE_TOKEN, 6, // 2 = ONE | 57 -ONE_TOKEN, 6, // 2 = ONE |
48 8, 12, // 3 = LOW_VAL | 58 8, 12, // 3 = LOW_VAL |
49 -TWO_TOKEN, 10, // 4 = TWO | 59 -TWO_TOKEN, 10, // 4 = TWO |
50 -THREE_TOKEN, -FOUR_TOKEN, // 5 = THREE | 60 -THREE_TOKEN, -FOUR_TOKEN, // 5 = THREE |
51 14, 16, // 6 = HIGH_LOW | 61 14, 16, // 6 = HIGH_LOW |
52 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 7 = CAT_ONE | 62 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 7 = CAT_ONE |
53 18, 20, // 8 = CAT_THREEFOUR | 63 18, 20, // 8 = CAT_THREEFOUR |
54 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 9 = CAT_THREE | 64 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 9 = CAT_THREE |
55 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 10 = CAT_FIVE | 65 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 10 = CAT_FIVE |
56 }; | 66 }; |
57 | 67 |
58 // Unconstrained Node Tree | 68 // Unconstrained Node Tree |
59 const vp9_tree_index vp9_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)] = { | 69 const vp9_tree_index vp9_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)] = { |
60 2, 6, // 0 = LOW_VAL | 70 2, 6, // 0 = LOW_VAL |
61 -TWO_TOKEN, 4, // 1 = TWO | 71 -TWO_TOKEN, 4, // 1 = TWO |
62 -THREE_TOKEN, -FOUR_TOKEN, // 2 = THREE | 72 -THREE_TOKEN, -FOUR_TOKEN, // 2 = THREE |
63 8, 10, // 3 = HIGH_LOW | 73 8, 10, // 3 = HIGH_LOW |
64 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 4 = CAT_ONE | 74 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 4 = CAT_ONE |
65 12, 14, // 5 = CAT_THREEFOUR | 75 12, 14, // 5 = CAT_THREEFOUR |
66 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 6 = CAT_THREE | 76 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 6 = CAT_THREE |
67 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 7 = CAT_FIVE | 77 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 7 = CAT_FIVE |
68 }; | 78 }; |
69 | 79 |
70 static vp9_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[28]; | 80 static const vp9_tree_index cat1[2] = {0, 0}; |
| 81 static const vp9_tree_index cat2[4] = {2, 2, 0, 0}; |
| 82 static const vp9_tree_index cat3[6] = {2, 2, 4, 4, 0, 0}; |
| 83 static const vp9_tree_index cat4[8] = {2, 2, 4, 4, 6, 6, 0, 0}; |
| 84 static const vp9_tree_index cat5[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0}; |
| 85 static const vp9_tree_index cat6[28] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, |
| 86 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 0, 0}; |
| 87 |
| 88 static const int16_t zero_cost[] = {0}; |
| 89 static const int16_t one_cost[] = {255, 257}; |
| 90 static const int16_t two_cost[] = {255, 257}; |
| 91 static const int16_t three_cost[] = {255, 257}; |
| 92 static const int16_t four_cost[] = {255, 257}; |
| 93 static const int16_t cat1_cost[] = {429, 431, 616, 618}; |
| 94 static const int16_t cat2_cost[] = {624, 626, 727, 729, 848, 850, 951, 953}; |
| 95 static const int16_t cat3_cost[] = { |
| 96 820, 822, 893, 895, 940, 942, 1013, 1015, 1096, 1098, 1169, 1171, 1216, 1218, |
| 97 1289, 1291 |
| 98 }; |
| 99 static const int16_t cat4_cost[] = { |
| 100 1032, 1034, 1075, 1077, 1105, 1107, 1148, 1150, 1194, 1196, 1237, 1239, |
| 101 1267, 1269, 1310, 1312, 1328, 1330, 1371, 1373, 1401, 1403, 1444, 1446, |
| 102 1490, 1492, 1533, 1535, 1563, 1565, 1606, 1608 |
| 103 }; |
| 104 static const int16_t cat5_cost[] = { |
| 105 1269, 1271, 1283, 1285, 1306, 1308, 1320, |
| 106 1322, 1347, 1349, 1361, 1363, 1384, 1386, 1398, 1400, 1443, 1445, 1457, |
| 107 1459, 1480, 1482, 1494, 1496, 1521, 1523, 1535, 1537, 1558, 1560, 1572, |
| 108 1574, 1592, 1594, 1606, 1608, 1629, 1631, 1643, 1645, 1670, 1672, 1684, |
| 109 1686, 1707, 1709, 1721, 1723, 1766, 1768, 1780, 1782, 1803, 1805, 1817, |
| 110 1819, 1844, 1846, 1858, 1860, 1881, 1883, 1895, 1897 |
| 111 }; |
| 112 const int16_t vp9_cat6_low_cost[256] = { |
| 113 1638, 1640, 1646, 1648, 1652, 1654, 1660, 1662, |
| 114 1670, 1672, 1678, 1680, 1684, 1686, 1692, 1694, 1711, 1713, 1719, 1721, |
| 115 1725, 1727, 1733, 1735, 1743, 1745, 1751, 1753, 1757, 1759, 1765, 1767, |
| 116 1787, 1789, 1795, 1797, 1801, 1803, 1809, 1811, 1819, 1821, 1827, 1829, |
| 117 1833, 1835, 1841, 1843, 1860, 1862, 1868, 1870, 1874, 1876, 1882, 1884, |
| 118 1892, 1894, 1900, 1902, 1906, 1908, 1914, 1916, 1940, 1942, 1948, 1950, |
| 119 1954, 1956, 1962, 1964, 1972, 1974, 1980, 1982, 1986, 1988, 1994, 1996, |
| 120 2013, 2015, 2021, 2023, 2027, 2029, 2035, 2037, 2045, 2047, 2053, 2055, |
| 121 2059, 2061, 2067, 2069, 2089, 2091, 2097, 2099, 2103, 2105, 2111, 2113, |
| 122 2121, 2123, 2129, 2131, 2135, 2137, 2143, 2145, 2162, 2164, 2170, 2172, |
| 123 2176, 2178, 2184, 2186, 2194, 2196, 2202, 2204, 2208, 2210, 2216, 2218, |
| 124 2082, 2084, 2090, 2092, 2096, 2098, 2104, 2106, 2114, 2116, 2122, 2124, |
| 125 2128, 2130, 2136, 2138, 2155, 2157, 2163, 2165, 2169, 2171, 2177, 2179, |
| 126 2187, 2189, 2195, 2197, 2201, 2203, 2209, 2211, 2231, 2233, 2239, 2241, |
| 127 2245, 2247, 2253, 2255, 2263, 2265, 2271, 2273, 2277, 2279, 2285, 2287, |
| 128 2304, 2306, 2312, 2314, 2318, 2320, 2326, 2328, 2336, 2338, 2344, 2346, |
| 129 2350, 2352, 2358, 2360, 2384, 2386, 2392, 2394, 2398, 2400, 2406, 2408, |
| 130 2416, 2418, 2424, 2426, 2430, 2432, 2438, 2440, 2457, 2459, 2465, 2467, |
| 131 2471, 2473, 2479, 2481, 2489, 2491, 2497, 2499, 2503, 2505, 2511, 2513, |
| 132 2533, 2535, 2541, 2543, 2547, 2549, 2555, 2557, 2565, 2567, 2573, 2575, |
| 133 2579, 2581, 2587, 2589, 2606, 2608, 2614, 2616, 2620, 2622, 2628, 2630, |
| 134 2638, 2640, 2646, 2648, 2652, 2654, 2660, 2662 |
| 135 }; |
| 136 const int16_t vp9_cat6_high_cost[128] = { |
| 137 72, 892, 1183, 2003, 1448, 2268, 2559, 3379, |
| 138 1709, 2529, 2820, 3640, 3085, 3905, 4196, 5016, 2118, 2938, 3229, 4049, |
| 139 3494, 4314, 4605, 5425, 3755, 4575, 4866, 5686, 5131, 5951, 6242, 7062, |
| 140 2118, 2938, 3229, 4049, 3494, 4314, 4605, 5425, 3755, 4575, 4866, 5686, |
| 141 5131, 5951, 6242, 7062, 4164, 4984, 5275, 6095, 5540, 6360, 6651, 7471, |
| 142 5801, 6621, 6912, 7732, 7177, 7997, 8288, 9108, 2118, 2938, 3229, 4049, |
| 143 3494, 4314, 4605, 5425, 3755, 4575, 4866, 5686, 5131, 5951, 6242, 7062, |
| 144 4164, 4984, 5275, 6095, 5540, 6360, 6651, 7471, 5801, 6621, 6912, 7732, |
| 145 7177, 7997, 8288, 9108, 4164, 4984, 5275, 6095, 5540, 6360, 6651, 7471, |
| 146 5801, 6621, 6912, 7732, 7177, 7997, 8288, 9108, 6210, 7030, 7321, 8141, |
| 147 7586, 8406, 8697, 9517, 7847, 8667, 8958, 9778, 9223, 10043, 10334, 11154 |
| 148 }; |
71 | 149 |
72 #if CONFIG_VP9_HIGHBITDEPTH | 150 #if CONFIG_VP9_HIGHBITDEPTH |
73 static vp9_tree_index cat1_high10[2]; | 151 const int16_t vp9_cat6_high10_high_cost[512] = { |
74 static vp9_tree_index cat2_high10[4]; | 152 74, 894, 1185, 2005, 1450, 2270, 2561, |
75 static vp9_tree_index cat3_high10[6]; | 153 3381, 1711, 2531, 2822, 3642, 3087, 3907, 4198, 5018, 2120, 2940, 3231, |
76 static vp9_tree_index cat4_high10[8]; | 154 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, 5688, 5133, 5953, 6244, |
77 static vp9_tree_index cat5_high10[10]; | 155 7064, 2120, 2940, 3231, 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, |
78 static vp9_tree_index cat6_high10[32]; | 156 5688, 5133, 5953, 6244, 7064, 4166, 4986, 5277, 6097, 5542, 6362, 6653, |
79 static vp9_tree_index cat1_high12[2]; | 157 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 2120, 2940, 3231, |
80 static vp9_tree_index cat2_high12[4]; | 158 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, 5688, 5133, 5953, 6244, |
81 static vp9_tree_index cat3_high12[6]; | 159 7064, 4166, 4986, 5277, 6097, 5542, 6362, 6653, 7473, 5803, 6623, 6914, |
82 static vp9_tree_index cat4_high12[8]; | 160 7734, 7179, 7999, 8290, 9110, 4166, 4986, 5277, 6097, 5542, 6362, 6653, |
83 static vp9_tree_index cat5_high12[10]; | 161 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 6212, 7032, 7323, |
84 static vp9_tree_index cat6_high12[36]; | 162 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, 10045, 10336, |
| 163 11156, 2120, 2940, 3231, 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, |
| 164 5688, 5133, 5953, 6244, 7064, 4166, 4986, 5277, 6097, 5542, 6362, 6653, |
| 165 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 4166, 4986, 5277, |
| 166 6097, 5542, 6362, 6653, 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, |
| 167 9110, 6212, 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, |
| 168 9780, 9225, 10045, 10336, 11156, 4166, 4986, 5277, 6097, 5542, 6362, 6653, |
| 169 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 6212, 7032, 7323, |
| 170 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, 10045, 10336, |
| 171 11156, 6212, 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, |
| 172 9780, 9225, 10045, 10336, 11156, 8258, 9078, 9369, 10189, 9634, 10454, |
| 173 10745, 11565, 9895, 10715, 11006, 11826, 11271, 12091, 12382, 13202, 2120, |
| 174 2940, 3231, 4051, 3496, 4316, 4607, 5427, 3757, 4577, 4868, 5688, 5133, |
| 175 5953, 6244, 7064, 4166, 4986, 5277, 6097, 5542, 6362, 6653, 7473, 5803, |
| 176 6623, 6914, 7734, 7179, 7999, 8290, 9110, 4166, 4986, 5277, 6097, 5542, |
| 177 6362, 6653, 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, 9110, 6212, |
| 178 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, |
| 179 10045, 10336, 11156, 4166, 4986, 5277, 6097, 5542, 6362, 6653, 7473, 5803, |
| 180 6623, 6914, 7734, 7179, 7999, 8290, 9110, 6212, 7032, 7323, 8143, 7588, |
| 181 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, 10045, 10336, 11156, 6212, |
| 182 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, 9780, 9225, |
| 183 10045, 10336, 11156, 8258, 9078, 9369, 10189, 9634, 10454, 10745, 11565, |
| 184 9895, 10715, 11006, 11826, 11271, 12091, 12382, 13202, 4166, 4986, 5277, |
| 185 6097, 5542, 6362, 6653, 7473, 5803, 6623, 6914, 7734, 7179, 7999, 8290, |
| 186 9110, 6212, 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, 8960, |
| 187 9780, 9225, 10045, 10336, 11156, 6212, 7032, 7323, 8143, 7588, 8408, 8699, |
| 188 9519, 7849, 8669, 8960, 9780, 9225, 10045, 10336, 11156, 8258, 9078, 9369, |
| 189 10189, 9634, 10454, 10745, 11565, 9895, 10715, 11006, 11826, 11271, 12091, |
| 190 12382, 13202, 6212, 7032, 7323, 8143, 7588, 8408, 8699, 9519, 7849, 8669, |
| 191 8960, 9780, 9225, 10045, 10336, 11156, 8258, 9078, 9369, 10189, 9634, 10454, |
| 192 10745, 11565, 9895, 10715, 11006, 11826, 11271, 12091, 12382, 13202, 8258, |
| 193 9078, 9369, 10189, 9634, 10454, 10745, 11565, 9895, 10715, 11006, 11826, |
| 194 11271, 12091, 12382, 13202, 10304, 11124, 11415, 12235, 11680, 12500, 12791, |
| 195 13611, 11941, 12761, 13052, 13872, 13317, 14137, 14428, 15248, |
| 196 }; |
| 197 const int16_t vp9_cat6_high12_high_cost[2048] = { |
| 198 76, 896, 1187, 2007, 1452, 2272, 2563, |
| 199 3383, 1713, 2533, 2824, 3644, 3089, 3909, 4200, 5020, 2122, 2942, 3233, |
| 200 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, 5690, 5135, 5955, 6246, |
| 201 7066, 2122, 2942, 3233, 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, |
| 202 5690, 5135, 5955, 6246, 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, |
| 203 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 2122, 2942, 3233, |
| 204 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, 5690, 5135, 5955, 6246, |
| 205 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, |
| 206 7736, 7181, 8001, 8292, 9112, 4168, 4988, 5279, 6099, 5544, 6364, 6655, |
| 207 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, |
| 208 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, |
| 209 11158, 2122, 2942, 3233, 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, |
| 210 5690, 5135, 5955, 6246, 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, |
| 211 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 4168, 4988, 5279, |
| 212 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, |
| 213 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, |
| 214 9782, 9227, 10047, 10338, 11158, 4168, 4988, 5279, 6099, 5544, 6364, 6655, |
| 215 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, |
| 216 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, |
| 217 11158, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, |
| 218 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, |
| 219 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 2122, |
| 220 2942, 3233, 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, 5690, 5135, |
| 221 5955, 6246, 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, |
| 222 6625, 6916, 7736, 7181, 8001, 8292, 9112, 4168, 4988, 5279, 6099, 5544, |
| 223 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, |
| 224 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, |
| 225 10047, 10338, 11158, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, |
| 226 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, |
| 227 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 6214, |
| 228 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, |
| 229 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, |
| 230 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 4168, 4988, 5279, |
| 231 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, |
| 232 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, |
| 233 9782, 9227, 10047, 10338, 11158, 6214, 7034, 7325, 8145, 7590, 8410, 8701, |
| 234 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, |
| 235 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, |
| 236 12384, 13204, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, |
| 237 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, |
| 238 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 8260, |
| 239 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, |
| 240 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, |
| 241 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 2122, 2942, |
| 242 3233, 4053, 3498, 4318, 4609, 5429, 3759, 4579, 4870, 5690, 5135, 5955, |
| 243 6246, 7066, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, |
| 244 6916, 7736, 7181, 8001, 8292, 9112, 4168, 4988, 5279, 6099, 5544, 6364, |
| 245 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, |
| 246 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, |
| 247 10338, 11158, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, |
| 248 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, |
| 249 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 6214, 7034, |
| 250 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, |
| 251 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, |
| 252 10717, 11008, 11828, 11273, 12093, 12384, 13204, 4168, 4988, 5279, 6099, |
| 253 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, |
| 254 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, |
| 255 9227, 10047, 10338, 11158, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, |
| 256 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, |
| 257 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, |
| 258 13204, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, |
| 259 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, |
| 260 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 8260, |
| 261 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, |
| 262 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, |
| 263 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 4168, 4988, |
| 264 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, |
| 265 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, |
| 266 8962, 9782, 9227, 10047, 10338, 11158, 6214, 7034, 7325, 8145, 7590, 8410, |
| 267 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, |
| 268 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, |
| 269 12093, 12384, 13204, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, |
| 270 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, |
| 271 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, |
| 272 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, |
| 273 11828, 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, |
| 274 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 6214, |
| 275 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, |
| 276 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, |
| 277 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 8260, 9080, 9371, |
| 278 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, |
| 279 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, |
| 280 12763, 13054, 13874, 13319, 14139, 14430, 15250, 8260, 9080, 9371, 10191, |
| 281 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, |
| 282 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, |
| 283 13054, 13874, 13319, 14139, 14430, 15250, 10306, 11126, 11417, 12237, 11682, |
| 284 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, |
| 285 12352, 13172, 13463, 14283, 13728, 14548, 14839, 15659, 13989, 14809, 15100, |
| 286 15920, 15365, 16185, 16476, 17296, 2122, 2942, 3233, 4053, 3498, 4318, 4609, |
| 287 5429, 3759, 4579, 4870, 5690, 5135, 5955, 6246, 7066, 4168, 4988, 5279, |
| 288 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, |
| 289 9112, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, |
| 290 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, |
| 291 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 4168, 4988, 5279, |
| 292 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, 7736, 7181, 8001, 8292, |
| 293 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, |
| 294 9782, 9227, 10047, 10338, 11158, 6214, 7034, 7325, 8145, 7590, 8410, 8701, |
| 295 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, |
| 296 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, |
| 297 12384, 13204, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, |
| 298 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, |
| 299 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 6214, 7034, |
| 300 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, |
| 301 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, |
| 302 10717, 11008, 11828, 11273, 12093, 12384, 13204, 6214, 7034, 7325, 8145, |
| 303 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, |
| 304 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, |
| 305 11828, 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, 9636, 10456, |
| 306 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, |
| 307 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, |
| 308 13319, 14139, 14430, 15250, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, |
| 309 5805, 6625, 6916, 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, |
| 310 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, |
| 311 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, |
| 312 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, |
| 313 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 6214, 7034, |
| 314 7325, 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, |
| 315 10338, 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, |
| 316 10717, 11008, 11828, 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, |
| 317 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, |
| 318 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, |
| 319 13054, 13874, 13319, 14139, 14430, 15250, 6214, 7034, 7325, 8145, 7590, |
| 320 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, |
| 321 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, |
| 322 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, 9636, 10456, 10747, |
| 323 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, 11126, |
| 324 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, |
| 325 14139, 14430, 15250, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, |
| 326 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, 11126, 11417, |
| 327 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, |
| 328 14430, 15250, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, |
| 329 12763, 13054, 13874, 13319, 14139, 14430, 15250, 12352, 13172, 13463, 14283, |
| 330 13728, 14548, 14839, 15659, 13989, 14809, 15100, 15920, 15365, 16185, 16476, |
| 331 17296, 4168, 4988, 5279, 6099, 5544, 6364, 6655, 7475, 5805, 6625, 6916, |
| 332 7736, 7181, 8001, 8292, 9112, 6214, 7034, 7325, 8145, 7590, 8410, 8701, |
| 333 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 6214, 7034, 7325, |
| 334 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, |
| 335 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, |
| 336 11008, 11828, 11273, 12093, 12384, 13204, 6214, 7034, 7325, 8145, 7590, |
| 337 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, |
| 338 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, |
| 339 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, 9636, 10456, 10747, |
| 340 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, 11126, |
| 341 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, |
| 342 14139, 14430, 15250, 6214, 7034, 7325, 8145, 7590, 8410, 8701, 9521, 7851, |
| 343 8671, 8962, 9782, 9227, 10047, 10338, 11158, 8260, 9080, 9371, 10191, 9636, |
| 344 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, |
| 345 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, |
| 346 11828, 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, |
| 347 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 8260, |
| 348 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, 11008, 11828, |
| 349 11273, 12093, 12384, 13204, 10306, 11126, 11417, 12237, 11682, 12502, 12793, |
| 350 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 10306, 11126, |
| 351 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, |
| 352 14139, 14430, 15250, 12352, 13172, 13463, 14283, 13728, 14548, 14839, 15659, |
| 353 13989, 14809, 15100, 15920, 15365, 16185, 16476, 17296, 6214, 7034, 7325, |
| 354 8145, 7590, 8410, 8701, 9521, 7851, 8671, 8962, 9782, 9227, 10047, 10338, |
| 355 11158, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, 9897, 10717, |
| 356 11008, 11828, 11273, 12093, 12384, 13204, 8260, 9080, 9371, 10191, 9636, |
| 357 10456, 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, |
| 358 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, |
| 359 13874, 13319, 14139, 14430, 15250, 8260, 9080, 9371, 10191, 9636, 10456, |
| 360 10747, 11567, 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, |
| 361 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, |
| 362 13319, 14139, 14430, 15250, 10306, 11126, 11417, 12237, 11682, 12502, 12793, |
| 363 13613, 11943, 12763, 13054, 13874, 13319, 14139, 14430, 15250, 12352, 13172, |
| 364 13463, 14283, 13728, 14548, 14839, 15659, 13989, 14809, 15100, 15920, 15365, |
| 365 16185, 16476, 17296, 8260, 9080, 9371, 10191, 9636, 10456, 10747, 11567, |
| 366 9897, 10717, 11008, 11828, 11273, 12093, 12384, 13204, 10306, 11126, 11417, |
| 367 12237, 11682, 12502, 12793, 13613, 11943, 12763, 13054, 13874, 13319, 14139, |
| 368 14430, 15250, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, |
| 369 12763, 13054, 13874, 13319, 14139, 14430, 15250, 12352, 13172, 13463, 14283, |
| 370 13728, 14548, 14839, 15659, 13989, 14809, 15100, 15920, 15365, 16185, 16476, |
| 371 17296, 10306, 11126, 11417, 12237, 11682, 12502, 12793, 13613, 11943, 12763, |
| 372 13054, 13874, 13319, 14139, 14430, 15250, 12352, 13172, 13463, 14283, 13728, |
| 373 14548, 14839, 15659, 13989, 14809, 15100, 15920, 15365, 16185, 16476, 17296, |
| 374 12352, 13172, 13463, 14283, 13728, 14548, 14839, 15659, 13989, 14809, 15100, |
| 375 15920, 15365, 16185, 16476, 17296, 14398, 15218, 15509, 16329, 15774, 16594, |
| 376 16885, 17705, 16035, 16855, 17146, 17966, 17411, 18231, 18522, 19342 |
| 377 }; |
85 #endif | 378 #endif |
86 | 379 |
87 static void init_bit_tree(vp9_tree_index *p, int n) { | |
88 int i = 0; | |
89 | |
90 while (++i < n) { | |
91 p[0] = p[1] = i << 1; | |
92 p += 2; | |
93 } | |
94 | |
95 p[0] = p[1] = 0; | |
96 } | |
97 | |
98 static void init_bit_trees() { | |
99 init_bit_tree(cat1, 1); | |
100 init_bit_tree(cat2, 2); | |
101 init_bit_tree(cat3, 3); | |
102 init_bit_tree(cat4, 4); | |
103 init_bit_tree(cat5, 5); | |
104 init_bit_tree(cat6, 14); | |
105 #if CONFIG_VP9_HIGHBITDEPTH | 380 #if CONFIG_VP9_HIGHBITDEPTH |
106 init_bit_tree(cat1_high10, 1); | 381 static const vp9_tree_index cat1_high10[2] = {0, 0}; |
107 init_bit_tree(cat2_high10, 2); | 382 static const vp9_tree_index cat2_high10[4] = {2, 2, 0, 0}; |
108 init_bit_tree(cat3_high10, 3); | 383 static const vp9_tree_index cat3_high10[6] = {2, 2, 4, 4, 0, 0}; |
109 init_bit_tree(cat4_high10, 4); | 384 static const vp9_tree_index cat4_high10[8] = {2, 2, 4, 4, 6, 6, 0, 0}; |
110 init_bit_tree(cat5_high10, 5); | 385 static const vp9_tree_index cat5_high10[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0}; |
111 init_bit_tree(cat6_high10, 16); | 386 static const vp9_tree_index cat6_high10[32] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, |
112 init_bit_tree(cat1_high12, 1); | 387 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, |
113 init_bit_tree(cat2_high12, 2); | 388 30, 30, 0, 0}; |
114 init_bit_tree(cat3_high12, 3); | 389 static const vp9_tree_index cat1_high12[2] = {0, 0}; |
115 init_bit_tree(cat4_high12, 4); | 390 static const vp9_tree_index cat2_high12[4] = {2, 2, 0, 0}; |
116 init_bit_tree(cat5_high12, 5); | 391 static const vp9_tree_index cat3_high12[6] = {2, 2, 4, 4, 0, 0}; |
117 init_bit_tree(cat6_high12, 18); | 392 static const vp9_tree_index cat4_high12[8] = {2, 2, 4, 4, 6, 6, 0, 0}; |
| 393 static const vp9_tree_index cat5_high12[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0}; |
| 394 static const vp9_tree_index cat6_high12[36] = {2, 2, 4, 4, 6, 6, 8, 8, 10, 10, |
| 395 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, |
| 396 30, 30, 32, 32, 34, 34, 0, 0}; |
118 #endif | 397 #endif |
119 } | |
120 | 398 |
121 const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = { | 399 const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = { |
122 {0, 0, 0, 0}, // ZERO_TOKEN | 400 {0, 0, 0, 0, zero_cost}, // ZERO_TOKEN |
123 {0, 0, 0, 1}, // ONE_TOKEN | 401 {0, 0, 0, 1, one_cost}, // ONE_TOKEN |
124 {0, 0, 0, 2}, // TWO_TOKEN | 402 {0, 0, 0, 2, two_cost}, // TWO_TOKEN |
125 {0, 0, 0, 3}, // THREE_TOKEN | 403 {0, 0, 0, 3, three_cost}, // THREE_TOKEN |
126 {0, 0, 0, 4}, // FOUR_TOKEN | 404 {0, 0, 0, 4, four_cost}, // FOUR_TOKEN |
127 {cat1, vp9_cat1_prob, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN | 405 {cat1, vp9_cat1_prob, 1, CAT1_MIN_VAL, cat1_cost}, // CATEGORY1_TOKEN |
128 {cat2, vp9_cat2_prob, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN | 406 {cat2, vp9_cat2_prob, 2, CAT2_MIN_VAL, cat2_cost}, // CATEGORY2_TOKEN |
129 {cat3, vp9_cat3_prob, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN | 407 {cat3, vp9_cat3_prob, 3, CAT3_MIN_VAL, cat3_cost}, // CATEGORY3_TOKEN |
130 {cat4, vp9_cat4_prob, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN | 408 {cat4, vp9_cat4_prob, 4, CAT4_MIN_VAL, cat4_cost}, // CATEGORY4_TOKEN |
131 {cat5, vp9_cat5_prob, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN | 409 {cat5, vp9_cat5_prob, 5, CAT5_MIN_VAL, cat5_cost}, // CATEGORY5_TOKEN |
132 {cat6, vp9_cat6_prob, 14, CAT6_MIN_VAL}, // CATEGORY6_TOKEN | 410 {cat6, vp9_cat6_prob, 14, CAT6_MIN_VAL, 0}, // CATEGORY6_TOKEN |
133 {0, 0, 0, 0} // EOB_TOKEN | 411 {0, 0, 0, 0, zero_cost} // EOB_TOKEN |
134 }; | 412 }; |
135 | 413 |
136 #if CONFIG_VP9_HIGHBITDEPTH | 414 #if CONFIG_VP9_HIGHBITDEPTH |
137 const vp9_extra_bit vp9_extra_bits_high10[ENTROPY_TOKENS] = { | 415 const vp9_extra_bit vp9_extra_bits_high10[ENTROPY_TOKENS] = { |
138 {0, 0, 0, 0}, // ZERO_TOKEN | 416 {0, 0, 0, 0, zero_cost}, // ZERO |
139 {0, 0, 0, 1}, // ONE_TOKEN | 417 {0, 0, 0, 1, one_cost}, // ONE |
140 {0, 0, 0, 2}, // TWO_TOKEN | 418 {0, 0, 0, 2, two_cost}, // TWO |
141 {0, 0, 0, 3}, // THREE_TOKEN | 419 {0, 0, 0, 3, three_cost}, // THREE |
142 {0, 0, 0, 4}, // FOUR_TOKEN | 420 {0, 0, 0, 4, four_cost}, // FOUR |
143 {cat1_high10, vp9_cat1_prob_high10, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN | 421 {cat1_high10, vp9_cat1_prob_high10, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1 |
144 {cat2_high10, vp9_cat2_prob_high10, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN | 422 {cat2_high10, vp9_cat2_prob_high10, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2 |
145 {cat3_high10, vp9_cat3_prob_high10, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN | 423 {cat3_high10, vp9_cat3_prob_high10, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3 |
146 {cat4_high10, vp9_cat4_prob_high10, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN | 424 {cat4_high10, vp9_cat4_prob_high10, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4 |
147 {cat5_high10, vp9_cat5_prob_high10, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN | 425 {cat5_high10, vp9_cat5_prob_high10, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5 |
148 {cat6_high10, vp9_cat6_prob_high10, 16, CAT6_MIN_VAL}, // CATEGORY6_TOKEN | 426 {cat6_high10, vp9_cat6_prob_high10, 16, CAT6_MIN_VAL, 0}, // CAT6 |
149 {0, 0, 0, 0} // EOB_TOKEN | 427 {0, 0, 0, 0, zero_cost} // EOB |
150 }; | 428 }; |
151 const vp9_extra_bit vp9_extra_bits_high12[ENTROPY_TOKENS] = { | 429 const vp9_extra_bit vp9_extra_bits_high12[ENTROPY_TOKENS] = { |
152 {0, 0, 0, 0}, // ZERO_TOKEN | 430 {0, 0, 0, 0, zero_cost}, // ZERO |
153 {0, 0, 0, 1}, // ONE_TOKEN | 431 {0, 0, 0, 1, one_cost}, // ONE |
154 {0, 0, 0, 2}, // TWO_TOKEN | 432 {0, 0, 0, 2, two_cost}, // TWO |
155 {0, 0, 0, 3}, // THREE_TOKEN | 433 {0, 0, 0, 3, three_cost}, // THREE |
156 {0, 0, 0, 4}, // FOUR_TOKEN | 434 {0, 0, 0, 4, four_cost}, // FOUR |
157 {cat1_high12, vp9_cat1_prob_high12, 1, CAT1_MIN_VAL}, // CATEGORY1_TOKEN | 435 {cat1_high12, vp9_cat1_prob_high12, 1, CAT1_MIN_VAL, cat1_cost}, // CAT1 |
158 {cat2_high12, vp9_cat2_prob_high12, 2, CAT2_MIN_VAL}, // CATEGORY2_TOKEN | 436 {cat2_high12, vp9_cat2_prob_high12, 2, CAT2_MIN_VAL, cat2_cost}, // CAT2 |
159 {cat3_high12, vp9_cat3_prob_high12, 3, CAT3_MIN_VAL}, // CATEGORY3_TOKEN | 437 {cat3_high12, vp9_cat3_prob_high12, 3, CAT3_MIN_VAL, cat3_cost}, // CAT3 |
160 {cat4_high12, vp9_cat4_prob_high12, 4, CAT4_MIN_VAL}, // CATEGORY4_TOKEN | 438 {cat4_high12, vp9_cat4_prob_high12, 4, CAT4_MIN_VAL, cat4_cost}, // CAT4 |
161 {cat5_high12, vp9_cat5_prob_high12, 5, CAT5_MIN_VAL}, // CATEGORY5_TOKEN | 439 {cat5_high12, vp9_cat5_prob_high12, 5, CAT5_MIN_VAL, cat5_cost}, // CAT5 |
162 {cat6_high12, vp9_cat6_prob_high12, 18, CAT6_MIN_VAL}, // CATEGORY6_TOKEN | 440 {cat6_high12, vp9_cat6_prob_high12, 18, CAT6_MIN_VAL, 0}, // CAT6 |
163 {0, 0, 0, 0} // EOB_TOKEN | 441 {0, 0, 0, 0, zero_cost} // EOB |
164 }; | 442 }; |
165 #endif | 443 #endif |
166 | 444 |
167 struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS]; | 445 const struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS] = { |
168 | 446 {2, 2}, {6, 3}, {28, 5}, {58, 6}, {59, 6}, {60, 6}, {61, 6}, {124, 7}, |
169 void vp9_coef_tree_initialize() { | 447 {125, 7}, {126, 7}, {127, 7}, {0, 1} |
170 init_bit_trees(); | 448 }; |
171 vp9_tokens_from_tree(vp9_coef_encodings, vp9_coef_tree); | 449 |
172 } | |
173 | |
174 static void tokenize_init_one(TOKENVALUE *t, const vp9_extra_bit *const e, | |
175 int16_t *value_cost, int max_value) { | |
176 int i = -max_value; | |
177 int sign = 1; | |
178 | |
179 do { | |
180 if (!i) | |
181 sign = 0; | |
182 | |
183 { | |
184 const int a = sign ? -i : i; | |
185 int eb = sign; | |
186 | |
187 if (a > 4) { | |
188 int j = 4; | |
189 | |
190 while (++j < 11 && e[j].base_val <= a) {} | |
191 | |
192 t[i].token = --j; | |
193 eb |= (a - e[j].base_val) << 1; | |
194 } else { | |
195 t[i].token = a; | |
196 } | |
197 t[i].extra = eb; | |
198 } | |
199 | |
200 // initialize the cost for extra bits for all possible coefficient value. | |
201 { | |
202 int cost = 0; | |
203 const vp9_extra_bit *p = &e[t[i].token]; | |
204 | |
205 if (p->base_val) { | |
206 const int extra = t[i].extra; | |
207 const int length = p->len; | |
208 | |
209 if (length) | |
210 cost += treed_cost(p->tree, p->prob, extra >> 1, length); | |
211 | |
212 cost += vp9_cost_bit(vp9_prob_half, extra & 1); /* sign */ | |
213 value_cost[i] = cost; | |
214 } | |
215 } | |
216 } while (++i < max_value); | |
217 } | |
218 | |
219 void vp9_tokenize_initialize() { | |
220 vp9_dct_value_tokens_ptr = dct_value_tokens + DCT_MAX_VALUE; | |
221 vp9_dct_value_cost_ptr = dct_value_cost + DCT_MAX_VALUE; | |
222 | |
223 tokenize_init_one(dct_value_tokens + DCT_MAX_VALUE, vp9_extra_bits, | |
224 dct_value_cost + DCT_MAX_VALUE, DCT_MAX_VALUE); | |
225 #if CONFIG_VP9_HIGHBITDEPTH | |
226 vp9_dct_value_tokens_high10_ptr = dct_value_tokens_high10 + | |
227 DCT_MAX_VALUE_HIGH10; | |
228 vp9_dct_value_cost_high10_ptr = dct_value_cost_high10 + DCT_MAX_VALUE_HIGH10; | |
229 | |
230 tokenize_init_one(dct_value_tokens_high10 + DCT_MAX_VALUE_HIGH10, | |
231 vp9_extra_bits_high10, | |
232 dct_value_cost_high10 + DCT_MAX_VALUE_HIGH10, | |
233 DCT_MAX_VALUE_HIGH10); | |
234 vp9_dct_value_tokens_high12_ptr = dct_value_tokens_high12 + | |
235 DCT_MAX_VALUE_HIGH12; | |
236 vp9_dct_value_cost_high12_ptr = dct_value_cost_high12 + DCT_MAX_VALUE_HIGH12; | |
237 | |
238 tokenize_init_one(dct_value_tokens_high12 + DCT_MAX_VALUE_HIGH12, | |
239 vp9_extra_bits_high12, | |
240 dct_value_cost_high12 + DCT_MAX_VALUE_HIGH12, | |
241 DCT_MAX_VALUE_HIGH12); | |
242 #endif | |
243 } | |
244 | 450 |
245 struct tokenize_b_args { | 451 struct tokenize_b_args { |
246 VP9_COMP *cpi; | 452 VP9_COMP *cpi; |
247 ThreadData *td; | 453 ThreadData *td; |
248 TOKENEXTRA **tp; | 454 TOKENEXTRA **tp; |
249 }; | 455 }; |
250 | 456 |
251 static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize, | 457 static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize, |
252 TX_SIZE tx_size, void *arg) { | 458 TX_SIZE tx_size, void *arg) { |
253 struct tokenize_b_args* const args = arg; | 459 struct tokenize_b_args* const args = arg; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 const scan_order *so; | 521 const scan_order *so; |
316 const int ref = is_inter_block(mbmi); | 522 const int ref = is_inter_block(mbmi); |
317 unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] = | 523 unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] = |
318 td->rd_counts.coef_counts[tx_size][type][ref]; | 524 td->rd_counts.coef_counts[tx_size][type][ref]; |
319 vp9_prob (*const coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = | 525 vp9_prob (*const coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] = |
320 cpi->common.fc->coef_probs[tx_size][type][ref]; | 526 cpi->common.fc->coef_probs[tx_size][type][ref]; |
321 unsigned int (*const eob_branch)[COEFF_CONTEXTS] = | 527 unsigned int (*const eob_branch)[COEFF_CONTEXTS] = |
322 td->counts->eob_branch[tx_size][type][ref]; | 528 td->counts->eob_branch[tx_size][type][ref]; |
323 const uint8_t *const band = get_band_translate(tx_size); | 529 const uint8_t *const band = get_band_translate(tx_size); |
324 const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size); | 530 const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size); |
325 const TOKENVALUE *dct_value_tokens; | 531 int16_t token; |
326 | 532 EXTRABIT extra; |
327 int aoff, loff; | 533 int aoff, loff; |
328 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); | 534 txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff); |
329 | 535 |
330 pt = get_entropy_context(tx_size, pd->above_context + aoff, | 536 pt = get_entropy_context(tx_size, pd->above_context + aoff, |
331 pd->left_context + loff); | 537 pd->left_context + loff); |
332 so = get_scan(xd, tx_size, type, block); | 538 so = get_scan(xd, tx_size, type, block); |
333 scan = so->scan; | 539 scan = so->scan; |
334 nb = so->neighbors; | 540 nb = so->neighbors; |
335 c = 0; | 541 c = 0; |
336 #if CONFIG_VP9_HIGHBITDEPTH | |
337 if (cpi->common.profile >= PROFILE_2) { | |
338 dct_value_tokens = (cpi->common.bit_depth == VPX_BITS_10 ? | |
339 vp9_dct_value_tokens_high10_ptr : | |
340 vp9_dct_value_tokens_high12_ptr); | |
341 } else { | |
342 dct_value_tokens = vp9_dct_value_tokens_ptr; | |
343 } | |
344 #else | |
345 dct_value_tokens = vp9_dct_value_tokens_ptr; | |
346 #endif | |
347 | 542 |
348 while (c < eob) { | 543 while (c < eob) { |
349 int v = 0; | 544 int v = 0; |
350 int skip_eob = 0; | 545 int skip_eob = 0; |
351 v = qcoeff[scan[c]]; | 546 v = qcoeff[scan[c]]; |
352 | 547 |
353 while (!v) { | 548 while (!v) { |
354 add_token_no_extra(&t, coef_probs[band[c]][pt], ZERO_TOKEN, skip_eob, | 549 add_token_no_extra(&t, coef_probs[band[c]][pt], ZERO_TOKEN, skip_eob, |
355 counts[band[c]][pt]); | 550 counts[band[c]][pt]); |
356 eob_branch[band[c]][pt] += !skip_eob; | 551 eob_branch[band[c]][pt] += !skip_eob; |
357 | 552 |
358 skip_eob = 1; | 553 skip_eob = 1; |
359 token_cache[scan[c]] = 0; | 554 token_cache[scan[c]] = 0; |
360 ++c; | 555 ++c; |
361 pt = get_coef_context(nb, token_cache, c); | 556 pt = get_coef_context(nb, token_cache, c); |
362 v = qcoeff[scan[c]]; | 557 v = qcoeff[scan[c]]; |
363 } | 558 } |
364 | 559 |
365 add_token(&t, coef_probs[band[c]][pt], | 560 vp9_get_token_extra(v, &token, &extra); |
366 dct_value_tokens[v].extra, | 561 |
367 (uint8_t)dct_value_tokens[v].token, | 562 add_token(&t, coef_probs[band[c]][pt], extra, (uint8_t)token, |
368 (uint8_t)skip_eob, | 563 (uint8_t)skip_eob, counts[band[c]][pt]); |
369 counts[band[c]][pt]); | |
370 eob_branch[band[c]][pt] += !skip_eob; | 564 eob_branch[band[c]][pt] += !skip_eob; |
371 | 565 |
372 token_cache[scan[c]] = vp9_pt_energy_class[dct_value_tokens[v].token]; | 566 token_cache[scan[c]] = vp9_pt_energy_class[token]; |
373 ++c; | 567 ++c; |
374 pt = get_coef_context(nb, token_cache, c); | 568 pt = get_coef_context(nb, token_cache, c); |
375 } | 569 } |
376 if (c < seg_eob) { | 570 if (c < seg_eob) { |
377 add_token_no_extra(&t, coef_probs[band[c]][pt], EOB_TOKEN, 0, | 571 add_token_no_extra(&t, coef_probs[band[c]][pt], EOB_TOKEN, 0, |
378 counts[band[c]][pt]); | 572 counts[band[c]][pt]); |
379 ++eob_branch[band[c]][pt]; | 573 ++eob_branch[band[c]][pt]; |
380 } | 574 } |
381 | 575 |
382 *tp = t; | 576 *tp = t; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 640 } |
447 | 641 |
448 if (!dry_run) { | 642 if (!dry_run) { |
449 td->counts->skip[ctx][0] += skip_inc; | 643 td->counts->skip[ctx][0] += skip_inc; |
450 vp9_foreach_transformed_block(xd, bsize, tokenize_b, &arg); | 644 vp9_foreach_transformed_block(xd, bsize, tokenize_b, &arg); |
451 } else { | 645 } else { |
452 vp9_foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg); | 646 vp9_foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg); |
453 *t = t_backup; | 647 *t = t_backup; |
454 } | 648 } |
455 } | 649 } |
OLD | NEW |