mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-06 16:56:55 +08:00
If image sizes are greater than 32768, fixed point stepping will overflow an int. This CL changes the max size to 32768 and disables the test if larger.
BUG=libyuv:590 TESTED=LIBYUV_FLAGS=-1 LIBYUV_WIDTH=8192 LIBYUV_HEIGHT=16 out/Release/libyuv_unittest --gtest_filter=* R=harryjin@google.com Review URL: https://codereview.chromium.org/1947783002 .
This commit is contained in:
parent
6924590212
commit
07cb92272f
@ -1,6 +1,6 @@
|
|||||||
Name: libyuv
|
Name: libyuv
|
||||||
URL: http://code.google.com/p/libyuv/
|
URL: http://code.google.com/p/libyuv/
|
||||||
Version: 1586
|
Version: 1587
|
||||||
License: BSD
|
License: BSD
|
||||||
License File: LICENSE
|
License File: LICENSE
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,6 @@
|
|||||||
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
#ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT
|
||||||
#define INCLUDE_LIBYUV_VERSION_H_
|
#define INCLUDE_LIBYUV_VERSION_H_
|
||||||
|
|
||||||
#define LIBYUV_VERSION 1586
|
#define LIBYUV_VERSION 1587
|
||||||
|
|
||||||
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
#endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT
|
||||||
|
|||||||
@ -28,6 +28,10 @@ static int ARGBTestFilter(int src_width, int src_height,
|
|||||||
int dst_width, int dst_height,
|
int dst_width, int dst_height,
|
||||||
FilterMode f, int benchmark_iterations,
|
FilterMode f, int benchmark_iterations,
|
||||||
int disable_cpu_flags, int benchmark_cpu_info) {
|
int disable_cpu_flags, int benchmark_cpu_info) {
|
||||||
|
if (!SizeValid(src_width, src_height, dst_width, dst_height)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
const int b = 0; // 128 to test for padding/stride.
|
const int b = 0; // 128 to test for padding/stride.
|
||||||
int64 src_argb_plane_size = (Abs(src_width) + b * 2) *
|
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,
|
static int ARGBClipTestFilter(int src_width, int src_height,
|
||||||
int dst_width, int dst_height,
|
int dst_width, int dst_height,
|
||||||
FilterMode f, int benchmark_iterations) {
|
FilterMode f, int benchmark_iterations) {
|
||||||
|
if (!SizeValid(src_width, src_height, dst_width, dst_height)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const int b = 128;
|
const int b = 128;
|
||||||
int64 src_argb_plane_size = (Abs(src_width) + b * 2) *
|
int64 src_argb_plane_size = (Abs(src_width) + b * 2) *
|
||||||
(Abs(src_height) + b * 2) * 4;
|
(Abs(src_height) + b * 2) * 4;
|
||||||
|
|||||||
@ -25,6 +25,10 @@ static int TestFilter(int src_width, int src_height,
|
|||||||
int dst_width, int dst_height,
|
int dst_width, int dst_height,
|
||||||
FilterMode f, int benchmark_iterations,
|
FilterMode f, int benchmark_iterations,
|
||||||
int disable_cpu_flags, int benchmark_cpu_info) {
|
int disable_cpu_flags, int benchmark_cpu_info) {
|
||||||
|
if (!SizeValid(src_width, src_height, dst_width, dst_height)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
const int b = 0; // 128 to test for padding/stride.
|
const int b = 0; // 128 to test for padding/stride.
|
||||||
int src_width_uv = (Abs(src_width) + 1) >> 1;
|
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,
|
static int TestFilter_16(int src_width, int src_height,
|
||||||
int dst_width, int dst_height,
|
int dst_width, int dst_height,
|
||||||
FilterMode f, int benchmark_iterations) {
|
FilterMode f, int benchmark_iterations) {
|
||||||
|
if (!SizeValid(src_width, src_height, dst_width, dst_height)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int i, j;
|
int i, j;
|
||||||
const int b = 0; // 128 to test for padding/stride.
|
const int b = 0; // 128 to test for padding/stride.
|
||||||
int src_width_uv = (Abs(src_width) + 1) >> 1;
|
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
|
// The following adjustments in dimensions ensure the scale factor will be
|
||||||
// exactly achieved.
|
// exactly achieved.
|
||||||
// 2 is chroma subsample
|
// 2 is chroma subsample
|
||||||
#define DX(x, nom, denom) static_cast<int>((Abs(x) / nom / 2) * nom * 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 / 2) * denom * 2)
|
#define SX(x, nom, denom) static_cast<int>(((x / nom + 1) / 2) * denom * 2)
|
||||||
|
|
||||||
#define TEST_FACTOR1(name, filter, nom, denom, max_diff) \
|
#define TEST_FACTOR1(name, filter, nom, denom, max_diff) \
|
||||||
TEST_F(LibYUVScaleTest, ScaleDownBy##name##_##filter) { \
|
TEST_F(LibYUVScaleTest, ScaleDownBy##name##_##filter) { \
|
||||||
|
|||||||
@ -28,6 +28,32 @@ static __inline int Abs(int v) {
|
|||||||
|
|
||||||
#define OFFBY 0
|
#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) \
|
#define align_buffer_page_end(var, size) \
|
||||||
uint8* var; \
|
uint8* var; \
|
||||||
uint8* var##_mem; \
|
uint8* var##_mem; \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user