1 /* 2 * Copyright Samsung Electronics Co.,LTD. 3 * Copyright (C) 2010 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 #ifndef EXYNOS_EXIF_H_ 18 #define EXYNOS_EXIF_H_ 19 20 #include <math.h> 21 22 #define EXIF_LOG2(x) (log((double)(x)) / log(2.0)) 23 #define APEX_FNUM_TO_APERTURE(x) (((EXIF_LOG2((double)(x)) * 200) + 0.5)/100) 24 #define APEX_EXPOSURE_TO_SHUTTER(x) ((x) >= 1 ? \ 25 (int)(-(EXIF_LOG2((double)(x)) + 0.5)) : \ 26 (int)(-(EXIF_LOG2((double)(x)) - 0.5))) 27 #define APEX_ISO_TO_FILMSENSITIVITY(x) ((int)(EXIF_LOG2((x) / 3.125) + 0.5)) 28 29 #define NUM_SIZE 2 30 #define IFD_SIZE 12 31 #define OFFSET_SIZE 4 32 33 /* Add any additional writeExifIfd() in sections, increase buffer size */ 34 #define NUM_0TH_IFD_TIFF 11 35 #define NUM_0TH_IFD_EXIF 24 36 #define NUM_0TH_IFD_GPS 10 37 #define NUM_1TH_IFD_TIFF 9 38 39 /* Type */ 40 #define EXIF_TYPE_BYTE 1 41 #define EXIF_TYPE_ASCII 2 42 #define EXIF_TYPE_SHORT 3 43 #define EXIF_TYPE_LONG 4 44 #define EXIF_TYPE_RATIONAL 5 45 #define EXIF_TYPE_UNDEFINED 7 46 #define EXIF_TYPE_SLONG 9 47 #define EXIF_TYPE_SRATIONAL 10 48 49 #define EXIF_FILE_SIZE 28800 50 51 /* 0th IFD TIFF Tags */ 52 #define EXIF_TAG_IMAGE_WIDTH 0x0100 53 #define EXIF_TAG_IMAGE_HEIGHT 0x0101 54 #define EXIF_TAG_MAKE 0x010f 55 #define EXIF_TAG_MODEL 0x0110 56 #define EXIF_TAG_ORIENTATION 0x0112 57 #define EXIF_TAG_SOFTWARE 0x0131 58 #define EXIF_TAG_DATE_TIME 0x0132 59 #define EXIF_TAG_SUBSEC_TIME 0x9290 60 #define EXIF_TAG_YCBCR_POSITIONING 0x0213 61 #define EXIF_TAG_EXIF_IFD_POINTER 0x8769 62 #define EXIF_TAG_GPS_IFD_POINTER 0x8825 63 64 /* 0th IFD Exif Private Tags */ 65 #define EXIF_TAG_EXPOSURE_TIME 0x829A 66 #define EXIF_TAG_FNUMBER 0x829D 67 #define EXIF_TAG_EXPOSURE_PROGRAM 0x8822 68 #define EXIF_TAG_ISO_SPEED_RATING 0x8827 69 #define EXIF_TAG_EXIF_VERSION 0x9000 70 #define EXIF_TAG_DATE_TIME_ORG 0x9003 71 #define EXIF_TAG_SUBSEC_TIME_ORG 0x9291 72 #define EXIF_TAG_DATE_TIME_DIGITIZE 0x9004 73 #define EXIF_TAG_SUBSEC_TIME_DIGITIZE 0x9292 74 #define EXIF_TAG_SHUTTER_SPEED 0x9201 75 #define EXIF_TAG_APERTURE 0x9202 76 #define EXIF_TAG_BRIGHTNESS 0x9203 77 #define EXIF_TAG_EXPOSURE_BIAS 0x9204 78 #define EXIF_TAG_MAX_APERTURE 0x9205 79 #define EXIF_TAG_METERING_MODE 0x9207 80 #define EXIF_TAG_FLASH 0x9209 81 #define EXIF_TAG_FOCAL_LENGTH 0x920A 82 #define EXIF_TAG_USER_COMMENT 0x9286 83 #define EXIF_TAG_COLOR_SPACE 0xA001 84 #define EXIF_TAG_PIXEL_X_DIMENSION 0xA002 85 #define EXIF_TAG_PIXEL_Y_DIMENSION 0xA003 86 #define EXIF_TAG_EXPOSURE_MODE 0xA402 87 #define EXIF_TAG_WHITE_BALANCE 0xA403 88 #define EXIF_TAG_SCENCE_CAPTURE_TYPE 0xA406 89 90 /* 0th IFD GPS Info Tags */ 91 #define EXIF_TAG_GPS_VERSION_ID 0x0000 92 #define EXIF_TAG_GPS_LATITUDE_REF 0x0001 93 #define EXIF_TAG_GPS_LATITUDE 0x0002 94 #define EXIF_TAG_GPS_LONGITUDE_REF 0x0003 95 #define EXIF_TAG_GPS_LONGITUDE 0x0004 96 #define EXIF_TAG_GPS_ALTITUDE_REF 0x0005 97 #define EXIF_TAG_GPS_ALTITUDE 0x0006 98 #define EXIF_TAG_GPS_TIMESTAMP 0x0007 99 #define EXIF_TAG_GPS_PROCESSING_METHOD 0x001B 100 #define EXIF_TAG_GPS_DATESTAMP 0x001D 101 102 /* 1th IFD TIFF Tags */ 103 #define EXIF_TAG_COMPRESSION_SCHEME 0x0103 104 #define EXIF_TAG_X_RESOLUTION 0x011A 105 #define EXIF_TAG_Y_RESOLUTION 0x011B 106 #define EXIF_TAG_RESOLUTION_UNIT 0x0128 107 #define EXIF_TAG_JPEG_INTERCHANGE_FORMAT 0x0201 108 #define EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN 0x0202 109 110 typedef enum { 111 EXIF_ORIENTATION_UP = 1, 112 EXIF_ORIENTATION_90 = 6, 113 EXIF_ORIENTATION_180 = 3, 114 EXIF_ORIENTATION_270 = 8, 115 } ExifOrientationType; 116 117 typedef enum { 118 EXIF_SCENE_STANDARD, 119 EXIF_SCENE_LANDSCAPE, 120 EXIF_SCENE_PORTRAIT, 121 EXIF_SCENE_NIGHT, 122 } CamExifSceneCaptureType; 123 124 typedef enum { 125 EXIF_METERING_UNKNOWN, 126 EXIF_METERING_AVERAGE, 127 EXIF_METERING_CENTER, 128 EXIF_METERING_SPOT, 129 EXIF_METERING_MULTISPOT, 130 EXIF_METERING_PATTERN, 131 EXIF_METERING_PARTIAL, 132 EXIF_METERING_OTHER = 255, 133 } CamExifMeteringModeType; 134 135 typedef enum { 136 EXIF_EXPOSURE_AUTO, 137 EXIF_EXPOSURE_MANUAL, 138 EXIF_EXPOSURE_AUTO_BRACKET, 139 } CamExifExposureModeType; 140 141 typedef enum { 142 EXIF_WB_AUTO, 143 EXIF_WB_MANUAL, 144 } CamExifWhiteBalanceType; 145 146 /* Values */ 147 #define EXIF_DEF_MAKER "SAMSUNG" 148 #define EXIF_DEF_MODEL "SAMSUNG" 149 #define EXIF_DEF_SOFTWARE "SAMSUNG" 150 #define EXIF_DEF_EXIF_VERSION "0220" 151 #define EXIF_DEF_USERCOMMENTS "User comments" 152 153 #define EXIF_DEF_YCBCR_POSITIONING 1 /* centered */ 154 #define EXIF_DEF_FNUMBER_NUM 26 /* 2.6 */ 155 #define EXIF_DEF_FNUMBER_DEN 10 156 #define EXIF_DEF_EXPOSURE_PROGRAM 3 /* aperture priority */ 157 #define EXIF_DEF_FOCAL_LEN_NUM 278 /* 2.78mm */ 158 #define EXIF_DEF_FOCAL_LEN_DEN 100 159 #define EXIF_DEF_FLASH 0 /* O: off, 1: on*/ 160 #define EXIF_DEF_COLOR_SPACE 1 161 #define EXIF_DEF_EXPOSURE_MODE EXIF_EXPOSURE_AUTO 162 #define EXIF_DEF_APEX_DEN 100 163 164 #define EXIF_DEF_COMPRESSION 6 165 #define EXIF_DEF_RESOLUTION_NUM 72 166 #define EXIF_DEF_RESOLUTION_DEN 1 167 #define EXIF_DEF_RESOLUTION_UNIT 2 /* inches */ 168 169 typedef struct { 170 uint32_t num; 171 uint32_t den; 172 } rational_t; 173 174 typedef struct { 175 int32_t num; 176 int32_t den; 177 } srational_t; 178 179 typedef struct { 180 bool enableGps; 181 bool enableThumb; 182 183 unsigned char maker[32]; 184 unsigned char model[32]; 185 unsigned char software[32]; 186 unsigned char exif_version[4]; 187 unsigned char date_time[20]; 188 unsigned char sub_sec[4]; 189 unsigned char user_comment[150]; 190 191 uint32_t width; 192 uint32_t height; 193 uint32_t widthThumb; 194 uint32_t heightThumb; 195 196 uint16_t orientation; 197 uint16_t ycbcr_positioning; 198 uint16_t exposure_program; 199 uint16_t iso_speed_rating; 200 uint16_t metering_mode; 201 uint16_t flash; 202 uint16_t color_space; 203 uint16_t exposure_mode; 204 uint16_t white_balance; 205 uint16_t scene_capture_type; 206 207 rational_t exposure_time; 208 rational_t fnumber; 209 rational_t aperture; 210 rational_t max_aperture; 211 rational_t focal_length; 212 213 srational_t shutter_speed; 214 srational_t brightness; 215 srational_t exposure_bias; 216 217 unsigned char gps_latitude_ref[2]; 218 unsigned char gps_longitude_ref[2]; 219 220 uint8_t gps_version_id[4]; 221 uint8_t gps_altitude_ref; 222 223 rational_t gps_latitude[3]; 224 rational_t gps_longitude[3]; 225 rational_t gps_altitude; 226 rational_t gps_timestamp[3]; 227 unsigned char gps_datestamp[11]; 228 unsigned char gps_processing_method[100]; 229 230 rational_t x_resolution; 231 rational_t y_resolution; 232 uint16_t resolution_unit; 233 uint16_t compression_scheme; 234 } exif_attribute_t; 235 236 #endif /* EXYNOS_EXIF_H_ */ 237