From 49bbc1b4f368e7e30fe5f12663b2334a5213752e Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Tue, 27 Aug 2013 16:32:22 +0000 Subject: [PATCH] Move vertical scaler to common code. BUG=260 TEST=unittests build/run R=ryanpetrie@google.com Review URL: https://webrtc-codereview.appspot.com/2123004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@773 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- Android.mk | 1 + README.chromium | 2 +- include/libyuv/version.h | 2 +- libyuv.gyp | 1 + source/scale_argb.cc | 73 +--------------------------- source/scale_common.cc | 100 +++++++++++++++++++++++++++++++++++++++ source/scale_row.h | 36 ++++++++++++++ 7 files changed, 141 insertions(+), 74 deletions(-) create mode 100644 source/scale_common.cc create mode 100644 source/scale_row.h diff --git a/Android.mk b/Android.mk index 513a1961b..29b61c81e 100644 --- a/Android.mk +++ b/Android.mk @@ -27,6 +27,7 @@ LOCAL_SRC_FILES := \ source/row_posix.cc \ source/scale.cc \ source/scale_argb.cc \ + source/scale_common.cc \ source/scale_mips.cc \ source/video_common.cc diff --git a/README.chromium b/README.chromium index 8d4b002d3..1b3e43c9d 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 772 +Version: 773 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 9bcfe2687..3b08ba14a 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 772 +#define LIBYUV_VERSION 773 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/libyuv.gyp b/libyuv.gyp index ad6b78b5c..73d258fec 100644 --- a/libyuv.gyp +++ b/libyuv.gyp @@ -108,6 +108,7 @@ 'source/scale.cc', 'source/scale_argb.cc', 'source/scale_argb_neon.cc', + 'source/scale_common.cc', 'source/scale_mips.cc', 'source/scale_neon.cc', 'source/video_common.cc', diff --git a/source/scale_argb.cc b/source/scale_argb.cc index 8b8463800..81a45ae5a 100644 --- a/source/scale_argb.cc +++ b/source/scale_argb.cc @@ -16,6 +16,7 @@ #include "libyuv/cpu_id.h" #include "libyuv/planar_functions.h" // For CopyARGB #include "libyuv/row.h" +#include "../source/scale_row.h" #ifdef __cplusplus namespace libyuv { @@ -893,78 +894,6 @@ static void ScaleARGBDownEven(int src_width, int src_height, } } -// Scale ARGB vertically with bilinear interpolation. -// TODO(fbarchard): Use this for all formats. -static void ScaleARGBBilinearVertical(int src_height, - int dst_width, int dst_height, - int src_stride, int dst_stride, - const uint8* src_argb, uint8* dst_argb, - int x, int y, int dy, - int bpp, FilterMode filtering) { - int dst_widthx4 = dst_width * bpp; - src_argb += (x >> 16) * bpp; - assert(src_height > 0); - assert(dst_width > 0); - assert(dst_height > 0); - void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, - ptrdiff_t src_stride, int dst_width, int source_y_fraction) = - InterpolateRow_C; -#if defined(HAS_INTERPOLATEROW_SSE2) - if (TestCpuFlag(kCpuHasSSE2) && dst_widthx4 >= 16) { - InterpolateRow = InterpolateRow_Any_SSE2; - if (IS_ALIGNED(dst_widthx4, 16)) { - InterpolateRow = InterpolateRow_Unaligned_SSE2; - if (IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride, 16) && - IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride, 16)) { - InterpolateRow = InterpolateRow_SSE2; - } - } - } -#endif -#if defined(HAS_INTERPOLATEROW_SSSE3) - if (TestCpuFlag(kCpuHasSSSE3) && dst_widthx4 >= 16) { - InterpolateRow = InterpolateRow_Any_SSSE3; - if (IS_ALIGNED(dst_widthx4, 16)) { - InterpolateRow = InterpolateRow_Unaligned_SSSE3; - if (IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride, 16) && - IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride, 16)) { - InterpolateRow = InterpolateRow_SSSE3; - } - } - } -#endif -#if defined(HAS_INTERPOLATEROW_NEON) - if (TestCpuFlag(kCpuHasNEON) && dst_widthx4 >= 16) { - InterpolateRow = InterpolateRow_Any_NEON; - if (IS_ALIGNED(dst_widthx4, 16)) { - InterpolateRow = InterpolateRow_NEON; - } - } -#endif -#if defined(HAS_INTERPOLATEROWS_MIPS_DSPR2) - if (TestCpuFlag(kCpuHasMIPS_DSPR2) && dst_widthx4 >= 4 && - IS_ALIGNED(src_argb, 4) && IS_ALIGNED(src_stride, 4) && - IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride, 4)) { - InterpolateRow = InterpolateRow_Any_MIPS_DSPR2; - if (IS_ALIGNED(dst_widthx4, 4)) { - InterpolateRow = InterpolateRow_MIPS_DSPR2; - } - } -#endif - const int max_y = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0; - for (int j = 0; j < dst_height; ++j) { - if (y > max_y) { - y = max_y; - } - int yi = y >> 16; - int yf = filtering ? ((y >> 8) & 255) : 0; - const uint8* src = src_argb + yi * src_stride; - InterpolateRow(dst_argb, src, src_stride, dst_widthx4, yf); - dst_argb += dst_stride; - y += dy; - } -} - // Scale ARGB down with bilinear interpolation. static void ScaleARGBBilinearDown(int src_height, int dst_width, int dst_height, diff --git a/source/scale_common.cc b/source/scale_common.cc new file mode 100644 index 000000000..66e910072 --- /dev/null +++ b/source/scale_common.cc @@ -0,0 +1,100 @@ +/* + * Copyright 2011 The LibYuv Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "libyuv/scale.h" + +#include +#include + +#include "libyuv/cpu_id.h" +#include "libyuv/planar_functions.h" // For CopyARGB +#include "libyuv/row.h" +#include "../source/scale_row.h" + +#ifdef __cplusplus +namespace libyuv { +extern "C" { +#endif + +// Scale ARGB vertically with bilinear interpolation. +void ScaleARGBBilinearVertical(int src_height, + int dst_width, int dst_height, + int src_stride, int dst_stride, + const uint8* src_argb, uint8* dst_argb, + int x, int y, int dy, + int bpp, FilterMode filtering) { + int dst_widthx4 = dst_width * bpp; + src_argb += (x >> 16) * bpp; + assert(src_height > 0); + assert(dst_width > 0); + assert(dst_height > 0); + void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb, + ptrdiff_t src_stride, int dst_width, int source_y_fraction) = + InterpolateRow_C; +#if defined(HAS_INTERPOLATEROW_SSE2) + if (TestCpuFlag(kCpuHasSSE2) && dst_widthx4 >= 16) { + InterpolateRow = InterpolateRow_Any_SSE2; + if (IS_ALIGNED(dst_widthx4, 16)) { + InterpolateRow = InterpolateRow_Unaligned_SSE2; + if (IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride, 16)) { + InterpolateRow = InterpolateRow_SSE2; + } + } + } +#endif +#if defined(HAS_INTERPOLATEROW_SSSE3) + if (TestCpuFlag(kCpuHasSSSE3) && dst_widthx4 >= 16) { + InterpolateRow = InterpolateRow_Any_SSSE3; + if (IS_ALIGNED(dst_widthx4, 16)) { + InterpolateRow = InterpolateRow_Unaligned_SSSE3; + if (IS_ALIGNED(src_argb, 16) && IS_ALIGNED(src_stride, 16) && + IS_ALIGNED(dst_argb, 16) && IS_ALIGNED(dst_stride, 16)) { + InterpolateRow = InterpolateRow_SSSE3; + } + } + } +#endif +#if defined(HAS_INTERPOLATEROW_NEON) + if (TestCpuFlag(kCpuHasNEON) && dst_widthx4 >= 16) { + InterpolateRow = InterpolateRow_Any_NEON; + if (IS_ALIGNED(dst_widthx4, 16)) { + InterpolateRow = InterpolateRow_NEON; + } + } +#endif +#if defined(HAS_INTERPOLATEROWS_MIPS_DSPR2) + if (TestCpuFlag(kCpuHasMIPS_DSPR2) && dst_widthx4 >= 4 && + IS_ALIGNED(src_argb, 4) && IS_ALIGNED(src_stride, 4) && + IS_ALIGNED(dst_argb, 4) && IS_ALIGNED(dst_stride, 4)) { + InterpolateRow = InterpolateRow_Any_MIPS_DSPR2; + if (IS_ALIGNED(dst_widthx4, 4)) { + InterpolateRow = InterpolateRow_MIPS_DSPR2; + } + } +#endif + const int max_y = (src_height > 1) ? ((src_height - 1) << 16) - 1 : 0; + for (int j = 0; j < dst_height; ++j) { + if (y > max_y) { + y = max_y; + } + int yi = y >> 16; + int yf = filtering ? ((y >> 8) & 255) : 0; + const uint8* src = src_argb + yi * src_stride; + InterpolateRow(dst_argb, src, src_stride, dst_widthx4, yf); + dst_argb += dst_stride; + y += dy; + } +} + +#ifdef __cplusplus +} // extern "C" +} // namespace libyuv +#endif diff --git a/source/scale_row.h b/source/scale_row.h new file mode 100644 index 000000000..cda2dad65 --- /dev/null +++ b/source/scale_row.h @@ -0,0 +1,36 @@ +/* + * Copyright 2011 The LibYuv Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "libyuv/scale.h" + +#include +#include + +#include "libyuv/cpu_id.h" +#include "libyuv/planar_functions.h" // For CopyARGB +#include "libyuv/row.h" + +#ifdef __cplusplus +namespace libyuv { +extern "C" { +#endif + +// Scale ARGB vertically with bilinear interpolation. +void ScaleARGBBilinearVertical(int src_height, + int dst_width, int dst_height, + int src_stride, int dst_stride, + const uint8* src_argb, uint8* dst_argb, + int x, int y, int dy, + int bpp, FilterMode filtering); + +#ifdef __cplusplus +} // extern "C" +} // namespace libyuv +#endif