merge in lmp-mr1-release history after reset to lmp-mr1-dev
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos5.git] / libcamera / ExynosExif.h
CommitLineData
9426c428
JS
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) ((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
106typedef enum {
107 EXIF_ORIENTATION_UP = 1,
108 EXIF_ORIENTATION_90 = 6,
109 EXIF_ORIENTATION_180 = 3,
110 EXIF_ORIENTATION_270 = 8,
111} ExifOrientationType;
112
113typedef enum {
114 EXIF_SCENE_STANDARD,
115 EXIF_SCENE_LANDSCAPE,
116 EXIF_SCENE_PORTRAIT,
117 EXIF_SCENE_NIGHT,
118} CamExifSceneCaptureType;
119
120typedef enum {
121 EXIF_METERING_UNKNOWN,
122 EXIF_METERING_AVERAGE,
123 EXIF_METERING_CENTER,
124 EXIF_METERING_SPOT,
125 EXIF_METERING_MULTISPOT,
126 EXIF_METERING_PATTERN,
127 EXIF_METERING_PARTIAL,
128 EXIF_METERING_OTHER = 255,
129} CamExifMeteringModeType;
130
131typedef enum {
132 EXIF_EXPOSURE_AUTO,
133 EXIF_EXPOSURE_MANUAL,
134 EXIF_EXPOSURE_AUTO_BRACKET,
135} CamExifExposureModeType;
136
137typedef enum {
138 EXIF_WB_AUTO,
139 EXIF_WB_MANUAL,
140} CamExifWhiteBalanceType;
141
142/* Values */
143#define EXIF_DEF_MAKER "SAMSUNG"
144#define EXIF_DEF_MODEL "SAMSUNG"
145#define EXIF_DEF_SOFTWARE "SAMSUNG"
146#define EXIF_DEF_EXIF_VERSION "0220"
147#define EXIF_DEF_USERCOMMENTS "User comments"
148
149#define EXIF_DEF_YCBCR_POSITIONING 1 /* centered */
150#define EXIF_DEF_FNUMBER_NUM 26 /* 2.6 */
151#define EXIF_DEF_FNUMBER_DEN 10
152#define EXIF_DEF_EXPOSURE_PROGRAM 3 /* aperture priority */
153#define EXIF_DEF_FOCAL_LEN_NUM 278 /* 2.78mm */
154#define EXIF_DEF_FOCAL_LEN_DEN 100
155#define EXIF_DEF_FLASH 0 /* O: off, 1: on*/
156#define EXIF_DEF_COLOR_SPACE 1
157#define EXIF_DEF_EXPOSURE_MODE EXIF_EXPOSURE_AUTO
158#define EXIF_DEF_APEX_DEN 10
159
160#define EXIF_DEF_COMPRESSION 6
161#define EXIF_DEF_RESOLUTION_NUM 72
162#define EXIF_DEF_RESOLUTION_DEN 1
163#define EXIF_DEF_RESOLUTION_UNIT 2 /* inches */
164
165typedef struct {
166 uint32_t num;
167 uint32_t den;
168} rational_t;
169
170typedef struct {
171 int32_t num;
172 int32_t den;
173} srational_t;
174
175typedef struct {
176 bool enableGps;
177 bool enableThumb;
178
179 unsigned char maker[32];
180 unsigned char model[32];
181 unsigned char software[32];
182 unsigned char exif_version[4];
183 unsigned char date_time[20];
184 unsigned char user_comment[150];
185
186 uint32_t width;
187 uint32_t height;
188 uint32_t widthThumb;
189 uint32_t heightThumb;
190
191 uint16_t orientation;
192 uint16_t ycbcr_positioning;
193 uint16_t exposure_program;
194 uint16_t iso_speed_rating;
195 uint16_t metering_mode;
196 uint16_t flash;
197 uint16_t color_space;
198 uint16_t exposure_mode;
199 uint16_t white_balance;
200 uint16_t scene_capture_type;
201
202 rational_t exposure_time;
203 rational_t fnumber;
204 rational_t aperture;
205 rational_t max_aperture;
206 rational_t focal_length;
207
208 srational_t shutter_speed;
209 srational_t brightness;
210 srational_t exposure_bias;
211
212 unsigned char gps_latitude_ref[2];
213 unsigned char gps_longitude_ref[2];
214
215 uint8_t gps_version_id[4];
216 uint8_t gps_altitude_ref;
217
218 rational_t gps_latitude[3];
219 rational_t gps_longitude[3];
220 rational_t gps_altitude;
221 rational_t gps_timestamp[3];
222 unsigned char gps_datestamp[11];
223 unsigned char gps_processing_method[100];
224
225 rational_t x_resolution;
226 rational_t y_resolution;
227 uint16_t resolution_unit;
228 uint16_t compression_scheme;
229} exif_attribute_t;
230
231#endif /* EXYNOS_EXIF_H_ */