Index: source/convert_from.cc |
diff --git a/source/convert_from.cc b/source/convert_from.cc |
index f81054c20d2c696d221f0dcc8b28abe1435e5441..d285e98d6b2d25452eacabeb9c4bd5c938b087f9 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. |