Commit dde8ba70 authored by Frank Barchard's avatar Frank Barchard

ConvertFromI420: use halfstride instead of halfwidth

BUG=libyuv:660
TEST=try bots
R=kjellander@chromium.org

Review URL: https://codereview.chromium.org/2554213003 .
parent 56b5bbb0
Name: libyuv Name: libyuv
URL: http://code.google.com/p/libyuv/ URL: http://code.google.com/p/libyuv/
Version: 1635 Version: 1636
License: BSD License: BSD
License File: LICENSE License File: LICENSE
......
...@@ -11,6 +11,6 @@ ...@@ -11,6 +11,6 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_ #ifndef INCLUDE_LIBYUV_VERSION_H_
#define INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 1635 #define LIBYUV_VERSION 1636
#endif // INCLUDE_LIBYUV_VERSION_H_ #endif // INCLUDE_LIBYUV_VERSION_H_
...@@ -1094,53 +1094,58 @@ int ConvertFromI420(const uint8* y, ...@@ -1094,53 +1094,58 @@ int ConvertFromI420(const uint8* y,
} }
// TODO(fbarchard): Add M420. // TODO(fbarchard): Add M420.
// Triplanar formats // Triplanar formats
// TODO(fbarchard): halfstride instead of halfwidth
case FOURCC_I420: case FOURCC_I420:
case FOURCC_YV12: { 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; int halfheight = (height + 1) / 2;
uint8* dst_u; uint8* dst_u;
uint8* dst_v; uint8* dst_v;
if (format == FOURCC_YV12) { if (format == FOURCC_YV12) {
dst_v = dst_sample + width * height; dst_v = dst_sample + dst_sample_stride * height;
dst_u = dst_v + halfwidth * halfheight; dst_u = dst_v + halfstride * halfheight;
} else { } else {
dst_u = dst_sample + width * height; dst_u = dst_sample + dst_sample_stride * height;
dst_v = dst_u + halfwidth * halfheight; dst_v = dst_u + halfstride * halfheight;
} }
r = I420Copy(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, r = I420Copy(y, y_stride, u, u_stride, v, v_stride, dst_sample,
dst_u, halfwidth, dst_v, halfwidth, width, height); dst_sample_stride, dst_u, halfstride, dst_v, halfstride,
width, height);
break; break;
} }
case FOURCC_I422: case FOURCC_I422:
case FOURCC_YV16: { 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_u;
uint8* dst_v; uint8* dst_v;
if (format == FOURCC_YV16) { if (format == FOURCC_YV16) {
dst_v = dst_sample + width * height; dst_v = dst_sample + dst_sample_stride * height;
dst_u = dst_v + halfwidth * height; dst_u = dst_v + halfstride * height;
} else { } else {
dst_u = dst_sample + width * height; dst_u = dst_sample + dst_sample_stride * height;
dst_v = dst_u + halfwidth * height; dst_v = dst_u + halfstride * height;
} }
r = I420ToI422(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, r = I420ToI422(y, y_stride, u, u_stride, v, v_stride, dst_sample,
dst_u, halfwidth, dst_v, halfwidth, width, height); dst_sample_stride, dst_u, halfstride, dst_v, halfstride,
width, height);
break; break;
} }
case FOURCC_I444: case FOURCC_I444:
case FOURCC_YV24: { case FOURCC_YV24: {
dst_sample_stride = dst_sample_stride ? dst_sample_stride : width;
uint8* dst_u; uint8* dst_u;
uint8* dst_v; uint8* dst_v;
if (format == FOURCC_YV24) { if (format == FOURCC_YV24) {
dst_v = dst_sample + width * height; dst_v = dst_sample + dst_sample_stride * height;
dst_u = dst_v + width * height; dst_u = dst_v + dst_sample_stride * height;
} else { } else {
dst_u = dst_sample + width * height; dst_u = dst_sample + dst_sample_stride * height;
dst_v = dst_u + width * height; dst_v = dst_u + dst_sample_stride * height;
} }
r = I420ToI444(y, y_stride, u, u_stride, v, v_stride, dst_sample, width, r = I420ToI444(y, y_stride, u, u_stride, v, v_stride, dst_sample,
dst_u, width, dst_v, width, width, height); dst_sample_stride, dst_u, dst_sample_stride, dst_v,
dst_sample_stride, width, height);
break; break;
} }
// Formats not supported - MJPG, biplanar, some rgb formats. // Formats not supported - MJPG, biplanar, some rgb formats.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment