summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Zhijun He <zhijunhe@google.com> 2016-02-17 17:24:04 -0800
committer Zhijun He <zhijunhe@google.com> 2016-02-17 17:24:04 -0800
commit9cc3f881df13583c93ca08668281413be6412414 (patch)
tree74149946b40550ea9a96e7e92a406e28078a3dd3
parent6f4de5b6a15c8122a6412270f8e5dc90f5122f93 (diff)
ImageReader: override the flexible YUV compatible formats
For gralloc HAL v0.1 devices, if the producer buffer format is NV21 or YV12, the returned flexFormat will be NV21 or YV12, which causes CTS failure for ImageReader decoder test. This change overrides the NV21 or YV12 image formats to HAL_PIXEL_FORMAT_YCbCr_420_888 for such case. With this, the ImageReader will work for the devices with older gralloc HAL implementations for HAL_PIXEL_FORMAT_YCbCr_420_888 compatible formats. Bug: 27136665 Change-Id: Ib4722f1f8dc20ad6561088755e4ab9d2e68f1b47
-rw-r--r--media/jni/android_media_ImageReader.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp
index 4ac62f57a719..9e90a19f00cc 100644
--- a/media/jni/android_media_ImageReader.cpp
+++ b/media/jni/android_media_ImageReader.cpp
@@ -1264,6 +1264,14 @@ static jint Image_getFormat(JNIEnv* env, jobject thiz, jint readerFormat)
int readerHalFormat = android_view_Surface_mapPublicFormatToHalFormat(
static_cast<PublicFormat>(readerFormat));
int32_t fmt = applyFormatOverrides(buffer->flexFormat, readerHalFormat);
+ // Override the image format to HAL_PIXEL_FORMAT_YCbCr_420_888 if the actual format is
+ // NV21 or YV12. This could only happen when the Gralloc HAL version is v0.1 thus doesn't
+ // support lockycbcr(), the CpuConsumer need to use the lock() method in the
+ // lockNextBuffer() call. For Gralloc HAL v0.2 or newer, this format should already be
+ // overridden to HAL_PIXEL_FORMAT_YCbCr_420_888 for the flexible YUV compatible formats.
+ if (fmt == HAL_PIXEL_FORMAT_YCrCb_420_SP || fmt == HAL_PIXEL_FORMAT_YV12) {
+ fmt = HAL_PIXEL_FORMAT_YCbCr_420_888;
+ }
PublicFormat publicFmt = android_view_Surface_mapHalFormatDataspaceToPublicFormat(
fmt, buffer->dataSpace);
return static_cast<jint>(publicFmt);