/src/FreeImage/Source/LibRawLite/libraw/libraw.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 269 lines · 192 code · 44 blank · 33 comment · 4 complexity · 18024bdabf8dcf2fd410075804edfbe4 MD5 · raw file

  1. /* -*- C++ -*-
  2. * File: libraw.h
  3. * Copyright 2008-2010 LibRaw LLC (info@libraw.org)
  4. * Created: Sat Mar 8, 2008
  5. *
  6. * LibRaw C++ interface
  7. *
  8. LibRaw is free software; you can redistribute it and/or modify
  9. it under the terms of the one of three licenses as you choose:
  10. 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
  11. (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
  12. 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
  13. (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
  14. 3. LibRaw Software License 27032010
  15. (See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
  16. */
  17. #ifndef _LIBRAW_CLASS_H
  18. #define _LIBRAW_CLASS_H
  19. #ifdef __linux__
  20. #define _FILE_OFFSET_BITS 64
  21. #endif
  22. /* maximum file size to use LibRaw_file_datastream (fully buffered) I/O */
  23. #define LIBRAW_USE_STREAMS_DATASTREAM_MAXSIZE (250*1024L*1024L)
  24. #include <limits.h>
  25. #include <memory.h>
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include "libraw_datastream.h"
  29. #include "libraw_types.h"
  30. #include "libraw_const.h"
  31. #include "libraw_internal.h"
  32. #include "libraw_alloc.h"
  33. #ifdef __cplusplus
  34. extern "C"
  35. {
  36. #endif
  37. DllDef const char *libraw_strerror(int errorcode);
  38. DllDef const char *libraw_strprogress(enum LibRaw_progress);
  39. /* LibRaw C API */
  40. DllDef libraw_data_t *libraw_init(unsigned int flags);
  41. DllDef int libraw_open_file(libraw_data_t*, const char *);
  42. DllDef int libraw_open_file_ex(libraw_data_t*, const char *, INT64 max_buff_sz);
  43. DllDef int libraw_open_buffer(libraw_data_t*, void * buffer, size_t size);
  44. DllDef int libraw_unpack(libraw_data_t*);
  45. DllDef int libraw_unpack_thumb(libraw_data_t*);
  46. DllDef void libraw_recycle(libraw_data_t*);
  47. DllDef void libraw_close(libraw_data_t*);
  48. DllDef void libraw_subtract_black(libraw_data_t*);
  49. DllDef int libraw_raw2image(libraw_data_t*);
  50. DllDef void libraw_free_image(libraw_data_t*);
  51. /* version helpers */
  52. DllDef const char* libraw_version();
  53. DllDef int libraw_versionNumber();
  54. /* Camera list */
  55. DllDef const char** libraw_cameraList();
  56. DllDef int libraw_cameraCount();
  57. DllDef void libraw_set_memerror_handler(libraw_data_t*, memory_callback cb, void *datap);
  58. DllDef void libraw_set_dataerror_handler(libraw_data_t*,data_callback func,void *datap);
  59. DllDef void libraw_set_progress_handler(libraw_data_t*,progress_callback cb,void *datap);
  60. DllDef const char * libraw_unpack_function_name(libraw_data_t* lr);
  61. DllDef int libraw_get_decoder_info(libraw_data_t* lr,libraw_decoder_info_t* d);
  62. /* DCRAW compatibility */
  63. DllDef int libraw_adjust_sizes_info_only(libraw_data_t*);
  64. DllDef int libraw_dcraw_document_mode_processing(libraw_data_t*);
  65. DllDef int libraw_dcraw_ppm_tiff_writer(libraw_data_t* lr,const char *filename);
  66. DllDef int libraw_dcraw_thumb_writer(libraw_data_t* lr,const char *fname);
  67. DllDef int libraw_dcraw_process(libraw_data_t* lr);
  68. DllDef libraw_processed_image_t* libraw_dcraw_make_mem_image(libraw_data_t* lr, int *errc);
  69. DllDef libraw_processed_image_t* libraw_dcraw_make_mem_thumb(libraw_data_t* lr, int *errc);
  70. DllDef void libraw_dcraw_clear_mem(libraw_processed_image_t*);
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #ifdef __cplusplus
  75. class DllDef LibRaw
  76. {
  77. public:
  78. libraw_data_t imgdata;
  79. int verbose;
  80. LibRaw(unsigned int flags = LIBRAW_OPTIONS_NONE);
  81. libraw_output_params_t* output_params_ptr() { return &imgdata.params;}
  82. int open_file(const char *fname, INT64 max_buffered_sz=LIBRAW_USE_STREAMS_DATASTREAM_MAXSIZE);
  83. int open_buffer(void *buffer, size_t size);
  84. int open_datastream(LibRaw_abstract_datastream *);
  85. int unpack(void);
  86. int unpack_thumb(void);
  87. int adjust_sizes_info_only(void);
  88. void subtract_black();
  89. int raw2image();
  90. int raw2image_ex();
  91. void raw2image_start();
  92. void free_image();
  93. int adjust_maximum();
  94. void set_memerror_handler( memory_callback cb,void *data) {callbacks.memcb_data = data; callbacks.mem_cb = cb; }
  95. void set_dataerror_handler(data_callback func, void *data) { callbacks.datacb_data = data; callbacks.data_cb = func;}
  96. void set_progress_handler(progress_callback pcb, void *data) { callbacks.progresscb_data = data; callbacks.progress_cb = pcb;}
  97. /* helpers */
  98. static const char* version();
  99. static int versionNumber();
  100. static const char** cameraList();
  101. static int cameraCount();
  102. static const char* strprogress(enum LibRaw_progress);
  103. static const char* strerror(int p);
  104. /* dcraw emulation */
  105. int dcraw_document_mode_processing();
  106. int dcraw_ppm_tiff_writer(const char *filename);
  107. int dcraw_thumb_writer(const char *fname);
  108. int dcraw_process(void);
  109. /* memory writers */
  110. libraw_processed_image_t* dcraw_make_mem_image(int *errcode=NULL);
  111. libraw_processed_image_t* dcraw_make_mem_thumb(int *errcode=NULL);
  112. static void dcraw_clear_mem(libraw_processed_image_t*);
  113. /* Additional calls for make_mem_image */
  114. void get_mem_image_format(int* width, int* height, int* colors, int* bps) const;
  115. int copy_mem_image(void* scan0, int stride, int bgr);
  116. /* free all internal data structures */
  117. void recycle();
  118. ~LibRaw(void) { recycle(); delete tls; }
  119. int COLOR(int row, int col) { return libraw_internal_data.internal_output_params.fuji_width? FCF(row,col):FC(row,col);}
  120. int FC(int row,int col) { return (imgdata.idata.filters >> (((row << 1 & 14) | (col & 1)) << 1) & 3);}
  121. int fc (int row, int col);
  122. const char *unpack_function_name();
  123. int get_decoder_info(libraw_decoder_info_t* d_info);
  124. libraw_internal_data_t * get_internal_data_pointer(){ return &libraw_internal_data; }
  125. private:
  126. int FCF(int row,int col) {
  127. int rr,cc;
  128. if (libraw_internal_data.unpacker_data.fuji_layout) {
  129. rr = libraw_internal_data.internal_output_params.fuji_width - 1 - col + (row >> 1);
  130. cc = col + ((row+1) >> 1);
  131. } else {
  132. rr = libraw_internal_data.internal_output_params.fuji_width - 1 + row - (col >> 1);
  133. cc = row + ((col+1) >> 1);
  134. }
  135. return FC(rr,cc);
  136. }
  137. void* malloc(size_t t);
  138. void* calloc(size_t n,size_t t);
  139. void* realloc(void *p, size_t s);
  140. void free(void *p);
  141. void merror (void *ptr, const char *where);
  142. void derror();
  143. LibRaw_TLS *tls;
  144. libraw_internal_data_t libraw_internal_data;
  145. decode first_decode[2048], *second_decode, *free_decode;
  146. tiff_ifd_t tiff_ifd[10];
  147. libraw_memmgr memmgr;
  148. libraw_callbacks_t callbacks;
  149. LibRaw_constants rgb_constants;
  150. void (LibRaw:: *write_thumb)();
  151. void (LibRaw:: *write_fun)();
  152. void (LibRaw:: *load_raw)();
  153. void (LibRaw:: *thumb_load_raw)();
  154. void kodak_thumb_loader();
  155. void write_thumb_ppm_tiff(FILE *);
  156. void foveon_thumb_loader (void);
  157. int own_filtering_supported(){ return 0;}
  158. void identify();
  159. void identify2(unsigned, unsigned, char*);
  160. void write_ppm_tiff ();
  161. void convert_to_rgb();
  162. void remove_zeroes();
  163. #ifndef NO_LCMS
  164. void apply_profile(const char*,const char*);
  165. #endif
  166. void pre_interpolate();
  167. void border_interpolate (int border);
  168. void lin_interpolate();
  169. void vng_interpolate();
  170. void ppg_interpolate();
  171. void ahd_interpolate();
  172. /* from demosaic pack */
  173. void ahd_interpolate_mod();
  174. void afd_interpolate_pl(int afd_passes, int clip_on);
  175. void afd_noise_filter_pl();
  176. void lmmse_interpolate(int gamma_apply);
  177. void dcb(int iterations, int dcb_enhance);
  178. void fbdd(int noiserd);
  179. void vcd_interpolate(int ahd_cutoff);
  180. void amaze_demosaic_RT();
  181. void exp_bef(float expos, float preser);
  182. void CA_correct_RT(float cared, float cablue);
  183. void cfa_linedn(float linenoise);
  184. void cfa_impulse_gauss(float lclean, float cclean);
  185. void green_equilibrate(float thresh);
  186. /* demosaic pack end */
  187. void bad_pixels(const char*);
  188. void subtract(const char*);
  189. void hat_transform (float *temp, float *base, int st, int size, int sc);
  190. void wavelet_denoise();
  191. void scale_colors();
  192. void median_filter ();
  193. void blend_highlights();
  194. void recover_highlights();
  195. void green_matching();
  196. void fuji_rotate();
  197. void stretch();
  198. void foveon_thumb ();
  199. void jpeg_thumb_writer (FILE *tfp,char *thumb,int thumb_length);
  200. void jpeg_thumb ();
  201. void ppm_thumb ();
  202. void layer_thumb ();
  203. void rollei_thumb ();
  204. void kodak_thumb_load_raw();
  205. void foveon_decoder (unsigned size, unsigned code);
  206. unsigned get4();
  207. int flip_index (int row, int col);
  208. void gamma_curve (double pwr, double ts, int mode, int imax);
  209. #ifdef LIBRAW_LIBRARY_BUILD
  210. #include "internal/libraw_internal_funcs.h"
  211. #endif
  212. };
  213. #ifdef LIBRAW_LIBRARY_BUILD
  214. #define RUN_CALLBACK(stage,iter,expect) if(callbacks.progress_cb) { \
  215. int rr = (*callbacks.progress_cb)(callbacks.progresscb_data,stage,iter,expect); \
  216. if(rr!=0) throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK; \
  217. }
  218. #endif
  219. #endif /* __cplusplus */
  220. #endif /* _LIBRAW_CLASS_H */