From a6b8e0da516350c5395ffcfebd5c49f717c84bdd Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Mon, 9 Dec 2013 19:56:16 +0000 Subject: [PATCH] Reduce filter to None if 1 pixel wide. BUG=none TESTED=talk media_unittest YuvScalerTest.TestScaleUp1x6OptInt R=tpsiaki@google.com Review URL: https://webrtc-codereview.appspot.com/5449005 git-svn-id: http://libyuv.googlecode.com/svn/trunk@906 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/scale_common.cc | 11 ++++++++--- unit_test/unit_test.cc | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.chromium b/README.chromium index a8092917c..e0559ad5a 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 905 +Version: 906 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 7e23d9cc3..41807190f 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 905 +#define LIBYUV_VERSION 906 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/scale_common.cc b/source/scale_common.cc index ba8507795..ee6a33629 100644 --- a/source/scale_common.cc +++ b/source/scale_common.cc @@ -566,6 +566,11 @@ FilterMode ScaleFilterReduce(int src_width, int src_height, if (dst_height == src_height || dst_height * 3 == src_height) { filtering = kFilterLinear; } + // TODO(fbarchard): Remove 1 pixel wide filter restriction, which is to + // avoid reading 2 pixels horizontally that causes memory exception. + if (src_width == 1) { + filtering = kFilterNone; + } } if (filtering == kFilterLinear) { if (src_width == 1) { @@ -606,14 +611,14 @@ void ScaleSlope(int src_width, int src_height, // Scale step for bilinear sampling renders last pixel once for upsample. if (dst_width <= Abs(src_width)) { *dx = FixedDiv(Abs(src_width), dst_width); - *x = CENTERSTART(*dx, -32768); + *x = CENTERSTART(*dx, -32768); // Subtract 0.5 (32768) to center filter. } else if (dst_width > 1) { *dx = FIXEDDIV1(Abs(src_width), dst_width); *x = 0; } if (dst_height <= src_height) { *dy = FixedDiv(src_height, dst_height); - *y = CENTERSTART(*dy, -32768); // 32768 = -0.5 to center bilinear. + *y = CENTERSTART(*dy, -32768); // Subtract 0.5 (32768) to center filter. } else if (dst_height > 1) { *dy = FIXEDDIV1(src_height, dst_height); *y = 0; @@ -622,7 +627,7 @@ void ScaleSlope(int src_width, int src_height, // Scale step for bilinear sampling renders last pixel once for upsample. if (dst_width <= Abs(src_width)) { *dx = FixedDiv(Abs(src_width), dst_width); - *x = CENTERSTART(*dx, -32768); + *x = CENTERSTART(*dx, -32768); // Subtract 0.5 (32768) to center filter. } else if (dst_width > 1) { *dx = FIXEDDIV1(Abs(src_width), dst_width); *x = 0; diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc index d1bbffa4a..118a1e466 100644 --- a/unit_test/unit_test.cc +++ b/unit_test/unit_test.cc @@ -19,8 +19,8 @@ #define BENCHMARK_ITERATIONS 1 libyuvTest::libyuvTest() : rotate_max_w_(128), rotate_max_h_(128), - benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(33), - benchmark_height_(17) { + benchmark_iterations_(BENCHMARK_ITERATIONS), benchmark_width_(32), + benchmark_height_(24) { const char* repeat = getenv("LIBYUV_REPEAT"); if (repeat) { benchmark_iterations_ = atoi(repeat); // NOLINT