summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2014-09-29 19:47:25 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-29 19:47:25 +0000
commit48ca9cd9f852fb38504bd045007ab88102d6fae2 (patch)
tree077cc16aac01548f50b080609e1d85cbec97f951 /media
parent7fe33786d68639eea277885877076382ea7e55d6 (diff)
parent6c583ef7ea34a2ac2eb490237908587bcbddb0e3 (diff)
downloadframeworks_base-48ca9cd9f852fb38504bd045007ab88102d6fae2.zip
frameworks_base-48ca9cd9f852fb38504bd045007ab88102d6fae2.tar.gz
frameworks_base-48ca9cd9f852fb38504bd045007ab88102d6fae2.tar.bz2
am 6c583ef7: am c6c331ee: am 174355d6: am d0f17b98: am 6f34ad71: Merge "camera2: Fix native ImageReader test segfaults." into lmp-dev
* commit '6c583ef7ea34a2ac2eb490237908587bcbddb0e3': camera2: Fix native ImageReader test segfaults.
Diffstat (limited to 'media')
-rw-r--r--media/jni/android_media_ImageReader.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp
index a734774..f4eb459 100644
--- a/media/jni/android_media_ImageReader.cpp
+++ b/media/jni/android_media_ImageReader.cpp
@@ -286,13 +286,17 @@ static int Image_getPixelFormat(JNIEnv* env, int format)
return format;
}
-static uint32_t Image_getJpegSize(CpuConsumer::LockedBuffer* buffer)
+static uint32_t Image_getJpegSize(CpuConsumer::LockedBuffer* buffer, bool usingRGBAOverride)
{
ALOG_ASSERT(buffer != NULL, "Input buffer is NULL!!!");
uint32_t size = 0;
uint32_t width = buffer->width;
uint8_t* jpegBuffer = buffer->data;
+ if (usingRGBAOverride) {
+ width *= 4;
+ }
+
// First check for JPEG transport header at the end of the buffer
uint8_t* header = jpegBuffer + (width - sizeof(struct camera3_jpeg_blob));
struct camera3_jpeg_blob *blob = (struct camera3_jpeg_blob*)(header);
@@ -317,11 +321,15 @@ static uint32_t Image_getJpegSize(CpuConsumer::LockedBuffer* buffer)
return size;
}
+static bool usingRGBAToJpegOverride(int32_t bufferFormat, int32_t readerCtxFormat) {
+ return readerCtxFormat == HAL_PIXEL_FORMAT_BLOB && bufferFormat == HAL_PIXEL_FORMAT_RGBA_8888;
+}
+
static int32_t applyFormatOverrides(int32_t bufferFormat, int32_t readerCtxFormat)
{
// Using HAL_PIXEL_FORMAT_RGBA_8888 gralloc buffers containing JPEGs to get around SW
// write limitations for some platforms (b/17379185).
- if (readerCtxFormat == HAL_PIXEL_FORMAT_BLOB && bufferFormat == HAL_PIXEL_FORMAT_RGBA_8888) {
+ if (usingRGBAToJpegOverride(bufferFormat, readerCtxFormat)) {
return HAL_PIXEL_FORMAT_BLOB;
}
return bufferFormat;
@@ -345,6 +353,7 @@ static void Image_getLockedBufferInfo(JNIEnv* env, CpuConsumer::LockedBuffer* bu
dataSize = ySize = cSize = cStride = 0;
int32_t fmt = buffer->format;
+ bool usingRGBAOverride = usingRGBAToJpegOverride(fmt, readerFormat);
fmt = applyFormatOverrides(fmt, readerFormat);
switch (fmt) {
case HAL_PIXEL_FORMAT_YCbCr_420_888:
@@ -416,7 +425,7 @@ static void Image_getLockedBufferInfo(JNIEnv* env, CpuConsumer::LockedBuffer* bu
ALOG_ASSERT(buffer->height == 1, "JPEG should has height value %d", buffer->height);
pData = buffer->data;
- dataSize = Image_getJpegSize(buffer);
+ dataSize = Image_getJpegSize(buffer, usingRGBAOverride);
break;
case HAL_PIXEL_FORMAT_RAW_SENSOR:
// Single plane 16bpp bayer data.
@@ -912,7 +921,7 @@ static jobject Image_getByteBuffer(JNIEnv* env, jobject thiz, int idx, int reade
if (size > static_cast<uint32_t>(INT32_MAX)) {
// Byte buffer have 'int capacity', so check the range
jniThrowExceptionFmt(env, "java/lang/IllegalStateException",
- "Size too large for bytebuffer capacity " PRIu32, size);
+ "Size too large for bytebuffer capacity %" PRIu32, size);
return NULL;
}