diff --git a/README.chromium b/README.chromium index db3f6ff51..4ab691e3c 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1586 +Version: 1587 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index f1e6ae2f2..b460fdb12 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1586 +#define LIBYUV_VERSION 1587 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/unit_test/scale_argb_test.cc b/unit_test/scale_argb_test.cc index e85eb2a54..b1d47a2a3 100644 --- a/unit_test/scale_argb_test.cc +++ b/unit_test/scale_argb_test.cc @@ -28,6 +28,10 @@ static int ARGBTestFilter(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. int64 src_argb_plane_size = (Abs(src_width) + b * 2) * @@ -143,6 +147,10 @@ static int TileARGBScale(const uint8* src_argb, int src_stride_argb, static int ARGBClipTestFilter(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; + } + const int b = 128; int64 src_argb_plane_size = (Abs(src_width) + b * 2) * (Abs(src_height) + b * 2) * 4; diff --git a/unit_test/scale_test.cc b/unit_test/scale_test.cc index f31af80b3..7c9409631 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((Abs(x) / nom / 2) * nom * 2) -#define SX(x, nom, denom) static_cast((x / nom / 2) * denom * 2) +#define DX(x, nom, denom) static_cast(((Abs(x) / nom + 1) / 2) * nom * 2) +#define SX(x, nom, denom) static_cast(((x / nom + 1) / 2) * denom * 2) #define TEST_FACTOR1(name, filter, nom, denom, max_diff) \ TEST_F(LibYUVScaleTest, ScaleDownBy##name##_##filter) { \ diff --git a/unit_test/unit_test.h b/unit_test/unit_test.h index 009ff62ab..ae9c9c20b 100644 --- a/unit_test/unit_test.h +++ b/unit_test/unit_test.h @@ -28,6 +28,32 @@ static __inline int Abs(int v) { #define OFFBY 0 +// Scaling uses 16.16 fixed point to step thru the source image, so a +// maximum size of 32767.999 can be expressed. 32768 is valid because +// the step is 1 beyond the image but not used. +// Destination size is mainly constrained by valid scale step not the +// absolute size, so it may be possible to relax the destination size +// constraint. +// Source size is unconstrained for most specialized scalers. e.g. +// An image of 65536 scaled to half size would be valid. The test +// could be relaxed for special scale factors. +// If this test is removed, the scaling function should gracefully +// fail with a return code. The test could be changed to know that +// libyuv failed in a controlled way. + +static const int kMaxWidth = 32768; +static const int kMaxHeight = 32768; + +static inline bool SizeValid(int src_width, int src_height, + int dst_width, int dst_height) { + if (src_width > kMaxWidth || src_height > kMaxHeight || + dst_width > kMaxWidth || dst_height > kMaxHeight) { + printf("Warning - size too large to test. Skipping\n"); + return false; + } + return true; +} + #define align_buffer_page_end(var, size) \ uint8* var; \ uint8* var##_mem; \