From dde8ba70092cef3bb4a9dae8fab1ea903ea523fb Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Wed, 7 Dec 2016 10:16:16 -0800 Subject: [PATCH] ConvertFromI420: use halfstride instead of halfwidth BUG=libyuv:660 TEST=try bots R=kjellander@chromium.org Review URL: https://codereview.chromium.org/2554213003 . --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/convert_from.cc | 47 ++++++++++++++++++++++------------------ 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/README.chromium b/README.chromium index 34b61948a..9409caf9e 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 1635 +Version: 1636 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 298069979..ee286a30a 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1635 +#define LIBYUV_VERSION 1636 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/source/convert_from.cc b/source/convert_from.cc index f81054c20..d285e98d6 100644 --- a/source/convert_from.cc +++ b/source/convert_from.cc @@ -1094,53 +1094,58 @@ int ConvertFromI420(const uint8* y, } // TODO(fbarchard): Add M420. // Triplanar formats - // TODO(fbarchard): halfstride instead of halfwidth case FOURCC_I420: case FOURCC_YV12: { - int halfwidth = (width + 1) / 2; + dst_sample_stride = dst_sample_stride ? dst_sample_stride : width; + int halfstride = (dst_sample_stride + 1) / 2; int halfheight = (height + 1) / 2; uint8* dst_u; uint8* dst_v; if (format == FOURCC_YV12) { - dst_v = dst_sample + width * height; - dst_u = dst_v + halfwidth * halfheight; + dst_v = dst_sample + dst_sample_stride * height; + dst_u = dst_v + halfstride * halfheight; } else { - dst_u = dst_sample + width * height; - dst_v = dst_u + halfwidth * halfheight; + dst_u = dst_sample + dst_sample_stride * height; + dst_v = dst_u + halfstride * halfheight; } - r = I420Copy(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, - dst_u, halfwidth, dst_v, halfwidth, width, height); + r = I420Copy(y, y_stride, u, u_stride, v, v_stride, dst_sample, + dst_sample_stride, dst_u, halfstride, dst_v, halfstride, + width, height); break; } case FOURCC_I422: case FOURCC_YV16: { - int halfwidth = (width + 1) / 2; + dst_sample_stride = dst_sample_stride ? dst_sample_stride : width; + int halfstride = (dst_sample_stride + 1) / 2; uint8* dst_u; uint8* dst_v; if (format == FOURCC_YV16) { - dst_v = dst_sample + width * height; - dst_u = dst_v + halfwidth * height; + dst_v = dst_sample + dst_sample_stride * height; + dst_u = dst_v + halfstride * height; } else { - dst_u = dst_sample + width * height; - dst_v = dst_u + halfwidth * height; + dst_u = dst_sample + dst_sample_stride * height; + dst_v = dst_u + halfstride * height; } - r = I420ToI422(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, - dst_u, halfwidth, dst_v, halfwidth, width, height); + r = I420ToI422(y, y_stride, u, u_stride, v, v_stride, dst_sample, + dst_sample_stride, dst_u, halfstride, dst_v, halfstride, + width, height); break; } case FOURCC_I444: case FOURCC_YV24: { + dst_sample_stride = dst_sample_stride ? dst_sample_stride : width; uint8* dst_u; uint8* dst_v; if (format == FOURCC_YV24) { - dst_v = dst_sample + width * height; - dst_u = dst_v + width * height; + dst_v = dst_sample + dst_sample_stride * height; + dst_u = dst_v + dst_sample_stride * height; } else { - dst_u = dst_sample + width * height; - dst_v = dst_u + width * height; + dst_u = dst_sample + dst_sample_stride * height; + dst_v = dst_u + dst_sample_stride * height; } - r = I420ToI444(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, - dst_u, width, dst_v, width, width, height); + r = I420ToI444(y, y_stride, u, u_stride, v, v_stride, dst_sample, + dst_sample_stride, dst_u, dst_sample_stride, dst_v, + dst_sample_stride, width, height); break; } // Formats not supported - MJPG, biplanar, some rgb formats.