Home | History | Annotate | Download | only in libs3cjpeg
      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 ANDROID_HARDWARE_EXIF_H
     18 #define ANDROID_HARDWARE_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)        ((int)(EXIF_LOG2((double)(x)) * 2 + 0.5))
     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 #define NUM_0TH_IFD_TIFF            10
     34 #define NUM_0TH_IFD_EXIF            22
     35 #define NUM_0TH_IFD_GPS             10
     36 #define NUM_1TH_IFD_TIFF            9
     37 
     38 /* Type */
     39 #define EXIF_TYPE_BYTE              1
     40 #define EXIF_TYPE_ASCII             2
     41 #define EXIF_TYPE_SHORT             3
     42 #define EXIF_TYPE_LONG              4
     43 #define EXIF_TYPE_RATIONAL          5
     44 #define EXIF_TYPE_UNDEFINED         7
     45 #define EXIF_TYPE_SLONG             9
     46 #define EXIF_TYPE_SRATIONAL         10
     47 
     48 #define EXIF_FILE_SIZE              28800
     49 
     50 /* 0th IFD TIFF Tags */
     51 #define EXIF_TAG_IMAGE_WIDTH                    0x0100
     52 #define EXIF_TAG_IMAGE_HEIGHT                   0x0101
     53 #define EXIF_TAG_MAKE                           0x010f
     54 #define EXIF_TAG_MODEL                          0x0110
     55 #define EXIF_TAG_ORIENTATION                    0x0112
     56 #define EXIF_TAG_SOFTWARE                       0x0131
     57 #define EXIF_TAG_DATE_TIME                      0x0132
     58 #define EXIF_TAG_YCBCR_POSITIONING              0x0213
     59 #define EXIF_TAG_EXIF_IFD_POINTER               0x8769
     60 #define EXIF_TAG_GPS_IFD_POINTER                0x8825
     61 
     62 /* 0th IFD Exif Private Tags */
     63 #define EXIF_TAG_EXPOSURE_TIME                  0x829A
     64 #define EXIF_TAG_FNUMBER                        0x829D
     65 #define EXIF_TAG_EXPOSURE_PROGRAM               0x8822
     66 #define EXIF_TAG_ISO_SPEED_RATING               0x8827
     67 #define EXIF_TAG_EXIF_VERSION                   0x9000
     68 #define EXIF_TAG_DATE_TIME_ORG                  0x9003
     69 #define EXIF_TAG_DATE_TIME_DIGITIZE             0x9004
     70 #define EXIF_TAG_SHUTTER_SPEED                  0x9201
     71 #define EXIF_TAG_APERTURE                       0x9202
     72 #define EXIF_TAG_BRIGHTNESS                     0x9203
     73 #define EXIF_TAG_EXPOSURE_BIAS                  0x9204
     74 #define EXIF_TAG_MAX_APERTURE                   0x9205
     75 #define EXIF_TAG_METERING_MODE                  0x9207
     76 #define EXIF_TAG_FLASH                          0x9209
     77 #define EXIF_TAG_FOCAL_LENGTH                   0x920A
     78 #define EXIF_TAG_USER_COMMENT                   0x9286
     79 #define EXIF_TAG_COLOR_SPACE                    0xA001
     80 #define EXIF_TAG_PIXEL_X_DIMENSION              0xA002
     81 #define EXIF_TAG_PIXEL_Y_DIMENSION              0xA003
     82 #define EXIF_TAG_EXPOSURE_MODE                  0xA402
     83 #define EXIF_TAG_WHITE_BALANCE                  0xA403
     84 #define EXIF_TAG_SCENCE_CAPTURE_TYPE            0xA406
     85 
     86 /* 0th IFD GPS Info Tags */
     87 #define EXIF_TAG_GPS_VERSION_ID                 0x0000
     88 #define EXIF_TAG_GPS_LATITUDE_REF               0x0001
     89 #define EXIF_TAG_GPS_LATITUDE                   0x0002
     90 #define EXIF_TAG_GPS_LONGITUDE_REF              0x0003
     91 #define EXIF_TAG_GPS_LONGITUDE                  0x0004
     92 #define EXIF_TAG_GPS_ALTITUDE_REF               0x0005
     93 #define EXIF_TAG_GPS_ALTITUDE                   0x0006
     94 #define EXIF_TAG_GPS_TIMESTAMP                  0x0007
     95 #define EXIF_TAG_GPS_PROCESSING_METHOD          0x001B
     96 #define EXIF_TAG_GPS_DATESTAMP                  0x001D
     97 
     98 /* 1th IFD TIFF Tags */
     99 #define EXIF_TAG_COMPRESSION_SCHEME             0x0103
    100 #define EXIF_TAG_X_RESOLUTION                   0x011A
    101 #define EXIF_TAG_Y_RESOLUTION                   0x011B
    102 #define EXIF_TAG_RESOLUTION_UNIT                0x0128
    103 #define EXIF_TAG_JPEG_INTERCHANGE_FORMAT        0x0201
    104 #define EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN    0x0202
    105 
    106 
    107 typedef enum {
    108     EXIF_ORIENTATION_UP     = 1,
    109     EXIF_ORIENTATION_90     = 6,
    110     EXIF_ORIENTATION_180    = 3,
    111     EXIF_ORIENTATION_270    = 8,
    112 } ExifOrientationType;
    113 
    114 typedef enum {
    115     EXIF_SCENE_STANDARD,
    116     EXIF_SCENE_LANDSCAPE,
    117     EXIF_SCENE_PORTRAIT,
    118     EXIF_SCENE_NIGHT,
    119 } CamExifSceneCaptureType;
    120 
    121 typedef enum {
    122     EXIF_METERING_UNKNOWN,
    123     EXIF_METERING_AVERAGE,
    124     EXIF_METERING_CENTER,
    125     EXIF_METERING_SPOT,
    126     EXIF_METERING_MULTISPOT,
    127     EXIF_METERING_PATTERN,
    128     EXIF_METERING_PARTIAL,
    129     EXIF_METERING_OTHER     = 255,
    130 } CamExifMeteringModeType;
    131 
    132 typedef enum {
    133     EXIF_EXPOSURE_AUTO,
    134     EXIF_EXPOSURE_MANUAL,
    135     EXIF_EXPOSURE_AUTO_BRACKET,
    136 } CamExifExposureModeType;
    137 
    138 typedef enum {
    139     EXIF_WB_AUTO,
    140     EXIF_WB_MANUAL,
    141 } CamExifWhiteBalanceType;
    142 
    143 /* Values */
    144 #define EXIF_DEF_MAKER          "SAMSUNG"
    145 #define EXIF_DEF_MODEL          "GT-I9020"
    146 #define EXIF_DEF_SOFTWARE       "CRESPOJH2"
    147 #define EXIF_DEF_EXIF_VERSION   "0220"
    148 #define EXIF_DEF_USERCOMMENTS   "User comments"
    149 
    150 #define EXIF_DEF_YCBCR_POSITIONING  1   /* centered */
    151 #define EXIF_DEF_FNUMBER_NUM        26  /* 2.6 */
    152 #define EXIF_DEF_FNUMBER_DEN        10
    153 #define EXIF_DEF_EXPOSURE_PROGRAM   3   /* aperture priority */
    154 #define EXIF_DEF_FOCAL_LEN_NUM      278 /* 2.78mm */
    155 #define EXIF_DEF_FOCAL_LEN_DEN      100
    156 #define EXIF_DEF_FLASH              0   /* O: off, 1: on*/
    157 #define EXIF_DEF_COLOR_SPACE        1
    158 #define EXIF_DEF_EXPOSURE_MODE      EXIF_EXPOSURE_AUTO
    159 #define EXIF_DEF_APEX_DEN           10
    160 
    161 #define EXIF_DEF_COMPRESSION        6
    162 #define EXIF_DEF_RESOLUTION_NUM     72
    163 #define EXIF_DEF_RESOLUTION_DEN     1
    164 #define EXIF_DEF_RESOLUTION_UNIT    2   /* inches */
    165 
    166 typedef struct {
    167     uint32_t num;
    168     uint32_t den;
    169 } rational_t;
    170 
    171 typedef struct {
    172     int32_t num;
    173     int32_t den;
    174 } srational_t;
    175 
    176 typedef struct {
    177     bool enableGps;
    178     bool enableThumb;
    179 
    180     unsigned char maker[32];
    181     unsigned char model[32];
    182     unsigned char software[32];
    183     unsigned char exif_version[4];
    184     unsigned char date_time[20];
    185     unsigned char user_comment[150];
    186 
    187     uint32_t width;
    188     uint32_t height;
    189     uint32_t widthThumb;
    190     uint32_t heightThumb;
    191 
    192     uint16_t orientation;
    193     uint16_t ycbcr_positioning;
    194     uint16_t exposure_program;
    195     uint16_t iso_speed_rating;
    196     uint16_t metering_mode;
    197     uint16_t flash;
    198     uint16_t color_space;
    199     uint16_t exposure_mode;
    200     uint16_t white_balance;
    201     uint16_t scene_capture_type;
    202 
    203     rational_t exposure_time;
    204     rational_t fnumber;
    205     rational_t aperture;
    206     rational_t max_aperture;
    207     rational_t focal_length;
    208 
    209     srational_t shutter_speed;
    210     srational_t brightness;
    211     srational_t exposure_bias;
    212 
    213     unsigned char gps_latitude_ref[2];
    214     unsigned char gps_longitude_ref[2];
    215 
    216     uint8_t gps_version_id[4];
    217     uint8_t gps_altitude_ref;
    218 
    219     rational_t gps_latitude[3];
    220     rational_t gps_longitude[3];
    221     rational_t gps_altitude;
    222     rational_t gps_timestamp[3];
    223     unsigned char gps_datestamp[11];
    224     unsigned char gps_processing_method[100];
    225 
    226     rational_t x_resolution;
    227     rational_t y_resolution;
    228     uint16_t resolution_unit;
    229     uint16_t compression_scheme;
    230 } exif_attribute_t;
    231 
    232 
    233 #endif /* ANDROID_HARDWARE_EXIF_H */
    234