| 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 |
| 11 | 11 |
| 12 #include "./vp8_rtcd.h" |
| 13 #include "./vpx_dsp_rtcd.h" |
| 12 #include "onyx_int.h" | 14 #include "onyx_int.h" |
| 13 #include "mcomp.h" | 15 #include "mcomp.h" |
| 14 #include "vpx_mem/vpx_mem.h" | 16 #include "vpx_mem/vpx_mem.h" |
| 15 #include "vpx_config.h" | 17 #include "vpx_config.h" |
| 16 #include <stdio.h> | 18 #include <stdio.h> |
| 17 #include <limits.h> | 19 #include <limits.h> |
| 18 #include <math.h> | 20 #include <math.h> |
| 19 #include "vp8/common/findnearmv.h" | 21 #include "vp8/common/findnearmv.h" |
| 20 #include "vp8/common/common.h" | 22 #include "vp8/common/common.h" |
| 21 | 23 |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 /* adjust ref_mv to make sure it is within MV range */ | 895 /* adjust ref_mv to make sure it is within MV range */ |
| 894 vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_
max); | 896 vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_
max); |
| 895 br = ref_mv->as_mv.row; | 897 br = ref_mv->as_mv.row; |
| 896 bc = ref_mv->as_mv.col; | 898 bc = ref_mv->as_mv.col; |
| 897 | 899 |
| 898 /* Work out the start point for the search */ | 900 /* Work out the start point for the search */ |
| 899 base_offset = (unsigned char *)(base_pre + d->offset); | 901 base_offset = (unsigned char *)(base_pre + d->offset); |
| 900 this_offset = base_offset + (br * (pre_stride)) + bc; | 902 this_offset = base_offset + (br * (pre_stride)) + bc; |
| 901 this_mv.as_mv.row = br; | 903 this_mv.as_mv.row = br; |
| 902 this_mv.as_mv.col = bc; | 904 this_mv.as_mv.col = bc; |
| 903 bestsad = vfp->sdf(what, what_stride, this_offset, in_what_stride, UINT_MAX) | 905 bestsad = vfp->sdf(what, what_stride, this_offset, in_what_stride) |
| 904 + mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit); | 906 + mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost, sad_per_bit); |
| 905 | 907 |
| 906 #if CONFIG_MULTI_RES_ENCODING | 908 #if CONFIG_MULTI_RES_ENCODING |
| 907 /* Lower search range based on prediction info */ | 909 /* Lower search range based on prediction info */ |
| 908 if (search_param >= 6) goto cal_neighbors; | 910 if (search_param >= 6) goto cal_neighbors; |
| 909 else if (search_param >= 5) hex_range = 4; | 911 else if (search_param >= 5) hex_range = 4; |
| 910 else if (search_param >= 4) hex_range = 6; | 912 else if (search_param >= 4) hex_range = 6; |
| 911 else if (search_param >= 3) hex_range = 15; | 913 else if (search_param >= 3) hex_range = 15; |
| 912 else if (search_param >= 2) hex_range = 31; | 914 else if (search_param >= 2) hex_range = 31; |
| 913 else if (search_param >= 1) hex_range = 63; | 915 else if (search_param >= 1) hex_range = 63; |
| 914 | 916 |
| 915 dia_range = 8; | 917 dia_range = 8; |
| 916 #else | 918 #else |
| 917 (void)search_param; | 919 (void)search_param; |
| 918 #endif | 920 #endif |
| 919 | 921 |
| 920 /* hex search */ | 922 /* hex search */ |
| 921 CHECK_BOUNDS(2) | 923 CHECK_BOUNDS(2) |
| 922 | 924 |
| 923 if(all_in) | 925 if(all_in) |
| 924 { | 926 { |
| 925 for (i = 0; i < 6; i++) | 927 for (i = 0; i < 6; i++) |
| 926 { | 928 { |
| 927 this_mv.as_mv.row = br + hex[i].row; | 929 this_mv.as_mv.row = br + hex[i].row; |
| 928 this_mv.as_mv.col = bc + hex[i].col; | 930 this_mv.as_mv.col = bc + hex[i].col; |
| 929 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + t
his_mv.as_mv.col; | 931 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + t
his_mv.as_mv.col; |
| 930 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, b
estsad); | 932 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride); |
| 931 CHECK_BETTER | 933 CHECK_BETTER |
| 932 } | 934 } |
| 933 }else | 935 }else |
| 934 { | 936 { |
| 935 for (i = 0; i < 6; i++) | 937 for (i = 0; i < 6; i++) |
| 936 { | 938 { |
| 937 this_mv.as_mv.row = br + hex[i].row; | 939 this_mv.as_mv.row = br + hex[i].row; |
| 938 this_mv.as_mv.col = bc + hex[i].col; | 940 this_mv.as_mv.col = bc + hex[i].col; |
| 939 CHECK_POINT | 941 CHECK_POINT |
| 940 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + t
his_mv.as_mv.col; | 942 this_offset = base_offset + (this_mv.as_mv.row * in_what_stride) + t
his_mv.as_mv.col; |
| 941 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride, b
estsad); | 943 thissad = vfp->sdf(what, what_stride, this_offset, in_what_stride); |
| 942 CHECK_BETTER | 944 CHECK_BETTER |
| 943 } | 945 } |
| 944 } | 946 } |
| 945 | 947 |
| 946 if (best_site == -1) | 948 if (best_site == -1) |
| 947 goto cal_neighbors; | 949 goto cal_neighbors; |
| 948 else | 950 else |
| 949 { | 951 { |
| 950 br += hex[best_site].row; | 952 br += hex[best_site].row; |
| 951 bc += hex[best_site].col; | 953 bc += hex[best_site].col; |
| 952 k = best_site; | 954 k = best_site; |
| 953 } | 955 } |
| 954 | 956 |
| 955 for (j = 1; j < hex_range; j++) | 957 for (j = 1; j < hex_range; j++) |
| 956 { | 958 { |
| 957 best_site = -1; | 959 best_site = -1; |
| 958 CHECK_BOUNDS(2) | 960 CHECK_BOUNDS(2) |
| 959 | 961 |
| 960 if(all_in) | 962 if(all_in) |
| 961 { | 963 { |
| 962 for (i = 0; i < 3; i++) | 964 for (i = 0; i < 3; i++) |
| 963 { | 965 { |
| 964 this_mv.as_mv.row = br + next_chkpts[k][i].row; | 966 this_mv.as_mv.row = br + next_chkpts[k][i].row; |
| 965 this_mv.as_mv.col = bc + next_chkpts[k][i].col; | 967 this_mv.as_mv.col = bc + next_chkpts[k][i].col; |
| 966 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride
)) + this_mv.as_mv.col; | 968 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride
)) + this_mv.as_mv.col; |
| 967 thissad = vfp->sdf(what, what_stride, this_offset, in_what_strid
e, bestsad); | 969 thissad = vfp->sdf(what, what_stride, this_offset, in_what_strid
e); |
| 968 CHECK_BETTER | 970 CHECK_BETTER |
| 969 } | 971 } |
| 970 }else | 972 }else |
| 971 { | 973 { |
| 972 for (i = 0; i < 3; i++) | 974 for (i = 0; i < 3; i++) |
| 973 { | 975 { |
| 974 this_mv.as_mv.row = br + next_chkpts[k][i].row; | 976 this_mv.as_mv.row = br + next_chkpts[k][i].row; |
| 975 this_mv.as_mv.col = bc + next_chkpts[k][i].col; | 977 this_mv.as_mv.col = bc + next_chkpts[k][i].col; |
| 976 CHECK_POINT | 978 CHECK_POINT |
| 977 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride
)) + this_mv.as_mv.col; | 979 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride
)) + this_mv.as_mv.col; |
| 978 thissad = vfp->sdf(what, what_stride, this_offset, in_what_strid
e, bestsad); | 980 thissad = vfp->sdf(what, what_stride, this_offset, in_what_strid
e); |
| 979 CHECK_BETTER | 981 CHECK_BETTER |
| 980 } | 982 } |
| 981 } | 983 } |
| 982 | 984 |
| 983 if (best_site == -1) | 985 if (best_site == -1) |
| 984 break; | 986 break; |
| 985 else | 987 else |
| 986 { | 988 { |
| 987 br += next_chkpts[k][best_site].row; | 989 br += next_chkpts[k][best_site].row; |
| 988 bc += next_chkpts[k][best_site].col; | 990 bc += next_chkpts[k][best_site].col; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 999 best_site = -1; | 1001 best_site = -1; |
| 1000 CHECK_BOUNDS(1) | 1002 CHECK_BOUNDS(1) |
| 1001 | 1003 |
| 1002 if(all_in) | 1004 if(all_in) |
| 1003 { | 1005 { |
| 1004 for (i = 0; i < 4; i++) | 1006 for (i = 0; i < 4; i++) |
| 1005 { | 1007 { |
| 1006 this_mv.as_mv.row = br + neighbors[i].row; | 1008 this_mv.as_mv.row = br + neighbors[i].row; |
| 1007 this_mv.as_mv.col = bc + neighbors[i].col; | 1009 this_mv.as_mv.col = bc + neighbors[i].col; |
| 1008 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride
)) + this_mv.as_mv.col; | 1010 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride
)) + this_mv.as_mv.col; |
| 1009 thissad = vfp->sdf(what, what_stride, this_offset, in_what_strid
e, bestsad); | 1011 thissad = vfp->sdf(what, what_stride, this_offset, in_what_strid
e); |
| 1010 CHECK_BETTER | 1012 CHECK_BETTER |
| 1011 } | 1013 } |
| 1012 }else | 1014 }else |
| 1013 { | 1015 { |
| 1014 for (i = 0; i < 4; i++) | 1016 for (i = 0; i < 4; i++) |
| 1015 { | 1017 { |
| 1016 this_mv.as_mv.row = br + neighbors[i].row; | 1018 this_mv.as_mv.row = br + neighbors[i].row; |
| 1017 this_mv.as_mv.col = bc + neighbors[i].col; | 1019 this_mv.as_mv.col = bc + neighbors[i].col; |
| 1018 CHECK_POINT | 1020 CHECK_POINT |
| 1019 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride
)) + this_mv.as_mv.col; | 1021 this_offset = base_offset + (this_mv.as_mv.row * (in_what_stride
)) + this_mv.as_mv.col; |
| 1020 thissad = vfp->sdf(what, what_stride, this_offset, in_what_strid
e, bestsad); | 1022 thissad = vfp->sdf(what, what_stride, this_offset, in_what_strid
e); |
| 1021 CHECK_BETTER | 1023 CHECK_BETTER |
| 1022 } | 1024 } |
| 1023 } | 1025 } |
| 1024 | 1026 |
| 1025 if (best_site == -1) | 1027 if (best_site == -1) |
| 1026 break; | 1028 break; |
| 1027 else | 1029 else |
| 1028 { | 1030 { |
| 1029 br += neighbors[best_site].row; | 1031 br += neighbors[best_site].row; |
| 1030 bc += neighbors[best_site].col; | 1032 bc += neighbors[best_site].col; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 ref_col = ref_mv->as_mv.col; | 1096 ref_col = ref_mv->as_mv.col; |
| 1095 *num00 = 0; | 1097 *num00 = 0; |
| 1096 best_mv->as_mv.row = ref_row; | 1098 best_mv->as_mv.row = ref_row; |
| 1097 best_mv->as_mv.col = ref_col; | 1099 best_mv->as_mv.col = ref_col; |
| 1098 | 1100 |
| 1099 /* Work out the start point for the search */ | 1101 /* Work out the start point for the search */ |
| 1100 in_what = (unsigned char *)(base_pre + d->offset + (ref_row * pre_stride) +
ref_col); | 1102 in_what = (unsigned char *)(base_pre + d->offset + (ref_row * pre_stride) +
ref_col); |
| 1101 best_address = in_what; | 1103 best_address = in_what; |
| 1102 | 1104 |
| 1103 /* Check the starting position */ | 1105 /* Check the starting position */ |
| 1104 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, UINT_MAX) | 1106 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride) |
| 1105 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); | 1107 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); |
| 1106 | 1108 |
| 1107 /* search_param determines the length of the initial step and hence | 1109 /* search_param determines the length of the initial step and hence |
| 1108 * the number of iterations 0 = initial step (MAX_FIRST_STEP) pel : | 1110 * the number of iterations 0 = initial step (MAX_FIRST_STEP) pel : |
| 1109 * 1 = (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc. | 1111 * 1 = (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc. |
| 1110 */ | 1112 */ |
| 1111 ss = &x->ss[search_param * x->searches_per_step]; | 1113 ss = &x->ss[search_param * x->searches_per_step]; |
| 1112 tot_steps = (x->ss_count / x->searches_per_step) - search_param; | 1114 tot_steps = (x->ss_count / x->searches_per_step) - search_param; |
| 1113 | 1115 |
| 1114 i = 1; | 1116 i = 1; |
| 1115 | 1117 |
| 1116 for (step = 0; step < tot_steps ; step++) | 1118 for (step = 0; step < tot_steps ; step++) |
| 1117 { | 1119 { |
| 1118 for (j = 0 ; j < x->searches_per_step ; j++) | 1120 for (j = 0 ; j < x->searches_per_step ; j++) |
| 1119 { | 1121 { |
| 1120 /* Trap illegal vectors */ | 1122 /* Trap illegal vectors */ |
| 1121 this_row_offset = best_mv->as_mv.row + ss[i].mv.row; | 1123 this_row_offset = best_mv->as_mv.row + ss[i].mv.row; |
| 1122 this_col_offset = best_mv->as_mv.col + ss[i].mv.col; | 1124 this_col_offset = best_mv->as_mv.col + ss[i].mv.col; |
| 1123 | 1125 |
| 1124 if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_co
l_max) && | 1126 if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_co
l_max) && |
| 1125 (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_ma
x)) | 1127 (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_ma
x)) |
| 1126 | 1128 |
| 1127 { | 1129 { |
| 1128 check_here = ss[i].offset + best_address; | 1130 check_here = ss[i].offset + best_address; |
| 1129 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_str
ide, bestsad); | 1131 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_str
ide); |
| 1130 | 1132 |
| 1131 if (thissad < bestsad) | 1133 if (thissad < bestsad) |
| 1132 { | 1134 { |
| 1133 this_mv.as_mv.row = this_row_offset; | 1135 this_mv.as_mv.row = this_row_offset; |
| 1134 this_mv.as_mv.col = this_col_offset; | 1136 this_mv.as_mv.col = this_col_offset; |
| 1135 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, | 1137 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1136 mvsadcost, sad_per_bit); | 1138 mvsadcost, sad_per_bit); |
| 1137 | 1139 |
| 1138 if (thissad < bestsad) | 1140 if (thissad < bestsad) |
| 1139 { | 1141 { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 ref_col = ref_mv->as_mv.col; | 1220 ref_col = ref_mv->as_mv.col; |
| 1219 *num00 = 0; | 1221 *num00 = 0; |
| 1220 best_mv->as_mv.row = ref_row; | 1222 best_mv->as_mv.row = ref_row; |
| 1221 best_mv->as_mv.col = ref_col; | 1223 best_mv->as_mv.col = ref_col; |
| 1222 | 1224 |
| 1223 /* Work out the start point for the search */ | 1225 /* Work out the start point for the search */ |
| 1224 in_what = (unsigned char *)(base_pre + d->offset + (ref_row * pre_stride) +
ref_col); | 1226 in_what = (unsigned char *)(base_pre + d->offset + (ref_row * pre_stride) +
ref_col); |
| 1225 best_address = in_what; | 1227 best_address = in_what; |
| 1226 | 1228 |
| 1227 /* Check the starting position */ | 1229 /* Check the starting position */ |
| 1228 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride, UINT_MAX) | 1230 bestsad = fn_ptr->sdf(what, what_stride, in_what, in_what_stride) |
| 1229 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); | 1231 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); |
| 1230 | 1232 |
| 1231 /* search_param determines the length of the initial step and hence the | 1233 /* search_param determines the length of the initial step and hence the |
| 1232 * number of iterations 0 = initial step (MAX_FIRST_STEP) pel : 1 = | 1234 * number of iterations 0 = initial step (MAX_FIRST_STEP) pel : 1 = |
| 1233 * (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc. | 1235 * (MAX_FIRST_STEP/2) pel, 2 = (MAX_FIRST_STEP/4) pel... etc. |
| 1234 */ | 1236 */ |
| 1235 ss = &x->ss[search_param * x->searches_per_step]; | 1237 ss = &x->ss[search_param * x->searches_per_step]; |
| 1236 tot_steps = (x->ss_count / x->searches_per_step) - search_param; | 1238 tot_steps = (x->ss_count / x->searches_per_step) - search_param; |
| 1237 | 1239 |
| 1238 i = 1; | 1240 i = 1; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 for (j = 0 ; j < x->searches_per_step ; j++) | 1288 for (j = 0 ; j < x->searches_per_step ; j++) |
| 1287 { | 1289 { |
| 1288 /* Trap illegal vectors */ | 1290 /* Trap illegal vectors */ |
| 1289 this_row_offset = best_mv->as_mv.row + ss[i].mv.row; | 1291 this_row_offset = best_mv->as_mv.row + ss[i].mv.row; |
| 1290 this_col_offset = best_mv->as_mv.col + ss[i].mv.col; | 1292 this_col_offset = best_mv->as_mv.col + ss[i].mv.col; |
| 1291 | 1293 |
| 1292 if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->m
v_col_max) && | 1294 if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->m
v_col_max) && |
| 1293 (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_ro
w_max)) | 1295 (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_ro
w_max)) |
| 1294 { | 1296 { |
| 1295 check_here = ss[i].offset + best_address; | 1297 check_here = ss[i].offset + best_address; |
| 1296 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what
_stride, bestsad); | 1298 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what
_stride); |
| 1297 | 1299 |
| 1298 if (thissad < bestsad) | 1300 if (thissad < bestsad) |
| 1299 { | 1301 { |
| 1300 this_mv.as_mv.row = this_row_offset; | 1302 this_mv.as_mv.row = this_row_offset; |
| 1301 this_mv.as_mv.col = this_col_offset; | 1303 this_mv.as_mv.col = this_col_offset; |
| 1302 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, | 1304 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1303 mvsadcost, sad_per_bit); | 1305 mvsadcost, sad_per_bit); |
| 1304 | 1306 |
| 1305 if (thissad < bestsad) | 1307 if (thissad < bestsad) |
| 1306 { | 1308 { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1371 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; |
| 1370 | 1372 |
| 1371 /* Work out the mid point for the search */ | 1373 /* Work out the mid point for the search */ |
| 1372 in_what = base_pre + d->offset; | 1374 in_what = base_pre + d->offset; |
| 1373 bestaddress = in_what + (ref_row * pre_stride) + ref_col; | 1375 bestaddress = in_what + (ref_row * pre_stride) + ref_col; |
| 1374 | 1376 |
| 1375 best_mv->as_mv.row = ref_row; | 1377 best_mv->as_mv.row = ref_row; |
| 1376 best_mv->as_mv.col = ref_col; | 1378 best_mv->as_mv.col = ref_col; |
| 1377 | 1379 |
| 1378 /* Baseline value at the centre */ | 1380 /* Baseline value at the centre */ |
| 1379 bestsad = fn_ptr->sdf(what, what_stride, bestaddress, | 1381 bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride) |
| 1380 in_what_stride, UINT_MAX) | |
| 1381 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); | 1382 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); |
| 1382 | 1383 |
| 1383 /* Apply further limits to prevent us looking using vectors that | 1384 /* Apply further limits to prevent us looking using vectors that |
| 1384 * stretch beyiond the UMV border | 1385 * stretch beyiond the UMV border |
| 1385 */ | 1386 */ |
| 1386 if (col_min < x->mv_col_min) | 1387 if (col_min < x->mv_col_min) |
| 1387 col_min = x->mv_col_min; | 1388 col_min = x->mv_col_min; |
| 1388 | 1389 |
| 1389 if (col_max > x->mv_col_max) | 1390 if (col_max > x->mv_col_max) |
| 1390 col_max = x->mv_col_max; | 1391 col_max = x->mv_col_max; |
| 1391 | 1392 |
| 1392 if (row_min < x->mv_row_min) | 1393 if (row_min < x->mv_row_min) |
| 1393 row_min = x->mv_row_min; | 1394 row_min = x->mv_row_min; |
| 1394 | 1395 |
| 1395 if (row_max > x->mv_row_max) | 1396 if (row_max > x->mv_row_max) |
| 1396 row_max = x->mv_row_max; | 1397 row_max = x->mv_row_max; |
| 1397 | 1398 |
| 1398 for (r = row_min; r < row_max ; r++) | 1399 for (r = row_min; r < row_max ; r++) |
| 1399 { | 1400 { |
| 1400 this_mv.as_mv.row = r; | 1401 this_mv.as_mv.row = r; |
| 1401 check_here = r * mv_stride + in_what + col_min; | 1402 check_here = r * mv_stride + in_what + col_min; |
| 1402 | 1403 |
| 1403 for (c = col_min; c < col_max; c++) | 1404 for (c = col_min; c < col_max; c++) |
| 1404 { | 1405 { |
| 1405 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride,
bestsad); | 1406 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride)
; |
| 1406 | 1407 |
| 1407 this_mv.as_mv.col = c; | 1408 this_mv.as_mv.col = c; |
| 1408 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, | 1409 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1409 mvsadcost, sad_per_bit); | 1410 mvsadcost, sad_per_bit); |
| 1410 | 1411 |
| 1411 if (thissad < bestsad) | 1412 if (thissad < bestsad) |
| 1412 { | 1413 { |
| 1413 bestsad = thissad; | 1414 bestsad = thissad; |
| 1414 best_mv->as_mv.row = r; | 1415 best_mv->as_mv.row = r; |
| 1415 best_mv->as_mv.col = c; | 1416 best_mv->as_mv.col = c; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1468 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; |
| 1468 | 1469 |
| 1469 /* Work out the mid point for the search */ | 1470 /* Work out the mid point for the search */ |
| 1470 in_what = base_pre + d->offset; | 1471 in_what = base_pre + d->offset; |
| 1471 bestaddress = in_what + (ref_row * pre_stride) + ref_col; | 1472 bestaddress = in_what + (ref_row * pre_stride) + ref_col; |
| 1472 | 1473 |
| 1473 best_mv->as_mv.row = ref_row; | 1474 best_mv->as_mv.row = ref_row; |
| 1474 best_mv->as_mv.col = ref_col; | 1475 best_mv->as_mv.col = ref_col; |
| 1475 | 1476 |
| 1476 /* Baseline value at the centre */ | 1477 /* Baseline value at the centre */ |
| 1477 bestsad = fn_ptr->sdf(what, what_stride, bestaddress, | 1478 bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride) |
| 1478 in_what_stride, UINT_MAX) | |
| 1479 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); | 1479 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); |
| 1480 | 1480 |
| 1481 /* Apply further limits to prevent us looking using vectors that stretch | 1481 /* Apply further limits to prevent us looking using vectors that stretch |
| 1482 * beyond the UMV border | 1482 * beyond the UMV border |
| 1483 */ | 1483 */ |
| 1484 if (col_min < x->mv_col_min) | 1484 if (col_min < x->mv_col_min) |
| 1485 col_min = x->mv_col_min; | 1485 col_min = x->mv_col_min; |
| 1486 | 1486 |
| 1487 if (col_max > x->mv_col_max) | 1487 if (col_max > x->mv_col_max) |
| 1488 col_max = x->mv_col_max; | 1488 col_max = x->mv_col_max; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 } | 1524 } |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 check_here++; | 1527 check_here++; |
| 1528 c++; | 1528 c++; |
| 1529 } | 1529 } |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 while (c < col_max) | 1532 while (c < col_max) |
| 1533 { | 1533 { |
| 1534 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride,
bestsad); | 1534 thissad = fn_ptr->sdf(what, what_stride, check_here, in_what_stride)
; |
| 1535 | 1535 |
| 1536 if (thissad < bestsad) | 1536 if (thissad < bestsad) |
| 1537 { | 1537 { |
| 1538 this_mv.as_mv.col = c; | 1538 this_mv.as_mv.col = c; |
| 1539 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, | 1539 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1540 mvsadcost, sad_per_bit); | 1540 mvsadcost, sad_per_bit); |
| 1541 | 1541 |
| 1542 if (thissad < bestsad) | 1542 if (thissad < bestsad) |
| 1543 { | 1543 { |
| 1544 bestsad = thissad; | 1544 bestsad = thissad; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 unsigned char *check_here; | 1583 unsigned char *check_here; |
| 1584 | 1584 |
| 1585 int ref_row = ref_mv->as_mv.row; | 1585 int ref_row = ref_mv->as_mv.row; |
| 1586 int ref_col = ref_mv->as_mv.col; | 1586 int ref_col = ref_mv->as_mv.col; |
| 1587 | 1587 |
| 1588 int row_min = ref_row - distance; | 1588 int row_min = ref_row - distance; |
| 1589 int row_max = ref_row + distance; | 1589 int row_max = ref_row + distance; |
| 1590 int col_min = ref_col - distance; | 1590 int col_min = ref_col - distance; |
| 1591 int col_max = ref_col + distance; | 1591 int col_max = ref_col + distance; |
| 1592 | 1592 |
| 1593 DECLARE_ALIGNED_ARRAY(16, unsigned short, sad_array8, 8); | 1593 // TODO(johannkoenig): check if this alignment is necessary. |
| 1594 DECLARE_ALIGNED(16, unsigned int, sad_array8[8]); |
| 1594 unsigned int sad_array[3]; | 1595 unsigned int sad_array[3]; |
| 1595 | 1596 |
| 1596 int *mvsadcost[2]; | 1597 int *mvsadcost[2]; |
| 1597 int_mv fcenter_mv; | 1598 int_mv fcenter_mv; |
| 1598 | 1599 |
| 1599 mvsadcost[0] = x->mvsadcost[0]; | 1600 mvsadcost[0] = x->mvsadcost[0]; |
| 1600 mvsadcost[1] = x->mvsadcost[1]; | 1601 mvsadcost[1] = x->mvsadcost[1]; |
| 1601 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1602 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; |
| 1602 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1603 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; |
| 1603 | 1604 |
| 1604 /* Work out the mid point for the search */ | 1605 /* Work out the mid point for the search */ |
| 1605 in_what = base_pre + d->offset; | 1606 in_what = base_pre + d->offset; |
| 1606 bestaddress = in_what + (ref_row * pre_stride) + ref_col; | 1607 bestaddress = in_what + (ref_row * pre_stride) + ref_col; |
| 1607 | 1608 |
| 1608 best_mv->as_mv.row = ref_row; | 1609 best_mv->as_mv.row = ref_row; |
| 1609 best_mv->as_mv.col = ref_col; | 1610 best_mv->as_mv.col = ref_col; |
| 1610 | 1611 |
| 1611 /* Baseline value at the centre */ | 1612 /* Baseline value at the centre */ |
| 1612 bestsad = fn_ptr->sdf(what, what_stride, | 1613 bestsad = fn_ptr->sdf(what, what_stride, bestaddress, in_what_stride) |
| 1613 bestaddress, in_what_stride, UINT_MAX) | |
| 1614 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); | 1614 + mvsad_err_cost(best_mv, &fcenter_mv, mvsadcost, sad_per_bit); |
| 1615 | 1615 |
| 1616 /* Apply further limits to prevent us looking using vectors that stretch | 1616 /* Apply further limits to prevent us looking using vectors that stretch |
| 1617 * beyond the UMV border | 1617 * beyond the UMV border |
| 1618 */ | 1618 */ |
| 1619 if (col_min < x->mv_col_min) | 1619 if (col_min < x->mv_col_min) |
| 1620 col_min = x->mv_col_min; | 1620 col_min = x->mv_col_min; |
| 1621 | 1621 |
| 1622 if (col_max > x->mv_col_max) | 1622 if (col_max > x->mv_col_max) |
| 1623 col_max = x->mv_col_max; | 1623 col_max = x->mv_col_max; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 } | 1689 } |
| 1690 } | 1690 } |
| 1691 | 1691 |
| 1692 check_here++; | 1692 check_here++; |
| 1693 c++; | 1693 c++; |
| 1694 } | 1694 } |
| 1695 } | 1695 } |
| 1696 | 1696 |
| 1697 while (c < col_max) | 1697 while (c < col_max) |
| 1698 { | 1698 { |
| 1699 thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride
, bestsad); | 1699 thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_stride
); |
| 1700 | 1700 |
| 1701 if (thissad < bestsad) | 1701 if (thissad < bestsad) |
| 1702 { | 1702 { |
| 1703 this_mv.as_mv.col = c; | 1703 this_mv.as_mv.col = c; |
| 1704 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, | 1704 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, |
| 1705 mvsadcost, sad_per_bit); | 1705 mvsadcost, sad_per_bit); |
| 1706 | 1706 |
| 1707 if (thissad < bestsad) | 1707 if (thissad < bestsad) |
| 1708 { | 1708 { |
| 1709 bestsad = thissad; | 1709 bestsad = thissad; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 unsigned int thissad; | 1747 unsigned int thissad; |
| 1748 | 1748 |
| 1749 int *mvsadcost[2]; | 1749 int *mvsadcost[2]; |
| 1750 int_mv fcenter_mv; | 1750 int_mv fcenter_mv; |
| 1751 | 1751 |
| 1752 mvsadcost[0] = x->mvsadcost[0]; | 1752 mvsadcost[0] = x->mvsadcost[0]; |
| 1753 mvsadcost[1] = x->mvsadcost[1]; | 1753 mvsadcost[1] = x->mvsadcost[1]; |
| 1754 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1754 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; |
| 1755 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1755 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; |
| 1756 | 1756 |
| 1757 bestsad = fn_ptr->sdf(what, what_stride, best_address, | 1757 bestsad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride) |
| 1758 in_what_stride, UINT_MAX) | |
| 1759 + mvsad_err_cost(ref_mv, &fcenter_mv, mvsadcost, error_per_bit); | 1758 + mvsad_err_cost(ref_mv, &fcenter_mv, mvsadcost, error_per_bit); |
| 1760 | 1759 |
| 1761 for (i=0; i<search_range; i++) | 1760 for (i=0; i<search_range; i++) |
| 1762 { | 1761 { |
| 1763 int best_site = -1; | 1762 int best_site = -1; |
| 1764 | 1763 |
| 1765 for (j = 0 ; j < 4 ; j++) | 1764 for (j = 0 ; j < 4 ; j++) |
| 1766 { | 1765 { |
| 1767 this_row_offset = ref_mv->as_mv.row + neighbors[j].row; | 1766 this_row_offset = ref_mv->as_mv.row + neighbors[j].row; |
| 1768 this_col_offset = ref_mv->as_mv.col + neighbors[j].col; | 1767 this_col_offset = ref_mv->as_mv.col + neighbors[j].col; |
| 1769 | 1768 |
| 1770 if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_co
l_max) && | 1769 if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->mv_co
l_max) && |
| 1771 (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_ma
x)) | 1770 (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_row_ma
x)) |
| 1772 { | 1771 { |
| 1773 check_here = (neighbors[j].row)*in_what_stride + neighbors[j].co
l + best_address; | 1772 check_here = (neighbors[j].row)*in_what_stride + neighbors[j].co
l + best_address; |
| 1774 thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_st
ride, bestsad); | 1773 thissad = fn_ptr->sdf(what, what_stride, check_here , in_what_st
ride); |
| 1775 | 1774 |
| 1776 if (thissad < bestsad) | 1775 if (thissad < bestsad) |
| 1777 { | 1776 { |
| 1778 this_mv.as_mv.row = this_row_offset; | 1777 this_mv.as_mv.row = this_row_offset; |
| 1779 this_mv.as_mv.col = this_col_offset; | 1778 this_mv.as_mv.col = this_col_offset; |
| 1780 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost,
error_per_bit); | 1779 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadcost,
error_per_bit); |
| 1781 | 1780 |
| 1782 if (thissad < bestsad) | 1781 if (thissad < bestsad) |
| 1783 { | 1782 { |
| 1784 bestsad = thissad; | 1783 bestsad = thissad; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 unsigned int thissad; | 1826 unsigned int thissad; |
| 1828 | 1827 |
| 1829 int *mvsadcost[2]; | 1828 int *mvsadcost[2]; |
| 1830 int_mv fcenter_mv; | 1829 int_mv fcenter_mv; |
| 1831 | 1830 |
| 1832 mvsadcost[0] = x->mvsadcost[0]; | 1831 mvsadcost[0] = x->mvsadcost[0]; |
| 1833 mvsadcost[1] = x->mvsadcost[1]; | 1832 mvsadcost[1] = x->mvsadcost[1]; |
| 1834 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; | 1833 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3; |
| 1835 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; | 1834 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3; |
| 1836 | 1835 |
| 1837 bestsad = fn_ptr->sdf(what, what_stride, best_address, | 1836 bestsad = fn_ptr->sdf(what, what_stride, best_address, in_what_stride) |
| 1838 in_what_stride, UINT_MAX) | |
| 1839 + mvsad_err_cost(ref_mv, &fcenter_mv, mvsadcost, error_per_bit); | 1837 + mvsad_err_cost(ref_mv, &fcenter_mv, mvsadcost, error_per_bit); |
| 1840 | 1838 |
| 1841 for (i=0; i<search_range; i++) | 1839 for (i=0; i<search_range; i++) |
| 1842 { | 1840 { |
| 1843 int best_site = -1; | 1841 int best_site = -1; |
| 1844 int all_in = 1; | 1842 int all_in = 1; |
| 1845 | 1843 |
| 1846 all_in &= ((ref_mv->as_mv.row - 1) > x->mv_row_min); | 1844 all_in &= ((ref_mv->as_mv.row - 1) > x->mv_row_min); |
| 1847 all_in &= ((ref_mv->as_mv.row + 1) < x->mv_row_max); | 1845 all_in &= ((ref_mv->as_mv.row + 1) < x->mv_row_max); |
| 1848 all_in &= ((ref_mv->as_mv.col - 1) > x->mv_col_min); | 1846 all_in &= ((ref_mv->as_mv.col - 1) > x->mv_col_min); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1879 { | 1877 { |
| 1880 for (j = 0 ; j < 4 ; j++) | 1878 for (j = 0 ; j < 4 ; j++) |
| 1881 { | 1879 { |
| 1882 this_row_offset = ref_mv->as_mv.row + neighbors[j].row; | 1880 this_row_offset = ref_mv->as_mv.row + neighbors[j].row; |
| 1883 this_col_offset = ref_mv->as_mv.col + neighbors[j].col; | 1881 this_col_offset = ref_mv->as_mv.col + neighbors[j].col; |
| 1884 | 1882 |
| 1885 if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->m
v_col_max) && | 1883 if ((this_col_offset > x->mv_col_min) && (this_col_offset < x->m
v_col_max) && |
| 1886 (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_ro
w_max)) | 1884 (this_row_offset > x->mv_row_min) && (this_row_offset < x->mv_ro
w_max)) |
| 1887 { | 1885 { |
| 1888 check_here = (neighbors[j].row)*in_what_stride + neighbors[j
].col + best_address; | 1886 check_here = (neighbors[j].row)*in_what_stride + neighbors[j
].col + best_address; |
| 1889 thissad = fn_ptr->sdf(what, what_stride, check_here , in_wha
t_stride, bestsad); | 1887 thissad = fn_ptr->sdf(what, what_stride, check_here , in_wha
t_stride); |
| 1890 | 1888 |
| 1891 if (thissad < bestsad) | 1889 if (thissad < bestsad) |
| 1892 { | 1890 { |
| 1893 this_mv.as_mv.row = this_row_offset; | 1891 this_mv.as_mv.row = this_row_offset; |
| 1894 this_mv.as_mv.col = this_col_offset; | 1892 this_mv.as_mv.col = this_col_offset; |
| 1895 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadco
st, error_per_bit); | 1893 thissad += mvsad_err_cost(&this_mv, &fcenter_mv, mvsadco
st, error_per_bit); |
| 1896 | 1894 |
| 1897 if (thissad < bestsad) | 1895 if (thissad < bestsad) |
| 1898 { | 1896 { |
| 1899 bestsad = thissad; | 1897 bestsad = thissad; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1971 } | 1969 } |
| 1972 | 1970 |
| 1973 fprintf(f, "};\n"); | 1971 fprintf(f, "};\n"); |
| 1974 fclose(f); | 1972 fclose(f); |
| 1975 } | 1973 } |
| 1976 | 1974 |
| 1977 /* MV ref count VP8_ENTROPY_STATS stats code */ | 1975 /* MV ref count VP8_ENTROPY_STATS stats code */ |
| 1978 #ifdef VP8_ENTROPY_STATS | 1976 #ifdef VP8_ENTROPY_STATS |
| 1979 void init_mv_ref_counts() | 1977 void init_mv_ref_counts() |
| 1980 { | 1978 { |
| 1981 vpx_memset(mv_ref_ct, 0, sizeof(mv_ref_ct)); | 1979 memset(mv_ref_ct, 0, sizeof(mv_ref_ct)); |
| 1982 vpx_memset(mv_mode_cts, 0, sizeof(mv_mode_cts)); | 1980 memset(mv_mode_cts, 0, sizeof(mv_mode_cts)); |
| 1983 } | 1981 } |
| 1984 | 1982 |
| 1985 void accum_mv_refs(MB_PREDICTION_MODE m, const int ct[4]) | 1983 void accum_mv_refs(MB_PREDICTION_MODE m, const int ct[4]) |
| 1986 { | 1984 { |
| 1987 if (m == ZEROMV) | 1985 if (m == ZEROMV) |
| 1988 { | 1986 { |
| 1989 ++mv_ref_ct [ct[0]] [0] [0]; | 1987 ++mv_ref_ct [ct[0]] [0] [0]; |
| 1990 ++mv_mode_cts[0][0]; | 1988 ++mv_mode_cts[0][0]; |
| 1991 } | 1989 } |
| 1992 else | 1990 else |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2025 ++mv_mode_cts[3][1]; | 2023 ++mv_mode_cts[3][1]; |
| 2026 } | 2024 } |
| 2027 } | 2025 } |
| 2028 } | 2026 } |
| 2029 } | 2027 } |
| 2030 } | 2028 } |
| 2031 | 2029 |
| 2032 #endif/* END MV ref count VP8_ENTROPY_STATS stats code */ | 2030 #endif/* END MV ref count VP8_ENTROPY_STATS stats code */ |
| 2033 | 2031 |
| 2034 #endif | 2032 #endif |
| OLD | NEW |