From 5ca144d2140755ab668916335cd927e5583dbb42 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Thu, 14 Mar 2013 17:57:47 +0000 Subject: [PATCH] NV12 to/from I420 coalesce rows for Y and UV independently. BUG=197 TESTED=*NV12*_Opt Review URL: https://webrtc-codereview.appspot.com/1201004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@607 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/convert.cc | 16 ++++++++++++++-- source/convert_from.cc | 9 +++++---- source/row_any.cc | 1 - 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/README.chromium b/README.chromium index 8dda4a4df..95f53e026 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 606 +Version: 607 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 5c44d101d..66ab48d2f 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 606 +#define LIBYUV_VERSION 607 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/convert.cc b/source/convert.cc index 8f63fe7a5..20b642b7c 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -381,8 +381,21 @@ static int X420ToI420(const uint8* src_y, dst_stride_u = -dst_stride_u; dst_stride_v = -dst_stride_v; } - + // Coalesce contiguous rows. int halfwidth = (width + 1) >> 1; + int halfheight = (height + 1) >> 1; + if (src_stride_y0 == width && + src_stride_y1 == width && + dst_stride_y == width) { + width = width * height; + height = 1; + } + if (src_stride_uv == width && + dst_stride_u * 2 == width && + dst_stride_v * 2 == width) { + halfwidth = halfwidth * halfheight; + halfheight = 1; + } void (*SplitUVRow)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix) = SplitUVRow_C; #if defined(HAS_SPLITUVROW_SSE2) @@ -437,7 +450,6 @@ static int X420ToI420(const uint8* src_y, } } - int halfheight = (height + 1) >> 1; for (int y = 0; y < halfheight; ++y) { // Copy a row of UV. SplitUVRow(src_uv, dst_u, dst_v, halfwidth); diff --git a/source/convert_from.cc b/source/convert_from.cc index a087e886a..f33702370 100644 --- a/source/convert_from.cc +++ b/source/convert_from.cc @@ -465,12 +465,13 @@ int I420ToNV12(const uint8* src_y, int src_stride_y, int halfwidth = (width + 1) >> 1; int halfheight = (height + 1) >> 1; if (src_stride_y == width && - src_stride_u * 2 == width && - src_stride_v * 2 == width && - dst_stride_y == width && - dst_stride_uv == width) { + dst_stride_y == width) { width = width * height; height = 1; + } + if (src_stride_u * 2 == width && + src_stride_v * 2 == width && + dst_stride_uv == width) { halfwidth = halfwidth * halfheight; halfheight = 1; } diff --git a/source/row_any.cc b/source/row_any.cc index cc801cfae..5a3bf4cd6 100644 --- a/source/row_any.cc +++ b/source/row_any.cc @@ -19,7 +19,6 @@ extern "C" { // TODO(fbarchard): Consider 'any' functions handling any quantity of pixels. // TODO(fbarchard): Consider 'any' functions handling odd alignment. - // YUV to RGB does multiple of 8 with SIMD and remainder with C. #define YANY(NAMEANY, I420TORGB_SIMD, I420TORGB_C, UV_SHIFT, BPP, MASK) \ void NAMEANY(const uint8* y_buf, \