1 /* -*- C++ -*- 2 * File: libraw_internal_funcs.h 3 * Copyright 2008-2018 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 /* WF */ 24 void wf_bayer4_igauss_filter(int radius,void* src_image, int src_imgmode, void* dst_image, int dst_imgmode); 25 void wf_bayer4_green_blur (int mode,void* src_image, int src_imgmode, void* dst_image, int dst_imgmode); 26 void wf_bayer4_block_filter (int* radius_list, void* src_image, int src_imgmode, void* dst_image, int dst_imgmode); 27 double wf_filter_energy (int r1_greenmode, int r1, int r2_greenmode, int r2); 28 29 30 /* inline functions */ 31 ushort sget2 (uchar *s); 32 ushort sget2Rev(uchar *s); 33 unsigned setCanonBodyFeatures (unsigned id); 34 void processCanonCameraInfo (unsigned id, uchar *CameraInfo, unsigned maxlen, unsigned type); 35 void Canon_CameraSettings(); 36 void Canon_WBpresets (int skip1, int skip2); 37 void Canon_WBCTpresets (short WBCTversion); 38 void parseCanonMakernotes (unsigned tag, unsigned type, unsigned len); 39 void processNikonLensData (uchar *LensData, unsigned len); 40 void setOlympusBodyFeatures (unsigned long long id); 41 void setPhaseOneFeatures (unsigned id); 42 void setPentaxBodyFeatures (unsigned id); 43 void PentaxISO (ushort c); 44 void PentaxLensInfo (unsigned id, unsigned len); 45 void setSonyBodyFeatures (unsigned id); 46 void parseSonyLensType2 (uchar a, uchar b); 47 void parseSonyLensFeatures (uchar a, uchar b); 48 void process_Sony_0x0116 (uchar * buf, ushort, unsigned id); 49 void process_Sony_0x2010 (uchar * buf, ushort); 50 void process_Sony_0x9050 (uchar * buf, ushort, unsigned id); 51 void process_Sony_0x9400 (uchar * buf, ushort, unsigned id); 52 void process_Sony_0x9402 (uchar * buf, ushort); 53 void process_Sony_0x9403 (uchar * buf, ushort); 54 void process_Sony_0x9406 (uchar * buf, ushort); 55 void process_Sony_0x940c (uchar * buf, ushort); 56 void process_Sony_0x940e (uchar * buf, ushort, unsigned id); 57 void parseSonyMakernotes (unsigned tag, unsigned type, unsigned len, unsigned dng_writer, 58 uchar *&table_buf_0x0116, ushort &table_buf_0x0116_len, 59 uchar *&table_buf_0x2010, ushort &table_buf_0x2010_len, 60 uchar *&table_buf_0x9050, ushort &table_buf_0x9050_len, 61 uchar *&table_buf_0x9400, ushort &table_buf_0x9400_len, 62 uchar *&table_buf_0x9402, ushort &table_buf_0x9402_len, 63 uchar *&table_buf_0x9403, ushort &table_buf_0x9403_len, 64 uchar *&table_buf_0x9406, ushort &table_buf_0x9406_len, 65 uchar *&table_buf_0x940c, ushort &table_buf_0x940c_len, 66 uchar *&table_buf_0x940e, ushort &table_buf_0x940e_len); 67 68 void parseFujiMakernotes (unsigned tag, unsigned type); 69 70 ushort get2(); 71 unsigned sget4 (uchar *s); 72 unsigned getint (int type); 73 float int_to_float (int i); 74 double getreal (int type); 75 void read_shorts (ushort *pixel, unsigned count); 76 77 /* Canon P&S cameras */ 78 void canon_600_fixed_wb (int temp); 79 int canon_600_color (int ratio[2], int mar); 80 void canon_600_auto_wb(); 81 void canon_600_coeff(); 82 void canon_600_load_raw(); 83 void canon_600_correct(); 84 int canon_s2is(); 85 void parse_ciff (int offset, int length, int); 86 void ciff_block_1030(); 87 88 89 // LJPEG decoder 90 unsigned getbithuff (int nbits, ushort *huff); 91 ushort* make_decoder_ref (const uchar **source); 92 ushort* make_decoder (const uchar *source); 93 int ljpeg_start (struct jhead *jh, int info_only); 94 void ljpeg_end(struct jhead *jh); 95 int ljpeg_diff (ushort *huff); 96 ushort * ljpeg_row (int jrow, struct jhead *jh); 97 void ljpeg_idct (struct jhead *jh); 98 unsigned ph1_bithuff (int nbits, ushort *huff); 99 100 // Canon DSLRs 101 void crw_init_tables (unsigned table, ushort *huff[2]); 102 int canon_has_lowbits(); 103 void canon_load_raw(); 104 void lossless_jpeg_load_raw(); 105 void canon_sraw_load_raw(); 106 // Adobe DNG 107 void adobe_copy_pixel (unsigned int row, unsigned int col, ushort **rp); 108 void lossless_dng_load_raw(); 109 void deflate_dng_load_raw(); 110 void packed_dng_load_raw(); 111 void lossy_dng_load_raw(); 112 //void adobe_dng_load_raw_nc(); 113 114 // Pentax 115 void pentax_load_raw(); 116 void pentax_4shot_load_raw(); 117 118 void pentax_tree(); 119 120 // Nikon (and Minolta Z2) 121 void nikon_load_raw(); 122 void nikon_load_striped_packed_raw(); 123 void nikon_load_sraw(); 124 void nikon_yuv_load_raw(); 125 void nikon_coolscan_load_raw(); 126 int nikon_e995(); 127 int nikon_e2100(); 128 void nikon_3700(); 129 int minolta_z2(); 130 void nikon_e2100_load_raw(); 131 132 // Fuji 133 //void fuji_load_raw(); 134 void parse_fuji (int offset); 135 136 // RedCine 137 void parse_redcine(); 138 void redcine_load_raw(); 139 140 // Rollei 141 void rollei_load_raw(); 142 void parse_rollei(); 143 144 // MF backs 145 //int bayer (unsigned row, unsigned col); 146 int raw(unsigned,unsigned); 147 void phase_one_flat_field (int is_float, int nc); 148 void phase_one_load_raw(); 149 unsigned ph1_bits (int nbits); 150 void phase_one_load_raw_c(); 151 void hasselblad_load_raw(); 152 void leaf_hdr_load_raw(); 153 void sinar_4shot_load_raw(); 154 void imacon_full_load_raw(); 155 void hasselblad_full_load_raw(); 156 void packed_load_raw(); 157 float find_green(int,int,int,int); 158 void unpacked_load_raw(); 159 void unpacked_load_raw_reversed(); 160 void unpacked_load_raw_fuji_f700s20(); 161 void parse_sinar_ia(); 162 void parse_phase_one (int base); 163 164 // Misc P&S cameras 165 void parse_broadcom(); 166 void broadcom_load_raw(); 167 void nokia_load_raw(); 168 void android_loose_load_raw(); 169 void android_tight_load_raw(); 170 void canon_rmf_load_raw(); 171 unsigned pana_data (int nb, unsigned *bytes); 172 void panasonic_load_raw(); 173 void panasonic_16x10_load_raw(); 174 void olympus_load_raw(); 175 void olympus_cseries_load_raw(); 176 void minolta_rd175_load_raw(); 177 void quicktake_100_load_raw(); 178 const int* make_decoder_int (const int *source, int level); 179 int radc_token (int tree); 180 void kodak_radc_load_raw(); 181 void kodak_jpeg_load_raw(); 182 void kodak_dc120_load_raw(); 183 void eight_bit_load_raw(); 184 void smal_decode_segment (unsigned seg[2][2], int holes); 185 void smal_v6_load_raw(); 186 int median4 (int *p); 187 void fill_holes (int holes); 188 void smal_v9_load_raw(); 189 void parse_riff(); 190 void parse_cine(); 191 void parse_smal (int offset, int fsize); 192 int parse_jpeg (int offset); 193 194 // Kodak 195 void kodak_262_load_raw(); 196 int kodak_65000_decode (short *out, int bsize); 197 void kodak_65000_load_raw(); 198 void kodak_rgb_load_raw(); 199 void kodak_ycbcr_load_raw(); 200 // void kodak_yrgb_load_raw(); 201 void kodak_c330_load_raw(); 202 void kodak_c603_load_raw(); 203 void kodak_rgb_load_thumb(); 204 void kodak_ycbcr_load_thumb(); 205 206 // It's a Sony (and K&M) 207 void sony_decrypt (unsigned *data, int len, int start, int key); 208 void sony_load_raw(); 209 void sony_arw_load_raw(); 210 void sony_arw2_load_raw(); 211 void sony_arq_load_raw(); 212 void samsung_load_raw(); 213 void samsung2_load_raw(); 214 void samsung3_load_raw(); 215 void parse_minolta (int base); 216 217 // Foveon/Sigma 218 // We always have x3f code compiled in! 219 void parse_x3f(); 220 void x3f_load_raw(); 221 void x3f_dpq_interpolate_rg(); 222 void x3f_dpq_interpolate_af(int xstep, int ystep, int scale); // 1x1 af pixels 223 void x3f_dpq_interpolate_af_sd(int xstart,int ystart, int xend, int yend, int xstep, int ystep, int scale); // sd Quattro interpolation 224 225 // CAM/RGB 226 void pseudoinverse (double (*in)[3], double (*out)[3], int size); 227 void simple_coeff (int index); 228 229 230 // Tiff/Exif parsers 231 void tiff_get (unsigned base,unsigned *tag, unsigned *type, unsigned *len, unsigned *save); 232 void parse_thumb_note (int base, unsigned toff, unsigned tlen); 233 void parse_makernote (int base, int uptag); 234 void parse_makernote_0xc634(int base, int uptag, unsigned dng_writer); 235 void parse_exif (int base); 236 void linear_table (unsigned len); 237 void Kodak_WB_0x08tags(int wb, unsigned type); 238 void parse_kodak_ifd (int base); 239 int parse_tiff_ifd (int base); 240 int parse_tiff (int base); 241 void apply_tiff(void); 242 void parse_gps (int base); 243 void parse_gps_libraw(int base); 244 void romm_coeff(float romm_cam[3][3]); 245 void parse_mos (int offset); 246 void parse_qt (int end); 247 void get_timestamp (int reversed); 248 249 // External JPEGs, what cameras uses it ? 250 void parse_external_jpeg(); 251 252 // The identify 253 short guess_byte_order (int words); 254 255 // Tiff writer 256 void tiff_set(struct tiff_hdr *th, ushort *ntag,ushort tag, ushort type, int count, int val); 257 void tiff_head (struct tiff_hdr *th, int full); 258 259 // split AHD code 260 #define TS 512 261 void ahd_interpolate_green_h_and_v(int top, int left, ushort (*out_rgb)[TS][TS][3]); 262 void ahd_interpolate_r_and_b_in_rgb_and_convert_to_cielab(int top, int left, ushort (*inout_rgb)[TS][3], short (*out_lab)[TS][3]); 263 void ahd_interpolate_r_and_b_and_convert_to_cielab(int top, int left, ushort (*inout_rgb)[TS][TS][3], short (*out_lab)[TS][TS][3]); 264 void ahd_interpolate_build_homogeneity_map(int top, int left, short (*lab)[TS][TS][3], char (*out_homogeneity_map)[TS][2]); 265 void ahd_interpolate_combine_homogeneous_pixels(int top, int left, ushort (*rgb)[TS][TS][3], char (*homogeneity_map)[TS][2]); 266 267 #undef TS 268 void init_fuji_compr(struct fuji_compressed_params* info); 269 void init_fuji_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, INT64 raw_offset, unsigned dsize); 270 void copy_line_to_xtrans(struct fuji_compressed_block* info, int cur_line, int cur_block, int cur_block_width); 271 void copy_line_to_bayer(struct fuji_compressed_block* info, int cur_line, int cur_block, int cur_block_width); 272 void xtrans_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line); 273 void fuji_bayer_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line); 274 void fuji_compressed_load_raw(); 275 void fuji_14bit_load_raw(); 276 void parse_fuji_compressed_header(); 277 278 // DCB 279 void dcb_pp(); 280 void dcb_copy_to_buffer(float (*image2)[3]); 281 void dcb_restore_from_buffer(float (*image2)[3]); 282 void dcb_color(); 283 void dcb_color_full(); 284 void dcb_map(); 285 void dcb_correction(); 286 void dcb_correction2(); 287 void dcb_refinement(); 288 void rgb_to_lch(double (*image3)[3]); 289 void lch_to_rgb(double (*image3)[3]); 290 void fbdd_correction(); 291 void fbdd_correction2(double (*image3)[3]); 292 void fbdd_green(); 293 void dcb_ver(float (*image3)[3]); 294 void dcb_hor(float (*image2)[3]); 295 void dcb_color2(float (*image2)[3]); 296 void dcb_color3(float (*image3)[3]); 297 void dcb_decide(float (*image2)[3], float (*image3)[3]); 298 void dcb_nyquist(); 299 #endif 300 301 #endif 302