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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 vp9_copy(fc->skip_probs, default_skip_probs); | 327 vp9_copy(fc->skip_probs, default_skip_probs); |
328 vp9_copy(fc->inter_mode_probs, default_inter_mode_probs); | 328 vp9_copy(fc->inter_mode_probs, default_inter_mode_probs); |
329 } | 329 } |
330 | 330 |
331 const vp9_tree_index vp9_switchable_interp_tree | 331 const vp9_tree_index vp9_switchable_interp_tree |
332 [TREE_SIZE(SWITCHABLE_FILTERS)] = { | 332 [TREE_SIZE(SWITCHABLE_FILTERS)] = { |
333 -EIGHTTAP, 2, | 333 -EIGHTTAP, 2, |
334 -EIGHTTAP_SMOOTH, -EIGHTTAP_SHARP | 334 -EIGHTTAP_SMOOTH, -EIGHTTAP_SHARP |
335 }; | 335 }; |
336 | 336 |
337 #define COUNT_SAT 20 | |
338 #define MAX_UPDATE_FACTOR 128 | |
339 | |
340 static int adapt_prob(vp9_prob pre_prob, const unsigned int ct[2]) { | |
341 return merge_probs(pre_prob, ct, COUNT_SAT, MAX_UPDATE_FACTOR); | |
342 } | |
343 | |
344 static void adapt_probs(const vp9_tree_index *tree, | |
345 const vp9_prob *pre_probs, const unsigned int *counts, | |
346 vp9_prob *probs) { | |
347 vp9_tree_merge_probs(tree, pre_probs, counts, COUNT_SAT, MAX_UPDATE_FACTOR, | |
348 probs); | |
349 } | |
350 | |
351 void vp9_adapt_mode_probs(VP9_COMMON *cm) { | 337 void vp9_adapt_mode_probs(VP9_COMMON *cm) { |
352 int i, j; | 338 int i, j; |
353 FRAME_CONTEXT *fc = cm->fc; | 339 FRAME_CONTEXT *fc = cm->fc; |
354 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx]; | 340 const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx]; |
355 const FRAME_COUNTS *counts = &cm->counts; | 341 const FRAME_COUNTS *counts = &cm->counts; |
356 | 342 |
357 for (i = 0; i < INTRA_INTER_CONTEXTS; i++) | 343 for (i = 0; i < INTRA_INTER_CONTEXTS; i++) |
358 fc->intra_inter_prob[i] = adapt_prob(pre_fc->intra_inter_prob[i], | 344 fc->intra_inter_prob[i] = mode_mv_merge_probs(pre_fc->intra_inter_prob[i], |
359 counts->intra_inter[i]); | 345 counts->intra_inter[i]); |
360 for (i = 0; i < COMP_INTER_CONTEXTS; i++) | 346 for (i = 0; i < COMP_INTER_CONTEXTS; i++) |
361 fc->comp_inter_prob[i] = adapt_prob(pre_fc->comp_inter_prob[i], | 347 fc->comp_inter_prob[i] = mode_mv_merge_probs(pre_fc->comp_inter_prob[i], |
362 counts->comp_inter[i]); | 348 counts->comp_inter[i]); |
363 for (i = 0; i < REF_CONTEXTS; i++) | 349 for (i = 0; i < REF_CONTEXTS; i++) |
364 fc->comp_ref_prob[i] = adapt_prob(pre_fc->comp_ref_prob[i], | 350 fc->comp_ref_prob[i] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i], |
365 counts->comp_ref[i]); | 351 counts->comp_ref[i]); |
366 for (i = 0; i < REF_CONTEXTS; i++) | 352 for (i = 0; i < REF_CONTEXTS; i++) |
367 for (j = 0; j < 2; j++) | 353 for (j = 0; j < 2; j++) |
368 fc->single_ref_prob[i][j] = adapt_prob(pre_fc->single_ref_prob[i][j], | 354 fc->single_ref_prob[i][j] = mode_mv_merge_probs( |
369 counts->single_ref[i][j]); | 355 pre_fc->single_ref_prob[i][j], counts->single_ref[i][j]); |
370 | 356 |
371 for (i = 0; i < INTER_MODE_CONTEXTS; i++) | 357 for (i = 0; i < INTER_MODE_CONTEXTS; i++) |
372 adapt_probs(vp9_inter_mode_tree, pre_fc->inter_mode_probs[i], | 358 vp9_tree_merge_probs(vp9_inter_mode_tree, pre_fc->inter_mode_probs[i], |
373 counts->inter_mode[i], fc->inter_mode_probs[i]); | 359 counts->inter_mode[i], fc->inter_mode_probs[i]); |
374 | 360 |
375 for (i = 0; i < BLOCK_SIZE_GROUPS; i++) | 361 for (i = 0; i < BLOCK_SIZE_GROUPS; i++) |
376 adapt_probs(vp9_intra_mode_tree, pre_fc->y_mode_prob[i], | 362 vp9_tree_merge_probs(vp9_intra_mode_tree, pre_fc->y_mode_prob[i], |
377 counts->y_mode[i], fc->y_mode_prob[i]); | 363 counts->y_mode[i], fc->y_mode_prob[i]); |
378 | 364 |
379 for (i = 0; i < INTRA_MODES; ++i) | 365 for (i = 0; i < INTRA_MODES; ++i) |
380 adapt_probs(vp9_intra_mode_tree, pre_fc->uv_mode_prob[i], | 366 vp9_tree_merge_probs(vp9_intra_mode_tree, pre_fc->uv_mode_prob[i], |
381 counts->uv_mode[i], fc->uv_mode_prob[i]); | 367 counts->uv_mode[i], fc->uv_mode_prob[i]); |
382 | 368 |
383 for (i = 0; i < PARTITION_CONTEXTS; i++) | 369 for (i = 0; i < PARTITION_CONTEXTS; i++) |
384 adapt_probs(vp9_partition_tree, pre_fc->partition_prob[i], | 370 vp9_tree_merge_probs(vp9_partition_tree, pre_fc->partition_prob[i], |
385 counts->partition[i], fc->partition_prob[i]); | 371 counts->partition[i], fc->partition_prob[i]); |
386 | 372 |
387 if (cm->interp_filter == SWITCHABLE) { | 373 if (cm->interp_filter == SWITCHABLE) { |
388 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) | 374 for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) |
389 adapt_probs(vp9_switchable_interp_tree, pre_fc->switchable_interp_prob[i], | 375 vp9_tree_merge_probs(vp9_switchable_interp_tree, |
390 counts->switchable_interp[i], fc->switchable_interp_prob[i]); | 376 pre_fc->switchable_interp_prob[i], |
| 377 counts->switchable_interp[i], |
| 378 fc->switchable_interp_prob[i]); |
391 } | 379 } |
392 | 380 |
393 if (cm->tx_mode == TX_MODE_SELECT) { | 381 if (cm->tx_mode == TX_MODE_SELECT) { |
394 int j; | 382 int j; |
395 unsigned int branch_ct_8x8p[TX_SIZES - 3][2]; | 383 unsigned int branch_ct_8x8p[TX_SIZES - 3][2]; |
396 unsigned int branch_ct_16x16p[TX_SIZES - 2][2]; | 384 unsigned int branch_ct_16x16p[TX_SIZES - 2][2]; |
397 unsigned int branch_ct_32x32p[TX_SIZES - 1][2]; | 385 unsigned int branch_ct_32x32p[TX_SIZES - 1][2]; |
398 | 386 |
399 for (i = 0; i < TX_SIZE_CONTEXTS; ++i) { | 387 for (i = 0; i < TX_SIZE_CONTEXTS; ++i) { |
400 tx_counts_to_branch_counts_8x8(counts->tx.p8x8[i], branch_ct_8x8p); | 388 tx_counts_to_branch_counts_8x8(counts->tx.p8x8[i], branch_ct_8x8p); |
401 for (j = 0; j < TX_SIZES - 3; ++j) | 389 for (j = 0; j < TX_SIZES - 3; ++j) |
402 fc->tx_probs.p8x8[i][j] = adapt_prob(pre_fc->tx_probs.p8x8[i][j], | 390 fc->tx_probs.p8x8[i][j] = mode_mv_merge_probs( |
403 branch_ct_8x8p[j]); | 391 pre_fc->tx_probs.p8x8[i][j], branch_ct_8x8p[j]); |
404 | 392 |
405 tx_counts_to_branch_counts_16x16(counts->tx.p16x16[i], branch_ct_16x16p); | 393 tx_counts_to_branch_counts_16x16(counts->tx.p16x16[i], branch_ct_16x16p); |
406 for (j = 0; j < TX_SIZES - 2; ++j) | 394 for (j = 0; j < TX_SIZES - 2; ++j) |
407 fc->tx_probs.p16x16[i][j] = adapt_prob(pre_fc->tx_probs.p16x16[i][j], | 395 fc->tx_probs.p16x16[i][j] = mode_mv_merge_probs( |
408 branch_ct_16x16p[j]); | 396 pre_fc->tx_probs.p16x16[i][j], branch_ct_16x16p[j]); |
409 | 397 |
410 tx_counts_to_branch_counts_32x32(counts->tx.p32x32[i], branch_ct_32x32p); | 398 tx_counts_to_branch_counts_32x32(counts->tx.p32x32[i], branch_ct_32x32p); |
411 for (j = 0; j < TX_SIZES - 1; ++j) | 399 for (j = 0; j < TX_SIZES - 1; ++j) |
412 fc->tx_probs.p32x32[i][j] = adapt_prob(pre_fc->tx_probs.p32x32[i][j], | 400 fc->tx_probs.p32x32[i][j] = mode_mv_merge_probs( |
413 branch_ct_32x32p[j]); | 401 pre_fc->tx_probs.p32x32[i][j], branch_ct_32x32p[j]); |
414 } | 402 } |
415 } | 403 } |
416 | 404 |
417 for (i = 0; i < SKIP_CONTEXTS; ++i) | 405 for (i = 0; i < SKIP_CONTEXTS; ++i) |
418 fc->skip_probs[i] = adapt_prob(pre_fc->skip_probs[i], counts->skip[i]); | 406 fc->skip_probs[i] = mode_mv_merge_probs( |
| 407 pre_fc->skip_probs[i], counts->skip[i]); |
419 } | 408 } |
420 | 409 |
421 static void set_default_lf_deltas(struct loopfilter *lf) { | 410 static void set_default_lf_deltas(struct loopfilter *lf) { |
422 lf->mode_ref_delta_enabled = 1; | 411 lf->mode_ref_delta_enabled = 1; |
423 lf->mode_ref_delta_update = 1; | 412 lf->mode_ref_delta_update = 1; |
424 | 413 |
425 lf->ref_deltas[INTRA_FRAME] = 1; | 414 lf->ref_deltas[INTRA_FRAME] = 1; |
426 lf->ref_deltas[LAST_FRAME] = 0; | 415 lf->ref_deltas[LAST_FRAME] = 0; |
427 lf->ref_deltas[GOLDEN_FRAME] = -1; | 416 lf->ref_deltas[GOLDEN_FRAME] = -1; |
428 lf->ref_deltas[ALTREF_FRAME] = -1; | 417 lf->ref_deltas[ALTREF_FRAME] = -1; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 | 456 |
468 // prev_mip will only be allocated in encoder. | 457 // prev_mip will only be allocated in encoder. |
469 if (frame_is_intra_only(cm) && cm->prev_mip) | 458 if (frame_is_intra_only(cm) && cm->prev_mip) |
470 vpx_memset(cm->prev_mip, 0, cm->mi_stride * (cm->mi_rows + 1) * | 459 vpx_memset(cm->prev_mip, 0, cm->mi_stride * (cm->mi_rows + 1) * |
471 sizeof(*cm->prev_mip)); | 460 sizeof(*cm->prev_mip)); |
472 | 461 |
473 vp9_zero(cm->ref_frame_sign_bias); | 462 vp9_zero(cm->ref_frame_sign_bias); |
474 | 463 |
475 cm->frame_context_idx = 0; | 464 cm->frame_context_idx = 0; |
476 } | 465 } |
OLD | NEW |