From 89b9c07b5bbcc2de25dd5f61c28de4575b4df996 Mon Sep 17 00:00:00 2001 From: Wei-Ta Chen Date: Fri, 7 Oct 2011 15:23:22 -0700 Subject: Avoid a possible overflow on setting the mosaic size. Log the size of the mosaic image before cropping, so as to help debug. Also, fix another issue that NV21 should be vertically subsmapled. Bug: 5412447 Change-Id: I20b0ef7fc1968517c63b7f599f04c8126adc0471 --- jni/feature_mos/src/mosaic/Blend.cpp | 1 + jni/feature_mos/src/mosaic/ImageUtils.cpp | 2 +- jni/feature_mos_jni.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'jni') diff --git a/jni/feature_mos/src/mosaic/Blend.cpp b/jni/feature_mos/src/mosaic/Blend.cpp index e8b30f3..1f3d93c 100644 --- a/jni/feature_mos/src/mosaic/Blend.cpp +++ b/jni/feature_mos/src/mosaic/Blend.cpp @@ -236,6 +236,7 @@ int Blend::runBlend(MosaicFrame **oframes, MosaicFrame **rframes, return BLEND_RET_ERROR; } + LOGI("Allocate mosaic image for blending - size: %d x %d", Mwidth, Mheight); YUVinfo *imgMos = YUVinfo::allocateImage(Mwidth, Mheight); if (imgMos == NULL) { diff --git a/jni/feature_mos/src/mosaic/ImageUtils.cpp b/jni/feature_mos/src/mosaic/ImageUtils.cpp index 2671dd4..6d0aac0 100644 --- a/jni/feature_mos/src/mosaic/ImageUtils.cpp +++ b/jni/feature_mos/src/mosaic/ImageUtils.cpp @@ -360,7 +360,7 @@ YUVinfo *YUVinfo::allocateImage(unsigned short width, unsigned short height) heightUV = height; // figure out how much space to hold all pixels... - int size = (((width * height * 32) >> 3) + 8); + int size = ((width * height * 3) + 8); unsigned char *position = 0; // VC 8 does not like calling free on yuv->Y.ptr since it is in diff --git a/jni/feature_mos_jni.cpp b/jni/feature_mos_jni.cpp index e3fdea5..e40b75a 100644 --- a/jni/feature_mos_jni.cpp +++ b/jni/feature_mos_jni.cpp @@ -628,7 +628,7 @@ JNIEXPORT jbyteArray JNICALL Java_com_android_camera_panorama_Mosaic_getFinalMos // Convert YVU to NV21 format in-place ImageType V = resultYVU+mosaicWidth*mosaicHeight; ImageType U = V+mosaicWidth*mosaicHeight; - for(int j=0; j