Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1783)

Unified Diff: unit_test/scale_test.cc

Issue 1947783002: If image sizes are greater than 32768, fixed point stepping will overflow an int. This CL changes t… (Closed) Base URL: https://chromium.googlesource.com/libyuv/libyuv@master
Patch Set: make scaling subsample round up Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« unit_test/scale_argb_test.cc ('K') | « unit_test/scale_argb_test.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: unit_test/scale_test.cc
diff --git a/unit_test/scale_test.cc b/unit_test/scale_test.cc
index f31af80b3151759b46b779491fb5d61b2fb1d4df..b16b5d40cce49eedb1cffdf4880f19ad50816f43 100644
--- a/unit_test/scale_test.cc
+++ b/unit_test/scale_test.cc
@@ -25,6 +25,11 @@ static int TestFilter(int src_width, int src_height,
int dst_width, int dst_height,
FilterMode f, int benchmark_iterations,
int disable_cpu_flags, int benchmark_cpu_info) {
+ if (src_width > 32768 || src_height > 32768 ||
+ dst_width > 32768 || dst_height > 32768) {
+ printf("Warning - size too large to test. Skipping\n");
+ return 0;
+ }
int i, j;
const int b = 0; // 128 to test for padding/stride.
int src_width_uv = (Abs(src_width) + 1) >> 1;
@@ -148,6 +153,11 @@ static int TestFilter(int src_width, int src_height,
static int TestFilter_16(int src_width, int src_height,
int dst_width, int dst_height,
FilterMode f, int benchmark_iterations) {
+ if (src_width > 32768 || src_height > 32768 ||
+ dst_width > 32768 || dst_height > 32768) {
+ printf("Warning - size too large to test. Skipping\n");
+ return 0;
+ }
int i, j;
const int b = 0; // 128 to test for padding/stride.
int src_width_uv = (Abs(src_width) + 1) >> 1;
@@ -274,8 +284,8 @@ static int TestFilter_16(int src_width, int src_height,
// The following adjustments in dimensions ensure the scale factor will be
// exactly achieved.
// 2 is chroma subsample
-#define DX(x, nom, denom) static_cast<int>((Abs(x) / nom / 2) * nom * 2)
-#define SX(x, nom, denom) static_cast<int>((x / nom / 2) * denom * 2)
+#define DX(x, nom, denom) static_cast<int>(((Abs(x) / nom + 1) / 2) * nom * 2)
+#define SX(x, nom, denom) static_cast<int>(((x / nom + 1) / 2) * denom * 2)
#define TEST_FACTOR1(name, filter, nom, denom, max_diff) \
TEST_F(LibYUVScaleTest, ScaleDownBy##name##_##filter) { \
« unit_test/scale_argb_test.cc ('K') | « unit_test/scale_argb_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698