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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 548 |
549 static int vp8_rdcost_mby(MACROBLOCK *mb) | 549 static int vp8_rdcost_mby(MACROBLOCK *mb) |
550 { | 550 { |
551 int cost = 0; | 551 int cost = 0; |
552 int b; | 552 int b; |
553 MACROBLOCKD *x = &mb->e_mbd; | 553 MACROBLOCKD *x = &mb->e_mbd; |
554 ENTROPY_CONTEXT_PLANES t_above, t_left; | 554 ENTROPY_CONTEXT_PLANES t_above, t_left; |
555 ENTROPY_CONTEXT *ta; | 555 ENTROPY_CONTEXT *ta; |
556 ENTROPY_CONTEXT *tl; | 556 ENTROPY_CONTEXT *tl; |
557 | 557 |
558 vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)
); | 558 memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)); |
559 vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); | 559 memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); |
560 | 560 |
561 ta = (ENTROPY_CONTEXT *)&t_above; | 561 ta = (ENTROPY_CONTEXT *)&t_above; |
562 tl = (ENTROPY_CONTEXT *)&t_left; | 562 tl = (ENTROPY_CONTEXT *)&t_left; |
563 | 563 |
564 for (b = 0; b < 16; b++) | 564 for (b = 0; b < 16; b++) |
565 cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_Y_NO_DC, | 565 cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_Y_NO_DC, |
566 ta + vp8_block2above[b], tl + vp8_block2left[b]); | 566 ta + vp8_block2above[b], tl + vp8_block2left[b]); |
567 | 567 |
568 cost += cost_coeffs(mb, x->block + 24, PLANE_TYPE_Y2, | 568 cost += cost_coeffs(mb, x->block + 24, PLANE_TYPE_Y2, |
569 ta + vp8_block2above[24], tl + vp8_block2left[24]); | 569 ta + vp8_block2above[24], tl + vp8_block2left[24]); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 int rate = 0; | 643 int rate = 0; |
644 int distortion; | 644 int distortion; |
645 | 645 |
646 ENTROPY_CONTEXT ta = *a, tempa = *a; | 646 ENTROPY_CONTEXT ta = *a, tempa = *a; |
647 ENTROPY_CONTEXT tl = *l, templ = *l; | 647 ENTROPY_CONTEXT tl = *l, templ = *l; |
648 /* | 648 /* |
649 * The predictor buffer is a 2d buffer with a stride of 16. Create | 649 * The predictor buffer is a 2d buffer with a stride of 16. Create |
650 * a temp buffer that meets the stride requirements, but we are only | 650 * a temp buffer that meets the stride requirements, but we are only |
651 * interested in the left 4x4 block | 651 * interested in the left 4x4 block |
652 * */ | 652 * */ |
653 DECLARE_ALIGNED_ARRAY(16, unsigned char, best_predictor, 16*4); | 653 DECLARE_ALIGNED(16, unsigned char, best_predictor[16*4]); |
654 DECLARE_ALIGNED_ARRAY(16, short, best_dqcoeff, 16); | 654 DECLARE_ALIGNED(16, short, best_dqcoeff[16]); |
655 int dst_stride = x->e_mbd.dst.y_stride; | 655 int dst_stride = x->e_mbd.dst.y_stride; |
656 unsigned char *dst = x->e_mbd.dst.y_buffer + b->offset; | 656 unsigned char *dst = x->e_mbd.dst.y_buffer + b->offset; |
657 | 657 |
658 unsigned char *Above = dst - dst_stride; | 658 unsigned char *Above = dst - dst_stride; |
659 unsigned char *yleft = dst - 1; | 659 unsigned char *yleft = dst - 1; |
660 unsigned char top_left = Above[-1]; | 660 unsigned char top_left = Above[-1]; |
661 | 661 |
662 for (mode = B_DC_PRED; mode <= B_HU_PRED; mode++) | 662 for (mode = B_DC_PRED; mode <= B_HU_PRED; mode++) |
663 { | 663 { |
664 int this_rd; | 664 int this_rd; |
(...skipping 19 matching lines...) Expand all Loading... |
684 if (this_rd < best_rd) | 684 if (this_rd < best_rd) |
685 { | 685 { |
686 *bestrate = rate; | 686 *bestrate = rate; |
687 *bestratey = ratey; | 687 *bestratey = ratey; |
688 *bestdistortion = distortion; | 688 *bestdistortion = distortion; |
689 best_rd = this_rd; | 689 best_rd = this_rd; |
690 *best_mode = mode; | 690 *best_mode = mode; |
691 *a = tempa; | 691 *a = tempa; |
692 *l = templ; | 692 *l = templ; |
693 copy_predictor(best_predictor, b->predictor); | 693 copy_predictor(best_predictor, b->predictor); |
694 vpx_memcpy(best_dqcoeff, b->dqcoeff, 32); | 694 memcpy(best_dqcoeff, b->dqcoeff, 32); |
695 } | 695 } |
696 } | 696 } |
697 b->bmi.as_mode = *best_mode; | 697 b->bmi.as_mode = *best_mode; |
698 | 698 |
699 vp8_short_idct4x4llm(best_dqcoeff, best_predictor, 16, dst, dst_stride); | 699 vp8_short_idct4x4llm(best_dqcoeff, best_predictor, 16, dst, dst_stride); |
700 | 700 |
701 return best_rd; | 701 return best_rd; |
702 } | 702 } |
703 | 703 |
704 static int rd_pick_intra4x4mby_modes(MACROBLOCK *mb, int *Rate, | 704 static int rd_pick_intra4x4mby_modes(MACROBLOCK *mb, int *Rate, |
705 int *rate_y, int *Distortion, int best_rd) | 705 int *rate_y, int *Distortion, int best_rd) |
706 { | 706 { |
707 MACROBLOCKD *const xd = &mb->e_mbd; | 707 MACROBLOCKD *const xd = &mb->e_mbd; |
708 int i; | 708 int i; |
709 int cost = mb->mbmode_cost [xd->frame_type] [B_PRED]; | 709 int cost = mb->mbmode_cost [xd->frame_type] [B_PRED]; |
710 int distortion = 0; | 710 int distortion = 0; |
711 int tot_rate_y = 0; | 711 int tot_rate_y = 0; |
712 int64_t total_rd = 0; | 712 int64_t total_rd = 0; |
713 ENTROPY_CONTEXT_PLANES t_above, t_left; | 713 ENTROPY_CONTEXT_PLANES t_above, t_left; |
714 ENTROPY_CONTEXT *ta; | 714 ENTROPY_CONTEXT *ta; |
715 ENTROPY_CONTEXT *tl; | 715 ENTROPY_CONTEXT *tl; |
716 const int *bmode_costs; | 716 const int *bmode_costs; |
717 | 717 |
718 vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)
); | 718 memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)); |
719 vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); | 719 memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); |
720 | 720 |
721 ta = (ENTROPY_CONTEXT *)&t_above; | 721 ta = (ENTROPY_CONTEXT *)&t_above; |
722 tl = (ENTROPY_CONTEXT *)&t_left; | 722 tl = (ENTROPY_CONTEXT *)&t_left; |
723 | 723 |
724 intra_prediction_down_copy(xd, xd->dst.y_buffer - xd->dst.y_stride + 16); | 724 intra_prediction_down_copy(xd, xd->dst.y_buffer - xd->dst.y_stride + 16); |
725 | 725 |
726 bmode_costs = mb->inter_bmode_costs; | 726 bmode_costs = mb->inter_bmode_costs; |
727 | 727 |
728 for (i = 0; i < 16; i++) | 728 for (i = 0; i < 16; i++) |
729 { | 729 { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 | 813 |
814 static int rd_cost_mbuv(MACROBLOCK *mb) | 814 static int rd_cost_mbuv(MACROBLOCK *mb) |
815 { | 815 { |
816 int b; | 816 int b; |
817 int cost = 0; | 817 int cost = 0; |
818 MACROBLOCKD *x = &mb->e_mbd; | 818 MACROBLOCKD *x = &mb->e_mbd; |
819 ENTROPY_CONTEXT_PLANES t_above, t_left; | 819 ENTROPY_CONTEXT_PLANES t_above, t_left; |
820 ENTROPY_CONTEXT *ta; | 820 ENTROPY_CONTEXT *ta; |
821 ENTROPY_CONTEXT *tl; | 821 ENTROPY_CONTEXT *tl; |
822 | 822 |
823 vpx_memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)
); | 823 memcpy(&t_above, mb->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)); |
824 vpx_memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); | 824 memcpy(&t_left, mb->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); |
825 | 825 |
826 ta = (ENTROPY_CONTEXT *)&t_above; | 826 ta = (ENTROPY_CONTEXT *)&t_above; |
827 tl = (ENTROPY_CONTEXT *)&t_left; | 827 tl = (ENTROPY_CONTEXT *)&t_left; |
828 | 828 |
829 for (b = 16; b < 24; b++) | 829 for (b = 16; b < 24; b++) |
830 cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_UV, | 830 cost += cost_coeffs(mb, x->block + b, PLANE_TYPE_UV, |
831 ta + vp8_block2above[b], tl + vp8_block2left[b]); | 831 ta + vp8_block2above[b], tl + vp8_block2left[b]); |
832 | 832 |
833 return cost; | 833 return cost; |
834 } | 834 } |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 | 1121 |
1122 vp8_variance_fn_ptr_t *v_fn_ptr; | 1122 vp8_variance_fn_ptr_t *v_fn_ptr; |
1123 | 1123 |
1124 ENTROPY_CONTEXT_PLANES t_above, t_left; | 1124 ENTROPY_CONTEXT_PLANES t_above, t_left; |
1125 ENTROPY_CONTEXT *ta; | 1125 ENTROPY_CONTEXT *ta; |
1126 ENTROPY_CONTEXT *tl; | 1126 ENTROPY_CONTEXT *tl; |
1127 ENTROPY_CONTEXT_PLANES t_above_b, t_left_b; | 1127 ENTROPY_CONTEXT_PLANES t_above_b, t_left_b; |
1128 ENTROPY_CONTEXT *ta_b; | 1128 ENTROPY_CONTEXT *ta_b; |
1129 ENTROPY_CONTEXT *tl_b; | 1129 ENTROPY_CONTEXT *tl_b; |
1130 | 1130 |
1131 vpx_memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES))
; | 1131 memcpy(&t_above, x->e_mbd.above_context, sizeof(ENTROPY_CONTEXT_PLANES)); |
1132 vpx_memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); | 1132 memcpy(&t_left, x->e_mbd.left_context, sizeof(ENTROPY_CONTEXT_PLANES)); |
1133 | 1133 |
1134 ta = (ENTROPY_CONTEXT *)&t_above; | 1134 ta = (ENTROPY_CONTEXT *)&t_above; |
1135 tl = (ENTROPY_CONTEXT *)&t_left; | 1135 tl = (ENTROPY_CONTEXT *)&t_left; |
1136 ta_b = (ENTROPY_CONTEXT *)&t_above_b; | 1136 ta_b = (ENTROPY_CONTEXT *)&t_above_b; |
1137 tl_b = (ENTROPY_CONTEXT *)&t_left_b; | 1137 tl_b = (ENTROPY_CONTEXT *)&t_left_b; |
1138 | 1138 |
1139 br = 0; | 1139 br = 0; |
1140 bd = 0; | 1140 bd = 0; |
1141 | 1141 |
1142 v_fn_ptr = &cpi->fn_ptr[segmentation]; | 1142 v_fn_ptr = &cpi->fn_ptr[segmentation]; |
(...skipping 22 matching lines...) Expand all Loading... |
1165 /* search for the best motion vector on this segment */ | 1165 /* search for the best motion vector on this segment */ |
1166 for (this_mode = LEFT4X4; this_mode <= NEW4X4 ; this_mode ++) | 1166 for (this_mode = LEFT4X4; this_mode <= NEW4X4 ; this_mode ++) |
1167 { | 1167 { |
1168 int this_rd; | 1168 int this_rd; |
1169 int distortion; | 1169 int distortion; |
1170 int labelyrate; | 1170 int labelyrate; |
1171 ENTROPY_CONTEXT_PLANES t_above_s, t_left_s; | 1171 ENTROPY_CONTEXT_PLANES t_above_s, t_left_s; |
1172 ENTROPY_CONTEXT *ta_s; | 1172 ENTROPY_CONTEXT *ta_s; |
1173 ENTROPY_CONTEXT *tl_s; | 1173 ENTROPY_CONTEXT *tl_s; |
1174 | 1174 |
1175 vpx_memcpy(&t_above_s, &t_above, sizeof(ENTROPY_CONTEXT_PLANES)); | 1175 memcpy(&t_above_s, &t_above, sizeof(ENTROPY_CONTEXT_PLANES)); |
1176 vpx_memcpy(&t_left_s, &t_left, sizeof(ENTROPY_CONTEXT_PLANES)); | 1176 memcpy(&t_left_s, &t_left, sizeof(ENTROPY_CONTEXT_PLANES)); |
1177 | 1177 |
1178 ta_s = (ENTROPY_CONTEXT *)&t_above_s; | 1178 ta_s = (ENTROPY_CONTEXT *)&t_above_s; |
1179 tl_s = (ENTROPY_CONTEXT *)&t_left_s; | 1179 tl_s = (ENTROPY_CONTEXT *)&t_left_s; |
1180 | 1180 |
1181 if (this_mode == NEW4X4) | 1181 if (this_mode == NEW4X4) |
1182 { | 1182 { |
1183 int sseshift; | 1183 int sseshift; |
1184 int num00; | 1184 int num00; |
1185 int step_param = 0; | 1185 int step_param = 0; |
1186 int further_steps; | 1186 int further_steps; |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion); | 1322 this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion); |
1323 | 1323 |
1324 if (this_rd < best_label_rd) | 1324 if (this_rd < best_label_rd) |
1325 { | 1325 { |
1326 sbr = rate; | 1326 sbr = rate; |
1327 sbd = distortion; | 1327 sbd = distortion; |
1328 bestlabelyrate = labelyrate; | 1328 bestlabelyrate = labelyrate; |
1329 mode_selected = this_mode; | 1329 mode_selected = this_mode; |
1330 best_label_rd = this_rd; | 1330 best_label_rd = this_rd; |
1331 | 1331 |
1332 vpx_memcpy(ta_b, ta_s, sizeof(ENTROPY_CONTEXT_PLANES)); | 1332 memcpy(ta_b, ta_s, sizeof(ENTROPY_CONTEXT_PLANES)); |
1333 vpx_memcpy(tl_b, tl_s, sizeof(ENTROPY_CONTEXT_PLANES)); | 1333 memcpy(tl_b, tl_s, sizeof(ENTROPY_CONTEXT_PLANES)); |
1334 | 1334 |
1335 } | 1335 } |
1336 } /*for each 4x4 mode*/ | 1336 } /*for each 4x4 mode*/ |
1337 | 1337 |
1338 vpx_memcpy(ta, ta_b, sizeof(ENTROPY_CONTEXT_PLANES)); | 1338 memcpy(ta, ta_b, sizeof(ENTROPY_CONTEXT_PLANES)); |
1339 vpx_memcpy(tl, tl_b, sizeof(ENTROPY_CONTEXT_PLANES)); | 1339 memcpy(tl, tl_b, sizeof(ENTROPY_CONTEXT_PLANES)); |
1340 | 1340 |
1341 labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected], | 1341 labels2mode(x, labels, i, mode_selected, &mode_mv[mode_selected], |
1342 bsi->ref_mv, x->mvcost); | 1342 bsi->ref_mv, x->mvcost); |
1343 | 1343 |
1344 br += sbr; | 1344 br += sbr; |
1345 bd += sbd; | 1345 bd += sbd; |
1346 segmentyrate += bestlabelyrate; | 1346 segmentyrate += bestlabelyrate; |
1347 this_segment_rd += best_label_rd; | 1347 this_segment_rd += best_label_rd; |
1348 | 1348 |
1349 if (this_segment_rd >= bsi->segment_rd) | 1349 if (this_segment_rd >= bsi->segment_rd) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 | 1385 |
1386 static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x, | 1386 static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x, |
1387 int_mv *best_ref_mv, int best_rd, | 1387 int_mv *best_ref_mv, int best_rd, |
1388 int *mdcounts, int *returntotrate, | 1388 int *mdcounts, int *returntotrate, |
1389 int *returnyrate, int *returndistorti
on, | 1389 int *returnyrate, int *returndistorti
on, |
1390 int mvthresh) | 1390 int mvthresh) |
1391 { | 1391 { |
1392 int i; | 1392 int i; |
1393 BEST_SEG_INFO bsi; | 1393 BEST_SEG_INFO bsi; |
1394 | 1394 |
1395 vpx_memset(&bsi, 0, sizeof(bsi)); | 1395 memset(&bsi, 0, sizeof(bsi)); |
1396 | 1396 |
1397 bsi.segment_rd = best_rd; | 1397 bsi.segment_rd = best_rd; |
1398 bsi.ref_mv = best_ref_mv; | 1398 bsi.ref_mv = best_ref_mv; |
1399 bsi.mvp.as_int = best_ref_mv->as_int; | 1399 bsi.mvp.as_int = best_ref_mv->as_int; |
1400 bsi.mvthresh = mvthresh; | 1400 bsi.mvthresh = mvthresh; |
1401 bsi.mdcounts = mdcounts; | 1401 bsi.mdcounts = mdcounts; |
1402 | 1402 |
1403 for(i = 0; i < 16; i++) | 1403 for(i = 0; i < 16; i++) |
1404 { | 1404 { |
1405 bsi.modes[i] = ZERO4X4; | 1405 bsi.modes[i] = ZERO4X4; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 { | 1654 { |
1655 mvx[i] = near_mvs[i].as_mv.row; | 1655 mvx[i] = near_mvs[i].as_mv.row; |
1656 mvy[i] = near_mvs[i].as_mv.col; | 1656 mvy[i] = near_mvs[i].as_mv.col; |
1657 } | 1657 } |
1658 | 1658 |
1659 insertsortmv(mvx, vcnt); | 1659 insertsortmv(mvx, vcnt); |
1660 insertsortmv(mvy, vcnt); | 1660 insertsortmv(mvy, vcnt); |
1661 mv.as_mv.row = mvx[vcnt/2]; | 1661 mv.as_mv.row = mvx[vcnt/2]; |
1662 mv.as_mv.col = mvy[vcnt/2]; | 1662 mv.as_mv.col = mvy[vcnt/2]; |
1663 | 1663 |
1664 find = 1; | |
1665 /* sr is set to 0 to allow calling function to decide the search | 1664 /* sr is set to 0 to allow calling function to decide the search |
1666 * range. | 1665 * range. |
1667 */ | 1666 */ |
1668 *sr = 0; | 1667 *sr = 0; |
1669 } | 1668 } |
1670 } | 1669 } |
1671 | 1670 |
1672 /* Set up return values */ | 1671 /* Set up return values */ |
1673 mvp->as_int = mv.as_int; | 1672 mvp->as_int = mv.as_int; |
1674 vp8_clamp_mv2(mvp, xd); | 1673 vp8_clamp_mv2(mvp, xd); |
1675 } | 1674 } |
1676 | 1675 |
1677 void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffse
t, int near_sadidx[]) | 1676 void vp8_cal_sad(VP8_COMP *cpi, MACROBLOCKD *xd, MACROBLOCK *x, int recon_yoffse
t, int near_sadidx[]) |
1678 { | 1677 { |
1679 /* near_sad indexes: | 1678 /* near_sad indexes: |
1680 * 0-cf above, 1-cf left, 2-cf aboveleft, | 1679 * 0-cf above, 1-cf left, 2-cf aboveleft, |
1681 * 3-lf current, 4-lf above, 5-lf left, 6-lf right, 7-lf below | 1680 * 3-lf current, 4-lf above, 5-lf left, 6-lf right, 7-lf below |
1682 */ | 1681 */ |
1683 int near_sad[8] = {0}; | 1682 int near_sad[8] = {0}; |
1684 BLOCK *b = &x->block[0]; | 1683 BLOCK *b = &x->block[0]; |
1685 unsigned char *src_y_ptr = *(b->base_src); | 1684 unsigned char *src_y_ptr = *(b->base_src); |
1686 | 1685 |
1687 /* calculate sad for current frame 3 nearby MBs. */ | 1686 /* calculate sad for current frame 3 nearby MBs. */ |
1688 if( xd->mb_to_top_edge==0 && xd->mb_to_left_edge ==0) | 1687 if( xd->mb_to_top_edge==0 && xd->mb_to_left_edge ==0) |
1689 { | 1688 { |
1690 near_sad[0] = near_sad[1] = near_sad[2] = INT_MAX; | 1689 near_sad[0] = near_sad[1] = near_sad[2] = INT_MAX; |
1691 }else if(xd->mb_to_top_edge==0) | 1690 }else if(xd->mb_to_top_edge==0) |
1692 { /* only has left MB for sad calculation. */ | 1691 { /* only has left MB for sad calculation. */ |
1693 near_sad[0] = near_sad[2] = INT_MAX; | 1692 near_sad[0] = near_sad[2] = INT_MAX; |
1694 near_sad[1] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - 16,xd->dst.y_stride, UINT_MAX); | 1693 near_sad[1] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - 16,xd->dst.y_stride); |
1695 }else if(xd->mb_to_left_edge ==0) | 1694 }else if(xd->mb_to_left_edge ==0) |
1696 { /* only has left MB for sad calculation. */ | 1695 { /* only has left MB for sad calculation. */ |
1697 near_sad[1] = near_sad[2] = INT_MAX; | 1696 near_sad[1] = near_sad[2] = INT_MAX; |
1698 near_sad[0] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - xd->dst.y_stride *16,xd->dst.y_stride, UINT_MAX); | 1697 near_sad[0] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - xd->dst.y_stride *16,xd->dst.y_stride); |
1699 }else | 1698 }else |
1700 { | 1699 { |
1701 near_sad[0] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - xd->dst.y_stride *16,xd->dst.y_stride, UINT_MAX); | 1700 near_sad[0] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - xd->dst.y_stride *16,xd->dst.y_stride); |
1702 near_sad[1] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - 16,xd->dst.y_stride, UINT_MAX); | 1701 near_sad[1] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - 16,xd->dst.y_stride); |
1703 near_sad[2] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - xd->dst.y_stride *16 -16,xd->dst.y_stride, UINT_MAX); | 1702 near_sad[2] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, xd-
>dst.y_buffer - xd->dst.y_stride *16 -16,xd->dst.y_stride); |
1704 } | 1703 } |
1705 | 1704 |
1706 if(cpi->common.last_frame_type != KEY_FRAME) | 1705 if(cpi->common.last_frame_type != KEY_FRAME) |
1707 { | 1706 { |
1708 /* calculate sad for last frame 5 nearby MBs. */ | 1707 /* calculate sad for last frame 5 nearby MBs. */ |
1709 unsigned char *pre_y_buffer = cpi->common.yv12_fb[cpi->common.lst_fb_idx
].y_buffer + recon_yoffset; | 1708 unsigned char *pre_y_buffer = cpi->common.yv12_fb[cpi->common.lst_fb_idx
].y_buffer + recon_yoffset; |
1710 int pre_y_stride = cpi->common.yv12_fb[cpi->common.lst_fb_idx].y_stride; | 1709 int pre_y_stride = cpi->common.yv12_fb[cpi->common.lst_fb_idx].y_stride; |
1711 | 1710 |
1712 if(xd->mb_to_top_edge==0) near_sad[4] = INT_MAX; | 1711 if(xd->mb_to_top_edge==0) near_sad[4] = INT_MAX; |
1713 if(xd->mb_to_left_edge ==0) near_sad[5] = INT_MAX; | 1712 if(xd->mb_to_left_edge ==0) near_sad[5] = INT_MAX; |
1714 if(xd->mb_to_right_edge ==0) near_sad[6] = INT_MAX; | 1713 if(xd->mb_to_right_edge ==0) near_sad[6] = INT_MAX; |
1715 if(xd->mb_to_bottom_edge==0) near_sad[7] = INT_MAX; | 1714 if(xd->mb_to_bottom_edge==0) near_sad[7] = INT_MAX; |
1716 | 1715 |
1717 if(near_sad[4] != INT_MAX) | 1716 if(near_sad[4] != INT_MAX) |
1718 near_sad[4] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer - pre_y_stride *16, pre_y_stride, UINT_MAX); | 1717 near_sad[4] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer - pre_y_stride *16, pre_y_stride); |
1719 if(near_sad[5] != INT_MAX) | 1718 if(near_sad[5] != INT_MAX) |
1720 near_sad[5] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer - 16, pre_y_stride, UINT_MAX); | 1719 near_sad[5] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer - 16, pre_y_stride); |
1721 near_sad[3] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre
_y_buffer, pre_y_stride, UINT_MAX); | 1720 near_sad[3] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride, pre
_y_buffer, pre_y_stride); |
1722 if(near_sad[6] != INT_MAX) | 1721 if(near_sad[6] != INT_MAX) |
1723 near_sad[6] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer + 16, pre_y_stride, UINT_MAX); | 1722 near_sad[6] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer + 16, pre_y_stride); |
1724 if(near_sad[7] != INT_MAX) | 1723 if(near_sad[7] != INT_MAX) |
1725 near_sad[7] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer + pre_y_stride *16, pre_y_stride, UINT_MAX); | 1724 near_sad[7] = cpi->fn_ptr[BLOCK_16X16].sdf(src_y_ptr, b->src_stride,
pre_y_buffer + pre_y_stride *16, pre_y_stride); |
1726 } | 1725 } |
1727 | 1726 |
1728 if(cpi->common.last_frame_type != KEY_FRAME) | 1727 if(cpi->common.last_frame_type != KEY_FRAME) |
1729 { | 1728 { |
1730 insertsortsad(near_sad, near_sadidx, 8); | 1729 insertsortsad(near_sad, near_sadidx, 8); |
1731 }else | 1730 }else |
1732 { | 1731 { |
1733 insertsortsad(near_sad, near_sadidx, 3); | 1732 insertsortsad(near_sad, near_sadidx, 3); |
1734 } | 1733 } |
1735 } | 1734 } |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 MB_PREDICTION_MODE this_mode = x->e_mbd.mode_info_context->mbmi.mode; | 1918 MB_PREDICTION_MODE this_mode = x->e_mbd.mode_info_context->mbmi.mode; |
1920 | 1919 |
1921 other_cost += | 1920 other_cost += |
1922 x->ref_frame_cost[x->e_mbd.mode_info_context->mbmi.ref_frame]; | 1921 x->ref_frame_cost[x->e_mbd.mode_info_context->mbmi.ref_frame]; |
1923 | 1922 |
1924 /* Calculate the final y RD estimate for this mode */ | 1923 /* Calculate the final y RD estimate for this mode */ |
1925 best_mode->yrd = RDCOST(x->rdmult, x->rddiv, (rd->rate2-rd->rate_uv-other_co
st), | 1924 best_mode->yrd = RDCOST(x->rdmult, x->rddiv, (rd->rate2-rd->rate_uv-other_co
st), |
1926 (rd->distortion2-rd->distortion_uv)); | 1925 (rd->distortion2-rd->distortion_uv)); |
1927 | 1926 |
1928 best_mode->rd = this_rd; | 1927 best_mode->rd = this_rd; |
1929 vpx_memcpy(&best_mode->mbmode, &x->e_mbd.mode_info_context->mbmi, sizeof(MB_
MODE_INFO)); | 1928 memcpy(&best_mode->mbmode, &x->e_mbd.mode_info_context->mbmi, sizeof(MB_MODE
_INFO)); |
1930 vpx_memcpy(&best_mode->partition, x->partition_info, sizeof(PARTITION_INFO))
; | 1929 memcpy(&best_mode->partition, x->partition_info, sizeof(PARTITION_INFO)); |
1931 | 1930 |
1932 if ((this_mode == B_PRED) || (this_mode == SPLITMV)) | 1931 if ((this_mode == B_PRED) || (this_mode == SPLITMV)) |
1933 { | 1932 { |
1934 int i; | 1933 int i; |
1935 for (i = 0; i < 16; i++) | 1934 for (i = 0; i < 16; i++) |
1936 { | 1935 { |
1937 best_mode->bmodes[i] = x->e_mbd.block[i].bmi; | 1936 best_mode->bmodes[i] = x->e_mbd.block[i].bmi; |
1938 } | 1937 } |
1939 } | 1938 } |
1940 } | 1939 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 #if CONFIG_TEMPORAL_DENOISING | 1981 #if CONFIG_TEMPORAL_DENOISING |
1983 unsigned int zero_mv_sse = UINT_MAX, best_sse = UINT_MAX, | 1982 unsigned int zero_mv_sse = UINT_MAX, best_sse = UINT_MAX, |
1984 best_rd_sse = UINT_MAX; | 1983 best_rd_sse = UINT_MAX; |
1985 #endif | 1984 #endif |
1986 | 1985 |
1987 mode_mv = mode_mv_sb[sign_bias]; | 1986 mode_mv = mode_mv_sb[sign_bias]; |
1988 best_ref_mv.as_int = 0; | 1987 best_ref_mv.as_int = 0; |
1989 best_mode.rd = INT_MAX; | 1988 best_mode.rd = INT_MAX; |
1990 best_mode.yrd = INT_MAX; | 1989 best_mode.yrd = INT_MAX; |
1991 best_mode.intra_rd = INT_MAX; | 1990 best_mode.intra_rd = INT_MAX; |
1992 vpx_memset(mode_mv_sb, 0, sizeof(mode_mv_sb)); | 1991 memset(mode_mv_sb, 0, sizeof(mode_mv_sb)); |
1993 vpx_memset(&best_mode.mbmode, 0, sizeof(best_mode.mbmode)); | 1992 memset(&best_mode.mbmode, 0, sizeof(best_mode.mbmode)); |
1994 vpx_memset(&best_mode.bmodes, 0, sizeof(best_mode.bmodes)); | 1993 memset(&best_mode.bmodes, 0, sizeof(best_mode.bmodes)); |
1995 | 1994 |
1996 /* Setup search priorities */ | 1995 /* Setup search priorities */ |
1997 get_reference_search_order(cpi, ref_frame_map); | 1996 get_reference_search_order(cpi, ref_frame_map); |
1998 | 1997 |
1999 /* Check to see if there is at least 1 valid reference frame that we need | 1998 /* Check to see if there is at least 1 valid reference frame that we need |
2000 * to calculate near_mvs. | 1999 * to calculate near_mvs. |
2001 */ | 2000 */ |
2002 if (ref_frame_map[1] > 0) | 2001 if (ref_frame_map[1] > 0) |
2003 { | 2002 { |
2004 sign_bias = vp8_find_near_mvs_bias(&x->e_mbd, | 2003 sign_bias = vp8_find_near_mvs_bias(&x->e_mbd, |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 | 2285 |
2287 /* Initial step/diamond search */ | 2286 /* Initial step/diamond search */ |
2288 { | 2287 { |
2289 bestsme = cpi->diamond_search_sad(x, b, d, &mvp_full, &d->bmi.mv
, | 2288 bestsme = cpi->diamond_search_sad(x, b, d, &mvp_full, &d->bmi.mv
, |
2290 step_param, sadpb, &num00, | 2289 step_param, sadpb, &num00, |
2291 &cpi->fn_ptr[BLOCK_16X16], | 2290 &cpi->fn_ptr[BLOCK_16X16], |
2292 x->mvcost, &best_ref_mv); | 2291 x->mvcost, &best_ref_mv); |
2293 mode_mv[NEWMV].as_int = d->bmi.mv.as_int; | 2292 mode_mv[NEWMV].as_int = d->bmi.mv.as_int; |
2294 | 2293 |
2295 /* Further step/diamond searches as necessary */ | 2294 /* Further step/diamond searches as necessary */ |
2296 n = 0; | |
2297 further_steps = (cpi->sf.max_step_search_steps - 1) - step_param
; | 2295 further_steps = (cpi->sf.max_step_search_steps - 1) - step_param
; |
2298 | 2296 |
2299 n = num00; | 2297 n = num00; |
2300 num00 = 0; | 2298 num00 = 0; |
2301 | 2299 |
2302 /* If there won't be more n-step search, check to see if refinin
g search is needed. */ | 2300 /* If there won't be more n-step search, check to see if refinin
g search is needed. */ |
2303 if (n > further_steps) | 2301 if (n > further_steps) |
2304 do_refine = 0; | 2302 do_refine = 0; |
2305 | 2303 |
2306 while (n < further_steps) | 2304 while (n < further_steps) |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2553 x->e_mbd.mode_info_context->mbmi.mode = ZEROMV; | 2551 x->e_mbd.mode_info_context->mbmi.mode = ZEROMV; |
2554 x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED; | 2552 x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED; |
2555 x->e_mbd.mode_info_context->mbmi.mv.as_int = 0; | 2553 x->e_mbd.mode_info_context->mbmi.mv.as_int = 0; |
2556 | 2554 |
2557 this_rd = evaluate_inter_mode_rd(mdcounts, &rd, &disable_skip, cpi,
x); | 2555 this_rd = evaluate_inter_mode_rd(mdcounts, &rd, &disable_skip, cpi,
x); |
2558 this_rd = calculate_final_rd_costs(this_rd, &rd, &other_cost, | 2556 this_rd = calculate_final_rd_costs(this_rd, &rd, &other_cost, |
2559 disable_skip, uv_intra_tteob, | 2557 disable_skip, uv_intra_tteob, |
2560 intra_rd_penalty, cpi, x); | 2558 intra_rd_penalty, cpi, x); |
2561 if (this_rd < best_mode.rd || x->skip) | 2559 if (this_rd < best_mode.rd || x->skip) |
2562 { | 2560 { |
2563 /* Note index of best mode so far */ | |
2564 best_mode_index = mode_index; | |
2565 *returnrate = rd.rate2; | 2561 *returnrate = rd.rate2; |
2566 *returndistortion = rd.distortion2; | 2562 *returndistortion = rd.distortion2; |
2567 update_best_mode(&best_mode, this_rd, &rd, other_cost, x); | 2563 update_best_mode(&best_mode, this_rd, &rd, other_cost, x); |
2568 } | 2564 } |
2569 } | 2565 } |
2570 | 2566 |
2571 } | 2567 } |
2572 #endif | 2568 #endif |
2573 | 2569 |
2574 if (cpi->is_src_frame_alt_ref && | 2570 if (cpi->is_src_frame_alt_ref && |
2575 (best_mode.mbmode.mode != ZEROMV || best_mode.mbmode.ref_frame != ALTREF
_FRAME)) | 2571 (best_mode.mbmode.mode != ZEROMV || best_mode.mbmode.ref_frame != ALTREF
_FRAME)) |
2576 { | 2572 { |
2577 x->e_mbd.mode_info_context->mbmi.mode = ZEROMV; | 2573 x->e_mbd.mode_info_context->mbmi.mode = ZEROMV; |
2578 x->e_mbd.mode_info_context->mbmi.ref_frame = ALTREF_FRAME; | 2574 x->e_mbd.mode_info_context->mbmi.ref_frame = ALTREF_FRAME; |
2579 x->e_mbd.mode_info_context->mbmi.mv.as_int = 0; | 2575 x->e_mbd.mode_info_context->mbmi.mv.as_int = 0; |
2580 x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED; | 2576 x->e_mbd.mode_info_context->mbmi.uv_mode = DC_PRED; |
2581 x->e_mbd.mode_info_context->mbmi.mb_skip_coeff = | 2577 x->e_mbd.mode_info_context->mbmi.mb_skip_coeff = |
2582 (cpi->common.mb_no_coeff_skip); | 2578 (cpi->common.mb_no_coeff_skip); |
2583 x->e_mbd.mode_info_context->mbmi.partitioning = 0; | 2579 x->e_mbd.mode_info_context->mbmi.partitioning = 0; |
2584 return; | 2580 return; |
2585 } | 2581 } |
2586 | 2582 |
2587 | 2583 |
2588 /* macroblock modes */ | 2584 /* macroblock modes */ |
2589 vpx_memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mode.mbmode, sizeof(MB_M
ODE_INFO)); | 2585 memcpy(&x->e_mbd.mode_info_context->mbmi, &best_mode.mbmode, sizeof(MB_MODE_
INFO)); |
2590 | 2586 |
2591 if (best_mode.mbmode.mode == B_PRED) | 2587 if (best_mode.mbmode.mode == B_PRED) |
2592 { | 2588 { |
2593 for (i = 0; i < 16; i++) | 2589 for (i = 0; i < 16; i++) |
2594 xd->mode_info_context->bmi[i].as_mode = best_mode.bmodes[i].as_mode; | 2590 xd->mode_info_context->bmi[i].as_mode = best_mode.bmodes[i].as_mode; |
2595 } | 2591 } |
2596 | 2592 |
2597 if (best_mode.mbmode.mode == SPLITMV) | 2593 if (best_mode.mbmode.mode == SPLITMV) |
2598 { | 2594 { |
2599 for (i = 0; i < 16; i++) | 2595 for (i = 0; i < 16; i++) |
2600 xd->mode_info_context->bmi[i].mv.as_int = best_mode.bmodes[i].mv.as_
int; | 2596 xd->mode_info_context->bmi[i].mv.as_int = best_mode.bmodes[i].mv.as_
int; |
2601 | 2597 |
2602 vpx_memcpy(x->partition_info, &best_mode.partition, sizeof(PARTITION_INF
O)); | 2598 memcpy(x->partition_info, &best_mode.partition, sizeof(PARTITION_INFO)); |
2603 | 2599 |
2604 x->e_mbd.mode_info_context->mbmi.mv.as_int = | 2600 x->e_mbd.mode_info_context->mbmi.mv.as_int = |
2605 x->partition_info->bmi[15].mv.as_int; | 2601 x->partition_info->bmi[15].mv.as_int; |
2606 } | 2602 } |
2607 | 2603 |
2608 if (sign_bias | 2604 if (sign_bias |
2609 != cpi->common.ref_frame_sign_bias[xd->mode_info_context->mbmi.ref_frame
]) | 2605 != cpi->common.ref_frame_sign_bias[xd->mode_info_context->mbmi.ref_frame
]) |
2610 best_ref_mv.as_int = best_ref_mv_sb[!sign_bias].as_int; | 2606 best_ref_mv.as_int = best_ref_mv_sb[!sign_bias].as_int; |
2611 | 2607 |
2612 rd_update_mvcount(x, &best_ref_mv); | 2608 rd_update_mvcount(x, &best_ref_mv); |
(...skipping 25 matching lines...) Expand all Loading... |
2638 x->e_mbd.mode_info_context->mbmi.mode = B_PRED; | 2634 x->e_mbd.mode_info_context->mbmi.mode = B_PRED; |
2639 rate += rate4x4; | 2635 rate += rate4x4; |
2640 } | 2636 } |
2641 else | 2637 else |
2642 { | 2638 { |
2643 rate += rate16x16; | 2639 rate += rate16x16; |
2644 } | 2640 } |
2645 | 2641 |
2646 *rate_ = rate; | 2642 *rate_ = rate; |
2647 } | 2643 } |
OLD | NEW |