| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 128, 128, 128, 128, 128, 128, 128, 128, | 87 128, 128, 128, 128, 128, 128, 128, 128, |
| 88 128, 128, 128, 128, 128, 128, 128, 128, | 88 128, 128, 128, 128, 128, 128, 128, 128, |
| 89 128, 128, 128, 128, 128, 128, 128, 128, | 89 128, 128, 128, 128, 128, 128, 128, 128, |
| 90 128, 128, 128, 128, 128, 128, 128, 128, | 90 128, 128, 128, 128, 128, 128, 128, 128, |
| 91 128, 128, 128, 128, 128, 128, 128, 128, | 91 128, 128, 128, 128, 128, 128, 128, 128, |
| 92 128, 128, 128, 128, 128, 128, 128, 128, | 92 128, 128, 128, 128, 128, 128, 128, 128, |
| 93 128, 128, 128, 128, 128, 128, 128, 128, | 93 128, 128, 128, 128, 128, 128, 128, 128, |
| 94 128, 128, 128, 128, 128, 128, 128, 128 | 94 128, 128, 128, 128, 128, 128, 128, 128 |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi, MACROBLOCK *x, | 97 static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi, |
| 98 MACROBLOCK *x, |
| 98 BLOCK_SIZE bs) { | 99 BLOCK_SIZE bs) { |
| 99 unsigned int var, sse; | 100 unsigned int var, sse; |
| 100 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride, | 101 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride, |
| 101 VP9_VAR_OFFS, 0, &sse); | 102 VP9_VAR_OFFS, 0, &sse); |
| 102 return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); | 103 return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); |
| 103 } | 104 } |
| 104 | 105 |
| 106 static unsigned int get_sby_perpixel_diff_variance(VP9_COMP *cpi, |
| 107 MACROBLOCK *x, |
| 108 int mi_row, |
| 109 int mi_col, |
| 110 BLOCK_SIZE bs) { |
| 111 const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, LAST_FRAME); |
| 112 int offset = (mi_row * MI_SIZE) * yv12->y_stride + (mi_col * MI_SIZE); |
| 113 unsigned int var, sse; |
| 114 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, |
| 115 x->plane[0].src.stride, |
| 116 yv12->y_buffer + offset, |
| 117 yv12->y_stride, |
| 118 &sse); |
| 119 return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); |
| 120 } |
| 121 |
| 122 static BLOCK_SIZE get_rd_var_based_fixed_partition(VP9_COMP *cpi, |
| 123 int mi_row, |
| 124 int mi_col) { |
| 125 unsigned int var = get_sby_perpixel_diff_variance(cpi, &cpi->mb, |
| 126 mi_row, mi_col, |
| 127 BLOCK_64X64); |
| 128 if (var < 8) |
| 129 return BLOCK_64X64; |
| 130 else if (var < 128) |
| 131 return BLOCK_32X32; |
| 132 else if (var < 2048) |
| 133 return BLOCK_16X16; |
| 134 else |
| 135 return BLOCK_8X8; |
| 136 } |
| 137 |
| 138 static BLOCK_SIZE get_nonrd_var_based_fixed_partition(VP9_COMP *cpi, |
| 139 int mi_row, |
| 140 int mi_col) { |
| 141 unsigned int var = get_sby_perpixel_diff_variance(cpi, &cpi->mb, |
| 142 mi_row, mi_col, |
| 143 BLOCK_64X64); |
| 144 if (var < 4) |
| 145 return BLOCK_64X64; |
| 146 else if (var < 10) |
| 147 return BLOCK_32X32; |
| 148 else |
| 149 return BLOCK_16X16; |
| 150 } |
| 151 |
| 105 // Original activity measure from Tim T's code. | 152 // Original activity measure from Tim T's code. |
| 106 static unsigned int tt_activity_measure(MACROBLOCK *x) { | 153 static unsigned int tt_activity_measure(MACROBLOCK *x) { |
| 107 unsigned int sse; | 154 unsigned int sse; |
| 108 /* TODO: This could also be done over smaller areas (8x8), but that would | 155 /* TODO: This could also be done over smaller areas (8x8), but that would |
| 109 * require extensive changes elsewhere, as lambda is assumed to be fixed | 156 * require extensive changes elsewhere, as lambda is assumed to be fixed |
| 110 * over an entire MB in most of the code. | 157 * over an entire MB in most of the code. |
| 111 * Another option is to compute four 8x8 variances, and pick a single | 158 * Another option is to compute four 8x8 variances, and pick a single |
| 112 * lambda using a non-linear combination (e.g., the smallest, or second | 159 * lambda using a non-linear combination (e.g., the smallest, or second |
| 113 * smallest, etc.). | 160 * smallest, etc.). |
| 114 */ | 161 */ |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 int i, x_idx, y; | 438 int i, x_idx, y; |
| 392 VP9_COMMON *const cm = &cpi->common; | 439 VP9_COMMON *const cm = &cpi->common; |
| 393 MACROBLOCK *const x = &cpi->mb; | 440 MACROBLOCK *const x = &cpi->mb; |
| 394 MACROBLOCKD *const xd = &x->e_mbd; | 441 MACROBLOCKD *const xd = &x->e_mbd; |
| 395 struct macroblock_plane *const p = x->plane; | 442 struct macroblock_plane *const p = x->plane; |
| 396 struct macroblockd_plane *const pd = xd->plane; | 443 struct macroblockd_plane *const pd = xd->plane; |
| 397 MODE_INFO *mi = &ctx->mic; | 444 MODE_INFO *mi = &ctx->mic; |
| 398 MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; | 445 MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; |
| 399 MODE_INFO *mi_addr = xd->mi_8x8[0]; | 446 MODE_INFO *mi_addr = xd->mi_8x8[0]; |
| 400 | 447 |
| 401 const int mb_mode_index = ctx->best_mode_index; | |
| 402 const int mis = cm->mode_info_stride; | 448 const int mis = cm->mode_info_stride; |
| 403 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; | 449 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; |
| 404 const int mi_height = num_8x8_blocks_high_lookup[bsize]; | 450 const int mi_height = num_8x8_blocks_high_lookup[bsize]; |
| 405 int max_plane; | 451 int max_plane; |
| 406 | 452 |
| 407 assert(mi->mbmi.mode < MB_MODE_COUNT); | 453 assert(mi->mbmi.mode < MB_MODE_COUNT); |
| 408 assert(mi->mbmi.ref_frame[0] < MAX_REF_FRAMES); | 454 assert(mi->mbmi.ref_frame[0] < MAX_REF_FRAMES); |
| 409 assert(mi->mbmi.ref_frame[1] < MAX_REF_FRAMES); | 455 assert(mi->mbmi.ref_frame[1] < MAX_REF_FRAMES); |
| 410 assert(mi->mbmi.sb_type == bsize); | 456 assert(mi->mbmi.sb_type == bsize); |
| 411 | 457 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 435 // when the mode was picked for it | 481 // when the mode was picked for it |
| 436 for (y = 0; y < mi_height; y++) | 482 for (y = 0; y < mi_height; y++) |
| 437 for (x_idx = 0; x_idx < mi_width; x_idx++) | 483 for (x_idx = 0; x_idx < mi_width; x_idx++) |
| 438 if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx | 484 if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx |
| 439 && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { | 485 && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { |
| 440 xd->mi_8x8[x_idx + y * mis] = mi_addr; | 486 xd->mi_8x8[x_idx + y * mis] = mi_addr; |
| 441 } | 487 } |
| 442 | 488 |
| 443 if ((cpi->oxcf.aq_mode == VARIANCE_AQ) || | 489 if ((cpi->oxcf.aq_mode == VARIANCE_AQ) || |
| 444 (cpi->oxcf.aq_mode == COMPLEXITY_AQ)) { | 490 (cpi->oxcf.aq_mode == COMPLEXITY_AQ)) { |
| 445 vp9_mb_init_quantizer(cpi, x); | 491 vp9_init_plane_quantizers(cpi, x); |
| 446 } | 492 } |
| 447 | 493 |
| 448 // FIXME(rbultje) I'm pretty sure this should go to the end of this block | 494 // FIXME(rbultje) I'm pretty sure this should go to the end of this block |
| 449 // (i.e. after the output_enabled) | 495 // (i.e. after the output_enabled) |
| 450 if (bsize < BLOCK_32X32) { | 496 if (bsize < BLOCK_32X32) { |
| 451 if (bsize < BLOCK_16X16) | 497 if (bsize < BLOCK_16X16) |
| 452 ctx->tx_rd_diff[ALLOW_16X16] = ctx->tx_rd_diff[ALLOW_8X8]; | 498 ctx->tx_rd_diff[ALLOW_16X16] = ctx->tx_rd_diff[ALLOW_8X8]; |
| 453 ctx->tx_rd_diff[ALLOW_32X32] = ctx->tx_rd_diff[ALLOW_16X16]; | 499 ctx->tx_rd_diff[ALLOW_32X32] = ctx->tx_rd_diff[ALLOW_16X16]; |
| 454 } | 500 } |
| 455 | 501 |
| 456 if (is_inter_block(mbmi) && mbmi->sb_type < BLOCK_8X8) { | 502 if (is_inter_block(mbmi) && mbmi->sb_type < BLOCK_8X8) { |
| 457 mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int; | 503 mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int; |
| 458 mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int; | 504 mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int; |
| 459 } | 505 } |
| 460 | 506 |
| 461 x->skip = ctx->skip; | 507 x->skip = ctx->skip; |
| 462 vpx_memcpy(x->zcoeff_blk[mbmi->tx_size], ctx->zcoeff_blk, | 508 vpx_memcpy(x->zcoeff_blk[mbmi->tx_size], ctx->zcoeff_blk, |
| 463 sizeof(uint8_t) * ctx->num_4x4_blk); | 509 sizeof(uint8_t) * ctx->num_4x4_blk); |
| 464 | 510 |
| 465 if (!output_enabled) | 511 if (!output_enabled) |
| 466 return; | 512 return; |
| 467 | 513 |
| 468 if (!vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { | 514 if (!vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { |
| 469 for (i = 0; i < TX_MODES; i++) | 515 for (i = 0; i < TX_MODES; i++) |
| 470 cpi->rd_tx_select_diff[i] += ctx->tx_rd_diff[i]; | 516 cpi->rd_tx_select_diff[i] += ctx->tx_rd_diff[i]; |
| 471 } | 517 } |
| 472 | 518 |
| 519 #if CONFIG_INTERNAL_STATS |
| 473 if (frame_is_intra_only(cm)) { | 520 if (frame_is_intra_only(cm)) { |
| 474 #if CONFIG_INTERNAL_STATS | |
| 475 static const int kf_mode_index[] = { | 521 static const int kf_mode_index[] = { |
| 476 THR_DC /*DC_PRED*/, | 522 THR_DC /*DC_PRED*/, |
| 477 THR_V_PRED /*V_PRED*/, | 523 THR_V_PRED /*V_PRED*/, |
| 478 THR_H_PRED /*H_PRED*/, | 524 THR_H_PRED /*H_PRED*/, |
| 479 THR_D45_PRED /*D45_PRED*/, | 525 THR_D45_PRED /*D45_PRED*/, |
| 480 THR_D135_PRED /*D135_PRED*/, | 526 THR_D135_PRED /*D135_PRED*/, |
| 481 THR_D117_PRED /*D117_PRED*/, | 527 THR_D117_PRED /*D117_PRED*/, |
| 482 THR_D153_PRED /*D153_PRED*/, | 528 THR_D153_PRED /*D153_PRED*/, |
| 483 THR_D207_PRED /*D207_PRED*/, | 529 THR_D207_PRED /*D207_PRED*/, |
| 484 THR_D63_PRED /*D63_PRED*/, | 530 THR_D63_PRED /*D63_PRED*/, |
| 485 THR_TM /*TM_PRED*/, | 531 THR_TM /*TM_PRED*/, |
| 486 }; | 532 }; |
| 487 cpi->mode_chosen_counts[kf_mode_index[mbmi->mode]]++; | 533 ++cpi->mode_chosen_counts[kf_mode_index[mbmi->mode]]; |
| 488 #endif | |
| 489 } else { | 534 } else { |
| 490 // Note how often each mode chosen as best | 535 // Note how often each mode chosen as best |
| 491 cpi->mode_chosen_counts[mb_mode_index]++; | 536 ++cpi->mode_chosen_counts[ctx->best_mode_index]; |
| 492 | 537 } |
| 538 #endif |
| 539 if (!frame_is_intra_only(cm)) { |
| 493 if (is_inter_block(mbmi)) { | 540 if (is_inter_block(mbmi)) { |
| 494 if (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV) { | 541 if (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV) { |
| 495 int_mv best_mv[2]; | 542 MV best_mv[2]; |
| 496 for (i = 0; i < 1 + has_second_ref(mbmi); ++i) | 543 for (i = 0; i < 1 + has_second_ref(mbmi); ++i) |
| 497 best_mv[i].as_int = mbmi->ref_mvs[mbmi->ref_frame[i]][0].as_int; | 544 best_mv[i] = mbmi->ref_mvs[mbmi->ref_frame[i]][0].as_mv; |
| 498 vp9_update_mv_count(cpi, x, best_mv); | 545 vp9_update_mv_count(cm, xd, best_mv); |
| 499 } | 546 } |
| 500 | 547 |
| 501 if (cm->interp_filter == SWITCHABLE) { | 548 if (cm->interp_filter == SWITCHABLE) { |
| 502 const int ctx = vp9_get_pred_context_switchable_interp(xd); | 549 const int ctx = vp9_get_pred_context_switchable_interp(xd); |
| 503 ++cm->counts.switchable_interp[ctx][mbmi->interp_filter]; | 550 ++cm->counts.switchable_interp[ctx][mbmi->interp_filter]; |
| 504 } | 551 } |
| 505 } | 552 } |
| 506 | 553 |
| 507 cpi->rd_comp_pred_diff[SINGLE_REFERENCE] += ctx->single_pred_diff; | 554 cpi->rd_comp_pred_diff[SINGLE_REFERENCE] += ctx->single_pred_diff; |
| 508 cpi->rd_comp_pred_diff[COMPOUND_REFERENCE] += ctx->comp_pred_diff; | 555 cpi->rd_comp_pred_diff[COMPOUND_REFERENCE] += ctx->comp_pred_diff; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 593 |
| 547 set_skip_context(xd, cpi->above_context, cpi->left_context, mi_row, mi_col); | 594 set_skip_context(xd, cpi->above_context, cpi->left_context, mi_row, mi_col); |
| 548 | 595 |
| 549 // Activity map pointer | 596 // Activity map pointer |
| 550 x->mb_activity_ptr = &cpi->mb_activity_map[idx_map]; | 597 x->mb_activity_ptr = &cpi->mb_activity_map[idx_map]; |
| 551 x->active_ptr = cpi->active_map + idx_map; | 598 x->active_ptr = cpi->active_map + idx_map; |
| 552 | 599 |
| 553 xd->mi_8x8 = cm->mi_grid_visible + idx_str; | 600 xd->mi_8x8 = cm->mi_grid_visible + idx_str; |
| 554 xd->prev_mi_8x8 = cm->prev_mi_grid_visible + idx_str; | 601 xd->prev_mi_8x8 = cm->prev_mi_grid_visible + idx_str; |
| 555 | 602 |
| 556 // Special case: if prev_mi is NULL, the previous mode info context | |
| 557 // cannot be used. | |
| 558 xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL; | 603 xd->last_mi = cm->prev_mi ? xd->prev_mi_8x8[0] : NULL; |
| 559 | 604 |
| 560 xd->mi_8x8[0] = cm->mi + idx_str; | 605 xd->mi_8x8[0] = cm->mi + idx_str; |
| 561 | 606 |
| 562 mbmi = &xd->mi_8x8[0]->mbmi; | 607 mbmi = &xd->mi_8x8[0]->mbmi; |
| 563 | 608 |
| 564 // Set up destination pointers | 609 // Set up destination pointers |
| 565 setup_dst_planes(xd, get_frame_new_buffer(cm), mi_row, mi_col); | 610 setup_dst_planes(xd, get_frame_new_buffer(cm), mi_row, mi_col); |
| 566 | 611 |
| 567 // Set up limit values for MV components | 612 // Set up limit values for MV components |
| (...skipping 15 matching lines...) Expand all Loading... |
| 583 x->rddiv = cpi->RDDIV; | 628 x->rddiv = cpi->RDDIV; |
| 584 x->rdmult = cpi->RDMULT; | 629 x->rdmult = cpi->RDMULT; |
| 585 | 630 |
| 586 /* segment ID */ | 631 /* segment ID */ |
| 587 if (seg->enabled) { | 632 if (seg->enabled) { |
| 588 if (cpi->oxcf.aq_mode != VARIANCE_AQ) { | 633 if (cpi->oxcf.aq_mode != VARIANCE_AQ) { |
| 589 const uint8_t *const map = seg->update_map ? cpi->segmentation_map | 634 const uint8_t *const map = seg->update_map ? cpi->segmentation_map |
| 590 : cm->last_frame_seg_map; | 635 : cm->last_frame_seg_map; |
| 591 mbmi->segment_id = vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); | 636 mbmi->segment_id = vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); |
| 592 } | 637 } |
| 593 vp9_mb_init_quantizer(cpi, x); | 638 vp9_init_plane_quantizers(cpi, x); |
| 594 | 639 |
| 595 if (seg->enabled && cpi->seg0_cnt > 0 && | 640 if (seg->enabled && cpi->seg0_cnt > 0 && |
| 596 !vp9_segfeature_active(seg, 0, SEG_LVL_REF_FRAME) && | 641 !vp9_segfeature_active(seg, 0, SEG_LVL_REF_FRAME) && |
| 597 vp9_segfeature_active(seg, 1, SEG_LVL_REF_FRAME)) { | 642 vp9_segfeature_active(seg, 1, SEG_LVL_REF_FRAME)) { |
| 598 cpi->seg0_progress = (cpi->seg0_idx << 16) / cpi->seg0_cnt; | 643 cpi->seg0_progress = (cpi->seg0_idx << 16) / cpi->seg0_cnt; |
| 599 } else { | 644 } else { |
| 600 const int y = mb_row & ~3; | 645 const int y = mb_row & ~3; |
| 601 const int x = mb_col & ~3; | 646 const int x = mb_col & ~3; |
| 602 const int p16 = ((mb_row & 1) << 1) + (mb_col & 1); | 647 const int p16 = ((mb_row & 1) << 1) + (mb_col & 1); |
| 603 const int p32 = ((mb_row & 2) << 2) + ((mb_col & 2) << 1); | 648 const int p32 = ((mb_row & 2) << 2) + ((mb_col & 2) << 1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 622 int64_t best_rd) { | 667 int64_t best_rd) { |
| 623 VP9_COMMON *const cm = &cpi->common; | 668 VP9_COMMON *const cm = &cpi->common; |
| 624 MACROBLOCK *const x = &cpi->mb; | 669 MACROBLOCK *const x = &cpi->mb; |
| 625 MACROBLOCKD *const xd = &x->e_mbd; | 670 MACROBLOCKD *const xd = &x->e_mbd; |
| 626 struct macroblock_plane *const p = x->plane; | 671 struct macroblock_plane *const p = x->plane; |
| 627 struct macroblockd_plane *const pd = xd->plane; | 672 struct macroblockd_plane *const pd = xd->plane; |
| 628 int i; | 673 int i; |
| 629 int orig_rdmult = x->rdmult; | 674 int orig_rdmult = x->rdmult; |
| 630 double rdmult_ratio; | 675 double rdmult_ratio; |
| 631 | 676 |
| 632 vp9_clear_system_state(); // __asm emms; | 677 vp9_clear_system_state(); |
| 633 rdmult_ratio = 1.0; // avoid uninitialized warnings | 678 rdmult_ratio = 1.0; // avoid uninitialized warnings |
| 634 | 679 |
| 635 // Use the lower precision, but faster, 32x32 fdct for mode selection. | 680 // Use the lower precision, but faster, 32x32 fdct for mode selection. |
| 636 x->use_lp32x32fdct = 1; | 681 x->use_lp32x32fdct = 1; |
| 637 | 682 |
| 638 if (bsize < BLOCK_8X8) { | 683 if (bsize < BLOCK_8X8) { |
| 639 // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 | 684 // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 |
| 640 // there is nothing to be done. | 685 // there is nothing to be done. |
| 641 if (x->ab_index != 0) { | 686 if (x->ab_index != 0) { |
| 642 *totalrate = 0; | 687 *totalrate = 0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 671 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { | 716 (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref)) { |
| 672 xd->mi_8x8[0]->mbmi.segment_id = vp9_vaq_segment_id(energy); | 717 xd->mi_8x8[0]->mbmi.segment_id = vp9_vaq_segment_id(energy); |
| 673 } else { | 718 } else { |
| 674 const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map | 719 const uint8_t *const map = cm->seg.update_map ? cpi->segmentation_map |
| 675 : cm->last_frame_seg_map; | 720 : cm->last_frame_seg_map; |
| 676 xd->mi_8x8[0]->mbmi.segment_id = | 721 xd->mi_8x8[0]->mbmi.segment_id = |
| 677 vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); | 722 vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); |
| 678 } | 723 } |
| 679 | 724 |
| 680 rdmult_ratio = vp9_vaq_rdmult_ratio(energy); | 725 rdmult_ratio = vp9_vaq_rdmult_ratio(energy); |
| 681 vp9_mb_init_quantizer(cpi, x); | 726 vp9_init_plane_quantizers(cpi, x); |
| 682 } | 727 } |
| 683 | 728 |
| 684 if (cpi->oxcf.tuning == VP8_TUNE_SSIM) | 729 if (cpi->oxcf.tuning == VP8_TUNE_SSIM) |
| 685 activity_masking(cpi, x); | 730 activity_masking(cpi, x); |
| 686 | 731 |
| 687 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { | 732 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 688 vp9_clear_system_state(); // __asm emms; | 733 vp9_clear_system_state(); |
| 689 x->rdmult = round(x->rdmult * rdmult_ratio); | 734 x->rdmult = (int)round(x->rdmult * rdmult_ratio); |
| 690 } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { | 735 } else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { |
| 691 const int mi_offset = mi_row * cm->mi_cols + mi_col; | 736 const int mi_offset = mi_row * cm->mi_cols + mi_col; |
| 692 unsigned char complexity = cpi->complexity_map[mi_offset]; | 737 unsigned char complexity = cpi->complexity_map[mi_offset]; |
| 693 const int is_edge = (mi_row <= 1) || (mi_row >= (cm->mi_rows - 2)) || | 738 const int is_edge = (mi_row <= 1) || (mi_row >= (cm->mi_rows - 2)) || |
| 694 (mi_col <= 1) || (mi_col >= (cm->mi_cols - 2)); | 739 (mi_col <= 1) || (mi_col >= (cm->mi_cols - 2)); |
| 695 | 740 |
| 696 if (!is_edge && (complexity > 128)) { | 741 if (!is_edge && (complexity > 128)) { |
| 697 x->rdmult = x->rdmult + ((x->rdmult * (complexity - 128)) / 256); | 742 x->rdmult = x->rdmult + ((x->rdmult * (complexity - 128)) / 256); |
| 698 } | 743 } |
| 699 } | 744 } |
| 700 | 745 |
| 701 // Find best coding mode & reconstruct the MB so it is available | 746 // Find best coding mode & reconstruct the MB so it is available |
| 702 // as a predictor for MBs that follow in the SB | 747 // as a predictor for MBs that follow in the SB |
| 703 if (frame_is_intra_only(cm)) { | 748 if (frame_is_intra_only(cm)) { |
| 704 vp9_rd_pick_intra_mode_sb(cpi, x, totalrate, totaldist, bsize, ctx, | 749 vp9_rd_pick_intra_mode_sb(cpi, x, totalrate, totaldist, bsize, ctx, |
| 705 best_rd); | 750 best_rd); |
| 706 } else { | 751 } else { |
| 707 if (bsize >= BLOCK_8X8) | 752 if (bsize >= BLOCK_8X8) |
| 708 vp9_rd_pick_inter_mode_sb(cpi, x, tile, mi_row, mi_col, | 753 vp9_rd_pick_inter_mode_sb(cpi, x, tile, mi_row, mi_col, |
| 709 totalrate, totaldist, bsize, ctx, best_rd); | 754 totalrate, totaldist, bsize, ctx, best_rd); |
| 710 else | 755 else |
| 711 vp9_rd_pick_inter_mode_sub8x8(cpi, x, tile, mi_row, mi_col, totalrate, | 756 vp9_rd_pick_inter_mode_sub8x8(cpi, x, tile, mi_row, mi_col, totalrate, |
| 712 totaldist, bsize, ctx, best_rd); | 757 totaldist, bsize, ctx, best_rd); |
| 713 } | 758 } |
| 714 | 759 |
| 715 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { | 760 if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 716 x->rdmult = orig_rdmult; | 761 x->rdmult = orig_rdmult; |
| 717 if (*totalrate != INT_MAX) { | 762 if (*totalrate != INT_MAX) { |
| 718 vp9_clear_system_state(); // __asm emms; | 763 vp9_clear_system_state(); |
| 719 *totalrate = round(*totalrate * rdmult_ratio); | 764 *totalrate = (int)round(*totalrate * rdmult_ratio); |
| 720 } | 765 } |
| 721 } | 766 } |
| 722 else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { | 767 else if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { |
| 723 x->rdmult = orig_rdmult; | 768 x->rdmult = orig_rdmult; |
| 724 } | 769 } |
| 725 } | 770 } |
| 726 | 771 |
| 727 static void update_stats(VP9_COMP *cpi) { | 772 static void update_stats(VP9_COMP *cpi) { |
| 728 VP9_COMMON *const cm = &cpi->common; | 773 VP9_COMMON *const cm = &cpi->common; |
| 729 const MACROBLOCK *const x = &cpi->mb; | 774 const MACROBLOCK *const x = &cpi->mb; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 988 |
| 944 // Check to see if the given partition size is allowed for a specified number | 989 // Check to see if the given partition size is allowed for a specified number |
| 945 // of 8x8 block rows and columns remaining in the image. | 990 // of 8x8 block rows and columns remaining in the image. |
| 946 // If not then return the largest allowed partition size | 991 // If not then return the largest allowed partition size |
| 947 static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, | 992 static BLOCK_SIZE find_partition_size(BLOCK_SIZE bsize, |
| 948 int rows_left, int cols_left, | 993 int rows_left, int cols_left, |
| 949 int *bh, int *bw) { | 994 int *bh, int *bw) { |
| 950 if (rows_left <= 0 || cols_left <= 0) { | 995 if (rows_left <= 0 || cols_left <= 0) { |
| 951 return MIN(bsize, BLOCK_8X8); | 996 return MIN(bsize, BLOCK_8X8); |
| 952 } else { | 997 } else { |
| 953 for (; bsize > 0; --bsize) { | 998 for (; bsize > 0; bsize -= 3) { |
| 954 *bh = num_8x8_blocks_high_lookup[bsize]; | 999 *bh = num_8x8_blocks_high_lookup[bsize]; |
| 955 *bw = num_8x8_blocks_wide_lookup[bsize]; | 1000 *bw = num_8x8_blocks_wide_lookup[bsize]; |
| 956 if ((*bh <= rows_left) && (*bw <= cols_left)) { | 1001 if ((*bh <= rows_left) && (*bw <= cols_left)) { |
| 957 break; | 1002 break; |
| 958 } | 1003 } |
| 959 } | 1004 } |
| 960 } | 1005 } |
| 961 return bsize; | 1006 return bsize; |
| 962 } | 1007 } |
| 963 | 1008 |
| 964 // This function attempts to set all mode info entries in a given SB64 | 1009 // This function attempts to set all mode info entries in a given SB64 |
| 965 // to the same block partition size. | 1010 // to the same block partition size. |
| 966 // However, at the bottom and right borders of the image the requested size | 1011 // However, at the bottom and right borders of the image the requested size |
| 967 // may not be allowed in which case this code attempts to choose the largest | 1012 // may not be allowed in which case this code attempts to choose the largest |
| 968 // allowable partition. | 1013 // allowable partition. |
| 969 static void set_partitioning(VP9_COMP *cpi, const TileInfo *const tile, | 1014 static void set_partitioning(VP9_COMP *cpi, const TileInfo *const tile, |
| 970 MODE_INFO **mi_8x8, int mi_row, int mi_col) { | 1015 MODE_INFO **mi_8x8, int mi_row, int mi_col, |
| 1016 BLOCK_SIZE bsize) { |
| 971 VP9_COMMON *const cm = &cpi->common; | 1017 VP9_COMMON *const cm = &cpi->common; |
| 972 BLOCK_SIZE bsize = cpi->sf.always_this_block_size; | |
| 973 const int mis = cm->mode_info_stride; | 1018 const int mis = cm->mode_info_stride; |
| 974 int row8x8_remaining = tile->mi_row_end - mi_row; | 1019 int row8x8_remaining = tile->mi_row_end - mi_row; |
| 975 int col8x8_remaining = tile->mi_col_end - mi_col; | 1020 int col8x8_remaining = tile->mi_col_end - mi_col; |
| 976 int block_row, block_col; | 1021 int block_row, block_col; |
| 977 MODE_INFO *mi_upper_left = cm->mi + mi_row * mis + mi_col; | 1022 MODE_INFO *mi_upper_left = cm->mi + mi_row * mis + mi_col; |
| 978 int bh = num_8x8_blocks_high_lookup[bsize]; | 1023 int bh = num_8x8_blocks_high_lookup[bsize]; |
| 979 int bw = num_8x8_blocks_wide_lookup[bsize]; | 1024 int bw = num_8x8_blocks_wide_lookup[bsize]; |
| 980 | 1025 |
| 981 assert((row8x8_remaining > 0) && (col8x8_remaining > 0)); | 1026 assert((row8x8_remaining > 0) && (col8x8_remaining > 0)); |
| 982 | 1027 |
| 983 // Apply the requested partition size to the SB64 if it is all "in image" | 1028 // Apply the requested partition size to the SB64 if it is all "in image" |
| 984 if ((col8x8_remaining >= MI_BLOCK_SIZE) && | 1029 if ((col8x8_remaining >= MI_BLOCK_SIZE) && |
| 985 (row8x8_remaining >= MI_BLOCK_SIZE)) { | 1030 (row8x8_remaining >= MI_BLOCK_SIZE)) { |
| 986 for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { | 1031 for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { |
| 987 for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { | 1032 for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { |
| 988 int index = block_row * mis + block_col; | 1033 int index = block_row * mis + block_col; |
| 989 mi_8x8[index] = mi_upper_left + index; | 1034 mi_8x8[index] = mi_upper_left + index; |
| 990 mi_8x8[index]->mbmi.sb_type = bsize; | 1035 mi_8x8[index]->mbmi.sb_type = bsize; |
| 991 } | 1036 } |
| 992 } | 1037 } |
| 993 } else { | 1038 } else { |
| 994 // Else this is a partial SB64. | 1039 // Else this is a partial SB64. |
| 995 for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { | 1040 for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { |
| 996 for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { | 1041 for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { |
| 997 int index = block_row * mis + block_col; | 1042 int index = block_row * mis + block_col; |
| 998 // Find a partition size that fits | 1043 // Find a partition size that fits |
| 999 bsize = find_partition_size(cpi->sf.always_this_block_size, | 1044 bsize = find_partition_size(bsize, |
| 1000 (row8x8_remaining - block_row), | 1045 (row8x8_remaining - block_row), |
| 1001 (col8x8_remaining - block_col), &bh, &bw); | 1046 (col8x8_remaining - block_col), &bh, &bw); |
| 1002 mi_8x8[index] = mi_upper_left + index; | 1047 mi_8x8[index] = mi_upper_left + index; |
| 1003 mi_8x8[index]->mbmi.sb_type = bsize; | 1048 mi_8x8[index]->mbmi.sb_type = bsize; |
| 1004 } | 1049 } |
| 1005 } | 1050 } |
| 1006 } | 1051 } |
| 1007 } | 1052 } |
| 1008 | 1053 |
| 1009 static void copy_partitioning(VP9_COMMON *cm, MODE_INFO **mi_8x8, | 1054 static void copy_partitioning(VP9_COMMON *cm, MODE_INFO **mi_8x8, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1036 if (abs(prev_mi->mbmi.mv[0].as_mv.row) >= 8 || | 1081 if (abs(prev_mi->mbmi.mv[0].as_mv.row) >= 8 || |
| 1037 abs(prev_mi->mbmi.mv[0].as_mv.col) >= 8) | 1082 abs(prev_mi->mbmi.mv[0].as_mv.col) >= 8) |
| 1038 return 1; | 1083 return 1; |
| 1039 } | 1084 } |
| 1040 } | 1085 } |
| 1041 } | 1086 } |
| 1042 } | 1087 } |
| 1043 return 0; | 1088 return 0; |
| 1044 } | 1089 } |
| 1045 | 1090 |
| 1046 static void update_state_rt(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, | 1091 static void update_state_rt(VP9_COMP *cpi, const PICK_MODE_CONTEXT *ctx) { |
| 1047 BLOCK_SIZE bsize, int output_enabled) { | |
| 1048 int i; | 1092 int i; |
| 1049 VP9_COMMON *const cm = &cpi->common; | 1093 VP9_COMMON *const cm = &cpi->common; |
| 1050 MACROBLOCK *const x = &cpi->mb; | 1094 MACROBLOCK *const x = &cpi->mb; |
| 1051 MACROBLOCKD *const xd = &x->e_mbd; | 1095 MACROBLOCKD *const xd = &x->e_mbd; |
| 1052 struct macroblock_plane *const p = x->plane; | |
| 1053 struct macroblockd_plane *const pd = xd->plane; | |
| 1054 MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; | 1096 MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi; |
| 1055 | 1097 |
| 1056 const int mb_mode_index = ctx->best_mode_index; | |
| 1057 int max_plane; | |
| 1058 | |
| 1059 max_plane = is_inter_block(mbmi) ? MAX_MB_PLANE : 1; | |
| 1060 for (i = 0; i < max_plane; ++i) { | |
| 1061 p[i].coeff = ctx->coeff_pbuf[i][1]; | |
| 1062 p[i].qcoeff = ctx->qcoeff_pbuf[i][1]; | |
| 1063 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1]; | |
| 1064 p[i].eobs = ctx->eobs_pbuf[i][1]; | |
| 1065 } | |
| 1066 | |
| 1067 for (i = max_plane; i < MAX_MB_PLANE; ++i) { | |
| 1068 p[i].coeff = ctx->coeff_pbuf[i][2]; | |
| 1069 p[i].qcoeff = ctx->qcoeff_pbuf[i][2]; | |
| 1070 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][2]; | |
| 1071 p[i].eobs = ctx->eobs_pbuf[i][2]; | |
| 1072 } | |
| 1073 | |
| 1074 x->skip = ctx->skip; | 1098 x->skip = ctx->skip; |
| 1075 | 1099 |
| 1100 #if CONFIG_INTERNAL_STATS |
| 1076 if (frame_is_intra_only(cm)) { | 1101 if (frame_is_intra_only(cm)) { |
| 1077 #if CONFIG_INTERNAL_STATS | |
| 1078 static const int kf_mode_index[] = { | 1102 static const int kf_mode_index[] = { |
| 1079 THR_DC /*DC_PRED*/, | 1103 THR_DC /*DC_PRED*/, |
| 1080 THR_V_PRED /*V_PRED*/, | 1104 THR_V_PRED /*V_PRED*/, |
| 1081 THR_H_PRED /*H_PRED*/, | 1105 THR_H_PRED /*H_PRED*/, |
| 1082 THR_D45_PRED /*D45_PRED*/, | 1106 THR_D45_PRED /*D45_PRED*/, |
| 1083 THR_D135_PRED /*D135_PRED*/, | 1107 THR_D135_PRED /*D135_PRED*/, |
| 1084 THR_D117_PRED /*D117_PRED*/, | 1108 THR_D117_PRED /*D117_PRED*/, |
| 1085 THR_D153_PRED /*D153_PRED*/, | 1109 THR_D153_PRED /*D153_PRED*/, |
| 1086 THR_D207_PRED /*D207_PRED*/, | 1110 THR_D207_PRED /*D207_PRED*/, |
| 1087 THR_D63_PRED /*D63_PRED*/, | 1111 THR_D63_PRED /*D63_PRED*/, |
| 1088 THR_TM /*TM_PRED*/, | 1112 THR_TM /*TM_PRED*/, |
| 1089 }; | 1113 }; |
| 1090 ++cpi->mode_chosen_counts[kf_mode_index[mbmi->mode]]; | 1114 ++cpi->mode_chosen_counts[kf_mode_index[mbmi->mode]]; |
| 1091 #endif | |
| 1092 } else { | 1115 } else { |
| 1093 // Note how often each mode chosen as best | 1116 // Note how often each mode chosen as best |
| 1094 cpi->mode_chosen_counts[mb_mode_index]++; | 1117 ++cpi->mode_chosen_counts[ctx->best_mode_index]; |
| 1118 } |
| 1119 #endif |
| 1120 if (!frame_is_intra_only(cm)) { |
| 1095 if (is_inter_block(mbmi)) { | 1121 if (is_inter_block(mbmi)) { |
| 1096 if (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV) { | 1122 if (mbmi->sb_type < BLOCK_8X8 || mbmi->mode == NEWMV) { |
| 1097 int_mv best_mv[2]; | 1123 MV best_mv[2]; |
| 1098 for (i = 0; i < 1 + has_second_ref(mbmi); ++i) | 1124 for (i = 0; i < 1 + has_second_ref(mbmi); ++i) |
| 1099 best_mv[i].as_int = mbmi->ref_mvs[mbmi->ref_frame[i]][0].as_int; | 1125 best_mv[i] = mbmi->ref_mvs[mbmi->ref_frame[i]][0].as_mv; |
| 1100 vp9_update_mv_count(cpi, x, best_mv); | 1126 vp9_update_mv_count(cm, xd, best_mv); |
| 1101 } | 1127 } |
| 1102 | 1128 |
| 1103 if (cm->interp_filter == SWITCHABLE) { | 1129 if (cm->interp_filter == SWITCHABLE) { |
| 1104 const int ctx = vp9_get_pred_context_switchable_interp(xd); | 1130 const int pred_ctx = vp9_get_pred_context_switchable_interp(xd); |
| 1105 ++cm->counts.switchable_interp[ctx][mbmi->interp_filter]; | 1131 ++cm->counts.switchable_interp[pred_ctx][mbmi->interp_filter]; |
| 1106 } | 1132 } |
| 1107 } | 1133 } |
| 1108 } | 1134 } |
| 1109 } | 1135 } |
| 1110 | 1136 |
| 1111 static void encode_b_rt(VP9_COMP *cpi, const TileInfo *const tile, | 1137 static void encode_b_rt(VP9_COMP *cpi, const TileInfo *const tile, |
| 1112 TOKENEXTRA **tp, int mi_row, int mi_col, | 1138 TOKENEXTRA **tp, int mi_row, int mi_col, |
| 1113 int output_enabled, BLOCK_SIZE bsize) { | 1139 int output_enabled, BLOCK_SIZE bsize) { |
| 1114 MACROBLOCK *const x = &cpi->mb; | 1140 MACROBLOCK *const x = &cpi->mb; |
| 1115 | 1141 |
| 1116 if (bsize < BLOCK_8X8) { | 1142 if (bsize < BLOCK_8X8) { |
| 1117 // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 | 1143 // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 |
| 1118 // there is nothing to be done. | 1144 // there is nothing to be done. |
| 1119 if (x->ab_index > 0) | 1145 if (x->ab_index > 0) |
| 1120 return; | 1146 return; |
| 1121 } | 1147 } |
| 1122 set_offsets(cpi, tile, mi_row, mi_col, bsize); | 1148 set_offsets(cpi, tile, mi_row, mi_col, bsize); |
| 1123 update_state_rt(cpi, get_block_context(x, bsize), bsize, output_enabled); | 1149 update_state_rt(cpi, get_block_context(x, bsize)); |
| 1124 | 1150 |
| 1125 encode_superblock(cpi, tp, output_enabled, mi_row, mi_col, bsize); | 1151 encode_superblock(cpi, tp, output_enabled, mi_row, mi_col, bsize); |
| 1126 update_stats(cpi); | 1152 update_stats(cpi); |
| 1127 | 1153 |
| 1128 (*tp)->token = EOSB_TOKEN; | 1154 (*tp)->token = EOSB_TOKEN; |
| 1129 (*tp)++; | 1155 (*tp)++; |
| 1130 } | 1156 } |
| 1131 | 1157 |
| 1132 static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile, | 1158 static void encode_sb_rt(VP9_COMP *cpi, const TileInfo *const tile, |
| 1133 TOKENEXTRA **tp, int mi_row, int mi_col, | 1159 TOKENEXTRA **tp, int mi_row, int mi_col, |
| 1134 int output_enabled, BLOCK_SIZE bsize) { | 1160 int output_enabled, BLOCK_SIZE bsize) { |
| 1135 VP9_COMMON *const cm = &cpi->common; | 1161 VP9_COMMON *const cm = &cpi->common; |
| 1136 MACROBLOCK *const x = &cpi->mb; | 1162 MACROBLOCK *const x = &cpi->mb; |
| 1137 const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; | 1163 const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; |
| 1138 int ctx; | 1164 int ctx; |
| 1139 PARTITION_TYPE partition; | 1165 PARTITION_TYPE partition; |
| 1140 BLOCK_SIZE subsize; | 1166 BLOCK_SIZE subsize; |
| 1141 | 1167 |
| 1142 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 1168 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
| 1143 return; | 1169 return; |
| 1144 | 1170 |
| 1145 if (bsize >= BLOCK_8X8) { | 1171 if (bsize >= BLOCK_8X8) { |
| 1146 MACROBLOCKD *const xd = &cpi->mb.e_mbd; | 1172 MACROBLOCKD *const xd = &cpi->mb.e_mbd; |
| 1147 const int idx_str = xd->mode_info_stride * mi_row + mi_col; | 1173 const int idx_str = xd->mode_info_stride * mi_row + mi_col; |
| 1148 MODE_INFO ** mi_8x8 = cm->mi_grid_visible + idx_str; | 1174 MODE_INFO ** mi_8x8 = cm->mi_grid_visible + idx_str; |
| 1149 ctx = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, | 1175 ctx = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, |
| 1150 mi_row, mi_col, bsize); | 1176 mi_row, mi_col, bsize); |
| 1151 subsize = mi_8x8[0]->mbmi.sb_type; | 1177 subsize = mi_8x8[0]->mbmi.sb_type; |
| 1152 | |
| 1153 } else { | 1178 } else { |
| 1154 ctx = 0; | 1179 ctx = 0; |
| 1155 subsize = BLOCK_4X4; | 1180 subsize = BLOCK_4X4; |
| 1156 } | 1181 } |
| 1157 | 1182 |
| 1158 partition = partition_lookup[bsl][subsize]; | 1183 partition = partition_lookup[bsl][subsize]; |
| 1159 | 1184 |
| 1160 switch (partition) { | 1185 switch (partition) { |
| 1161 case PARTITION_NONE: | 1186 case PARTITION_NONE: |
| 1162 if (output_enabled && bsize >= BLOCK_8X8) | 1187 if (output_enabled && bsize >= BLOCK_8X8) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1193 *get_sb_index(x, subsize) = 0; | 1218 *get_sb_index(x, subsize) = 0; |
| 1194 encode_sb_rt(cpi, tile, tp, mi_row, mi_col, output_enabled, subsize); | 1219 encode_sb_rt(cpi, tile, tp, mi_row, mi_col, output_enabled, subsize); |
| 1195 *get_sb_index(x, subsize) = 1; | 1220 *get_sb_index(x, subsize) = 1; |
| 1196 encode_sb_rt(cpi, tile, tp, mi_row, mi_col + hbs, output_enabled, | 1221 encode_sb_rt(cpi, tile, tp, mi_row, mi_col + hbs, output_enabled, |
| 1197 subsize); | 1222 subsize); |
| 1198 *get_sb_index(x, subsize) = 2; | 1223 *get_sb_index(x, subsize) = 2; |
| 1199 encode_sb_rt(cpi, tile, tp, mi_row + hbs, mi_col, output_enabled, | 1224 encode_sb_rt(cpi, tile, tp, mi_row + hbs, mi_col, output_enabled, |
| 1200 subsize); | 1225 subsize); |
| 1201 *get_sb_index(x, subsize) = 3; | 1226 *get_sb_index(x, subsize) = 3; |
| 1202 encode_sb_rt(cpi, tile, tp, mi_row + hbs, mi_col + hbs, output_enabled, | 1227 encode_sb_rt(cpi, tile, tp, mi_row + hbs, mi_col + hbs, output_enabled, |
| 1203 subsize); | 1228 subsize); |
| 1204 break; | 1229 break; |
| 1205 default: | 1230 default: |
| 1206 assert("Invalid partition type."); | 1231 assert("Invalid partition type."); |
| 1207 } | 1232 } |
| 1208 | 1233 |
| 1209 if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) | 1234 if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) |
| 1210 update_partition_context(cpi->above_seg_context, cpi->left_seg_context, | 1235 update_partition_context(cpi->above_seg_context, cpi->left_seg_context, |
| 1211 mi_row, mi_col, subsize, bsize); | 1236 mi_row, mi_col, subsize, bsize); |
| 1212 } | 1237 } |
| 1213 | 1238 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1225 const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize]; | 1250 const int num_4x4_blocks_high = num_4x4_blocks_high_lookup[bsize]; |
| 1226 const int ms = num_4x4_blocks_wide / 2; | 1251 const int ms = num_4x4_blocks_wide / 2; |
| 1227 const int mh = num_4x4_blocks_high / 2; | 1252 const int mh = num_4x4_blocks_high / 2; |
| 1228 const int bss = (1 << bsl) / 4; | 1253 const int bss = (1 << bsl) / 4; |
| 1229 int i, pl; | 1254 int i, pl; |
| 1230 PARTITION_TYPE partition = PARTITION_NONE; | 1255 PARTITION_TYPE partition = PARTITION_NONE; |
| 1231 BLOCK_SIZE subsize; | 1256 BLOCK_SIZE subsize; |
| 1232 ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; | 1257 ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; |
| 1233 PARTITION_CONTEXT sl[8], sa[8]; | 1258 PARTITION_CONTEXT sl[8], sa[8]; |
| 1234 int last_part_rate = INT_MAX; | 1259 int last_part_rate = INT_MAX; |
| 1235 int64_t last_part_dist = INT_MAX; | 1260 int64_t last_part_dist = INT64_MAX; |
| 1236 int split_rate = INT_MAX; | 1261 int64_t last_part_rd = INT64_MAX; |
| 1237 int64_t split_dist = INT_MAX; | |
| 1238 int none_rate = INT_MAX; | 1262 int none_rate = INT_MAX; |
| 1239 int64_t none_dist = INT_MAX; | 1263 int64_t none_dist = INT64_MAX; |
| 1264 int64_t none_rd = INT64_MAX; |
| 1240 int chosen_rate = INT_MAX; | 1265 int chosen_rate = INT_MAX; |
| 1241 int64_t chosen_dist = INT_MAX; | 1266 int64_t chosen_dist = INT64_MAX; |
| 1267 int64_t chosen_rd = INT64_MAX; |
| 1242 BLOCK_SIZE sub_subsize = BLOCK_4X4; | 1268 BLOCK_SIZE sub_subsize = BLOCK_4X4; |
| 1243 int splits_below = 0; | 1269 int splits_below = 0; |
| 1244 BLOCK_SIZE bs_type = mi_8x8[0]->mbmi.sb_type; | 1270 BLOCK_SIZE bs_type = mi_8x8[0]->mbmi.sb_type; |
| 1245 | 1271 |
| 1246 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 1272 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
| 1247 return; | 1273 return; |
| 1248 | 1274 |
| 1249 partition = partition_lookup[bsl][bs_type]; | 1275 partition = partition_lookup[bsl][bs_type]; |
| 1250 subsize = get_subsize(bsize, partition); | 1276 subsize = get_subsize(bsize, partition); |
| 1251 | 1277 |
| 1252 if (bsize < BLOCK_8X8) { | 1278 if (bsize < BLOCK_8X8) { |
| 1253 // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 | 1279 // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 |
| 1254 // there is nothing to be done. | 1280 // there is nothing to be done. |
| 1255 if (x->ab_index != 0) { | 1281 if (x->ab_index != 0) { |
| 1256 *rate = 0; | 1282 *rate = 0; |
| 1257 *dist = 0; | 1283 *dist = 0; |
| 1258 return; | 1284 return; |
| 1259 } | 1285 } |
| 1260 } else { | 1286 } else { |
| 1261 *(get_sb_partitioning(x, bsize)) = subsize; | 1287 *(get_sb_partitioning(x, bsize)) = subsize; |
| 1262 } | 1288 } |
| 1263 save_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); | 1289 save_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
| 1264 | 1290 |
| 1265 if (bsize == BLOCK_16X16) { | 1291 if (bsize == BLOCK_16X16) { |
| 1266 set_offsets(cpi, tile, mi_row, mi_col, bsize); | 1292 set_offsets(cpi, tile, mi_row, mi_col, bsize); |
| 1267 x->mb_energy = vp9_block_energy(cpi, x, bsize); | 1293 x->mb_energy = vp9_block_energy(cpi, x, bsize); |
| 1268 } | 1294 } |
| 1269 | 1295 |
| 1270 if (cpi->sf.adjust_partitioning_from_last_frame) { | 1296 if (cpi->sf.partition_search_type == SEARCH_PARTITION && |
| 1297 cpi->sf.adjust_partitioning_from_last_frame) { |
| 1271 // Check if any of the sub blocks are further split. | 1298 // Check if any of the sub blocks are further split. |
| 1272 if (partition == PARTITION_SPLIT && subsize > BLOCK_8X8) { | 1299 if (partition == PARTITION_SPLIT && subsize > BLOCK_8X8) { |
| 1273 sub_subsize = get_subsize(subsize, PARTITION_SPLIT); | 1300 sub_subsize = get_subsize(subsize, PARTITION_SPLIT); |
| 1274 splits_below = 1; | 1301 splits_below = 1; |
| 1275 for (i = 0; i < 4; i++) { | 1302 for (i = 0; i < 4; i++) { |
| 1276 int jj = i >> 1, ii = i & 0x01; | 1303 int jj = i >> 1, ii = i & 0x01; |
| 1277 MODE_INFO * this_mi = mi_8x8[jj * bss * mis + ii * bss]; | 1304 MODE_INFO * this_mi = mi_8x8[jj * bss * mis + ii * bss]; |
| 1278 if (this_mi && this_mi->mbmi.sb_type >= sub_subsize) { | 1305 if (this_mi && this_mi->mbmi.sb_type >= sub_subsize) { |
| 1279 splits_below = 0; | 1306 splits_below = 0; |
| 1280 } | 1307 } |
| 1281 } | 1308 } |
| 1282 } | 1309 } |
| 1283 | 1310 |
| 1284 // If partition is not none try none unless each of the 4 splits are split | 1311 // If partition is not none try none unless each of the 4 splits are split |
| 1285 // even further.. | 1312 // even further.. |
| 1286 if (partition != PARTITION_NONE && !splits_below && | 1313 if (partition != PARTITION_NONE && !splits_below && |
| 1287 mi_row + (ms >> 1) < cm->mi_rows && | 1314 mi_row + (ms >> 1) < cm->mi_rows && |
| 1288 mi_col + (ms >> 1) < cm->mi_cols) { | 1315 mi_col + (ms >> 1) < cm->mi_cols) { |
| 1289 *(get_sb_partitioning(x, bsize)) = bsize; | 1316 *(get_sb_partitioning(x, bsize)) = bsize; |
| 1290 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize, | 1317 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize, |
| 1291 get_block_context(x, bsize), INT64_MAX); | 1318 get_block_context(x, bsize), INT64_MAX); |
| 1292 | 1319 |
| 1293 pl = partition_plane_context(cpi->above_seg_context, | 1320 pl = partition_plane_context(cpi->above_seg_context, |
| 1294 cpi->left_seg_context, | 1321 cpi->left_seg_context, |
| 1295 mi_row, mi_col, bsize); | 1322 mi_row, mi_col, bsize); |
| 1296 none_rate += x->partition_cost[pl][PARTITION_NONE]; | 1323 |
| 1324 if (none_rate < INT_MAX) { |
| 1325 none_rate += x->partition_cost[pl][PARTITION_NONE]; |
| 1326 none_rd = RDCOST(x->rdmult, x->rddiv, none_rate, none_dist); |
| 1327 } |
| 1297 | 1328 |
| 1298 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); | 1329 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
| 1299 mi_8x8[0]->mbmi.sb_type = bs_type; | 1330 mi_8x8[0]->mbmi.sb_type = bs_type; |
| 1300 *(get_sb_partitioning(x, bsize)) = subsize; | 1331 *(get_sb_partitioning(x, bsize)) = subsize; |
| 1301 } | 1332 } |
| 1302 } | 1333 } |
| 1303 | 1334 |
| 1304 switch (partition) { | 1335 switch (partition) { |
| 1305 case PARTITION_NONE: | 1336 case PARTITION_NONE: |
| 1306 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &last_part_rate, | 1337 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &last_part_rate, |
| 1307 &last_part_dist, bsize, | 1338 &last_part_dist, bsize, |
| 1308 get_block_context(x, bsize), INT64_MAX); | 1339 get_block_context(x, bsize), INT64_MAX); |
| 1309 break; | 1340 break; |
| 1310 case PARTITION_HORZ: | 1341 case PARTITION_HORZ: |
| 1311 *get_sb_index(x, subsize) = 0; | 1342 *get_sb_index(x, subsize) = 0; |
| 1312 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &last_part_rate, | 1343 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &last_part_rate, |
| 1313 &last_part_dist, subsize, | 1344 &last_part_dist, subsize, |
| 1314 get_block_context(x, subsize), INT64_MAX); | 1345 get_block_context(x, subsize), INT64_MAX); |
| 1315 if (last_part_rate != INT_MAX && | 1346 if (last_part_rate != INT_MAX && |
| 1316 bsize >= BLOCK_8X8 && mi_row + (mh >> 1) < cm->mi_rows) { | 1347 bsize >= BLOCK_8X8 && mi_row + (mh >> 1) < cm->mi_rows) { |
| 1317 int rt = 0; | 1348 int rt = 0; |
| 1318 int64_t dt = 0; | 1349 int64_t dt = 0; |
| 1319 update_state(cpi, get_block_context(x, subsize), subsize, 0); | 1350 update_state(cpi, get_block_context(x, subsize), subsize, 0); |
| 1320 encode_superblock(cpi, tp, 0, mi_row, mi_col, subsize); | 1351 encode_superblock(cpi, tp, 0, mi_row, mi_col, subsize); |
| 1321 *get_sb_index(x, subsize) = 1; | 1352 *get_sb_index(x, subsize) = 1; |
| 1322 rd_pick_sb_modes(cpi, tile, mi_row + (ms >> 1), mi_col, &rt, &dt, | 1353 rd_pick_sb_modes(cpi, tile, mi_row + (ms >> 1), mi_col, &rt, &dt, |
| 1323 subsize, get_block_context(x, subsize), INT64_MAX); | 1354 subsize, get_block_context(x, subsize), INT64_MAX); |
| 1324 if (rt == INT_MAX || dt == INT_MAX) { | 1355 if (rt == INT_MAX || dt == INT64_MAX) { |
| 1325 last_part_rate = INT_MAX; | 1356 last_part_rate = INT_MAX; |
| 1326 last_part_dist = INT_MAX; | 1357 last_part_dist = INT64_MAX; |
| 1327 break; | 1358 break; |
| 1328 } | 1359 } |
| 1329 | 1360 |
| 1330 last_part_rate += rt; | 1361 last_part_rate += rt; |
| 1331 last_part_dist += dt; | 1362 last_part_dist += dt; |
| 1332 } | 1363 } |
| 1333 break; | 1364 break; |
| 1334 case PARTITION_VERT: | 1365 case PARTITION_VERT: |
| 1335 *get_sb_index(x, subsize) = 0; | 1366 *get_sb_index(x, subsize) = 0; |
| 1336 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &last_part_rate, | 1367 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &last_part_rate, |
| 1337 &last_part_dist, subsize, | 1368 &last_part_dist, subsize, |
| 1338 get_block_context(x, subsize), INT64_MAX); | 1369 get_block_context(x, subsize), INT64_MAX); |
| 1339 if (last_part_rate != INT_MAX && | 1370 if (last_part_rate != INT_MAX && |
| 1340 bsize >= BLOCK_8X8 && mi_col + (ms >> 1) < cm->mi_cols) { | 1371 bsize >= BLOCK_8X8 && mi_col + (ms >> 1) < cm->mi_cols) { |
| 1341 int rt = 0; | 1372 int rt = 0; |
| 1342 int64_t dt = 0; | 1373 int64_t dt = 0; |
| 1343 update_state(cpi, get_block_context(x, subsize), subsize, 0); | 1374 update_state(cpi, get_block_context(x, subsize), subsize, 0); |
| 1344 encode_superblock(cpi, tp, 0, mi_row, mi_col, subsize); | 1375 encode_superblock(cpi, tp, 0, mi_row, mi_col, subsize); |
| 1345 *get_sb_index(x, subsize) = 1; | 1376 *get_sb_index(x, subsize) = 1; |
| 1346 rd_pick_sb_modes(cpi, tile, mi_row, mi_col + (ms >> 1), &rt, &dt, | 1377 rd_pick_sb_modes(cpi, tile, mi_row, mi_col + (ms >> 1), &rt, &dt, |
| 1347 subsize, get_block_context(x, subsize), INT64_MAX); | 1378 subsize, get_block_context(x, subsize), INT64_MAX); |
| 1348 if (rt == INT_MAX || dt == INT_MAX) { | 1379 if (rt == INT_MAX || dt == INT64_MAX) { |
| 1349 last_part_rate = INT_MAX; | 1380 last_part_rate = INT_MAX; |
| 1350 last_part_dist = INT_MAX; | 1381 last_part_dist = INT64_MAX; |
| 1351 break; | 1382 break; |
| 1352 } | 1383 } |
| 1353 last_part_rate += rt; | 1384 last_part_rate += rt; |
| 1354 last_part_dist += dt; | 1385 last_part_dist += dt; |
| 1355 } | 1386 } |
| 1356 break; | 1387 break; |
| 1357 case PARTITION_SPLIT: | 1388 case PARTITION_SPLIT: |
| 1358 // Split partition. | 1389 // Split partition. |
| 1359 last_part_rate = 0; | 1390 last_part_rate = 0; |
| 1360 last_part_dist = 0; | 1391 last_part_dist = 0; |
| 1361 for (i = 0; i < 4; i++) { | 1392 for (i = 0; i < 4; i++) { |
| 1362 int x_idx = (i & 1) * (ms >> 1); | 1393 int x_idx = (i & 1) * (ms >> 1); |
| 1363 int y_idx = (i >> 1) * (ms >> 1); | 1394 int y_idx = (i >> 1) * (ms >> 1); |
| 1364 int jj = i >> 1, ii = i & 0x01; | 1395 int jj = i >> 1, ii = i & 0x01; |
| 1365 int rt; | 1396 int rt; |
| 1366 int64_t dt; | 1397 int64_t dt; |
| 1367 | 1398 |
| 1368 if ((mi_row + y_idx >= cm->mi_rows) || (mi_col + x_idx >= cm->mi_cols)) | 1399 if ((mi_row + y_idx >= cm->mi_rows) || (mi_col + x_idx >= cm->mi_cols)) |
| 1369 continue; | 1400 continue; |
| 1370 | 1401 |
| 1371 *get_sb_index(x, subsize) = i; | 1402 *get_sb_index(x, subsize) = i; |
| 1372 | 1403 |
| 1373 rd_use_partition(cpi, tile, mi_8x8 + jj * bss * mis + ii * bss, tp, | 1404 rd_use_partition(cpi, tile, mi_8x8 + jj * bss * mis + ii * bss, tp, |
| 1374 mi_row + y_idx, mi_col + x_idx, subsize, &rt, &dt, | 1405 mi_row + y_idx, mi_col + x_idx, subsize, &rt, &dt, |
| 1375 i != 3); | 1406 i != 3); |
| 1376 if (rt == INT_MAX || dt == INT_MAX) { | 1407 if (rt == INT_MAX || dt == INT64_MAX) { |
| 1377 last_part_rate = INT_MAX; | 1408 last_part_rate = INT_MAX; |
| 1378 last_part_dist = INT_MAX; | 1409 last_part_dist = INT64_MAX; |
| 1379 break; | 1410 break; |
| 1380 } | 1411 } |
| 1381 last_part_rate += rt; | 1412 last_part_rate += rt; |
| 1382 last_part_dist += dt; | 1413 last_part_dist += dt; |
| 1383 } | 1414 } |
| 1384 break; | 1415 break; |
| 1385 default: | 1416 default: |
| 1386 assert(0); | 1417 assert(0); |
| 1387 } | 1418 } |
| 1388 | 1419 |
| 1389 pl = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, | 1420 pl = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, |
| 1390 mi_row, mi_col, bsize); | 1421 mi_row, mi_col, bsize); |
| 1391 if (last_part_rate < INT_MAX) | 1422 if (last_part_rate < INT_MAX) { |
| 1392 last_part_rate += x->partition_cost[pl][partition]; | 1423 last_part_rate += x->partition_cost[pl][partition]; |
| 1424 last_part_rd = RDCOST(x->rdmult, x->rddiv, last_part_rate, last_part_dist); |
| 1425 } |
| 1393 | 1426 |
| 1394 if (cpi->sf.adjust_partitioning_from_last_frame | 1427 if (cpi->sf.adjust_partitioning_from_last_frame |
| 1428 && cpi->sf.partition_search_type == SEARCH_PARTITION |
| 1395 && partition != PARTITION_SPLIT && bsize > BLOCK_8X8 | 1429 && partition != PARTITION_SPLIT && bsize > BLOCK_8X8 |
| 1396 && (mi_row + ms < cm->mi_rows || mi_row + (ms >> 1) == cm->mi_rows) | 1430 && (mi_row + ms < cm->mi_rows || mi_row + (ms >> 1) == cm->mi_rows) |
| 1397 && (mi_col + ms < cm->mi_cols || mi_col + (ms >> 1) == cm->mi_cols)) { | 1431 && (mi_col + ms < cm->mi_cols || mi_col + (ms >> 1) == cm->mi_cols)) { |
| 1398 BLOCK_SIZE split_subsize = get_subsize(bsize, PARTITION_SPLIT); | 1432 BLOCK_SIZE split_subsize = get_subsize(bsize, PARTITION_SPLIT); |
| 1399 split_rate = 0; | 1433 chosen_rate = 0; |
| 1400 split_dist = 0; | 1434 chosen_dist = 0; |
| 1401 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); | 1435 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
| 1402 | 1436 |
| 1403 // Split partition. | 1437 // Split partition. |
| 1404 for (i = 0; i < 4; i++) { | 1438 for (i = 0; i < 4; i++) { |
| 1405 int x_idx = (i & 1) * (num_4x4_blocks_wide >> 2); | 1439 int x_idx = (i & 1) * (num_4x4_blocks_wide >> 2); |
| 1406 int y_idx = (i >> 1) * (num_4x4_blocks_wide >> 2); | 1440 int y_idx = (i >> 1) * (num_4x4_blocks_wide >> 2); |
| 1407 int rt = 0; | 1441 int rt = 0; |
| 1408 int64_t dt = 0; | 1442 int64_t dt = 0; |
| 1409 ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; | 1443 ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; |
| 1410 PARTITION_CONTEXT sl[8], sa[8]; | 1444 PARTITION_CONTEXT sl[8], sa[8]; |
| 1411 | 1445 |
| 1412 if ((mi_row + y_idx >= cm->mi_rows) || (mi_col + x_idx >= cm->mi_cols)) | 1446 if ((mi_row + y_idx >= cm->mi_rows) || (mi_col + x_idx >= cm->mi_cols)) |
| 1413 continue; | 1447 continue; |
| 1414 | 1448 |
| 1415 *get_sb_index(x, split_subsize) = i; | 1449 *get_sb_index(x, split_subsize) = i; |
| 1416 *get_sb_partitioning(x, bsize) = split_subsize; | 1450 *get_sb_partitioning(x, bsize) = split_subsize; |
| 1417 *get_sb_partitioning(x, split_subsize) = split_subsize; | 1451 *get_sb_partitioning(x, split_subsize) = split_subsize; |
| 1418 | 1452 |
| 1419 save_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); | 1453 save_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
| 1420 | 1454 |
| 1421 rd_pick_sb_modes(cpi, tile, mi_row + y_idx, mi_col + x_idx, &rt, &dt, | 1455 rd_pick_sb_modes(cpi, tile, mi_row + y_idx, mi_col + x_idx, &rt, &dt, |
| 1422 split_subsize, get_block_context(x, split_subsize), | 1456 split_subsize, get_block_context(x, split_subsize), |
| 1423 INT64_MAX); | 1457 INT64_MAX); |
| 1424 | 1458 |
| 1425 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); | 1459 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
| 1426 | 1460 |
| 1427 if (rt == INT_MAX || dt == INT_MAX) { | 1461 if (rt == INT_MAX || dt == INT64_MAX) { |
| 1428 split_rate = INT_MAX; | 1462 chosen_rate = INT_MAX; |
| 1429 split_dist = INT_MAX; | 1463 chosen_dist = INT64_MAX; |
| 1430 break; | 1464 break; |
| 1431 } | 1465 } |
| 1432 | 1466 |
| 1467 chosen_rate += rt; |
| 1468 chosen_dist += dt; |
| 1469 |
| 1433 if (i != 3) | 1470 if (i != 3) |
| 1434 encode_sb(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, 0, | 1471 encode_sb(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, 0, |
| 1435 split_subsize); | 1472 split_subsize); |
| 1436 | 1473 |
| 1437 split_rate += rt; | |
| 1438 split_dist += dt; | |
| 1439 pl = partition_plane_context(cpi->above_seg_context, | 1474 pl = partition_plane_context(cpi->above_seg_context, |
| 1440 cpi->left_seg_context, | 1475 cpi->left_seg_context, |
| 1441 mi_row + y_idx, mi_col + x_idx, | 1476 mi_row + y_idx, mi_col + x_idx, |
| 1442 split_subsize); | 1477 split_subsize); |
| 1443 split_rate += x->partition_cost[pl][PARTITION_NONE]; | 1478 chosen_rate += x->partition_cost[pl][PARTITION_NONE]; |
| 1444 } | 1479 } |
| 1445 pl = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, | 1480 pl = partition_plane_context(cpi->above_seg_context, cpi->left_seg_context, |
| 1446 mi_row, mi_col, bsize); | 1481 mi_row, mi_col, bsize); |
| 1447 if (split_rate < INT_MAX) { | 1482 if (chosen_rate < INT_MAX) { |
| 1448 split_rate += x->partition_cost[pl][PARTITION_SPLIT]; | 1483 chosen_rate += x->partition_cost[pl][PARTITION_SPLIT]; |
| 1449 | 1484 chosen_rd = RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist); |
| 1450 chosen_rate = split_rate; | |
| 1451 chosen_dist = split_dist; | |
| 1452 } | 1485 } |
| 1453 } | 1486 } |
| 1454 | 1487 |
| 1455 // If last_part is better set the partitioning to that... | 1488 // If last_part is better set the partitioning to that... |
| 1456 if (RDCOST(x->rdmult, x->rddiv, last_part_rate, last_part_dist) | 1489 if (last_part_rd < chosen_rd) { |
| 1457 < RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist)) { | |
| 1458 mi_8x8[0]->mbmi.sb_type = bsize; | 1490 mi_8x8[0]->mbmi.sb_type = bsize; |
| 1459 if (bsize >= BLOCK_8X8) | 1491 if (bsize >= BLOCK_8X8) |
| 1460 *(get_sb_partitioning(x, bsize)) = subsize; | 1492 *(get_sb_partitioning(x, bsize)) = subsize; |
| 1461 chosen_rate = last_part_rate; | 1493 chosen_rate = last_part_rate; |
| 1462 chosen_dist = last_part_dist; | 1494 chosen_dist = last_part_dist; |
| 1495 chosen_rd = last_part_rd; |
| 1463 } | 1496 } |
| 1464 // If none was better set the partitioning to that... | 1497 // If none was better set the partitioning to that... |
| 1465 if (RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist) | 1498 if (none_rd < chosen_rd) { |
| 1466 > RDCOST(x->rdmult, x->rddiv, none_rate, none_dist)) { | |
| 1467 if (bsize >= BLOCK_8X8) | 1499 if (bsize >= BLOCK_8X8) |
| 1468 *(get_sb_partitioning(x, bsize)) = bsize; | 1500 *(get_sb_partitioning(x, bsize)) = bsize; |
| 1469 chosen_rate = none_rate; | 1501 chosen_rate = none_rate; |
| 1470 chosen_dist = none_dist; | 1502 chosen_dist = none_dist; |
| 1471 } | 1503 } |
| 1472 | 1504 |
| 1473 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); | 1505 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
| 1474 | 1506 |
| 1475 // We must have chosen a partitioning and encoding or we'll fail later on. | 1507 // We must have chosen a partitioning and encoding or we'll fail later on. |
| 1476 // No other opportunities for success. | 1508 // No other opportunities for success. |
| 1477 if ( bsize == BLOCK_64X64) | 1509 if ( bsize == BLOCK_64X64) |
| 1478 assert(chosen_rate < INT_MAX && chosen_dist < INT_MAX); | 1510 assert(chosen_rate < INT_MAX && chosen_dist < INT64_MAX); |
| 1479 | 1511 |
| 1480 if (do_recon) { | 1512 if (do_recon) { |
| 1481 int output_enabled = (bsize == BLOCK_64X64); | 1513 int output_enabled = (bsize == BLOCK_64X64); |
| 1482 | 1514 |
| 1483 // Check the projected output rate for this SB against it's target | 1515 // Check the projected output rate for this SB against it's target |
| 1484 // and and if necessary apply a Q delta using segmentation to get | 1516 // and and if necessary apply a Q delta using segmentation to get |
| 1485 // closer to the target. | 1517 // closer to the target. |
| 1486 if ((cpi->oxcf.aq_mode == COMPLEXITY_AQ) && cm->seg.update_map) { | 1518 if ((cpi->oxcf.aq_mode == COMPLEXITY_AQ) && cm->seg.update_map) { |
| 1487 select_in_frame_q_segment(cpi, mi_row, mi_col, | 1519 select_in_frame_q_segment(cpi, mi_row, mi_col, |
| 1488 output_enabled, chosen_rate); | 1520 output_enabled, chosen_rate); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 // and and if necessary apply a Q delta using segmentation to get | 1958 // and and if necessary apply a Q delta using segmentation to get |
| 1927 // closer to the target. | 1959 // closer to the target. |
| 1928 if ((cpi->oxcf.aq_mode == COMPLEXITY_AQ) && cm->seg.update_map) { | 1960 if ((cpi->oxcf.aq_mode == COMPLEXITY_AQ) && cm->seg.update_map) { |
| 1929 select_in_frame_q_segment(cpi, mi_row, mi_col, output_enabled, best_rate); | 1961 select_in_frame_q_segment(cpi, mi_row, mi_col, output_enabled, best_rate); |
| 1930 } | 1962 } |
| 1931 encode_sb(cpi, tile, tp, mi_row, mi_col, output_enabled, bsize); | 1963 encode_sb(cpi, tile, tp, mi_row, mi_col, output_enabled, bsize); |
| 1932 } | 1964 } |
| 1933 if (bsize == BLOCK_64X64) { | 1965 if (bsize == BLOCK_64X64) { |
| 1934 assert(tp_orig < *tp); | 1966 assert(tp_orig < *tp); |
| 1935 assert(best_rate < INT_MAX); | 1967 assert(best_rate < INT_MAX); |
| 1936 assert(best_dist < INT_MAX); | 1968 assert(best_dist < INT64_MAX); |
| 1937 } else { | 1969 } else { |
| 1938 assert(tp_orig == *tp); | 1970 assert(tp_orig == *tp); |
| 1939 } | 1971 } |
| 1940 } | 1972 } |
| 1941 | 1973 |
| 1942 static void encode_sb_row(VP9_COMP *cpi, const TileInfo *const tile, | 1974 static void encode_rd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, |
| 1943 int mi_row, TOKENEXTRA **tp) { | 1975 int mi_row, TOKENEXTRA **tp) { |
| 1944 VP9_COMMON *const cm = &cpi->common; | 1976 VP9_COMMON *const cm = &cpi->common; |
| 1945 int mi_col; | 1977 int mi_col; |
| 1946 | 1978 |
| 1947 // Initialize the left context for the new SB row | 1979 // Initialize the left context for the new SB row |
| 1948 vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context)); | 1980 vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context)); |
| 1949 vpx_memset(cpi->left_seg_context, 0, sizeof(cpi->left_seg_context)); | 1981 vpx_memset(cpi->left_seg_context, 0, sizeof(cpi->left_seg_context)); |
| 1950 | 1982 |
| 1951 // Code each SB in the row | 1983 // Code each SB in the row |
| 1952 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; | 1984 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; |
| 1953 mi_col += MI_BLOCK_SIZE) { | 1985 mi_col += MI_BLOCK_SIZE) { |
| 1954 int dummy_rate; | 1986 int dummy_rate; |
| 1955 int64_t dummy_dist; | 1987 int64_t dummy_dist; |
| 1956 | 1988 |
| 1957 BLOCK_SIZE i; | 1989 BLOCK_SIZE i; |
| 1958 MACROBLOCK *x = &cpi->mb; | 1990 MACROBLOCK *x = &cpi->mb; |
| 1959 for (i = BLOCK_4X4; i < BLOCK_8X8; ++i) { | 1991 |
| 1960 const int num_4x4_w = num_4x4_blocks_wide_lookup[i]; | 1992 if (cpi->sf.adaptive_pred_interp_filter) { |
| 1961 const int num_4x4_h = num_4x4_blocks_high_lookup[i]; | 1993 for (i = BLOCK_4X4; i < BLOCK_8X8; ++i) { |
| 1962 const int num_4x4_blk = MAX(4, num_4x4_w * num_4x4_h); | 1994 const int num_4x4_w = num_4x4_blocks_wide_lookup[i]; |
| 1963 for (x->sb_index = 0; x->sb_index < 4; ++x->sb_index) | 1995 const int num_4x4_h = num_4x4_blocks_high_lookup[i]; |
| 1964 for (x->mb_index = 0; x->mb_index < 4; ++x->mb_index) | 1996 const int num_4x4_blk = MAX(4, num_4x4_w * num_4x4_h); |
| 1965 for (x->b_index = 0; x->b_index < 16 / num_4x4_blk; ++x->b_index) | 1997 for (x->sb_index = 0; x->sb_index < 4; ++x->sb_index) |
| 1966 get_block_context(x, i)->pred_interp_filter = SWITCHABLE; | 1998 for (x->mb_index = 0; x->mb_index < 4; ++x->mb_index) |
| 1999 for (x->b_index = 0; x->b_index < 16 / num_4x4_blk; ++x->b_index) |
| 2000 get_block_context(x, i)->pred_interp_filter = SWITCHABLE; |
| 2001 } |
| 1967 } | 2002 } |
| 1968 | 2003 |
| 1969 vp9_zero(cpi->mb.pred_mv); | 2004 vp9_zero(cpi->mb.pred_mv); |
| 1970 | 2005 |
| 1971 if (cpi->sf.use_lastframe_partitioning || | 2006 if ((cpi->sf.partition_search_type == SEARCH_PARTITION && |
| 1972 cpi->sf.use_one_partition_size_always ) { | 2007 cpi->sf.use_lastframe_partitioning) || |
| 2008 cpi->sf.partition_search_type == FIXED_PARTITION || |
| 2009 cpi->sf.partition_search_type == VAR_BASED_FIXED_PARTITION) { |
| 1973 const int idx_str = cm->mode_info_stride * mi_row + mi_col; | 2010 const int idx_str = cm->mode_info_stride * mi_row + mi_col; |
| 1974 MODE_INFO **mi_8x8 = cm->mi_grid_visible + idx_str; | 2011 MODE_INFO **mi_8x8 = cm->mi_grid_visible + idx_str; |
| 1975 MODE_INFO **prev_mi_8x8 = cm->prev_mi_grid_visible + idx_str; | 2012 MODE_INFO **prev_mi_8x8 = cm->prev_mi_grid_visible + idx_str; |
| 1976 | 2013 |
| 1977 cpi->mb.source_variance = UINT_MAX; | 2014 cpi->mb.source_variance = UINT_MAX; |
| 1978 if (cpi->sf.use_one_partition_size_always) { | 2015 if (cpi->sf.partition_search_type == FIXED_PARTITION) { |
| 1979 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); | 2016 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); |
| 1980 set_partitioning(cpi, tile, mi_8x8, mi_row, mi_col); | 2017 set_partitioning(cpi, tile, mi_8x8, mi_row, mi_col, |
| 2018 cpi->sf.always_this_block_size); |
| 2019 rd_use_partition(cpi, tile, mi_8x8, tp, mi_row, mi_col, BLOCK_64X64, |
| 2020 &dummy_rate, &dummy_dist, 1); |
| 2021 } else if (cpi->sf.partition_search_type == VAR_BASED_FIXED_PARTITION || |
| 2022 cpi->sf.partition_search_type == VAR_BASED_PARTITION) { |
| 2023 // TODO(debargha): Implement VAR_BASED_PARTITION as a separate case. |
| 2024 // Currently both VAR_BASED_FIXED_PARTITION/VAR_BASED_PARTITION |
| 2025 // map to the same thing. |
| 2026 BLOCK_SIZE bsize; |
| 2027 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); |
| 2028 bsize = get_rd_var_based_fixed_partition(cpi, mi_row, mi_col); |
| 2029 set_partitioning(cpi, tile, mi_8x8, mi_row, mi_col, bsize); |
| 1981 rd_use_partition(cpi, tile, mi_8x8, tp, mi_row, mi_col, BLOCK_64X64, | 2030 rd_use_partition(cpi, tile, mi_8x8, tp, mi_row, mi_col, BLOCK_64X64, |
| 1982 &dummy_rate, &dummy_dist, 1); | 2031 &dummy_rate, &dummy_dist, 1); |
| 1983 } else { | 2032 } else { |
| 1984 if ((cm->current_video_frame | 2033 if ((cm->current_video_frame |
| 1985 % cpi->sf.last_partitioning_redo_frequency) == 0 | 2034 % cpi->sf.last_partitioning_redo_frequency) == 0 |
| 1986 || cm->prev_mi == 0 | 2035 || cm->prev_mi == 0 |
| 1987 || cm->show_frame == 0 | 2036 || cm->show_frame == 0 |
| 1988 || cm->frame_type == KEY_FRAME | 2037 || cm->frame_type == KEY_FRAME |
| 1989 || cpi->rc.is_src_frame_alt_ref | 2038 || cpi->rc.is_src_frame_alt_ref |
| 1990 || ((cpi->sf.use_lastframe_partitioning == | 2039 || ((cpi->sf.use_lastframe_partitioning == |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2112 static void set_txfm_flag(MODE_INFO **mi_8x8, int mis, int ymbs, int xmbs, | 2161 static void set_txfm_flag(MODE_INFO **mi_8x8, int mis, int ymbs, int xmbs, |
| 2113 TX_SIZE tx_size) { | 2162 TX_SIZE tx_size) { |
| 2114 int x, y; | 2163 int x, y; |
| 2115 | 2164 |
| 2116 for (y = 0; y < ymbs; y++) { | 2165 for (y = 0; y < ymbs; y++) { |
| 2117 for (x = 0; x < xmbs; x++) | 2166 for (x = 0; x < xmbs; x++) |
| 2118 mi_8x8[y * mis + x]->mbmi.tx_size = tx_size; | 2167 mi_8x8[y * mis + x]->mbmi.tx_size = tx_size; |
| 2119 } | 2168 } |
| 2120 } | 2169 } |
| 2121 | 2170 |
| 2122 static void reset_skip_txfm_size_b(VP9_COMMON *cm, MODE_INFO **mi_8x8, | 2171 static void reset_skip_txfm_size_b(const VP9_COMMON *cm, int mis, |
| 2123 int mis, TX_SIZE max_tx_size, int bw, int bh, | 2172 TX_SIZE max_tx_size, int bw, int bh, |
| 2124 int mi_row, int mi_col, BLOCK_SIZE bsize) { | 2173 int mi_row, int mi_col, |
| 2174 MODE_INFO **mi_8x8) { |
| 2125 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) { | 2175 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) { |
| 2126 return; | 2176 return; |
| 2127 } else { | 2177 } else { |
| 2128 MB_MODE_INFO * const mbmi = &mi_8x8[0]->mbmi; | 2178 MB_MODE_INFO * const mbmi = &mi_8x8[0]->mbmi; |
| 2129 if (mbmi->tx_size > max_tx_size) { | 2179 if (mbmi->tx_size > max_tx_size) { |
| 2130 const int ymbs = MIN(bh, cm->mi_rows - mi_row); | 2180 const int ymbs = MIN(bh, cm->mi_rows - mi_row); |
| 2131 const int xmbs = MIN(bw, cm->mi_cols - mi_col); | 2181 const int xmbs = MIN(bw, cm->mi_cols - mi_col); |
| 2132 | 2182 |
| 2133 assert(vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) || | 2183 assert(vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP) || |
| 2134 get_skip_flag(mi_8x8, mis, ymbs, xmbs)); | 2184 get_skip_flag(mi_8x8, mis, ymbs, xmbs)); |
| 2135 set_txfm_flag(mi_8x8, mis, ymbs, xmbs, max_tx_size); | 2185 set_txfm_flag(mi_8x8, mis, ymbs, xmbs, max_tx_size); |
| 2136 } | 2186 } |
| 2137 } | 2187 } |
| 2138 } | 2188 } |
| 2139 | 2189 |
| 2140 static void reset_skip_txfm_size_sb(VP9_COMMON *cm, MODE_INFO **mi_8x8, | 2190 static void reset_skip_txfm_size_sb(VP9_COMMON *cm, MODE_INFO **mi_8x8, |
| 2141 TX_SIZE max_tx_size, int mi_row, int mi_col, | 2191 TX_SIZE max_tx_size, int mi_row, int mi_col, |
| 2142 BLOCK_SIZE bsize) { | 2192 BLOCK_SIZE bsize) { |
| 2143 const int mis = cm->mode_info_stride; | 2193 const int mis = cm->mode_info_stride; |
| 2144 int bw, bh; | 2194 int bw, bh; |
| 2145 const int bs = num_8x8_blocks_wide_lookup[bsize], hbs = bs / 2; | 2195 const int bs = num_8x8_blocks_wide_lookup[bsize], hbs = bs / 2; |
| 2146 | 2196 |
| 2147 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 2197 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
| 2148 return; | 2198 return; |
| 2149 | 2199 |
| 2150 bw = num_8x8_blocks_wide_lookup[mi_8x8[0]->mbmi.sb_type]; | 2200 bw = num_8x8_blocks_wide_lookup[mi_8x8[0]->mbmi.sb_type]; |
| 2151 bh = num_8x8_blocks_high_lookup[mi_8x8[0]->mbmi.sb_type]; | 2201 bh = num_8x8_blocks_high_lookup[mi_8x8[0]->mbmi.sb_type]; |
| 2152 | 2202 |
| 2153 if (bw == bs && bh == bs) { | 2203 if (bw == bs && bh == bs) { |
| 2154 reset_skip_txfm_size_b(cm, mi_8x8, mis, max_tx_size, bs, bs, mi_row, | 2204 reset_skip_txfm_size_b(cm, mis, max_tx_size, bs, bs, mi_row, mi_col, |
| 2155 mi_col, bsize); | 2205 mi_8x8); |
| 2156 } else if (bw == bs && bh < bs) { | 2206 } else if (bw == bs && bh < bs) { |
| 2157 reset_skip_txfm_size_b(cm, mi_8x8, mis, max_tx_size, bs, hbs, mi_row, | 2207 reset_skip_txfm_size_b(cm, mis, max_tx_size, bs, hbs, mi_row, mi_col, |
| 2158 mi_col, bsize); | 2208 mi_8x8); |
| 2159 reset_skip_txfm_size_b(cm, mi_8x8 + hbs * mis, mis, max_tx_size, bs, hbs, | 2209 reset_skip_txfm_size_b(cm, mis, max_tx_size, bs, hbs, mi_row + hbs, |
| 2160 mi_row + hbs, mi_col, bsize); | 2210 mi_col, mi_8x8 + hbs * mis); |
| 2161 } else if (bw < bs && bh == bs) { | 2211 } else if (bw < bs && bh == bs) { |
| 2162 reset_skip_txfm_size_b(cm, mi_8x8, mis, max_tx_size, hbs, bs, mi_row, | 2212 reset_skip_txfm_size_b(cm, mis, max_tx_size, hbs, bs, mi_row, mi_col, |
| 2163 mi_col, bsize); | 2213 mi_8x8); |
| 2164 reset_skip_txfm_size_b(cm, mi_8x8 + hbs, mis, max_tx_size, hbs, bs, mi_row, | 2214 reset_skip_txfm_size_b(cm, mis, max_tx_size, hbs, bs, mi_row, |
| 2165 mi_col + hbs, bsize); | 2215 mi_col + hbs, mi_8x8 + hbs); |
| 2166 | |
| 2167 } else { | 2216 } else { |
| 2168 const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize]; | 2217 const BLOCK_SIZE subsize = subsize_lookup[PARTITION_SPLIT][bsize]; |
| 2169 int n; | 2218 int n; |
| 2170 | 2219 |
| 2171 assert(bw < bs && bh < bs); | 2220 assert(bw < bs && bh < bs); |
| 2172 | 2221 |
| 2173 for (n = 0; n < 4; n++) { | 2222 for (n = 0; n < 4; n++) { |
| 2174 const int mi_dc = hbs * (n & 1); | 2223 const int mi_dc = hbs * (n & 1); |
| 2175 const int mi_dr = hbs * (n >> 1); | 2224 const int mi_dr = hbs * (n >> 1); |
| 2176 | 2225 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 ZERO_PLUS_PREDICTED = 1, | 2288 ZERO_PLUS_PREDICTED = 1, |
| 2240 BOTH_PREDICTED = 2, | 2289 BOTH_PREDICTED = 2, |
| 2241 NEW_PLUS_NON_INTRA = 3, | 2290 NEW_PLUS_NON_INTRA = 3, |
| 2242 BOTH_NEW = 4, | 2291 BOTH_NEW = 4, |
| 2243 INTRA_PLUS_NON_INTRA = 5, | 2292 INTRA_PLUS_NON_INTRA = 5, |
| 2244 BOTH_INTRA = 6, | 2293 BOTH_INTRA = 6, |
| 2245 INVALID_CASE = 9 | 2294 INVALID_CASE = 9 |
| 2246 } motion_vector_context; | 2295 } motion_vector_context; |
| 2247 | 2296 |
| 2248 static void set_mode_info(MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, | 2297 static void set_mode_info(MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, |
| 2249 MB_PREDICTION_MODE mode, int mi_row, int mi_col) { | 2298 MB_PREDICTION_MODE mode) { |
| 2250 mbmi->interp_filter = EIGHTTAP; | 2299 mbmi->interp_filter = EIGHTTAP; |
| 2251 mbmi->mode = mode; | 2300 mbmi->mode = mode; |
| 2252 mbmi->mv[0].as_int = 0; | 2301 mbmi->mv[0].as_int = 0; |
| 2253 mbmi->mv[1].as_int = 0; | 2302 mbmi->mv[1].as_int = 0; |
| 2254 if (mode < NEARESTMV) { | 2303 if (mode < NEARESTMV) { |
| 2255 mbmi->ref_frame[0] = INTRA_FRAME; | 2304 mbmi->ref_frame[0] = INTRA_FRAME; |
| 2256 } else { | 2305 } else { |
| 2257 mbmi->ref_frame[0] = LAST_FRAME; | 2306 mbmi->ref_frame[0] = LAST_FRAME; |
| 2258 } | 2307 } |
| 2259 | 2308 |
| 2260 mbmi->ref_frame[1] = INTRA_FRAME; | 2309 mbmi->ref_frame[1] = INTRA_FRAME; |
| 2261 mbmi->tx_size = max_txsize_lookup[bsize]; | 2310 mbmi->tx_size = max_txsize_lookup[bsize]; |
| 2262 mbmi->uv_mode = mode; | 2311 mbmi->uv_mode = mode; |
| 2263 mbmi->skip = 0; | 2312 mbmi->skip = 0; |
| 2264 mbmi->sb_type = bsize; | 2313 mbmi->sb_type = bsize; |
| 2265 mbmi->segment_id = 0; | 2314 mbmi->segment_id = 0; |
| 2266 } | 2315 } |
| 2267 | 2316 |
| 2268 static INLINE int get_block_row(int b32i, int b16i, int b8i) { | 2317 static INLINE int get_block_row(int b32i, int b16i, int b8i) { |
| 2269 return ((b32i >> 1) << 2) + ((b16i >> 1) << 1) + (b8i >> 1); | 2318 return ((b32i >> 1) << 2) + ((b16i >> 1) << 1) + (b8i >> 1); |
| 2270 } | 2319 } |
| 2271 | 2320 |
| 2272 static INLINE int get_block_col(int b32i, int b16i, int b8i) { | 2321 static INLINE int get_block_col(int b32i, int b16i, int b8i) { |
| 2273 return ((b32i & 1) << 2) + ((b16i & 1) << 1) + (b8i & 1); | 2322 return ((b32i & 1) << 2) + ((b16i & 1) << 1) + (b8i & 1); |
| 2274 } | 2323 } |
| 2275 | 2324 |
| 2276 static void rtc_use_partition(VP9_COMP *cpi, | 2325 static void nonrd_use_partition(VP9_COMP *cpi, const TileInfo *const tile, |
| 2277 const TileInfo *const tile, | 2326 TOKENEXTRA **tp, int mi_row, int mi_col, |
| 2278 MODE_INFO **mi_8x8, | 2327 BLOCK_SIZE bsize, int *rate, int64_t *dist) { |
| 2279 TOKENEXTRA **tp, int mi_row, int mi_col, | |
| 2280 BLOCK_SIZE bsize, int *rate, int64_t *dist, | |
| 2281 int do_recon) { | |
| 2282 VP9_COMMON *const cm = &cpi->common; | 2328 VP9_COMMON *const cm = &cpi->common; |
| 2283 MACROBLOCK *const x = &cpi->mb; | 2329 MACROBLOCK *const x = &cpi->mb; |
| 2284 MACROBLOCKD *const xd = &cpi->mb.e_mbd; | 2330 MACROBLOCKD *const xd = &cpi->mb.e_mbd; |
| 2285 const int mis = cm->mode_info_stride; | 2331 int mis = cm->mode_info_stride; |
| 2286 int mi_width = num_8x8_blocks_wide_lookup[cpi->sf.always_this_block_size]; | 2332 int br, bc; |
| 2287 int mi_height = num_8x8_blocks_high_lookup[cpi->sf.always_this_block_size]; | |
| 2288 int i, j; | 2333 int i, j; |
| 2289 int chosen_rate = INT_MAX; | |
| 2290 int64_t chosen_dist = INT_MAX; | |
| 2291 MB_PREDICTION_MODE mode = DC_PRED; | 2334 MB_PREDICTION_MODE mode = DC_PRED; |
| 2292 int row8x8_remaining = tile->mi_row_end - mi_row; | 2335 int rows = MIN(MI_BLOCK_SIZE, tile->mi_row_end - mi_row); |
| 2293 int col8x8_remaining = tile->mi_col_end - mi_col; | 2336 int cols = MIN(MI_BLOCK_SIZE, tile->mi_col_end - mi_col); |
| 2294 int b32i; | |
| 2295 for (b32i = 0; b32i < 4; b32i++) { | |
| 2296 int b16i; | |
| 2297 for (b16i = 0; b16i < 4; b16i++) { | |
| 2298 int b8i; | |
| 2299 int block_row = get_block_row(b32i, b16i, 0); | |
| 2300 int block_col = get_block_col(b32i, b16i, 0); | |
| 2301 int index = block_row * mis + block_col; | |
| 2302 int rate; | |
| 2303 int64_t dist; | |
| 2304 | 2337 |
| 2305 // Find a partition size that fits | 2338 int bw = num_8x8_blocks_wide_lookup[bsize]; |
| 2306 bsize = find_partition_size(cpi->sf.always_this_block_size, | 2339 int bh = num_8x8_blocks_high_lookup[bsize]; |
| 2307 (row8x8_remaining - block_row), | |
| 2308 (col8x8_remaining - block_col), | |
| 2309 &mi_height, &mi_width); | |
| 2310 mi_8x8[index] = mi_8x8[0] + index; | |
| 2311 | 2340 |
| 2312 set_mi_row_col(xd, tile, mi_row + block_row, mi_height, | 2341 int brate = 0; |
| 2313 mi_col + block_col, mi_width, cm->mi_rows, cm->mi_cols); | 2342 int64_t bdist = 0; |
| 2343 *rate = 0; |
| 2344 *dist = 0; |
| 2314 | 2345 |
| 2315 xd->mi_8x8 = mi_8x8 + index; | 2346 // find prediction mode for each 8x8 block |
| 2347 for (br = 0; br < rows; br += bh) { |
| 2348 for (bc = 0; bc < cols; bc += bw) { |
| 2349 int row = mi_row + br; |
| 2350 int col = mi_col + bc; |
| 2316 | 2351 |
| 2317 if (cm->frame_type != KEY_FRAME) { | 2352 BLOCK_SIZE bs = find_partition_size(bsize, rows - br, cols - bc, |
| 2318 set_offsets(cpi, tile, mi_row + block_row, mi_col + block_col, bsize); | 2353 &bh, &bw); |
| 2319 | 2354 |
| 2320 vp9_pick_inter_mode(cpi, x, tile, | 2355 set_offsets(cpi, tile, row, col, bs); |
| 2321 mi_row + block_row, mi_col + block_col, | |
| 2322 &rate, &dist, bsize); | |
| 2323 } else { | |
| 2324 set_mode_info(&mi_8x8[index]->mbmi, bsize, mode, | |
| 2325 mi_row + block_row, mi_col + block_col); | |
| 2326 } | |
| 2327 | 2356 |
| 2328 for (j = 0; j < mi_height; j++) | 2357 if (cm->frame_type != KEY_FRAME) |
| 2329 for (i = 0; i < mi_width; i++) | 2358 vp9_pick_inter_mode(cpi, x, tile, row, col, |
| 2330 if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > i | 2359 &brate, &bdist, bs); |
| 2331 && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > j) { | 2360 else |
| 2332 mi_8x8[index+ i + j * mis] = mi_8x8[index]; | 2361 set_mode_info(&xd->mi_8x8[0]->mbmi, bs, mode); |
| 2333 } | |
| 2334 | 2362 |
| 2335 for (b8i = 0; b8i < 4; b8i++) { | 2363 *rate += brate; |
| 2336 } | 2364 *dist += bdist; |
| 2365 |
| 2366 for (j = 0; j < bh; ++j) |
| 2367 for (i = 0; i < bw; ++i) |
| 2368 xd->mi_8x8[j * mis + i] = xd->mi_8x8[0]; |
| 2337 } | 2369 } |
| 2338 } | 2370 } |
| 2339 encode_sb_rt(cpi, tile, tp, mi_row, mi_col, 1, BLOCK_64X64); | |
| 2340 | |
| 2341 *rate = chosen_rate; | |
| 2342 *dist = chosen_dist; | |
| 2343 } | 2371 } |
| 2344 | 2372 |
| 2345 static void encode_rtc_sb_row(VP9_COMP *cpi, const TileInfo *const tile, | 2373 static void encode_nonrd_sb_row(VP9_COMP *cpi, const TileInfo *const tile, |
| 2346 int mi_row, TOKENEXTRA **tp) { | 2374 int mi_row, TOKENEXTRA **tp) { |
| 2347 VP9_COMMON * const cm = &cpi->common; | |
| 2348 int mi_col; | 2375 int mi_col; |
| 2349 | 2376 |
| 2350 // Initialize the left context for the new SB row | 2377 // Initialize the left context for the new SB row |
| 2351 vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context)); | 2378 vpx_memset(&cpi->left_context, 0, sizeof(cpi->left_context)); |
| 2352 vpx_memset(cpi->left_seg_context, 0, sizeof(cpi->left_seg_context)); | 2379 vpx_memset(cpi->left_seg_context, 0, sizeof(cpi->left_seg_context)); |
| 2353 | 2380 |
| 2354 // Code each SB in the row | 2381 // Code each SB in the row |
| 2355 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; | 2382 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; |
| 2356 mi_col += MI_BLOCK_SIZE) { | 2383 mi_col += MI_BLOCK_SIZE) { |
| 2357 int dummy_rate; | 2384 int dummy_rate; |
| 2358 int64_t dummy_dist; | 2385 int64_t dummy_dist; |
| 2359 | 2386 |
| 2360 const int idx_str = cm->mode_info_stride * mi_row + mi_col; | |
| 2361 MODE_INFO **mi_8x8 = cm->mi_grid_visible + idx_str; | |
| 2362 cpi->mb.source_variance = UINT_MAX; | 2387 cpi->mb.source_variance = UINT_MAX; |
| 2363 | 2388 |
| 2364 set_partitioning(cpi, tile, mi_8x8, mi_row, mi_col); | 2389 if (cpi->sf.partition_search_type == FIXED_PARTITION) { |
| 2365 rtc_use_partition(cpi, tile, mi_8x8, tp, mi_row, mi_col, BLOCK_64X64, | 2390 nonrd_use_partition(cpi, tile, tp, mi_row, mi_col, |
| 2366 &dummy_rate, &dummy_dist, 1); | 2391 cpi->sf.always_this_block_size, |
| 2392 &dummy_rate, &dummy_dist); |
| 2393 encode_sb_rt(cpi, tile, tp, mi_row, mi_col, 1, BLOCK_64X64); |
| 2394 } else if (cpi->sf.partition_search_type == VAR_BASED_FIXED_PARTITION || |
| 2395 cpi->sf.partition_search_type == VAR_BASED_PARTITION) { |
| 2396 // TODO(debargha): Implement VAR_BASED_PARTITION as a separate case. |
| 2397 // Currently both VAR_BASED_FIXED_PARTITION/VAR_BASED_PARTITION |
| 2398 // map to the same thing. |
| 2399 BLOCK_SIZE bsize = get_nonrd_var_based_fixed_partition(cpi, |
| 2400 mi_row, |
| 2401 mi_col); |
| 2402 nonrd_use_partition(cpi, tile, tp, mi_row, mi_col, |
| 2403 bsize, &dummy_rate, &dummy_dist); |
| 2404 encode_sb_rt(cpi, tile, tp, mi_row, mi_col, 1, BLOCK_64X64); |
| 2405 } else { |
| 2406 assert(0); |
| 2407 } |
| 2367 } | 2408 } |
| 2368 } | 2409 } |
| 2369 // end RTC play code | 2410 // end RTC play code |
| 2370 | 2411 |
| 2371 static void encode_frame_internal(VP9_COMP *cpi) { | 2412 static void encode_frame_internal(VP9_COMP *cpi) { |
| 2372 int mi_row; | 2413 int mi_row; |
| 2373 MACROBLOCK *const x = &cpi->mb; | 2414 MACROBLOCK *const x = &cpi->mb; |
| 2374 VP9_COMMON *const cm = &cpi->common; | 2415 VP9_COMMON *const cm = &cpi->common; |
| 2375 MACROBLOCKD *const xd = &x->e_mbd; | 2416 MACROBLOCKD *const xd = &x->e_mbd; |
| 2376 | 2417 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2412 // Re-initialize encode frame context. | 2453 // Re-initialize encode frame context. |
| 2413 init_encode_frame_mb_context(cpi); | 2454 init_encode_frame_mb_context(cpi); |
| 2414 | 2455 |
| 2415 vp9_zero(cpi->rd_comp_pred_diff); | 2456 vp9_zero(cpi->rd_comp_pred_diff); |
| 2416 vp9_zero(cpi->rd_filter_diff); | 2457 vp9_zero(cpi->rd_filter_diff); |
| 2417 vp9_zero(cpi->rd_tx_select_diff); | 2458 vp9_zero(cpi->rd_tx_select_diff); |
| 2418 vp9_zero(cpi->rd_tx_select_threshes); | 2459 vp9_zero(cpi->rd_tx_select_threshes); |
| 2419 | 2460 |
| 2420 set_prev_mi(cm); | 2461 set_prev_mi(cm); |
| 2421 | 2462 |
| 2463 if (cpi->sf.use_nonrd_pick_mode) { |
| 2464 // Initialize internal buffer pointers for rtc coding, where non-RD |
| 2465 // mode decision is used and hence no buffer pointer swap needed. |
| 2466 int i; |
| 2467 struct macroblock_plane *const p = x->plane; |
| 2468 struct macroblockd_plane *const pd = xd->plane; |
| 2469 PICK_MODE_CONTEXT *ctx = &cpi->mb.sb64_context; |
| 2470 |
| 2471 for (i = 0; i < MAX_MB_PLANE; ++i) { |
| 2472 p[i].coeff = ctx->coeff_pbuf[i][0]; |
| 2473 p[i].qcoeff = ctx->qcoeff_pbuf[i][0]; |
| 2474 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][0]; |
| 2475 p[i].eobs = ctx->eobs_pbuf[i][0]; |
| 2476 } |
| 2477 } |
| 2478 |
| 2422 { | 2479 { |
| 2423 struct vpx_usec_timer emr_timer; | 2480 struct vpx_usec_timer emr_timer; |
| 2424 vpx_usec_timer_start(&emr_timer); | 2481 vpx_usec_timer_start(&emr_timer); |
| 2425 | 2482 |
| 2426 { | 2483 { |
| 2427 // Take tiles into account and give start/end MB | 2484 // Take tiles into account and give start/end MB |
| 2428 int tile_col, tile_row; | 2485 int tile_col, tile_row; |
| 2429 TOKENEXTRA *tp = cpi->tok; | 2486 TOKENEXTRA *tp = cpi->tok; |
| 2430 const int tile_cols = 1 << cm->log2_tile_cols; | 2487 const int tile_cols = 1 << cm->log2_tile_cols; |
| 2431 const int tile_rows = 1 << cm->log2_tile_rows; | 2488 const int tile_rows = 1 << cm->log2_tile_rows; |
| 2432 | 2489 |
| 2433 for (tile_row = 0; tile_row < tile_rows; tile_row++) { | 2490 for (tile_row = 0; tile_row < tile_rows; tile_row++) { |
| 2434 for (tile_col = 0; tile_col < tile_cols; tile_col++) { | 2491 for (tile_col = 0; tile_col < tile_cols; tile_col++) { |
| 2435 TileInfo tile; | 2492 TileInfo tile; |
| 2436 TOKENEXTRA *tp_old = tp; | 2493 TOKENEXTRA *tp_old = tp; |
| 2437 | 2494 |
| 2438 // For each row of SBs in the frame | 2495 // For each row of SBs in the frame |
| 2439 vp9_tile_init(&tile, cm, tile_row, tile_col); | 2496 vp9_tile_init(&tile, cm, tile_row, tile_col); |
| 2440 for (mi_row = tile.mi_row_start; | 2497 for (mi_row = tile.mi_row_start; |
| 2441 mi_row < tile.mi_row_end; mi_row += 8) { | 2498 mi_row < tile.mi_row_end; mi_row += MI_BLOCK_SIZE) { |
| 2442 if (cpi->sf.use_pick_mode) | 2499 if (cpi->sf.use_nonrd_pick_mode) |
| 2443 encode_rtc_sb_row(cpi, &tile, mi_row, &tp); | 2500 encode_nonrd_sb_row(cpi, &tile, mi_row, &tp); |
| 2444 else | 2501 else |
| 2445 encode_sb_row(cpi, &tile, mi_row, &tp); | 2502 encode_rd_sb_row(cpi, &tile, mi_row, &tp); |
| 2446 } | 2503 } |
| 2447 cpi->tok_count[tile_row][tile_col] = (unsigned int)(tp - tp_old); | 2504 cpi->tok_count[tile_row][tile_col] = (unsigned int)(tp - tp_old); |
| 2448 assert(tp - cpi->tok <= get_token_alloc(cm->mb_rows, cm->mb_cols)); | 2505 assert(tp - cpi->tok <= get_token_alloc(cm->mb_rows, cm->mb_cols)); |
| 2449 } | 2506 } |
| 2450 } | 2507 } |
| 2451 } | 2508 } |
| 2452 | 2509 |
| 2453 vpx_usec_timer_mark(&emr_timer); | 2510 vpx_usec_timer_mark(&emr_timer); |
| 2454 cpi->time_encode_sb_row += vpx_usec_timer_elapsed(&emr_timer); | 2511 cpi->time_encode_sb_row += vpx_usec_timer_elapsed(&emr_timer); |
| 2455 } | 2512 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 MACROBLOCK *const x = &cpi->mb; | 2752 MACROBLOCK *const x = &cpi->mb; |
| 2696 MACROBLOCKD *const xd = &x->e_mbd; | 2753 MACROBLOCKD *const xd = &x->e_mbd; |
| 2697 MODE_INFO **mi_8x8 = xd->mi_8x8; | 2754 MODE_INFO **mi_8x8 = xd->mi_8x8; |
| 2698 MODE_INFO *mi = mi_8x8[0]; | 2755 MODE_INFO *mi = mi_8x8[0]; |
| 2699 MB_MODE_INFO *mbmi = &mi->mbmi; | 2756 MB_MODE_INFO *mbmi = &mi->mbmi; |
| 2700 PICK_MODE_CONTEXT *ctx = get_block_context(x, bsize); | 2757 PICK_MODE_CONTEXT *ctx = get_block_context(x, bsize); |
| 2701 unsigned int segment_id = mbmi->segment_id; | 2758 unsigned int segment_id = mbmi->segment_id; |
| 2702 const int mis = cm->mode_info_stride; | 2759 const int mis = cm->mode_info_stride; |
| 2703 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; | 2760 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; |
| 2704 const int mi_height = num_8x8_blocks_high_lookup[bsize]; | 2761 const int mi_height = num_8x8_blocks_high_lookup[bsize]; |
| 2762 |
| 2705 x->skip_recode = !x->select_txfm_size && mbmi->sb_type >= BLOCK_8X8 && | 2763 x->skip_recode = !x->select_txfm_size && mbmi->sb_type >= BLOCK_8X8 && |
| 2706 (cpi->oxcf.aq_mode != COMPLEXITY_AQ) && | 2764 (cpi->oxcf.aq_mode != COMPLEXITY_AQ) && |
| 2707 !cpi->sf.use_pick_mode; | 2765 !cpi->sf.use_nonrd_pick_mode; |
| 2708 x->skip_optimize = ctx->is_coded; | 2766 x->skip_optimize = ctx->is_coded; |
| 2709 ctx->is_coded = 1; | 2767 ctx->is_coded = 1; |
| 2710 x->use_lp32x32fdct = cpi->sf.use_lp32x32fdct; | 2768 x->use_lp32x32fdct = cpi->sf.use_lp32x32fdct; |
| 2711 x->skip_encode = (!output_enabled && cpi->sf.skip_encode_frame && | 2769 x->skip_encode = (!output_enabled && cpi->sf.skip_encode_frame && |
| 2712 x->q_index < QIDX_SKIP_THRESH); | 2770 x->q_index < QIDX_SKIP_THRESH); |
| 2713 if (x->skip_encode) | 2771 if (x->skip_encode) |
| 2714 return; | 2772 return; |
| 2715 | 2773 |
| 2716 if (cm->frame_type == KEY_FRAME) { | 2774 if (cm->frame_type == KEY_FRAME) { |
| 2717 if (cpi->oxcf.tuning == VP8_TUNE_SSIM) { | 2775 if (cpi->oxcf.tuning == VP8_TUNE_SSIM) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2734 vp9_update_zbin_extra(cpi, x); | 2792 vp9_update_zbin_extra(cpi, x); |
| 2735 } | 2793 } |
| 2736 | 2794 |
| 2737 if (!is_inter_block(mbmi)) { | 2795 if (!is_inter_block(mbmi)) { |
| 2738 int plane; | 2796 int plane; |
| 2739 mbmi->skip = 1; | 2797 mbmi->skip = 1; |
| 2740 for (plane = 0; plane < MAX_MB_PLANE; ++plane) | 2798 for (plane = 0; plane < MAX_MB_PLANE; ++plane) |
| 2741 vp9_encode_intra_block_plane(x, MAX(bsize, BLOCK_8X8), plane); | 2799 vp9_encode_intra_block_plane(x, MAX(bsize, BLOCK_8X8), plane); |
| 2742 if (output_enabled) | 2800 if (output_enabled) |
| 2743 sum_intra_stats(&cm->counts, mi); | 2801 sum_intra_stats(&cm->counts, mi); |
| 2802 vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); |
| 2744 } else { | 2803 } else { |
| 2745 int ref; | 2804 int ref; |
| 2746 const int is_compound = has_second_ref(mbmi); | 2805 const int is_compound = has_second_ref(mbmi); |
| 2747 for (ref = 0; ref < 1 + is_compound; ++ref) { | 2806 for (ref = 0; ref < 1 + is_compound; ++ref) { |
| 2748 YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, | 2807 YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, |
| 2749 mbmi->ref_frame[ref]); | 2808 mbmi->ref_frame[ref]); |
| 2750 setup_pre_planes(xd, ref, cfg, mi_row, mi_col, &xd->block_refs[ref]->sf); | 2809 setup_pre_planes(xd, ref, cfg, mi_row, mi_col, &xd->block_refs[ref]->sf); |
| 2751 } | 2810 } |
| 2752 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); | 2811 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); |
| 2753 } | |
| 2754 | 2812 |
| 2755 if (!is_inter_block(mbmi)) { | 2813 if (!x->skip) { |
| 2756 vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); | 2814 mbmi->skip = 1; |
| 2757 } else if (!x->skip) { | 2815 vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); |
| 2758 mbmi->skip = 1; | 2816 vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); |
| 2759 vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); | 2817 } else { |
| 2760 vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); | 2818 mbmi->skip = 1; |
| 2761 } else { | 2819 if (output_enabled) |
| 2762 mbmi->skip = 1; | 2820 cm->counts.skip[vp9_get_skip_context(xd)][1]++; |
| 2763 if (output_enabled) | 2821 reset_skip_context(xd, MAX(bsize, BLOCK_8X8)); |
| 2764 cm->counts.skip[vp9_get_skip_context(xd)][1]++; | 2822 } |
| 2765 reset_skip_context(xd, MAX(bsize, BLOCK_8X8)); | |
| 2766 } | 2823 } |
| 2767 | 2824 |
| 2768 if (output_enabled) { | 2825 if (output_enabled) { |
| 2769 if (cm->tx_mode == TX_MODE_SELECT && | 2826 if (cm->tx_mode == TX_MODE_SELECT && |
| 2770 mbmi->sb_type >= BLOCK_8X8 && | 2827 mbmi->sb_type >= BLOCK_8X8 && |
| 2771 !(is_inter_block(mbmi) && | 2828 !(is_inter_block(mbmi) && |
| 2772 (mbmi->skip || | 2829 (mbmi->skip || |
| 2773 vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)))) { | 2830 vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)))) { |
| 2774 ++get_tx_counts(max_txsize_lookup[bsize], vp9_get_tx_size_context(xd), | 2831 ++get_tx_counts(max_txsize_lookup[bsize], vp9_get_tx_size_context(xd), |
| 2775 &cm->counts.tx)[mbmi->tx_size]; | 2832 &cm->counts.tx)[mbmi->tx_size]; |
| 2776 } else { | 2833 } else { |
| 2777 int x, y; | 2834 int x, y; |
| 2778 TX_SIZE tx_size; | 2835 TX_SIZE tx_size; |
| 2779 // The new intra coding scheme requires no change of transform size | 2836 // The new intra coding scheme requires no change of transform size |
| 2780 if (is_inter_block(&mi->mbmi)) { | 2837 if (is_inter_block(&mi->mbmi)) { |
| 2781 tx_size = MIN(tx_mode_to_biggest_tx_size[cm->tx_mode], | 2838 tx_size = MIN(tx_mode_to_biggest_tx_size[cm->tx_mode], |
| 2782 max_txsize_lookup[bsize]); | 2839 max_txsize_lookup[bsize]); |
| 2783 } else { | 2840 } else { |
| 2784 tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4; | 2841 tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4; |
| 2785 } | 2842 } |
| 2786 | 2843 |
| 2787 for (y = 0; y < mi_height; y++) | 2844 for (y = 0; y < mi_height; y++) |
| 2788 for (x = 0; x < mi_width; x++) | 2845 for (x = 0; x < mi_width; x++) |
| 2789 if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) | 2846 if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) |
| 2790 mi_8x8[mis * y + x]->mbmi.tx_size = tx_size; | 2847 mi_8x8[mis * y + x]->mbmi.tx_size = tx_size; |
| 2791 } | 2848 } |
| 2792 } | 2849 } |
| 2793 } | 2850 } |
| OLD | NEW |