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