From cf17f0cd2b3f6d7eb16b576759c8b266d5d47ec0 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Thu, 26 Dec 2013 20:00:54 +0000 Subject: [PATCH] Scale exit early if simple version used BUG=none TEST=none R=tpsiaki@google.com Review URL: https://webrtc-codereview.appspot.com/6319004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@921 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/scale.cc | 53 +++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/README.chromium b/README.chromium index c9b59234a..0e7cf6b76 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 920 +Version: 921 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 505411db4..d6c9db355 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 920 +#define LIBYUV_VERSION 921 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/scale.cc b/source/scale.cc index 4f19742a2..36bc9c084 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -407,41 +407,38 @@ static void ScalePlaneBox(int src_width, int src_height, src, dst); dst += dst_stride; } - } else { - SIMD_ALIGNED(uint16 row[kMaxStride]); - void (*ScaleAddRows)(const uint8* src_ptr, ptrdiff_t src_stride, - uint16* dst_ptr, int src_width, int src_height) = - ScaleAddRows_C; - void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx, - const uint16* src_ptr, uint8* dst_ptr); - if (dx & 0xffff) { - ScaleAddCols = ScaleAddCols2_C; - } else { - ScaleAddCols = ScaleAddCols1_C; - } + return; + } + // TODO(fbarchard): Remove kMaxStride limitation. + SIMD_ALIGNED(uint16 row[kMaxStride]); + void (*ScaleAddRows)(const uint8* src_ptr, ptrdiff_t src_stride, + uint16* dst_ptr, int src_width, int src_height) = ScaleAddRows_C; + void (*ScaleAddCols)(int dst_width, int boxheight, int x, int dx, + const uint16* src_ptr, uint8* dst_ptr) = + (dx & 0xffff) ? ScaleAddCols2_C: ScaleAddCols1_C; #if defined(HAS_SCALEADDROWS_SSE2) - if (TestCpuFlag(kCpuHasSSE2) && + if (TestCpuFlag(kCpuHasSSE2) && #ifdef AVOID_OVERREAD - IS_ALIGNED(src_width, 16) && + IS_ALIGNED(src_width, 16) && #endif - IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(src_stride, 16)) { - ScaleAddRows = ScaleAddRows_SSE2; - } + IS_ALIGNED(src_ptr, 16) && IS_ALIGNED(src_stride, 16)) { + ScaleAddRows = ScaleAddRows_SSE2; + } #endif - for (int j = 0; j < dst_height; ++j) { - int iy = y >> 16; - const uint8* src = src_ptr + iy * src_stride; - y += dy; - if (y > (src_height << 16)) { - y = (src_height << 16); - } - int boxheight = (y >> 16) - iy; - ScaleAddRows(src, src_stride, row, src_width, boxheight); - ScaleAddCols(dst_width, boxheight, x, dx, row, dst_ptr); - dst_ptr += dst_stride; + for (int j = 0; j < dst_height; ++j) { + int iy = y >> 16; + const uint8* src = src_ptr + iy * src_stride; + y += dy; + if (y > (src_height << 16)) { + y = (src_height << 16); } + int boxheight = (y >> 16) - iy; + ScaleAddRows(src, src_stride, row, src_width, boxheight); + ScaleAddCols(dst_width, boxheight, x, dx, row, dst_ptr); + dst_ptr += dst_stride; } + } // Scale plane down with bilinear interpolation.