summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2014-05-22 06:08:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-22 06:08:56 +0000
commit94520c74608bfcd61ff987410a8018d87b75d734 (patch)
tree57cbe1577329df9ccb0a20f26deada5f70952c8b /media
parent521d8cdae0be5c7d33715e0fa7b5b85367c5de09 (diff)
parentfeb50af361e4305a25758966b6b5df2738c00259 (diff)
downloadframeworks_base-94520c74608bfcd61ff987410a8018d87b75d734.zip
frameworks_base-94520c74608bfcd61ff987410a8018d87b75d734.tar.gz
frameworks_base-94520c74608bfcd61ff987410a8018d87b75d734.tar.bz2
Merge "camera2: Add HAL1 compatibility shim skeleton."
Diffstat (limited to 'media')
-rw-r--r--media/jni/android_media_ImageReader.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp
index 7a86811..36cfb0f 100644
--- a/media/jni/android_media_ImageReader.cpp
+++ b/media/jni/android_media_ImageReader.cpp
@@ -764,21 +764,30 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz,
return -1;
}
- if (ctx->getBufferFormat() != buffer->format) {
- // Return the buffer to the queue.
- consumer->unlockBuffer(*buffer);
- ctx->returnLockedBuffer(buffer);
-
- // Throw exception
- ALOGE("Producer output buffer format: 0x%x, ImageReader configured format: 0x%x",
- buffer->format, ctx->getBufferFormat());
- String8 msg;
- msg.appendFormat("The producer output buffer format 0x%x doesn't "
- "match the ImageReader's configured buffer format 0x%x.",
- buffer->format, ctx->getBufferFormat());
- jniThrowException(env, "java/lang/UnsupportedOperationException",
- msg.string());
- return -1;
+ int imgReaderFmt = ctx->getBufferFormat();
+ int bufFmt = buffer->format;
+ if (imgReaderFmt != bufFmt) {
+ // Special casing for when producer switches format
+ if (imgReaderFmt == HAL_PIXEL_FORMAT_YCbCr_420_888 && bufFmt ==
+ HAL_PIXEL_FORMAT_YCrCb_420_SP) {
+ ctx->setBufferFormat(HAL_PIXEL_FORMAT_YCrCb_420_SP);
+ ALOGV("%s: Overriding NV21 to YUV_420_888.", __FUNCTION__);
+ } else {
+ // Return the buffer to the queue.
+ consumer->unlockBuffer(*buffer);
+ ctx->returnLockedBuffer(buffer);
+
+ // Throw exception
+ ALOGE("Producer output buffer format: 0x%x, ImageReader configured format: 0x%x",
+ buffer->format, ctx->getBufferFormat());
+ String8 msg;
+ msg.appendFormat("The producer output buffer format 0x%x doesn't "
+ "match the ImageReader's configured buffer format 0x%x.",
+ buffer->format, ctx->getBufferFormat());
+ jniThrowException(env, "java/lang/UnsupportedOperationException",
+ msg.string());
+ return -1;
+ }
}
// Set SurfaceImage instance member variables
Image_setBuffer(env, image, buffer);