| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 */ | 155 */ |
| 156 | 156 |
| 157 /* estimated cost of a motion vector (r,c) */ | 157 /* estimated cost of a motion vector (r,c) */ |
| 158 #define MVC(r, c) \ | 158 #define MVC(r, c) \ |
| 159 (mvcost ? \ | 159 (mvcost ? \ |
| 160 ((mvjcost[((r) != rr) * 2 + ((c) != rc)] + \ | 160 ((mvjcost[((r) != rr) * 2 + ((c) != rc)] + \ |
| 161 mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \ | 161 mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \ |
| 162 error_per_bit + 4096) >> 13 : 0) | 162 error_per_bit + 4096) >> 13 : 0) |
| 163 | 163 |
| 164 | 164 |
| 165 // convert motion vector component to offset for svf calc | 165 // convert motion vector component to offset for sv[a]f calc |
| 166 static INLINE int sp(int x) { | 166 static INLINE int sp(int x) { |
| 167 return (x & 7) << 1; | 167 return x & 7; |
| 168 } | 168 } |
| 169 | 169 |
| 170 static INLINE const uint8_t *pre(const uint8_t *buf, int stride, int r, int c) { | 170 static INLINE const uint8_t *pre(const uint8_t *buf, int stride, int r, int c) { |
| 171 return &buf[(r >> 3) * stride + (c >> 3)]; | 171 return &buf[(r >> 3) * stride + (c >> 3)]; |
| 172 } | 172 } |
| 173 | 173 |
| 174 /* checks if (r, c) has better score than previous best */ | 174 /* checks if (r, c) has better score than previous best */ |
| 175 #define CHECK_BETTER(v, r, c) \ | 175 #define CHECK_BETTER(v, r, c) \ |
| 176 if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ | 176 if (c >= minc && c <= maxc && r >= minr && r <= maxr) { \ |
| 177 if (second_pred == NULL) \ | 177 if (second_pred == NULL) \ |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 672 |
| 673 (void) cost_list; // to silence compiler warning | 673 (void) cost_list; // to silence compiler warning |
| 674 | 674 |
| 675 for (iter = 0; iter < round; ++iter) { | 675 for (iter = 0; iter < round; ++iter) { |
| 676 // Check vertical and horizontal sub-pixel positions. | 676 // Check vertical and horizontal sub-pixel positions. |
| 677 for (idx = 0; idx < 4; ++idx) { | 677 for (idx = 0; idx < 4; ++idx) { |
| 678 tr = br + search_step[idx].row; | 678 tr = br + search_step[idx].row; |
| 679 tc = bc + search_step[idx].col; | 679 tc = bc + search_step[idx].col; |
| 680 if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { | 680 if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { |
| 681 const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3); | 681 const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3); |
| 682 int row_offset = (tr & 0x07) << 1; | |
| 683 int col_offset = (tc & 0x07) << 1; | |
| 684 MV this_mv; | 682 MV this_mv; |
| 685 this_mv.row = tr; | 683 this_mv.row = tr; |
| 686 this_mv.col = tc; | 684 this_mv.col = tc; |
| 687 if (second_pred == NULL) | 685 if (second_pred == NULL) |
| 688 thismse = vfp->svf(pre_address, y_stride, col_offset, row_offset, | 686 thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr), |
| 689 src_address, src_stride, &sse); | 687 src_address, src_stride, &sse); |
| 690 else | 688 else |
| 691 thismse = vfp->svaf(pre_address, y_stride, col_offset, row_offset, | 689 thismse = vfp->svaf(pre_address, y_stride, sp(tc), sp(tr), |
| 692 src_address, src_stride, &sse, second_pred); | 690 src_address, src_stride, &sse, second_pred); |
| 693 cost_array[idx] = thismse + | 691 cost_array[idx] = thismse + |
| 694 mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); | 692 mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); |
| 695 | 693 |
| 696 if (cost_array[idx] < besterr) { | 694 if (cost_array[idx] < besterr) { |
| 697 best_idx = idx; | 695 best_idx = idx; |
| 698 besterr = cost_array[idx]; | 696 besterr = cost_array[idx]; |
| 699 *distortion = thismse; | 697 *distortion = thismse; |
| 700 *sse1 = sse; | 698 *sse1 = sse; |
| 701 } | 699 } |
| 702 } else { | 700 } else { |
| 703 cost_array[idx] = INT_MAX; | 701 cost_array[idx] = INT_MAX; |
| 704 } | 702 } |
| 705 } | 703 } |
| 706 | 704 |
| 707 // Check diagonal sub-pixel position | 705 // Check diagonal sub-pixel position |
| 708 tc = bc + (cost_array[0] < cost_array[1] ? -hstep : hstep); | 706 tc = bc + (cost_array[0] < cost_array[1] ? -hstep : hstep); |
| 709 tr = br + (cost_array[2] < cost_array[3] ? -hstep : hstep); | 707 tr = br + (cost_array[2] < cost_array[3] ? -hstep : hstep); |
| 710 if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { | 708 if (tc >= minc && tc <= maxc && tr >= minr && tr <= maxr) { |
| 711 const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3); | 709 const uint8_t *const pre_address = y + (tr >> 3) * y_stride + (tc >> 3); |
| 712 int row_offset = (tr & 0x07) << 1; | |
| 713 int col_offset = (tc & 0x07) << 1; | |
| 714 MV this_mv = {tr, tc}; | 710 MV this_mv = {tr, tc}; |
| 715 if (second_pred == NULL) | 711 if (second_pred == NULL) |
| 716 thismse = vfp->svf(pre_address, y_stride, col_offset, row_offset, | 712 thismse = vfp->svf(pre_address, y_stride, sp(tc), sp(tr), |
| 717 src_address, src_stride, &sse); | 713 src_address, src_stride, &sse); |
| 718 else | 714 else |
| 719 thismse = vfp->svaf(pre_address, y_stride, col_offset, row_offset, | 715 thismse = vfp->svaf(pre_address, y_stride, sp(tc), sp(tr), |
| 720 src_address, src_stride, &sse, second_pred); | 716 src_address, src_stride, &sse, second_pred); |
| 721 cost_array[4] = thismse + | 717 cost_array[4] = thismse + |
| 722 mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); | 718 mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); |
| 723 | 719 |
| 724 if (cost_array[4] < besterr) { | 720 if (cost_array[4] < besterr) { |
| 725 best_idx = 4; | 721 best_idx = 4; |
| 726 besterr = cost_array[4]; | 722 besterr = cost_array[4]; |
| 727 *distortion = thismse; | 723 *distortion = thismse; |
| 728 *sse1 = sse; | 724 *sse1 = sse; |
| 729 } | 725 } |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2352 break; | 2348 break; |
| 2353 default: | 2349 default: |
| 2354 assert(0 && "Invalid search method."); | 2350 assert(0 && "Invalid search method."); |
| 2355 } | 2351 } |
| 2356 | 2352 |
| 2357 if (method != NSTEP && rd && var < var_max) | 2353 if (method != NSTEP && rd && var < var_max) |
| 2358 var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1); | 2354 var = vp9_get_mvpred_var(x, tmp_mv, ref_mv, fn_ptr, 1); |
| 2359 | 2355 |
| 2360 return var; | 2356 return var; |
| 2361 } | 2357 } |
| OLD | NEW |