diff options
author | Lajos Molnar <lajos@google.com> | 2015-01-22 19:03:31 -0800 |
---|---|---|
committer | Lajos Molnar <lajos@google.com> | 2015-01-28 17:34:23 -0800 |
commit | 4fb442617cdea52b11ed622b5cf0490337928ec1 (patch) | |
tree | 40ea6a51f57754d34954883b34ce43536e6575e9 /media/jni/android_media_ImageReader.cpp | |
parent | e0b5a3812269228070dabb792bc501ae435338bb (diff) | |
download | frameworks_base-4fb442617cdea52b11ed622b5cf0490337928ec1.zip frameworks_base-4fb442617cdea52b11ed622b5cf0490337928ec1.tar.gz frameworks_base-4fb442617cdea52b11ed622b5cf0490337928ec1.tar.bz2 |
ImageReader: add support for compatible flexYUV buffers
Bug: 17906609
Change-Id: Ia21aff632b9a92f4e391b3917a7774af46fd81a0
Diffstat (limited to 'media/jni/android_media_ImageReader.cpp')
-rw-r--r-- | media/jni/android_media_ImageReader.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp index 3f4736d..890b039 100644 --- a/media/jni/android_media_ImageReader.cpp +++ b/media/jni/android_media_ImageReader.cpp @@ -351,7 +351,7 @@ static void Image_getLockedBufferInfo(JNIEnv* env, CpuConsumer::LockedBuffer* bu int bytesPerPixel = 0; dataSize = ySize = cSize = cStride = 0; - int32_t fmt = buffer->format; + int32_t fmt = buffer->flexFormat; bool usingRGBAOverride = usingRGBAToJpegOverride(fmt, readerFormat); fmt = applyFormatOverrides(fmt, readerFormat); @@ -363,18 +363,21 @@ static void Image_getLockedBufferInfo(JNIEnv* env, CpuConsumer::LockedBuffer* bu (idx == 1) ? buffer->dataCb : buffer->dataCr; + // only map until last pixel if (idx == 0) { - dataSize = buffer->stride * buffer->height; + dataSize = buffer->stride * (buffer->height - 1) + buffer->width; } else { - dataSize = buffer->chromaStride * buffer->height / 2; + dataSize = buffer->chromaStride * (buffer->height / 2 - 1) + + buffer->chromaStep * (buffer->width / 2 - 1) + 1; } break; // NV21 case HAL_PIXEL_FORMAT_YCrCb_420_SP: cr = buffer->data + (buffer->stride * buffer->height); cb = cr + 1; - ySize = buffer->width * buffer->height; - cSize = buffer->width * buffer->height / 2; + // only map until last pixel + ySize = buffer->width * (buffer->height - 1) + buffer->width; + cSize = buffer->width * (buffer->height / 2 - 1) + buffer->width - 1; pData = (idx == 0) ? @@ -488,7 +491,7 @@ static jint Image_imageGetPixelStride(JNIEnv* env, CpuConsumer::LockedBuffer* bu int pixelStride = 0; ALOG_ASSERT(buffer != NULL, "buffer is NULL"); - int32_t fmt = buffer->format; + int32_t fmt = buffer->flexFormat; fmt = applyFormatOverrides(fmt, readerFormat); @@ -549,7 +552,7 @@ static jint Image_imageGetRowStride(JNIEnv* env, CpuConsumer::LockedBuffer* buff int rowStride = 0; ALOG_ASSERT(buffer != NULL, "buffer is NULL"); - int32_t fmt = buffer->format; + int32_t fmt = buffer->flexFormat; fmt = applyFormatOverrides(fmt, readerFormat); @@ -797,7 +800,7 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, return ACQUIRE_NO_BUFFERS; } - if (buffer->format == HAL_PIXEL_FORMAT_YCrCb_420_SP) { + if (buffer->flexFormat == HAL_PIXEL_FORMAT_YCrCb_420_SP) { jniThrowException(env, "java/lang/UnsupportedOperationException", "NV21 format is not supported by ImageReader"); return -1; @@ -826,8 +829,10 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, } int bufFmt = buffer->format; + if (imgReaderFmt == HAL_PIXEL_FORMAT_YCbCr_420_888) { + bufFmt = buffer->flexFormat; + } if (imgReaderFmt != bufFmt) { - if (imgReaderFmt == HAL_PIXEL_FORMAT_YCbCr_420_888 && (bufFmt == HAL_PIXEL_FORMAT_YCrCb_420_SP || bufFmt == HAL_PIXEL_FORMAT_YV12)) { // Special casing for when producer switches to a format compatible with flexible YUV @@ -849,7 +854,7 @@ static jint ImageReader_imageSetup(JNIEnv* env, jobject thiz, 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()); + bufFmt, ctx->getBufferFormat()); jniThrowException(env, "java/lang/UnsupportedOperationException", msg.string()); return -1; |