Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_mcomp.c

Issue 181493009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.h ('k') | source/libvpx/vp9/encoder/vp9_onyx_if.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 {-512, 512}, {-512, 0}}, 848 {-512, 512}, {-512, 0}},
849 {{-1024, -1024}, {0, -1024}, {1024, -1024}, {1024, 0}, {1024, 1024}, 849 {{-1024, -1024}, {0, -1024}, {1024, -1024}, {1024, 0}, {1024, 1024},
850 {0, 1024}, {-1024, 1024}, {-1024, 0}}, 850 {0, 1024}, {-1024, 1024}, {-1024, 0}},
851 }; 851 };
852 return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit, 852 return vp9_pattern_search(x, ref_mv, search_param, sad_per_bit,
853 do_init_search, 0, vfp, use_mvcost, 853 do_init_search, 0, vfp, use_mvcost,
854 center_mv, best_mv, 854 center_mv, best_mv,
855 square_num_candidates, square_candidates); 855 square_num_candidates, square_candidates);
856 }; 856 };
857 857
858 // Number of candidates in first hex search
859 #define FIRST_HEX_CANDIDATES 6
860 // Index of previous hex search's best match
861 #define PRE_BEST_CANDIDATE 6
862 // Number of candidates in following hex search
863 #define NEXT_HEX_CANDIDATES 3
864 // Number of candidates in refining search
865 #define REFINE_CANDIDATES 4
866
867 int vp9_fast_hex_search(const MACROBLOCK *x,
868 MV *ref_mv,
869 int search_param,
870 int sad_per_bit,
871 const vp9_variance_fn_ptr_t *vfp,
872 int use_mvcost,
873 const MV *center_mv,
874 MV *best_mv) {
875 const MACROBLOCKD* const xd = &x->e_mbd;
876 static const MV hex[FIRST_HEX_CANDIDATES] = {
877 { -1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0}
878 };
879 static const MV next_chkpts[PRE_BEST_CANDIDATE][NEXT_HEX_CANDIDATES] = {
880 {{ -2, 0}, { -1, -2}, {1, -2}},
881 {{ -1, -2}, {1, -2}, {2, 0}},
882 {{1, -2}, {2, 0}, {1, 2}},
883 {{2, 0}, {1, 2}, { -1, 2}},
884 {{1, 2}, { -1, 2}, { -2, 0}},
885 {{ -1, 2}, { -2, 0}, { -1, -2}}
886 };
887 static const MV neighbors[REFINE_CANDIDATES] = {
888 {0, -1}, { -1, 0}, {1, 0}, {0, 1}
889 };
890 int i, j;
891
892 const uint8_t *what = x->plane[0].src.buf;
893 const int what_stride = x->plane[0].src.stride;
894 const int in_what_stride = xd->plane[0].pre[0].stride;
895 int br, bc;
896 MV this_mv;
897 unsigned int bestsad = 0x7fffffff;
898 unsigned int thissad;
899 const uint8_t *base_offset;
900 const uint8_t *this_offset;
901 int k = -1;
902 int best_site = -1;
903 const int max_hex_search = 512;
904 const int max_dia_search = 32;
905
906 const int *mvjsadcost = x->nmvjointsadcost;
907 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
908
909 const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
910
911 // Adjust ref_mv to make sure it is within MV range
912 clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
913 br = ref_mv->row;
914 bc = ref_mv->col;
915
916 // Check the start point
917 base_offset = xd->plane[0].pre[0].buf;
918 this_offset = base_offset + (br * in_what_stride) + bc;
919 this_mv.row = br;
920 this_mv.col = bc;
921 bestsad = vfp->sdf(what, what_stride, this_offset, in_what_stride, 0x7fffffff)
922 + mvsad_err_cost(&this_mv, &fcenter_mv, mvjsadcost, mvsadcost,
923 sad_per_bit);
924
925 // Initial 6-point hex search
926 if (check_bounds(x, br, bc, 2)) {
927 for (i = 0; i < FIRST_HEX_CANDIDATES; i++) {
928 this_mv.row = br + hex[i].row;
929 this_mv.col = bc + hex[i].col;
930 this_offset = base_offset + (this_mv.row * in_what_stride) + this_mv.col;
931 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
932 bestsad);
933 CHECK_BETTER
934 }
935 } else {
936 for (i = 0; i < FIRST_HEX_CANDIDATES; i++) {
937 this_mv.row = br + hex[i].row;
938 this_mv.col = bc + hex[i].col;
939 if (!is_mv_in(x, &this_mv))
940 continue;
941 this_offset = base_offset + (this_mv.row * in_what_stride) + this_mv.col;
942 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
943 bestsad);
944 CHECK_BETTER
945 }
946 }
947
948 // Continue hex search if we find a better match in first round
949 if (best_site != -1) {
950 br += hex[best_site].row;
951 bc += hex[best_site].col;
952 k = best_site;
953
954 // Allow search covering maximum MV range
955 for (j = 1; j < max_hex_search; j++) {
956 best_site = -1;
957
958 if (check_bounds(x, br, bc, 2)) {
959 for (i = 0; i < 3; i++) {
960 this_mv.row = br + next_chkpts[k][i].row;
961 this_mv.col = bc + next_chkpts[k][i].col;
962 this_offset = base_offset + (this_mv.row * in_what_stride) +
963 this_mv.col;
964 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
965 bestsad);
966 CHECK_BETTER
967 }
968 } else {
969 for (i = 0; i < 3; i++) {
970 this_mv.row = br + next_chkpts[k][i].row;
971 this_mv.col = bc + next_chkpts[k][i].col;
972 if (!is_mv_in(x, &this_mv))
973 continue;
974 this_offset = base_offset + (this_mv.row * in_what_stride) +
975 this_mv.col;
976 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
977 bestsad);
978 CHECK_BETTER
979 }
980 }
981
982 if (best_site == -1) {
983 break;
984 } else {
985 br += next_chkpts[k][best_site].row;
986 bc += next_chkpts[k][best_site].col;
987 k += 5 + best_site;
988 if (k >= 12) k -= 12;
989 else if (k >= 6) k -= 6;
990 }
991 }
992 }
993
994 // Check 4 1-away neighbors
995 for (j = 0; j < max_dia_search; j++) {
996 best_site = -1;
997
998 if (check_bounds(x, br, bc, 1)) {
999 for (i = 0; i < REFINE_CANDIDATES; i++) {
1000 this_mv.row = br + neighbors[i].row;
1001 this_mv.col = bc + neighbors[i].col;
1002 this_offset = base_offset + (this_mv.row * in_what_stride) +
1003 this_mv.col;
1004 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
1005 bestsad);
1006 CHECK_BETTER
1007 }
1008 } else {
1009 for (i = 0; i < REFINE_CANDIDATES; i++) {
1010 this_mv.row = br + neighbors[i].row;
1011 this_mv.col = bc + neighbors[i].col;
1012 if (!is_mv_in(x, &this_mv))
1013 continue;
1014 this_offset = base_offset + (this_mv.row * in_what_stride) +
1015 this_mv.col;
1016 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride,
1017 bestsad);
1018 CHECK_BETTER
1019 }
1020 }
1021
1022 if (best_site == -1) {
1023 break;
1024 } else {
1025 br += neighbors[best_site].row;
1026 bc += neighbors[best_site].col;
1027 }
1028 }
1029
1030 best_mv->row = br;
1031 best_mv->col = bc;
1032
1033 return bestsad;
1034 }
1035
858 #undef CHECK_BETTER 1036 #undef CHECK_BETTER
859 1037
860 int vp9_full_range_search_c(const MACROBLOCK *x, MV *ref_mv, MV *best_mv, 1038 int vp9_full_range_search_c(const MACROBLOCK *x, MV *ref_mv, MV *best_mv,
861 int search_param, int sad_per_bit, int *num00, 1039 int search_param, int sad_per_bit, int *num00,
862 const vp9_variance_fn_ptr_t *fn_ptr, 1040 const vp9_variance_fn_ptr_t *fn_ptr,
863 int *mvjcost, int *mvcost[2], 1041 int *mvjcost, int *mvcost[2],
864 const MV *center_mv) { 1042 const MV *center_mv) {
865 const MACROBLOCKD *const xd = &x->e_mbd; 1043 const MACROBLOCKD *const xd = &x->e_mbd;
866 const uint8_t *what = x->plane[0].src.buf; 1044 const uint8_t *what = x->plane[0].src.buf;
867 const int what_stride = x->plane[0].src.stride; 1045 const int what_stride = x->plane[0].src.stride;
868 const uint8_t *in_what; 1046 const uint8_t *in_what;
869 const int in_what_stride = xd->plane[0].pre[0].stride; 1047 const int in_what_stride = xd->plane[0].pre[0].stride;
870 const uint8_t *best_address; 1048 const uint8_t *best_address;
871 1049
872 MV this_mv; 1050 MV this_mv;
873 1051
874 int bestsad = INT_MAX; 1052 unsigned int bestsad = INT_MAX;
875 int ref_row, ref_col; 1053 int ref_row, ref_col;
876 1054
877 int thissad; 1055 unsigned int thissad;
878 const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; 1056 const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
879 1057
880 const int *mvjsadcost = x->nmvjointsadcost; 1058 const int *mvjsadcost = x->nmvjointsadcost;
881 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; 1059 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
882 1060
883 int tr, tc; 1061 int tr, tc;
884 int best_tr = 0; 1062 int best_tr = 0;
885 int best_tc = 0; 1063 int best_tc = 0;
886 int range = 64; 1064 int range = 64;
887 1065
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 } 1518 }
1341 } 1519 }
1342 1520
1343 return bestsme; 1521 return bestsme;
1344 } 1522 }
1345 1523
1346 int vp9_full_search_sad_c(const MACROBLOCK *x, const MV *ref_mv, 1524 int vp9_full_search_sad_c(const MACROBLOCK *x, const MV *ref_mv,
1347 int sad_per_bit, int distance, 1525 int sad_per_bit, int distance,
1348 const vp9_variance_fn_ptr_t *fn_ptr, 1526 const vp9_variance_fn_ptr_t *fn_ptr,
1349 int *mvjcost, int *mvcost[2], 1527 int *mvjcost, int *mvcost[2],
1350 const MV *center_mv, int block) { 1528 const MV *center_mv, MV *best_mv) {
1351 int r, c; 1529 int r, c;
1352 const MACROBLOCKD *const xd = &x->e_mbd; 1530 const MACROBLOCKD *const xd = &x->e_mbd;
1353 const uint8_t *const what = x->plane[0].src.buf; 1531 const uint8_t *const what = x->plane[0].src.buf;
1354 const int what_stride = x->plane[0].src.stride; 1532 const int what_stride = x->plane[0].src.stride;
1355 const uint8_t *const in_what = xd->plane[0].pre[0].buf; 1533 const uint8_t *const in_what = xd->plane[0].pre[0].buf;
1356 const int in_what_stride = xd->plane[0].pre[0].stride; 1534 const int in_what_stride = xd->plane[0].pre[0].stride;
1357 const int row_min = MAX(ref_mv->row - distance, x->mv_row_min); 1535 const int row_min = MAX(ref_mv->row - distance, x->mv_row_min);
1358 const int row_max = MIN(ref_mv->row + distance, x->mv_row_max); 1536 const int row_max = MIN(ref_mv->row + distance, x->mv_row_max);
1359 const int col_min = MAX(ref_mv->col - distance, x->mv_col_min); 1537 const int col_min = MAX(ref_mv->col - distance, x->mv_col_min);
1360 const int col_max = MIN(ref_mv->col + distance, x->mv_col_max); 1538 const int col_max = MIN(ref_mv->col + distance, x->mv_col_max);
1361 const int *mvjsadcost = x->nmvjointsadcost; 1539 const int *mvjsadcost = x->nmvjointsadcost;
1362 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; 1540 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
1363 const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; 1541 const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
1364 const uint8_t *best_address = &in_what[ref_mv->row * in_what_stride + 1542 const uint8_t *best_address = &in_what[ref_mv->row * in_what_stride +
1365 ref_mv->col]; 1543 ref_mv->col];
1366 int best_sad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride, 1544 int best_sad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride,
1367 0x7fffffff) + 1545 0x7fffffff) +
1368 mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, sad_per_bit); 1546 mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, sad_per_bit);
1369 MV *best_mv = &xd->mi_8x8[0]->bmi[block].as_mv[0].as_mv;
1370 *best_mv = *ref_mv; 1547 *best_mv = *ref_mv;
1371 1548
1372 for (r = row_min; r < row_max; ++r) { 1549 for (r = row_min; r < row_max; ++r) {
1373 for (c = col_min; c < col_max; ++c) { 1550 for (c = col_min; c < col_max; ++c) {
1374 const MV this_mv = {r, c}; 1551 const MV this_mv = {r, c};
1375 const uint8_t *check_here = &in_what[r * in_what_stride + c]; 1552 const uint8_t *check_here = &in_what[r * in_what_stride + c];
1376 const int sad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, 1553 const int sad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride,
1377 best_sad) + 1554 best_sad) +
1378 mvsad_err_cost(&this_mv, &fcenter_mv, 1555 mvsad_err_cost(&this_mv, &fcenter_mv,
1379 mvjsadcost, mvsadcost, sad_per_bit); 1556 mvjsadcost, mvsadcost, sad_per_bit);
(...skipping 13 matching lines...) Expand all
1393 + mv_err_cost(&mv, center_mv, mvjcost, mvcost, x->errorperbit); 1570 + mv_err_cost(&mv, center_mv, mvjcost, mvcost, x->errorperbit);
1394 } else { 1571 } else {
1395 return INT_MAX; 1572 return INT_MAX;
1396 } 1573 }
1397 } 1574 }
1398 1575
1399 int vp9_full_search_sadx3(const MACROBLOCK *x, const MV *ref_mv, 1576 int vp9_full_search_sadx3(const MACROBLOCK *x, const MV *ref_mv,
1400 int sad_per_bit, int distance, 1577 int sad_per_bit, int distance,
1401 const vp9_variance_fn_ptr_t *fn_ptr, 1578 const vp9_variance_fn_ptr_t *fn_ptr,
1402 int *mvjcost, int *mvcost[2], 1579 int *mvjcost, int *mvcost[2],
1403 const MV *center_mv, int n) { 1580 const MV *center_mv, MV *best_mv) {
1404 const MACROBLOCKD *const xd = &x->e_mbd; 1581 const MACROBLOCKD *const xd = &x->e_mbd;
1405 const uint8_t *const what = x->plane[0].src.buf; 1582 const uint8_t *const what = x->plane[0].src.buf;
1406 const int what_stride = x->plane[0].src.stride; 1583 const int what_stride = x->plane[0].src.stride;
1407 const uint8_t *const in_what = xd->plane[0].pre[0].buf; 1584 const uint8_t *const in_what = xd->plane[0].pre[0].buf;
1408 const int in_what_stride = xd->plane[0].pre[0].stride; 1585 const int in_what_stride = xd->plane[0].pre[0].stride;
1409 MV *best_mv = &xd->mi_8x8[0]->bmi[n].as_mv[0].as_mv;
1410 MV this_mv; 1586 MV this_mv;
1411 unsigned int bestsad = INT_MAX; 1587 unsigned int bestsad = INT_MAX;
1412 int r, c; 1588 int r, c;
1413 unsigned int thissad; 1589 unsigned int thissad;
1414 int ref_row = ref_mv->row; 1590 int ref_row = ref_mv->row;
1415 int ref_col = ref_mv->col; 1591 int ref_col = ref_mv->col;
1416 1592
1417 // Apply further limits to prevent us looking using vectors that stretch 1593 // Apply further limits to prevent us looking using vectors that stretch
1418 // beyond the UMV border 1594 // beyond the UMV border
1419 const int row_min = MAX(ref_row - distance, x->mv_row_min); 1595 const int row_min = MAX(ref_row - distance, x->mv_row_min);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 mv_err_cost(&this_mv, center_mv, 1675 mv_err_cost(&this_mv, center_mv,
1500 mvjcost, mvcost, x->errorperbit); 1676 mvjcost, mvcost, x->errorperbit);
1501 else 1677 else
1502 return INT_MAX; 1678 return INT_MAX;
1503 } 1679 }
1504 1680
1505 int vp9_full_search_sadx8(const MACROBLOCK *x, const MV *ref_mv, 1681 int vp9_full_search_sadx8(const MACROBLOCK *x, const MV *ref_mv,
1506 int sad_per_bit, int distance, 1682 int sad_per_bit, int distance,
1507 const vp9_variance_fn_ptr_t *fn_ptr, 1683 const vp9_variance_fn_ptr_t *fn_ptr,
1508 int *mvjcost, int *mvcost[2], 1684 int *mvjcost, int *mvcost[2],
1509 const MV *center_mv, int n) { 1685 const MV *center_mv, MV *best_mv) {
1510 const MACROBLOCKD *const xd = &x->e_mbd; 1686 const MACROBLOCKD *const xd = &x->e_mbd;
1511 const uint8_t *const what = x->plane[0].src.buf; 1687 const uint8_t *const what = x->plane[0].src.buf;
1512 const int what_stride = x->plane[0].src.stride; 1688 const int what_stride = x->plane[0].src.stride;
1513 const uint8_t *const in_what = xd->plane[0].pre[0].buf; 1689 const uint8_t *const in_what = xd->plane[0].pre[0].buf;
1514 const int in_what_stride = xd->plane[0].pre[0].stride; 1690 const int in_what_stride = xd->plane[0].pre[0].stride;
1515 MV *best_mv = &xd->mi_8x8[0]->bmi[n].as_mv[0].as_mv;
1516 MV this_mv; 1691 MV this_mv;
1517 unsigned int bestsad = INT_MAX; 1692 unsigned int bestsad = INT_MAX;
1518 int r, c; 1693 int r, c;
1519 unsigned int thissad; 1694 unsigned int thissad;
1520 int ref_row = ref_mv->row; 1695 int ref_row = ref_mv->row;
1521 int ref_col = ref_mv->col; 1696 int ref_col = ref_mv->col;
1522 1697
1523 // Apply further limits to prevent us looking using vectors that stretch 1698 // Apply further limits to prevent us looking using vectors that stretch
1524 // beyond the UMV border 1699 // beyond the UMV border
1525 const int row_min = MAX(ref_row - distance, x->mv_row_min); 1700 const int row_min = MAX(ref_row - distance, x->mv_row_min);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 const MACROBLOCKD *const xd = &x->e_mbd; 1820 const MACROBLOCKD *const xd = &x->e_mbd;
1646 const MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; 1821 const MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
1647 int i, j; 1822 int i, j;
1648 1823
1649 const int what_stride = x->plane[0].src.stride; 1824 const int what_stride = x->plane[0].src.stride;
1650 const uint8_t *const what = x->plane[0].src.buf; 1825 const uint8_t *const what = x->plane[0].src.buf;
1651 const int in_what_stride = xd->plane[0].pre[0].stride; 1826 const int in_what_stride = xd->plane[0].pre[0].stride;
1652 const uint8_t *const in_what = xd->plane[0].pre[0].buf; 1827 const uint8_t *const in_what = xd->plane[0].pre[0].buf;
1653 const uint8_t *best_address = &in_what[ref_mv->row * in_what_stride + 1828 const uint8_t *best_address = &in_what[ref_mv->row * in_what_stride +
1654 ref_mv->col]; 1829 ref_mv->col];
1655 unsigned int thissad;
1656
1657 const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3}; 1830 const MV fcenter_mv = {center_mv->row >> 3, center_mv->col >> 3};
1658 MV this_mv;
1659
1660 const int *mvjsadcost = x->nmvjointsadcost; 1831 const int *mvjsadcost = x->nmvjointsadcost;
1661 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]}; 1832 int *mvsadcost[2] = {x->nmvsadcost[0], x->nmvsadcost[1]};
1662 1833
1663 unsigned int bestsad = fn_ptr->sdf(what, what_stride, best_address, 1834 unsigned int bestsad = fn_ptr->sdf(what, what_stride, best_address,
1664 in_what_stride, 0x7fffffff) + 1835 in_what_stride, 0x7fffffff) +
1665 mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, error_per_bit); 1836 mvsad_err_cost(ref_mv, &fcenter_mv, mvjsadcost, mvsadcost, error_per_bit);
1666 1837
1667 for (i = 0; i < search_range; i++) { 1838 for (i = 0; i < search_range; i++) {
1668 int best_site = -1; 1839 int best_site = -1;
1669 1840
1670 for (j = 0; j < 4; j++) { 1841 for (j = 0; j < 4; j++) {
1671 this_mv.row = ref_mv->row + neighbors[j].row; 1842 const MV this_mv = {ref_mv->row + neighbors[j].row,
1672 this_mv.col = ref_mv->col + neighbors[j].col; 1843 ref_mv->col + neighbors[j].col};
1673
1674 if (is_mv_in(x, &this_mv)) { 1844 if (is_mv_in(x, &this_mv)) {
1675 const uint8_t *check_here = &in_what[this_mv.row * in_what_stride + 1845 const uint8_t *check_here = &in_what[this_mv.row * in_what_stride +
1676 this_mv.col]; 1846 this_mv.col];
1677 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride, 1847 unsigned int thissad = fn_ptr->sdf(what, what_stride, check_here,
1678 bestsad); 1848 in_what_stride, bestsad);
1679
1680 if (thissad < bestsad) { 1849 if (thissad < bestsad) {
1681 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, 1850 thissad += mvsad_err_cost(&this_mv, &fcenter_mv,
1682 mvjsadcost, mvsadcost, error_per_bit); 1851 mvjsadcost, mvsadcost, error_per_bit);
1683 1852
1684 if (thissad < bestsad) { 1853 if (thissad < bestsad) {
1685 bestsad = thissad; 1854 bestsad = thissad;
1686 best_site = j; 1855 best_site = j;
1687 } 1856 }
1688 } 1857 }
1689 } 1858 }
1690 } 1859 }
1691 1860
1692 if (best_site == -1) { 1861 if (best_site == -1) {
1693 break; 1862 break;
1694 } else { 1863 } else {
1695 ref_mv->row += neighbors[best_site].row; 1864 ref_mv->row += neighbors[best_site].row;
1696 ref_mv->col += neighbors[best_site].col; 1865 ref_mv->col += neighbors[best_site].col;
1697 best_address = &in_what[ref_mv->row * in_what_stride + ref_mv->col]; 1866 best_address = &in_what[ref_mv->row * in_what_stride + ref_mv->col];
1698 } 1867 }
1699 } 1868 }
1700 1869
1701 this_mv.row = ref_mv->row * 8; 1870 if (bestsad < INT_MAX) {
1702 this_mv.col = ref_mv->col * 8; 1871 unsigned int unused;
1703 1872 const MV mv = {ref_mv->row * 8, ref_mv->col * 8};
1704 if (bestsad < INT_MAX)
1705 return fn_ptr->vf(what, what_stride, best_address, in_what_stride, 1873 return fn_ptr->vf(what, what_stride, best_address, in_what_stride,
1706 (unsigned int *)(&thissad)) + 1874 &unused) +
1707 mv_err_cost(&this_mv, center_mv, mvjcost, mvcost, x->errorperbit); 1875 mv_err_cost(&mv, center_mv, mvjcost, mvcost, x->errorperbit);
1708 else 1876 } else {
1709 return INT_MAX; 1877 return INT_MAX;
1878 }
1710 } 1879 }
1711 1880
1712 int vp9_refining_search_sadx4(const MACROBLOCK *x, 1881 int vp9_refining_search_sadx4(const MACROBLOCK *x,
1713 MV *ref_mv, int error_per_bit, 1882 MV *ref_mv, int error_per_bit,
1714 int search_range, 1883 int search_range,
1715 const vp9_variance_fn_ptr_t *fn_ptr, 1884 const vp9_variance_fn_ptr_t *fn_ptr,
1716 int *mvjcost, int *mvcost[2], 1885 int *mvjcost, int *mvcost[2],
1717 const MV *center_mv) { 1886 const MV *center_mv) {
1718 const MACROBLOCKD *const xd = &x->e_mbd; 1887 const MACROBLOCKD *const xd = &x->e_mbd;
1719 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}}; 1888 MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 // FIXME(rbultje, yunqing): add full-pixel averaging variance functions 2063 // FIXME(rbultje, yunqing): add full-pixel averaging variance functions
1895 // so we don't have to use the subpixel with xoff=0,yoff=0 here. 2064 // so we don't have to use the subpixel with xoff=0,yoff=0 here.
1896 return fn_ptr->svaf(best_address, in_what_stride, 0, 0, what, what_stride, 2065 return fn_ptr->svaf(best_address, in_what_stride, 0, 0, what, what_stride,
1897 (unsigned int *)(&thissad), second_pred) + 2066 (unsigned int *)(&thissad), second_pred) +
1898 mv_err_cost(&this_mv, center_mv, 2067 mv_err_cost(&this_mv, center_mv,
1899 mvjcost, mvcost, x->errorperbit); 2068 mvjcost, mvcost, x->errorperbit);
1900 } else { 2069 } else {
1901 return INT_MAX; 2070 return INT_MAX;
1902 } 2071 }
1903 } 2072 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_mcomp.h ('k') | source/libvpx/vp9/encoder/vp9_onyx_if.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698