hardware: samsung_slsi: libcamera2: fix thumbnail size bug
authorSungjoong Kang <sj3.kang@samsung.com>
Thu, 30 Aug 2012 06:14:17 +0000 (15:14 +0900)
committerRebecca Schultz Zavin <rebecca@android.com>
Fri, 31 Aug 2012 22:56:11 +0000 (15:56 -0700)
1. default thumbnail size is 160*120
2. thumbnail size is decided from metadata

Change-Id: Iac6faec295f8df0fc55a400431596077381807b4
Signed-off-by: Sungjoong Kang <sj3.kang@samsung.com>
libcamera2/ExynosCamera2.cpp
libcamera2/ExynosCameraHWInterface2.cpp
libcamera2/ExynosCameraHWInterface2.h

index 554dfef613287c664110d731cc250ad4d18da2ba..dcf937e0ca70a2061da00664c4e1fcd0466fec16 100644 (file)
@@ -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);
 
index 4d472cdfe71011b9c1bc2ef5fe752ceaf42fcb26..612479ea569a9bd1a412ac68cde2ed60c4e4f6cf 100644 (file)
@@ -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,
index c469f1173180240bd1cf49ed98692c0c655309d7..4bdc251fafbde7c9f248ebe4068fc25d64b74c07 100644 (file)
@@ -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