From: Ruben Brunk Date: Thu, 2 Oct 2014 00:00:21 +0000 (-0700) Subject: Fix JPEG thumbnail size check. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=17071e43a448f45e864bc41049528ceb82f21a37;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung_slsi_exynos5.git Fix JPEG thumbnail size check. Bug: 17590892 Change-Id: I72363eca10fc5c2fb6eb76934bc908b42b2741db --- diff --git a/libcamera2/ExynosCamera2.cpp b/libcamera2/ExynosCamera2.cpp index c7cdd48..35bb9f5 100644 --- a/libcamera2/ExynosCamera2.cpp +++ b/libcamera2/ExynosCamera2.cpp @@ -38,6 +38,21 @@ 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)); diff --git a/libcamera2/ExynosCamera2.h b/libcamera2/ExynosCamera2.h index e9973b4..60e088e 100644 --- a/libcamera2/ExynosCamera2.h +++ b/libcamera2/ExynosCamera2.h @@ -28,6 +28,9 @@ * */ +#ifndef EXYNOS_CAMERA_2_H +#define EXYNOS_CAMERA_2_H + #include #include #include @@ -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 diff --git a/libcamera2/ExynosCameraHWInterface2.cpp b/libcamera2/ExynosCameraHWInterface2.cpp index 4d65914..8fce907 100644 --- a/libcamera2/ExynosCameraHWInterface2.cpp +++ b/libcamera2/ExynosCameraHWInterface2.cpp @@ -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)) diff --git a/libcamera2/ExynosCameraHWInterface2.h b/libcamera2/ExynosCameraHWInterface2.h index 8085643..a8e3348 100644 --- a/libcamera2/ExynosCameraHWInterface2.h +++ b/libcamera2/ExynosCameraHWInterface2.h @@ -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,