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

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: comments updated Created 4 years, 7 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
« no previous file with comments | « unit_test/scale_argb_test.cc ('k') | unit_test/unit_test.h » ('j') | 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..7c9409631f34d2a17acccceeac3e99a7ce59ef3b 100644
--- a/unit_test/scale_test.cc
+++ b/unit_test/scale_test.cc
@@ -25,6 +25,10 @@ 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 (!SizeValid(src_width, src_height, dst_width, dst_height)) {
+ 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 +152,10 @@ 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 (!SizeValid(src_width, src_height, dst_width, dst_height)) {
+ 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 +282,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) { \
« no previous file with comments | « unit_test/scale_argb_test.cc ('k') | unit_test/unit_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698