Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1200)

Side by Side Diff: source/libvpx/vp9/common/vp9_entropy.c

Issue 11555023: libvpx: Add VP9 decoder. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
12 #include <stdio.h>
13
14 #include "vp9/common/vp9_entropy.h"
15 #include "string.h"
16 #include "vp9/common/vp9_blockd.h"
17 #include "vp9/common/vp9_onyxc_int.h"
18 #include "vp9/common/vp9_entropymode.h"
19 #include "vpx_mem/vpx_mem.h"
20
21 #define uchar unsigned char /* typedefs can clash */
22 #define uint unsigned int
23
24 typedef const uchar cuchar;
25 typedef const uint cuint;
26
27 typedef vp9_prob Prob;
28
29 #include "vp9/common/vp9_coefupdateprobs.h"
30
31 const int vp9_i8x8_block[4] = {0, 2, 8, 10};
32
33 DECLARE_ALIGNED(16, const unsigned char, vp9_norm[256]) = {
34 0, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
35 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
36 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
37 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
38 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
39 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
41 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
42 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
43 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
45 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
47 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
48 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
49 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
50 };
51
52 DECLARE_ALIGNED(16, const int, vp9_coef_bands[16]) = {
53 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7
54 };
55
56 DECLARE_ALIGNED(16, cuchar, vp9_prev_token_class[MAX_ENTROPY_TOKENS]) = {
57 0, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 0
58 };
59
60 DECLARE_ALIGNED(16, const int, vp9_default_zig_zag1d[16]) = {
61 0, 1, 4, 8,
62 5, 2, 3, 6,
63 9, 12, 13, 10,
64 7, 11, 14, 15,
65 };
66
67 DECLARE_ALIGNED(16, const int, vp9_col_scan[16]) = {
68 0, 4, 8, 12,
69 1, 5, 9, 13,
70 2, 6, 10, 14,
71 3, 7, 11, 15
72 };
73 DECLARE_ALIGNED(16, const int, vp9_row_scan[16]) = {
74 0, 1, 2, 3,
75 4, 5, 6, 7,
76 8, 9, 10, 11,
77 12, 13, 14, 15
78 };
79
80
81 DECLARE_ALIGNED(64, const int, vp9_coef_bands_8x8[64]) = { 0, 1, 2, 3, 5, 4, 4, 5,
82 5, 3, 6, 3, 5, 4, 6, 6,
83 6, 5, 5, 6, 6, 6, 6, 6,
84 6, 6, 6, 6, 6, 6, 6, 6,
85 6, 6, 6, 6, 7, 7, 7, 7,
86 7, 7, 7, 7, 7, 7, 7, 7,
87 7, 7, 7, 7, 7, 7, 7, 7,
88 7, 7, 7, 7, 7, 7, 7, 7
89 };
90 DECLARE_ALIGNED(64, const int, vp9_default_zig_zag1d_8x8[64]) = {
91 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
92 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
93 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
94 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63,
95 };
96
97 // Table can be optimized.
98 DECLARE_ALIGNED(16, const int, vp9_coef_bands_16x16[256]) = {
99 0, 1, 2, 3, 5, 4, 4, 5, 5, 3, 6, 3, 5, 4, 6, 6,
100 6, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
101 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
102 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
103 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
104 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
105 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
106 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
107 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
108 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
109 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
110 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
111 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
112 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
113 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
114 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
115 };
116 DECLARE_ALIGNED(16, const int, vp9_default_zig_zag1d_16x16[256]) = {
117 0, 1, 16, 32, 17, 2, 3, 18, 33, 48, 64, 49, 34, 19, 4, 5,
118 20, 35, 50, 65, 80, 96, 81, 66, 51, 36, 21, 6, 7, 22, 37, 52,
119 67, 82, 97, 112, 128, 113, 98, 83, 68, 53, 38, 23, 8, 9, 24, 39,
120 54, 69, 84, 99, 114, 129, 144, 160, 145, 130, 115, 100, 85, 70, 55, 40,
121 25, 10, 11, 26, 41, 56, 71, 86, 101, 116, 131, 146, 161, 176, 192, 1 77,
122 162, 147, 132, 117, 102, 87, 72, 57, 42, 27, 12, 13, 28, 43, 58, 73,
123 88, 103, 118, 133, 148, 163, 178, 193, 208, 224, 209, 194, 179, 164, 149, 1 34,
124 119, 104, 89, 74, 59, 44, 29, 14, 15, 30, 45, 60, 75, 90, 105, 1 20,
125 135, 150, 165, 180, 195, 210, 225, 240, 241, 226, 211, 196, 181, 166, 151, 1 36,
126 121, 106, 91, 76, 61, 46, 31, 47, 62, 77, 92, 107, 122, 137, 152, 1 67,
127 182, 197, 212, 227, 242, 243, 228, 213, 198, 183, 168, 153, 138, 123, 108, 93,
128 78, 63, 79, 94, 109, 124, 139, 154, 169, 184, 199, 214, 229, 244, 245, 2 30,
129 215, 200, 185, 170, 155, 140, 125, 110, 95, 111, 126, 141, 156, 171, 186, 2 01,
130 216, 231, 246, 247, 232, 217, 202, 187, 172, 157, 142, 127, 143, 158, 173, 1 88,
131 203, 218, 233, 248, 249, 234, 219, 204, 189, 174, 159, 175, 190, 205, 220, 2 35,
132 250, 251, 236, 221, 206, 191, 207, 222, 237, 252, 253, 238, 223, 239, 254, 2 55,
133 };
134
135
136 /* Array indices are identical to previously-existing CONTEXT_NODE indices */
137
138 const vp9_tree_index vp9_coef_tree[ 22] = /* corresponding _CONTEXT_NODEs */
139 {
140 -DCT_EOB_TOKEN, 2, /* 0 = EOB */
141 -ZERO_TOKEN, 4, /* 1 = ZERO */
142 -ONE_TOKEN, 6, /* 2 = ONE */
143 8, 12, /* 3 = LOW_VAL */
144 -TWO_TOKEN, 10, /* 4 = TWO */
145 -THREE_TOKEN, -FOUR_TOKEN, /* 5 = THREE */
146 14, 16, /* 6 = HIGH_LOW */
147 -DCT_VAL_CATEGORY1, -DCT_VAL_CATEGORY2, /* 7 = CAT_ONE */
148 18, 20, /* 8 = CAT_THREEFOUR */
149 -DCT_VAL_CATEGORY3, -DCT_VAL_CATEGORY4, /* 9 = CAT_THREE */
150 -DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6 /* 10 = CAT_FIVE */
151 };
152
153 struct vp9_token_struct vp9_coef_encodings[MAX_ENTROPY_TOKENS];
154
155 /* Trees for extra bits. Probabilities are constant and
156 do not depend on previously encoded bits */
157
158 static const Prob Pcat1[] = { 159};
159 static const Prob Pcat2[] = { 165, 145};
160 static const Prob Pcat3[] = { 173, 148, 140};
161 static const Prob Pcat4[] = { 176, 155, 140, 135};
162 static const Prob Pcat5[] = { 180, 157, 141, 134, 130};
163 static const Prob Pcat6[] =
164 { 254, 254, 252, 249, 243, 230, 196, 177, 153, 140, 133, 130, 129};
165
166 static vp9_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[26];
167
168 static void init_bit_tree(vp9_tree_index *p, int n) {
169 int i = 0;
170
171 while (++i < n) {
172 p[0] = p[1] = i << 1;
173 p += 2;
174 }
175
176 p[0] = p[1] = 0;
177 }
178
179 static void init_bit_trees() {
180 init_bit_tree(cat1, 1);
181 init_bit_tree(cat2, 2);
182 init_bit_tree(cat3, 3);
183 init_bit_tree(cat4, 4);
184 init_bit_tree(cat5, 5);
185 init_bit_tree(cat6, 13);
186 }
187
188 vp9_extra_bit_struct vp9_extra_bits[12] = {
189 { 0, 0, 0, 0},
190 { 0, 0, 0, 1},
191 { 0, 0, 0, 2},
192 { 0, 0, 0, 3},
193 { 0, 0, 0, 4},
194 { cat1, Pcat1, 1, 5},
195 { cat2, Pcat2, 2, 7},
196 { cat3, Pcat3, 3, 11},
197 { cat4, Pcat4, 4, 19},
198 { cat5, Pcat5, 5, 35},
199 { cat6, Pcat6, 13, 67},
200 { 0, 0, 0, 0}
201 };
202
203 #include "vp9/common/vp9_default_coef_probs.h"
204
205 void vp9_default_coef_probs(VP9_COMMON *pc) {
206 vpx_memcpy(pc->fc.coef_probs, default_coef_probs,
207 sizeof(pc->fc.coef_probs));
208 vpx_memcpy(pc->fc.hybrid_coef_probs, default_hybrid_coef_probs,
209 sizeof(pc->fc.hybrid_coef_probs));
210
211 vpx_memcpy(pc->fc.coef_probs_8x8, default_coef_probs_8x8,
212 sizeof(pc->fc.coef_probs_8x8));
213 vpx_memcpy(pc->fc.hybrid_coef_probs_8x8, default_hybrid_coef_probs_8x8,
214 sizeof(pc->fc.hybrid_coef_probs_8x8));
215
216 vpx_memcpy(pc->fc.coef_probs_16x16, default_coef_probs_16x16,
217 sizeof(pc->fc.coef_probs_16x16));
218 vpx_memcpy(pc->fc.hybrid_coef_probs_16x16,
219 default_hybrid_coef_probs_16x16,
220 sizeof(pc->fc.hybrid_coef_probs_16x16));
221 }
222
223 void vp9_coef_tree_initialize() {
224 init_bit_trees();
225 vp9_tokens_from_tree(vp9_coef_encodings, vp9_coef_tree);
226 }
227
228 // #define COEF_COUNT_TESTING
229
230 #define COEF_COUNT_SAT 24
231 #define COEF_MAX_UPDATE_FACTOR 112
232 #define COEF_COUNT_SAT_KEY 24
233 #define COEF_MAX_UPDATE_FACTOR_KEY 112
234 #define COEF_COUNT_SAT_AFTER_KEY 24
235 #define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
236
237 void vp9_adapt_coef_probs(VP9_COMMON *cm) {
238 int t, i, j, k, count;
239 unsigned int branch_ct[ENTROPY_NODES][2];
240 vp9_prob coef_probs[ENTROPY_NODES];
241 int update_factor; /* denominator 256 */
242 int factor;
243 int count_sat;
244
245 // printf("Frame type: %d\n", cm->frame_type);
246 if (cm->frame_type == KEY_FRAME) {
247 update_factor = COEF_MAX_UPDATE_FACTOR_KEY;
248 count_sat = COEF_COUNT_SAT_KEY;
249 } else if (cm->last_frame_type == KEY_FRAME) {
250 update_factor = COEF_MAX_UPDATE_FACTOR_AFTER_KEY; /* adapt quickly */
251 count_sat = COEF_COUNT_SAT_AFTER_KEY;
252 } else {
253 update_factor = COEF_MAX_UPDATE_FACTOR;
254 count_sat = COEF_COUNT_SAT;
255 }
256
257 #ifdef COEF_COUNT_TESTING
258 {
259 printf("static const unsigned int\ncoef_counts"
260 "[BLOCK_TYPES] [COEF_BANDS]"
261 "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
262 for (i = 0; i < BLOCK_TYPES; ++i) {
263 printf(" {\n");
264 for (j = 0; j < COEF_BANDS; ++j) {
265 printf(" {\n");
266 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
267 printf(" {");
268 for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
269 printf("%d, ", cm->fc.coef_counts[i][j][k][t]);
270 printf("},\n");
271 }
272 printf(" },\n");
273 }
274 printf(" },\n");
275 }
276 printf("};\n");
277 printf("static const unsigned int\ncoef_counts_8x8"
278 "[BLOCK_TYPES_8X8] [COEF_BANDS]"
279 "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
280 for (i = 0; i < BLOCK_TYPES_8X8; ++i) {
281 printf(" {\n");
282 for (j = 0; j < COEF_BANDS; ++j) {
283 printf(" {\n");
284 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
285 printf(" {");
286 for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
287 printf("%d, ", cm->fc.coef_counts_8x8[i][j][k][t]);
288 printf("},\n");
289 }
290 printf(" },\n");
291 }
292 printf(" },\n");
293 }
294 printf("};\n");
295 printf("static const unsigned int\nhybrid_coef_counts"
296 "[BLOCK_TYPES] [COEF_BANDS]"
297 "[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
298 for (i = 0; i < BLOCK_TYPES; ++i) {
299 printf(" {\n");
300 for (j = 0; j < COEF_BANDS; ++j) {
301 printf(" {\n");
302 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
303 printf(" {");
304 for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
305 printf("%d, ", cm->fc.hybrid_coef_counts[i][j][k][t]);
306 printf("},\n");
307 }
308 printf(" },\n");
309 }
310 printf(" },\n");
311 }
312 printf("};\n");
313 }
314 #endif
315
316 for (i = 0; i < BLOCK_TYPES; ++i)
317 for (j = 0; j < COEF_BANDS; ++j)
318 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
319 if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
320 continue;
321 vp9_tree_probs_from_distribution(
322 MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
323 coef_probs, branch_ct, cm->fc.coef_counts [i][j][k],
324 256, 1);
325 for (t = 0; t < ENTROPY_NODES; ++t) {
326 int prob;
327 count = branch_ct[t][0] + branch_ct[t][1];
328 count = count > count_sat ? count_sat : count;
329 factor = (update_factor * count / count_sat);
330 prob = ((int)cm->fc.pre_coef_probs[i][j][k][t] * (256 - factor) +
331 (int)coef_probs[t] * factor + 128) >> 8;
332 if (prob <= 0) cm->fc.coef_probs[i][j][k][t] = 1;
333 else if (prob > 255) cm->fc.coef_probs[i][j][k][t] = 255;
334 else cm->fc.coef_probs[i][j][k][t] = prob;
335 }
336 }
337
338 for (i = 0; i < BLOCK_TYPES; ++i)
339 for (j = 0; j < COEF_BANDS; ++j)
340 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
341 if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
342 continue;
343 vp9_tree_probs_from_distribution(
344 MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
345 coef_probs, branch_ct, cm->fc.hybrid_coef_counts [i][j][k],
346 256, 1);
347 for (t = 0; t < ENTROPY_NODES; ++t) {
348 int prob;
349 count = branch_ct[t][0] + branch_ct[t][1];
350 count = count > count_sat ? count_sat : count;
351 factor = (update_factor * count / count_sat);
352 prob = ((int)cm->fc.pre_hybrid_coef_probs[i][j][k][t] * (256 - factor) +
353 (int)coef_probs[t] * factor + 128) >> 8;
354 if (prob <= 0) cm->fc.hybrid_coef_probs[i][j][k][t] = 1;
355 else if (prob > 255) cm->fc.hybrid_coef_probs[i][j][k][t] = 255;
356 else cm->fc.hybrid_coef_probs[i][j][k][t] = prob;
357 }
358 }
359
360 for (i = 0; i < BLOCK_TYPES_8X8; ++i)
361 for (j = 0; j < COEF_BANDS; ++j)
362 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
363 if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
364 continue;
365 vp9_tree_probs_from_distribution(
366 MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
367 coef_probs, branch_ct, cm->fc.coef_counts_8x8 [i][j][k],
368 256, 1);
369 for (t = 0; t < ENTROPY_NODES; ++t) {
370 int prob;
371 count = branch_ct[t][0] + branch_ct[t][1];
372 count = count > count_sat ? count_sat : count;
373 factor = (update_factor * count / count_sat);
374 prob = ((int)cm->fc.pre_coef_probs_8x8[i][j][k][t] * (256 - factor) +
375 (int)coef_probs[t] * factor + 128) >> 8;
376 if (prob <= 0) cm->fc.coef_probs_8x8[i][j][k][t] = 1;
377 else if (prob > 255) cm->fc.coef_probs_8x8[i][j][k][t] = 255;
378 else cm->fc.coef_probs_8x8[i][j][k][t] = prob;
379 }
380 }
381
382 for (i = 0; i < BLOCK_TYPES_8X8; ++i)
383 for (j = 0; j < COEF_BANDS; ++j)
384 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
385 if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
386 continue;
387 vp9_tree_probs_from_distribution(
388 MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
389 coef_probs, branch_ct, cm->fc.hybrid_coef_counts_8x8 [i][j][k],
390 256, 1);
391 for (t = 0; t < ENTROPY_NODES; ++t) {
392 int prob;
393 count = branch_ct[t][0] + branch_ct[t][1];
394 count = count > count_sat ? count_sat : count;
395 factor = (update_factor * count / count_sat);
396 prob = ((int)cm->fc.pre_hybrid_coef_probs_8x8[i][j][k][t] *
397 (256 - factor) +
398 (int)coef_probs[t] * factor + 128) >> 8;
399 if (prob <= 0) cm->fc.hybrid_coef_probs_8x8[i][j][k][t] = 1;
400 else if (prob > 255) cm->fc.hybrid_coef_probs_8x8[i][j][k][t] = 255;
401 else cm->fc.hybrid_coef_probs_8x8[i][j][k][t] = prob;
402 }
403 }
404
405 for (i = 0; i < BLOCK_TYPES_16X16; ++i)
406 for (j = 0; j < COEF_BANDS; ++j)
407 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
408 if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
409 continue;
410 vp9_tree_probs_from_distribution(
411 MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
412 coef_probs, branch_ct, cm->fc.coef_counts_16x16[i][j][k], 256, 1);
413 for (t = 0; t < ENTROPY_NODES; ++t) {
414 int prob;
415 count = branch_ct[t][0] + branch_ct[t][1];
416 count = count > count_sat ? count_sat : count;
417 factor = (update_factor * count / count_sat);
418 prob = ((int)cm->fc.pre_coef_probs_16x16[i][j][k][t] *
419 (256 - factor) +
420 (int)coef_probs[t] * factor + 128) >> 8;
421 if (prob <= 0) cm->fc.coef_probs_16x16[i][j][k][t] = 1;
422 else if (prob > 255) cm->fc.coef_probs_16x16[i][j][k][t] = 255;
423 else cm->fc.coef_probs_16x16[i][j][k][t] = prob;
424 }
425 }
426
427 for (i = 0; i < BLOCK_TYPES_16X16; ++i)
428 for (j = 0; j < COEF_BANDS; ++j)
429 for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
430 if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
431 continue;
432 vp9_tree_probs_from_distribution(
433 MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
434 coef_probs, branch_ct, cm->fc.hybrid_coef_counts_16x16[i][j][k], 256, 1);
435 for (t = 0; t < ENTROPY_NODES; ++t) {
436 int prob;
437 count = branch_ct[t][0] + branch_ct[t][1];
438 count = count > count_sat ? count_sat : count;
439 factor = (update_factor * count / count_sat);
440 prob = ((int)cm->fc.pre_hybrid_coef_probs_16x16[i][j][k][t] * (256 - f actor) +
441 (int)coef_probs[t] * factor + 128) >> 8;
442 if (prob <= 0) cm->fc.hybrid_coef_probs_16x16[i][j][k][t] = 1;
443 else if (prob > 255) cm->fc.hybrid_coef_probs_16x16[i][j][k][t] = 255;
444 else cm->fc.hybrid_coef_probs_16x16[i][j][k][t] = prob;
445 }
446 }
447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698