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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return BLOCK_16X16; | 123 return BLOCK_16X16; |
124 } | 124 } |
125 | 125 |
126 // Lighter version of set_offsets that only sets the mode info | 126 // Lighter version of set_offsets that only sets the mode info |
127 // pointers. | 127 // pointers. |
128 static INLINE void set_modeinfo_offsets(VP9_COMMON *const cm, | 128 static INLINE void set_modeinfo_offsets(VP9_COMMON *const cm, |
129 MACROBLOCKD *const xd, | 129 MACROBLOCKD *const xd, |
130 int mi_row, | 130 int mi_row, |
131 int mi_col) { | 131 int mi_col) { |
132 const int idx_str = xd->mi_stride * mi_row + mi_col; | 132 const int idx_str = xd->mi_stride * mi_row + mi_col; |
133 xd->mi = cm->mi_grid_visible + idx_str; | 133 xd->mi = cm->mi + idx_str; |
134 xd->mi[0] = cm->mi + idx_str; | 134 xd->mi[0].src_mi = &xd->mi[0]; |
135 } | 135 } |
136 | 136 |
137 static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, | 137 static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, |
138 int mi_row, int mi_col, BLOCK_SIZE bsize) { | 138 int mi_row, int mi_col, BLOCK_SIZE bsize) { |
139 MACROBLOCK *const x = &cpi->mb; | 139 MACROBLOCK *const x = &cpi->mb; |
140 VP9_COMMON *const cm = &cpi->common; | 140 VP9_COMMON *const cm = &cpi->common; |
141 MACROBLOCKD *const xd = &x->e_mbd; | 141 MACROBLOCKD *const xd = &x->e_mbd; |
142 MB_MODE_INFO *mbmi; | 142 MB_MODE_INFO *mbmi; |
143 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; | 143 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; |
144 const int mi_height = num_8x8_blocks_high_lookup[bsize]; | 144 const int mi_height = num_8x8_blocks_high_lookup[bsize]; |
145 const struct segmentation *const seg = &cm->seg; | 145 const struct segmentation *const seg = &cm->seg; |
146 | 146 |
147 set_skip_context(xd, mi_row, mi_col); | 147 set_skip_context(xd, mi_row, mi_col); |
148 | 148 |
149 set_modeinfo_offsets(cm, xd, mi_row, mi_col); | 149 set_modeinfo_offsets(cm, xd, mi_row, mi_col); |
150 | 150 |
151 mbmi = &xd->mi[0]->mbmi; | 151 mbmi = &xd->mi[0].src_mi->mbmi; |
152 | 152 |
153 // Set up destination pointers. | 153 // Set up destination pointers. |
154 vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); | 154 vp9_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col); |
155 | 155 |
156 // Set up limit values for MV components. | 156 // Set up limit values for MV components. |
157 // Mv beyond the range do not produce new/different prediction block. | 157 // Mv beyond the range do not produce new/different prediction block. |
158 x->mv_row_min = -(((mi_row + mi_height) * MI_SIZE) + VP9_INTERP_EXTEND); | 158 x->mv_row_min = -(((mi_row + mi_height) * MI_SIZE) + VP9_INTERP_EXTEND); |
159 x->mv_col_min = -(((mi_col + mi_width) * MI_SIZE) + VP9_INTERP_EXTEND); | 159 x->mv_col_min = -(((mi_col + mi_width) * MI_SIZE) + VP9_INTERP_EXTEND); |
160 x->mv_row_max = (cm->mi_rows - mi_row) * MI_SIZE + VP9_INTERP_EXTEND; | 160 x->mv_row_max = (cm->mi_rows - mi_row) * MI_SIZE + VP9_INTERP_EXTEND; |
161 x->mv_col_max = (cm->mi_cols - mi_col) * MI_SIZE + VP9_INTERP_EXTEND; | 161 x->mv_col_max = (cm->mi_cols - mi_col) * MI_SIZE + VP9_INTERP_EXTEND; |
(...skipping 28 matching lines...) Expand all Loading... |
190 | 190 |
191 static void duplicate_mode_info_in_sb(VP9_COMMON *cm, MACROBLOCKD *xd, | 191 static void duplicate_mode_info_in_sb(VP9_COMMON *cm, MACROBLOCKD *xd, |
192 int mi_row, int mi_col, | 192 int mi_row, int mi_col, |
193 BLOCK_SIZE bsize) { | 193 BLOCK_SIZE bsize) { |
194 const int block_width = num_8x8_blocks_wide_lookup[bsize]; | 194 const int block_width = num_8x8_blocks_wide_lookup[bsize]; |
195 const int block_height = num_8x8_blocks_high_lookup[bsize]; | 195 const int block_height = num_8x8_blocks_high_lookup[bsize]; |
196 int i, j; | 196 int i, j; |
197 for (j = 0; j < block_height; ++j) | 197 for (j = 0; j < block_height; ++j) |
198 for (i = 0; i < block_width; ++i) { | 198 for (i = 0; i < block_width; ++i) { |
199 if (mi_row + j < cm->mi_rows && mi_col + i < cm->mi_cols) | 199 if (mi_row + j < cm->mi_rows && mi_col + i < cm->mi_cols) |
200 xd->mi[j * xd->mi_stride + i] = xd->mi[0]; | 200 xd->mi[j * xd->mi_stride + i].src_mi = &xd->mi[0]; |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 static void set_block_size(VP9_COMP * const cpi, | 204 static void set_block_size(VP9_COMP * const cpi, |
205 int mi_row, int mi_col, | 205 int mi_row, int mi_col, |
206 BLOCK_SIZE bsize) { | 206 BLOCK_SIZE bsize) { |
207 if (cpi->common.mi_cols > mi_col && cpi->common.mi_rows > mi_row) { | 207 if (cpi->common.mi_cols > mi_col && cpi->common.mi_rows > mi_row) { |
208 MACROBLOCKD *const xd = &cpi->mb.e_mbd; | 208 MACROBLOCKD *const xd = &cpi->mb.e_mbd; |
209 set_modeinfo_offsets(&cpi->common, xd, mi_row, mi_col); | 209 set_modeinfo_offsets(&cpi->common, xd, mi_row, mi_col); |
210 xd->mi[0]->mbmi.sb_type = bsize; | 210 xd->mi[0].src_mi->mbmi.sb_type = bsize; |
211 duplicate_mode_info_in_sb(&cpi->common, xd, mi_row, mi_col, bsize); | 211 duplicate_mode_info_in_sb(&cpi->common, xd, mi_row, mi_col, bsize); |
212 } | 212 } |
213 } | 213 } |
214 | 214 |
215 typedef struct { | 215 typedef struct { |
216 int64_t sum_square_error; | 216 int64_t sum_square_error; |
217 int64_t sum_error; | 217 int64_t sum_error; |
218 int count; | 218 int count; |
219 int variance; | 219 int variance; |
220 } var; | 220 } var; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 pixels_wide += (xd->mb_to_right_edge >> 3); | 398 pixels_wide += (xd->mb_to_right_edge >> 3); |
399 if (xd->mb_to_bottom_edge < 0) | 399 if (xd->mb_to_bottom_edge < 0) |
400 pixels_high += (xd->mb_to_bottom_edge >> 3); | 400 pixels_high += (xd->mb_to_bottom_edge >> 3); |
401 | 401 |
402 s = x->plane[0].src.buf; | 402 s = x->plane[0].src.buf; |
403 sp = x->plane[0].src.stride; | 403 sp = x->plane[0].src.stride; |
404 | 404 |
405 if (cm->frame_type != KEY_FRAME) { | 405 if (cm->frame_type != KEY_FRAME) { |
406 vp9_setup_pre_planes(xd, 0, yv12, mi_row, mi_col, sf); | 406 vp9_setup_pre_planes(xd, 0, yv12, mi_row, mi_col, sf); |
407 | 407 |
408 xd->mi[0]->mbmi.ref_frame[0] = LAST_FRAME; | 408 xd->mi[0].src_mi->mbmi.ref_frame[0] = LAST_FRAME; |
409 xd->mi[0]->mbmi.sb_type = BLOCK_64X64; | 409 xd->mi[0].src_mi->mbmi.sb_type = BLOCK_64X64; |
410 vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv, | 410 vp9_find_best_ref_mvs(xd, cm->allow_high_precision_mv, |
411 xd->mi[0]->mbmi.ref_mvs[LAST_FRAME], | 411 xd->mi[0].src_mi->mbmi.ref_mvs[LAST_FRAME], |
412 &nearest_mv, &near_mv); | 412 &nearest_mv, &near_mv); |
413 | 413 |
414 xd->mi[0]->mbmi.mv[0] = nearest_mv; | 414 xd->mi[0].src_mi->mbmi.mv[0] = nearest_mv; |
415 vp9_build_inter_predictors_sby(xd, mi_row, mi_col, BLOCK_64X64); | 415 vp9_build_inter_predictors_sby(xd, mi_row, mi_col, BLOCK_64X64); |
416 | 416 |
417 d = xd->plane[0].dst.buf; | 417 d = xd->plane[0].dst.buf; |
418 dp = xd->plane[0].dst.stride; | 418 dp = xd->plane[0].dst.stride; |
419 } else { | 419 } else { |
420 d = VP9_VAR_OFFS; | 420 d = VP9_VAR_OFFS; |
421 dp = 0; | 421 dp = 0; |
422 } | 422 } |
423 | 423 |
424 // Fill in the entire tree of 8x8 variances for splits. | 424 // Fill in the entire tree of 8x8 variances for splits. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 int mi_row, int mi_col, BLOCK_SIZE bsize, | 508 int mi_row, int mi_col, BLOCK_SIZE bsize, |
509 int output_enabled) { | 509 int output_enabled) { |
510 int i, x_idx, y; | 510 int i, x_idx, y; |
511 VP9_COMMON *const cm = &cpi->common; | 511 VP9_COMMON *const cm = &cpi->common; |
512 RD_OPT *const rd_opt = &cpi->rd; | 512 RD_OPT *const rd_opt = &cpi->rd; |
513 MACROBLOCK *const x = &cpi->mb; | 513 MACROBLOCK *const x = &cpi->mb; |
514 MACROBLOCKD *const xd = &x->e_mbd; | 514 MACROBLOCKD *const xd = &x->e_mbd; |
515 struct macroblock_plane *const p = x->plane; | 515 struct macroblock_plane *const p = x->plane; |
516 struct macroblockd_plane *const pd = xd->plane; | 516 struct macroblockd_plane *const pd = xd->plane; |
517 MODE_INFO *mi = &ctx->mic; | 517 MODE_INFO *mi = &ctx->mic; |
518 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 518 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
519 MODE_INFO *mi_addr = xd->mi[0]; | 519 MODE_INFO *mi_addr = &xd->mi[0]; |
520 const struct segmentation *const seg = &cm->seg; | 520 const struct segmentation *const seg = &cm->seg; |
521 | 521 |
522 const int mis = cm->mi_stride; | 522 const int mis = cm->mi_stride; |
523 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; | 523 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; |
524 const int mi_height = num_8x8_blocks_high_lookup[bsize]; | 524 const int mi_height = num_8x8_blocks_high_lookup[bsize]; |
525 int max_plane; | 525 int max_plane; |
526 | 526 |
527 assert(mi->mbmi.sb_type == bsize); | 527 assert(mi->mbmi.sb_type == bsize); |
528 | 528 |
529 *mi_addr = *mi; | 529 *mi_addr = *mi; |
| 530 mi_addr->src_mi = mi_addr; |
530 | 531 |
531 // If segmentation in use | 532 // If segmentation in use |
532 if (seg->enabled && output_enabled) { | 533 if (seg->enabled && output_enabled) { |
533 // For in frame complexity AQ copy the segment id from the segment map. | 534 // For in frame complexity AQ copy the segment id from the segment map. |
534 if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { | 535 if (cpi->oxcf.aq_mode == COMPLEXITY_AQ) { |
535 const uint8_t *const map = seg->update_map ? cpi->segmentation_map | 536 const uint8_t *const map = seg->update_map ? cpi->segmentation_map |
536 : cm->last_frame_seg_map; | 537 : cm->last_frame_seg_map; |
537 mi_addr->mbmi.segment_id = | 538 mi_addr->mbmi.segment_id = |
538 vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); | 539 vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); |
539 } | 540 } |
540 // Else for cyclic refresh mode update the segment map, set the segment id | 541 // Else for cyclic refresh mode update the segment map, set the segment id |
541 // and then update the quantizer. | 542 // and then update the quantizer. |
542 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { | 543 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) { |
543 vp9_cyclic_refresh_update_segment(cpi, &xd->mi[0]->mbmi, | 544 vp9_cyclic_refresh_update_segment(cpi, &xd->mi[0].src_mi->mbmi, |
544 mi_row, mi_col, bsize, 1); | 545 mi_row, mi_col, bsize, 1); |
545 } | 546 } |
546 } | 547 } |
547 | 548 |
548 max_plane = is_inter_block(mbmi) ? MAX_MB_PLANE : 1; | 549 max_plane = is_inter_block(mbmi) ? MAX_MB_PLANE : 1; |
549 for (i = 0; i < max_plane; ++i) { | 550 for (i = 0; i < max_plane; ++i) { |
550 p[i].coeff = ctx->coeff_pbuf[i][1]; | 551 p[i].coeff = ctx->coeff_pbuf[i][1]; |
551 p[i].qcoeff = ctx->qcoeff_pbuf[i][1]; | 552 p[i].qcoeff = ctx->qcoeff_pbuf[i][1]; |
552 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1]; | 553 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][1]; |
553 p[i].eobs = ctx->eobs_pbuf[i][1]; | 554 p[i].eobs = ctx->eobs_pbuf[i][1]; |
554 } | 555 } |
555 | 556 |
556 for (i = max_plane; i < MAX_MB_PLANE; ++i) { | 557 for (i = max_plane; i < MAX_MB_PLANE; ++i) { |
557 p[i].coeff = ctx->coeff_pbuf[i][2]; | 558 p[i].coeff = ctx->coeff_pbuf[i][2]; |
558 p[i].qcoeff = ctx->qcoeff_pbuf[i][2]; | 559 p[i].qcoeff = ctx->qcoeff_pbuf[i][2]; |
559 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][2]; | 560 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][2]; |
560 p[i].eobs = ctx->eobs_pbuf[i][2]; | 561 p[i].eobs = ctx->eobs_pbuf[i][2]; |
561 } | 562 } |
562 | 563 |
563 // Restore the coding context of the MB to that that was in place | 564 // Restore the coding context of the MB to that that was in place |
564 // when the mode was picked for it | 565 // when the mode was picked for it |
565 for (y = 0; y < mi_height; y++) | 566 for (y = 0; y < mi_height; y++) |
566 for (x_idx = 0; x_idx < mi_width; x_idx++) | 567 for (x_idx = 0; x_idx < mi_width; x_idx++) |
567 if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx | 568 if ((xd->mb_to_right_edge >> (3 + MI_SIZE_LOG2)) + mi_width > x_idx |
568 && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { | 569 && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) { |
569 xd->mi[x_idx + y * mis] = mi_addr; | 570 xd->mi[x_idx + y * mis].src_mi = mi_addr; |
570 } | 571 } |
571 | 572 |
572 if (cpi->oxcf.aq_mode) | 573 if (cpi->oxcf.aq_mode) |
573 vp9_init_plane_quantizers(cpi, x); | 574 vp9_init_plane_quantizers(cpi, x); |
574 | 575 |
575 // FIXME(rbultje) I'm pretty sure this should go to the end of this block | 576 // FIXME(rbultje) I'm pretty sure this should go to the end of this block |
576 // (i.e. after the output_enabled) | 577 // (i.e. after the output_enabled) |
577 if (bsize < BLOCK_32X32) { | 578 if (bsize < BLOCK_32X32) { |
578 if (bsize < BLOCK_16X16) | 579 if (bsize < BLOCK_16X16) |
579 ctx->tx_rd_diff[ALLOW_16X16] = ctx->tx_rd_diff[ALLOW_8X8]; | 580 ctx->tx_rd_diff[ALLOW_16X16] = ctx->tx_rd_diff[ALLOW_8X8]; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 648 |
648 for (i = 0; i < MAX_MB_PLANE; i++) | 649 for (i = 0; i < MAX_MB_PLANE; i++) |
649 setup_pred_plane(&x->plane[i].src, buffers[i], strides[i], mi_row, mi_col, | 650 setup_pred_plane(&x->plane[i].src, buffers[i], strides[i], mi_row, mi_col, |
650 NULL, x->e_mbd.plane[i].subsampling_x, | 651 NULL, x->e_mbd.plane[i].subsampling_x, |
651 x->e_mbd.plane[i].subsampling_y); | 652 x->e_mbd.plane[i].subsampling_y); |
652 } | 653 } |
653 | 654 |
654 static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode, int *rate, | 655 static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode, int *rate, |
655 int64_t *dist, BLOCK_SIZE bsize) { | 656 int64_t *dist, BLOCK_SIZE bsize) { |
656 MACROBLOCKD *const xd = &x->e_mbd; | 657 MACROBLOCKD *const xd = &x->e_mbd; |
657 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 658 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
658 INTERP_FILTER filter_ref; | 659 INTERP_FILTER filter_ref; |
659 | 660 |
660 if (xd->up_available) | 661 if (xd->up_available) |
661 filter_ref = xd->mi[-xd->mi_stride]->mbmi.interp_filter; | 662 filter_ref = xd->mi[-xd->mi_stride].src_mi->mbmi.interp_filter; |
662 else if (xd->left_available) | 663 else if (xd->left_available) |
663 filter_ref = xd->mi[-1]->mbmi.interp_filter; | 664 filter_ref = xd->mi[-1].src_mi->mbmi.interp_filter; |
664 else | 665 else |
665 filter_ref = EIGHTTAP; | 666 filter_ref = EIGHTTAP; |
666 | 667 |
667 mbmi->sb_type = bsize; | 668 mbmi->sb_type = bsize; |
668 mbmi->mode = ZEROMV; | 669 mbmi->mode = ZEROMV; |
669 mbmi->tx_size = MIN(max_txsize_lookup[bsize], | 670 mbmi->tx_size = MIN(max_txsize_lookup[bsize], |
670 tx_mode_to_biggest_tx_size[tx_mode]); | 671 tx_mode_to_biggest_tx_size[tx_mode]); |
671 mbmi->skip = 1; | 672 mbmi->skip = 1; |
672 mbmi->uv_mode = DC_PRED; | 673 mbmi->uv_mode = DC_PRED; |
673 mbmi->ref_frame[0] = LAST_FRAME; | 674 mbmi->ref_frame[0] = LAST_FRAME; |
674 mbmi->ref_frame[1] = NONE; | 675 mbmi->ref_frame[1] = NONE; |
675 mbmi->mv[0].as_int = 0; | 676 mbmi->mv[0].as_int = 0; |
676 mbmi->interp_filter = filter_ref; | 677 mbmi->interp_filter = filter_ref; |
677 | 678 |
678 xd->mi[0]->bmi[0].as_mv[0].as_int = 0; | 679 xd->mi[0].src_mi->bmi[0].as_mv[0].as_int = 0; |
679 x->skip = 1; | 680 x->skip = 1; |
680 | 681 |
681 *rate = 0; | 682 *rate = 0; |
682 *dist = 0; | 683 *dist = 0; |
683 } | 684 } |
684 | 685 |
685 static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, | 686 static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, |
686 int mi_row, int mi_col, | 687 int mi_row, int mi_col, |
687 int *totalrate, int64_t *totaldist, | 688 int *totalrate, int64_t *totaldist, |
688 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, | 689 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, |
(...skipping 21 matching lines...) Expand all Loading... |
710 // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 | 711 // When ab_index = 0 all sub-blocks are handled, so for ab_index != 0 |
711 // there is nothing to be done. | 712 // there is nothing to be done. |
712 if (block != 0) { | 713 if (block != 0) { |
713 *totalrate = 0; | 714 *totalrate = 0; |
714 *totaldist = 0; | 715 *totaldist = 0; |
715 return; | 716 return; |
716 } | 717 } |
717 } | 718 } |
718 | 719 |
719 set_offsets(cpi, tile, mi_row, mi_col, bsize); | 720 set_offsets(cpi, tile, mi_row, mi_col, bsize); |
720 mbmi = &xd->mi[0]->mbmi; | 721 mbmi = &xd->mi[0].src_mi->mbmi; |
721 mbmi->sb_type = bsize; | 722 mbmi->sb_type = bsize; |
722 | 723 |
723 for (i = 0; i < MAX_MB_PLANE; ++i) { | 724 for (i = 0; i < MAX_MB_PLANE; ++i) { |
724 p[i].coeff = ctx->coeff_pbuf[i][0]; | 725 p[i].coeff = ctx->coeff_pbuf[i][0]; |
725 p[i].qcoeff = ctx->qcoeff_pbuf[i][0]; | 726 p[i].qcoeff = ctx->qcoeff_pbuf[i][0]; |
726 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][0]; | 727 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][0]; |
727 p[i].eobs = ctx->eobs_pbuf[i][0]; | 728 p[i].eobs = ctx->eobs_pbuf[i][0]; |
728 } | 729 } |
729 ctx->is_coded = 0; | 730 ctx->is_coded = 0; |
730 ctx->skippable = 0; | 731 ctx->skippable = 0; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 x->rdmult = orig_rdmult; | 793 x->rdmult = orig_rdmult; |
793 | 794 |
794 if (aq_mode == VARIANCE_AQ && *totalrate != INT_MAX) { | 795 if (aq_mode == VARIANCE_AQ && *totalrate != INT_MAX) { |
795 vp9_clear_system_state(); | 796 vp9_clear_system_state(); |
796 *totalrate = (int)round(*totalrate * rdmult_ratio); | 797 *totalrate = (int)round(*totalrate * rdmult_ratio); |
797 } | 798 } |
798 } | 799 } |
799 | 800 |
800 static void update_stats(VP9_COMMON *cm, const MACROBLOCK *x) { | 801 static void update_stats(VP9_COMMON *cm, const MACROBLOCK *x) { |
801 const MACROBLOCKD *const xd = &x->e_mbd; | 802 const MACROBLOCKD *const xd = &x->e_mbd; |
802 const MODE_INFO *const mi = xd->mi[0]; | 803 const MODE_INFO *const mi = xd->mi[0].src_mi; |
803 const MB_MODE_INFO *const mbmi = &mi->mbmi; | 804 const MB_MODE_INFO *const mbmi = &mi->mbmi; |
804 | 805 |
805 if (!frame_is_intra_only(cm)) { | 806 if (!frame_is_intra_only(cm)) { |
806 const int seg_ref_active = vp9_segfeature_active(&cm->seg, mbmi->segment_id, | 807 const int seg_ref_active = vp9_segfeature_active(&cm->seg, mbmi->segment_id, |
807 SEG_LVL_REF_FRAME); | 808 SEG_LVL_REF_FRAME); |
808 if (!seg_ref_active) { | 809 if (!seg_ref_active) { |
809 FRAME_COUNTS *const counts = &cm->counts; | 810 FRAME_COUNTS *const counts = &cm->counts; |
810 const int inter_block = is_inter_block(mbmi); | 811 const int inter_block = is_inter_block(mbmi); |
811 | 812 |
812 counts->intra_inter[vp9_get_intra_inter_context(xd)][inter_block]++; | 813 counts->intra_inter[vp9_get_intra_inter_context(xd)][inter_block]++; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 if ((*bh <= rows_left) && (*bw <= cols_left)) { | 1005 if ((*bh <= rows_left) && (*bw <= cols_left)) { |
1005 break; | 1006 break; |
1006 } | 1007 } |
1007 } | 1008 } |
1008 } | 1009 } |
1009 return bsize; | 1010 return bsize; |
1010 } | 1011 } |
1011 | 1012 |
1012 static void set_partial_b64x64_partition(MODE_INFO *mi, int mis, | 1013 static void set_partial_b64x64_partition(MODE_INFO *mi, int mis, |
1013 int bh_in, int bw_in, int row8x8_remaining, int col8x8_remaining, | 1014 int bh_in, int bw_in, int row8x8_remaining, int col8x8_remaining, |
1014 BLOCK_SIZE bsize, MODE_INFO **mi_8x8) { | 1015 BLOCK_SIZE bsize, MODE_INFO *mi_8x8) { |
1015 int bh = bh_in; | 1016 int bh = bh_in; |
1016 int r, c; | 1017 int r, c; |
1017 for (r = 0; r < MI_BLOCK_SIZE; r += bh) { | 1018 for (r = 0; r < MI_BLOCK_SIZE; r += bh) { |
1018 int bw = bw_in; | 1019 int bw = bw_in; |
1019 for (c = 0; c < MI_BLOCK_SIZE; c += bw) { | 1020 for (c = 0; c < MI_BLOCK_SIZE; c += bw) { |
1020 const int index = r * mis + c; | 1021 const int index = r * mis + c; |
1021 mi_8x8[index] = mi + index; | 1022 mi_8x8[index].src_mi = mi + index; |
1022 mi_8x8[index]->mbmi.sb_type = find_partition_size(bsize, | 1023 mi_8x8[index].src_mi->mbmi.sb_type = find_partition_size(bsize, |
1023 row8x8_remaining - r, col8x8_remaining - c, &bh, &bw); | 1024 row8x8_remaining - r, col8x8_remaining - c, &bh, &bw); |
1024 } | 1025 } |
1025 } | 1026 } |
1026 } | 1027 } |
1027 | 1028 |
1028 // This function attempts to set all mode info entries in a given SB64 | 1029 // This function attempts to set all mode info entries in a given SB64 |
1029 // to the same block partition size. | 1030 // to the same block partition size. |
1030 // However, at the bottom and right borders of the image the requested size | 1031 // However, at the bottom and right borders of the image the requested size |
1031 // may not be allowed in which case this code attempts to choose the largest | 1032 // may not be allowed in which case this code attempts to choose the largest |
1032 // allowable partition. | 1033 // allowable partition. |
1033 static void set_fixed_partitioning(VP9_COMP *cpi, const TileInfo *const tile, | 1034 static void set_fixed_partitioning(VP9_COMP *cpi, const TileInfo *const tile, |
1034 MODE_INFO **mi_8x8, int mi_row, int mi_col, | 1035 MODE_INFO *mi_8x8, int mi_row, int mi_col, |
1035 BLOCK_SIZE bsize) { | 1036 BLOCK_SIZE bsize) { |
1036 VP9_COMMON *const cm = &cpi->common; | 1037 VP9_COMMON *const cm = &cpi->common; |
1037 const int mis = cm->mi_stride; | 1038 const int mis = cm->mi_stride; |
1038 const int row8x8_remaining = tile->mi_row_end - mi_row; | 1039 const int row8x8_remaining = tile->mi_row_end - mi_row; |
1039 const int col8x8_remaining = tile->mi_col_end - mi_col; | 1040 const int col8x8_remaining = tile->mi_col_end - mi_col; |
1040 int block_row, block_col; | 1041 int block_row, block_col; |
1041 MODE_INFO *mi_upper_left = cm->mi + mi_row * mis + mi_col; | 1042 MODE_INFO *mi_upper_left = cm->mi + mi_row * mis + mi_col; |
1042 int bh = num_8x8_blocks_high_lookup[bsize]; | 1043 int bh = num_8x8_blocks_high_lookup[bsize]; |
1043 int bw = num_8x8_blocks_wide_lookup[bsize]; | 1044 int bw = num_8x8_blocks_wide_lookup[bsize]; |
1044 | 1045 |
1045 assert((row8x8_remaining > 0) && (col8x8_remaining > 0)); | 1046 assert((row8x8_remaining > 0) && (col8x8_remaining > 0)); |
1046 | 1047 |
1047 // Apply the requested partition size to the SB64 if it is all "in image" | 1048 // Apply the requested partition size to the SB64 if it is all "in image" |
1048 if ((col8x8_remaining >= MI_BLOCK_SIZE) && | 1049 if ((col8x8_remaining >= MI_BLOCK_SIZE) && |
1049 (row8x8_remaining >= MI_BLOCK_SIZE)) { | 1050 (row8x8_remaining >= MI_BLOCK_SIZE)) { |
1050 for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { | 1051 for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { |
1051 for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { | 1052 for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { |
1052 int index = block_row * mis + block_col; | 1053 int index = block_row * mis + block_col; |
1053 mi_8x8[index] = mi_upper_left + index; | 1054 mi_8x8[index].src_mi = mi_upper_left + index; |
1054 mi_8x8[index]->mbmi.sb_type = bsize; | 1055 mi_8x8[index].src_mi->mbmi.sb_type = bsize; |
1055 } | 1056 } |
1056 } | 1057 } |
1057 } else { | 1058 } else { |
1058 // Else this is a partial SB64. | 1059 // Else this is a partial SB64. |
1059 set_partial_b64x64_partition(mi_upper_left, mis, bh, bw, row8x8_remaining, | 1060 set_partial_b64x64_partition(mi_upper_left, mis, bh, bw, row8x8_remaining, |
1060 col8x8_remaining, bsize, mi_8x8); | 1061 col8x8_remaining, bsize, mi_8x8); |
1061 } | 1062 } |
1062 } | 1063 } |
1063 | 1064 |
1064 static void copy_partitioning(VP9_COMMON *cm, MODE_INFO **mi_8x8, | 1065 static void copy_partitioning(VP9_COMMON *cm, MODE_INFO *mi_8x8, |
1065 MODE_INFO **prev_mi_8x8) { | 1066 MODE_INFO *prev_mi_8x8) { |
1066 const int mis = cm->mi_stride; | 1067 const int mis = cm->mi_stride; |
1067 int block_row, block_col; | 1068 int block_row, block_col; |
1068 | 1069 |
1069 for (block_row = 0; block_row < 8; ++block_row) { | 1070 for (block_row = 0; block_row < 8; ++block_row) { |
1070 for (block_col = 0; block_col < 8; ++block_col) { | 1071 for (block_col = 0; block_col < 8; ++block_col) { |
1071 MODE_INFO *const prev_mi = prev_mi_8x8[block_row * mis + block_col]; | 1072 MODE_INFO *const prev_mi = |
| 1073 prev_mi_8x8[block_row * mis + block_col].src_mi; |
1072 const BLOCK_SIZE sb_type = prev_mi ? prev_mi->mbmi.sb_type : 0; | 1074 const BLOCK_SIZE sb_type = prev_mi ? prev_mi->mbmi.sb_type : 0; |
1073 | 1075 |
1074 if (prev_mi) { | 1076 if (prev_mi) { |
1075 const ptrdiff_t offset = prev_mi - cm->prev_mi; | 1077 const ptrdiff_t offset = prev_mi - cm->prev_mi; |
1076 mi_8x8[block_row * mis + block_col] = cm->mi + offset; | 1078 mi_8x8[block_row * mis + block_col].src_mi = cm->mi + offset; |
1077 mi_8x8[block_row * mis + block_col]->mbmi.sb_type = sb_type; | 1079 mi_8x8[block_row * mis + block_col].src_mi->mbmi.sb_type = sb_type; |
1078 } | 1080 } |
1079 } | 1081 } |
1080 } | 1082 } |
1081 } | 1083 } |
1082 | 1084 |
1083 static void constrain_copy_partitioning(VP9_COMP *const cpi, | 1085 static void constrain_copy_partitioning(VP9_COMP *const cpi, |
1084 const TileInfo *const tile, | 1086 const TileInfo *const tile, |
1085 MODE_INFO **mi_8x8, | 1087 MODE_INFO *mi_8x8, |
1086 MODE_INFO **prev_mi_8x8, | 1088 MODE_INFO *prev_mi_8x8, |
1087 int mi_row, int mi_col, | 1089 int mi_row, int mi_col, |
1088 BLOCK_SIZE bsize) { | 1090 BLOCK_SIZE bsize) { |
1089 VP9_COMMON *const cm = &cpi->common; | 1091 VP9_COMMON *const cm = &cpi->common; |
1090 const int mis = cm->mi_stride; | 1092 const int mis = cm->mi_stride; |
1091 const int row8x8_remaining = tile->mi_row_end - mi_row; | 1093 const int row8x8_remaining = tile->mi_row_end - mi_row; |
1092 const int col8x8_remaining = tile->mi_col_end - mi_col; | 1094 const int col8x8_remaining = tile->mi_col_end - mi_col; |
1093 MODE_INFO *const mi_upper_left = cm->mi + mi_row * mis + mi_col; | 1095 MODE_INFO *const mi_upper_left = cm->mi + mi_row * mis + mi_col; |
1094 const int bh = num_8x8_blocks_high_lookup[bsize]; | 1096 const int bh = num_8x8_blocks_high_lookup[bsize]; |
1095 const int bw = num_8x8_blocks_wide_lookup[bsize]; | 1097 const int bw = num_8x8_blocks_wide_lookup[bsize]; |
1096 int block_row, block_col; | 1098 int block_row, block_col; |
1097 | 1099 |
1098 assert((row8x8_remaining > 0) && (col8x8_remaining > 0)); | 1100 assert((row8x8_remaining > 0) && (col8x8_remaining > 0)); |
1099 | 1101 |
1100 // If the SB64 if it is all "in image". | 1102 // If the SB64 if it is all "in image". |
1101 if ((col8x8_remaining >= MI_BLOCK_SIZE) && | 1103 if ((col8x8_remaining >= MI_BLOCK_SIZE) && |
1102 (row8x8_remaining >= MI_BLOCK_SIZE)) { | 1104 (row8x8_remaining >= MI_BLOCK_SIZE)) { |
1103 for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { | 1105 for (block_row = 0; block_row < MI_BLOCK_SIZE; block_row += bh) { |
1104 for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { | 1106 for (block_col = 0; block_col < MI_BLOCK_SIZE; block_col += bw) { |
1105 const int index = block_row * mis + block_col; | 1107 const int index = block_row * mis + block_col; |
1106 MODE_INFO *prev_mi = prev_mi_8x8[index]; | 1108 MODE_INFO *prev_mi = prev_mi_8x8[index].src_mi; |
1107 const BLOCK_SIZE sb_type = prev_mi ? prev_mi->mbmi.sb_type : 0; | 1109 const BLOCK_SIZE sb_type = prev_mi ? prev_mi->mbmi.sb_type : 0; |
1108 // Use previous partition if block size is not larger than bsize. | 1110 // Use previous partition if block size is not larger than bsize. |
1109 if (prev_mi && sb_type <= bsize) { | 1111 if (prev_mi && sb_type <= bsize) { |
1110 int block_row2, block_col2; | 1112 int block_row2, block_col2; |
1111 for (block_row2 = 0; block_row2 < bh; ++block_row2) { | 1113 for (block_row2 = 0; block_row2 < bh; ++block_row2) { |
1112 for (block_col2 = 0; block_col2 < bw; ++block_col2) { | 1114 for (block_col2 = 0; block_col2 < bw; ++block_col2) { |
1113 const int index2 = (block_row + block_row2) * mis + | 1115 const int index2 = (block_row + block_row2) * mis + |
1114 block_col + block_col2; | 1116 block_col + block_col2; |
1115 prev_mi = prev_mi_8x8[index2]; | 1117 prev_mi = prev_mi_8x8[index2].src_mi; |
1116 if (prev_mi) { | 1118 if (prev_mi) { |
1117 const ptrdiff_t offset = prev_mi - cm->prev_mi; | 1119 const ptrdiff_t offset = prev_mi - cm->prev_mi; |
1118 mi_8x8[index2] = cm->mi + offset; | 1120 mi_8x8[index2].src_mi = cm->mi + offset; |
1119 mi_8x8[index2]->mbmi.sb_type = prev_mi->mbmi.sb_type; | 1121 mi_8x8[index2].src_mi->mbmi.sb_type = prev_mi->mbmi.sb_type; |
1120 } | 1122 } |
1121 } | 1123 } |
1122 } | 1124 } |
1123 } else { | 1125 } else { |
1124 // Otherwise, use fixed partition of size bsize. | 1126 // Otherwise, use fixed partition of size bsize. |
1125 mi_8x8[index] = mi_upper_left + index; | 1127 mi_8x8[index].src_mi = mi_upper_left + index; |
1126 mi_8x8[index]->mbmi.sb_type = bsize; | 1128 mi_8x8[index].src_mi->mbmi.sb_type = bsize; |
1127 } | 1129 } |
1128 } | 1130 } |
1129 } | 1131 } |
1130 } else { | 1132 } else { |
1131 // Else this is a partial SB64, copy previous partition. | 1133 // Else this is a partial SB64, copy previous partition. |
1132 copy_partitioning(cm, mi_8x8, prev_mi_8x8); | 1134 copy_partitioning(cm, mi_8x8, prev_mi_8x8); |
1133 } | 1135 } |
1134 } | 1136 } |
1135 | 1137 |
1136 const struct { | 1138 const struct { |
1137 int row; | 1139 int row; |
1138 int col; | 1140 int col; |
1139 } coord_lookup[16] = { | 1141 } coord_lookup[16] = { |
1140 // 32x32 index = 0 | 1142 // 32x32 index = 0 |
1141 {0, 0}, {0, 2}, {2, 0}, {2, 2}, | 1143 {0, 0}, {0, 2}, {2, 0}, {2, 2}, |
1142 // 32x32 index = 1 | 1144 // 32x32 index = 1 |
1143 {0, 4}, {0, 6}, {2, 4}, {2, 6}, | 1145 {0, 4}, {0, 6}, {2, 4}, {2, 6}, |
1144 // 32x32 index = 2 | 1146 // 32x32 index = 2 |
1145 {4, 0}, {4, 2}, {6, 0}, {6, 2}, | 1147 {4, 0}, {4, 2}, {6, 0}, {6, 2}, |
1146 // 32x32 index = 3 | 1148 // 32x32 index = 3 |
1147 {4, 4}, {4, 6}, {6, 4}, {6, 6}, | 1149 {4, 4}, {4, 6}, {6, 4}, {6, 6}, |
1148 }; | 1150 }; |
1149 | 1151 |
1150 static void set_source_var_based_partition(VP9_COMP *cpi, | 1152 static void set_source_var_based_partition(VP9_COMP *cpi, |
1151 const TileInfo *const tile, | 1153 const TileInfo *const tile, |
1152 MODE_INFO **mi_8x8, | 1154 MODE_INFO *mi_8x8, |
1153 int mi_row, int mi_col) { | 1155 int mi_row, int mi_col) { |
1154 VP9_COMMON *const cm = &cpi->common; | 1156 VP9_COMMON *const cm = &cpi->common; |
1155 MACROBLOCK *const x = &cpi->mb; | 1157 MACROBLOCK *const x = &cpi->mb; |
1156 const int mis = cm->mi_stride; | 1158 const int mis = cm->mi_stride; |
1157 const int row8x8_remaining = tile->mi_row_end - mi_row; | 1159 const int row8x8_remaining = tile->mi_row_end - mi_row; |
1158 const int col8x8_remaining = tile->mi_col_end - mi_col; | 1160 const int col8x8_remaining = tile->mi_col_end - mi_col; |
1159 MODE_INFO *mi_upper_left = cm->mi + mi_row * mis + mi_col; | 1161 MODE_INFO *mi_upper_left = cm->mi + mi_row * mis + mi_col; |
1160 | 1162 |
1161 vp9_setup_src_planes(x, cpi->Source, mi_row, mi_col); | 1163 vp9_setup_src_planes(x, cpi->Source, mi_row, mi_col); |
1162 | 1164 |
(...skipping 17 matching lines...) Expand all Loading... |
1180 | 1182 |
1181 for (j = 0; j < 4; j++) { | 1183 for (j = 0; j < 4; j++) { |
1182 int b_mi_row = coord_lookup[i * 4 + j].row; | 1184 int b_mi_row = coord_lookup[i * 4 + j].row; |
1183 int b_mi_col = coord_lookup[i * 4 + j].col; | 1185 int b_mi_col = coord_lookup[i * 4 + j].col; |
1184 int boffset = b_mi_row / 2 * cm->mb_cols + | 1186 int boffset = b_mi_row / 2 * cm->mb_cols + |
1185 b_mi_col / 2; | 1187 b_mi_col / 2; |
1186 | 1188 |
1187 d16[j] = cpi->source_diff_var + offset + boffset; | 1189 d16[j] = cpi->source_diff_var + offset + boffset; |
1188 | 1190 |
1189 index = b_mi_row * mis + b_mi_col; | 1191 index = b_mi_row * mis + b_mi_col; |
1190 mi_8x8[index] = mi_upper_left + index; | 1192 mi_8x8[index].src_mi = mi_upper_left + index; |
1191 mi_8x8[index]->mbmi.sb_type = BLOCK_16X16; | 1193 mi_8x8[index].src_mi->mbmi.sb_type = BLOCK_16X16; |
1192 | 1194 |
1193 // TODO(yunqingwang): If d16[j].var is very large, use 8x8 partition | 1195 // TODO(yunqingwang): If d16[j].var is very large, use 8x8 partition |
1194 // size to further improve quality. | 1196 // size to further improve quality. |
1195 } | 1197 } |
1196 | 1198 |
1197 is_larger_better = (d16[0]->var < thr) && (d16[1]->var < thr) && | 1199 is_larger_better = (d16[0]->var < thr) && (d16[1]->var < thr) && |
1198 (d16[2]->var < thr) && (d16[3]->var < thr); | 1200 (d16[2]->var < thr) && (d16[3]->var < thr); |
1199 | 1201 |
1200 // Use 32x32 partition | 1202 // Use 32x32 partition |
1201 if (is_larger_better) { | 1203 if (is_larger_better) { |
1202 use32x32 += 1; | 1204 use32x32 += 1; |
1203 | 1205 |
1204 for (j = 0; j < 4; j++) { | 1206 for (j = 0; j < 4; j++) { |
1205 d32[i].sse += d16[j]->sse; | 1207 d32[i].sse += d16[j]->sse; |
1206 d32[i].sum += d16[j]->sum; | 1208 d32[i].sum += d16[j]->sum; |
1207 } | 1209 } |
1208 | 1210 |
1209 d32[i].var = d32[i].sse - (((int64_t)d32[i].sum * d32[i].sum) >> 10); | 1211 d32[i].var = d32[i].sse - (((int64_t)d32[i].sum * d32[i].sum) >> 10); |
1210 | 1212 |
1211 index = coord_lookup[i*4].row * mis + coord_lookup[i*4].col; | 1213 index = coord_lookup[i*4].row * mis + coord_lookup[i*4].col; |
1212 mi_8x8[index] = mi_upper_left + index; | 1214 mi_8x8[index].src_mi = mi_upper_left + index; |
1213 mi_8x8[index]->mbmi.sb_type = BLOCK_32X32; | 1215 mi_8x8[index].src_mi->mbmi.sb_type = BLOCK_32X32; |
1214 } | 1216 } |
1215 } | 1217 } |
1216 | 1218 |
1217 if (use32x32 == 4) { | 1219 if (use32x32 == 4) { |
1218 thr <<= 1; | 1220 thr <<= 1; |
1219 is_larger_better = (d32[0].var < thr) && (d32[1].var < thr) && | 1221 is_larger_better = (d32[0].var < thr) && (d32[1].var < thr) && |
1220 (d32[2].var < thr) && (d32[3].var < thr); | 1222 (d32[2].var < thr) && (d32[3].var < thr); |
1221 | 1223 |
1222 // Use 64x64 partition | 1224 // Use 64x64 partition |
1223 if (is_larger_better) { | 1225 if (is_larger_better) { |
1224 mi_8x8[0] = mi_upper_left; | 1226 mi_8x8[0].src_mi = mi_upper_left; |
1225 mi_8x8[0]->mbmi.sb_type = BLOCK_64X64; | 1227 mi_8x8[0].src_mi->mbmi.sb_type = BLOCK_64X64; |
1226 } | 1228 } |
1227 } | 1229 } |
1228 } else { // partial in-image SB64 | 1230 } else { // partial in-image SB64 |
1229 int bh = num_8x8_blocks_high_lookup[BLOCK_16X16]; | 1231 int bh = num_8x8_blocks_high_lookup[BLOCK_16X16]; |
1230 int bw = num_8x8_blocks_wide_lookup[BLOCK_16X16]; | 1232 int bw = num_8x8_blocks_wide_lookup[BLOCK_16X16]; |
1231 set_partial_b64x64_partition(mi_upper_left, mis, bh, bw, | 1233 set_partial_b64x64_partition(mi_upper_left, mis, bh, bw, |
1232 row8x8_remaining, col8x8_remaining, BLOCK_16X16, mi_8x8); | 1234 row8x8_remaining, col8x8_remaining, BLOCK_16X16, mi_8x8); |
1233 } | 1235 } |
1234 } | 1236 } |
1235 | 1237 |
(...skipping 20 matching lines...) Expand all Loading... |
1256 for (r = 0; r < row8x8_remaining; r += 2) | 1258 for (r = 0; r < row8x8_remaining; r += 2) |
1257 for (c = 0; c < col8x8_remaining; c += 2) | 1259 for (c = 0; c < col8x8_remaining; c += 2) |
1258 this_sad += cpi->fn_ptr[BLOCK_16X16].sdf(src, src_stride, | 1260 this_sad += cpi->fn_ptr[BLOCK_16X16].sdf(src, src_stride, |
1259 pre, pre_stride); | 1261 pre, pre_stride); |
1260 threshold = (row8x8_remaining * col8x8_remaining) << 6; | 1262 threshold = (row8x8_remaining * col8x8_remaining) << 6; |
1261 } | 1263 } |
1262 | 1264 |
1263 return this_sad < 2 * threshold; | 1265 return this_sad < 2 * threshold; |
1264 } | 1266 } |
1265 | 1267 |
1266 static int sb_has_motion(const VP9_COMMON *cm, MODE_INFO **prev_mi_8x8, | 1268 static int sb_has_motion(const VP9_COMMON *cm, MODE_INFO *prev_mi_8x8, |
1267 const int motion_thresh) { | 1269 const int motion_thresh) { |
1268 const int mis = cm->mi_stride; | 1270 const int mis = cm->mi_stride; |
1269 int block_row, block_col; | 1271 int block_row, block_col; |
1270 | 1272 |
1271 if (cm->prev_mi) { | 1273 if (cm->prev_mi) { |
1272 for (block_row = 0; block_row < 8; ++block_row) { | 1274 for (block_row = 0; block_row < 8; ++block_row) { |
1273 for (block_col = 0; block_col < 8; ++block_col) { | 1275 for (block_col = 0; block_col < 8; ++block_col) { |
1274 const MODE_INFO *prev_mi = prev_mi_8x8[block_row * mis + block_col]; | 1276 const MODE_INFO *prev_mi = |
| 1277 prev_mi_8x8[block_row * mis + block_col].src_mi; |
1275 if (prev_mi) { | 1278 if (prev_mi) { |
1276 if (abs(prev_mi->mbmi.mv[0].as_mv.row) > motion_thresh || | 1279 if (abs(prev_mi->mbmi.mv[0].as_mv.row) > motion_thresh || |
1277 abs(prev_mi->mbmi.mv[0].as_mv.col) > motion_thresh) | 1280 abs(prev_mi->mbmi.mv[0].as_mv.col) > motion_thresh) |
1278 return 1; | 1281 return 1; |
1279 } | 1282 } |
1280 } | 1283 } |
1281 } | 1284 } |
1282 } | 1285 } |
1283 return 0; | 1286 return 0; |
1284 } | 1287 } |
1285 | 1288 |
1286 static void update_state_rt(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, | 1289 static void update_state_rt(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, |
1287 int mi_row, int mi_col, int bsize) { | 1290 int mi_row, int mi_col, int bsize) { |
1288 VP9_COMMON *const cm = &cpi->common; | 1291 VP9_COMMON *const cm = &cpi->common; |
1289 MACROBLOCK *const x = &cpi->mb; | 1292 MACROBLOCK *const x = &cpi->mb; |
1290 MACROBLOCKD *const xd = &x->e_mbd; | 1293 MACROBLOCKD *const xd = &x->e_mbd; |
1291 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; | 1294 MB_MODE_INFO *const mbmi = &xd->mi[0].src_mi->mbmi; |
1292 const struct segmentation *const seg = &cm->seg; | 1295 const struct segmentation *const seg = &cm->seg; |
1293 | 1296 |
1294 *(xd->mi[0]) = ctx->mic; | 1297 *(xd->mi[0].src_mi) = ctx->mic; |
| 1298 xd->mi[0].src_mi = &xd->mi[0]; |
| 1299 |
1295 | 1300 |
1296 // For in frame adaptive Q, check for reseting the segment_id and updating | 1301 // For in frame adaptive Q, check for reseting the segment_id and updating |
1297 // the cyclic refresh map. | 1302 // the cyclic refresh map. |
1298 if ((cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) && seg->enabled) { | 1303 if ((cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ) && seg->enabled) { |
1299 vp9_cyclic_refresh_update_segment(cpi, &xd->mi[0]->mbmi, | 1304 vp9_cyclic_refresh_update_segment(cpi, &xd->mi[0].src_mi->mbmi, |
1300 mi_row, mi_col, bsize, 1); | 1305 mi_row, mi_col, bsize, 1); |
1301 vp9_init_plane_quantizers(cpi, x); | 1306 vp9_init_plane_quantizers(cpi, x); |
1302 } | 1307 } |
1303 | 1308 |
1304 if (is_inter_block(mbmi)) { | 1309 if (is_inter_block(mbmi)) { |
1305 vp9_update_mv_count(cm, xd); | 1310 vp9_update_mv_count(cm, xd); |
1306 | 1311 |
1307 if (cm->interp_filter == SWITCHABLE) { | 1312 if (cm->interp_filter == SWITCHABLE) { |
1308 const int pred_ctx = vp9_get_pred_context_switchable_interp(xd); | 1313 const int pred_ctx = vp9_get_pred_context_switchable_interp(xd); |
1309 ++cm->counts.switchable_interp[pred_ctx][mbmi->interp_filter]; | 1314 ++cm->counts.switchable_interp[pred_ctx][mbmi->interp_filter]; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; | 1351 const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; |
1347 int ctx; | 1352 int ctx; |
1348 PARTITION_TYPE partition; | 1353 PARTITION_TYPE partition; |
1349 BLOCK_SIZE subsize; | 1354 BLOCK_SIZE subsize; |
1350 | 1355 |
1351 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 1356 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
1352 return; | 1357 return; |
1353 | 1358 |
1354 if (bsize >= BLOCK_8X8) { | 1359 if (bsize >= BLOCK_8X8) { |
1355 const int idx_str = xd->mi_stride * mi_row + mi_col; | 1360 const int idx_str = xd->mi_stride * mi_row + mi_col; |
1356 MODE_INFO ** mi_8x8 = cm->mi_grid_visible + idx_str; | 1361 MODE_INFO *mi_8x8 = cm->mi[idx_str].src_mi; |
1357 ctx = partition_plane_context(xd, mi_row, mi_col, bsize); | 1362 ctx = partition_plane_context(xd, mi_row, mi_col, bsize); |
1358 subsize = mi_8x8[0]->mbmi.sb_type; | 1363 subsize = mi_8x8[0].src_mi->mbmi.sb_type; |
1359 } else { | 1364 } else { |
1360 ctx = 0; | 1365 ctx = 0; |
1361 subsize = BLOCK_4X4; | 1366 subsize = BLOCK_4X4; |
1362 } | 1367 } |
1363 | 1368 |
1364 partition = partition_lookup[bsl][subsize]; | 1369 partition = partition_lookup[bsl][subsize]; |
1365 if (output_enabled && bsize != BLOCK_4X4) | 1370 if (output_enabled && bsize != BLOCK_4X4) |
1366 cm->counts.partition[ctx][partition]++; | 1371 cm->counts.partition[ctx][partition]++; |
1367 | 1372 |
1368 switch (partition) { | 1373 switch (partition) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 assert("Invalid partition type."); | 1406 assert("Invalid partition type."); |
1402 break; | 1407 break; |
1403 } | 1408 } |
1404 | 1409 |
1405 if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) | 1410 if (partition != PARTITION_SPLIT || bsize == BLOCK_8X8) |
1406 update_partition_context(xd, mi_row, mi_col, subsize, bsize); | 1411 update_partition_context(xd, mi_row, mi_col, subsize, bsize); |
1407 } | 1412 } |
1408 | 1413 |
1409 static void rd_use_partition(VP9_COMP *cpi, | 1414 static void rd_use_partition(VP9_COMP *cpi, |
1410 const TileInfo *const tile, | 1415 const TileInfo *const tile, |
1411 MODE_INFO **mi_8x8, | 1416 MODE_INFO *mi_8x8, |
1412 TOKENEXTRA **tp, int mi_row, int mi_col, | 1417 TOKENEXTRA **tp, int mi_row, int mi_col, |
1413 BLOCK_SIZE bsize, int *rate, int64_t *dist, | 1418 BLOCK_SIZE bsize, int *rate, int64_t *dist, |
1414 int do_recon, PC_TREE *pc_tree) { | 1419 int do_recon, PC_TREE *pc_tree) { |
1415 VP9_COMMON *const cm = &cpi->common; | 1420 VP9_COMMON *const cm = &cpi->common; |
1416 MACROBLOCK *const x = &cpi->mb; | 1421 MACROBLOCK *const x = &cpi->mb; |
1417 MACROBLOCKD *const xd = &x->e_mbd; | 1422 MACROBLOCKD *const xd = &x->e_mbd; |
1418 const int mis = cm->mi_stride; | 1423 const int mis = cm->mi_stride; |
1419 const int bsl = b_width_log2(bsize); | 1424 const int bsl = b_width_log2(bsize); |
1420 const int mi_step = num_4x4_blocks_wide_lookup[bsize] / 2; | 1425 const int mi_step = num_4x4_blocks_wide_lookup[bsize] / 2; |
1421 const int bss = (1 << bsl) / 4; | 1426 const int bss = (1 << bsl) / 4; |
1422 int i, pl; | 1427 int i, pl; |
1423 PARTITION_TYPE partition = PARTITION_NONE; | 1428 PARTITION_TYPE partition = PARTITION_NONE; |
1424 BLOCK_SIZE subsize; | 1429 BLOCK_SIZE subsize; |
1425 ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; | 1430 ENTROPY_CONTEXT l[16 * MAX_MB_PLANE], a[16 * MAX_MB_PLANE]; |
1426 PARTITION_CONTEXT sl[8], sa[8]; | 1431 PARTITION_CONTEXT sl[8], sa[8]; |
1427 int last_part_rate = INT_MAX; | 1432 int last_part_rate = INT_MAX; |
1428 int64_t last_part_dist = INT64_MAX; | 1433 int64_t last_part_dist = INT64_MAX; |
1429 int64_t last_part_rd = INT64_MAX; | 1434 int64_t last_part_rd = INT64_MAX; |
1430 int none_rate = INT_MAX; | 1435 int none_rate = INT_MAX; |
1431 int64_t none_dist = INT64_MAX; | 1436 int64_t none_dist = INT64_MAX; |
1432 int64_t none_rd = INT64_MAX; | 1437 int64_t none_rd = INT64_MAX; |
1433 int chosen_rate = INT_MAX; | 1438 int chosen_rate = INT_MAX; |
1434 int64_t chosen_dist = INT64_MAX; | 1439 int64_t chosen_dist = INT64_MAX; |
1435 int64_t chosen_rd = INT64_MAX; | 1440 int64_t chosen_rd = INT64_MAX; |
1436 BLOCK_SIZE sub_subsize = BLOCK_4X4; | 1441 BLOCK_SIZE sub_subsize = BLOCK_4X4; |
1437 int splits_below = 0; | 1442 int splits_below = 0; |
1438 BLOCK_SIZE bs_type = mi_8x8[0]->mbmi.sb_type; | 1443 BLOCK_SIZE bs_type = mi_8x8[0].src_mi->mbmi.sb_type; |
1439 int do_partition_search = 1; | 1444 int do_partition_search = 1; |
1440 PICK_MODE_CONTEXT *ctx = &pc_tree->none; | 1445 PICK_MODE_CONTEXT *ctx = &pc_tree->none; |
1441 | 1446 |
1442 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 1447 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
1443 return; | 1448 return; |
1444 | 1449 |
1445 assert(num_4x4_blocks_wide_lookup[bsize] == | 1450 assert(num_4x4_blocks_wide_lookup[bsize] == |
1446 num_4x4_blocks_high_lookup[bsize]); | 1451 num_4x4_blocks_high_lookup[bsize]); |
1447 | 1452 |
1448 partition = partition_lookup[bsl][bs_type]; | 1453 partition = partition_lookup[bsl][bs_type]; |
1449 subsize = get_subsize(bsize, partition); | 1454 subsize = get_subsize(bsize, partition); |
1450 | 1455 |
1451 pc_tree->partitioning = partition; | 1456 pc_tree->partitioning = partition; |
1452 save_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); | 1457 save_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
1453 | 1458 |
1454 if (bsize == BLOCK_16X16 && cpi->oxcf.aq_mode) { | 1459 if (bsize == BLOCK_16X16 && cpi->oxcf.aq_mode) { |
1455 set_offsets(cpi, tile, mi_row, mi_col, bsize); | 1460 set_offsets(cpi, tile, mi_row, mi_col, bsize); |
1456 x->mb_energy = vp9_block_energy(cpi, x, bsize); | 1461 x->mb_energy = vp9_block_energy(cpi, x, bsize); |
1457 } | 1462 } |
1458 | 1463 |
1459 if (do_partition_search && | 1464 if (do_partition_search && |
1460 cpi->sf.partition_search_type == SEARCH_PARTITION && | 1465 cpi->sf.partition_search_type == SEARCH_PARTITION && |
1461 cpi->sf.adjust_partitioning_from_last_frame) { | 1466 cpi->sf.adjust_partitioning_from_last_frame) { |
1462 // Check if any of the sub blocks are further split. | 1467 // Check if any of the sub blocks are further split. |
1463 if (partition == PARTITION_SPLIT && subsize > BLOCK_8X8) { | 1468 if (partition == PARTITION_SPLIT && subsize > BLOCK_8X8) { |
1464 sub_subsize = get_subsize(subsize, PARTITION_SPLIT); | 1469 sub_subsize = get_subsize(subsize, PARTITION_SPLIT); |
1465 splits_below = 1; | 1470 splits_below = 1; |
1466 for (i = 0; i < 4; i++) { | 1471 for (i = 0; i < 4; i++) { |
1467 int jj = i >> 1, ii = i & 0x01; | 1472 int jj = i >> 1, ii = i & 0x01; |
1468 MODE_INFO * this_mi = mi_8x8[jj * bss * mis + ii * bss]; | 1473 MODE_INFO *this_mi = mi_8x8[jj * bss * mis + ii * bss].src_mi; |
1469 if (this_mi && this_mi->mbmi.sb_type >= sub_subsize) { | 1474 if (this_mi && this_mi->mbmi.sb_type >= sub_subsize) { |
1470 splits_below = 0; | 1475 splits_below = 0; |
1471 } | 1476 } |
1472 } | 1477 } |
1473 } | 1478 } |
1474 | 1479 |
1475 // If partition is not none try none unless each of the 4 splits are split | 1480 // If partition is not none try none unless each of the 4 splits are split |
1476 // even further.. | 1481 // even further.. |
1477 if (partition != PARTITION_NONE && !splits_below && | 1482 if (partition != PARTITION_NONE && !splits_below && |
1478 mi_row + (mi_step >> 1) < cm->mi_rows && | 1483 mi_row + (mi_step >> 1) < cm->mi_rows && |
1479 mi_col + (mi_step >> 1) < cm->mi_cols) { | 1484 mi_col + (mi_step >> 1) < cm->mi_cols) { |
1480 pc_tree->partitioning = PARTITION_NONE; | 1485 pc_tree->partitioning = PARTITION_NONE; |
1481 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize, | 1486 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize, |
1482 ctx, INT64_MAX, 0); | 1487 ctx, INT64_MAX, 0); |
1483 | 1488 |
1484 pl = partition_plane_context(xd, mi_row, mi_col, bsize); | 1489 pl = partition_plane_context(xd, mi_row, mi_col, bsize); |
1485 | 1490 |
1486 if (none_rate < INT_MAX) { | 1491 if (none_rate < INT_MAX) { |
1487 none_rate += cpi->partition_cost[pl][PARTITION_NONE]; | 1492 none_rate += cpi->partition_cost[pl][PARTITION_NONE]; |
1488 none_rd = RDCOST(x->rdmult, x->rddiv, none_rate, none_dist); | 1493 none_rd = RDCOST(x->rdmult, x->rddiv, none_rate, none_dist); |
1489 } | 1494 } |
1490 | 1495 |
1491 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); | 1496 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); |
1492 mi_8x8[0]->mbmi.sb_type = bs_type; | 1497 mi_8x8[0].src_mi->mbmi.sb_type = bs_type; |
1493 pc_tree->partitioning = partition; | 1498 pc_tree->partitioning = partition; |
1494 } | 1499 } |
1495 } | 1500 } |
1496 | 1501 |
1497 switch (partition) { | 1502 switch (partition) { |
1498 case PARTITION_NONE: | 1503 case PARTITION_NONE: |
1499 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &last_part_rate, | 1504 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &last_part_rate, |
1500 &last_part_dist, bsize, ctx, INT64_MAX, 0); | 1505 &last_part_dist, bsize, ctx, INT64_MAX, 0); |
1501 break; | 1506 break; |
1502 case PARTITION_HORZ: | 1507 case PARTITION_HORZ: |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 } | 1645 } |
1641 pl = partition_plane_context(xd, mi_row, mi_col, bsize); | 1646 pl = partition_plane_context(xd, mi_row, mi_col, bsize); |
1642 if (chosen_rate < INT_MAX) { | 1647 if (chosen_rate < INT_MAX) { |
1643 chosen_rate += cpi->partition_cost[pl][PARTITION_SPLIT]; | 1648 chosen_rate += cpi->partition_cost[pl][PARTITION_SPLIT]; |
1644 chosen_rd = RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist); | 1649 chosen_rd = RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist); |
1645 } | 1650 } |
1646 } | 1651 } |
1647 | 1652 |
1648 // If last_part is better set the partitioning to that. | 1653 // If last_part is better set the partitioning to that. |
1649 if (last_part_rd < chosen_rd) { | 1654 if (last_part_rd < chosen_rd) { |
1650 mi_8x8[0]->mbmi.sb_type = bsize; | 1655 mi_8x8[0].src_mi->mbmi.sb_type = bsize; |
1651 if (bsize >= BLOCK_8X8) | 1656 if (bsize >= BLOCK_8X8) |
1652 pc_tree->partitioning = partition; | 1657 pc_tree->partitioning = partition; |
1653 chosen_rate = last_part_rate; | 1658 chosen_rate = last_part_rate; |
1654 chosen_dist = last_part_dist; | 1659 chosen_dist = last_part_dist; |
1655 chosen_rd = last_part_rd; | 1660 chosen_rd = last_part_rd; |
1656 } | 1661 } |
1657 // If none was better set the partitioning to that. | 1662 // If none was better set the partitioning to that. |
1658 if (none_rd < chosen_rd) { | 1663 if (none_rd < chosen_rd) { |
1659 if (bsize >= BLOCK_8X8) | 1664 if (bsize >= BLOCK_8X8) |
1660 pc_tree->partitioning = PARTITION_NONE; | 1665 pc_tree->partitioning = PARTITION_NONE; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 BLOCK_64X64 | 1712 BLOCK_64X64 |
1708 }; | 1713 }; |
1709 | 1714 |
1710 // Look at all the mode_info entries for blocks that are part of this | 1715 // Look at all the mode_info entries for blocks that are part of this |
1711 // partition and find the min and max values for sb_type. | 1716 // partition and find the min and max values for sb_type. |
1712 // At the moment this is designed to work on a 64x64 SB but could be | 1717 // At the moment this is designed to work on a 64x64 SB but could be |
1713 // adjusted to use a size parameter. | 1718 // adjusted to use a size parameter. |
1714 // | 1719 // |
1715 // The min and max are assumed to have been initialized prior to calling this | 1720 // The min and max are assumed to have been initialized prior to calling this |
1716 // function so repeat calls can accumulate a min and max of more than one sb64. | 1721 // function so repeat calls can accumulate a min and max of more than one sb64. |
1717 static void get_sb_partition_size_range(MACROBLOCKD *xd, MODE_INFO **mi_8x8, | 1722 static void get_sb_partition_size_range(MACROBLOCKD *xd, MODE_INFO *mi_8x8, |
1718 BLOCK_SIZE *min_block_size, | 1723 BLOCK_SIZE *min_block_size, |
1719 BLOCK_SIZE *max_block_size, | 1724 BLOCK_SIZE *max_block_size, |
1720 int bs_hist[BLOCK_SIZES]) { | 1725 int bs_hist[BLOCK_SIZES]) { |
1721 int sb_width_in_blocks = MI_BLOCK_SIZE; | 1726 int sb_width_in_blocks = MI_BLOCK_SIZE; |
1722 int sb_height_in_blocks = MI_BLOCK_SIZE; | 1727 int sb_height_in_blocks = MI_BLOCK_SIZE; |
1723 int i, j; | 1728 int i, j; |
1724 int index = 0; | 1729 int index = 0; |
1725 | 1730 |
1726 // Check the sb_type for each block that belongs to this region. | 1731 // Check the sb_type for each block that belongs to this region. |
1727 for (i = 0; i < sb_height_in_blocks; ++i) { | 1732 for (i = 0; i < sb_height_in_blocks; ++i) { |
1728 for (j = 0; j < sb_width_in_blocks; ++j) { | 1733 for (j = 0; j < sb_width_in_blocks; ++j) { |
1729 MODE_INFO * mi = mi_8x8[index+j]; | 1734 MODE_INFO *mi = mi_8x8[index+j].src_mi; |
1730 BLOCK_SIZE sb_type = mi ? mi->mbmi.sb_type : 0; | 1735 BLOCK_SIZE sb_type = mi ? mi->mbmi.sb_type : 0; |
1731 bs_hist[sb_type]++; | 1736 bs_hist[sb_type]++; |
1732 *min_block_size = MIN(*min_block_size, sb_type); | 1737 *min_block_size = MIN(*min_block_size, sb_type); |
1733 *max_block_size = MAX(*max_block_size, sb_type); | 1738 *max_block_size = MAX(*max_block_size, sb_type); |
1734 } | 1739 } |
1735 index += xd->mi_stride; | 1740 index += xd->mi_stride; |
1736 } | 1741 } |
1737 } | 1742 } |
1738 | 1743 |
1739 // Next square block size less or equal than current block size. | 1744 // Next square block size less or equal than current block size. |
1740 static const BLOCK_SIZE next_square_size[BLOCK_SIZES] = { | 1745 static const BLOCK_SIZE next_square_size[BLOCK_SIZES] = { |
1741 BLOCK_4X4, BLOCK_4X4, BLOCK_4X4, | 1746 BLOCK_4X4, BLOCK_4X4, BLOCK_4X4, |
1742 BLOCK_8X8, BLOCK_8X8, BLOCK_8X8, | 1747 BLOCK_8X8, BLOCK_8X8, BLOCK_8X8, |
1743 BLOCK_16X16, BLOCK_16X16, BLOCK_16X16, | 1748 BLOCK_16X16, BLOCK_16X16, BLOCK_16X16, |
1744 BLOCK_32X32, BLOCK_32X32, BLOCK_32X32, | 1749 BLOCK_32X32, BLOCK_32X32, BLOCK_32X32, |
1745 BLOCK_64X64 | 1750 BLOCK_64X64 |
1746 }; | 1751 }; |
1747 | 1752 |
1748 // Look at neighboring blocks and set a min and max partition size based on | 1753 // Look at neighboring blocks and set a min and max partition size based on |
1749 // what they chose. | 1754 // what they chose. |
1750 static void rd_auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, | 1755 static void rd_auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, |
1751 int mi_row, int mi_col, | 1756 int mi_row, int mi_col, |
1752 BLOCK_SIZE *min_block_size, | 1757 BLOCK_SIZE *min_block_size, |
1753 BLOCK_SIZE *max_block_size) { | 1758 BLOCK_SIZE *max_block_size) { |
1754 VP9_COMMON *const cm = &cpi->common; | 1759 VP9_COMMON *const cm = &cpi->common; |
1755 MACROBLOCKD *const xd = &cpi->mb.e_mbd; | 1760 MACROBLOCKD *const xd = &cpi->mb.e_mbd; |
1756 MODE_INFO **mi = xd->mi; | 1761 MODE_INFO *mi = xd->mi[0].src_mi; |
1757 const int left_in_image = xd->left_available && mi[-1]; | 1762 const int left_in_image = xd->left_available && mi[-1].src_mi; |
1758 const int above_in_image = xd->up_available && mi[-xd->mi_stride]; | 1763 const int above_in_image = xd->up_available && mi[-xd->mi_stride].src_mi; |
1759 const int row8x8_remaining = tile->mi_row_end - mi_row; | 1764 const int row8x8_remaining = tile->mi_row_end - mi_row; |
1760 const int col8x8_remaining = tile->mi_col_end - mi_col; | 1765 const int col8x8_remaining = tile->mi_col_end - mi_col; |
1761 int bh, bw; | 1766 int bh, bw; |
1762 BLOCK_SIZE min_size = BLOCK_4X4; | 1767 BLOCK_SIZE min_size = BLOCK_4X4; |
1763 BLOCK_SIZE max_size = BLOCK_64X64; | 1768 BLOCK_SIZE max_size = BLOCK_64X64; |
1764 int i = 0; | 1769 int i = 0; |
1765 int bs_hist[BLOCK_SIZES] = {0}; | 1770 int bs_hist[BLOCK_SIZES] = {0}; |
1766 | 1771 |
1767 // Trap case where we do not have a prediction. | 1772 // Trap case where we do not have a prediction. |
1768 if (left_in_image || above_in_image || cm->frame_type != KEY_FRAME) { | 1773 if (left_in_image || above_in_image || cm->frame_type != KEY_FRAME) { |
1769 // Default "min to max" and "max to min" | 1774 // Default "min to max" and "max to min" |
1770 min_size = BLOCK_64X64; | 1775 min_size = BLOCK_64X64; |
1771 max_size = BLOCK_4X4; | 1776 max_size = BLOCK_4X4; |
1772 | 1777 |
1773 // NOTE: each call to get_sb_partition_size_range() uses the previous | 1778 // NOTE: each call to get_sb_partition_size_range() uses the previous |
1774 // passed in values for min and max as a starting point. | 1779 // passed in values for min and max as a starting point. |
1775 // Find the min and max partition used in previous frame at this location | 1780 // Find the min and max partition used in previous frame at this location |
1776 if (cm->frame_type != KEY_FRAME) { | 1781 if (cm->frame_type != KEY_FRAME) { |
1777 MODE_INFO **const prev_mi = | 1782 MODE_INFO *prev_mi = |
1778 &cm->prev_mi_grid_visible[mi_row * xd->mi_stride + mi_col]; | 1783 cm->prev_mip + cm->mi_stride + 1 + mi_row * xd->mi_stride + mi_col; |
| 1784 |
1779 get_sb_partition_size_range(xd, prev_mi, &min_size, &max_size, bs_hist); | 1785 get_sb_partition_size_range(xd, prev_mi, &min_size, &max_size, bs_hist); |
1780 } | 1786 } |
1781 // Find the min and max partition sizes used in the left SB64 | 1787 // Find the min and max partition sizes used in the left SB64 |
1782 if (left_in_image) { | 1788 if (left_in_image) { |
1783 MODE_INFO **left_sb64_mi = &mi[-MI_BLOCK_SIZE]; | 1789 MODE_INFO *left_sb64_mi = mi[-MI_BLOCK_SIZE].src_mi; |
1784 get_sb_partition_size_range(xd, left_sb64_mi, &min_size, &max_size, | 1790 get_sb_partition_size_range(xd, left_sb64_mi, &min_size, &max_size, |
1785 bs_hist); | 1791 bs_hist); |
1786 } | 1792 } |
1787 // Find the min and max partition sizes used in the above SB64. | 1793 // Find the min and max partition sizes used in the above SB64. |
1788 if (above_in_image) { | 1794 if (above_in_image) { |
1789 MODE_INFO **above_sb64_mi = &mi[-xd->mi_stride * MI_BLOCK_SIZE]; | 1795 MODE_INFO *above_sb64_mi = mi[-xd->mi_stride * MI_BLOCK_SIZE].src_mi; |
1790 get_sb_partition_size_range(xd, above_sb64_mi, &min_size, &max_size, | 1796 get_sb_partition_size_range(xd, above_sb64_mi, &min_size, &max_size, |
1791 bs_hist); | 1797 bs_hist); |
1792 } | 1798 } |
1793 | 1799 |
1794 // adjust observed min and max | 1800 // adjust observed min and max |
1795 if (cpi->sf.auto_min_max_partition_size == RELAXED_NEIGHBORING_MIN_MAX) { | 1801 if (cpi->sf.auto_min_max_partition_size == RELAXED_NEIGHBORING_MIN_MAX) { |
1796 min_size = min_partition_size[min_size]; | 1802 min_size = min_partition_size[min_size]; |
1797 max_size = max_partition_size[max_size]; | 1803 max_size = max_partition_size[max_size]; |
1798 } else if (cpi->sf.auto_min_max_partition_size == | 1804 } else if (cpi->sf.auto_min_max_partition_size == |
1799 CONSTRAIN_NEIGHBORING_MIN_MAX) { | 1805 CONSTRAIN_NEIGHBORING_MIN_MAX) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 *min_block_size = min_size; | 1847 *min_block_size = min_size; |
1842 *max_block_size = max_size; | 1848 *max_block_size = max_size; |
1843 } | 1849 } |
1844 | 1850 |
1845 static void auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, | 1851 static void auto_partition_range(VP9_COMP *cpi, const TileInfo *const tile, |
1846 int mi_row, int mi_col, | 1852 int mi_row, int mi_col, |
1847 BLOCK_SIZE *min_block_size, | 1853 BLOCK_SIZE *min_block_size, |
1848 BLOCK_SIZE *max_block_size) { | 1854 BLOCK_SIZE *max_block_size) { |
1849 VP9_COMMON *const cm = &cpi->common; | 1855 VP9_COMMON *const cm = &cpi->common; |
1850 MACROBLOCKD *const xd = &cpi->mb.e_mbd; | 1856 MACROBLOCKD *const xd = &cpi->mb.e_mbd; |
1851 MODE_INFO **mi_8x8 = xd->mi; | 1857 MODE_INFO *mi_8x8 = xd->mi; |
1852 const int left_in_image = xd->left_available && mi_8x8[-1]; | 1858 const int left_in_image = xd->left_available && mi_8x8[-1].src_mi; |
1853 const int above_in_image = xd->up_available && | 1859 const int above_in_image = xd->up_available && |
1854 mi_8x8[-xd->mi_stride]; | 1860 mi_8x8[-xd->mi_stride].src_mi; |
1855 int row8x8_remaining = tile->mi_row_end - mi_row; | 1861 int row8x8_remaining = tile->mi_row_end - mi_row; |
1856 int col8x8_remaining = tile->mi_col_end - mi_col; | 1862 int col8x8_remaining = tile->mi_col_end - mi_col; |
1857 int bh, bw; | 1863 int bh, bw; |
1858 BLOCK_SIZE min_size = BLOCK_32X32; | 1864 BLOCK_SIZE min_size = BLOCK_32X32; |
1859 BLOCK_SIZE max_size = BLOCK_8X8; | 1865 BLOCK_SIZE max_size = BLOCK_8X8; |
1860 int bsl = mi_width_log2(BLOCK_64X64); | 1866 int bsl = mi_width_log2(BLOCK_64X64); |
1861 const int search_range_ctrl = (((mi_row + mi_col) >> bsl) + | 1867 const int search_range_ctrl = (((mi_row + mi_col) >> bsl) + |
1862 get_chessboard_index(cm->current_video_frame)) & 0x1; | 1868 get_chessboard_index(cm->current_video_frame)) & 0x1; |
1863 // Trap case where we do not have a prediction. | 1869 // Trap case where we do not have a prediction. |
1864 if (search_range_ctrl && | 1870 if (search_range_ctrl && |
1865 (left_in_image || above_in_image || cm->frame_type != KEY_FRAME)) { | 1871 (left_in_image || above_in_image || cm->frame_type != KEY_FRAME)) { |
1866 int block; | 1872 int block; |
1867 MODE_INFO **mi; | 1873 MODE_INFO *mi; |
1868 BLOCK_SIZE sb_type; | 1874 BLOCK_SIZE sb_type; |
1869 | 1875 |
1870 // Find the min and max partition sizes used in the left SB64. | 1876 // Find the min and max partition sizes used in the left SB64. |
1871 if (left_in_image) { | 1877 if (left_in_image) { |
1872 MODE_INFO *cur_mi; | 1878 MODE_INFO *cur_mi; |
1873 mi = &mi_8x8[-1]; | 1879 mi = mi_8x8[-1].src_mi; |
1874 for (block = 0; block < MI_BLOCK_SIZE; ++block) { | 1880 for (block = 0; block < MI_BLOCK_SIZE; ++block) { |
1875 cur_mi = mi[block * xd->mi_stride]; | 1881 cur_mi = mi[block * xd->mi_stride].src_mi; |
1876 sb_type = cur_mi ? cur_mi->mbmi.sb_type : 0; | 1882 sb_type = cur_mi ? cur_mi->mbmi.sb_type : 0; |
1877 min_size = MIN(min_size, sb_type); | 1883 min_size = MIN(min_size, sb_type); |
1878 max_size = MAX(max_size, sb_type); | 1884 max_size = MAX(max_size, sb_type); |
1879 } | 1885 } |
1880 } | 1886 } |
1881 // Find the min and max partition sizes used in the above SB64. | 1887 // Find the min and max partition sizes used in the above SB64. |
1882 if (above_in_image) { | 1888 if (above_in_image) { |
1883 mi = &mi_8x8[-xd->mi_stride * MI_BLOCK_SIZE]; | 1889 mi = mi_8x8[-xd->mi_stride * MI_BLOCK_SIZE].src_mi; |
1884 for (block = 0; block < MI_BLOCK_SIZE; ++block) { | 1890 for (block = 0; block < MI_BLOCK_SIZE; ++block) { |
1885 sb_type = mi[block] ? mi[block]->mbmi.sb_type : 0; | 1891 sb_type = mi[block].src_mi ? mi[block].src_mi->mbmi.sb_type : 0; |
1886 min_size = MIN(min_size, sb_type); | 1892 min_size = MIN(min_size, sb_type); |
1887 max_size = MAX(max_size, sb_type); | 1893 max_size = MAX(max_size, sb_type); |
1888 } | 1894 } |
1889 } | 1895 } |
1890 | 1896 |
1891 min_size = min_partition_size[min_size]; | 1897 min_size = min_partition_size[min_size]; |
1892 max_size = find_partition_size(max_size, row8x8_remaining, col8x8_remaining, | 1898 max_size = find_partition_size(max_size, row8x8_remaining, col8x8_remaining, |
1893 &bh, &bw); | 1899 &bh, &bw); |
1894 min_size = MIN(min_size, max_size); | 1900 min_size = MIN(min_size, max_size); |
1895 min_size = MAX(min_size, BLOCK_8X8); | 1901 min_size = MAX(min_size, BLOCK_8X8); |
1896 max_size = MIN(max_size, BLOCK_32X32); | 1902 max_size = MIN(max_size, BLOCK_32X32); |
1897 } else { | 1903 } else { |
1898 min_size = BLOCK_8X8; | 1904 min_size = BLOCK_8X8; |
1899 max_size = BLOCK_32X32; | 1905 max_size = BLOCK_32X32; |
1900 } | 1906 } |
1901 | 1907 |
1902 *min_block_size = min_size; | 1908 *min_block_size = min_size; |
1903 *max_block_size = max_size; | 1909 *max_block_size = max_size; |
1904 } | 1910 } |
1905 | 1911 |
1906 // TODO(jingning) refactor functions setting partition search range | 1912 // TODO(jingning) refactor functions setting partition search range |
1907 static void set_partition_range(VP9_COMMON *cm, MACROBLOCKD *xd, | 1913 static void set_partition_range(VP9_COMMON *cm, MACROBLOCKD *xd, |
1908 int mi_row, int mi_col, BLOCK_SIZE bsize, | 1914 int mi_row, int mi_col, BLOCK_SIZE bsize, |
1909 BLOCK_SIZE *min_bs, BLOCK_SIZE *max_bs) { | 1915 BLOCK_SIZE *min_bs, BLOCK_SIZE *max_bs) { |
1910 int mi_width = num_8x8_blocks_wide_lookup[bsize]; | 1916 int mi_width = num_8x8_blocks_wide_lookup[bsize]; |
1911 int mi_height = num_8x8_blocks_high_lookup[bsize]; | 1917 int mi_height = num_8x8_blocks_high_lookup[bsize]; |
1912 int idx, idy; | 1918 int idx, idy; |
1913 | 1919 |
1914 MODE_INFO *mi; | 1920 MODE_INFO *mi; |
1915 MODE_INFO **prev_mi = | 1921 const int idx_str = cm->mi_stride * mi_row + mi_col; |
1916 &cm->prev_mi_grid_visible[mi_row * cm->mi_stride + mi_col]; | 1922 MODE_INFO *prev_mi = (cm->prev_mip + cm->mi_stride + 1 + idx_str)->src_mi; |
| 1923 |
| 1924 |
1917 BLOCK_SIZE bs, min_size, max_size; | 1925 BLOCK_SIZE bs, min_size, max_size; |
1918 | 1926 |
1919 min_size = BLOCK_64X64; | 1927 min_size = BLOCK_64X64; |
1920 max_size = BLOCK_4X4; | 1928 max_size = BLOCK_4X4; |
1921 | 1929 |
1922 if (prev_mi) { | 1930 if (prev_mi) { |
1923 for (idy = 0; idy < mi_height; ++idy) { | 1931 for (idy = 0; idy < mi_height; ++idy) { |
1924 for (idx = 0; idx < mi_width; ++idx) { | 1932 for (idx = 0; idx < mi_width; ++idx) { |
1925 mi = prev_mi[idy * cm->mi_stride + idx]; | 1933 mi = prev_mi[idy * cm->mi_stride + idx].src_mi; |
1926 bs = mi ? mi->mbmi.sb_type : bsize; | 1934 bs = mi ? mi->mbmi.sb_type : bsize; |
1927 min_size = MIN(min_size, bs); | 1935 min_size = MIN(min_size, bs); |
1928 max_size = MAX(max_size, bs); | 1936 max_size = MAX(max_size, bs); |
1929 } | 1937 } |
1930 } | 1938 } |
1931 } | 1939 } |
1932 | 1940 |
1933 if (xd->left_available) { | 1941 if (xd->left_available) { |
1934 for (idy = 0; idy < mi_height; ++idy) { | 1942 for (idy = 0; idy < mi_height; ++idy) { |
1935 mi = xd->mi[idy * cm->mi_stride - 1]; | 1943 mi = xd->mi[idy * cm->mi_stride - 1].src_mi; |
1936 bs = mi ? mi->mbmi.sb_type : bsize; | 1944 bs = mi ? mi->mbmi.sb_type : bsize; |
1937 min_size = MIN(min_size, bs); | 1945 min_size = MIN(min_size, bs); |
1938 max_size = MAX(max_size, bs); | 1946 max_size = MAX(max_size, bs); |
1939 } | 1947 } |
1940 } | 1948 } |
1941 | 1949 |
1942 if (xd->up_available) { | 1950 if (xd->up_available) { |
1943 for (idx = 0; idx < mi_width; ++idx) { | 1951 for (idx = 0; idx < mi_width; ++idx) { |
1944 mi = xd->mi[idx - cm->mi_stride]; | 1952 mi = xd->mi[idx - cm->mi_stride].src_mi; |
1945 bs = mi ? mi->mbmi.sb_type : bsize; | 1953 bs = mi ? mi->mbmi.sb_type : bsize; |
1946 min_size = MIN(min_size, bs); | 1954 min_size = MIN(min_size, bs); |
1947 max_size = MAX(max_size, bs); | 1955 max_size = MAX(max_size, bs); |
1948 } | 1956 } |
1949 } | 1957 } |
1950 | 1958 |
1951 if (min_size == max_size) { | 1959 if (min_size == max_size) { |
1952 min_size = min_partition_size[min_size]; | 1960 min_size = min_partition_size[min_size]; |
1953 max_size = max_partition_size[max_size]; | 1961 max_size = max_partition_size[max_size]; |
1954 } | 1962 } |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2459 cpi->pc_tree[i].vertical[0].pred_interp_filter = SWITCHABLE; | 2467 cpi->pc_tree[i].vertical[0].pred_interp_filter = SWITCHABLE; |
2460 cpi->pc_tree[i].vertical[1].pred_interp_filter = SWITCHABLE; | 2468 cpi->pc_tree[i].vertical[1].pred_interp_filter = SWITCHABLE; |
2461 cpi->pc_tree[i].horizontal[0].pred_interp_filter = SWITCHABLE; | 2469 cpi->pc_tree[i].horizontal[0].pred_interp_filter = SWITCHABLE; |
2462 cpi->pc_tree[i].horizontal[1].pred_interp_filter = SWITCHABLE; | 2470 cpi->pc_tree[i].horizontal[1].pred_interp_filter = SWITCHABLE; |
2463 } | 2471 } |
2464 } | 2472 } |
2465 | 2473 |
2466 vp9_zero(cpi->mb.pred_mv); | 2474 vp9_zero(cpi->mb.pred_mv); |
2467 cpi->pc_root->index = 0; | 2475 cpi->pc_root->index = 0; |
2468 | 2476 |
| 2477 // TODO(yunqingwang): use_lastframe_partitioning is no longer used in good- |
| 2478 // quality encoding. Need to evaluate it in real-time encoding later to |
| 2479 // decide if it can be removed too. And then, do the code cleanup. |
2469 if ((sf->partition_search_type == SEARCH_PARTITION && | 2480 if ((sf->partition_search_type == SEARCH_PARTITION && |
2470 sf->use_lastframe_partitioning) || | 2481 sf->use_lastframe_partitioning) || |
2471 sf->partition_search_type == FIXED_PARTITION || | 2482 sf->partition_search_type == FIXED_PARTITION || |
2472 sf->partition_search_type == VAR_BASED_PARTITION || | 2483 sf->partition_search_type == VAR_BASED_PARTITION || |
2473 sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { | 2484 sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { |
2474 const int idx_str = cm->mi_stride * mi_row + mi_col; | 2485 const int idx_str = cm->mi_stride * mi_row + mi_col; |
2475 MODE_INFO **mi = cm->mi_grid_visible + idx_str; | 2486 MODE_INFO *mi = cm->mi + idx_str; |
2476 MODE_INFO **prev_mi = cm->prev_mi_grid_visible + idx_str; | 2487 MODE_INFO *prev_mi = (cm->prev_mip + cm->mi_stride + 1 + idx_str)->src_mi; |
2477 cpi->mb.source_variance = UINT_MAX; | 2488 cpi->mb.source_variance = UINT_MAX; |
2478 if (sf->partition_search_type == FIXED_PARTITION) { | 2489 if (sf->partition_search_type == FIXED_PARTITION) { |
2479 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); | 2490 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); |
2480 set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, | 2491 set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, |
2481 sf->always_this_block_size); | 2492 sf->always_this_block_size); |
2482 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, | 2493 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, |
2483 &dummy_rate, &dummy_dist, 1, cpi->pc_root); | 2494 &dummy_rate, &dummy_dist, 1, cpi->pc_root); |
2484 } else if (cpi->skippable_frame || | 2495 } else if (cpi->skippable_frame || |
2485 sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { | 2496 sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { |
2486 BLOCK_SIZE bsize; | 2497 BLOCK_SIZE bsize; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2572 return 0; | 2583 return 0; |
2573 } else { | 2584 } else { |
2574 return (!!(ref_flags & VP9_GOLD_FLAG) + !!(ref_flags & VP9_LAST_FLAG) | 2585 return (!!(ref_flags & VP9_GOLD_FLAG) + !!(ref_flags & VP9_LAST_FLAG) |
2575 + !!(ref_flags & VP9_ALT_FLAG)) >= 2; | 2586 + !!(ref_flags & VP9_ALT_FLAG)) >= 2; |
2576 } | 2587 } |
2577 } | 2588 } |
2578 | 2589 |
2579 static void reset_skip_tx_size(VP9_COMMON *cm, TX_SIZE max_tx_size) { | 2590 static void reset_skip_tx_size(VP9_COMMON *cm, TX_SIZE max_tx_size) { |
2580 int mi_row, mi_col; | 2591 int mi_row, mi_col; |
2581 const int mis = cm->mi_stride; | 2592 const int mis = cm->mi_stride; |
2582 MODE_INFO **mi_ptr = cm->mi_grid_visible; | 2593 MODE_INFO *mi_ptr = cm->mi; |
2583 | 2594 |
2584 for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row, mi_ptr += mis) { | 2595 for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row, mi_ptr += mis) { |
2585 for (mi_col = 0; mi_col < cm->mi_cols; ++mi_col) { | 2596 for (mi_col = 0; mi_col < cm->mi_cols; ++mi_col) { |
2586 if (mi_ptr[mi_col]->mbmi.tx_size > max_tx_size) | 2597 if (mi_ptr[mi_col].src_mi->mbmi.tx_size > max_tx_size) |
2587 mi_ptr[mi_col]->mbmi.tx_size = max_tx_size; | 2598 mi_ptr[mi_col].src_mi->mbmi.tx_size = max_tx_size; |
2588 } | 2599 } |
2589 } | 2600 } |
2590 } | 2601 } |
2591 | 2602 |
2592 static MV_REFERENCE_FRAME get_frame_type(const VP9_COMP *cpi) { | 2603 static MV_REFERENCE_FRAME get_frame_type(const VP9_COMP *cpi) { |
2593 if (frame_is_intra_only(&cpi->common)) | 2604 if (frame_is_intra_only(&cpi->common)) |
2594 return INTRA_FRAME; | 2605 return INTRA_FRAME; |
2595 else if (cpi->rc.is_src_frame_alt_ref && cpi->refresh_golden_frame) | 2606 else if (cpi->rc.is_src_frame_alt_ref && cpi->refresh_golden_frame) |
2596 return ALTREF_FRAME; | 2607 return ALTREF_FRAME; |
2597 else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) | 2608 else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) |
(...skipping 16 matching lines...) Expand all Loading... |
2614 | 2625 |
2615 static void nonrd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, | 2626 static void nonrd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, |
2616 int mi_row, int mi_col, | 2627 int mi_row, int mi_col, |
2617 int *rate, int64_t *dist, | 2628 int *rate, int64_t *dist, |
2618 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) { | 2629 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx) { |
2619 VP9_COMMON *const cm = &cpi->common; | 2630 VP9_COMMON *const cm = &cpi->common; |
2620 MACROBLOCK *const x = &cpi->mb; | 2631 MACROBLOCK *const x = &cpi->mb; |
2621 MACROBLOCKD *const xd = &x->e_mbd; | 2632 MACROBLOCKD *const xd = &x->e_mbd; |
2622 MB_MODE_INFO *mbmi; | 2633 MB_MODE_INFO *mbmi; |
2623 set_offsets(cpi, tile, mi_row, mi_col, bsize); | 2634 set_offsets(cpi, tile, mi_row, mi_col, bsize); |
2624 mbmi = &xd->mi[0]->mbmi; | 2635 mbmi = &xd->mi[0].src_mi->mbmi; |
2625 mbmi->sb_type = bsize; | 2636 mbmi->sb_type = bsize; |
2626 | 2637 |
2627 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) | 2638 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) |
2628 if (mbmi->segment_id && x->in_static_area) | 2639 if (mbmi->segment_id && x->in_static_area) |
2629 x->rdmult = vp9_cyclic_refresh_get_rdmult(cpi->cyclic_refresh); | 2640 x->rdmult = vp9_cyclic_refresh_get_rdmult(cpi->cyclic_refresh); |
2630 | 2641 |
2631 if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) | 2642 if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) |
2632 set_mode_info_seg_skip(x, cm->tx_mode, rate, dist, bsize); | 2643 set_mode_info_seg_skip(x, cm->tx_mode, rate, dist, bsize); |
2633 else | 2644 else |
2634 vp9_pick_inter_mode(cpi, x, tile, mi_row, mi_col, rate, dist, bsize, ctx); | 2645 vp9_pick_inter_mode(cpi, x, tile, mi_row, mi_col, rate, dist, bsize, ctx); |
(...skipping 10 matching lines...) Expand all Loading... |
2645 PARTITION_TYPE partition = pc_tree->partitioning; | 2656 PARTITION_TYPE partition = pc_tree->partitioning; |
2646 | 2657 |
2647 assert(bsize >= BLOCK_8X8); | 2658 assert(bsize >= BLOCK_8X8); |
2648 | 2659 |
2649 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 2660 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
2650 return; | 2661 return; |
2651 | 2662 |
2652 switch (partition) { | 2663 switch (partition) { |
2653 case PARTITION_NONE: | 2664 case PARTITION_NONE: |
2654 set_modeinfo_offsets(cm, xd, mi_row, mi_col); | 2665 set_modeinfo_offsets(cm, xd, mi_row, mi_col); |
2655 *(xd->mi[0]) = pc_tree->none.mic; | 2666 *(xd->mi[0].src_mi) = pc_tree->none.mic; |
2656 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); | 2667 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); |
2657 break; | 2668 break; |
2658 case PARTITION_VERT: | 2669 case PARTITION_VERT: |
2659 set_modeinfo_offsets(cm, xd, mi_row, mi_col); | 2670 set_modeinfo_offsets(cm, xd, mi_row, mi_col); |
2660 *(xd->mi[0]) = pc_tree->vertical[0].mic; | 2671 *(xd->mi[0].src_mi) = pc_tree->vertical[0].mic; |
2661 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); | 2672 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); |
2662 | 2673 |
2663 if (mi_col + hbs < cm->mi_cols) { | 2674 if (mi_col + hbs < cm->mi_cols) { |
2664 set_modeinfo_offsets(cm, xd, mi_row, mi_col + hbs); | 2675 set_modeinfo_offsets(cm, xd, mi_row, mi_col + hbs); |
2665 *(xd->mi[0]) = pc_tree->vertical[1].mic; | 2676 *(xd->mi[0].src_mi) = pc_tree->vertical[1].mic; |
2666 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col + hbs, bsize); | 2677 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col + hbs, bsize); |
2667 } | 2678 } |
2668 break; | 2679 break; |
2669 case PARTITION_HORZ: | 2680 case PARTITION_HORZ: |
2670 set_modeinfo_offsets(cm, xd, mi_row, mi_col); | 2681 set_modeinfo_offsets(cm, xd, mi_row, mi_col); |
2671 *(xd->mi[0]) = pc_tree->horizontal[0].mic; | 2682 *(xd->mi[0].src_mi) = pc_tree->horizontal[0].mic; |
2672 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); | 2683 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); |
2673 if (mi_row + hbs < cm->mi_rows) { | 2684 if (mi_row + hbs < cm->mi_rows) { |
2674 set_modeinfo_offsets(cm, xd, mi_row + hbs, mi_col); | 2685 set_modeinfo_offsets(cm, xd, mi_row + hbs, mi_col); |
2675 *(xd->mi[0]) = pc_tree->horizontal[1].mic; | 2686 *(xd->mi[0].src_mi) = pc_tree->horizontal[1].mic; |
2676 duplicate_mode_info_in_sb(cm, xd, mi_row + hbs, mi_col, bsize); | 2687 duplicate_mode_info_in_sb(cm, xd, mi_row + hbs, mi_col, bsize); |
2677 } | 2688 } |
2678 break; | 2689 break; |
2679 case PARTITION_SPLIT: { | 2690 case PARTITION_SPLIT: { |
2680 BLOCK_SIZE subsubsize = get_subsize(subsize, PARTITION_SPLIT); | 2691 BLOCK_SIZE subsubsize = get_subsize(subsize, PARTITION_SPLIT); |
2681 fill_mode_info_sb(cm, x, mi_row, mi_col, subsize, | 2692 fill_mode_info_sb(cm, x, mi_row, mi_col, subsize, |
2682 subsubsize, pc_tree->split[0]); | 2693 subsubsize, pc_tree->split[0]); |
2683 fill_mode_info_sb(cm, x, mi_row, mi_col + hbs, subsize, | 2694 fill_mode_info_sb(cm, x, mi_row, mi_col + hbs, subsize, |
2684 subsubsize, pc_tree->split[1]); | 2695 subsubsize, pc_tree->split[1]); |
2685 fill_mode_info_sb(cm, x, mi_row + hbs, mi_col, subsize, | 2696 fill_mode_info_sb(cm, x, mi_row + hbs, mi_col, subsize, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2744 } | 2755 } |
2745 if (sf->use_square_partition_only) { | 2756 if (sf->use_square_partition_only) { |
2746 partition_horz_allowed &= force_horz_split; | 2757 partition_horz_allowed &= force_horz_split; |
2747 partition_vert_allowed &= force_vert_split; | 2758 partition_vert_allowed &= force_vert_split; |
2748 } | 2759 } |
2749 | 2760 |
2750 // PARTITION_NONE | 2761 // PARTITION_NONE |
2751 if (partition_none_allowed) { | 2762 if (partition_none_allowed) { |
2752 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, | 2763 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, |
2753 &this_rate, &this_dist, bsize, ctx); | 2764 &this_rate, &this_dist, bsize, ctx); |
2754 ctx->mic.mbmi = xd->mi[0]->mbmi; | 2765 ctx->mic.mbmi = xd->mi[0].src_mi->mbmi; |
2755 ctx->skip_txfm[0] = x->skip_txfm[0]; | 2766 ctx->skip_txfm[0] = x->skip_txfm[0]; |
2756 ctx->skip = x->skip; | 2767 ctx->skip = x->skip; |
2757 | 2768 |
2758 if (this_rate != INT_MAX) { | 2769 if (this_rate != INT_MAX) { |
2759 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); | 2770 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); |
2760 this_rate += cpi->partition_cost[pl][PARTITION_NONE]; | 2771 this_rate += cpi->partition_cost[pl][PARTITION_NONE]; |
2761 sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist); | 2772 sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist); |
2762 if (sum_rd < best_rd) { | 2773 if (sum_rd < best_rd) { |
2763 int64_t stop_thresh = 4096; | 2774 int64_t stop_thresh = 4096; |
2764 int64_t stop_thresh_rd; | 2775 int64_t stop_thresh_rd; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2829 // PARTITION_HORZ | 2840 // PARTITION_HORZ |
2830 if (partition_horz_allowed && do_rect) { | 2841 if (partition_horz_allowed && do_rect) { |
2831 subsize = get_subsize(bsize, PARTITION_HORZ); | 2842 subsize = get_subsize(bsize, PARTITION_HORZ); |
2832 if (sf->adaptive_motion_search) | 2843 if (sf->adaptive_motion_search) |
2833 load_pred_mv(x, ctx); | 2844 load_pred_mv(x, ctx); |
2834 | 2845 |
2835 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, | 2846 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, |
2836 &this_rate, &this_dist, subsize, | 2847 &this_rate, &this_dist, subsize, |
2837 &pc_tree->horizontal[0]); | 2848 &pc_tree->horizontal[0]); |
2838 | 2849 |
2839 pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; | 2850 pc_tree->horizontal[0].mic.mbmi = xd->mi[0].src_mi->mbmi; |
2840 pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0]; | 2851 pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0]; |
2841 pc_tree->horizontal[0].skip = x->skip; | 2852 pc_tree->horizontal[0].skip = x->skip; |
2842 | 2853 |
2843 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); | 2854 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); |
2844 | 2855 |
2845 if (sum_rd < best_rd && mi_row + ms < cm->mi_rows) { | 2856 if (sum_rd < best_rd && mi_row + ms < cm->mi_rows) { |
2846 load_pred_mv(x, ctx); | 2857 load_pred_mv(x, ctx); |
2847 nonrd_pick_sb_modes(cpi, tile, mi_row + ms, mi_col, | 2858 nonrd_pick_sb_modes(cpi, tile, mi_row + ms, mi_col, |
2848 &this_rate, &this_dist, subsize, | 2859 &this_rate, &this_dist, subsize, |
2849 &pc_tree->horizontal[1]); | 2860 &pc_tree->horizontal[1]); |
2850 | 2861 |
2851 pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi; | 2862 pc_tree->horizontal[1].mic.mbmi = xd->mi[0].src_mi->mbmi; |
2852 pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0]; | 2863 pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0]; |
2853 pc_tree->horizontal[1].skip = x->skip; | 2864 pc_tree->horizontal[1].skip = x->skip; |
2854 | 2865 |
2855 if (this_rate == INT_MAX) { | 2866 if (this_rate == INT_MAX) { |
2856 sum_rd = INT64_MAX; | 2867 sum_rd = INT64_MAX; |
2857 } else { | 2868 } else { |
2858 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); | 2869 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); |
2859 this_rate += cpi->partition_cost[pl][PARTITION_HORZ]; | 2870 this_rate += cpi->partition_cost[pl][PARTITION_HORZ]; |
2860 sum_rate += this_rate; | 2871 sum_rate += this_rate; |
2861 sum_dist += this_dist; | 2872 sum_dist += this_dist; |
(...skipping 11 matching lines...) Expand all Loading... |
2873 // PARTITION_VERT | 2884 // PARTITION_VERT |
2874 if (partition_vert_allowed && do_rect) { | 2885 if (partition_vert_allowed && do_rect) { |
2875 subsize = get_subsize(bsize, PARTITION_VERT); | 2886 subsize = get_subsize(bsize, PARTITION_VERT); |
2876 | 2887 |
2877 if (sf->adaptive_motion_search) | 2888 if (sf->adaptive_motion_search) |
2878 load_pred_mv(x, ctx); | 2889 load_pred_mv(x, ctx); |
2879 | 2890 |
2880 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, | 2891 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, |
2881 &this_rate, &this_dist, subsize, | 2892 &this_rate, &this_dist, subsize, |
2882 &pc_tree->vertical[0]); | 2893 &pc_tree->vertical[0]); |
2883 pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; | 2894 pc_tree->vertical[0].mic.mbmi = xd->mi[0].src_mi->mbmi; |
2884 pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0]; | 2895 pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0]; |
2885 pc_tree->vertical[0].skip = x->skip; | 2896 pc_tree->vertical[0].skip = x->skip; |
2886 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); | 2897 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); |
2887 if (sum_rd < best_rd && mi_col + ms < cm->mi_cols) { | 2898 if (sum_rd < best_rd && mi_col + ms < cm->mi_cols) { |
2888 load_pred_mv(x, ctx); | 2899 load_pred_mv(x, ctx); |
2889 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + ms, | 2900 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + ms, |
2890 &this_rate, &this_dist, subsize, | 2901 &this_rate, &this_dist, subsize, |
2891 &pc_tree->vertical[1]); | 2902 &pc_tree->vertical[1]); |
2892 pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; | 2903 pc_tree->vertical[1].mic.mbmi = xd->mi[0].src_mi->mbmi; |
2893 pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0]; | 2904 pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0]; |
2894 pc_tree->vertical[1].skip = x->skip; | 2905 pc_tree->vertical[1].skip = x->skip; |
2895 if (this_rate == INT_MAX) { | 2906 if (this_rate == INT_MAX) { |
2896 sum_rd = INT64_MAX; | 2907 sum_rd = INT64_MAX; |
2897 } else { | 2908 } else { |
2898 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); | 2909 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); |
2899 this_rate += cpi->partition_cost[pl][PARTITION_VERT]; | 2910 this_rate += cpi->partition_cost[pl][PARTITION_VERT]; |
2900 sum_rate += this_rate; | 2911 sum_rate += this_rate; |
2901 sum_dist += this_dist; | 2912 sum_dist += this_dist; |
2902 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); | 2913 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2947 assert(tp_orig < *tp); | 2958 assert(tp_orig < *tp); |
2948 assert(best_rate < INT_MAX); | 2959 assert(best_rate < INT_MAX); |
2949 assert(best_dist < INT64_MAX); | 2960 assert(best_dist < INT64_MAX); |
2950 } else { | 2961 } else { |
2951 assert(tp_orig == *tp); | 2962 assert(tp_orig == *tp); |
2952 } | 2963 } |
2953 } | 2964 } |
2954 | 2965 |
2955 static void nonrd_use_partition(VP9_COMP *cpi, | 2966 static void nonrd_use_partition(VP9_COMP *cpi, |
2956 const TileInfo *const tile, | 2967 const TileInfo *const tile, |
2957 MODE_INFO **mi, | 2968 MODE_INFO *mi, |
2958 TOKENEXTRA **tp, | 2969 TOKENEXTRA **tp, |
2959 int mi_row, int mi_col, | 2970 int mi_row, int mi_col, |
2960 BLOCK_SIZE bsize, int output_enabled, | 2971 BLOCK_SIZE bsize, int output_enabled, |
2961 int *totrate, int64_t *totdist, | 2972 int *totrate, int64_t *totdist, |
2962 PC_TREE *pc_tree) { | 2973 PC_TREE *pc_tree) { |
2963 VP9_COMMON *const cm = &cpi->common; | 2974 VP9_COMMON *const cm = &cpi->common; |
2964 MACROBLOCK *const x = &cpi->mb; | 2975 MACROBLOCK *const x = &cpi->mb; |
2965 MACROBLOCKD *const xd = &x->e_mbd; | 2976 MACROBLOCKD *const xd = &x->e_mbd; |
2966 const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; | 2977 const int bsl = b_width_log2(bsize), hbs = (1 << bsl) / 4; |
2967 const int mis = cm->mi_stride; | 2978 const int mis = cm->mi_stride; |
2968 PARTITION_TYPE partition; | 2979 PARTITION_TYPE partition; |
2969 BLOCK_SIZE subsize; | 2980 BLOCK_SIZE subsize; |
2970 int rate = INT_MAX; | 2981 int rate = INT_MAX; |
2971 int64_t dist = INT64_MAX; | 2982 int64_t dist = INT64_MAX; |
2972 | 2983 |
2973 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) | 2984 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) |
2974 return; | 2985 return; |
2975 | 2986 |
2976 subsize = (bsize >= BLOCK_8X8) ? mi[0]->mbmi.sb_type : BLOCK_4X4; | 2987 subsize = (bsize >= BLOCK_8X8) ? mi[0].src_mi->mbmi.sb_type : BLOCK_4X4; |
2977 partition = partition_lookup[bsl][subsize]; | 2988 partition = partition_lookup[bsl][subsize]; |
2978 | 2989 |
2979 switch (partition) { | 2990 switch (partition) { |
2980 case PARTITION_NONE: | 2991 case PARTITION_NONE: |
2981 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, | 2992 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, |
2982 subsize, &pc_tree->none); | 2993 subsize, &pc_tree->none); |
2983 pc_tree->none.mic.mbmi = xd->mi[0]->mbmi; | 2994 pc_tree->none.mic.mbmi = xd->mi[0].src_mi->mbmi; |
2984 pc_tree->none.skip_txfm[0] = x->skip_txfm[0]; | 2995 pc_tree->none.skip_txfm[0] = x->skip_txfm[0]; |
2985 pc_tree->none.skip = x->skip; | 2996 pc_tree->none.skip = x->skip; |
2986 break; | 2997 break; |
2987 case PARTITION_VERT: | 2998 case PARTITION_VERT: |
2988 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, | 2999 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, |
2989 subsize, &pc_tree->vertical[0]); | 3000 subsize, &pc_tree->vertical[0]); |
2990 pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; | 3001 pc_tree->vertical[0].mic.mbmi = xd->mi[0].src_mi->mbmi; |
2991 pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0]; | 3002 pc_tree->vertical[0].skip_txfm[0] = x->skip_txfm[0]; |
2992 pc_tree->vertical[0].skip = x->skip; | 3003 pc_tree->vertical[0].skip = x->skip; |
2993 if (mi_col + hbs < cm->mi_cols) { | 3004 if (mi_col + hbs < cm->mi_cols) { |
2994 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + hbs, | 3005 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + hbs, |
2995 &rate, &dist, subsize, &pc_tree->vertical[1]); | 3006 &rate, &dist, subsize, &pc_tree->vertical[1]); |
2996 pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; | 3007 pc_tree->vertical[1].mic.mbmi = xd->mi[0].src_mi->mbmi; |
2997 pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0]; | 3008 pc_tree->vertical[1].skip_txfm[0] = x->skip_txfm[0]; |
2998 pc_tree->vertical[1].skip = x->skip; | 3009 pc_tree->vertical[1].skip = x->skip; |
2999 if (rate != INT_MAX && dist != INT64_MAX && | 3010 if (rate != INT_MAX && dist != INT64_MAX && |
3000 *totrate != INT_MAX && *totdist != INT64_MAX) { | 3011 *totrate != INT_MAX && *totdist != INT64_MAX) { |
3001 *totrate += rate; | 3012 *totrate += rate; |
3002 *totdist += dist; | 3013 *totdist += dist; |
3003 } | 3014 } |
3004 } | 3015 } |
3005 break; | 3016 break; |
3006 case PARTITION_HORZ: | 3017 case PARTITION_HORZ: |
3007 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, | 3018 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, |
3008 subsize, &pc_tree->horizontal[0]); | 3019 subsize, &pc_tree->horizontal[0]); |
3009 pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; | 3020 pc_tree->horizontal[0].mic.mbmi = xd->mi[0].src_mi->mbmi; |
3010 pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0]; | 3021 pc_tree->horizontal[0].skip_txfm[0] = x->skip_txfm[0]; |
3011 pc_tree->horizontal[0].skip = x->skip; | 3022 pc_tree->horizontal[0].skip = x->skip; |
3012 if (mi_row + hbs < cm->mi_rows) { | 3023 if (mi_row + hbs < cm->mi_rows) { |
3013 nonrd_pick_sb_modes(cpi, tile, mi_row + hbs, mi_col, | 3024 nonrd_pick_sb_modes(cpi, tile, mi_row + hbs, mi_col, |
3014 &rate, &dist, subsize, &pc_tree->horizontal[0]); | 3025 &rate, &dist, subsize, &pc_tree->horizontal[0]); |
3015 pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi; | 3026 pc_tree->horizontal[1].mic.mbmi = xd->mi[0].src_mi->mbmi; |
3016 pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0]; | 3027 pc_tree->horizontal[1].skip_txfm[0] = x->skip_txfm[0]; |
3017 pc_tree->horizontal[1].skip = x->skip; | 3028 pc_tree->horizontal[1].skip = x->skip; |
3018 if (rate != INT_MAX && dist != INT64_MAX && | 3029 if (rate != INT_MAX && dist != INT64_MAX && |
3019 *totrate != INT_MAX && *totdist != INT64_MAX) { | 3030 *totrate != INT_MAX && *totdist != INT64_MAX) { |
3020 *totrate += rate; | 3031 *totrate += rate; |
3021 *totdist += dist; | 3032 *totdist += dist; |
3022 } | 3033 } |
3023 } | 3034 } |
3024 break; | 3035 break; |
3025 case PARTITION_SPLIT: | 3036 case PARTITION_SPLIT: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3076 // Initialize the left context for the new SB row | 3087 // Initialize the left context for the new SB row |
3077 vpx_memset(&xd->left_context, 0, sizeof(xd->left_context)); | 3088 vpx_memset(&xd->left_context, 0, sizeof(xd->left_context)); |
3078 vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context)); | 3089 vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context)); |
3079 | 3090 |
3080 // Code each SB in the row | 3091 // Code each SB in the row |
3081 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; | 3092 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; |
3082 mi_col += MI_BLOCK_SIZE) { | 3093 mi_col += MI_BLOCK_SIZE) { |
3083 int dummy_rate = 0; | 3094 int dummy_rate = 0; |
3084 int64_t dummy_dist = 0; | 3095 int64_t dummy_dist = 0; |
3085 const int idx_str = cm->mi_stride * mi_row + mi_col; | 3096 const int idx_str = cm->mi_stride * mi_row + mi_col; |
3086 MODE_INFO **mi = cm->mi_grid_visible + idx_str; | 3097 MODE_INFO *mi = cm->mi + idx_str; |
3087 MODE_INFO **prev_mi = cm->prev_mi_grid_visible + idx_str; | 3098 MODE_INFO *prev_mi = (cm->prev_mip + cm->mi_stride + 1 + idx_str)->src_mi; |
3088 BLOCK_SIZE bsize; | 3099 BLOCK_SIZE bsize; |
3089 | |
3090 x->in_static_area = 0; | 3100 x->in_static_area = 0; |
3091 x->source_variance = UINT_MAX; | 3101 x->source_variance = UINT_MAX; |
3092 vp9_zero(x->pred_mv); | 3102 vp9_zero(x->pred_mv); |
3093 | 3103 |
3094 // Set the partition type of the 64X64 block | 3104 // Set the partition type of the 64X64 block |
3095 switch (sf->partition_search_type) { | 3105 switch (sf->partition_search_type) { |
3096 case VAR_BASED_PARTITION: | 3106 case VAR_BASED_PARTITION: |
3097 choose_partitioning(cpi, tile, mi_row, mi_col); | 3107 choose_partitioning(cpi, tile, mi_row, mi_col); |
3098 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, | 3108 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, |
3099 1, &dummy_rate, &dummy_dist, cpi->pc_root); | 3109 1, &dummy_rate, &dummy_dist, cpi->pc_root); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3280 } | 3290 } |
3281 #endif | 3291 #endif |
3282 | 3292 |
3283 static void encode_frame_internal(VP9_COMP *cpi) { | 3293 static void encode_frame_internal(VP9_COMP *cpi) { |
3284 SPEED_FEATURES *const sf = &cpi->sf; | 3294 SPEED_FEATURES *const sf = &cpi->sf; |
3285 RD_OPT *const rd_opt = &cpi->rd; | 3295 RD_OPT *const rd_opt = &cpi->rd; |
3286 MACROBLOCK *const x = &cpi->mb; | 3296 MACROBLOCK *const x = &cpi->mb; |
3287 VP9_COMMON *const cm = &cpi->common; | 3297 VP9_COMMON *const cm = &cpi->common; |
3288 MACROBLOCKD *const xd = &x->e_mbd; | 3298 MACROBLOCKD *const xd = &x->e_mbd; |
3289 | 3299 |
3290 xd->mi = cm->mi_grid_visible; | 3300 xd->mi = cm->mi; |
3291 xd->mi[0] = cm->mi; | 3301 xd->mi[0].src_mi = &xd->mi[0]; |
3292 | 3302 |
3293 vp9_zero(cm->counts); | 3303 vp9_zero(cm->counts); |
3294 vp9_zero(cpi->coef_counts); | 3304 vp9_zero(cpi->coef_counts); |
3295 vp9_zero(rd_opt->comp_pred_diff); | 3305 vp9_zero(rd_opt->comp_pred_diff); |
3296 vp9_zero(rd_opt->filter_diff); | 3306 vp9_zero(rd_opt->filter_diff); |
3297 vp9_zero(rd_opt->tx_select_diff); | 3307 vp9_zero(rd_opt->tx_select_diff); |
3298 vp9_zero(rd_opt->tx_select_threshes); | 3308 vp9_zero(rd_opt->tx_select_threshes); |
3299 | 3309 |
3300 xd->lossless = cm->base_qindex == 0 && | 3310 xd->lossless = cm->base_qindex == 0 && |
3301 cm->y_dc_delta_q == 0 && | 3311 cm->y_dc_delta_q == 0 && |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3551 return 0; | 3561 return 0; |
3552 } | 3562 } |
3553 } | 3563 } |
3554 | 3564 |
3555 static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, | 3565 static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, |
3556 int mi_row, int mi_col, BLOCK_SIZE bsize, | 3566 int mi_row, int mi_col, BLOCK_SIZE bsize, |
3557 PICK_MODE_CONTEXT *ctx) { | 3567 PICK_MODE_CONTEXT *ctx) { |
3558 VP9_COMMON *const cm = &cpi->common; | 3568 VP9_COMMON *const cm = &cpi->common; |
3559 MACROBLOCK *const x = &cpi->mb; | 3569 MACROBLOCK *const x = &cpi->mb; |
3560 MACROBLOCKD *const xd = &x->e_mbd; | 3570 MACROBLOCKD *const xd = &x->e_mbd; |
3561 MODE_INFO **mi_8x8 = xd->mi; | 3571 MODE_INFO *mi_8x8 = xd->mi; |
3562 MODE_INFO *mi = mi_8x8[0]; | 3572 MODE_INFO *mi = mi_8x8; |
3563 MB_MODE_INFO *mbmi = &mi->mbmi; | 3573 MB_MODE_INFO *mbmi = &mi->mbmi; |
3564 const int seg_skip = vp9_segfeature_active(&cm->seg, mbmi->segment_id, | 3574 const int seg_skip = vp9_segfeature_active(&cm->seg, mbmi->segment_id, |
3565 SEG_LVL_SKIP); | 3575 SEG_LVL_SKIP); |
3566 const int mis = cm->mi_stride; | 3576 const int mis = cm->mi_stride; |
3567 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; | 3577 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; |
3568 const int mi_height = num_8x8_blocks_high_lookup[bsize]; | 3578 const int mi_height = num_8x8_blocks_high_lookup[bsize]; |
3569 | 3579 |
3570 x->skip_recode = !x->select_tx_size && mbmi->sb_type >= BLOCK_8X8 && | 3580 x->skip_recode = !x->select_tx_size && mbmi->sb_type >= BLOCK_8X8 && |
3571 cpi->oxcf.aq_mode != COMPLEXITY_AQ && | 3581 cpi->oxcf.aq_mode != COMPLEXITY_AQ && |
3572 cpi->oxcf.aq_mode != CYCLIC_REFRESH_AQ && | 3582 cpi->oxcf.aq_mode != CYCLIC_REFRESH_AQ && |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3607 YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, | 3617 YV12_BUFFER_CONFIG *cfg = get_ref_frame_buffer(cpi, |
3608 mbmi->ref_frame[ref]); | 3618 mbmi->ref_frame[ref]); |
3609 vp9_setup_pre_planes(xd, ref, cfg, mi_row, mi_col, | 3619 vp9_setup_pre_planes(xd, ref, cfg, mi_row, mi_col, |
3610 &xd->block_refs[ref]->sf); | 3620 &xd->block_refs[ref]->sf); |
3611 } | 3621 } |
3612 if (!cpi->sf.reuse_inter_pred_sby || seg_skip) | 3622 if (!cpi->sf.reuse_inter_pred_sby || seg_skip) |
3613 vp9_build_inter_predictors_sby(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); | 3623 vp9_build_inter_predictors_sby(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); |
3614 | 3624 |
3615 vp9_build_inter_predictors_sbuv(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); | 3625 vp9_build_inter_predictors_sbuv(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); |
3616 | 3626 |
3617 if (!x->skip) { | 3627 vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); |
3618 mbmi->skip = 1; | 3628 vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); |
3619 vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); | |
3620 vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); | |
3621 } else { | |
3622 mbmi->skip = 1; | |
3623 if (output_enabled && !seg_skip) | |
3624 cm->counts.skip[vp9_get_skip_context(xd)][1]++; | |
3625 reset_skip_context(xd, MAX(bsize, BLOCK_8X8)); | |
3626 } | |
3627 } | 3629 } |
3628 | 3630 |
3629 if (output_enabled) { | 3631 if (output_enabled) { |
3630 if (cm->tx_mode == TX_MODE_SELECT && | 3632 if (cm->tx_mode == TX_MODE_SELECT && |
3631 mbmi->sb_type >= BLOCK_8X8 && | 3633 mbmi->sb_type >= BLOCK_8X8 && |
3632 !(is_inter_block(mbmi) && (mbmi->skip || seg_skip))) { | 3634 !(is_inter_block(mbmi) && (mbmi->skip || seg_skip))) { |
3633 ++get_tx_counts(max_txsize_lookup[bsize], vp9_get_tx_size_context(xd), | 3635 ++get_tx_counts(max_txsize_lookup[bsize], vp9_get_tx_size_context(xd), |
3634 &cm->counts.tx)[mbmi->tx_size]; | 3636 &cm->counts.tx)[mbmi->tx_size]; |
3635 } else { | 3637 } else { |
3636 int x, y; | 3638 int x, y; |
3637 TX_SIZE tx_size; | 3639 TX_SIZE tx_size; |
3638 // The new intra coding scheme requires no change of transform size | 3640 // The new intra coding scheme requires no change of transform size |
3639 if (is_inter_block(&mi->mbmi)) { | 3641 if (is_inter_block(&mi->mbmi)) { |
3640 tx_size = MIN(tx_mode_to_biggest_tx_size[cm->tx_mode], | 3642 tx_size = MIN(tx_mode_to_biggest_tx_size[cm->tx_mode], |
3641 max_txsize_lookup[bsize]); | 3643 max_txsize_lookup[bsize]); |
3642 } else { | 3644 } else { |
3643 tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4; | 3645 tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4; |
3644 } | 3646 } |
3645 | 3647 |
3646 for (y = 0; y < mi_height; y++) | 3648 for (y = 0; y < mi_height; y++) |
3647 for (x = 0; x < mi_width; x++) | 3649 for (x = 0; x < mi_width; x++) |
3648 if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) | 3650 if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) |
3649 mi_8x8[mis * y + x]->mbmi.tx_size = tx_size; | 3651 mi_8x8[mis * y + x].src_mi->mbmi.tx_size = tx_size; |
3650 } | 3652 } |
3651 } | 3653 } |
3652 } | 3654 } |
OLD | NEW |