2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
2014-03-05 20:57:57 +01:00
|
|
|
#include <assert.h>
|
2010-05-18 17:58:33 +02:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2014-03-05 20:57:57 +01:00
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
|
|
|
|
2014-03-05 20:57:57 +01:00
|
|
|
#include "vp9/common/vp9_entropy.h"
|
2012-11-27 22:59:17 +01:00
|
|
|
#include "vp9/common/vp9_pred_common.h"
|
|
|
|
#include "vp9/common/vp9_seg_common.h"
|
2014-03-05 20:57:57 +01:00
|
|
|
|
|
|
|
#include "vp9/encoder/vp9_cost.h"
|
2014-04-19 03:27:47 +02:00
|
|
|
#include "vp9/encoder/vp9_encoder.h"
|
2014-03-05 20:57:57 +01:00
|
|
|
#include "vp9/encoder/vp9_tokenize.h"
|
2011-10-05 12:26:00 +02:00
|
|
|
|
2014-12-22 17:42:52 +01:00
|
|
|
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},
|
|
|
|
{9, 31}, {9, 29}, {9, 27}, {9, 25}, {9, 23}, {9, 21}, {9, 19}, {9, 17},
|
|
|
|
{9, 15}, {9, 13}, {9, 11}, {9, 9}, {9, 7}, {9, 5}, {9, 3}, {9, 1},
|
|
|
|
{8, 31}, {8, 29}, {8, 27}, {8, 25}, {8, 23}, {8, 21},
|
|
|
|
{8, 19}, {8, 17}, {8, 15}, {8, 13}, {8, 11}, {8, 9},
|
|
|
|
{8, 7}, {8, 5}, {8, 3}, {8, 1},
|
|
|
|
{7, 15}, {7, 13}, {7, 11}, {7, 9}, {7, 7}, {7, 5}, {7, 3}, {7, 1},
|
|
|
|
{6, 7}, {6, 5}, {6, 3}, {6, 1}, {5, 3}, {5, 1},
|
|
|
|
{4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 0},
|
|
|
|
{1, 0}, {2, 0}, {3, 0}, {4, 0},
|
|
|
|
{5, 0}, {5, 2}, {6, 0}, {6, 2}, {6, 4}, {6, 6},
|
|
|
|
{7, 0}, {7, 2}, {7, 4}, {7, 6}, {7, 8}, {7, 10}, {7, 12}, {7, 14},
|
|
|
|
{8, 0}, {8, 2}, {8, 4}, {8, 6}, {8, 8}, {8, 10}, {8, 12},
|
|
|
|
{8, 14}, {8, 16}, {8, 18}, {8, 20}, {8, 22}, {8, 24},
|
|
|
|
{8, 26}, {8, 28}, {8, 30}, {9, 0}, {9, 2},
|
|
|
|
{9, 4}, {9, 6}, {9, 8}, {9, 10}, {9, 12}, {9, 14}, {9, 16},
|
|
|
|
{9, 18}, {9, 20}, {9, 22}, {9, 24}, {9, 26}, {9, 28},
|
|
|
|
{9, 30}, {9, 32}, {9, 34}, {9, 36}, {9, 38}, {9, 40},
|
|
|
|
{9, 42}, {9, 44}, {9, 46}, {9, 48}, {9, 50}, {9, 52},
|
|
|
|
{9, 54}, {9, 56}, {9, 58}, {9, 60}, {9, 62}
|
|
|
|
};
|
|
|
|
const TOKENVALUE *vp9_dct_cat_lt_10_value_tokens = dct_cat_lt_10_value_tokens +
|
|
|
|
(sizeof(dct_cat_lt_10_value_tokens) / sizeof(*dct_cat_lt_10_value_tokens))
|
|
|
|
/ 2;
|
|
|
|
|
2013-11-27 20:27:57 +01:00
|
|
|
// Array indices are identical to previously-existing CONTEXT_NODE indices
|
2013-12-04 02:23:03 +01:00
|
|
|
const vp9_tree_index vp9_coef_tree[TREE_SIZE(ENTROPY_TOKENS)] = {
|
|
|
|
-EOB_TOKEN, 2, // 0 = EOB
|
|
|
|
-ZERO_TOKEN, 4, // 1 = ZERO
|
|
|
|
-ONE_TOKEN, 6, // 2 = ONE
|
|
|
|
8, 12, // 3 = LOW_VAL
|
|
|
|
-TWO_TOKEN, 10, // 4 = TWO
|
|
|
|
-THREE_TOKEN, -FOUR_TOKEN, // 5 = THREE
|
|
|
|
14, 16, // 6 = HIGH_LOW
|
|
|
|
-CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 7 = CAT_ONE
|
|
|
|
18, 20, // 8 = CAT_THREEFOUR
|
|
|
|
-CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 9 = CAT_THREE
|
|
|
|
-CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 10 = CAT_FIVE
|
2013-11-27 20:27:57 +01:00
|
|
|
};
|
|
|
|
|
2014-12-17 23:08:42 +01:00
|
|
|
static const vp9_tree_index cat1[2] = {0, 0};
|
|
|
|
static const vp9_tree_index cat2[4] = {2, 2, 0, 0};
|
|
|
|
static const vp9_tree_index cat3[6] = {2, 2, 4, 4, 0, 0};
|
|
|
|
static const vp9_tree_index cat4[8] = {2, 2, 4, 4, 6, 6, 0, 0};
|
|
|
|
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};
|
2013-11-27 20:27:57 +01:00
|
|
|
|
2014-12-24 00:06:17 +01:00
|
|
|
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
|
|
|
|
|
2014-09-19 19:13:47 +02:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
2014-12-17 23:08:42 +01:00
|
|
|
static const vp9_tree_index cat1_high10[2] = {0, 0};
|
|
|
|
static const vp9_tree_index cat2_high10[4] = {2, 2, 0, 0};
|
|
|
|
static const vp9_tree_index cat3_high10[6] = {2, 2, 4, 4, 0, 0};
|
|
|
|
static const vp9_tree_index cat4_high10[8] = {2, 2, 4, 4, 6, 6, 0, 0};
|
|
|
|
static const vp9_tree_index cat5_high10[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0};
|
|
|
|
static const vp9_tree_index cat6_high10[32] = {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, 28, 28,
|
|
|
|
30, 30, 0, 0};
|
|
|
|
static const vp9_tree_index cat1_high12[2] = {0, 0};
|
|
|
|
static const vp9_tree_index cat2_high12[4] = {2, 2, 0, 0};
|
|
|
|
static const vp9_tree_index cat3_high12[6] = {2, 2, 4, 4, 0, 0};
|
|
|
|
static const vp9_tree_index cat4_high12[8] = {2, 2, 4, 4, 6, 6, 0, 0};
|
|
|
|
static const vp9_tree_index cat5_high12[10] = {2, 2, 4, 4, 6, 6, 8, 8, 0, 0};
|
|
|
|
static const vp9_tree_index cat6_high12[36] = {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, 28, 28,
|
|
|
|
30, 30, 32, 32, 34, 34, 0, 0};
|
2014-09-19 19:13:47 +02:00
|
|
|
#endif
|
|
|
|
|
2013-12-04 02:23:03 +01:00
|
|
|
const vp9_extra_bit vp9_extra_bits[ENTROPY_TOKENS] = {
|
2014-12-24 00:06:17 +01:00
|
|
|
{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
|
2013-11-27 20:27:57 +01:00
|
|
|
};
|
|
|
|
|
2014-09-19 19:13:47 +02:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
const vp9_extra_bit vp9_extra_bits_high10[ENTROPY_TOKENS] = {
|
2014-12-24 00:06:17 +01:00
|
|
|
{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
|
2014-09-19 19:13:47 +02:00
|
|
|
};
|
|
|
|
const vp9_extra_bit vp9_extra_bits_high12[ENTROPY_TOKENS] = {
|
2014-12-24 00:06:17 +01:00
|
|
|
{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
|
2014-09-19 19:13:47 +02:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2014-12-22 22:35:56 +01:00
|
|
|
const struct vp9_token vp9_coef_encodings[ENTROPY_TOKENS] = {
|
|
|
|
{2, 2}, {6, 3}, {28, 5}, {58, 6}, {59, 6}, {60, 6}, {61, 6}, {124, 7},
|
|
|
|
{125, 7}, {126, 7}, {127, 7}, {0, 1}
|
|
|
|
};
|
2013-11-27 20:27:57 +01:00
|
|
|
|
2012-11-28 00:51:06 +01:00
|
|
|
|
2013-04-29 20:57:48 +02:00
|
|
|
struct tokenize_b_args {
|
|
|
|
VP9_COMP *cpi;
|
2014-11-21 20:11:06 +01:00
|
|
|
ThreadData *td;
|
2013-04-29 20:57:48 +02:00
|
|
|
TOKENEXTRA **tp;
|
|
|
|
};
|
2013-06-06 15:07:09 +02:00
|
|
|
|
2013-08-27 20:05:08 +02:00
|
|
|
static void set_entropy_context_b(int plane, int block, BLOCK_SIZE plane_bsize,
|
2013-08-16 02:03:03 +02:00
|
|
|
TX_SIZE tx_size, void *arg) {
|
2013-07-29 23:54:31 +02:00
|
|
|
struct tokenize_b_args* const args = arg;
|
2014-11-21 20:11:06 +01:00
|
|
|
ThreadData *const td = args->td;
|
|
|
|
MACROBLOCK *const x = &td->mb;
|
|
|
|
MACROBLOCKD *const xd = &x->e_mbd;
|
|
|
|
struct macroblock_plane *p = &x->plane[plane];
|
2013-08-20 00:47:24 +02:00
|
|
|
struct macroblockd_plane *pd = &xd->plane[plane];
|
2013-08-21 20:55:04 +02:00
|
|
|
int aoff, loff;
|
|
|
|
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff);
|
2014-02-01 02:35:53 +01:00
|
|
|
vp9_set_contexts(xd, pd, plane_bsize, tx_size, p->eobs[block] > 0,
|
|
|
|
aoff, loff);
|
2013-07-29 23:54:31 +02:00
|
|
|
}
|
|
|
|
|
2014-01-15 00:05:13 +01:00
|
|
|
static INLINE void add_token(TOKENEXTRA **t, const vp9_prob *context_tree,
|
2014-10-01 06:56:33 +02:00
|
|
|
int32_t extra, uint8_t token,
|
2014-01-15 00:05:13 +01:00
|
|
|
uint8_t skip_eob_node,
|
|
|
|
unsigned int *counts) {
|
|
|
|
(*t)->token = token;
|
|
|
|
(*t)->extra = extra;
|
|
|
|
(*t)->context_tree = context_tree;
|
|
|
|
(*t)->skip_eob_node = skip_eob_node;
|
|
|
|
(*t)++;
|
|
|
|
++counts[token];
|
|
|
|
}
|
|
|
|
|
2014-02-04 04:49:37 +01:00
|
|
|
static INLINE void add_token_no_extra(TOKENEXTRA **t,
|
|
|
|
const vp9_prob *context_tree,
|
|
|
|
uint8_t token,
|
|
|
|
uint8_t skip_eob_node,
|
|
|
|
unsigned int *counts) {
|
|
|
|
(*t)->token = token;
|
|
|
|
(*t)->context_tree = context_tree;
|
|
|
|
(*t)->skip_eob_node = skip_eob_node;
|
|
|
|
(*t)++;
|
|
|
|
++counts[token];
|
|
|
|
}
|
|
|
|
|
2014-02-28 03:26:44 +01:00
|
|
|
static INLINE int get_tx_eob(const struct segmentation *seg, int segment_id,
|
|
|
|
TX_SIZE tx_size) {
|
|
|
|
const int eob_max = 16 << (tx_size << 1);
|
|
|
|
return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
|
|
|
|
}
|
|
|
|
|
2013-08-27 20:05:08 +02:00
|
|
|
static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
|
2013-08-16 02:03:03 +02:00
|
|
|
TX_SIZE tx_size, void *arg) {
|
2013-04-29 20:57:48 +02:00
|
|
|
struct tokenize_b_args* const args = arg;
|
|
|
|
VP9_COMP *cpi = args->cpi;
|
2014-11-21 20:11:06 +01:00
|
|
|
ThreadData *const td = args->td;
|
|
|
|
MACROBLOCK *const x = &td->mb;
|
|
|
|
MACROBLOCKD *const xd = &x->e_mbd;
|
2013-04-29 20:57:48 +02:00
|
|
|
TOKENEXTRA **tp = args->tp;
|
2014-02-28 03:58:32 +01:00
|
|
|
uint8_t token_cache[32 * 32];
|
2014-11-21 20:11:06 +01:00
|
|
|
struct macroblock_plane *p = &x->plane[plane];
|
2013-08-20 00:47:24 +02:00
|
|
|
struct macroblockd_plane *pd = &xd->plane[plane];
|
2015-04-21 14:36:58 +02:00
|
|
|
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
|
2012-08-03 02:03:14 +02:00
|
|
|
int pt; /* near block/prev token context index */
|
2014-02-04 04:49:37 +01:00
|
|
|
int c;
|
2012-08-03 02:03:14 +02:00
|
|
|
TOKENEXTRA *t = *tp; /* store tokens starting here */
|
2014-01-15 00:05:13 +01:00
|
|
|
int eob = p->eobs[block];
|
2013-08-20 00:47:24 +02:00
|
|
|
const PLANE_TYPE type = pd->plane_type;
|
2014-09-03 01:34:09 +02:00
|
|
|
const tran_low_t *qcoeff = BLOCK_OFFSET(p->qcoeff, block);
|
2013-03-04 23:12:17 +01:00
|
|
|
const int segment_id = mbmi->segment_id;
|
2013-07-01 20:36:07 +02:00
|
|
|
const int16_t *scan, *nb;
|
2013-11-23 01:20:45 +01:00
|
|
|
const scan_order *so;
|
2013-08-03 01:25:33 +02:00
|
|
|
const int ref = is_inter_block(mbmi);
|
2014-02-04 04:49:37 +01:00
|
|
|
unsigned int (*const counts)[COEFF_CONTEXTS][ENTROPY_TOKENS] =
|
2014-11-21 20:11:06 +01:00
|
|
|
td->rd_counts.coef_counts[tx_size][type][ref];
|
2014-02-04 04:49:37 +01:00
|
|
|
vp9_prob (*const coef_probs)[COEFF_CONTEXTS][UNCONSTRAINED_NODES] =
|
2014-10-22 23:37:38 +02:00
|
|
|
cpi->common.fc->coef_probs[tx_size][type][ref];
|
2014-02-04 04:49:37 +01:00
|
|
|
unsigned int (*const eob_branch)[COEFF_CONTEXTS] =
|
2014-11-21 20:11:06 +01:00
|
|
|
td->counts->eob_branch[tx_size][type][ref];
|
2014-01-15 00:05:13 +01:00
|
|
|
const uint8_t *const band = get_band_translate(tx_size);
|
2013-08-27 23:17:53 +02:00
|
|
|
const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
|
2014-12-22 17:42:52 +01:00
|
|
|
int16_t token;
|
|
|
|
EXTRABIT extra;
|
2013-08-21 20:55:04 +02:00
|
|
|
int aoff, loff;
|
|
|
|
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff);
|
|
|
|
|
2013-09-19 14:53:48 +02:00
|
|
|
pt = get_entropy_context(tx_size, pd->above_context + aoff,
|
2014-01-15 00:05:13 +01:00
|
|
|
pd->left_context + loff);
|
2013-11-23 01:20:45 +01:00
|
|
|
so = get_scan(xd, tx_size, type, block);
|
|
|
|
scan = so->scan;
|
|
|
|
nb = so->neighbors;
|
2013-03-28 18:42:23 +01:00
|
|
|
c = 0;
|
2014-09-19 19:13:47 +02:00
|
|
|
|
2014-01-15 00:05:13 +01:00
|
|
|
while (c < eob) {
|
2013-02-20 19:16:24 +01:00
|
|
|
int v = 0;
|
2014-01-15 00:05:13 +01:00
|
|
|
int skip_eob = 0;
|
2014-02-14 02:40:10 +01:00
|
|
|
v = qcoeff[scan[c]];
|
2014-01-15 00:05:13 +01:00
|
|
|
|
|
|
|
while (!v) {
|
2014-02-04 04:49:37 +01:00
|
|
|
add_token_no_extra(&t, coef_probs[band[c]][pt], ZERO_TOKEN, skip_eob,
|
|
|
|
counts[band[c]][pt]);
|
|
|
|
eob_branch[band[c]][pt] += !skip_eob;
|
2013-05-08 19:04:14 +02:00
|
|
|
|
2014-01-15 00:05:13 +01:00
|
|
|
skip_eob = 1;
|
|
|
|
token_cache[scan[c]] = 0;
|
|
|
|
++c;
|
|
|
|
pt = get_coef_context(nb, token_cache, c);
|
2014-02-14 02:40:10 +01:00
|
|
|
v = qcoeff[scan[c]];
|
2014-01-15 00:05:13 +01:00
|
|
|
}
|
2014-02-04 04:49:37 +01:00
|
|
|
|
2014-12-22 17:42:52 +01:00
|
|
|
vp9_get_token_extra(v, &token, &extra);
|
|
|
|
|
|
|
|
add_token(&t, coef_probs[band[c]][pt], extra, (uint8_t)token,
|
|
|
|
(uint8_t)skip_eob, counts[band[c]][pt]);
|
2014-02-04 04:49:37 +01:00
|
|
|
eob_branch[band[c]][pt] += !skip_eob;
|
2013-07-30 02:06:18 +02:00
|
|
|
|
2014-12-22 17:42:52 +01:00
|
|
|
token_cache[scan[c]] = vp9_pt_energy_class[token];
|
2014-01-15 00:05:13 +01:00
|
|
|
++c;
|
|
|
|
pt = get_coef_context(nb, token_cache, c);
|
|
|
|
}
|
|
|
|
if (c < seg_eob) {
|
2014-02-04 04:49:37 +01:00
|
|
|
add_token_no_extra(&t, coef_probs[band[c]][pt], EOB_TOKEN, 0,
|
|
|
|
counts[band[c]][pt]);
|
|
|
|
++eob_branch[band[c]][pt];
|
2014-01-15 00:05:13 +01:00
|
|
|
}
|
2012-10-13 20:46:21 +02:00
|
|
|
|
|
|
|
*tp = t;
|
2013-08-21 20:55:04 +02:00
|
|
|
|
2014-02-01 02:35:53 +01:00
|
|
|
vp9_set_contexts(xd, pd, plane_bsize, tx_size, c > 0, aoff, loff);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2013-04-11 20:14:31 +02:00
|
|
|
struct is_skippable_args {
|
2013-12-04 02:59:32 +01:00
|
|
|
MACROBLOCK *x;
|
2013-04-11 20:14:31 +02:00
|
|
|
int *skippable;
|
|
|
|
};
|
|
|
|
static void is_skippable(int plane, int block,
|
2013-08-27 20:05:08 +02:00
|
|
|
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
|
2013-08-20 00:47:24 +02:00
|
|
|
void *argv) {
|
2013-04-11 20:14:31 +02:00
|
|
|
struct is_skippable_args *args = argv;
|
2014-05-13 19:44:40 +02:00
|
|
|
(void)plane_bsize;
|
|
|
|
(void)tx_size;
|
2013-12-04 02:59:32 +01:00
|
|
|
args->skippable[0] &= (!args->x->plane[plane].eobs[block]);
|
2012-09-12 04:36:28 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 16:39:55 +02:00
|
|
|
// TODO(yaowu): rewrite and optimize this function to remove the usage of
|
|
|
|
// vp9_foreach_transform_block() and simplify is_skippable().
|
2013-12-04 02:59:32 +01:00
|
|
|
int vp9_is_skippable_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
|
2013-04-11 20:14:31 +02:00
|
|
|
int result = 1;
|
2013-12-04 02:59:32 +01:00
|
|
|
struct is_skippable_args args = {x, &result};
|
2014-02-01 02:35:53 +01:00
|
|
|
vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane, is_skippable,
|
|
|
|
&args);
|
2013-04-11 20:14:31 +02:00
|
|
|
return result;
|
2013-03-04 23:12:17 +01:00
|
|
|
}
|
|
|
|
|
Rework partition search skip scheme
This commit enables the encoder to skip split partition search if
the bigger block size has all non-zero quantized coefficients in low
frequency area and the total rate cost is below a certain threshold.
It logarithmatically scales the rate threshold according to the
current block size. For speed 3, the compression performance loss:
derf -0.093%
stdhd -0.066%
Local experiments show 4% - 20% encoding speed-up for speed 3.
blue_sky_1080p, 1500 kbps
51051 b/f, 35.891 dB, 67236 ms ->
50554 b/f, 35.857 dB, 59270 ms (12% speed-up)
old_town_cross_720p, 1500 kbps
14431 b/f, 36.249 dB, 57687 ms ->
14108 b/f, 36.172 dB, 46586 ms (19% speed-up)
pedestrian_area_1080p, 1500 kbps
50812 b/f, 40.124 dB, 100439 ms ->
50755 b/f, 40.118 dB, 96549 ms (4% speed-up)
mobile_calendar_720p, 1000 kbps
10352 b/f, 35.055 dB, 51837 ms ->
10172 b/f, 35.003 dB, 44076 ms (15% speed-up)
Change-Id: I412e34db49060775b3b89ba1738522317c3239c8
2014-10-03 02:49:00 +02:00
|
|
|
static void has_high_freq_coeff(int plane, int block,
|
|
|
|
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
|
|
|
|
void *argv) {
|
|
|
|
struct is_skippable_args *args = argv;
|
|
|
|
int eobs = (tx_size == TX_4X4) ? 3 : 10;
|
|
|
|
(void) plane_bsize;
|
|
|
|
|
|
|
|
*(args->skippable) |= (args->x->plane[plane].eobs[block] > eobs);
|
|
|
|
}
|
|
|
|
|
|
|
|
int vp9_has_high_freq_in_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane) {
|
|
|
|
int result = 0;
|
|
|
|
struct is_skippable_args args = {x, &result};
|
|
|
|
vp9_foreach_transformed_block_in_plane(&x->e_mbd, bsize, plane,
|
|
|
|
has_high_freq_coeff, &args);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-11-21 20:11:06 +01:00
|
|
|
void vp9_tokenize_sb(VP9_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
|
|
|
|
int dry_run, BLOCK_SIZE bsize) {
|
2013-07-12 03:39:10 +02:00
|
|
|
VP9_COMMON *const cm = &cpi->common;
|
2014-11-21 20:11:06 +01:00
|
|
|
MACROBLOCK *const x = &td->mb;
|
|
|
|
MACROBLOCKD *const xd = &x->e_mbd;
|
2015-04-21 14:36:58 +02:00
|
|
|
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
|
2013-12-10 23:11:26 +01:00
|
|
|
const int ctx = vp9_get_skip_context(xd);
|
2013-08-14 20:20:33 +02:00
|
|
|
const int skip_inc = !vp9_segfeature_active(&cm->seg, mbmi->segment_id,
|
2013-07-10 21:29:43 +02:00
|
|
|
SEG_LVL_SKIP);
|
2014-11-21 20:11:06 +01:00
|
|
|
struct tokenize_b_args arg = {cpi, td, t};
|
2014-02-13 02:44:12 +01:00
|
|
|
if (mbmi->skip) {
|
32x32 transform for superblocks.
This adds Debargha's DCT/DWT hybrid and a regular 32x32 DCT, and adds
code all over the place to wrap that in the bitstream/encoder/decoder/RD.
Some implementation notes (these probably need careful review):
- token range is extended by 1 bit, since the value range out of this
transform is [-16384,16383].
- the coefficients coming out of the FDCT are manually scaled back by
1 bit, or else they won't fit in int16_t (they are 17 bits). Because
of this, the RD error scoring does not right-shift the MSE score by
two (unlike for 4x4/8x8/16x16).
- to compensate for this loss in precision, the quantizer is halved
also. This is currently a little hacky.
- FDCT and IDCT is double-only right now. Needs a fixed-point impl.
- There are no default probabilities for the 32x32 transform yet; I'm
simply using the 16x16 luma ones. A future commit will add newly
generated probabilities for all transforms.
- No ADST version. I don't think we'll add one for this level; if an
ADST is desired, transform-size selection can scale back to 16x16
or lower, and use an ADST at that level.
Additional notes specific to Debargha's DWT/DCT hybrid:
- coefficient scale is different for the top/left 16x16 (DCT-over-DWT)
block than for the rest (DWT pixel differences) of the block. Therefore,
RD error scoring isn't easily scalable between coefficient and pixel
domain. Thus, unfortunately, we need to compute the RD distortion in
the pixel domain until we figure out how to scale these appropriately.
Change-Id: I00386f20f35d7fabb19aba94c8162f8aee64ef2b
2012-12-07 23:45:05 +01:00
|
|
|
if (!dry_run)
|
2014-11-21 20:11:06 +01:00
|
|
|
td->counts->skip[ctx][1] += skip_inc;
|
2013-08-12 20:24:24 +02:00
|
|
|
reset_skip_context(xd, bsize);
|
32x32 transform for superblocks.
This adds Debargha's DCT/DWT hybrid and a regular 32x32 DCT, and adds
code all over the place to wrap that in the bitstream/encoder/decoder/RD.
Some implementation notes (these probably need careful review):
- token range is extended by 1 bit, since the value range out of this
transform is [-16384,16383].
- the coefficients coming out of the FDCT are manually scaled back by
1 bit, or else they won't fit in int16_t (they are 17 bits). Because
of this, the RD error scoring does not right-shift the MSE score by
two (unlike for 4x4/8x8/16x16).
- to compensate for this loss in precision, the quantizer is halved
also. This is currently a little hacky.
- FDCT and IDCT is double-only right now. Needs a fixed-point impl.
- There are no default probabilities for the 32x32 transform yet; I'm
simply using the 16x16 luma ones. A future commit will add newly
generated probabilities for all transforms.
- No ADST version. I don't think we'll add one for this level; if an
ADST is desired, transform-size selection can scale back to 16x16
or lower, and use an ADST at that level.
Additional notes specific to Debargha's DWT/DCT hybrid:
- coefficient scale is different for the top/left 16x16 (DCT-over-DWT)
block than for the rest (DWT pixel differences) of the block. Therefore,
RD error scoring isn't easily scalable between coefficient and pixel
domain. Thus, unfortunately, we need to compute the RD distortion in
the pixel domain until we figure out how to scale these appropriately.
Change-Id: I00386f20f35d7fabb19aba94c8162f8aee64ef2b
2012-12-07 23:45:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-29 23:54:31 +02:00
|
|
|
if (!dry_run) {
|
2014-11-21 20:11:06 +01:00
|
|
|
td->counts->skip[ctx][0] += skip_inc;
|
2014-02-01 02:35:53 +01:00
|
|
|
vp9_foreach_transformed_block(xd, bsize, tokenize_b, &arg);
|
2013-07-29 23:54:31 +02:00
|
|
|
} else {
|
2014-02-01 02:35:53 +01:00
|
|
|
vp9_foreach_transformed_block(xd, bsize, set_entropy_context_b, &arg);
|
2013-07-29 23:54:31 +02:00
|
|
|
}
|
32x32 transform for superblocks.
This adds Debargha's DCT/DWT hybrid and a regular 32x32 DCT, and adds
code all over the place to wrap that in the bitstream/encoder/decoder/RD.
Some implementation notes (these probably need careful review):
- token range is extended by 1 bit, since the value range out of this
transform is [-16384,16383].
- the coefficients coming out of the FDCT are manually scaled back by
1 bit, or else they won't fit in int16_t (they are 17 bits). Because
of this, the RD error scoring does not right-shift the MSE score by
two (unlike for 4x4/8x8/16x16).
- to compensate for this loss in precision, the quantizer is halved
also. This is currently a little hacky.
- FDCT and IDCT is double-only right now. Needs a fixed-point impl.
- There are no default probabilities for the 32x32 transform yet; I'm
simply using the 16x16 luma ones. A future commit will add newly
generated probabilities for all transforms.
- No ADST version. I don't think we'll add one for this level; if an
ADST is desired, transform-size selection can scale back to 16x16
or lower, and use an ADST at that level.
Additional notes specific to Debargha's DWT/DCT hybrid:
- coefficient scale is different for the top/left 16x16 (DCT-over-DWT)
block than for the rest (DWT pixel differences) of the block. Therefore,
RD error scoring isn't easily scalable between coefficient and pixel
domain. Thus, unfortunately, we need to compute the RD distortion in
the pixel domain until we figure out how to scale these appropriately.
Change-Id: I00386f20f35d7fabb19aba94c8162f8aee64ef2b
2012-12-07 23:45:05 +01:00
|
|
|
}
|