summaryrefslogtreecommitdiffstats
path: root/media/jni
diff options
context:
space:
mode:
authorZhijun He <zhijunhe@google.com>2014-04-08 16:59:29 -0700
committerZhijun He <zhijunhe@google.com>2014-04-08 16:59:29 -0700
commit977ad8d26e701ed3902247852986d474e0e07f4d (patch)
treeb0e6a170ec78718b2a7b0f6c0bb7bdbee0eb3ca8 /media/jni
parente49ba1a3fc6c915a4ec6c526ecb25afe2dbd7f32 (diff)
downloadframeworks_base-977ad8d26e701ed3902247852986d474e0e07f4d.zip
frameworks_base-977ad8d26e701ed3902247852986d474e0e07f4d.tar.gz
frameworks_base-977ad8d26e701ed3902247852986d474e0e07f4d.tar.bz2
ImageReader: Fix raw buffer size calculation issue
Stride should be used to calculate the size rather than width. Change-Id: I01051fdf4dd2978d56b9998d8bcd542c50458f56
Diffstat (limited to 'media/jni')
-rw-r--r--media/jni/android_media_ImageReader.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/media/jni/android_media_ImageReader.cpp b/media/jni/android_media_ImageReader.cpp
index fcd425e..716418c 100644
--- a/media/jni/android_media_ImageReader.cpp
+++ b/media/jni/android_media_ImageReader.cpp
@@ -386,11 +386,12 @@ static void Image_getLockedBufferInfo(JNIEnv* env, CpuConsumer::LockedBuffer* bu
dataSize = buffer->stride * buffer->height;
break;
case HAL_PIXEL_FORMAT_Y16:
+ bytesPerPixel = 2;
// Single plane, 16bpp, strides are specified in pixels, not in bytes
ALOG_ASSERT(idx == 0, "Wrong index: %d", idx);
pData = buffer->data;
- dataSize = buffer->stride * buffer->height * 2;
+ dataSize = buffer->stride * buffer->height * bytesPerPixel;
break;
case HAL_PIXEL_FORMAT_BLOB:
// Used for JPEG data, height must be 1, width == size, single plane.
@@ -402,9 +403,10 @@ static void Image_getLockedBufferInfo(JNIEnv* env, CpuConsumer::LockedBuffer* bu
break;
case HAL_PIXEL_FORMAT_RAW_SENSOR:
// Single plane 16bpp bayer data.
+ bytesPerPixel = 2;
ALOG_ASSERT(idx == 0, "Wrong index: %d", idx);
pData = buffer->data;
- dataSize = buffer->width * 2 * buffer->height;
+ dataSize = buffer->stride * buffer->height * bytesPerPixel;
break;
case HAL_PIXEL_FORMAT_RGBA_8888:
case HAL_PIXEL_FORMAT_RGBX_8888: