OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 { 67, 6, 25, 204, 243, 158, 13, 21, 96 }, // y = h | 154 { 67, 6, 25, 204, 243, 158, 13, 21, 96 }, // y = h |
155 { 97, 5, 44, 131, 176, 139, 48, 68, 97 }, // y = d45 | 155 { 97, 5, 44, 131, 176, 139, 48, 68, 97 }, // y = d45 |
156 { 83, 5, 42, 156, 111, 152, 26, 49, 152 }, // y = d135 | 156 { 83, 5, 42, 156, 111, 152, 26, 49, 152 }, // y = d135 |
157 { 80, 5, 58, 178, 74, 83, 33, 62, 145 }, // y = d117 | 157 { 80, 5, 58, 178, 74, 83, 33, 62, 145 }, // y = d117 |
158 { 86, 5, 32, 154, 192, 168, 14, 22, 163 }, // y = d153 | 158 { 86, 5, 32, 154, 192, 168, 14, 22, 163 }, // y = d153 |
159 { 85, 5, 32, 156, 216, 148, 19, 29, 73 }, // y = d207 | 159 { 85, 5, 32, 156, 216, 148, 19, 29, 73 }, // y = d207 |
160 { 77, 7, 64, 116, 132, 122, 37, 126, 120 }, // y = d63 | 160 { 77, 7, 64, 116, 132, 122, 37, 126, 120 }, // y = d63 |
161 { 101, 21, 107, 181, 192, 103, 19, 67, 125 } // y = tm | 161 { 101, 21, 107, 181, 192, 103, 19, 67, 125 } // y = tm |
162 }; | 162 }; |
163 | 163 |
164 static const vp9_prob default_partition_probs[FRAME_TYPES][PARTITION_CONTEXTS] | 164 const vp9_prob vp9_kf_partition_probs[PARTITION_CONTEXTS] |
| 165 [PARTITION_TYPES - 1] = { |
| 166 // 8x8 -> 4x4 |
| 167 { 158, 97, 94 }, // a/l both not split |
| 168 { 93, 24, 99 }, // a split, l not split |
| 169 { 85, 119, 44 }, // l split, a not split |
| 170 { 62, 59, 67 }, // a/l both split |
| 171 // 16x16 -> 8x8 |
| 172 { 149, 53, 53 }, // a/l both not split |
| 173 { 94, 20, 48 }, // a split, l not split |
| 174 { 83, 53, 24 }, // l split, a not split |
| 175 { 52, 18, 18 }, // a/l both split |
| 176 // 32x32 -> 16x16 |
| 177 { 150, 40, 39 }, // a/l both not split |
| 178 { 78, 12, 26 }, // a split, l not split |
| 179 { 67, 33, 11 }, // l split, a not split |
| 180 { 24, 7, 5 }, // a/l both split |
| 181 // 64x64 -> 32x32 |
| 182 { 174, 35, 49 }, // a/l both not split |
| 183 { 68, 11, 27 }, // a split, l not split |
| 184 { 57, 15, 9 }, // l split, a not split |
| 185 { 12, 3, 3 }, // a/l both split |
| 186 }; |
| 187 |
| 188 static const vp9_prob default_partition_probs[PARTITION_CONTEXTS] |
165 [PARTITION_TYPES - 1] = { | 189 [PARTITION_TYPES - 1] = { |
166 { // frame_type = keyframe | 190 // 8x8 -> 4x4 |
167 // 8x8 -> 4x4 | 191 { 199, 122, 141 }, // a/l both not split |
168 { 158, 97, 94 }, // a/l both not split | 192 { 147, 63, 159 }, // a split, l not split |
169 { 93, 24, 99 }, // a split, l not split | 193 { 148, 133, 118 }, // l split, a not split |
170 { 85, 119, 44 }, // l split, a not split | 194 { 121, 104, 114 }, // a/l both split |
171 { 62, 59, 67 }, // a/l both split | 195 // 16x16 -> 8x8 |
172 // 16x16 -> 8x8 | 196 { 174, 73, 87 }, // a/l both not split |
173 { 149, 53, 53 }, // a/l both not split | 197 { 92, 41, 83 }, // a split, l not split |
174 { 94, 20, 48 }, // a split, l not split | 198 { 82, 99, 50 }, // l split, a not split |
175 { 83, 53, 24 }, // l split, a not split | 199 { 53, 39, 39 }, // a/l both split |
176 { 52, 18, 18 }, // a/l both split | 200 // 32x32 -> 16x16 |
177 // 32x32 -> 16x16 | 201 { 177, 58, 59 }, // a/l both not split |
178 { 150, 40, 39 }, // a/l both not split | 202 { 68, 26, 63 }, // a split, l not split |
179 { 78, 12, 26 }, // a split, l not split | 203 { 52, 79, 25 }, // l split, a not split |
180 { 67, 33, 11 }, // l split, a not split | 204 { 17, 14, 12 }, // a/l both split |
181 { 24, 7, 5 }, // a/l both split | 205 // 64x64 -> 32x32 |
182 // 64x64 -> 32x32 | 206 { 222, 34, 30 }, // a/l both not split |
183 { 174, 35, 49 }, // a/l both not split | 207 { 72, 16, 44 }, // a split, l not split |
184 { 68, 11, 27 }, // a split, l not split | 208 { 58, 32, 12 }, // l split, a not split |
185 { 57, 15, 9 }, // l split, a not split | 209 { 10, 7, 6 }, // a/l both split |
186 { 12, 3, 3 }, // a/l both split | |
187 }, { // frame_type = interframe | |
188 // 8x8 -> 4x4 | |
189 { 199, 122, 141 }, // a/l both not split | |
190 { 147, 63, 159 }, // a split, l not split | |
191 { 148, 133, 118 }, // l split, a not split | |
192 { 121, 104, 114 }, // a/l both split | |
193 // 16x16 -> 8x8 | |
194 { 174, 73, 87 }, // a/l both not split | |
195 { 92, 41, 83 }, // a split, l not split | |
196 { 82, 99, 50 }, // l split, a not split | |
197 { 53, 39, 39 }, // a/l both split | |
198 // 32x32 -> 16x16 | |
199 { 177, 58, 59 }, // a/l both not split | |
200 { 68, 26, 63 }, // a split, l not split | |
201 { 52, 79, 25 }, // l split, a not split | |
202 { 17, 14, 12 }, // a/l both split | |
203 // 64x64 -> 32x32 | |
204 { 222, 34, 30 }, // a/l both not split | |
205 { 72, 16, 44 }, // a split, l not split | |
206 { 58, 32, 12 }, // l split, a not split | |
207 { 10, 7, 6 }, // a/l both split | |
208 } | |
209 }; | 210 }; |
210 | 211 |
211 static const vp9_prob default_inter_mode_probs[INTER_MODE_CONTEXTS] | 212 static const vp9_prob default_inter_mode_probs[INTER_MODE_CONTEXTS] |
212 [INTER_MODES - 1] = { | 213 [INTER_MODES - 1] = { |
213 {2, 173, 34}, // 0 = both zero mv | 214 {2, 173, 34}, // 0 = both zero mv |
214 {7, 145, 85}, // 1 = one zero mv + one a predicted mv | 215 {7, 145, 85}, // 1 = one zero mv + one a predicted mv |
215 {7, 166, 63}, // 2 = two predicted mvs | 216 {7, 166, 63}, // 2 = two predicted mvs |
216 {7, 94, 66}, // 3 = one predicted/zero and one new mv | 217 {7, 94, 66}, // 3 = one predicted/zero and one new mv |
217 {8, 64, 46}, // 4 = two new mvs | 218 {8, 64, 46}, // 4 = two new mvs |
218 {17, 81, 31}, // 5 = one intra neighbour + x | 219 {17, 81, 31}, // 5 = one intra neighbour + x |
219 {25, 29, 30}, // 6 = two intra neighbours | 220 {25, 29, 30}, // 6 = two intra neighbours |
220 }; | 221 }; |
221 | 222 |
222 /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */ | 223 /* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */ |
223 const vp9_tree_index vp9_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = { | 224 const vp9_tree_index vp9_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = { |
224 -DC_PRED, 2, /* 0 = DC_NODE */ | 225 -DC_PRED, 2, /* 0 = DC_NODE */ |
225 -TM_PRED, 4, /* 1 = TM_NODE */ | 226 -TM_PRED, 4, /* 1 = TM_NODE */ |
226 -V_PRED, 6, /* 2 = V_NODE */ | 227 -V_PRED, 6, /* 2 = V_NODE */ |
227 8, 12, /* 3 = COM_NODE */ | 228 8, 12, /* 3 = COM_NODE */ |
228 -H_PRED, 10, /* 4 = H_NODE */ | 229 -H_PRED, 10, /* 4 = H_NODE */ |
229 -D135_PRED, -D117_PRED, /* 5 = D135_NODE */ | 230 -D135_PRED, -D117_PRED, /* 5 = D135_NODE */ |
230 -D45_PRED, 14, /* 6 = D45_NODE */ | 231 -D45_PRED, 14, /* 6 = D45_NODE */ |
231 -D63_PRED, 16, /* 7 = D63_NODE */ | 232 -D63_PRED, 16, /* 7 = D63_NODE */ |
232 -D153_PRED, -D207_PRED /* 8 = D153_NODE */ | 233 -D153_PRED, -D207_PRED /* 8 = D153_NODE */ |
233 }; | 234 }; |
234 struct vp9_token vp9_intra_mode_encodings[INTRA_MODES]; | |
235 | 235 |
236 const vp9_tree_index vp9_inter_mode_tree[TREE_SIZE(INTER_MODES)] = { | 236 const vp9_tree_index vp9_inter_mode_tree[TREE_SIZE(INTER_MODES)] = { |
237 -ZEROMV, 2, | 237 -INTER_OFFSET(ZEROMV), 2, |
238 -NEARESTMV, 4, | 238 -INTER_OFFSET(NEARESTMV), 4, |
239 -NEARMV, -NEWMV | 239 -INTER_OFFSET(NEARMV), -INTER_OFFSET(NEWMV) |
240 }; | 240 }; |
241 struct vp9_token vp9_inter_mode_encodings[INTER_MODES]; | |
242 | 241 |
243 const vp9_tree_index vp9_partition_tree[TREE_SIZE(PARTITION_TYPES)] = { | 242 const vp9_tree_index vp9_partition_tree[TREE_SIZE(PARTITION_TYPES)] = { |
244 -PARTITION_NONE, 2, | 243 -PARTITION_NONE, 2, |
245 -PARTITION_HORZ, 4, | 244 -PARTITION_HORZ, 4, |
246 -PARTITION_VERT, -PARTITION_SPLIT | 245 -PARTITION_VERT, -PARTITION_SPLIT |
247 }; | 246 }; |
248 struct vp9_token vp9_partition_encodings[PARTITION_TYPES]; | |
249 | 247 |
250 static const vp9_prob default_intra_inter_p[INTRA_INTER_CONTEXTS] = { | 248 static const vp9_prob default_intra_inter_p[INTRA_INTER_CONTEXTS] = { |
251 9, 102, 187, 225 | 249 9, 102, 187, 225 |
252 }; | 250 }; |
253 | 251 |
254 static const vp9_prob default_comp_inter_p[COMP_INTER_CONTEXTS] = { | 252 static const vp9_prob default_comp_inter_p[COMP_INTER_CONTEXTS] = { |
255 239, 183, 119, 96, 41 | 253 239, 183, 119, 96, 41 |
256 }; | 254 }; |
257 | 255 |
258 static const vp9_prob default_comp_ref_p[REF_CONTEXTS] = { | 256 static const vp9_prob default_comp_ref_p[REF_CONTEXTS] = { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 vp9_copy(cm->fc.uv_mode_prob, default_if_uv_probs); | 319 vp9_copy(cm->fc.uv_mode_prob, default_if_uv_probs); |
322 vp9_copy(cm->fc.y_mode_prob, default_if_y_probs); | 320 vp9_copy(cm->fc.y_mode_prob, default_if_y_probs); |
323 vp9_copy(cm->fc.switchable_interp_prob, default_switchable_interp_prob); | 321 vp9_copy(cm->fc.switchable_interp_prob, default_switchable_interp_prob); |
324 vp9_copy(cm->fc.partition_prob, default_partition_probs); | 322 vp9_copy(cm->fc.partition_prob, default_partition_probs); |
325 vp9_copy(cm->fc.intra_inter_prob, default_intra_inter_p); | 323 vp9_copy(cm->fc.intra_inter_prob, default_intra_inter_p); |
326 vp9_copy(cm->fc.comp_inter_prob, default_comp_inter_p); | 324 vp9_copy(cm->fc.comp_inter_prob, default_comp_inter_p); |
327 vp9_copy(cm->fc.comp_ref_prob, default_comp_ref_p); | 325 vp9_copy(cm->fc.comp_ref_prob, default_comp_ref_p); |
328 vp9_copy(cm->fc.single_ref_prob, default_single_ref_p); | 326 vp9_copy(cm->fc.single_ref_prob, default_single_ref_p); |
329 cm->fc.tx_probs = default_tx_probs; | 327 cm->fc.tx_probs = default_tx_probs; |
330 vp9_copy(cm->fc.mbskip_probs, default_mbskip_probs); | 328 vp9_copy(cm->fc.mbskip_probs, default_mbskip_probs); |
| 329 vp9_copy(cm->fc.inter_mode_probs, default_inter_mode_probs); |
331 } | 330 } |
332 | 331 |
333 const vp9_tree_index vp9_switchable_interp_tree | 332 const vp9_tree_index vp9_switchable_interp_tree |
334 [TREE_SIZE(SWITCHABLE_FILTERS)] = { | 333 [TREE_SIZE(SWITCHABLE_FILTERS)] = { |
335 -EIGHTTAP, 2, | 334 -EIGHTTAP, 2, |
336 -EIGHTTAP_SMOOTH, -EIGHTTAP_SHARP | 335 -EIGHTTAP_SMOOTH, -EIGHTTAP_SHARP |
337 }; | 336 }; |
338 struct vp9_token vp9_switchable_interp_encodings[SWITCHABLE_FILTERS]; | |
339 | |
340 void vp9_entropy_mode_init() { | |
341 vp9_tokens_from_tree(vp9_intra_mode_encodings, vp9_intra_mode_tree); | |
342 vp9_tokens_from_tree(vp9_switchable_interp_encodings, | |
343 vp9_switchable_interp_tree); | |
344 vp9_tokens_from_tree(vp9_partition_encodings, vp9_partition_tree); | |
345 vp9_tokens_from_tree_offset(vp9_inter_mode_encodings, | |
346 vp9_inter_mode_tree, NEARESTMV); | |
347 } | |
348 | 337 |
349 #define COUNT_SAT 20 | 338 #define COUNT_SAT 20 |
350 #define MAX_UPDATE_FACTOR 128 | 339 #define MAX_UPDATE_FACTOR 128 |
351 | 340 |
352 static int update_ct(vp9_prob pre_prob, vp9_prob prob, | 341 static int adapt_prob(vp9_prob pre_prob, const unsigned int ct[2]) { |
353 const unsigned int ct[2]) { | 342 return merge_probs(pre_prob, ct, COUNT_SAT, MAX_UPDATE_FACTOR); |
354 return merge_probs(pre_prob, prob, ct, COUNT_SAT, MAX_UPDATE_FACTOR); | |
355 } | 343 } |
356 | 344 |
357 static int update_ct2(vp9_prob pre_prob, const unsigned int ct[2]) { | 345 static void adapt_probs(const vp9_tree_index *tree, |
358 return merge_probs2(pre_prob, ct, COUNT_SAT, MAX_UPDATE_FACTOR); | 346 const vp9_prob *pre_probs, const unsigned int *counts, |
359 } | 347 vp9_prob *probs) { |
360 | 348 tree_merge_probs(tree, pre_probs, counts, COUNT_SAT, MAX_UPDATE_FACTOR, |
361 static void update_mode_probs(int n_modes, | 349 probs); |
362 const vp9_tree_index *tree, | |
363 const unsigned int *cnt, | |
364 const vp9_prob *pre_probs, vp9_prob *dst_probs, | |
365 unsigned int tok0_offset) { | |
366 #define MAX_PROBS 32 | |
367 vp9_prob probs[MAX_PROBS]; | |
368 unsigned int branch_ct[MAX_PROBS][2]; | |
369 int t; | |
370 | |
371 assert(n_modes - 1 < MAX_PROBS); | |
372 vp9_tree_probs_from_distribution(tree, probs, branch_ct, cnt, tok0_offset); | |
373 for (t = 0; t < n_modes - 1; ++t) | |
374 dst_probs[t] = update_ct(pre_probs[t], probs[t], branch_ct[t]); | |
375 } | 350 } |
376 | 351 |
377 void vp9_adapt_mode_probs(VP9_COMMON *cm) { | 352 void vp9_adapt_mode_probs(VP9_COMMON *cm) { |
378 int i, j; | 353 int i, j; |
379 FRAME_CONTEXT *fc = &cm->fc; | 354 FRAME_CONTEXT *fc = &cm->fc; |
380 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx]; | 355 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx]; |
381 const FRAME_COUNTS *counts = &cm->counts; | 356 const FRAME_COUNTS *counts = &cm->counts; |
382 | 357 |
383 for (i = 0; i < INTRA_INTER_CONTEXTS; i++) | 358 for (i = 0; i < INTRA_INTER_CONTEXTS; i++) |
384 fc->intra_inter_prob[i] = update_ct2(pre_fc->intra_inter_prob[i], | 359 fc->intra_inter_prob[i] = adapt_prob(pre_fc->intra_inter_prob[i], |
385 counts->intra_inter[i]); | 360 counts->intra_inter[i]); |
386 for (i = 0; i < COMP_INTER_CONTEXTS; i++) | 361 for (i = 0; i < COMP_INTER_CONTEXTS; i++) |
387 fc->comp_inter_prob[i] = update_ct2(pre_fc->comp_inter_prob[i], | 362 fc->comp_inter_prob[i] = adapt_prob(pre_fc->comp_inter_prob[i], |
388 counts->comp_inter[i]); | 363 counts->comp_inter[i]); |
389 for (i = 0; i < REF_CONTEXTS; i++) | 364 for (i = 0; i < REF_CONTEXTS; i++) |
390 fc->comp_ref_prob[i] = update_ct2(pre_fc->comp_ref_prob[i], | 365 fc->comp_ref_prob[i] = adapt_prob(pre_fc->comp_ref_prob[i], |
391 counts->comp_ref[i]); | 366 counts->comp_ref[i]); |
392 for (i = 0; i < REF_CONTEXTS; i++) | 367 for (i = 0; i < REF_CONTEXTS; i++) |
393 for (j = 0; j < 2; j++) | 368 for (j = 0; j < 2; j++) |
394 fc->single_ref_prob[i][j] = update_ct2(pre_fc->single_ref_prob[i][j], | 369 fc->single_ref_prob[i][j] = adapt_prob(pre_fc->single_ref_prob[i][j], |
395 counts->single_ref[i][j]); | 370 counts->single_ref[i][j]); |
396 | 371 |
397 for (i = 0; i < INTER_MODE_CONTEXTS; i++) | 372 for (i = 0; i < INTER_MODE_CONTEXTS; i++) |
398 update_mode_probs(INTER_MODES, vp9_inter_mode_tree, | 373 adapt_probs(vp9_inter_mode_tree, pre_fc->inter_mode_probs[i], |
399 counts->inter_mode[i], pre_fc->inter_mode_probs[i], | 374 counts->inter_mode[i], fc->inter_mode_probs[i]); |
400 fc->inter_mode_probs[i], NEARESTMV); | |
401 | 375 |
402 for (i = 0; i < BLOCK_SIZE_GROUPS; i++) | 376 for (i = 0; i < BLOCK_SIZE_GROUPS; i++) |
403 update_mode_probs(INTRA_MODES, vp9_intra_mode_tree, | 377 adapt_probs(vp9_intra_mode_tree, pre_fc->y_mode_prob[i], |
404 counts->y_mode[i], pre_fc->y_mode_prob[i], | 378 counts->y_mode[i], fc->y_mode_prob[i]); |
405 fc->y_mode_prob[i], 0); | |
406 | 379 |
407 for (i = 0; i < INTRA_MODES; ++i) | 380 for (i = 0; i < INTRA_MODES; ++i) |
408 update_mode_probs(INTRA_MODES, vp9_intra_mode_tree, | 381 adapt_probs(vp9_intra_mode_tree, pre_fc->uv_mode_prob[i], |
409 counts->uv_mode[i], pre_fc->uv_mode_prob[i], | 382 counts->uv_mode[i], fc->uv_mode_prob[i]); |
410 fc->uv_mode_prob[i], 0); | |
411 | 383 |
412 for (i = 0; i < PARTITION_CONTEXTS; i++) | 384 for (i = 0; i < PARTITION_CONTEXTS; i++) |
413 update_mode_probs(PARTITION_TYPES, vp9_partition_tree, | 385 adapt_probs(vp9_partition_tree, pre_fc->partition_prob[i], |
414 counts->partition[i], | 386 counts->partition[i], fc->partition_prob[i]); |
415 pre_fc->partition_prob[INTER_FRAME][i], | |
416 fc->partition_prob[INTER_FRAME][i], 0); | |
417 | 387 |
418 if (cm->mcomp_filter_type == SWITCHABLE) { | 388 if (cm->mcomp_filter_type == SWITCHABLE) { |
419 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) | 389 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) |
420 update_mode_probs(SWITCHABLE_FILTERS, vp9_switchable_interp_tree, | 390 adapt_probs(vp9_switchable_interp_tree, pre_fc->switchable_interp_prob[i], |
421 counts->switchable_interp[i], | 391 counts->switchable_interp[i], fc->switchable_interp_prob[i]); |
422 pre_fc->switchable_interp_prob[i], | |
423 fc->switchable_interp_prob[i], 0); | |
424 } | 392 } |
425 | 393 |
426 if (cm->tx_mode == TX_MODE_SELECT) { | 394 if (cm->tx_mode == TX_MODE_SELECT) { |
427 int j; | 395 int j; |
428 unsigned int branch_ct_8x8p[TX_SIZES - 3][2]; | 396 unsigned int branch_ct_8x8p[TX_SIZES - 3][2]; |
429 unsigned int branch_ct_16x16p[TX_SIZES - 2][2]; | 397 unsigned int branch_ct_16x16p[TX_SIZES - 2][2]; |
430 unsigned int branch_ct_32x32p[TX_SIZES - 1][2]; | 398 unsigned int branch_ct_32x32p[TX_SIZES - 1][2]; |
431 | 399 |
432 for (i = 0; i < TX_SIZE_CONTEXTS; ++i) { | 400 for (i = 0; i < TX_SIZE_CONTEXTS; ++i) { |
433 tx_counts_to_branch_counts_8x8(counts->tx.p8x8[i], branch_ct_8x8p); | 401 tx_counts_to_branch_counts_8x8(counts->tx.p8x8[i], branch_ct_8x8p); |
434 for (j = 0; j < TX_SIZES - 3; ++j) | 402 for (j = 0; j < TX_SIZES - 3; ++j) |
435 fc->tx_probs.p8x8[i][j] = update_ct2(pre_fc->tx_probs.p8x8[i][j], | 403 fc->tx_probs.p8x8[i][j] = adapt_prob(pre_fc->tx_probs.p8x8[i][j], |
436 branch_ct_8x8p[j]); | 404 branch_ct_8x8p[j]); |
437 | 405 |
438 tx_counts_to_branch_counts_16x16(counts->tx.p16x16[i], branch_ct_16x16p); | 406 tx_counts_to_branch_counts_16x16(counts->tx.p16x16[i], branch_ct_16x16p); |
439 for (j = 0; j < TX_SIZES - 2; ++j) | 407 for (j = 0; j < TX_SIZES - 2; ++j) |
440 fc->tx_probs.p16x16[i][j] = update_ct2(pre_fc->tx_probs.p16x16[i][j], | 408 fc->tx_probs.p16x16[i][j] = adapt_prob(pre_fc->tx_probs.p16x16[i][j], |
441 branch_ct_16x16p[j]); | 409 branch_ct_16x16p[j]); |
442 | 410 |
443 tx_counts_to_branch_counts_32x32(counts->tx.p32x32[i], branch_ct_32x32p); | 411 tx_counts_to_branch_counts_32x32(counts->tx.p32x32[i], branch_ct_32x32p); |
444 for (j = 0; j < TX_SIZES - 1; ++j) | 412 for (j = 0; j < TX_SIZES - 1; ++j) |
445 fc->tx_probs.p32x32[i][j] = update_ct2(pre_fc->tx_probs.p32x32[i][j], | 413 fc->tx_probs.p32x32[i][j] = adapt_prob(pre_fc->tx_probs.p32x32[i][j], |
446 branch_ct_32x32p[j]); | 414 branch_ct_32x32p[j]); |
447 } | 415 } |
448 } | 416 } |
449 | 417 |
450 for (i = 0; i < MBSKIP_CONTEXTS; ++i) | 418 for (i = 0; i < MBSKIP_CONTEXTS; ++i) |
451 fc->mbskip_probs[i] = update_ct2(pre_fc->mbskip_probs[i], | 419 fc->mbskip_probs[i] = adapt_prob(pre_fc->mbskip_probs[i], |
452 counts->mbskip[i]); | 420 counts->mbskip[i]); |
453 } | 421 } |
454 | 422 |
455 static void set_default_lf_deltas(struct loopfilter *lf) { | 423 static void set_default_lf_deltas(struct loopfilter *lf) { |
456 lf->mode_ref_delta_enabled = 1; | 424 lf->mode_ref_delta_enabled = 1; |
457 lf->mode_ref_delta_update = 1; | 425 lf->mode_ref_delta_update = 1; |
458 | 426 |
459 lf->ref_deltas[INTRA_FRAME] = 1; | 427 lf->ref_deltas[INTRA_FRAME] = 1; |
460 lf->ref_deltas[LAST_FRAME] = 0; | 428 lf->ref_deltas[LAST_FRAME] = 0; |
461 lf->ref_deltas[GOLDEN_FRAME] = -1; | 429 lf->ref_deltas[GOLDEN_FRAME] = -1; |
(...skipping 18 matching lines...) Expand all Loading... |
480 vp9_zero(lf->last_ref_deltas); | 448 vp9_zero(lf->last_ref_deltas); |
481 vp9_zero(lf->last_mode_deltas); | 449 vp9_zero(lf->last_mode_deltas); |
482 set_default_lf_deltas(lf); | 450 set_default_lf_deltas(lf); |
483 | 451 |
484 // To force update of the sharpness | 452 // To force update of the sharpness |
485 lf->last_sharpness_level = -1; | 453 lf->last_sharpness_level = -1; |
486 | 454 |
487 vp9_default_coef_probs(cm); | 455 vp9_default_coef_probs(cm); |
488 vp9_init_mbmode_probs(cm); | 456 vp9_init_mbmode_probs(cm); |
489 vp9_init_mv_probs(cm); | 457 vp9_init_mv_probs(cm); |
490 vp9_copy(cm->fc.inter_mode_probs, default_inter_mode_probs); | |
491 | 458 |
492 if (cm->frame_type == KEY_FRAME || | 459 if (cm->frame_type == KEY_FRAME || |
493 cm->error_resilient_mode || cm->reset_frame_context == 3) { | 460 cm->error_resilient_mode || cm->reset_frame_context == 3) { |
494 // Reset all frame contexts. | 461 // Reset all frame contexts. |
495 for (i = 0; i < NUM_FRAME_CONTEXTS; ++i) | 462 for (i = 0; i < FRAME_CONTEXTS; ++i) |
496 cm->frame_contexts[i] = cm->fc; | 463 cm->frame_contexts[i] = cm->fc; |
497 } else if (cm->reset_frame_context == 2) { | 464 } else if (cm->reset_frame_context == 2) { |
498 // Reset only the frame context specified in the frame header. | 465 // Reset only the frame context specified in the frame header. |
499 cm->frame_contexts[cm->frame_context_idx] = cm->fc; | 466 cm->frame_contexts[cm->frame_context_idx] = cm->fc; |
500 } | 467 } |
501 | 468 |
502 vpx_memset(cm->prev_mip, 0, | 469 vpx_memset(cm->prev_mip, 0, |
503 cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); | 470 cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); |
504 vpx_memset(cm->mip, 0, | 471 vpx_memset(cm->mip, 0, |
505 cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); | 472 cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); |
506 | 473 |
507 vp9_update_mode_info_border(cm, cm->mip); | |
508 vp9_update_mode_info_border(cm, cm->prev_mip); | |
509 | |
510 vp9_zero(cm->ref_frame_sign_bias); | 474 vp9_zero(cm->ref_frame_sign_bias); |
511 | 475 |
512 cm->frame_context_idx = 0; | 476 cm->frame_context_idx = 0; |
513 } | 477 } |
OLD | NEW |