Fix JPEG thumbnail size check.
authorRuben Brunk <rubenbrunk@google.com>
Thu, 2 Oct 2014 00:00:21 +0000 (17:00 -0700)
committerRuben Brunk <rubenbrunk@google.com>
Thu, 2 Oct 2014 18:54:51 +0000 (11:54 -0700)
Bug: 17590892

Change-Id: I72363eca10fc5c2fb6eb76934bc908b42b2741db

libcamera2/ExynosCamera2.cpp
libcamera2/ExynosCamera2.h
libcamera2/ExynosCameraHWInterface2.cpp
libcamera2/ExynosCameraHWInterface2.h

index c7cdd48c076e1c1997c9b0b6a568595474cd8d9e..35bb9f518d6f772a492c07662ef31e72d71a0725 100644 (file)
 
 namespace android {
 
+int32_t SUPPORT_THUMBNAIL_REAR_SIZE[3][2] =
+{
+    {160, 120},
+    {160, 90},
+    {144, 96}
+};
+
+int32_t SUPPORT_THUMBNAIL_FRONT_SIZE[4][2] =
+{
+    {160, 120},
+    {160, 160},
+    {160, 90},
+    {144, 96}
+};
+
 class Sensor {
 public:
     /**
@@ -527,13 +542,23 @@ status_t ExynosCamera2::constructStaticInfo(camera_metadata_t **info,
 
     // android.jpeg
 
-    static const int32_t jpegThumbnailSizes[] = {
-            160, 120,
-            160, 160,
-            160, 90,
-            144, 96,
-              0, 0
-    };
+    size_t sizeOfThumbnailList = (cameraId) ? sizeof(SUPPORT_THUMBNAIL_FRONT_SIZE) /
+            sizeof(int32_t) : sizeof(SUPPORT_THUMBNAIL_REAR_SIZE) / sizeof(int32_t);
+
+    // Copy sizes from front or back camera
+    int32_t jpegThumbnailSizes[sizeOfThumbnailList + 2];
+
+    if (cameraId) {
+        memcpy(jpegThumbnailSizes, SUPPORT_THUMBNAIL_FRONT_SIZE,
+                sizeof(int32_t) * sizeOfThumbnailList);
+    } else {
+        memcpy(jpegThumbnailSizes, SUPPORT_THUMBNAIL_REAR_SIZE,
+                sizeof(int32_t) * sizeOfThumbnailList);
+    }
+
+    // Always include 0,0 size in list
+    jpegThumbnailSizes[sizeOfThumbnailList] = 0;
+    jpegThumbnailSizes[sizeOfThumbnailList + 1] = 0;
 
     ADD_OR_SIZE(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
             jpegThumbnailSizes, sizeof(jpegThumbnailSizes)/sizeof(int32_t));
index e9973b4c357f30857b600237b461197c923266a0..60e088eec55dd39ee64f45f171f7a924d5489956 100644 (file)
@@ -28,6 +28,9 @@
  *
  */
 
+#ifndef EXYNOS_CAMERA_2_H
+#define EXYNOS_CAMERA_2_H
+
 #include <hardware/camera2.h>
 #include <camera/Camera.h>
 #include <camera/CameraParameters.h>
@@ -36,6 +39,9 @@
 
 namespace android {
 
+extern int32_t SUPPORT_THUMBNAIL_REAR_SIZE[3][2];
+extern int32_t SUPPORT_THUMBNAIL_FRONT_SIZE[4][2];
+
 struct ExynosCamera2Info
 {
 public:
@@ -99,3 +105,5 @@ public:
     int     m_cameraId;
 };
 }
+
+#endif
index 4d6591467580b2ec5dfe97d98c63fcd5068ceecc..8fce907870b2de6cff2ea1151c8813357a3687b0 100644 (file)
@@ -4662,7 +4662,7 @@ bool ExynosCameraHWInterface2::m_checkThumbnailSize(int w, int h)
 
     //REAR Camera
     if(this->getCameraId() == 0) {
-        sizeOfSupportList = sizeof(SUPPORT_THUMBNAIL_REAR_SIZE) / (sizeof(int)*2);
+        sizeOfSupportList = sizeof(SUPPORT_THUMBNAIL_REAR_SIZE) / (sizeof(int32_t)*2);
 
         for(int i = 0; i < sizeOfSupportList; i++) {
             if((SUPPORT_THUMBNAIL_REAR_SIZE[i][0] == w) &&(SUPPORT_THUMBNAIL_REAR_SIZE[i][1] == h))
@@ -4671,7 +4671,7 @@ bool ExynosCameraHWInterface2::m_checkThumbnailSize(int w, int h)
 
     }
     else {
-        sizeOfSupportList = sizeof(SUPPORT_THUMBNAIL_FRONT_SIZE) / (sizeof(int)*2);
+        sizeOfSupportList = sizeof(SUPPORT_THUMBNAIL_FRONT_SIZE) / (sizeof(int32_t)*2);
 
         for(int i = 0; i < sizeOfSupportList; i++) {
             if((SUPPORT_THUMBNAIL_FRONT_SIZE[i][0] == w) &&(SUPPORT_THUMBNAIL_FRONT_SIZE[i][1] == h))
index 80856437d72882e6057d8eb1c562480b99409877..a8e334885e1665a3f4b19a276281144053905db5 100644 (file)
@@ -150,21 +150,6 @@ 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}
-};
-
 enum is_set_flash_command_state {
     IS_FLASH_STATE_NONE = 0,
     IS_FLASH_STATE_ON = 1,