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
1515 #include <stdio.h>
1616 #include <limits.h>
1717 #include <math.h>
18+#include "vp8/common/findnearmv.h"
1819
1920 #ifdef ENTROPY_STATS
2021 static int mv_ref_ct [31] [4] [2];
@@ -866,7 +867,7 @@ int vp8_hex_search · 845 unmodified lines
866867 unsigned char *what = (*(b->base_src) + b->src);
867868 int what_stride = b->src_stride;
868869 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;
870871 int_mv this_mv;
871872 unsigned int bestsad = 0x7fffffff;
872873 unsigned int thissad;
@@ -880,6 +881,11 @@ int vp8_hex_search · 7 unmodified lines
880881 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
881882 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
882883
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+
883889 // Work out the start point for the search
884890 base_offset = (unsigned char *)(*(d->base_pre) + d->pre);
885891 this_offset = base_offset + (br * (d->pre_stride)) + bc;
@@ -1043,8 +1049,8 @@ int vp8_diamond_search_sad · 157 unmodified lines
10431049 int best_site = 0;
10441050 int last_site = 0;
10451051
1046− int ref_row = ref_mv->as_mv.row;
1047− int ref_col = ref_mv->as_mv.col;
1052+ int ref_row;
1053+ int ref_col;
10481054 int this_row_offset;
10491055 int this_col_offset;
10501056 search_site *ss;
@@ -1057,8 +1063,10 @@ int vp8_diamond_search_sad · 6 unmodified lines
10571063 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
10581064 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
10591065
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;
10601069 *num00 = 0;
1061−
10621070 best_mv->as_mv.row = ref_row;
10631071 best_mv->as_mv.col = ref_col;
10641072
@@ -1162,8 +1170,8 @@ int vp8_diamond_search_sadx4 · 97 unmodified lines
11621170 int best_site = 0;
11631171 int last_site = 0;
11641172
1165− int ref_row = ref_mv->as_mv.row;
1166− int ref_col = ref_mv->as_mv.col;
1173+ int ref_row;
1174+ int ref_col;
11671175 int this_row_offset;
11681176 int this_col_offset;
11691177 search_site *ss;
@@ -1176,6 +1184,9 @@ int vp8_diamond_search_sadx4 · 6 unmodified lines
11761184 fcenter_mv.as_mv.row = center_mv->as_mv.row >> 3;
11771185 fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
11781186
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;
11791190 *num00 = 0;
11801191 best_mv->as_mv.row = ref_row;
11811192 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
669669 mvp_full.as_mv.col = mvp.as_mv.col>>3;
670670 mvp_full.as_mv.row = mvp.as_mv.row>>3;
671671
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);
674672 }else
675673 {
676674 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
20162016 mvp_full.as_mv.col = mvp.as_mv.col>>3;
20172017 mvp_full.as_mv.row = mvp.as_mv.row>>3;
20182018
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−
20222019 // Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
20232020 if (x->mv_col_min < col_min )
20242021 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