aboutsummaryrefslogtreecommitdiff
path: root/source/convert_from.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2016-12-07 10:16:16 -0800
committerFrank Barchard <fbarchard@google.com>2016-12-07 10:16:16 -0800
commitdde8ba70092cef3bb4a9dae8fab1ea903ea523fb (patch)
tree32fae8b9bcd4e3ef0af9cd236c7c6292cc081ce9 /source/convert_from.cc
parent56b5bbb0be6368c50dca5e120a3d72379e1ffbad (diff)
downloadlibyuv-dde8ba70092cef3bb4a9dae8fab1ea903ea523fb.tar.gz
ConvertFromI420: use halfstride instead of halfwidth
BUG=libyuv:660 TEST=try bots R=kjellander@chromium.org Review URL: https://codereview.chromium.org/2554213003 .
Diffstat (limited to 'source/convert_from.cc')
-rw-r--r--source/convert_from.cc47
1 files changed, 26 insertions, 21 deletions
diff --git a/source/convert_from.cc b/source/convert_from.cc
index f81054c2..d285e98d 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.