libhwjpeg: resolve compilation errors
[GitHub/LineageOS/android_hardware_samsung_slsi_exynos.git] / include / ExynosExif.h
1 /*
2 * Copyright Samsung Electronics Co.,LTD.
3 * Copyright (C) 2015 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
18 // To prevent build conflict with the previous libhwjpeg
19 #ifdef USES_UNIVERSAL_LIBHWJPEG
20
21 #ifndef __HARDWARE_EXYNOS_EXYNOS_EXIF_H__
22 #define __HARDWARE_EXYNOS_EXYNOS_EXIF_H__
23
24 #include <math.h>
25
26 #include <sys/types.h>
27
28 #define EXIF_LOG2(x) (log((double)(x)) / log(2.0))
29 #define APEX_FNUM_TO_APERTURE(x) ((EXIF_LOG2((double)(x))) * 2.0)
30 #define APEX_EXPOSURE_TO_SHUTTER(x) ((x) >= 1 ? \
31 (int)(-(EXIF_LOG2((double)(x)) + 0.5)) : \
32 (int)(-(EXIF_LOG2((double)(x)) - 0.5)))
33 #define APEX_ISO_TO_FILMSENSITIVITY(x) ((int)(EXIF_LOG2((x) / 3.125) + 0.5))
34
35 #define NUM_SIZE 2
36 #define IFD_SIZE 12
37 #define OFFSET_SIZE 4
38 #define EXIF_INFO_LIMIT_SIZE 12288
39
40 #define NUM_0TH_IFD_TIFF 10
41 #define NUM_0TH_IFD_EXIF 29
42 #define NUM_0TH_IFD_INTEROPERABILITY (2)
43 #define NUM_0TH_IFD_GPS 10
44 #define NUM_1TH_IFD_TIFF 9
45
46 /* Type */
47 #define EXIF_TYPE_BYTE 1
48 #define EXIF_TYPE_ASCII 2
49 #define EXIF_TYPE_SHORT 3
50 #define EXIF_TYPE_LONG 4
51 #define EXIF_TYPE_RATIONAL 5
52 #define EXIF_TYPE_UNDEFINED 7
53 #define EXIF_TYPE_SLONG 9
54 #define EXIF_TYPE_SRATIONAL 10
55
56 #define EXIF_FILE_SIZE 28800
57
58 /* 0th IFD TIFF Tags */
59 #define EXIF_TAG_IMAGE_WIDTH 0x0100
60 #define EXIF_TAG_IMAGE_HEIGHT 0x0101
61 #define EXIF_TAG_MAKE 0x010f
62 #define EXIF_TAG_MODEL 0x0110
63 #define EXIF_TAG_ORIENTATION 0x0112
64 #define EXIF_TAG_SOFTWARE 0x0131
65 #define EXIF_TAG_DATE_TIME 0x0132
66 #define EXIF_TAG_YCBCR_POSITIONING 0x0213
67 #define EXIF_TAG_EXIF_IFD_POINTER 0x8769
68 #define EXIF_TAG_GPS_IFD_POINTER 0x8825
69
70 /* 0th IFD Exif Private Tags */
71 #define EXIF_TAG_EXPOSURE_TIME 0x829A
72 #define EXIF_TAG_FNUMBER 0x829D
73 #define EXIF_TAG_EXPOSURE_PROGRAM 0x8822
74 #define EXIF_TAG_ISO_SPEED_RATING 0x8827
75 #define EXIF_TAG_EXIF_VERSION 0x9000
76 #define EXIF_TAG_DATE_TIME_ORG 0x9003
77 #define EXIF_TAG_DATE_TIME_DIGITIZE 0x9004
78 #define EXIF_TAG_SHUTTER_SPEED 0x9201
79 #define EXIF_TAG_APERTURE 0x9202
80 #define EXIF_TAG_BRIGHTNESS 0x9203
81 #define EXIF_TAG_EXPOSURE_BIAS 0x9204
82 #define EXIF_TAG_MAX_APERTURE 0x9205
83 #define EXIF_TAG_METERING_MODE 0x9207
84 #define EXIF_TAG_FLASH 0x9209
85 #define EXIF_TAG_FOCAL_LENGTH 0x920A
86 #define EXIF_TAG_MAKER_NOTE 0x927C
87 #define EXIF_TAG_USER_COMMENT 0x9286
88 #define EXIF_TAG_SUBSEC_TIME 0x9290
89 #define EXIF_TAG_SUBSEC_TIME_ORIG 0x9291
90 #define EXIF_TAG_SUBSEC_TIME_DIG 0x9292
91 #define EXIF_TAG_COLOR_SPACE 0xA001
92 #define EXIF_TAG_PIXEL_X_DIMENSION 0xA002
93 #define EXIF_TAG_PIXEL_Y_DIMENSION 0xA003
94 #define EXIF_TAG_RELATED_SOUND_FILE 0xA004
95 #define EXIF_TAG_INTEROPERABILITY 0xA005
96 #define EXIF_TAG_EXPOSURE_MODE 0xA402
97 #define EXIF_TAG_WHITE_BALANCE 0xA403
98 #define EXIF_TAG_FOCA_LENGTH_IN_35MM_FILM 0xA405
99 #define EXIF_TAG_SCENCE_CAPTURE_TYPE 0xA406
100 #define EXIF_TAG_IMAGE_UNIQUE_ID 0xA420
101
102 /* 0th IFD Interoperability Info Tags */
103 #define EXIF_TAG_INTEROPERABILITY_INDEX 0x0001
104 #define EXIF_TAG_INTEROPERABILITY_VERSION 0x0002
105
106 /* 0th IFD GPS Info Tags */
107 #define EXIF_TAG_GPS_VERSION_ID 0x0000
108 #define EXIF_TAG_GPS_LATITUDE_REF 0x0001
109 #define EXIF_TAG_GPS_LATITUDE 0x0002
110 #define EXIF_TAG_GPS_LONGITUDE_REF 0x0003
111 #define EXIF_TAG_GPS_LONGITUDE 0x0004
112 #define EXIF_TAG_GPS_ALTITUDE_REF 0x0005
113 #define EXIF_TAG_GPS_ALTITUDE 0x0006
114 #define EXIF_TAG_GPS_TIMESTAMP 0x0007
115 #define EXIF_TAG_GPS_PROCESSING_METHOD 0x001B
116 #define EXIF_TAG_GPS_DATESTAMP 0x001D
117
118 /* 1th IFD TIFF Tags */
119 #define EXIF_TAG_COMPRESSION_SCHEME 0x0103
120 #define EXIF_TAG_X_RESOLUTION 0x011A
121 #define EXIF_TAG_Y_RESOLUTION 0x011B
122 #define EXIF_TAG_RESOLUTION_UNIT 0x0128
123 #define EXIF_TAG_JPEG_INTERCHANGE_FORMAT 0x0201
124 #define EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LEN 0x0202
125
126 typedef enum {
127 EXIF_ORIENTATION_UP = 1,
128 EXIF_ORIENTATION_90 = 6,
129 EXIF_ORIENTATION_180 = 3,
130 EXIF_ORIENTATION_270 = 8,
131 } ExifOrientationType;
132
133 typedef enum {
134 EXIF_SCENE_STANDARD,
135 EXIF_SCENE_LANDSCAPE,
136 EXIF_SCENE_PORTRAIT,
137 EXIF_SCENE_NIGHT,
138 } CamExifSceneCaptureType;
139
140 typedef enum {
141 EXIF_METERING_UNKNOWN,
142 EXIF_METERING_AVERAGE,
143 EXIF_METERING_CENTER,
144 EXIF_METERING_SPOT,
145 EXIF_METERING_MULTISPOT,
146 EXIF_METERING_PATTERN,
147 EXIF_METERING_PARTIAL,
148 EXIF_METERING_OTHER = 255,
149 } CamExifMeteringModeType;
150
151 typedef enum {
152 EXIF_EXPOSURE_AUTO,
153 EXIF_EXPOSURE_MANUAL,
154 EXIF_EXPOSURE_AUTO_BRACKET,
155 } CamExifExposureModeType;
156
157 typedef enum {
158 EXIF_WB_AUTO,
159 EXIF_WB_MANUAL,
160 EXIF_WB_INCANDESCENT,
161 EXIF_WB_FLUORESCENT,
162 EXIF_WB_DAYLIGHT,
163 EXIF_WB_CLOUDY,
164 } CamExifWhiteBalanceType;
165
166 /* Values */
167 #define EXIF_DEF_MAKER "Samsung Electronics Co., Ltd." /* testJpegExif on the CTS test. This should match Build.MANUFACTURER */
168 #define EXIF_DEF_MODEL "SAMSUNG"
169 #define EXIF_DEF_SOFTWARE "SAMSUNG"
170 #define EXIF_DEF_EXIF_VERSION "0220"
171 #define EXIF_DEF_USERCOMMENTS "User comments"
172
173 #define EXIF_DEF_YCBCR_POSITIONING 1 /* centered */
174 #define EXIF_DEF_EXPOSURE_MANUAL 1 /* manual program */
175 #define EXIF_DEF_EXPOSURE_PROGRAM 2 /* normal program */
176 #define EXIF_DEF_FLASH 0 /* O: off, 1: on*/
177 #define EXIF_DEF_COLOR_SPACE 1
178 #define EXIF_DEF_INTEROPERABILITY (0)
179 #define EXIF_DEF_EXPOSURE_MODE EXIF_EXPOSURE_AUTO
180 #define EXIF_DEF_APEX_DEN (100)
181
182 #define EXIF_DEF_COMPRESSION 6
183 #define EXIF_DEF_RESOLUTION_NUM 72
184 #define EXIF_DEF_RESOLUTION_DEN 1
185 #define EXIF_DEF_RESOLUTION_UNIT 2 /* inches */
186
187 #define APP_MARKER_4 4
188 #define APP_MARKER_5 5
189
190 typedef struct {
191 uint32_t num;
192 uint32_t den;
193 } rational_t;
194
195 typedef struct {
196 int32_t num;
197 int32_t den;
198 } srational_t;
199
200 typedef struct {
201 bool enableGps;
202 bool enableThumb;
203
204 char maker[32];
205 char model[32];
206 char software[32];
207 char exif_version[4];
208 char date_time[20];
209 char sec_time[5];
210 unsigned int maker_note_size;
211 unsigned char *maker_note;
212 unsigned int user_comment_size;
213 unsigned char *user_comment;
214
215 uint32_t width;
216 uint32_t height;
217 uint32_t widthThumb;
218 uint32_t heightThumb;
219
220 uint16_t orientation;
221 uint16_t ycbcr_positioning;
222 uint16_t exposure_program;
223 uint16_t iso_speed_rating;
224 uint16_t metering_mode;
225 uint16_t flash;
226 uint16_t color_space;
227 uint16_t interoperability_index;
228
229 uint16_t exposure_mode;
230 uint16_t white_balance;
231 uint16_t focal_length_in_35mm_length;
232 uint16_t scene_capture_type;
233 char unique_id[30];
234
235 rational_t exposure_time;
236 rational_t fnumber;
237 rational_t aperture;
238 rational_t max_aperture;
239 rational_t focal_length;
240
241 srational_t shutter_speed;
242 srational_t brightness;
243 srational_t exposure_bias;
244
245 char gps_latitude_ref[2];
246 char gps_longitude_ref[2];
247
248 uint8_t gps_version_id[4];
249 uint8_t gps_altitude_ref;
250
251 rational_t gps_latitude[3];
252 rational_t gps_longitude[3];
253 rational_t gps_altitude;
254 rational_t gps_timestamp[3];
255 char gps_datestamp[11];
256 char gps_processing_method[100];
257
258 rational_t x_resolution;
259 rational_t y_resolution;
260 uint16_t resolution_unit;
261 uint16_t compression_scheme;
262 } exif_attribute_t;
263
264 typedef struct {
265 int num_of_appmarker; /* number of app marker */
266 int idx[15][1]; /* idx[number_of_appmarker][appmarker_number] */
267 char *debugData[15]; /* 0-base */
268 unsigned int debugSize[15];
269 } debug_attribute_t;
270
271 bool UpdateDebugData(char *jpeg, size_t jpeglen, debug_attribute_t *debug);
272 bool UpdateExif(char *jpeg, size_t jpeglen, exif_attribute_t *exif);
273
274 #endif /* __HARDWARE_EXYNOS_EXYNOS_EXIF_H__ */
275
276 #endif //USES_UNIVERSAL_LIBHWJPEG