Fix crash with cb4x4 and warped-motion
BUG=aomedia:314
Change-Id: I66af7f69ca0b97b9d840918a6b9ec34708a7f4e5
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index b874a3a..ca7674b 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -1087,6 +1087,7 @@
}
}
}
+ assert(2 * np <= SAMPLES_ARRAY_SIZE);
// scan the left column
if (left_available) {
@@ -1129,6 +1130,7 @@
}
}
}
+ assert(2 * np <= SAMPLES_ARRAY_SIZE);
if (left_available && up_available) {
int mi_row_offset = -1;
@@ -1166,6 +1168,7 @@
np += pixelperblock;
}
}
+ assert(2 * np <= SAMPLES_ARRAY_SIZE);
for (i = 0; i < (mvnumber - 1); ++i) {
if (mvasint[i] != mvasint[i + 1]) break;
@@ -1200,6 +1203,7 @@
}
np += pixelperblock;
}
+ assert(2 * np <= SAMPLES_ARRAY_SIZE);
return np;
}
diff --git a/av1/common/warped_motion.c b/av1/common/warped_motion.c
index e807a7b..5b51aa6 100644
--- a/av1/common/warped_motion.c
+++ b/av1/common/warped_motion.c
@@ -413,7 +413,7 @@
// [-1, 2) * WARPEDPIXEL_PREC_SHIFTS.
// We need an extra 2 taps to fit this in, for a total of 8 taps.
/* clang-format off */
-const int16_t warped_filter[WARPEDPIXEL_PREC_SHIFTS*3][8] = {
+const int16_t warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3][8] = {
// [-1, 0)
{ 0, 0, 128, 0, 0, 0, 0, 0 }, { 0, - 1, 128, 2, - 1, 0, 0, 0 },
{ 1, - 3, 127, 4, - 1, 0, 0, 0 }, { 1, - 4, 126, 6, - 2, 1, 0, 0 },
diff --git a/av1/common/warped_motion.h b/av1/common/warped_motion.h
index 142362c..c1d8177 100644
--- a/av1/common/warped_motion.h
+++ b/av1/common/warped_motion.h
@@ -25,6 +25,8 @@
#define MAX_PARAMDIM 9
#if CONFIG_WARPED_MOTION
+#define SAMPLES_PER_NEIGHBOR 4
+#define SAMPLES_ARRAY_SIZE ((2 * MAX_MIB_SIZE + 2) * SAMPLES_PER_NEIGHBOR * 2)
#define DEFAULT_WMTYPE ROTZOOM
#endif // CONFIG_WARPED_MOTION
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 4dc866f..f5dd86f 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -1510,7 +1510,7 @@
#endif // CONFIG_REF_MV && CONFIG_EXT_INTER
int16_t mode_ctx = 0;
#if CONFIG_WARPED_MOTION
- double pts[144], pts_inref[144];
+ double pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
#endif // CONFIG_WARPED_MOTION
#if CONFIG_EC_ADAPT
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 1659258..83f7c2d 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -7818,7 +7818,7 @@
#endif // CONFIG_EXT_INTER
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if CONFIG_WARPED_MOTION
- double pts[144], pts_inref[144];
+ double pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
#endif // CONFIG_WARPED_MOTION
int64_t rd = INT64_MAX;
BUFFER_SET orig_dst, tmp_dst;