summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Huber <andih@google.com> 2011-05-05 15:51:25 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2011-05-05 15:51:25 -0700
commitbf0420ccd613dd5bfa47bc121e0cd09d17a68451 (patch)
tree3593ffe0205725a55dfc6282b8757f9d7b99defc
parentc44b8855775a5d781f8742e2312fe801959f1c97 (diff)
parenta161af9d1e2baa3f23e32634ef7dd9b4bbce9a6c (diff)
Merge "Color conversion now supports YUV420p->RGB565 conversion even if the width is odd."
-rw-r--r--media/libstagefright/colorconversion/ColorConverter.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/media/libstagefright/colorconversion/ColorConverter.cpp b/media/libstagefright/colorconversion/ColorConverter.cpp
index 3b92e5d0072e..4b72a53ac5bc 100644
--- a/media/libstagefright/colorconversion/ColorConverter.cpp
+++ b/media/libstagefright/colorconversion/ColorConverter.cpp
@@ -187,8 +187,7 @@ status_t ColorConverter::convertCbYCrY(
status_t ColorConverter::convertYUV420Planar(
const BitmapParams &src, const BitmapParams &dst) {
- if (!((dst.mWidth & 1) == 0
- && (src.mCropLeft & 1) == 0
+ if (!((src.mCropLeft & 1) == 0
&& src.cropWidth() == dst.cropWidth()
&& src.cropHeight() == dst.cropHeight())) {
return ERROR_UNSUPPORTED;
@@ -196,8 +195,8 @@ status_t ColorConverter::convertYUV420Planar(
uint8_t *kAdjustedClip = initClip();
- uint32_t *dst_ptr = (uint32_t *)dst.mBits
- + (dst.mCropTop * dst.mWidth + dst.mCropLeft) / 2;
+ uint16_t *dst_ptr = (uint16_t *)dst.mBits
+ + dst.mCropTop * dst.mWidth + dst.mCropLeft;
const uint8_t *src_y =
(const uint8_t *)src.mBits + src.mCropTop * src.mWidth + src.mCropLeft;
@@ -260,7 +259,11 @@ status_t ColorConverter::convertYUV420Planar(
| ((kAdjustedClip[g2] >> 2) << 5)
| (kAdjustedClip[b2] >> 3);
- dst_ptr[x / 2] = (rgb2 << 16) | rgb1;
+ if (x + 1 < src.cropWidth()) {
+ *(uint32_t *)(&dst_ptr[x]) = (rgb2 << 16) | rgb1;
+ } else {
+ dst_ptr[x] = rgb1;
+ }
}
src_y += src.mWidth;
@@ -270,7 +273,7 @@ status_t ColorConverter::convertYUV420Planar(
src_v += src.mWidth / 2;
}
- dst_ptr += dst.mWidth / 2;
+ dst_ptr += dst.mWidth;
}
return OK;