diff options
author | Zhijun He <zhijunhe@google.com> | 2013-09-18 08:00:02 -0700 |
---|---|---|
committer | Zhijun He <zhijunhe@google.com> | 2013-09-18 10:30:50 -0700 |
commit | 4eda9f5359347c11914e47f477535c9533674d32 (patch) | |
tree | 24907a83b37a6311307b67b80763bba0dc9c2920 | |
parent | c255a7113a6a6b058f1b3b5b128fba1d24bbd3d9 (diff) | |
download | frameworks_base-4eda9f5359347c11914e47f477535c9533674d32.zip frameworks_base-4eda9f5359347c11914e47f477535c9533674d32.tar.gz frameworks_base-4eda9f5359347c11914e47f477535c9533674d32.tar.bz2 |
ImageReader: disable NV21 support
Bug: 10787131
Change-Id: I5ff0a67144b5ec49eabde6129423a41c9597c2b8
-rw-r--r-- | media/java/android/media/ImageReader.java | 8 | ||||
-rw-r--r-- | media/jni/android_media_ImageReader.cpp | 11 |
2 files changed, 15 insertions, 4 deletions
diff --git a/media/java/android/media/ImageReader.java b/media/java/android/media/ImageReader.java index f9e48d4..1bd32c4 100644 --- a/media/java/android/media/ImageReader.java +++ b/media/java/android/media/ImageReader.java @@ -83,7 +83,8 @@ public class ImageReader implements AutoCloseable { * @param format * The format of the Image that this reader will produce. This * must be one of the {@link android.graphics.ImageFormat} or - * {@link android.graphics.PixelFormat} constants. + * {@link android.graphics.PixelFormat} constants. Note that + * not all formats is supported, like ImageFormat.NV21. * @param maxImages * The maximum number of images the user will want to * access simultaneously. This should be as small as possible to limit @@ -116,6 +117,11 @@ public class ImageReader implements AutoCloseable { "Maximum outstanding image count must be at least 1"); } + if (format == ImageFormat.NV21) { + throw new IllegalArgumentException( + "NV21 format is not supported"); + } + mNumPlanes = getNumPlanesFromFormat(); nativeInit(new WeakReference<ImageReader>(this), width, height, format, maxImages); diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index a03dbf3..0030dbd 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -721,13 +721,18 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, return ACQUIRE_NO_BUFFERS; } + if (buffer->format == HAL_PIXEL_FORMAT_YCrCb_420_SP) { + jniThrowException(env, "java/lang/UnsupportedOperationException", + "NV21 format is not supported by ImageReader"); + return -1; + } + // Check if the left-top corner of the crop rect is origin, we currently assume this point is // zero, will revist this once this assumption turns out problematic. Point lt = buffer->crop.leftTop(); if (lt.x != 0 || lt.y != 0) { - ALOGE("crop left: %d, top = %d", lt.x, lt.y); - jniThrowException(env, "java/lang/UnsupportedOperationException", - "crop left top corner need to at origin"); + jniThrowExceptionFmt(env, "java/lang/UnsupportedOperationException", + "crop left top corner [%d, %d] need to be at origin", lt.x, lt.y); return -1; } |