History

Fix range checks in motion search

There were some situations that the start motion vectors were out of range. This fix adjusted range checks to make sure they are checked and clamped.

Yunqing Wang committed 15 years ago

Commit bde2afb1 parent fe270dd3 files · +17 −11Browse files

Unified · Split

3 files
  1. vp8/encoder/mcomp.c +17 −6
  2. vp8/encoder/pickinter.c +0 −2
  3. vp8/encoder/rdopt.c +0 −3
vp8/encoder/mcomp.c+17−6
@@ -15,6 +15,7 @@ · 14 unmodified lines
15#include <stdio.h>15#include <stdio.h>
16#include <limits.h>16#include <limits.h>
17#include <math.h>17#include <math.h>
18#include "vp8/common/findnearmv.h"
18 19
19#ifdef ENTROPY_STATS20#ifdef ENTROPY_STATS
20static int mv_ref_ct [31] [4] [2];21static int mv_ref_ct [31] [4] [2];
@@ -866,7 +867,7 @@ int vp8_hex_search · 845 unmodified lines
866 unsigned char *what = (*(b->base_src) + b->src);867 unsigned char *what = (*(b->base_src) + b->src);
867 int what_stride = b->src_stride;868 int what_stride = b->src_stride;
868 int in_what_stride = d->pre_stride;869 int in_what_stride = d->pre_stride;
869 int br = ref_mv->as_mv.row, bc = ref_mv->as_mv.col;870 int br, bc;
870 int_mv this_mv;871 int_mv this_mv;
871 unsigned int bestsad = 0x7fffffff;872 unsigned int bestsad = 0x7fffffff;
872 unsigned int thissad;873 unsigned int thissad;
@@ -880,6 +881,11 @@ int vp8_hex_search · 7 unmodified lines
880 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;881 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
881 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;882 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
882 883
884 // adjust ref_mv to make sure it is within MV range
885 vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
886 br = ref_mv->as_mv.row;
887 bc = ref_mv->as_mv.col;
888
883 // Work out the start point for the search889 // Work out the start point for the search
884 base_offset = (unsigned char *)(*(d->base_pre) + d->pre);890 base_offset = (unsigned char *)(*(d->base_pre) + d->pre);
885 this_offset = base_offset + (br * (d->pre_stride)) + bc;891 this_offset = base_offset + (br * (d->pre_stride)) + bc;
@@ -1043,8 +1049,8 @@ int vp8_diamond_search_sad · 157 unmodified lines
1043 int best_site = 0;1049 int best_site = 0;
1044 int last_site = 0;1050 int last_site = 0;
1045 1051
1046 int ref_row = ref_mv->as_mv.row;1052 int ref_row;
1047 int ref_col = ref_mv->as_mv.col;1053 int ref_col;
1048 int this_row_offset;1054 int this_row_offset;
1049 int this_col_offset;1055 int this_col_offset;
1050 search_site *ss;1056 search_site *ss;
@@ -1057,8 +1063,10 @@ int vp8_diamond_search_sad · 6 unmodified lines
1057 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;1063 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
1058 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;1064 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
1059 1065
1066 vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
1067 ref_row = ref_mv->as_mv.row;
1068 ref_col = ref_mv->as_mv.col;
1060 *num00 = 0;1069 *num00 = 0;
1061
1062 best_mv->as_mv.row = ref_row;1070 best_mv->as_mv.row = ref_row;
1063 best_mv->as_mv.col = ref_col;1071 best_mv->as_mv.col = ref_col;
1064 1072
@@ -1162,8 +1170,8 @@ int vp8_diamond_search_sadx4 · 97 unmodified lines
1162 int best_site = 0;1170 int best_site = 0;
1163 int last_site = 0;1171 int last_site = 0;
1164 1172
1165 int ref_row = ref_mv->as_mv.row;1173 int ref_row;
1166 int ref_col = ref_mv->as_mv.col;1174 int ref_col;
1167 int this_row_offset;1175 int this_row_offset;
1168 int this_col_offset;1176 int this_col_offset;
1169 search_site *ss;1177 search_site *ss;
@@ -1176,6 +1184,9 @@ int vp8_diamond_search_sadx4 · 6 unmodified lines
1176 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;1184 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
1177 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;1185 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
1178 1186
1187 vp8_clamp_mv(ref_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
1188 ref_row = ref_mv->as_mv.row;
1189 ref_col = ref_mv->as_mv.col;
1179 *num00 = 0;1190 *num00 = 0;
1180 best_mv->as_mv.row = ref_row;1191 best_mv->as_mv.row = ref_row;
1181 best_mv->as_mv.col = ref_col;1192 best_mv->as_mv.col = ref_col;
vp8/encoder/pickinter.c+0−2
@@ -669,8 +669,6 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, · 668 unmodified lines
669 mvp_full.as_mv.col = mvp.as_mv.col>>3;669 mvp_full.as_mv.col = mvp.as_mv.col>>3;
670 mvp_full.as_mv.row = mvp.as_mv.row>>3;670 mvp_full.as_mv.row = mvp.as_mv.row>>3;
671 671
672 /* adjust mvp to make sure it is within MV range */
673 vp8_clamp_mv(&mvp_full, col_min, col_max, row_min, row_max);
674 }else672 }else
675 {673 {
676 mvp.as_int = best_ref_mv.as_int;674 mvp.as_int = best_ref_mv.as_int;
vp8/encoder/rdopt.c+0−3
@@ -2016,9 +2016,6 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int · 2015 unmodified lines
2016 mvp_full.as_mv.col = mvp.as_mv.col>>3;2016 mvp_full.as_mv.col = mvp.as_mv.col>>3;
2017 mvp_full.as_mv.row = mvp.as_mv.row>>3;2017 mvp_full.as_mv.row = mvp.as_mv.row>>3;
2018 2018
2019 /* adjust mvp to make sure it is within MV range */
2020 vp8_clamp_mv(&mvp_full, col_min, col_max, row_min, row_max);
2021
2022 // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.2019 // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
2023 if (x->mv_col_min < col_min )2020 if (x->mv_col_min < col_min )
2024 x->mv_col_min = col_min;2021 x->mv_col_min = col_min;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t