/src/libraw/internal/libraw_internal_funcs.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- C++ -*- |
2 | | * File: libraw_internal_funcs.h |
3 | | * Copyright 2008-2024 LibRaw LLC (info@libraw.org) |
4 | | * Created: Sat Mar 14, 2008 |
5 | | |
6 | | LibRaw is free software; you can redistribute it and/or modify |
7 | | it under the terms of the one of two licenses as you choose: |
8 | | |
9 | | 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 |
10 | | (See file LICENSE.LGPL provided in LibRaw distribution archive for details). |
11 | | |
12 | | 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 |
13 | | (See file LICENSE.CDDL provided in LibRaw distribution archive for details). |
14 | | |
15 | | */ |
16 | | |
17 | | #ifndef _LIBRAW_INTERNAL_FUNCS_H |
18 | | #define _LIBRAW_INTERNAL_FUNCS_H |
19 | | |
20 | | #ifndef LIBRAW_LIBRARY_BUILD |
21 | | #error "This file should be used only for libraw library build" |
22 | | #else |
23 | | |
24 | | /* inline functions */ |
25 | | static int stread(char *buf, size_t len, LibRaw_abstract_datastream *fp); |
26 | | static int getwords(char *line, char *words[], int maxwords, int maxlen); |
27 | | static void remove_trailing_spaces(char *string, size_t len); |
28 | | static void remove_caseSubstr(char *string, char *remove); |
29 | | static void removeExcessiveSpaces(char *string); |
30 | | static void trimSpaces(char *s); |
31 | | /* static tables/variables */ |
32 | | static libraw_static_table_t tagtype_dataunit_bytes; |
33 | | static libraw_static_table_t Canon_wbi2std; |
34 | | static libraw_static_table_t Canon_KeyIsZero_Len2048_linenums_2_StdWBi; |
35 | | static libraw_static_table_t Canon_KeyIs0x0410_Len3072_linenums_2_StdWBi; |
36 | | static libraw_static_table_t Canon_KeyIs0x0410_Len2048_linenums_2_StdWBi; |
37 | | static libraw_static_table_t Canon_D30_linenums_2_StdWBi; |
38 | | static libraw_static_table_t Canon_G9_linenums_2_StdWBi; |
39 | | |
40 | | static libraw_static_table_t Fuji_wb_list1; |
41 | | static libraw_static_table_t FujiCCT_K; |
42 | | static libraw_static_table_t Fuji_wb_list2; |
43 | | |
44 | | static libraw_static_table_t Pentax_wb_list1; |
45 | | static libraw_static_table_t Pentax_wb_list2; |
46 | | |
47 | | static libraw_static_table_t Oly_wb_list1; |
48 | | static libraw_static_table_t Oly_wb_list2; |
49 | | |
50 | | static libraw_static_table_t Sony_SRF_wb_list; |
51 | | static libraw_static_table_t Sony_SR2_wb_list; |
52 | | static libraw_static_table_t Sony_SR2_wb_list1; |
53 | | /* */ |
54 | | int find_ifd_by_offset(INT64 ); |
55 | | void libraw_swab(void *arr, int len); |
56 | | ushort sget2 (uchar *s); |
57 | | ushort sget2Rev(uchar *s); |
58 | | libraw_area_t get_CanonArea(); |
59 | | int parseCR3(INT64 oAtomList, INT64 szAtomList, short &nesting, char *AtomNameStack, short& nTrack, short &TrackType); |
60 | | void selectCRXTrack(); |
61 | | void parseCR3_Free(); |
62 | | int parseCR3_CTMD(short trackNum); |
63 | | int selectCRXFrame(short trackNum, unsigned frameIndex); |
64 | | void setCanonBodyFeatures (unsigned long long id); |
65 | | void processCanonCameraInfo (unsigned long long id, uchar *CameraInfo, unsigned maxlen, unsigned type, unsigned dng_writer); |
66 | | static float _CanonConvertAperture(ushort in); |
67 | | void Canon_CameraSettings(unsigned len); |
68 | | void Canon_WBpresets (int skip1, int skip2); |
69 | | void Canon_WBCTpresets (short WBCTversion); |
70 | | void parseCanonMakernotes (unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
71 | | void processNikonLensData (uchar *LensData, unsigned len); |
72 | | void Nikon_NRW_WBtag (int wb, int skip); |
73 | | void parseNikonMakernote (INT64 base, int uptag, unsigned dng_writer); |
74 | | void parseEpsonMakernote (INT64 base, int uptag, unsigned dng_writer); |
75 | | void parseSigmaMakernote (INT64 base, int uptag, unsigned dng_writer); |
76 | | void setOlympusBodyFeatures (unsigned long long id); |
77 | | void getOlympus_CameraType2 (); |
78 | | void getOlympus_SensorTemperature (unsigned len); |
79 | | void parseOlympus_Equipment (unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
80 | | void parseOlympus_CameraSettings (INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
81 | | void parseOlympus_ImageProcessing (unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
82 | | void parseOlympus_RawInfo (unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
83 | | void parseOlympusMakernotes (INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
84 | | void setPhaseOneFeatures (unsigned long long id); |
85 | | void setPentaxBodyFeatures (unsigned long long id); |
86 | | void PentaxISO (ushort c); |
87 | | void PentaxLensInfo (unsigned long long id, unsigned len); |
88 | | void parsePentaxMakernotes(INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
89 | | void parseRicohMakernotes(INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
90 | | void parseSamsungMakernotes(INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
91 | | void setSonyBodyFeatures (unsigned long long id); |
92 | | void parseSonyLensType2 (uchar a, uchar b); |
93 | | void parseSonyLensFeatures (uchar a, uchar b); |
94 | | void process_Sony_0x0116 (uchar * buf, ushort, unsigned long long id); |
95 | | void process_Sony_0x2010 (uchar * buf, ushort); |
96 | | void process_Sony_0x9050 (uchar * buf, ushort, unsigned long long id); |
97 | | void process_Sony_0x9400 (uchar * buf, ushort, unsigned long long id); |
98 | | void process_Sony_0x9402 (uchar * buf, ushort); |
99 | | void process_Sony_0x9403 (uchar * buf, ushort); |
100 | | void process_Sony_0x9406 (uchar * buf, ushort); |
101 | | void process_Sony_0x940c (uchar * buf, ushort); |
102 | | void process_Sony_0x940e (uchar * buf, ushort, unsigned long long id); |
103 | | void parseSonyMakernotes (INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer, |
104 | | uchar *&table_buf_0x0116, ushort &table_buf_0x0116_len, |
105 | | uchar *&table_buf_0x2010, ushort &table_buf_0x2010_len, |
106 | | uchar *&table_buf_0x9050, ushort &table_buf_0x9050_len, |
107 | | uchar *&table_buf_0x9400, ushort &table_buf_0x9400_len, |
108 | | uchar *&table_buf_0x9402, ushort &table_buf_0x9402_len, |
109 | | uchar *&table_buf_0x9403, ushort &table_buf_0x9403_len, |
110 | | uchar *&table_buf_0x9406, ushort &table_buf_0x9406_len, |
111 | | uchar *&table_buf_0x940c, ushort &table_buf_0x940c_len, |
112 | | uchar *&table_buf_0x940e, ushort &table_buf_0x940e_len); |
113 | | void parseSonySR2 (uchar *cbuf_SR2, unsigned SR2SubIFDOffset, unsigned SR2SubIFDLength, unsigned dng_writer); |
114 | | void parseSonySRF (unsigned len); |
115 | | void parseFujiMakernotes (unsigned tag, unsigned type, unsigned len, unsigned dng_writer); |
116 | | const char* HassyRawFormat_idx2HR(unsigned idx); |
117 | | void process_Hassy_Lens (int LensMount); |
118 | | void parseHassyModel (); |
119 | | |
120 | | void setLeicaBodyFeatures(int LeicaMakernoteSignature); |
121 | | void parseLeicaLensID(); |
122 | | int parseLeicaLensName(unsigned len); |
123 | | int parseLeicaInternalBodySerial(unsigned len); |
124 | | void parseLeicaMakernote(INT64 base, int uptag, unsigned MakernoteTagType); |
125 | | void parseAdobePanoMakernote (); |
126 | | void parseAdobeRAFMakernote (); |
127 | | void GetNormalizedModel (); |
128 | | void SetStandardIlluminants (unsigned, const char* ); |
129 | | |
130 | | ushort get2(); |
131 | | unsigned sget4 (uchar *s); |
132 | | unsigned getint(int type); |
133 | | float int_to_float (int i); |
134 | | double getreal (int type); |
135 | 505k | float getrealf(int type) { return float(getreal(type)); } |
136 | | double sgetreal(int type, uchar *s); |
137 | | void read_shorts (ushort *pixel, unsigned count); |
138 | | |
139 | | /* Canon P&S cameras */ |
140 | | void canon_600_fixed_wb (int temp); |
141 | | int canon_600_color (int ratio[2], int mar); |
142 | | void canon_600_auto_wb(); |
143 | | void canon_600_coeff(); |
144 | | void canon_600_load_raw(); |
145 | | void canon_600_correct(); |
146 | | int canon_s2is(); |
147 | | void parse_ciff (INT64 offset, int length, int); |
148 | | void ciff_block_1030(); |
149 | | |
150 | | |
151 | | // LJPEG decoder |
152 | | unsigned getbithuff (int nbits, ushort *huff); |
153 | | ushort* make_decoder_ref (const uchar **source); |
154 | | ushort* make_decoder (const uchar *source); |
155 | | int ljpeg_start (struct jhead *jh, int info_only); |
156 | | void ljpeg_end(struct jhead *jh); |
157 | | int ljpeg_diff (ushort *huff); |
158 | | ushort * ljpeg_row (int jrow, struct jhead *jh); |
159 | | ushort * ljpeg_row_unrolled (int jrow, struct jhead *jh); |
160 | | void ljpeg_idct (struct jhead *jh); |
161 | | unsigned ph1_bithuff (int nbits, ushort *huff); |
162 | | |
163 | | // Canon DSLRs |
164 | | void crw_init_tables (unsigned table, ushort *huff[2]); |
165 | | int canon_has_lowbits(); |
166 | | void canon_load_raw(); |
167 | | void lossless_jpeg_load_raw(); |
168 | | void canon_sraw_load_raw(); |
169 | | // Adobe DNG |
170 | | void adobe_copy_pixel (unsigned int row, unsigned int col, ushort **rp); |
171 | | void lossless_dng_load_raw(); |
172 | | void deflate_dng_load_raw(); |
173 | | void packed_dng_load_raw(); |
174 | | void packed_tiled_dng_load_raw(); |
175 | | void uncompressed_fp_dng_load_raw(); |
176 | | void lossy_dng_load_raw(); |
177 | | //void adobe_dng_load_raw_nc(); |
178 | | |
179 | | // Pentax |
180 | | void pentax_load_raw(); |
181 | | void pentax_4shot_load_raw(); |
182 | | |
183 | | void pentax_tree(); |
184 | | |
185 | | // Nikon (and Minolta Z2) |
186 | | void nikon_load_raw(); |
187 | | void nikon_he_load_raw_placeholder(); |
188 | | void nikon_read_curve(); |
189 | | void nikon_load_striped_packed_raw(); |
190 | | void nikon_load_padded_packed_raw(); |
191 | | void nikon_load_sraw(); |
192 | | void nikon_yuv_load_raw(); |
193 | | void nikon_coolscan_load_raw(); |
194 | | int nikon_e995(); |
195 | | int nikon_e2100(); |
196 | | void nikon_3700(); |
197 | | int minolta_z2(); |
198 | | // void nikon_e2100_load_raw(); |
199 | | |
200 | | // Fuji |
201 | | // void fuji_load_raw(); |
202 | | int guess_RAFDataGeneration (uchar *RAFData_start); |
203 | | void parse_fuji (INT64 offset); |
204 | | void parse_fuji_thumbnail(INT64 offset); |
205 | | |
206 | | // Rollei |
207 | | void rollei_load_raw(); |
208 | | void parse_rollei(); |
209 | | |
210 | | // Contax |
211 | | void parse_kyocera (); |
212 | | |
213 | | // MF backs |
214 | | //int bayer (unsigned row, unsigned col); |
215 | | int p1raw(unsigned,unsigned); |
216 | | void phase_one_flat_field (int is_float, int nc); |
217 | | int p1rawc(unsigned row, unsigned col, unsigned& count); |
218 | | void phase_one_fix_col_pixel_avg(unsigned row, unsigned col); |
219 | | void phase_one_fix_pixel_grad(unsigned row, unsigned col); |
220 | | void phase_one_load_raw(); |
221 | | unsigned ph1_bits (int nbits); |
222 | | void phase_one_load_raw_c(); |
223 | | void phase_one_load_raw_s(); |
224 | | void hasselblad_load_raw(); |
225 | | void leaf_hdr_load_raw(); |
226 | | void sinar_4shot_load_raw(); |
227 | | void imacon_full_load_raw(); |
228 | | void hasselblad_full_load_raw(); |
229 | | void packed_load_raw(); |
230 | | float find_green(int,int,int,int); |
231 | | void unpacked_load_raw(); |
232 | | void unpacked_load_raw_FujiDBP(); |
233 | | void unpacked_load_raw_reversed(); |
234 | | void unpacked_load_raw_fuji_f700s20(); |
235 | | void parse_sinar_ia(); |
236 | | void parse_phase_one (INT64 base); |
237 | | |
238 | | // Misc P&S cameras |
239 | | void parse_broadcom(); |
240 | | void broadcom_load_raw(); |
241 | | void nokia_load_raw(); |
242 | | void android_loose_load_raw(); |
243 | | void android_tight_load_raw(); |
244 | | unsigned pana_data (int nb, unsigned *bytes); |
245 | | void panasonic_load_raw(); |
246 | | // void panasonic_16x10_load_raw(); |
247 | | // void olympus_load_raw(); |
248 | | void olympus14_load_raw(); |
249 | | // void olympus_cseries_load_raw(); |
250 | | void minolta_rd175_load_raw(); |
251 | | void quicktake_100_load_raw(); |
252 | | const int* make_decoder_int (const int *source, int level); |
253 | | int radc_token (int tree); |
254 | | void kodak_radc_load_raw(); |
255 | | void kodak_jpeg_load_raw(); |
256 | | void kodak_dc120_load_raw(); |
257 | | void eight_bit_load_raw(); |
258 | | void smal_decode_segment (unsigned seg[2][2], int holes); |
259 | | void smal_v6_load_raw(); |
260 | | int median4 (int *p); |
261 | | void fill_holes (int holes); |
262 | | void smal_v9_load_raw(); |
263 | | void parse_riff(int maxdepth); |
264 | | void parse_cine(); |
265 | | void parse_smal (INT64 offset, INT64 fsize); |
266 | | int parse_jpeg (INT64 offset); |
267 | | |
268 | | // Kodak |
269 | | void kodak_262_load_raw(); |
270 | | int kodak_65000_decode (short *out, int bsize); |
271 | | void kodak_65000_load_raw(); |
272 | | void kodak_rgb_load_raw(); |
273 | | void kodak_ycbcr_load_raw(); |
274 | | // void kodak_yrgb_load_raw(); |
275 | | void kodak_c330_load_raw(); |
276 | | void kodak_c603_load_raw(); |
277 | | void kodak_rgb_load_thumb(); |
278 | | void kodak_ycbcr_load_thumb(); |
279 | | void vc5_dng_load_raw_placeholder(); |
280 | | void jxl_dng_load_raw_placeholder(); |
281 | | // It's a Sony (and K&M) |
282 | | void sony_decrypt (unsigned *data, int len, int start, int key); |
283 | | void sony_load_raw(); |
284 | | void sony_arw_load_raw(); |
285 | | void sony_arw2_load_raw(); |
286 | | void sony_arq_load_raw(); |
287 | | void sony_ljpeg_load_raw(); |
288 | | void sony_ycbcr_load_raw(); |
289 | | void samsung_load_raw(); |
290 | | void samsung2_load_raw(); |
291 | | void samsung3_load_raw(); |
292 | | void parse_minolta (INT64 base); |
293 | | |
294 | | #ifdef USE_X3FTOOLS |
295 | | // Foveon/Sigma |
296 | | // We always have x3f code compiled in! |
297 | | void parse_x3f(); |
298 | | void x3f_load_raw(); |
299 | | void x3f_dpq_interpolate_rg(); |
300 | | void x3f_dpq_interpolate_af(int xstep, int ystep, int scale); // 1x1 af pixels |
301 | | void x3f_dpq_interpolate_af_sd(int xstart,int ystart, int xend, int yend, int xstep, int ystep, int scale); // sd Quattro interpolation |
302 | | #else |
303 | 1 | void parse_x3f() {} |
304 | 0 | void x3f_load_raw(){} |
305 | | #endif |
306 | | #ifdef USE_6BY9RPI |
307 | | void rpi_load_raw8(); |
308 | | void rpi_load_raw12(); |
309 | | void rpi_load_raw14(); |
310 | | void rpi_load_raw16(); |
311 | | void parse_raspberrypi(); |
312 | | #endif |
313 | | |
314 | | void kodak_thumb_loader(); |
315 | | void dng_ycbcr_thumb_loader(); |
316 | | #ifdef USE_X3FTOOLS |
317 | | void x3f_thumb_loader(); |
318 | | int x3f_thumb_size(); |
319 | | #endif |
320 | | |
321 | | |
322 | | // CAM/RGB |
323 | | void pseudoinverse (double (*in)[3], double (*out)[3], int size); |
324 | | void simple_coeff (int index); |
325 | | |
326 | | // Openp |
327 | | char** malloc_omp_buffers(int buffer_count, size_t buffer_size); |
328 | | void free_omp_buffers(char** buffers, int buffer_count); |
329 | | |
330 | | |
331 | | // Tiff/Exif parsers |
332 | | void tiff_get (INT64 base,unsigned *tag, unsigned *type, unsigned *len, INT64 *save); |
333 | | short tiff_sget(unsigned save, uchar *buf, unsigned buf_len, INT64 *tag_offset, |
334 | | unsigned *tag_id, unsigned *tag_type, INT64 *tag_dataoffset, |
335 | | unsigned *tag_datalen, int *tag_dataunit_len); |
336 | | void parse_thumb_note (INT64 base, unsigned toff, unsigned tlen); |
337 | | void parse_makernote (INT64 base, int uptag); |
338 | | void parse_makernote_0xc634(INT64 base, int uptag, unsigned dng_writer); |
339 | | void parse_exif (INT64 base); |
340 | | void parse_exif_interop(INT64 base); |
341 | | void linear_table(unsigned len); |
342 | | void Kodak_DCR_WBtags(int wb, unsigned type, int wbi); |
343 | | void Kodak_KDC_WBtags(int wb, int wbi); |
344 | | short KodakIllumMatrix (unsigned type, float *romm_camIllum); |
345 | | void parse_kodak_ifd (INT64 base); |
346 | | int parse_tiff_ifd (INT64 base); |
347 | | int parse_tiff (INT64 base); |
348 | | void apply_tiff(void); |
349 | | void parse_gps (INT64 base); |
350 | | void parse_gps_libraw(INT64 base); |
351 | | void aRGB_coeff(double aRGB_cam[3][3]); |
352 | | void romm_coeff(float romm_cam[3][3]); |
353 | | void parse_mos (INT64 offset); |
354 | | void parse_qt (INT64 end); |
355 | | void get_timestamp (int reversed); |
356 | | |
357 | | // The identify |
358 | | short guess_byte_order (int words); |
359 | | void identify_process_dng_fields(); |
360 | | void identify_finetune_pentax(); |
361 | | void identify_finetune_by_filesize(INT64); |
362 | | void identify_finetune_dcr(char head[64],INT64,INT64); |
363 | | // Tiff writer |
364 | | void tiff_set(struct tiff_hdr *th, ushort *ntag,ushort tag, ushort type, int count, int val); |
365 | | void tiff_head (struct tiff_hdr *th, int full); |
366 | | |
367 | | // split AHD code |
368 | | void ahd_interpolate_green_h_and_v(int top, int left, ushort (*out_rgb)[LIBRAW_AHD_TILE][LIBRAW_AHD_TILE][3]); |
369 | | void ahd_interpolate_r_and_b_in_rgb_and_convert_to_cielab(int top, int left, ushort (*inout_rgb)[LIBRAW_AHD_TILE][3], short (*out_lab)[LIBRAW_AHD_TILE][3]); |
370 | | void ahd_interpolate_r_and_b_and_convert_to_cielab(int top, int left, ushort (*inout_rgb)[LIBRAW_AHD_TILE][LIBRAW_AHD_TILE][3], short (*out_lab)[LIBRAW_AHD_TILE][LIBRAW_AHD_TILE][3]); |
371 | | void ahd_interpolate_build_homogeneity_map(int top, int left, short (*lab)[LIBRAW_AHD_TILE][LIBRAW_AHD_TILE][3], char (*out_homogeneity_map)[LIBRAW_AHD_TILE][2]); |
372 | | void ahd_interpolate_combine_homogeneous_pixels(int top, int left, ushort (*rgb)[LIBRAW_AHD_TILE][LIBRAW_AHD_TILE][3], char (*homogeneity_map)[LIBRAW_AHD_TILE][2]); |
373 | | |
374 | | void init_fuji_compr(struct fuji_compressed_params* info); |
375 | | void init_fuji_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, INT64 raw_offset, unsigned dsize); |
376 | | void copy_line_to_xtrans(struct fuji_compressed_block* info, int cur_line, int cur_block, int cur_block_width); |
377 | | void copy_line_to_bayer(struct fuji_compressed_block* info, int cur_line, int cur_block, int cur_block_width); |
378 | | void xtrans_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line); |
379 | | void fuji_bayer_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line); |
380 | | void fuji_compressed_load_raw(); |
381 | | void fuji_14bit_load_raw(); |
382 | | void parse_fuji_compressed_header(); |
383 | | void crxLoadRaw(); |
384 | | int crxParseImageHeader(uchar *cmp1TagData, int nTrack, INT64 size); |
385 | | void panasonicC6_load_raw(); |
386 | | void panasonicC7_load_raw(); |
387 | | void panasonicC8_load_raw(); |
388 | | |
389 | | void nikon_14bit_load_raw(); |
390 | | |
391 | | // DCB |
392 | | void dcb_pp(); |
393 | | void dcb_copy_to_buffer(float (*image2)[3]); |
394 | | void dcb_restore_from_buffer(float (*image2)[3]); |
395 | | void dcb_color(); |
396 | | void dcb_color_full(); |
397 | | void dcb_map(); |
398 | | void dcb_correction(); |
399 | | void dcb_correction2(); |
400 | | void dcb_refinement(); |
401 | | void rgb_to_lch(double (*image3)[3]); |
402 | | void lch_to_rgb(double (*image3)[3]); |
403 | | void fbdd_correction(); |
404 | | void fbdd_correction2(double (*image3)[3]); |
405 | | void fbdd_green(); |
406 | | void dcb_ver(float (*image3)[3]); |
407 | | void dcb_hor(float (*image2)[3]); |
408 | | void dcb_color2(float (*image2)[3]); |
409 | | void dcb_color3(float (*image3)[3]); |
410 | | void dcb_decide(float (*image2)[3], float (*image3)[3]); |
411 | | void dcb_nyquist(); |
412 | | #endif |
413 | | |
414 | | #endif |