From: Sungjoong Kang Date: Thu, 30 Aug 2012 06:14:17 +0000 (+0900) Subject: hardware: samsung_slsi: libcamera2: fix thumbnail size bug X-Git-Tag: cm-10.1-M1~198 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2d5e6ec2fb1a3868f882d058ebd8286be0bb6185;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos5.git hardware: samsung_slsi: libcamera2: fix thumbnail size bug 1. default thumbnail size is 160*120 2. thumbnail size is decided from metadata Change-Id: Iac6faec295f8df0fc55a400431596077381807b4 Signed-off-by: Sungjoong Kang --- diff --git a/libcamera2/ExynosCamera2.cpp b/libcamera2/ExynosCamera2.cpp index 554dfef..dcf937e 100644 --- a/libcamera2/ExynosCamera2.cpp +++ b/libcamera2/ExynosCamera2.cpp @@ -411,8 +411,9 @@ status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info, static const int32_t jpegThumbnailSizes[] = { 160, 120, - 320, 240, - 640, 480 + 160, 160, + 160, 90, + 144, 96 }; ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, @@ -733,7 +734,7 @@ status_t ExynosCamera2::constructDefaultRequest( ADD_OR_SIZE(ANDROID_JPEG_QUALITY, &jpegQuality, 1); static const int32_t thumbnailSize[2] = { - 640, 480 + 160, 120 }; ADD_OR_SIZE(ANDROID_JPEG_THUMBNAIL_SIZE, thumbnailSize, 2); diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp index 4d472cd..612479e 100644 --- a/libcamera2/ExynosCameraHWInterface2.cpp +++ b/libcamera2/ExynosCameraHWInterface2.cpp @@ -853,7 +853,9 @@ ExynosCameraHWInterface2::ExynosCameraHWInterface2(int cameraId, camera2_device_ m_halDevice(dev), m_need_streamoff(0), m_nightCaptureCnt(0), - m_cameraId(cameraId) + m_cameraId(cameraId), + m_thumbNailW(160), + m_thumbNailH(120) { ALOGV("DEBUG(%s):", __FUNCTION__); int ret = 0; @@ -3673,15 +3675,37 @@ void ExynosCameraHWInterface2::m_streamThreadFunc(SignalDrivenThread * self) return; } +bool ExynosCameraHWInterface2::m_checkThumbnailSize(int w, int h) +{ + int sizeOfSupportList; + + //REAR Camera + if(this->getCameraId() == 0) { + sizeOfSupportList = sizeof(SUPPORT_THUMBNAIL_REAR_SIZE) / (sizeof(int)*2); + + for(int i = 0; i < sizeOfSupportList; i++) { + if((SUPPORT_THUMBNAIL_REAR_SIZE[i][0] == w) &&(SUPPORT_THUMBNAIL_REAR_SIZE[i][1] == h)) + return true; + } + + } + else { + sizeOfSupportList = sizeof(SUPPORT_THUMBNAIL_FRONT_SIZE) / (sizeof(int)*2); + + for(int i = 0; i < sizeOfSupportList; i++) { + if((SUPPORT_THUMBNAIL_FRONT_SIZE[i][0] == w) &&(SUPPORT_THUMBNAIL_FRONT_SIZE[i][1] == h)) + return true; + } + } + + return false; +} bool ExynosCameraHWInterface2::yuv2Jpeg(ExynosBuffer *yuvBuf, ExynosBuffer *jpegBuf, ExynosRect *rect) { unsigned char *addr; - int thumbW = 320; - int thumbH = 240; - ExynosJpegEncoderForCamera jpegEnc; bool ret = false; int res = 0; @@ -3714,14 +3738,29 @@ bool ExynosCameraHWInterface2::yuv2Jpeg(ExynosBuffer *yuvBuf, goto jpeg_encode_done; } - mExifInfo.enableThumb = true; + if((m_jpegMetadata.ctl.jpeg.thumbnailSize[0] != 0) && (m_jpegMetadata.ctl.jpeg.thumbnailSize[1] != 0)) { + mExifInfo.enableThumb = true; + if(!m_checkThumbnailSize(m_jpegMetadata.ctl.jpeg.thumbnailSize[0], m_jpegMetadata.ctl.jpeg.thumbnailSize[1])) { + //default value + m_thumbNailW = SUPPORT_THUMBNAIL_REAR_SIZE[0][0]; + m_thumbNailH = SUPPORT_THUMBNAIL_REAR_SIZE[0][1]; + } else { + m_thumbNailW = m_jpegMetadata.ctl.jpeg.thumbnailSize[0]; + m_thumbNailH = m_jpegMetadata.ctl.jpeg.thumbnailSize[1]; + } + + ALOGV("(%s) m_thumbNailW = %d, m_thumbNailH = %d", __FUNCTION__, m_thumbNailW, m_thumbNailH); + + } else { + mExifInfo.enableThumb = false; + } - if (jpegEnc.setThumbnailSize(thumbW, thumbH)) { - ALOGE("ERR(%s):jpegEnc.setThumbnailSize(%d, %d) fail", __FUNCTION__, thumbW, thumbH); + if (jpegEnc.setThumbnailSize(m_thumbNailW, m_thumbNailH)) { + ALOGE("ERR(%s):jpegEnc.setThumbnailSize(%d, %d) fail", __FUNCTION__, m_thumbNailH, m_thumbNailH); goto jpeg_encode_done; } - ALOGV("(%s):jpegEnc.setThumbnailSize(%d, %d) ", __FUNCTION__, thumbW, thumbH); + ALOGV("(%s):jpegEnc.setThumbnailSize(%d, %d) ", __FUNCTION__, m_thumbNailW, m_thumbNailW); if (jpegEnc.setThumbnailQuality(50)) { ALOGE("ERR(%s):jpegEnc.setThumbnailQuality fail", __FUNCTION__); goto jpeg_encode_done; @@ -4470,7 +4509,7 @@ void ExynosCameraHWInterface2::m_setExifFixedAttribute(void) char property[PROPERTY_VALUE_MAX]; //2 0th IFD TIFF Tags -#if 0 // STOPSHIP TODO(aray): remove before launch, but for now don't leak product data +#if 1 // STOPSHIP TODO(aray): remove before launch, but for now don't leak product data //3 Maker property_get("ro.product.brand", property, EXIF_DEF_MAKER); strncpy((char *)mExifInfo.maker, property, diff --git a/libcamera2/ExynosCameraHWInterface2.h b/libcamera2/ExynosCameraHWInterface2.h index c469f11..4bdc251 100644 --- a/libcamera2/ExynosCameraHWInterface2.h +++ b/libcamera2/ExynosCameraHWInterface2.h @@ -113,6 +113,21 @@ enum is_subscenario_id { ISS_SUB_END }; +int SUPPORT_THUMBNAIL_REAR_SIZE[][2] = +{ + {160, 120}, + {160, 90}, + {144, 96} +}; + +int SUPPORT_THUMBNAIL_FRONT_SIZE[][2] = +{ + {160, 120}, + {160, 160}, + {160, 90}, + {144, 96} +}; + typedef struct node_info { int fd; int width; @@ -493,6 +508,7 @@ class MainThread : public SignalDrivenThread { void initCameraMemory(ExynosBuffer *buf, int iMemoryNum); void DumpInfoWithShot(struct camera2_shot_ext * shot_ext); + bool m_checkThumbnailSize(int w, int h); bool yuv2Jpeg(ExynosBuffer *yuvBuf, ExynosBuffer *jpegBuf, ExynosRect *rect); @@ -586,6 +602,8 @@ class MainThread : public SignalDrivenThread { struct camera2_shot m_jpegMetadata; int m_nightCaptureCnt; int m_nightCaptureFrameCnt; + int m_thumbNailW; + int m_thumbNailH; }; }; // namespace android