PageRenderTime 38ms CodeModel.GetById 15ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 0ms

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