Allow a large motion search range
After extending full-pixel motion vectors to 12 bits, in motion search,
allow a large motion search range. This is an encoder side change.
Borg test result:
avg_psnr ovr_psnr ssim
hdres: -0.036 -0.037 -0.091
lowres: 0.002 -0.003 0.041
BUG=aomedia:966
Change-Id: Iea805455126444acfac3d7082476fe96d7ccebb8
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index 0293a01..393f192 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -364,7 +364,7 @@
aom_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[bsize];
const int new_mv_mode_penalty = NEW_MV_MODE_PENALTY;
- int step_param = 3;
+ int step_param = 4;
int further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
const int sr = get_search_range(cpi);
step_param += sr;
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 2de21b6..b67f1c1 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -1025,7 +1025,7 @@
} \
}
-#define MAX_PATTERN_SCALES 11
+#define MAX_PATTERN_SCALES 12
#define MAX_PATTERN_CANDIDATES 8 // max number of canddiates per scale
#define PATTERN_CANDIDATES_REF 3 // number of refinement candidates
@@ -1131,7 +1131,7 @@
const MV candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES]) {
const MACROBLOCKD *const xd = &x->e_mbd;
static const int search_param_to_steps[MAX_MVSEARCH_STEPS] = {
- 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
+ 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
};
int i, s, t;
const struct buf_2d *const what = &x->plane[0].src;
@@ -1444,8 +1444,9 @@
const MV *center_mv) {
// First scale has 8-closest points, the rest have 6 points in hex shape
// at increasing scales
- static const int hex_num_candidates[MAX_PATTERN_SCALES] = { 8, 6, 6, 6, 6, 6,
- 6, 6, 6, 6, 6 };
+ static const int hex_num_candidates[MAX_PATTERN_SCALES] = {
+ 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6
+ };
// Note that the largest candidate step at each scale is 2^scale
/* clang-format off */
static const MV hex_candidates[MAX_PATTERN_SCALES][MAX_PATTERN_CANDIDATES] = {
@@ -1467,6 +1468,8 @@
{ -512, 0 } },
{ { -512, -1024 }, { 512, -1024 }, { 1024, 0 }, { 512, 1024 },
{ -512, 1024 }, { -1024, 0 } },
+ { { -1024, -2048 }, { 1024, -2048 }, { 2048, 0 }, { 1024, 2048 },
+ { -1024, 2048 }, { -2048, 0 } },
};
/* clang-format on */
return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search,
@@ -1481,7 +1484,7 @@
// First scale has 4-closest points, the rest have 8 points in diamond
// shape at increasing scales
static const int bigdia_num_candidates[MAX_PATTERN_SCALES] = {
- 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
// Note that the largest candidate step at each scale is 2^scale
/* clang-format off */
@@ -1508,6 +1511,8 @@
{ 0, 512 }, { -256, 256 }, { -512, 0 } },
{ { -512, -512 }, { 0, -1024 }, { 512, -512 }, { 1024, 0 },
{ 512, 512 }, { 0, 1024 }, { -512, 512 }, { -1024, 0 } },
+ { { -1024, -1024 }, { 0, -2048 }, { 1024, -1024 }, { 2048, 0 },
+ { 1024, 1024 }, { 0, 2048 }, { -1024, 1024 }, { -2048, 0 } },
};
/* clang-format on */
return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search,
@@ -1521,7 +1526,7 @@
const MV *center_mv) {
// All scales have 8 closest points in square shape
static const int square_num_candidates[MAX_PATTERN_SCALES] = {
- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
// Note that the largest candidate step at each scale is 2^scale
/* clang-format off */
@@ -1549,6 +1554,8 @@
{ 0, 512 }, { -512, 512 }, { -512, 0 } },
{ { -1024, -1024 }, { 0, -1024 }, { 1024, -1024 }, { 1024, 0 },
{ 1024, 1024 }, { 0, 1024 }, { -1024, 1024 }, { -1024, 0 } },
+ { { -2048, -2048 }, { 0, -2048 }, { 2048, -2048 }, { 2048, 0 },
+ { 2048, 2048 }, { 0, 2048 }, { -2048, 2048 }, { -2048, 0 } },
};
/* clang-format on */
return pattern_search(x, start_mv, search_param, sad_per_bit, do_init_search,
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index e678148..85a38de 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -21,9 +21,9 @@
// The maximum number of steps in a step search given the largest
// allowed initial step
-#define MAX_MVSEARCH_STEPS 11
+#define MAX_MVSEARCH_STEPS 12
// Max full pel mv specified in the unit of full pixel
-// Enable the use of motion vector in range [-1023, 1023].
+// Enable the use of motion vector in range [-2047, 2047].
#define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS - 1)) - 1)
// Maximum size of the first step in full pel units
#define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS - 1))
@@ -74,13 +74,6 @@
const aom_variance_fn_ptr_t *fn_ptr,
const struct mv *center_mv);
-// Runs sequence of diamond searches in smaller steps for RD.
-int av1_full_pixel_diamond(const struct AV1_COMP *cpi, MACROBLOCK *x,
- MV *mvp_full, int step_param, int sadpb,
- int further_steps, int do_refine, int *cost_list,
- const aom_variance_fn_ptr_t *fn_ptr,
- const MV *ref_mv, MV *dst_mv);
-
// Perform integral projection based motion estimation.
unsigned int av1_int_pro_motion_estimation(const struct AV1_COMP *cpi,
MACROBLOCK *x, BLOCK_SIZE bsize,