1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "vp9/common/vp9_entropy.h"
12 #include "vp9/common/vp9_blockd.h"
13 #include "vp9/common/vp9_onyxc_int.h"
14 #include "vp9/common/vp9_entropymode.h"
15 #include "vpx_mem/vpx_mem.h"
16 #include "vpx/vpx_integer.h"
17
18 // Unconstrained Node Tree
19 /* clang-format off */
20 const vpx_tree_index vp9_coef_con_tree[TREE_SIZE(ENTROPY_TOKENS)] = {
21 2, 6, // 0 = LOW_VAL
22 -TWO_TOKEN, 4, // 1 = TWO
23 -THREE_TOKEN, -FOUR_TOKEN, // 2 = THREE
24 8, 10, // 3 = HIGH_LOW
25 -CATEGORY1_TOKEN, -CATEGORY2_TOKEN, // 4 = CAT_ONE
26 12, 14, // 5 = CAT_THREEFOUR
27 -CATEGORY3_TOKEN, -CATEGORY4_TOKEN, // 6 = CAT_THREE
28 -CATEGORY5_TOKEN, -CATEGORY6_TOKEN // 7 = CAT_FIVE
29 };
30 /* clang-format on */
31
32 const vpx_prob vp9_cat1_prob[] = { 159 };
33 const vpx_prob vp9_cat2_prob[] = { 165, 145 };
34 const vpx_prob vp9_cat3_prob[] = { 173, 148, 140 };
35 const vpx_prob vp9_cat4_prob[] = { 176, 155, 140, 135 };
36 const vpx_prob vp9_cat5_prob[] = { 180, 157, 141, 134, 130 };
37 const vpx_prob vp9_cat6_prob[] = { 254, 254, 254, 252, 249, 243, 230,
38 196, 177, 153, 140, 133, 130, 129 };
39 #if CONFIG_VP9_HIGHBITDEPTH
40 const vpx_prob vp9_cat6_prob_high12[] = { 255, 255, 255, 255, 254, 254,
41 254, 252, 249, 243, 230, 196,
42 177, 153, 140, 133, 130, 129 };
43 #endif
44
45 const uint8_t vp9_coefband_trans_8x8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, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
86 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
87 };
88
89 const uint8_t vp9_coefband_trans_4x4[16] = {
90 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5,
91 };
92
93 const uint8_t vp9_pt_energy_class[ENTROPY_TOKENS] = { 0, 1, 2, 3, 3, 4,
94 4, 5, 5, 5, 5, 5 };
95
96 // Model obtained from a 2-sided zero-centerd distribuition derived
97 // from a Pareto distribution. The cdf of the distribution is:
98 // cdf(x) = 0.5 + 0.5 * sgn(x) * [1 - {alpha/(alpha + |x|)} ^ beta]
99 //
100 // For a given beta and a given probablity of the 1-node, the alpha
101 // is first solved, and then the {alpha, beta} pair is used to generate
102 // the probabilities for the rest of the nodes.
103
104 // beta = 8
105
106 // Every odd line in this table can be generated from the even lines
107 // by averaging :
108 // vp9_pareto8_full[l][node] = (vp9_pareto8_full[l-1][node] +
109 // vp9_pareto8_full[l+1][node] ) >> 1;
110 const vpx_prob vp9_pareto8_full[COEFF_PROB_MODELS][MODEL_NODES] = {
111 { 3, 86, 128, 6, 86, 23, 88, 29 },
112 { 6, 86, 128, 11, 87, 42, 91, 52 },
113 { 9, 86, 129, 17, 88, 61, 94, 76 },
114 { 12, 86, 129, 22, 88, 77, 97, 93 },
115 { 15, 87, 129, 28, 89, 93, 100, 110 },
116 { 17, 87, 129, 33, 90, 105, 103, 123 },
117 { 20, 88, 130, 38, 91, 118, 106, 136 },
118 { 23, 88, 130, 43, 91, 128, 108, 146 },
119 { 26, 89, 131, 48, 92, 139, 111, 156 },
120 { 28, 89, 131, 53, 93, 147, 114, 163 },
121 { 31, 90, 131, 58, 94, 156, 117, 171 },
122 { 34, 90, 131, 62, 94, 163, 119, 177 },
123 { 37, 90, 132, 66, 95, 171, 122, 184 },
124 { 39, 90, 132, 70, 96, 177, 124, 189 },
125 { 42, 91, 132, 75, 97, 183, 127, 194 },
126 { 44, 91, 132, 79, 97, 188, 129, 198 },
127 { 47, 92, 133, 83, 98, 193, 132, 202 },
128 { 49, 92, 133, 86, 99, 197, 134, 205 },
129 { 52, 93, 133, 90, 100, 201, 137, 208 },
130 { 54, 93, 133, 94, 100, 204, 139, 211 },
131 { 57, 94, 134, 98, 101, 208, 142, 214 },
132 { 59, 94, 134, 101, 102, 211, 144, 216 },
133 { 62, 94, 135, 105, 103, 214, 146, 218 },
134 { 64, 94, 135, 108, 103, 216, 148, 220 },
135 { 66, 95, 135, 111, 104, 219, 151, 222 },
136 { 68, 95, 135, 114, 105, 221, 153, 223 },
137 { 71, 96, 136, 117, 106, 224, 155, 225 },
138 { 73, 96, 136, 120, 106, 225, 157, 226 },
139 { 76, 97, 136, 123, 107, 227, 159, 228 },
140 { 78, 97, 136, 126, 108, 229, 160, 229 },
141 { 80, 98, 137, 129, 109, 231, 162, 231 },
142 { 82, 98, 137, 131, 109, 232, 164, 232 },
143 { 84, 98, 138, 134, 110, 234, 166, 233 },
144 { 86, 98, 138, 137, 111, 235, 168, 234 },
145 { 89, 99, 138, 140, 112, 236, 170, 235 },
146 { 91, 99, 138, 142, 112, 237, 171, 235 },
147 { 93, 100, 139, 145, 113, 238, 173, 236 },
148 { 95, 100, 139, 147, 114, 239, 174, 237 },
149 { 97, 101, 140, 149, 115, 240, 176, 238 },
150 { 99, 101, 140, 151, 115, 241, 177, 238 },
151 { 101, 102, 140, 154, 116, 242, 179, 239 },
152 { 103, 102, 140, 156, 117, 242, 180, 239 },
153 { 105, 103, 141, 158, 118, 243, 182, 240 },
154 { 107, 103, 141, 160, 118, 243, 183, 240 },
155 { 109, 104, 141, 162, 119, 244, 185, 241 },
156 { 111, 104, 141, 164, 119, 244, 186, 241 },
157 { 113, 104, 142, 166, 120, 245, 187, 242 },
158 { 114, 104, 142, 168, 121, 245, 188, 242 },
159 { 116, 105, 143, 170, 122, 246, 190, 243 },
160 { 118, 105, 143, 171, 122, 246, 191, 243 },
161 { 120, 106, 143, 173, 123, 247, 192, 244 },
162 { 121, 106, 143, 175, 124, 247, 193, 244 },
163 { 123, 107, 144, 177, 125, 248, 195, 244 },
164 { 125, 107, 144, 178, 125, 248, 196, 244 },
165 { 127, 108, 145, 180, 126, 249, 197, 245 },
166 { 128, 108, 145, 181, 127, 249, 198, 245 },
167 { 130, 109, 145, 183, 128, 249, 199, 245 },
168 { 132, 109, 145, 184, 128, 249, 200, 245 },
169 { 134, 110, 146, 186, 129, 250, 201, 246 },
170 { 135, 110, 146, 187, 130, 250, 202, 246 },
171 { 137, 111, 147, 189, 131, 251, 203, 246 },
172 { 138, 111, 147, 190, 131, 251, 204, 246 },
173 { 140, 112, 147, 192, 132, 251, 205, 247 },
174 { 141, 112, 147, 193, 132, 251, 206, 247 },
175 { 143, 113, 148, 194, 133, 251, 207, 247 },
176 { 144, 113, 148, 195, 134, 251, 207, 247 },
177 { 146, 114, 149, 197, 135, 252, 208, 248 },
178 { 147, 114, 149, 198, 135, 252, 209, 248 },
179 { 149, 115, 149, 199, 136, 252, 210, 248 },
180 { 150, 115, 149, 200, 137, 252, 210, 248 },
181 { 152, 115, 150, 201, 138, 252, 211, 248 },
182 { 153, 115, 150, 202, 138, 252, 212, 248 },
183 { 155, 116, 151, 204, 139, 253, 213, 249 },
184 { 156, 116, 151, 205, 139, 253, 213, 249 },
185 { 158, 117, 151, 206, 140, 253, 214, 249 },
186 { 159, 117, 151, 207, 141, 253, 215, 249 },
187 { 161, 118, 152, 208, 142, 253, 216, 249 },
188 { 162, 118, 152, 209, 142, 253, 216, 249 },
189 { 163, 119, 153, 210, 143, 253, 217, 249 },
190 { 164, 119, 153, 211, 143, 253, 217, 249 },
191 { 166, 120, 153, 212, 144, 254, 218, 250 },
192 { 167, 120, 153, 212, 145, 254, 219, 250 },
193 { 168, 121, 154, 213, 146, 254, 220, 250 },
194 { 169, 121, 154, 214, 146, 254, 220, 250 },
195 { 171, 122, 155, 215, 147, 254, 221, 250 },
196 { 172, 122, 155, 216, 147, 254, 221, 250 },
197 { 173, 123, 155, 217, 148, 254, 222, 250 },
198 { 174, 123, 155, 217, 149, 254, 222, 250 },
199 { 176, 124, 156, 218, 150, 254, 223, 250 },
200 { 177, 124, 156, 219, 150, 254, 223, 250 },
201 { 178, 125, 157, 220, 151, 254, 224, 251 },
202 { 179, 125, 157, 220, 151, 254, 224, 251 },
203 { 180, 126, 157, 221, 152, 254, 225, 251 },
204 { 181, 126, 157, 221, 152, 254, 225, 251 },
205 { 183, 127, 158, 222, 153, 254, 226, 251 },
206 { 184, 127, 158, 223, 154, 254, 226, 251 },
207 { 185, 128, 159, 224, 155, 255, 227, 251 },
208 { 186, 128, 159, 224, 155, 255, 227, 251 },
209 { 187, 129, 160, 225, 156, 255, 228, 251 },
210 { 188, 130, 160, 225, 156, 255, 228, 251 },
211 { 189, 131, 160, 226, 157, 255, 228, 251 },
212 { 190, 131, 160, 226, 158, 255, 228, 251 },
213 { 191, 132, 161, 227, 159, 255, 229, 251 },
214 { 192, 132, 161, 227, 159, 255, 229, 251 },
215 { 193, 133, 162, 228, 160, 255, 230, 252 },
216 { 194, 133, 162, 229, 160, 255, 230, 252 },
217 { 195, 134, 163, 230, 161, 255, 231, 252 },
218 { 196, 134, 163, 230, 161, 255, 231, 252 },
219 { 197, 135, 163, 231, 162, 255, 231, 252 },
220 { 198, 135, 163, 231, 162, 255, 231, 252 },
221 { 199, 136, 164, 232, 163, 255, 232, 252 },
222 { 200, 136, 164, 232, 164, 255, 232, 252 },
223 { 201, 137, 165, 233, 165, 255, 233, 252 },
224 { 201, 137, 165, 233, 165, 255, 233, 252 },
225 { 202, 138, 166, 233, 166, 255, 233, 252 },
226 { 203, 138, 166, 233, 166, 255, 233, 252 },
227 { 204, 139, 166, 234, 167, 255, 234, 252 },
228 { 205, 139, 166, 234, 167, 255, 234, 252 },
229 { 206, 140, 167, 235, 168, 255, 235, 252 },
230 { 206, 140, 167, 235, 168, 255, 235, 252 },
231 { 207, 141, 168, 236, 169, 255, 235, 252 },
232 { 208, 141, 168, 236, 170, 255, 235, 252 },
233 { 209, 142, 169, 237, 171, 255, 236, 252 },
234 { 209, 143, 169, 237, 171, 255, 236, 252 },
235 { 210, 144, 169, 237, 172, 255, 236, 252 },
236 { 211, 144, 169, 237, 172, 255, 236, 252 },
237 { 212, 145, 170, 238, 173, 255, 237, 252 },
238 { 213, 145, 170, 238, 173, 255, 237, 252 },
239 { 214, 146, 171, 239, 174, 255, 237, 253 },
240 { 214, 146, 171, 239, 174, 255, 237, 253 },
241 { 215, 147, 172, 240, 175, 255, 238, 253 },
242 { 215, 147, 172, 240, 175, 255, 238, 253 },
243 { 216, 148, 173, 240, 176, 255, 238, 253 },
244 { 217, 148, 173, 240, 176, 255, 238, 253 },
245 { 218, 149, 173, 241, 177, 255, 239, 253 },
246 { 218, 149, 173, 241, 178, 255, 239, 253 },
247 { 219, 150, 174, 241, 179, 255, 239, 253 },
248 { 219, 151, 174, 241, 179, 255, 239, 253 },
249 { 220, 152, 175, 242, 180, 255, 240, 253 },
250 { 221, 152, 175, 242, 180, 255, 240, 253 },
251 { 222, 153, 176, 242, 181, 255, 240, 253 },
252 { 222, 153, 176, 242, 181, 255, 240, 253 },
253 { 223, 154, 177, 243, 182, 255, 240, 253 },
254 { 223, 154, 177, 243, 182, 255, 240, 253 },
255 { 224, 155, 178, 244, 183, 255, 241, 253 },
256 { 224, 155, 178, 244, 183, 255, 241, 253 },
257 { 225, 156, 178, 244, 184, 255, 241, 253 },
258 { 225, 157, 178, 244, 184, 255, 241, 253 },
259 { 226, 158, 179, 244, 185, 255, 242, 253 },
260 { 227, 158, 179, 244, 185, 255, 242, 253 },
261 { 228, 159, 180, 245, 186, 255, 242, 253 },
262 { 228, 159, 180, 245, 186, 255, 242, 253 },
263 { 229, 160, 181, 245, 187, 255, 242, 253 },
264 { 229, 160, 181, 245, 187, 255, 242, 253 },
265 { 230, 161, 182, 246, 188, 255, 243, 253 },
266 { 230, 162, 182, 246, 188, 255, 243, 253 },
267 { 231, 163, 183, 246, 189, 255, 243, 253 },
268 { 231, 163, 183, 246, 189, 255, 243, 253 },
269 { 232, 164, 184, 247, 190, 255, 243, 253 },
270 { 232, 164, 184, 247, 190, 255, 243, 253 },
271 { 233, 165, 185, 247, 191, 255, 244, 253 },
272 { 233, 165, 185, 247, 191, 255, 244, 253 },
273 { 234, 166, 185, 247, 192, 255, 244, 253 },
274 { 234, 167, 185, 247, 192, 255, 244, 253 },
275 { 235, 168, 186, 248, 193, 255, 244, 253 },
276 { 235, 168, 186, 248, 193, 255, 244, 253 },
277 { 236, 169, 187, 248, 194, 255, 244, 253 },
278 { 236, 169, 187, 248, 194, 255, 244, 253 },
279 { 236, 170, 188, 248, 195, 255, 245, 253 },
280 { 236, 170, 188, 248, 195, 255, 245, 253 },
281 { 237, 171, 189, 249, 196, 255, 245, 254 },
282 { 237, 172, 189, 249, 196, 255, 245, 254 },
283 { 238, 173, 190, 249, 197, 255, 245, 254 },
284 { 238, 173, 190, 249, 197, 255, 245, 254 },
285 { 239, 174, 191, 249, 198, 255, 245, 254 },
286 { 239, 174, 191, 249, 198, 255, 245, 254 },
287 { 240, 175, 192, 249, 199, 255, 246, 254 },
288 { 240, 176, 192, 249, 199, 255, 246, 254 },
289 { 240, 177, 193, 250, 200, 255, 246, 254 },
290 { 240, 177, 193, 250, 200, 255, 246, 254 },
291 { 241, 178, 194, 250, 201, 255, 246, 254 },
292 { 241, 178, 194, 250, 201, 255, 246, 254 },
293 { 242, 179, 195, 250, 202, 255, 246, 254 },
294 { 242, 180, 195, 250, 202, 255, 246, 254 },
295 { 242, 181, 196, 250, 203, 255, 247, 254 },
296 { 242, 181, 196, 250, 203, 255, 247, 254 },
297 { 243, 182, 197, 251, 204, 255, 247, 254 },
298 { 243, 183, 197, 251, 204, 255, 247, 254 },
299 { 244, 184, 198, 251, 205, 255, 247, 254 },
300 { 244, 184, 198, 251, 205, 255, 247, 254 },
301 { 244, 185, 199, 251, 206, 255, 247, 254 },
302 { 244, 185, 199, 251, 206, 255, 247, 254 },
303 { 245, 186, 200, 251, 207, 255, 247, 254 },
304 { 245, 187, 200, 251, 207, 255, 247, 254 },
305 { 246, 188, 201, 252, 207, 255, 248, 254 },
306 { 246, 188, 201, 252, 207, 255, 248, 254 },
307 { 246, 189, 202, 252, 208, 255, 248, 254 },
308 { 246, 190, 202, 252, 208, 255, 248, 254 },
309 { 247, 191, 203, 252, 209, 255, 248, 254 },
310 { 247, 191, 203, 252, 209, 255, 248, 254 },
311 { 247, 192, 204, 252, 210, 255, 248, 254 },
312 { 247, 193, 204, 252, 210, 255, 248, 254 },
313 { 248, 194, 205, 252, 211, 255, 248, 254 },
314 { 248, 194, 205, 252, 211, 255, 248, 254 },
315 { 248, 195, 206, 252, 212, 255, 249, 254 },
316 { 248, 196, 206, 252, 212, 255, 249, 254 },
317 { 249, 197, 207, 253, 213, 255, 249, 254 },
318 { 249, 197, 207, 253, 213, 255, 249, 254 },
319 { 249, 198, 208, 253, 214, 255, 249, 254 },
320 { 249, 199, 209, 253, 214, 255, 249, 254 },
321 { 250, 200, 210, 253, 215, 255, 249, 254 },
322 { 250, 200, 210, 253, 215, 255, 249, 254 },
323 { 250, 201, 211, 253, 215, 255, 249, 254 },
324 { 250, 202, 211, 253, 215, 255, 249, 254 },
325 { 250, 203, 212, 253, 216, 255, 249, 254 },
326 { 250, 203, 212, 253, 216, 255, 249, 254 },
327 { 251, 204, 213, 253, 217, 255, 250, 254 },
328 { 251, 205, 213, 253, 217, 255, 250, 254 },
329 { 251, 206, 214, 254, 218, 255, 250, 254 },
330 { 251, 206, 215, 254, 218, 255, 250, 254 },
331 { 252, 207, 216, 254, 219, 255, 250, 254 },
332 { 252, 208, 216, 254, 219, 255, 250, 254 },
333 { 252, 209, 217, 254, 220, 255, 250, 254 },
334 { 252, 210, 217, 254, 220, 255, 250, 254 },
335 { 252, 211, 218, 254, 221, 255, 250, 254 },
336 { 252, 212, 218, 254, 221, 255, 250, 254 },
337 { 253, 213, 219, 254, 222, 255, 250, 254 },
338 { 253, 213, 220, 254, 222, 255, 250, 254 },
339 { 253, 214, 221, 254, 223, 255, 250, 254 },
340 { 253, 215, 221, 254, 223, 255, 250, 254 },
341 { 253, 216, 222, 254, 224, 255, 251, 254 },
342 { 253, 217, 223, 254, 224, 255, 251, 254 },
343 { 253, 218, 224, 254, 225, 255, 251, 254 },
344 { 253, 219, 224, 254, 225, 255, 251, 254 },
345 { 254, 220, 225, 254, 225, 255, 251, 254 },
346 { 254, 221, 226, 254, 225, 255, 251, 254 },
347 { 254, 222, 227, 255, 226, 255, 251, 254 },
348 { 254, 223, 227, 255, 226, 255, 251, 254 },
349 { 254, 224, 228, 255, 227, 255, 251, 254 },
350 { 254, 225, 229, 255, 227, 255, 251, 254 },
351 { 254, 226, 230, 255, 228, 255, 251, 254 },
352 { 254, 227, 230, 255, 229, 255, 251, 254 },
353 { 255, 228, 231, 255, 230, 255, 251, 254 },
354 { 255, 229, 232, 255, 230, 255, 251, 254 },
355 { 255, 230, 233, 255, 231, 255, 252, 254 },
356 { 255, 231, 234, 255, 231, 255, 252, 254 },
357 { 255, 232, 235, 255, 232, 255, 252, 254 },
358 { 255, 233, 236, 255, 232, 255, 252, 254 },
359 { 255, 235, 237, 255, 233, 255, 252, 254 },
360 { 255, 236, 238, 255, 234, 255, 252, 254 },
361 { 255, 238, 240, 255, 235, 255, 252, 255 },
362 { 255, 239, 241, 255, 235, 255, 252, 254 },
363 { 255, 241, 243, 255, 236, 255, 252, 254 },
364 { 255, 243, 245, 255, 237, 255, 252, 254 },
365 { 255, 246, 247, 255, 239, 255, 253, 255 },
366 };
367
368 static const vp9_coeff_probs_model default_coef_probs_4x4[PLANE_TYPES] = {
369 { // Y plane
370 { // Intra
371 { // Band 0
372 { 195, 29, 183 },
373 { 84, 49, 136 },
374 { 8, 42, 71 } },
375 { // Band 1
376 { 31, 107, 169 },
377 { 35, 99, 159 },
378 { 17, 82, 140 },
379 { 8, 66, 114 },
380 { 2, 44, 76 },
381 { 1, 19, 32 } },
382 { // Band 2
383 { 40, 132, 201 },
384 { 29, 114, 187 },
385 { 13, 91, 157 },
386 { 7, 75, 127 },
387 { 3, 58, 95 },
388 { 1, 28, 47 } },
389 { // Band 3
390 { 69, 142, 221 },
391 { 42, 122, 201 },
392 { 15, 91, 159 },
393 { 6, 67, 121 },
394 { 1, 42, 77 },
395 { 1, 17, 31 } },
396 { // Band 4
397 { 102, 148, 228 },
398 { 67, 117, 204 },
399 { 17, 82, 154 },
400 { 6, 59, 114 },
401 { 2, 39, 75 },
402 { 1, 15, 29 } },
403 { // Band 5
404 { 156, 57, 233 },
405 { 119, 57, 212 },
406 { 58, 48, 163 },
407 { 29, 40, 124 },
408 { 12, 30, 81 },
409 { 3, 12, 31 } } },
410 { // Inter
411 { // Band 0
412 { 191, 107, 226 },
413 { 124, 117, 204 },
414 { 25, 99, 155 } },
415 { // Band 1
416 { 29, 148, 210 },
417 { 37, 126, 194 },
418 { 8, 93, 157 },
419 { 2, 68, 118 },
420 { 1, 39, 69 },
421 { 1, 17, 33 } },
422 { // Band 2
423 { 41, 151, 213 },
424 { 27, 123, 193 },
425 { 3, 82, 144 },
426 { 1, 58, 105 },
427 { 1, 32, 60 },
428 { 1, 13, 26 } },
429 { // Band 3
430 { 59, 159, 220 },
431 { 23, 126, 198 },
432 { 4, 88, 151 },
433 { 1, 66, 114 },
434 { 1, 38, 71 },
435 { 1, 18, 34 } },
436 { // Band 4
437 { 114, 136, 232 },
438 { 51, 114, 207 },
439 { 11, 83, 155 },
440 { 3, 56, 105 },
441 { 1, 33, 65 },
442 { 1, 17, 34 } },
443 { // Band 5
444 { 149, 65, 234 },
445 { 121, 57, 215 },
446 { 61, 49, 166 },
447 { 28, 36, 114 },
448 { 12, 25, 76 },
449 { 3, 16, 42 } } } },
450 { // UV plane
451 { // Intra
452 { // Band 0
453 { 214, 49, 220 },
454 { 132, 63, 188 },
455 { 42, 65, 137 } },
456 { // Band 1
457 { 85, 137, 221 },
458 { 104, 131, 216 },
459 { 49, 111, 192 },
460 { 21, 87, 155 },
461 { 2, 49, 87 },
462 { 1, 16, 28 } },
463 { // Band 2
464 { 89, 163, 230 },
465 { 90, 137, 220 },
466 { 29, 100, 183 },
467 { 10, 70, 135 },
468 { 2, 42, 81 },
469 { 1, 17, 33 } },
470 { // Band 3
471 { 108, 167, 237 },
472 { 55, 133, 222 },
473 { 15, 97, 179 },
474 { 4, 72, 135 },
475 { 1, 45, 85 },
476 { 1, 19, 38 } },
477 { // Band 4
478 { 124, 146, 240 },
479 { 66, 124, 224 },
480 { 17, 88, 175 },
481 { 4, 58, 122 },
482 { 1, 36, 75 },
483 { 1, 18, 37 } },
484 { // Band 5
485 { 141, 79, 241 },
486 { 126, 70, 227 },
487 { 66, 58, 182 },
488 { 30, 44, 136 },
489 { 12, 34, 96 },
490 { 2, 20, 47 } } },
491 { // Inter
492 { // Band 0
493 { 229, 99, 249 },
494 { 143, 111, 235 },
495 { 46, 109, 192 } },
496 { // Band 1
497 { 82, 158, 236 },
498 { 94, 146, 224 },
499 { 25, 117, 191 },
500 { 9, 87, 149 },
501 { 3, 56, 99 },
502 { 1, 33, 57 } },
503 { // Band 2
504 { 83, 167, 237 },
505 { 68, 145, 222 },
506 { 10, 103, 177 },
507 { 2, 72, 131 },
508 { 1, 41, 79 },
509 { 1, 20, 39 } },
510 { // Band 3
511 { 99, 167, 239 },
512 { 47, 141, 224 },
513 { 10, 104, 178 },
514 { 2, 73, 133 },
515 { 1, 44, 85 },
516 { 1, 22, 47 } },
517 { // Band 4
518 { 127, 145, 243 },
519 { 71, 129, 228 },
520 { 17, 93, 177 },
521 { 3, 61, 124 },
522 { 1, 41, 84 },
523 { 1, 21, 52 } },
524 { // Band 5
525 { 157, 78, 244 },
526 { 140, 72, 231 },
527 { 69, 58, 184 },
528 { 31, 44, 137 },
529 { 14, 38, 105 },
530 { 8, 23, 61 } } } }
531 };
532
533 static const vp9_coeff_probs_model default_coef_probs_8x8[PLANE_TYPES] = {
534 { // Y plane
535 { // Intra
536 { // Band 0
537 { 125, 34, 187 },
538 { 52, 41, 133 },
539 { 6, 31, 56 } },
540 { // Band 1
541 { 37, 109, 153 },
542 { 51, 102, 147 },
543 { 23, 87, 128 },
544 { 8, 67, 101 },
545 { 1, 41, 63 },
546 { 1, 19, 29 } },
547 { // Band 2
548 { 31, 154, 185 },
549 { 17, 127, 175 },
550 { 6, 96, 145 },
551 { 2, 73, 114 },
552 { 1, 51, 82 },
553 { 1, 28, 45 } },
554 { // Band 3
555 { 23, 163, 200 },
556 { 10, 131, 185 },
557 { 2, 93, 148 },
558 { 1, 67, 111 },
559 { 1, 41, 69 },
560 { 1, 14, 24 } },
561 { // Band 4
562 { 29, 176, 217 },
563 { 12, 145, 201 },
564 { 3, 101, 156 },
565 { 1, 69, 111 },
566 { 1, 39, 63 },
567 { 1, 14, 23 } },
568 { // Band 5
569 { 57, 192, 233 },
570 { 25, 154, 215 },
571 { 6, 109, 167 },
572 { 3, 78, 118 },
573 { 1, 48, 69 },
574 { 1, 21, 29 } } },
575 { // Inter
576 { // Band 0
577 { 202, 105, 245 },
578 { 108, 106, 216 },
579 { 18, 90, 144 } },
580 { // Band 1
581 { 33, 172, 219 },
582 { 64, 149, 206 },
583 { 14, 117, 177 },
584 { 5, 90, 141 },
585 { 2, 61, 95 },
586 { 1, 37, 57 } },
587 { // Band 2
588 { 33, 179, 220 },
589 { 11, 140, 198 },
590 { 1, 89, 148 },
591 { 1, 60, 104 },
592 { 1, 33, 57 },
593 { 1, 12, 21 } },
594 { // Band 3
595 { 30, 181, 221 },
596 { 8, 141, 198 },
597 { 1, 87, 145 },
598 { 1, 58, 100 },
599 { 1, 31, 55 },
600 { 1, 12, 20 } },
601 { // Band 4
602 { 32, 186, 224 },
603 { 7, 142, 198 },
604 { 1, 86, 143 },
605 { 1, 58, 100 },
606 { 1, 31, 55 },
607 { 1, 12, 22 } },
608 { // Band 5
609 { 57, 192, 227 },
610 { 20, 143, 204 },
611 { 3, 96, 154 },
612 { 1, 68, 112 },
613 { 1, 42, 69 },
614 { 1, 19, 32 } } } },
615 { // UV plane
616 { // Intra
617 { // Band 0
618 { 212, 35, 215 },
619 { 113, 47, 169 },
620 { 29, 48, 105 } },
621 { // Band 1
622 { 74, 129, 203 },
623 { 106, 120, 203 },
624 { 49, 107, 178 },
625 { 19, 84, 144 },
626 { 4, 50, 84 },
627 { 1, 15, 25 } },
628 { // Band 2
629 { 71, 172, 217 },
630 { 44, 141, 209 },
631 { 15, 102, 173 },
632 { 6, 76, 133 },
633 { 2, 51, 89 },
634 { 1, 24, 42 } },
635 { // Band 3
636 { 64, 185, 231 },
637 { 31, 148, 216 },
638 { 8, 103, 175 },
639 { 3, 74, 131 },
640 { 1, 46, 81 },
641 { 1, 18, 30 } },
642 { // Band 4
643 { 65, 196, 235 },
644 { 25, 157, 221 },
645 { 5, 105, 174 },
646 { 1, 67, 120 },
647 { 1, 38, 69 },
648 { 1, 15, 30 } },
649 { // Band 5
650 { 65, 204, 238 },
651 { 30, 156, 224 },
652 { 7, 107, 177 },
653 { 2, 70, 124 },
654 { 1, 42, 73 },
655 { 1, 18, 34 } } },
656 { // Inter
657 { // Band 0
658 { 225, 86, 251 },
659 { 144, 104, 235 },
660 { 42, 99, 181 } },
661 { // Band 1
662 { 85, 175, 239 },
663 { 112, 165, 229 },
664 { 29, 136, 200 },
665 { 12, 103, 162 },
666 { 6, 77, 123 },
667 { 2, 53, 84 } },
668 { // Band 2
669 { 75, 183, 239 },
670 { 30, 155, 221 },
671 { 3, 106, 171 },
672 { 1, 74, 128 },
673 { 1, 44, 76 },
674 { 1, 17, 28 } },
675 { // Band 3
676 { 73, 185, 240 },
677 { 27, 159, 222 },
678 { 2, 107, 172 },
679 { 1, 75, 127 },
680 { 1, 42, 73 },
681 { 1, 17, 29 } },
682 { // Band 4
683 { 62, 190, 238 },
684 { 21, 159, 222 },
685 { 2, 107, 172 },
686 { 1, 72, 122 },
687 { 1, 40, 71 },
688 { 1, 18, 32 } },
689 { // Band 5
690 { 61, 199, 240 },
691 { 27, 161, 226 },
692 { 4, 113, 180 },
693 { 1, 76, 129 },
694 { 1, 46, 80 },
695 { 1, 23, 41 } } } }
696 };
697
698 static const vp9_coeff_probs_model default_coef_probs_16x16[PLANE_TYPES] = {
699 { // Y plane
700 { // Intra
701 { // Band 0
702 { 7, 27, 153 },
703 { 5, 30, 95 },
704 { 1, 16, 30 } },
705 { // Band 1
706 { 50, 75, 127 },
707 { 57, 75, 124 },
708 { 27, 67, 108 },
709 { 10, 54, 86 },
710 { 1, 33, 52 },
711 { 1, 12, 18 } },
712 { // Band 2
713 { 43, 125, 151 },
714 { 26, 108, 148 },
715 { 7, 83, 122 },
716 { 2, 59, 89 },
717 { 1, 38, 60 },
718 { 1, 17, 27 } },
719 { // Band 3
720 { 23, 144, 163 },
721 { 13, 112, 154 },
722 { 2, 75, 117 },
723 { 1, 50, 81 },
724 { 1, 31, 51 },
725 { 1, 14, 23 } },
726 { // Band 4
727 { 18, 162, 185 },
728 { 6, 123, 171 },
729 { 1, 78, 125 },
730 { 1, 51, 86 },
731 { 1, 31, 54 },
732 { 1, 14, 23 } },
733 { // Band 5
734 { 15, 199, 227 },
735 { 3, 150, 204 },
736 { 1, 91, 146 },
737 { 1, 55, 95 },
738 { 1, 30, 53 },
739 { 1, 11, 20 } } },
740 { // Inter
741 { // Band 0
742 { 19, 55, 240 },
743 { 19, 59, 196 },
744 { 3, 52, 105 } },
745 { // Band 1
746 { 41, 166, 207 },
747 { 104, 153, 199 },
748 { 31, 123, 181 },
749 { 14, 101, 152 },
750 { 5, 72, 106 },
751 { 1, 36, 52 } },
752 { // Band 2
753 { 35, 176, 211 },
754 { 12, 131, 190 },
755 { 2, 88, 144 },
756 { 1, 60, 101 },
757 { 1, 36, 60 },
758 { 1, 16, 28 } },
759 { // Band 3
760 { 28, 183, 213 },
761 { 8, 134, 191 },
762 { 1, 86, 142 },
763 { 1, 56, 96 },
764 { 1, 30, 53 },
765 { 1, 12, 20 } },
766 { // Band 4
767 { 20, 190, 215 },
768 { 4, 135, 192 },
769 { 1, 84, 139 },
770 { 1, 53, 91 },
771 { 1, 28, 49 },
772 { 1, 11, 20 } },
773 { // Band 5
774 { 13, 196, 216 },
775 { 2, 137, 192 },
776 { 1, 86, 143 },
777 { 1, 57, 99 },
778 { 1, 32, 56 },
779 { 1, 13, 24 } } } },
780 { // UV plane
781 { // Intra
782 { // Band 0
783 { 211, 29, 217 },
784 { 96, 47, 156 },
785 { 22, 43, 87 } },
786 { // Band 1
787 { 78, 120, 193 },
788 { 111, 116, 186 },
789 { 46, 102, 164 },
790 { 15, 80, 128 },
791 { 2, 49, 76 },
792 { 1, 18, 28 } },
793 { // Band 2
794 { 71, 161, 203 },
795 { 42, 132, 192 },
796 { 10, 98, 150 },
797 { 3, 69, 109 },
798 { 1, 44, 70 },
799 { 1, 18, 29 } },
800 { // Band 3
801 { 57, 186, 211 },
802 { 30, 140, 196 },
803 { 4, 93, 146 },
804 { 1, 62, 102 },
805 { 1, 38, 65 },
806 { 1, 16, 27 } },
807 { // Band 4
808 { 47, 199, 217 },
809 { 14, 145, 196 },
810 { 1, 88, 142 },
811 { 1, 57, 98 },
812 { 1, 36, 62 },
813 { 1, 15, 26 } },
814 { // Band 5
815 { 26, 219, 229 },
816 { 5, 155, 207 },
817 { 1, 94, 151 },
818 { 1, 60, 104 },
819 { 1, 36, 62 },
820 { 1, 16, 28 } } },
821 { // Inter
822 { // Band 0
823 { 233, 29, 248 },
824 { 146, 47, 220 },
825 { 43, 52, 140 } },
826 { // Band 1
827 { 100, 163, 232 },
828 { 179, 161, 222 },
829 { 63, 142, 204 },
830 { 37, 113, 174 },
831 { 26, 89, 137 },
832 { 18, 68, 97 } },
833 { // Band 2
834 { 85, 181, 230 },
835 { 32, 146, 209 },
836 { 7, 100, 164 },
837 { 3, 71, 121 },
838 { 1, 45, 77 },
839 { 1, 18, 30 } },
840 { // Band 3
841 { 65, 187, 230 },
842 { 20, 148, 207 },
843 { 2, 97, 159 },
844 { 1, 68, 116 },
845 { 1, 40, 70 },
846 { 1, 14, 29 } },
847 { // Band 4
848 { 40, 194, 227 },
849 { 8, 147, 204 },
850 { 1, 94, 155 },
851 { 1, 65, 112 },
852 { 1, 39, 66 },
853 { 1, 14, 26 } },
854 { // Band 5
855 { 16, 208, 228 },
856 { 3, 151, 207 },
857 { 1, 98, 160 },
858 { 1, 67, 117 },
859 { 1, 41, 74 },
860 { 1, 17, 31 } } } }
861 };
862
863 static const vp9_coeff_probs_model default_coef_probs_32x32[PLANE_TYPES] = {
864 { // Y plane
865 { // Intra
866 { // Band 0
867 { 17, 38, 140 },
868 { 7, 34, 80 },
869 { 1, 17, 29 } },
870 { // Band 1
871 { 37, 75, 128 },
872 { 41, 76, 128 },
873 { 26, 66, 116 },
874 { 12, 52, 94 },
875 { 2, 32, 55 },
876 { 1, 10, 16 } },
877 { // Band 2
878 { 50, 127, 154 },
879 { 37, 109, 152 },
880 { 16, 82, 121 },
881 { 5, 59, 85 },
882 { 1, 35, 54 },
883 { 1, 13, 20 } },
884 { // Band 3
885 { 40, 142, 167 },
886 { 17, 110, 157 },
887 { 2, 71, 112 },
888 { 1, 44, 72 },
889 { 1, 27, 45 },
890 { 1, 11, 17 } },
891 { // Band 4
892 { 30, 175, 188 },
893 { 9, 124, 169 },
894 { 1, 74, 116 },
895 { 1, 48, 78 },
896 { 1, 30, 49 },
897 { 1, 11, 18 } },
898 { // Band 5
899 { 10, 222, 223 },
900 { 2, 150, 194 },
901 { 1, 83, 128 },
902 { 1, 48, 79 },
903 { 1, 27, 45 },
904 { 1, 11, 17 } } },
905 { // Inter
906 { // Band 0
907 { 36, 41, 235 },
908 { 29, 36, 193 },
909 { 10, 27, 111 } },
910 { // Band 1
911 { 85, 165, 222 },
912 { 177, 162, 215 },
913 { 110, 135, 195 },
914 { 57, 113, 168 },
915 { 23, 83, 120 },
916 { 10, 49, 61 } },
917 { // Band 2
918 { 85, 190, 223 },
919 { 36, 139, 200 },
920 { 5, 90, 146 },
921 { 1, 60, 103 },
922 { 1, 38, 65 },
923 { 1, 18, 30 } },
924 { // Band 3
925 { 72, 202, 223 },
926 { 23, 141, 199 },
927 { 2, 86, 140 },
928 { 1, 56, 97 },
929 { 1, 36, 61 },
930 { 1, 16, 27 } },
931 { // Band 4
932 { 55, 218, 225 },
933 { 13, 145, 200 },
934 { 1, 86, 141 },
935 { 1, 57, 99 },
936 { 1, 35, 61 },
937 { 1, 13, 22 } },
938 { // Band 5
939 { 15, 235, 212 },
940 { 1, 132, 184 },
941 { 1, 84, 139 },
942 { 1, 57, 97 },
943 { 1, 34, 56 },
944 { 1, 14, 23 } } } },
945 { // UV plane
946 { // Intra
947 { // Band 0
948 { 181, 21, 201 },
949 { 61, 37, 123 },
950 { 10, 38, 71 } },
951 { // Band 1
952 { 47, 106, 172 },
953 { 95, 104, 173 },
954 { 42, 93, 159 },
955 { 18, 77, 131 },
956 { 4, 50, 81 },
957 { 1, 17, 23 } },
958 { // Band 2
959 { 62, 147, 199 },
960 { 44, 130, 189 },
961 { 28, 102, 154 },
962 { 18, 75, 115 },
963 { 2, 44, 65 },
964 { 1, 12, 19 } },
965 { // Band 3
966 { 55, 153, 210 },
967 { 24, 130, 194 },
968 { 3, 93, 146 },
969 { 1, 61, 97 },
970 { 1, 31, 50 },
971 { 1, 10, 16 } },
972 { // Band 4
973 { 49, 186, 223 },
974 { 17, 148, 204 },
975 { 1, 96, 142 },
976 { 1, 53, 83 },
977 { 1, 26, 44 },
978 { 1, 11, 17 } },
979 { // Band 5
980 { 13, 217, 212 },
981 { 2, 136, 180 },
982 { 1, 78, 124 },
983 { 1, 50, 83 },
984 { 1, 29, 49 },
985 { 1, 14, 23 } } },
986 { // Inter
987 { // Band 0
988 { 197, 13, 247 },
989 { 82, 17, 222 },
990 { 25, 17, 162 } },
991 { // Band 1
992 { 126, 186, 247 },
993 { 234, 191, 243 },
994 { 176, 177, 234 },
995 { 104, 158, 220 },
996 { 66, 128, 186 },
997 { 55, 90, 137 } },
998 { // Band 2
999 { 111, 197, 242 },
1000 { 46, 158, 219 },
1001 { 9, 104, 171 },
1002 { 2, 65, 125 },
1003 { 1, 44, 80 },
1004 { 1, 17, 91 } },
1005 { // Band 3
1006 { 104, 208, 245 },
1007 { 39, 168, 224 },
1008 { 3, 109, 162 },
1009 { 1, 79, 124 },
1010 { 1, 50, 102 },
1011 { 1, 43, 102 } },
1012 { // Band 4
1013 { 84, 220, 246 },
1014 { 31, 177, 231 },
1015 { 2, 115, 180 },
1016 { 1, 79, 134 },
1017 { 1, 55, 77 },
1018 { 1, 60, 79 } },
1019 { // Band 5
1020 { 43, 243, 240 },
1021 { 8, 180, 217 },
1022 { 1, 115, 166 },
1023 { 1, 84, 121 },
1024 { 1, 51, 67 },
1025 { 1, 16, 6 } } } }
1026 };
1027
extend_to_full_distribution(vpx_prob * probs,vpx_prob p)1028 static void extend_to_full_distribution(vpx_prob *probs, vpx_prob p) {
1029 assert(p != 0);
1030 memcpy(probs, vp9_pareto8_full[p - 1], MODEL_NODES * sizeof(vpx_prob));
1031 }
1032
vp9_model_to_full_probs(const vpx_prob * model,vpx_prob * full)1033 void vp9_model_to_full_probs(const vpx_prob *model, vpx_prob *full) {
1034 if (full != model)
1035 memcpy(full, model, sizeof(vpx_prob) * UNCONSTRAINED_NODES);
1036 extend_to_full_distribution(&full[UNCONSTRAINED_NODES], model[PIVOT_NODE]);
1037 }
1038
vp9_default_coef_probs(VP9_COMMON * cm)1039 void vp9_default_coef_probs(VP9_COMMON *cm) {
1040 vp9_copy(cm->fc->coef_probs[TX_4X4], default_coef_probs_4x4);
1041 vp9_copy(cm->fc->coef_probs[TX_8X8], default_coef_probs_8x8);
1042 vp9_copy(cm->fc->coef_probs[TX_16X16], default_coef_probs_16x16);
1043 vp9_copy(cm->fc->coef_probs[TX_32X32], default_coef_probs_32x32);
1044 }
1045
1046 #define COEF_COUNT_SAT 24
1047 #define COEF_MAX_UPDATE_FACTOR 112
1048 #define COEF_COUNT_SAT_KEY 24
1049 #define COEF_MAX_UPDATE_FACTOR_KEY 112
1050 #define COEF_COUNT_SAT_AFTER_KEY 24
1051 #define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
1052
adapt_coef_probs(VP9_COMMON * cm,TX_SIZE tx_size,unsigned int count_sat,unsigned int update_factor)1053 static void adapt_coef_probs(VP9_COMMON *cm, TX_SIZE tx_size,
1054 unsigned int count_sat,
1055 unsigned int update_factor) {
1056 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
1057 vp9_coeff_probs_model *const probs = cm->fc->coef_probs[tx_size];
1058 const vp9_coeff_probs_model *const pre_probs = pre_fc->coef_probs[tx_size];
1059 vp9_coeff_count_model *counts = cm->counts.coef[tx_size];
1060 unsigned int(*eob_counts)[REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] =
1061 cm->counts.eob_branch[tx_size];
1062 int i, j, k, l, m;
1063
1064 for (i = 0; i < PLANE_TYPES; ++i)
1065 for (j = 0; j < REF_TYPES; ++j)
1066 for (k = 0; k < COEF_BANDS; ++k)
1067 for (l = 0; l < BAND_COEFF_CONTEXTS(k); ++l) {
1068 const int n0 = counts[i][j][k][l][ZERO_TOKEN];
1069 const int n1 = counts[i][j][k][l][ONE_TOKEN];
1070 const int n2 = counts[i][j][k][l][TWO_TOKEN];
1071 const int neob = counts[i][j][k][l][EOB_MODEL_TOKEN];
1072 const unsigned int branch_ct[UNCONSTRAINED_NODES][2] = {
1073 { neob, eob_counts[i][j][k][l] - neob }, { n0, n1 + n2 }, { n1, n2 }
1074 };
1075 for (m = 0; m < UNCONSTRAINED_NODES; ++m)
1076 probs[i][j][k][l][m] =
1077 merge_probs(pre_probs[i][j][k][l][m], branch_ct[m], count_sat,
1078 update_factor);
1079 }
1080 }
1081
vp9_adapt_coef_probs(VP9_COMMON * cm)1082 void vp9_adapt_coef_probs(VP9_COMMON *cm) {
1083 TX_SIZE t;
1084 unsigned int count_sat, update_factor;
1085
1086 if (frame_is_intra_only(cm)) {
1087 update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
1088 count_sat = COEF_COUNT_SAT_KEY;
1089 } else if (cm->last_frame_type == KEY_FRAME) {
1090 update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
1091 count_sat = COEF_COUNT_SAT_AFTER_KEY;
1092 } else {
1093 update_factor = COEF_MAX_UPDATE_FACTOR;
1094 count_sat = COEF_COUNT_SAT;
1095 }
1096 for (t = TX_4X4; t <= TX_32X32; t++)
1097 adapt_coef_probs(cm, t, count_sat, update_factor);
1098 }
1099