From 90a36b29d3ffac9ecaa239191c7106c9993dc093 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Fri, 3 Jan 2014 00:34:55 +0000 Subject: [PATCH] Use 64 bit fixed point for scaling columns if source is 32k or wider. BUG=302 TESTED=out\release\libyuv_unittest --gtest_filter=*I*ToI* R=tpsiaki@google.com Review URL: https://webrtc-codereview.appspot.com/6509004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@942 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/scale_row.h | 2 ++ include/libyuv/version.h | 2 +- source/scale.cc | 11 ++++++++--- source/scale_common.cc | 24 ++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/README.chromium b/README.chromium index d677519fb..499366e12 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 941 +Version: 942 License: BSD License File: LICENSE diff --git a/include/libyuv/scale_row.h b/include/libyuv/scale_row.h index fddb15215..e1b0333cd 100644 --- a/include/libyuv/scale_row.h +++ b/include/libyuv/scale_row.h @@ -112,6 +112,8 @@ void ScaleColsUp2_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int, int); void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx); +void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr, + int dst_width, int x, int dx); void ScaleRowDown38_C(const uint8* src_ptr, ptrdiff_t /* src_stride */, uint8* dst, int dst_width); void ScaleRowDown38_3_Box_C(const uint8* src_ptr, diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 7a2eabfd9..4e6894ed4 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 941 +#define LIBYUV_VERSION 942 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/scale.cc b/source/scale.cc index 5bc6c9b7c..1f135aee3 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -511,9 +511,11 @@ void ScalePlaneBilinearDown(int src_width, int src_height, #endif void (*ScaleFilterCols)(uint8* dst_ptr, const uint8* src_ptr, - int dst_width, int x, int dx) = ScaleFilterCols_C; + int dst_width, int x, int dx) = + (src_width >= 32768) ? ScaleFilterCols64_C : ScaleFilterCols_C; + #if defined(HAS_SCALEFILTERCOLS_SSSE3) - if (TestCpuFlag(kCpuHasSSSE3)) { + if (TestCpuFlag(kCpuHasSSSE3) && src_width < 32768) { ScaleFilterCols = ScaleFilterCols_SSSE3; } #endif @@ -614,8 +616,11 @@ void ScalePlaneBilinearUp(int src_width, int src_height, void (*ScaleFilterCols)(uint8* dst_ptr, const uint8* src_ptr, int dst_width, int x, int dx) = filtering ? ScaleFilterCols_C : ScaleCols_C; + if (filtering && src_width >= 32768) { + ScaleFilterCols = ScaleFilterCols64_C; + } #if defined(HAS_SCALEFILTERCOLS_SSSE3) - if (filtering && TestCpuFlag(kCpuHasSSSE3)) { + if (filtering && TestCpuFlag(kCpuHasSSSE3) && src_width < 32768) { ScaleFilterCols = ScaleFilterCols_SSSE3; } #endif diff --git a/source/scale_common.cc b/source/scale_common.cc index 5d0fcb8b9..6cc5ff8cb 100644 --- a/source/scale_common.cc +++ b/source/scale_common.cc @@ -229,6 +229,30 @@ void ScaleFilterCols_C(uint8* dst_ptr, const uint8* src_ptr, dst_ptr[0] = BLENDER(a, b, x & 0xffff); } } + +void ScaleFilterCols64_C(uint8* dst_ptr, const uint8* src_ptr, + int dst_width, int x32, int dx) { + int64 x = static_cast(x32); + for (int j = 0; j < dst_width - 1; j += 2) { + int64 xi = x >> 16; + int a = src_ptr[xi]; + int b = src_ptr[xi + 1]; + dst_ptr[0] = BLENDER(a, b, x & 0xffff); + x += dx; + xi = x >> 16; + a = src_ptr[xi]; + b = src_ptr[xi + 1]; + dst_ptr[1] = BLENDER(a, b, x & 0xffff); + x += dx; + dst_ptr += 2; + } + if (dst_width & 1) { + int64 xi = x >> 16; + int a = src_ptr[xi]; + int b = src_ptr[xi + 1]; + dst_ptr[0] = BLENDER(a, b, x & 0xffff); + } +} #undef BLENDER void ScaleRowDown38_C(const uint8* src_ptr, ptrdiff_t /* src_stride */,