From 45b9ef0f6a404fe416d7a04bbd6da13037f3716b Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Fri, 16 Dec 2011 03:34:09 +0000 Subject: [PATCH] scale call copyplane in planarfunctions BUG=none TEST=none Review URL: http://webrtc-codereview.appspot.com/335002 git-svn-id: http://libyuv.googlecode.com/svn/trunk@112 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/planar_functions.h | 5 +++++ source/planar_functions.cc | 7 ++++--- source/row_win.cc | 2 +- source/scale.cc | 31 ++----------------------------- 5 files changed, 13 insertions(+), 34 deletions(-) diff --git a/README.chromium b/README.chromium index 6ad8ed20a..e82f2d815 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 110 +Version: 112 License: BSD License File: LICENSE diff --git a/include/libyuv/planar_functions.h b/include/libyuv/planar_functions.h index 2ef10c4fd..e96442328 100644 --- a/include/libyuv/planar_functions.h +++ b/include/libyuv/planar_functions.h @@ -189,6 +189,11 @@ int ARGBCopy(const uint8* src_argb, int src_stride_argb, uint8* dst_argb, int dst_stride_argb, int width, int height); +// Copy a plane of data +void CopyPlane(const uint8* src_y, int src_stride_y, + uint8* dst_y, int dst_stride_y, + int width, int height); + #ifdef __cplusplus } // extern "C" } // namespace libyuv diff --git a/source/planar_functions.cc b/source/planar_functions.cc index 3a067b9ba..5b92f8640 100644 --- a/source/planar_functions.cc +++ b/source/planar_functions.cc @@ -211,9 +211,10 @@ void CopyRow_C(const uint8* src, uint8* dst, int count) { memcpy(dst, src, count); } -static void CopyPlane(const uint8* src_y, int src_stride_y, - uint8* dst_y, int dst_stride_y, - int width, int height) { +// Copy a plane of data +void CopyPlane(const uint8* src_y, int src_stride_y, + uint8* dst_y, int dst_stride_y, + int width, int height) { void (*CopyRow)(const uint8* src, uint8* dst, int width); #if defined(HAS_COPYROW_SSE2) if (TestCpuFlag(kCpuHasSSE2) && diff --git a/source/row_win.cc b/source/row_win.cc index e744f9149..139a80420 100644 --- a/source/row_win.cc +++ b/source/row_win.cc @@ -867,7 +867,7 @@ __asm { por xmm0, xmm1 pshuflw xmm0, xmm0, 0x1b // swap words pshufhw xmm0, xmm0, 0x1b - pshufd xmm0, xmm0, 0x4e + pshufd xmm0, xmm0, 0x4e // swap qwords movdqa [edx], xmm0 lea edx, [edx + 16] sub ecx, 16 diff --git a/source/scale.cc b/source/scale.cc index 15daa7f65..7b301ca5a 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -14,6 +14,7 @@ #include #include "libyuv/cpu_id.h" +#include "libyuv/planar_functions.h" // For CopyPlane #include "row.h" #ifdef __cplusplus @@ -3570,33 +3571,6 @@ static void ScalePlaneDown(int src_width, int src_height, } } -/** - * Copy plane, no scaling - * - * This simply copies the given plane without scaling. - * The current implementation is ~115 times faster - * compared to the reference implementation. - * - */ -static void CopyPlane(int src_width, int src_height, - int dst_width, int dst_height, - int src_stride, int dst_stride, - const uint8* src_ptr, uint8* dst_ptr) { - if (src_stride == src_width && dst_stride == dst_width) { - // All contiguous, so can use REALLY fast path. - memcpy(dst_ptr, src_ptr, src_width * src_height); - } else { - // Not all contiguous; must copy scanlines individually - const uint8* src = src_ptr; - uint8* dst = dst_ptr; - for (int i = 0; i < src_height; ++i) { - memcpy(dst, src, src_width); - dst += dst_stride; - src += src_stride; - } - } -} - static void ScalePlane(const uint8* src, int src_stride, int src_width, int src_height, uint8* dst, int dst_stride, @@ -3606,8 +3580,7 @@ static void ScalePlane(const uint8* src, int src_stride, // For example, all the 1/2 scalings will use ScalePlaneDown2() if (dst_width == src_width && dst_height == src_height) { // Straight copy. - CopyPlane(src_width, src_height, dst_width, dst_height, src_stride, - dst_stride, src, dst); + CopyPlane(src, src_stride, dst, dst_stride, dst_width, dst_height); } else if (dst_width <= src_width && dst_height <= src_height) { // Scale down. if (use_ref) {