LibRaw C API is a wrapper around C++ API; therefore, virtually all
+ documentation to C API functions is represented by a set of hyperlinks to
+ the corresponding places in the description of C++
+ API.
The function returns the pointer to the instance
+ of libraw_data_t structure.
+ The resultant pointer should be passed as the first argument to all C
+ API functions (except for libraw_strerror).
+ Returns NULL in case of error, pointer to the structure in all other
+ cases.
+
void libraw_close(libraw_data_t *);
+
Closes libraw_data_t handler and deallocates all memory.
+
+
+
Returned values
+
Functions of C API return EINVAL (see errno.h) if the null pointer was
+ passed to them as the first argument. In all other cases, the C++
+ API return code is returned.
+
+
Data Loading from a File/Buffer
+
+
int libraw_open_file(libraw_data_t*, const char *)
+
int libraw_open_file_ex(libraw_data_t*, const char *,INT64
+ bigfile_size)
+
WIN32: int libraw_open_wfile(libraw_data_t*, const wchar_t *)
+
WIN32: int libraw_open_wfile_ex(libraw_data_t*, const wchar_t *,INT64
+ bigfile_size)
These functions provides interface to imgdata.params, .sizes and .color
+ fields which works regardless of LibRaw versions used when building
+ calling app and the library itself.
The postprocessing parameters for the calls described below are set, just
+ as for C++ API, via setting of fields in the libraw_output_params_t
+ structure:
The results of processing are placed in the imgdata field of type libraw_data_t;
+ the same data set contains fields that control the postprocessing and
+ output.
The function returns an integer number in accordance with the return
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
Before file opening, recycle() is always called;
+ hence, if several images are processed in the batch mode, there is no need
+ to call recycle() at the end of each processing cycle.
+
Input data: pointer to object, derived from LibRaw_abstract_datastream
+ class. This object should be initialized and ready to read. This object
+ should be destroyed in calling application after use.
+
+
int LibRaw::open_file(const char *filename[,INT64 bigfile_size])
+
Win32 only: int LibRaw::open_file(const wchar_t *filename[,INT64
+ bigfile_size])
+
Creates an LibRaw_file_datastream object,
+ calls open_datastream(). If succeed, sets
+ internal flag which signals to destroy internal datastream object on recycle().
+ On failure, just created file_datastream destroyed immediately.
+
Second optional parameter bigfile_size controls
+ background I/O interface used for file operations. For files smaller than
+ bigfile_size the LibRaw_file_datastream
+ will be used and the LibRaw_bigfile_datastream
+ otherwise.
+
The function returns an integer number in accordance with the return
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
int LibRaw::open_buffer(void *buffer, size_t bufsize)
+
Created an LibRaw_buffer_datastream
+ object, calls open_datastream(). If
+ succeed, sets internal flag which signals to destroy internal datastream
+ object on recycle(). On failure, just created
+ file_datastream destroyed immediately.
+
The function returns an integer number in accordance with the return
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
_raw_width/_raw_height/*margin - image size and margins
+
procflags:
+
+
for 10-bit format:
+
+
1: "4 pixels in 5 bytes" packing is used
+
0: "6 pixels in 8 bytes" packing is used
+
+
+
for 16-bit format:
+
+
1: Big-endian data
+
+
+
+
+
bayer_pattern: one of LIBRAW_OPENBAYER_RGGB,LIBRAW_OPENBAYER_BGGR,
+ LIBRAW_OPENBAYER_GRBG,LIBRAW_OPENBAYER_GBRG
+
unused_bits: count of upper zero bits
+
otherflags:
+
+
Bit 1 - filter (average neighbors) for pixels with values of zero
+
+
Bits 2-4 - the orientation of the image (0=do not rotate, 3=180,
+ 5=90CCW, 6=90CW)
+
+
+
black_level: file black level (it also may be specified via
+ imgdata.params)
+
+ See samples/openbayer_sample.cpp for usage sample (note, this sample is
+ 'sample only', suited for Kodak KAI-0340 sensor, you'll need change
+ open_bayer() params for your data).
+
+
int LibRaw::unpack(void)
+
Unpacks the RAW files of the image, calculates the black level (not for
+ all formats). The results are placed in imgdata.image.
+
Data reading is sometimes (not frequently) affected by settings made in
+ imgdata.params (libraw_output_params_t);
+ see API notes for details.
+
The function returns an integer number in accordance with the return
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
int LibRaw::unpack_thumb(void)
+
int LibRaw::unpack_thumb_ex(int i)
+
+
unpack_thumb(): reads (or unpacks) the default (largest) image preview
+ (thumbnail), placing the result into the imgdata.thumbnail.thumb buffer.
+
unpack_thumb_ex(int i): reads i-th thumbnail (thumbnails list is
+ available in imgdata.thumbs_list structure).
+
JPEG previews are placed into this buffer without any changes (with the
+ header etc.). Other preview formats are placed into the buffer in the form
+ of the unpacked bitmap image (three components, 8 bits per component).
+ The thumbnail format is written to the imgdata.thumbnail.tformat field;
+ for the possible values, see description
+ of constants and data structures.
+
The function returns an integer number in accordance with the return
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
+
+
Auxiliary Functions
+
Library version check
+
+
const char* LibRaw::version()
+
Returns string representation of LibRaw version in
+ MAJOR.MINOR.PATCH-Status format (i.e. 0.6.0-Alpha2 or 0.6.1-Release).
+
+
int LibRaw::versionNumber()
+
Returns integer representation of LibRaw version. During LibRaw
+ development, the version number is always increase .
+
+
bool LIBRAW_CHECK_VERSION(major,minor,patch)
+
Macro for version check in caller applications. Returns 'true' if current
+ library version is greater or equal to set in macro parameters. This macro
+ executes at runtime (not at compile time) and may be used for checking
+ version of dynamically loaded LibRaw (from DLL/shared library).
+
List of supported RAW formats (cameras)
+
+
int LibRaw::cameraCount()
+
Returns count of cameras supported.
+
+
const char** LibRaw::cameraList()
+
Returns list of supported cameras. Latest item of list is set to NULL
+ (for easy printing).
+
+
int LibRaw::set_rawspeed_camerafile(char *path_to_cameras_xml)
+
(Only if LibRaw was built with RawSpeed support).
+
Loads XML file with RawSpeed camera description data (cameras.xml)
+ specified by path_to_cameras_xml. Returns 0 on success, nonzero on error.
+
+
int LibRaw::get_decoder_info(libraw_decoder_info_t *)
+
The function fills libraw_decoder_info_t
+ structure by passed pointer with current raw decoder data.
+
The function returns an integer number in accordance with the return
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
const char* LibRaw::unpack_function_name()
+
Returns function name of file unpacking function. Intended only for
+ LibRaw test suite designers to use in test coverage evaluation.
+
+
void LibRaw::setCancelFlag()
+
This call sets internal fast cancel flags. If set, current Raw decoder
+ will be terminated ASAP. This call is useful if you need to cancel all
+ LibRaw decoders in multithreaded program (e.g. for fast program
+ termination or just for cancel current processing).
+
+
void LibRaw::clearCancelFlag()
+
This call clears internal fast cancel flags, so (early) terminated LibRaw
+ decoder may work again.
+
+
int LibRaw::COLOR(int row, int col)
+
This call returns pixel color (color component number) in bayer pattern at
+ row,col. The returned value is in 0..3 range for 4-component Bayer (RGBG2,
+ CMYG and so on) and in 0..2 range for 3-color data.
+
Color indexes returned could be used as index in imgdata.idata.cdesc
+ string to get color 'name'.
+
+
int LibRaw::error_count()
+
This call returns count of non-fatal data errors (out of range, etc)
+ occurred in unpack() stage.
+
+
int LibRaw::subtract_black()
+
This call will subtract black level values from RAW data (for suitable
+ RAW data). colordata.data_maximum
+ and colordata.maximum and black level data (colordata.black
+ and colordata.cblack) will be adjusted too.
+
This call should be used if you postprocess RAW data by your own code.
+ LibRaw postprocessing functions will call subtract_black()
+ by oneself.
+
The function returns an integer number in accordance with the return
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
int LibRaw::adjust_to_raw_inset_crop(unsigned mask, float maxcrop =
+ 0.55f)
+
Promotes imgdata.sizes.raw_inset_crops[] values to imgdata.sizes.*margin
+ and imgdata.sizes.width/height fields
+
Parameters
+ mask:
+
+
if bit 1 is set: prefer raw_inset_crops[1]
+
if bit 0 is set: prefer raw_inset_crops[0]
+
+
maxcrop: limits crop to not less than (original width/height)*maxcrop; if
+ raw_inset_crops[i] data results in tighter crop, than this item is
+ ignored.
+
return value: index in raw_inset_crops[] used increased by one, so
+
+
0: no changes made
+
1: [0]th data used
+
2: [1]th data used
+
+
Note: this call SHOULD be used after LibRaw::unpack(), otherwise black
+ level calculation from masked area may be fooled resulting in wrong black
+ levels.
+
+
Support for floating point data
+
Libraw can read floating point DNG files (no other RAW formats may use
+ floating point) with or without conversion to integer data. Floating point
+ values are stored in imgdata.rawdata buffers:
+
+
float * float_image (if
+ not NULL) points to floating point bayer data
+
float (*float3_image)[3]
+ (if not NULL) points to floating point 3-channel buffer
+
float (*float4_image)[4]
+ (if not NULL) points to floating point 4-channel buffer
+
+
Function calls for floating point support:
+
+
int LibRaw::is_floating_point();
+ function will return 1 if file contains floating point data
+
int LibRaw::have_fpdata();
+ function will return 1 if FP data has read (decoded) into memory and not
+ converted to integer data
+
int LibRaw::convertFloatToInt(float dmin=4096.f, float dmax=32767.f,
+ float dtarget = 16383.f) converts floating point data to integer. If
+ data maximum is out of dmin..dmax range, than data scaled to set maximum
+ to dtarget
+
+
+
Support for YCC formats (Canon sRAW/mRAW and Nikon Small NEF)
+
int LibRaw::is_sraw(); int LibRaw::is_nikon_sraw(); int LibRaw::sraw_midpoint()
+
+
is_sraw() call returns nonzero if current image is YCC-based.
+
is_nikon_sraw() call returns nonzero for Nikon Small NEF files
+
sraw_midpoint() call returns neutral (gray) point for color channels
+
+
+
void LibRaw::set_dng_host(void* p)
+
If LibRaw is compiled with Adobe DNG SDK support and you wish to use this
+ support:
+
+
you need to create own dng_host object
+
and pass it to LibRaw object using this function
+
+
void LibRaw::recycle_datastream(void)
+
This call closes input datastream with associated data buffer and
+ unblocks opened file.
+
void LibRaw::recycle(void)
+
Frees the allocated data of LibRaw instance, enabling one to process the
+ next file using the same processor. Repeated calls of recycle() are quite
+ possible and do not conflict with anything.
Converts progress stage code to description string (in English).
+
+
const char* LibRaw::strerror(int errorcode)
+
Analog of strerror(3) function: outputs the text descriptions of LibRaw
+ error codes (in English).
+
+
Setting Error Notification Functions
+
In process of RAW conversion LibRaw can call user-setted callback. This
+ callback can be used for:
+
+
Dynamic status update (progress bar and so on).
+
Cancel of processing (for example, user pressed Cancel button).
+
+
Also, work of the library may cause two types of exceptional situations
+ that require notification of the calling application:
+
+
Memory shortage
+
Data read error.
+
+
An application may set its own callbacks that will be called in the cases
+ mentioned above to notify the user (or the calling program).
+
+
Progress indication/processing termination
+
typedef int (*progress_callback)(void *callback_data,enum LibRaw_progress stage, int iteration, int expected); void LibRaw::set_progress_handler(progress_callback func,void *callback_data);
+
LibRaw user can set own callback which will be called 10-50 times during
+ RAW postprocessing by dcraw_process().
+
This callback may terminate current image processing by returning of
+ non-zero value. In such case all processing will be cancelled immediately
+ and all resources will be returned to system by recycle() call. Current
+ call of dcraw_process() will return error code
+ LIBRAW_CANCELLED_BY_CALLBACK.
+
Callback parameters:
+
+
void *callback_data
+
void*-pointer, passed as 2nd argument to set_progress_handler(). This
+ pointer should be used to pass additional data to callback (i.e. thread
+ local data and so on).
+
enum LibRaw_progress stage
+
Current processing stage. This number can be converted to string by
+ call to LibRaw::strprogress. Not all
+ processing stages are covered by callback calls.
+
int iteration
+
Iteration number within current stage (from 0 to expected-1).
+
int expected
+
Expected number of iterations on current stage.
+
+
Callback should return value of: 0 for continue
+ processing and non-zero for immediate cancel of
+ processing.
+
+
If LibRaw compiled with OpenMP support, iteration parameter may not
+ always increase within one stage. Out of order callback calls are
+ possible.
+
Callback code sample:
+
int my_progress_callback(void *data,enum LibRaw_progress p,int iteration, int expected) { char *passed_string = (char *data); printf("Callback: %s pass %d of %d, data passed: %s\n",libraw_strprogress(p),iteration,expected,passed_string); if(timeout || key_pressed ) return 1; // cancel processing immediately else return 0; // can continue }
+
+
User-specified exif tag parser callback
+
typedef void (*exif_parser_callback) (void *context, int tag, int type, int len,unsigned int ord, void *ifp); void LibRaw::set_exifparser_handler( exif_parser_callback cb,void *context);
+
Callback to be called on each parsed EXIF/Makernotes tag with parameters:
+
+
context - pointer to context passed to set_exifparser_handler();
+
tag - EXIF/Makernotes tag value
+
type - TIFF(EXIF) tag type
+
len - tag length
+
ord - byte order (II or MM)
+
void *ifp - pointer to LibRaw_abstract_datastream, positioned to tag
+ data
The user can define his or her own function to be called in the case of
+ error in the input data. It is a void function receiving two parameters:
+
+
void *callback_data - void*-pointer, passed as 2nd
+ argument to set_progress_handler(). This pointer should be used to pass
+ additional data to callback (i.e. thread local data and so on).
+
file is the name of the RAW file whose processing
+ evoked the file read error. This name can be NULL if
+ underlying data input layer does not know the name. So, if calling
+ application sets own callback, this callback should work with NULL file
+ name.
+
offset is -1 at end-of-file (if LibRaw expects more
+ data) or a positive number equal to the file position (bytes from file
+ beginning) where the unpacking error occurred.
+
+
The callback function is intended for information purposes: it notifies
+ the user or the program code that processing is impossible.
+
If the user does not set his or her own handler, the standard one (output
+ of error message in stderr) will be used.
+
One can set the null handler by passing NULL to set_dataerror_handler;
+ then no notifier function will be called. The same effect can be achieved
+ by creating a LibRaw object with the LIBRAW_OPTIONS_NO_DATAERR_CALLBACK
+ flag in the constructor.
+
In the case of error in the input data, processing of the current file is
+ terminated and a notifier is called; all allocated resources are freed,
+ and recycle() is performed. The current call will
+ return LIBRAW_IO_ERROR.
+ At an attempt to continue data processing, all subsequent calls will
+ return LIBRAW_OUT_OF_ORDER_CALL. Processing of a new file may be started
+ in the usual way, by calling LibRaw::open_file().
+
+
Data Postprocessing: Emulation of dcraw Behavior
+
Instead of writing one's own Bayer pattern postprocessing, one can use
+ the dcraw functions, which are called after the calls of open_file() +
+ unpack() /+ unpack_thumb()/
+
+
Parameter Setting
+
Virtually all parameters that can be set through the dcraw command line
+ are specified by assigning values to fields of the LibRaw::imgdata.params
+ structure. The type of this structure is libraw_output_params_t;
+ all fields are listed and described in sufficient detail in the description
+ of data structures.
+
+
int LibRaw::raw2image
+
This function allocates buffer for postprocessing (imgdata.image) and
+ fills it with data layout compatible with LibRaw 0.13/0.14 and below. If
+ the buffer is already allocated, it will be free()ed and allocated again.
+
This function should be called only if your code do postprocessing stage.
+ If you use LibRaw's postprocessing calls (see below) you don't need to
+ call raw2image().
+
The function returns an integer number in accordance with the return
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
void LibRaw::free_image
+
This function releases the imgdata.image buffer allocated by raw2image();
+
This method should be called if current postprocessing results are not
+ needed by the program (e.g. already copied somewhere), but new
+ postprocessing calls (with another settings) are possible, so it is to
+ early to call recycle().
+
+
int LibRaw::adjust_sizes_info_only(void)
+
The function calculates the correct size of the output image
+ (imgdata.sizes.iwidth and imgdata.sizes.iheight) for the following cases:
+
+
Files from Fuji cameras (with a 45-degree rotation)
+
Files from cameras with non-square pixels
+
Images shot by a rotated camera.
+
+
In the aforementioned cases, the function changes the fields of the image
+ output size; note that this change cannot be repeated again.
+
+
int LibRaw::dcraw_process(void)
+
The function emulates the postprocessing capabilities available in dcraw.
+ Called after calling LibRaw::unpack();
+
The entire functionality of dcraw (set via the field values in imgdata.params)
+ is supported, except for
+
+
Dark frame subtraction
+
Work with bad pixels.
+
+
The function is intended solely for demonstration and testing purposes;
+ it is assumed that its source code will be used in most real applications
+ as the reference material concerning the order of RAW data processing.
+
The function returns an integer number in accordance with the error
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
Data Output to Files: Emulation of dcraw Behavior
+
In spite of the abundance of libraries for file output in any formats,
+ LibRaw includes calls that emulate the file output provided by dcraw. This
+ is done primarily for easier verification of library work: the resultant
+ files must be binary identical.
+
+
int LibRaw::dcraw_ppm_tiff_writer(const char *outfile)
+
The function outputs the postprocessing results to a file in the PPM/PGM
+ or TIFF format (the format is set via imgdata.params.output_tiff). The
+ results are binary identical to those provided by dcraw.
+
If "-" is passed as outfile, the function will write to standard output
+ (stdout).
+
The function returns an integer number in accordance with the error
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
int LibRaw::dcraw_thumb_writer(const char *thumbfile)
+
Writes the thumbnail to a file in the PPM format for bitmap thumbnails
+ and in the JPEG format for JPEG thumbnails, i.e., in the format completely
+ identical to the results provided by dcraw.
+
The function returns an integer number in accordance with the error
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
Copying unpacked data into memory buffer
+
There is several function calls for store unpacked data into memory
+ buffer (after using dcraw_process() and so on):
+
+
get_mem_image_format - get resulting bitmap size and
+ bit depth.
+
copy_mem_image - copy postprocessed data into some
+ memory buffer with different color order and line stride.
+
dcraw_make_mem_image - store processed image data
+ into allocated buffer;
+
dcraw_make_mem_thumb - store extracted thumbnail into
+ buffer as JPEG-file image (for most cameras) or as RGB-bitmap.
+
+
For usage primer see samples/mem_image.c sample.
+
+
+
void get_mem_image_format(int *widthp, int *heightp, int *colorsp, int
+ *bpp) const - return processing bitmap size
+
This function returns size of postprocessed image:
+
+
Image width is returned in *widthp;
+
Bitmap height is returned in *heightp;
+
Image color count is returned in *colorsp;
+
Bits per pixel (8 or 16) is returned in *bpp;
+
+
+
int LibRaw::copy_mem_image(void* scan0, int stride, int bgr) - copies
+ postprocessed bitmap data into buffer
+
Function parameters:
+
+
void *scan0 - pointer to buffer to copy data to. The buffer should be
+ at least stride*image_height bytes;
+
int stride - stride of each other image line (row) in bytes. Usually
+ image_width*(bit_per_pixel/8)*image_colors, but may be more if you wish
+ to align image rows to, for example, 8 or 16 or 32 bytes to make CPU
+ more happy.
+
int bgr - pixel copy order. RGB if bgr==0 and BGR otherwise.
+
+
The function returns an integer number in accordance with the error
+ code convention: positive if any system call has returned an error,
+ negative (from the LibRaw
+ error list) if there has been an error situation within LibRaw.
+
+
libraw_processed_image_t *dcraw_make_mem_image(int *errorcode=NULL) -
+ store unpacked and processed image into memory buffer as RGB-bitmap
+
This function allocates memory buffer and stores unpacked-preprocessed
+ image into this buffer. Function returns allocated structure libraw_processed_image_t
+ with filled fields. Always returns data as RGB bitmap (i.e. type
+ field is equal to LIBRAW_IMAGE_BITMAP).
+
dcraw_process() should be called before dcraw_make_mem_image();
+
Returns NULL in case of an error. If caller has passed not-NULL value as
+ errorcode parameter, than *errorcode will be set to error code according
+ to error code convention.
+
NOTE! Memory, allocated for return value will not be
+ fried at destructor or LibRaw::recycle calls. Caller of
+ dcraw_make_mem_image should free this memory by call to LibRaw::dcraw_clear_mem().
+
+
libraw_processed_image_t *dcraw_make_mem_thumb(int *errorcode=NULL) -
+ store unpacked thumbnail into memory buffer
+
This function allocates memory buffer and stores thumbnail data in it.
+ Function returns allocated structure libraw_processed_image_t
+ with filled fields. For most RAW images allocated structure will contains
+ JPEG image (i.e. type field is equal to
+ LIBRAW_IMAGE_JPEG). For some cameras with RGB-bitmap thumbnail (Kodak
+ SLRs) returned structure contains RGB bitmap (type field
+ is equal to LIBRAW_IMAGE_JPEG, see structure description for details).
+
unpack_thumb() should be called before dcraw_make_mem_thumb();
+
Returns NULL in case of an error. If caller has passed not-NULL value as
+ errorcode parameter, than *errorcode will be set to error code according
+ to error code convention.
+
NOTE! Memory, allocated for return value will not be
+ fried at destructor or LibRaw::recycle calls. Caller of
+ dcraw_make_mem_image should free this memory by call to LibRaw::dcraw_clear_mem().
This function will free the memory allocated by dcraw_make_mem_image
+ or dcraw_make_mem_thumb.
+
This is static class member, so call syntax should be
+ LibRaw::dcraw_clear_mem(...).
+
This call translates directly to free() system function, but it is better
+ to use dcraw_clear_mem because LibRaw (DLL) may be compiled with memory
+ manager other than in calling application.
+
+
Input layer abstraction
+
+
class LibRaw_abstract_datastream - abstract RAW read interface
+
LibRaw reads RAW-data by calling (virtual) methods of C++ object derived
+ from LibRaw_abstract_datastream. This C++ class does not
+ implement any read, but defines interface to be called. Call to base class
+ methods always results in error.
+
+
LibRaw_abstract_datastream class methods
+
+
Object verification
+
+
virtual int valid()
+
Checks input datastream validity. Returns 1 on valid stream and 0 if
+ datastream was created on non-valid input parameters (wrong filename for
+ file stream and so on).
+
+
+
Stream read and positioning
+
This group of methods implements file object (FILE*) semantics.
+
+
virtual int read(void * ptr,size_t size, size_t nmemb)
+
Similar to fread(ptr,size,nmemb,file).
+
virtual int seek(off_t o, int whence)
+
Similar to fseek(file,o,whence).
+
virtual int tell(
+
Similar to ftell(file).
+
virtual int get_char()
+
Similar to getc(file)/fgetc(file).
+
virtual char* gets(char *s, int n)
+
Similar to fgets(s,n,file).
+
virtual int eof()
+
Similar to feof(file).
+
virtual int scanf_one(const char *fmt, void *val)
+
Simplified variant of fscanf(file,fmt,val): format string is always
+ contains one argument to read. So, variable args call is not needed and
+ only one pointer to data passed.
+
virtual int jpeg_src(void * p);
+
Initializes read structures in j_decompress_ptr object passed as *p.
+ This object is used by libjpeg for JPEG data reading from datastream.
+
Returns -1 on error and 0 on success.
+
+
+
+
Other methods
+
This group of methods includes several supplementary calls. These calls
+ are used to temporary switch to another data stream (file and/or memory
+ buffer).
+
+
virtual const char* fname()
+
Returns name of opened file if datastream object knows it (for
+ example, LibRaw_file_datastream used). Filename used
+ in:
+
+
error notification callbacks;
+
generation of filename of JPEG-file with metadata when needed
+ (i.e. cameras with 'Diag RAW hack').
+
+
+
virtual int subfile_open(const char *fn)
+
This call temporary switches input to file fn.
+ Returns 0 on success and error code on error.
+ The function used to read metadata from external JPEG file (on cameras
+ with "Diag RAW hack").
+ This call is not implemented for LibRaw_buffer_datastream,
+ so external JPEG processing is not possible when buffer datastream used.
+
+ This function should be implemented in real input class, base class call
+ always return error.
+ Working implementation sample can be found in LibRaw_file_datastream
+ implementation in libraw/libraw_datastream.h file.
+
virtual void subfile_close()
+
This call switches input stream from temporary open file back to main
+ data stream.
+
virtual int tempbuffer_open(void *buf, size_t size)
+
This call temporary switches input to LibRaw_buffer_datastream
+ object, created from buf.
+ This method is needed for Sony encrypted metadata parser.
+
This call implemented in base class (LibRaw_abstract_datastream),
+ there is no need to reimplement in in derived classes.
+ Possible activity of temporary datastream requires very accurate
+ programming when implementing datastreams derived from base LibRaw_abstract_datastream.
+ See below for more details.
+
+
virtual void tempbuffer_close()
+
This call switch input back from temporary datastream to main stream.
+ This call implemented in base LibRaw_abstract_datastream
+ class.
+
+
+
Derived input classes included in LibRaw
+
There is three "standard" input classes in LibRaw distribution:
LibRaw C++ interface users can implement their own input classes and use
+ them via LibRaw::open_datastream call.
+ Requirements and implementation specifics are described below.
+
+
class LibRaw_file_datastream - file input interface
+
This class implements input from file.
+
Class methods:
+
+
LibRaw_file_datastream(const char *fname)
+
This constructor creates LibRaw_file_datastream
+ object from file fname.
+ Unfortunately, C++ constructor cannot return an error. So if bad
+ filename passed (e.g. nonexistent file) object is created as non-valid
+ (valid() call returns zero).
+
+
All other class methods are described
+ above.
+ This class implements all possible methods, including fname() and
+ subfile_open().
+
+
class LibRaw_bigfile_datastream - file input interface
+
This class implements input from file.
+
Class methods:
+
+
LibRaw_bigfile_datastream(const char *fname)
+
This constructor creates LibRaw_bigfile_datastream
+ object from file fname.
+ Unfortunately, C++ constructor cannot return an error. So if bad
+ filename passed (e.g. nonexistent file) object is created as non-valid
+ (valid() call returns zero).
+
+
The difference between file and bigfile
+ datastreams are obvious from class name: bigfile one supports large files
+ (more than 2Gb) on all supported systems. File one uses streambuf
+ interface which is limited to 2Gb on many systems.
+
All other class methods are described
+ above.
+ This class implements all possible methods, including fname() and
+ subfile_open().
+
+
class LibRaw_buffer_datastream - memory buffer input interface
This constructor creates datastream object from buffer
+ with size bsize.
+ It is not possibly to verify the pointer passed, so buffer address is
+ checked against 0 and -1 only.
+
+
All other class methods are described
+ above.
+ This class does not implement fname() and subfile_open() calls, so
+ external JPEG metadata parsing is not possible.
+
+
Own datastream derived classes
+
To create own read interface LibRaw user should implement C++ class
+ derived from LibRaw_abstract_datastream with all read
+ methods.
+ LibRaw standard implementations may be used as reference. See libraw/libraw_datastream.h
+ file for details (all standard LibRaw input classes are implemented using
+ inline functions only).
Structure libraw_data_t is a "wrapping" for data structures accessible to
+ the user of the library.
+ When one uses C++ API, it is accessible as LibRaw::imgdata
+ (class_instance.imgdata). The data in this structure appear after a file
+ is opened through open_file (and other open_ calls), except for the image
+ itself (filled by unpack()) and data containing the preview information
+ (filled by calling unpack_thumb()).
The structure describes the main image parameters retrieved from the
+ RAW file. Fields of this structure are described in detail
+ below .
+
libraw_image_sizes_t sizes;
+
The structure describes the geometrical parameters of the image.
+ Fields of this structure are described in detail
+ below .
+
libraw_lensinfo_t lens;
+
The structure describes lens used for the shot. Fields of this
+ structure are described in detail below
+ .
+
libraw_makernotes_t makernotes;
+
The structure contains camera/vendor specific metadata extracted from
+ file. No description provided, sorry, if you're interested in particular
+ tag/camera/vendor - use Exiftool documentation as a reference
+
libraw_colordata_t color;
+
The structure contains color data retrieved from the file. Fields of
+ this structure are described in detail
+ below .
+
libraw_imgother_t other;
+
Data structure for information purposes: it contains the image
+ parameters that have been extracted from the file but are not needed in
+ further file processing. Fields of this structure are described in
+ detail below .
+
libraw_thumbnail_t thumbnail;
+
Data structure containing information on the preview and the preview
+ data themselves. All fields of this structure but thumbnail itself are
+ filled when open_file() is called. Thumbnail read by unpack_thumb()
+ call. The fields are described in detail
+ below .
+
libraw_rawdata_t rawdata;
+
Data structure with pointer to raw-data buffer. Details are described
+ below .
+
ushort (*image)[4];
+
The memory area that contains the image pixels per se. It is filled
+ when raw2image() or dcraw_process() is called.
+
libraw_output_params_t params;
+
Data structure intended for management of image postprocessing (using
+ the dcraw emulator). Fields of this structure are described in detail below .
Structure libraw_iparams_t: Main Parameters of the Image
+
+
char make[64];
+
Camera manufacturer.
+
char model[64];
+
Camera model.
+
normalized_make[64]
+
There is a huge number of identical cameras sold under different
+ names, depending on the market (e.g. multiple Panasonic or Canon models)
+ and even some identical cameras sold under different brands (Panasonic
+ -> Leica, Sony -> Hasselblad). normalized_make contains primary
+ vendor name (e.g. Panasonic for Leica re-branded cameras).
+
normalized_model[64]
+
Primary camera model name.
+
unsigned maker_index
+
Primary vendor name in indexed form (enum LibRaw_cameramaker_index,
+ LIBRAW_CAMERAMAKER_* constant)
+
char software[64];
+
Softwary name/version (mostly for DNG files, to distinguish in-camera
+ DNGs from Adobe DNG Converter produced ones).
+
unsigned raw_count;
+
Number of RAW images in file (0 means that the file has not been
+ recognized).
+
unsigned is_foveon;
+
Nonzero for Sigma Foveon images
+
unsigned dng_version;
+
DNG version (for the DNG format).
+
int colors;
+
Number of colors in the file.
+
unsigned filters;
+
Bit mask describing the order of color pixels in the matrix (0 for
+ full-color images). 32 bits of this field describe 16 pixels (8 rows
+ with two pixels in each, from left to right and from top to bottom).
+ Each two bits have values 0 to 3, which correspond to four possible
+ colors. Convenient work with this field is ensured by the
+ COLOR(row,column) function, which returns the number of the active color
+ for a given pixel.
+ Values less than 1000 are reserved as special cases:
+
+
1 - Leaf Catchlight with 16x16 bayer matrix;
+
9 - Fuji X-Trans (6x6 matrix)
+
3..8 and 10..999 - are unused.
+
+
+
char xtrans[6][6];
+
char xtrans_abs[6][6];
+
These matrices contains Fuji X-Trans row/col to color mapping. First
+ one is relative to visible area, while second is positioned relative to
+ sensor edges.
+
char cdesc[5];
+
Description of colors numbered from 0 to 3 (RGBG,RGBE,GMCY, or GBTG).
+
unsigned xmplen; char *xmpdata;
+
XMP packed data length and pointer to extracted XMP packet.
+
+
+
Structure libraw_image_sizes_t: Image Dimensions
+
Structure libraw_image_sizes_t is a collection of all file data that
+ describe the size of the image.
+
Data fields:
+
+
ushort raw_height, raw_width;
+
Full size of RAW image (including the frame) in pixels.
+
ushort height, width;
+
Size of visible ("meaningful") part of the image (without the frame).
+
ushort top_margin, left_margin;
+
Coordinates of the top left corner of the frame (the second corner is
+ calculated from the full size of the image and size of its visible
+ part).
+
ushort iheight, iwidth;
+
Size of the output image (may differ from height/width for cameras
+ that require image rotation or have non-square pixels).
+
unsigned raw_pitch;
+
Full size of raw data row in bytes .
+
double pixel_aspect;
+
Pixel width/height ratio. If it is not unity, scaling of the image
+ along one of the axes is required during output.
+
int flip;
+
Image orientation (0 if does not require rotation; 3 if requires
+ 180-deg rotation; 5 if 90 deg counterclockwise, 6 if 90 deg clockwise).
item at[0] contains standard crop data parsed from camera metadata
+ (DNG: DefaultCrop* tags, other formats: vendor specific tags)
+
item at [1] is 'user crop', in particular:
+ - set by DNG DefaultUserCrop tag
+ - or set via raw aspect ratio tags (e.g. 16:9 aspect on Fujifilm
+ cameras) raw_inset_crops[1] is filled only if aspect ratio tags
+ provides different aspect ratio compared to raw_inset_crops[0].
+
+
+
+
+
Structure libraw_colordata_t: Color Information
+
Structure libraw_colordata_t unites all color data, both retrieved from
+ the RAW file and calculated on the basis of the image itself. For
+ different cameras, there are different ways of color handling.
+
Data fields:
+
+
ushort curve[0x10000];
+
Camera tone curve. May be read from file as is, or calculated,
+ depending on file format;
+
unsigned black;
+
Black level. Depending on the camera, it may be zero (this means that
+ black has been subtracted at the unpacking stage or by the camera
+ itself), calculated at the unpacking stage, read from the RAW file, or
+ hardcoded.
+
unsigned cblack[4102];
+
Per-channel black level correction. First 4 values are per-channel
+ correction, next two are black level pattern block size, than
+ cblack[4]*cblack[5] correction values (for indexes
+ [6....6+cblack[4]*cblack[5]).
+
unsigned data_maximum;
+
Maximum pixel value in current file. Calculated at raw2image or
+ dcraw_process() calls.
+
unsigned maximum;
+
Maximum pixel value. Calculated from the data for most cameras,
+ hardcoded for others. This value may be changed on postprocessing stage
+ (when black subtraction performed) and by automated maximum adjustment
+ (this adjustment performed if params.adjust_maximum_thr
+ is set to nonzero).
+
unsigned linear_max[4];
+
Per-channel linear data maximum read from file metadata. If RAW file
+ does not contains this data, linear_max[] is set to zero. Black value is
+ not subtracted
+
float fmaximum;
+
Maximum pixel value in real image for floating data files.
+
float fnorm;
+
Normalization coefficient used while converting floating point raw
+ data to integer.
+
ushort white[8][8];
+
Block of white pixels extracted from files CIFF/CRW. Not extracted for
+ other formats. Used to calculate white balance coefficients.
+
float cam_xyz[4][3];
+
Camera RGB - XYZ conversion matrix. This matrix is constant (different
+ for different models). Last row is zero for RGB cameras and non-zero for
+ different color models (CMYG and so on).
+
float cam_mul[4];
+
White balance coefficients (as shot). Either read from file or
+ calculated.
+
float pre_mul[4];
+
White balance coefficients for daylight (daylight balance). Either
+ read from file, or calculated on the basis of file data, or taken from
+ hardcoded constants.
+
float cmatrix[3][4];
+
Camera color data read from RAW file (if any)
+
float rgb_cam[3][4];
+
Camera to sRGB conversion matrix
+
float ccm[3][4];
+
Camera color correction matrix read from file metadata (uniform
+ matrix if no such data in file)
+
ph1_t phase_one_data;
+
Color data block that is read for Phase One cameras.
+
float flash_used;
+
float canon_ev;
+
Fields used for white balance calculations (for some P&S Canon
+ cameras).
Pointer to the retrieved ICC profile (if it is present in the RAW
+ file).
+
unsigned profile_length;
+
Length of ICC profile in bytes.
+
unsigned black_stat[8];
+
Black level statistics if calculated from masked area: 4 sum of pixel
+ values, than 4 pixel counts (per channel).
+
libraw_dng_color_t dng_color[2];
+
Color data read from DNG: illuminant, calibration matrix and color
+ matrix for two light sources. (see DNG specs for details).
+
libraw_dng_levels_t dng_levels
+
DNG black/white levels, analog balance, WB for active IFD. See DNG
+ specs for details.
+
int WB_Coeffs[256][4]
+
Index: EXIF color source value, [i][0..3] WB Coeffs
+
float WBCT_Coeffs[64][5]
+
Color temperature in [i][0], WB coeffs in [i][1..4]
+
int as_shot_wb_applied
+
Set to 1 if WB already applied in camera (multishot modes; small raw)
+
libraw_P1_color_t P1_color[2]
+
Phase-one specific color data
+
unsigned raw_bps
+
RAW bits per pixel (PhaseOne: Raw format used)
+
int ExifColorSpace
+
EXIF color space parsed from EXIF tags: LIBRAW_COLORSPACE_Unknown,
+ LIBRAW_COLORSPACE_sRGB, or LIBRAW_COLORSPACE_Adobe
+
+
+
Structure libraw_imgother_t: Other Parameters of the Image
+
Data fields:
+
+
float iso_speed;
+
ISO sensitivity.
+
float shutter;
+
Shutter speed.
+
float aperture;
+
Aperture.
+
float focal_len;
+
Focal length.
+
time_t timestamp;
+
Date of shooting.
+
unsigned shot_order;
+
Serial number of image.
+
unsigned gpsdata[32];
+
GPS data (unparsed block, to write to output as is).
+
libraw_gps_info_t parsed_gps;
+
Parsed GPS-data: longitude/latitude/altitude and time stamp.
+
char desc[512];
+
Image description.
+
char artist[64];
+
Author of image.
+
float FlashEC;
+
Flash exposure compensation.
+
+
+
Structure libraw_rawdata_t: holds unpacked RAW data
+
Structure libraw_rawdata_t holds:
+
+
RAW-data from sensor, read and unpacked by the
+ unpack() call.
+
"backup" copy of color and over data modified during postprocessing.
+ When postprocessing calls repeats, the needed data is restored from this
+ backup.
+
+
Data fields:
+
+
void *raw_alloc;
+
Buffer allocated to hold RAW-data
+
unsigned short *raw_image;
+
Pointer to buffer with one-component (bayer) data.
+
unsigned short (*color3_image)[3];
+
Pointer to 3-component pixel array.
+
unsigned short (*color4_image)[4];
+
Pointer to buffer with 4-component pixel data data
+
float *float_image;
+
Pointer to buffer with one-component (bayer) data in FP-format.
+
float (*float3_image)[3];
+
Pointer to 3-component FP pixel array.
+
float (*float4_image)[4];
+
Pointer to buffer with 4-component pixel data data
+
+
After call to unpack() only one of
+ these fields is non-NULL.
+
All other fields of this structure are for internal use and should not be
+ touched by user code.
+
Structure libraw_thumbnail_t: Description of Thumbnail
+
Structure libraw_thumbnail_t describes all parameters associated with the
+ preview saved in the RAW file.
Array of libraw_thumbnail_item_t, one for each thumbnail:
+
+
enum LibRaw_internal_thumbnail_formats tformat
+
Internal thumbnail format (this field stores thumbnail decoder
+ needed for thumbnail extraction)
+
ushort twidth, theight
+
Thumbnail image size. Note: these fields may be zero (so, image
+ size is unknown at parse phase)
+
ushort tflip
+
Thumbnail image rotation, it may differ from main image rotation.
+ This field may be set to 0xffff, this means 'rotation is not known'
+
unsigned tlength;
+
Thumbnail on-disk data size
+
unsigned tmisc;
+
Bits per pixel and color count: (color << 5) | bits
+
INT64 toffset;
+
Thumbnail data offset in file
+
+
+
+
+ Note: even if no thumbnails were found in TIFF/CR3 structure, the
+ thumbcount field will be initialized to 1 and thumblist[0] will be
+ initialized to thumbnail data from the thumbnail data, so
+ LibRaw::unpack_thumb_ex(0) will do the same as LibRaw::unpack_thumb().
+
+
+
Structure libraw_lensinfo_t: parsed lens data
+
The following parameters are extracted from Makernotes and EXIF, to help
+ identify which lens was mounted on the camera. If the value is missing in
+ Makernotes or EXIF, the parameter is set to zero with some exceptions
+ noted below. In some cases the values for the fields like CameraFormat and
+ CameraMount are set based on the camera model and/or camera ID.
Lens string, if not empty, contains the lens name
+ present in Makernotes.
+
LensFormat and CameraFormat
+ currently provide one of value from enum LibRaw_camera_formats;
+
In a similar manner, values for LensMount and CameraMount
+ follow the enum LibRaw_camera_mounts;
+
In some cases, the Makernotes for MF cameras contain either an id for
+ the body, or a string containing the name of the body. The name is
+ copied to body field, while the id is converted to the
+ appropriate body name and also copied to 'body' field. In other cases
+ the 'body' field is empty.
+
FocalType is set based on Makernotes tag, if present.
+ The values are:
+
+
-1 Undefined
+
0 Unknown;
+
1 Fixed focal length lens
+
2 Zoom lens
+
+
LensFeatures_pre - lens name prefix and LensFeatures_suf
+ - lens name suffix: (if not empty) some cameras record alphabet soup
+ that characterizes the lens in separate Makernote tags (see, for
+ example, 0xb02a LensSpec at http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Sony.html
+ ), and for some lenses those acronyms can be derived from the 'Lens'
+ field itself (see processCanonCameraInfo). Those can also help better
+ lens identification.
+
MinFocal and MaxFocal , if
+ non-zero, contain the minimum and maximum focal lengths for the lens
+ mounted on the camera.
+
MaxAp4MinFocal, MaxAp4MaxFocal, MinAp4MinFocal,
+ MinAp4MaxFocal - if non-zero, contain maximum aperture
+ available at minimal focal length, maximum aperture available at maximum
+ focal length, minimum aperture available at minimal focal length,
+ minimum aperture available at maximum focal length, respectively.
+
MaxAp and MinAp, if non-zero,
+ contain the maximum aperture for the lens (usually it is the maximum
+ aperture for minimal focal length) and the minimum aperture across the
+ focal length range. For zooms with variable maximum aperture this is
+ usually the minimum aperture for the maximum focal length.
+
CurFocal, if non-zero, is current focal length - that
+ is the focal length used to take the shot.
+
CurAp, if non-zero, is current aperture.
+
MaxAp4CurFocal and MinAp4CurFocal,
+ if non-zero, contain the minimum and maximum apertures for the current
+ focal length.
+
LensFStops - if non-zero, contains the number of
+ aperture "clicks" or the number of f-stops, depending on the model of
+ the camera.
+
TeleconverterID, AdapterID, AttachmentID,
+ if non-zero, are the numbers extracted from Makernotes to identify lens
+ accessories used to take the shot.
+
Teleconverter, Adapter, Attachment,
+ if non-empty, are the strings containing the names of the accessories as
+ they appear in Makernotes, or for some cameras, decoded from a numeric
+ field in Makernotes.
+
FocalUnits - an auxiliary field, should not be needed
+ most of the cases. See Canon.pm module in exiftool for more information
+ on this value.
+
FocalLengthIn35mmFormat, if non-zero: for some reason
+ certain Samsung cameras record this value in Makernotes instead of the
+ EXIF proper. Also used for Sigma cameras.
Contains minimum focal length, maximum focal length, maximum aperture
+ available at minimal focal length, and maximum aperture available at
+ maximum focal length, extracted from EXIF field of a DNG raw file.
+
libraw_lensinfo_t structure:
+
Contains all the structures described above, plus parameters extracted
+ directly from EXIF fields:
+
+
MinFocal and MaxFocal , if
+ non-zero, contain the minimum and maximum focal lengths for the lens
+ mounted on the camera.
+
MaxAp4MinFocal, MaxAp4MaxFocal - if
+ non-zero, contain maximum aperture available at minimal focal length and
+ maximum aperture available at maximum focal length
+
LensMake, if not empty, contains a string with the
+ lens manufacturer name.
+
Lens, if not empty, contains the lens name as
+ recorded in EXIF
+
FocalLengthIn35mmFormat - if non-zero, same as
+ FocalLengthIn35mmFilm in EXIF standard, tag 0xa405.
+
EXIF_MaxAp - if non-zero, contains the value derived
+ from EXIF tag 0x9205.
+
+
+
Structure libraw_raw_unpack_params_t: RAW decoding options and flags
+
Structure libraw_raw_unpack_params_t contains fields/flags that affects
+ RAWdata and metadata decoding
+
+
int options
+
Processing options used on unpack() phase for specific image formats,
+ see below for possible values:
+ LibRaw_processing_options
+
unsigned shot_select;
+
dcraw keys: -s
+ Selection of image number for processing (for formats that contain
+ several RAW images in one file).
+
int specials
+
Special processing mode (e.g. omit YCC to RGB conversion), see below
+ for possible values.
+ LibRaw_rawspecial_t
+
int max_raw_memory_mb
+
Stop processing if raw buffer size grows larger than that value (in
+ megabytes). Default is LIBRAW_MAX_ALLOC_MB_DEFAULT (2048Mb)
+
int sony_arw2_posterization_thr
+
If LIBRAW_PROCESSING_SONYARW2_DELTATOVALUE used for
+ raw_processing_options, sets the level to suppress posterization display
+ in shadows.
+
float coolscan_nef_gamma;
+
Gamma value for Coolscan NEF decoding (no way to get if from file, it
+ should be set by calling application).
+
char p4shot_order[5];
+
Shot order for Pentax 4shot files. Default is "3102".
+
+
+
Structure libraw_output_params_t: management of dcraw-style
+ postprocessing
+
Structure libraw_output_params_t (imgdata.params) is used for management
+ of dcraw-compatible calls dcraw_process(), dcraw_ppm_tiff_writer(), and
+ dcraw_thumb_writer(). Fields of this structure correspond to command line
+ keys of dcraw.
+
Data fields:
+
+
unsigned greybox[4];
+
dcraw keys: -A x y w h
+ 4 numbers corresponding to the coordinates (in pixels) of the rectangle
+ that is used to calculate the white balance. X and Y are coordinates of
+ the left-top rectangle corner; w and h are the rectangle's width and
+ height, respectively.
+
unsigned cropbox[4];
+
dcraw keys: none
+ This field sets the image cropping rectangle. Cropbox[0] and cropbox[1]
+ are the rectangle's top-left corner coordinates, remaining two values
+ are width and height respectively. All coordinates are applied before
+ any image rotation.
+
double aber[4];
+
dcraw keys: -C
+ Correction of chromatic aberrations; the only specified values are
+ aber[0], the red multiplier
+ aber[2], the blue multiplier. For some formats, it affects
+ RAW data reading , since correction of aberrations changes the
+ output size.
+
double gamm[6];
+
dcraw keys: -g power toe_slope
+ Sets user gamma-curve. Library user should set first two fields of gamm
+ array:
+ gamm[0] - inverted gamma value)
+ gamm[1] - slope for linear part (so called toe slope). Set to zero for
+ simple power curve.
+ Remaining 4 values are filled automatically.
+ By default settings for rec. BT.709 are used: power 2.222 (i.e.
+ gamm[0]=1/2.222) and slope 4.5. For sRGB curve use gamm[0]=1/2.4 and
+ gamm[1]=12.92, for linear curve set gamm[0]/gamm[1] to 1.0.
+
float user_mul[4];
+
dcraw keys: -r mul0 mul1 mul2 mul3
+ 4 multipliers (r,g,b,g) of the user's white balance.
+
float bright;
+
dcraw keys: -b
+ Brightness (default 1.0).
+
float threshold;
+
dcraw keys: -n
+ Parameter for noise reduction through wavelet denoising.
+
int half_size;
+
dcraw keys: -h
+ Outputs the image in 50% size. For some formats, it affects
+ RAW data reading .
+
int four_color_rgb;
+
dcraw keys: -f
+ Switches on separate interpolations for two green components.
dcraw keys: -a
+ Use automatic white balance obtained after averaging over the entire
+ image.
+
int use_camera_wb;
+
dcraw keys: -w
+ If possible, use the white balance from the camera.
+
If camera-recorded WB is not available, dcraw_process() will
+ fallback to:
+
+
Auto-WB if bit LIBRAW_PROCESSING_CAMERAWB_FALLBACK_TO_DAYLIGHT is
+ not set in params.raw_processing_options (or for the rare specific
+ case: no valid WB index was parsed from CRW file)
+
Daylight-WB if abovementioned bit is not set.
+
+
+
int use_camera_matrix;
+
dcraw keys: +M/-M
+
+
0: do not use embedded color profile
+
1 (default): use embedded color profile (if present) for DNG files
+ (always); for other files only if use_camera_wb is set;
+
3: use embedded color data (if present) regardless of white
+ balance setting.
dcraw keys: -o filename
+ Path to output profile ICC file (used only if LibRaw compiled with LCMS
+ support)
+
char* camera_profile;
+
dcraw keys: -p file
+ Path to input (camera) profile ICC file (or 'embed' for embedded
+ profile). Used only if LCMS support compiled in.
+
char* bad_pixels;
+
dcraw keys: -P file
+ Path to file with bad pixels map (in dcraw format: "column row
+ date-of-pixel-death-in-UNIX-format", one pixel per row).
+
char* dark_frame;
+
dcraw keys: -K file
+ Path to dark frame file (in 16-bit PGM format)
+
int output_bps;
+
dcraw keys: -4
+ 8 bit (default)/16 bit (key -4).
+
int output_tiff;
+
dcraw keys: -T
+ 0/1: output PPM/TIFF.
+
int output_flags;
+
dcraw keys: none
+ Bitfield that allows to set output file options:
+
+
LIBRAW_OUTPUT_FLAGS_PPMMETA - write additional
+ metadata into PPM/PGM output files
+
+
+
int user_flip;
+
dcraw keys: -t
+ [0-7] Flip image (0=none, 3=180, 5=90CCW, 6=90CW). Default -1, which
+ means taking the corresponding value from RAW.
+ For some formats, affects RAW data reading
+ , e.g., unpacking of thumbnails from Kodak cameras.
+
int user_qual;
+
dcraw keys: -q
+ 0-10: interpolation quality:
+
+
0 - linear interpolation
+
1 - VNG interpolation
+
2 - PPG interpolation
+
3 - AHD interpolation
+
4 - DCB interpolation
+
11 - DHT interpolation
+
12 - Modified AHD interpolation (by Anton Petrusevich)
+
+
+
int user_black;
+
dcraw keys: -k
+ User black level.
+
int user_cblack[4];
+
dcraw keys: none
+ Per-channel corrections to user_black.
+
int user_sat;
+
dcraw keys: -S
+ Saturation adjustment.
+
int med_passes;
+
dcraw keys: -m
+ Number of median filter passes.
+
int no_auto_bright;
+
dcraw keys: -W
+ Don't use automatic increase of brightness by histogram.
+
float auto_bright_thr;
+
dcraw keys: none
+ Portion of clipped pixels when auto brightness increase is used. Default
+ value is 0.01 (1%) for dcraw compatibility. Recommended value for modern
+ low-noise multimegapixel cameras depends on shooting style. Values in
+ 0.001-0.00003 range looks reasonable.
+
float adjust_maximum_thr;
+
dcraw keys: none
+ This parameters controls auto-adjusting of maximum value based on
+ channel_maximum[] data, calculated from real frame data. If calculated
+ maximum is greater than adjust_maximum_thr*maximum, than maximum is set
+ to calculated_maximum.
+ Default: 0.75. If you set this value above 0.99999, than default value
+ will be used. If you set this value below 0.00001, than no maximum
+ adjustment will be performed.
+ Adjusting maximum should not damage any picture (esp. if you use default
+ value) and is very useful for correcting channel overflow problems
+ (magenta clouds on landscape shots, green-blue highlights for indoor
+ shots).
+
int use_fuji_rotate;
+
dcraw keys: -j
+ Default -1 (use), 0 - don't use rotation for cameras on a Fuji sensor.
+
int green_matching;
+
Turns on fixing of green channels disbalance. dcraw keys:
+ none
+ Default: 0 (not use), 1 - turns on this postprocessing stage.
+ green_matching requires additional memory for image data.
+
int dcb_iterations
+
dcraw keys: none
+ Number of DCB correction passes. Default is -1 (no correction). Useful
+ only for DCB interpolation.
exp_correc: positive value turns the feature on (default: off).
+
exp_shift: exposure shift in linear scale. Usable range from 0.25
+ (2-stop darken) to 8.0 (3-stop lighter). Default: 1.0 (no exposure
+ shift).
+
exp_preser: preserve highlights when lighten the image. Usable
+ range from 0.0 (no preservation) to 1.0 (full preservation). 0.0 is
+ the default value.
+
+
+
int use_rawspeed;
+
Turns on using RawSpeed library for data unpacking (only if RawSpeed
+ support compiled in).
+
int use_dng_sdk;
+
Turns on using Adobe DNG SDK (if compiled with it and dng host is set:
+
+
+
0 - do not use
+
1 - use for speciality formats (Float, Linear DNG, deflate
+ compression, 8 bit)
+
2 - use for all DNG files
+
+
+
int no_auto_scale;
+
Disables pixel values scaling (call to LibRaw::scale_colors()) in
+ LibRaw::dcraw_process().
+ This is special use value because white balance is
+ performed in scale_colors(), so skipping it will result in non-balanced
+ image.
+ This setting is targeted to use with no_interpolation, or with own
+ interpolation callback call.
+
int no_interpolation;
+
Disables call to demosaic code in LibRaw::dcraw_process()
+
int use_p1_correction;
+
If set to non-zero (default): PhaseOne compressed files will be corrected (linearization; defect mapping)
+ based on metadata contained in file.
Called on data error, settable via set_dataerror_handler. See C++
+ API for details.
+
progress_callback progress_cb
+
Called on process callback, settable via set_progress_handler. See C++ API for details.
+
exif_parser_callback exif_cb, params: (void *context, int tag, int
+ type, int len, unsigned int ord, void *ifp)
+
Called by EXIF/TIFF IFD parsers on each processed tag.
+ Parameters:
+
+
context: user-specified context, set via set_exifparser_handler()
+
tag: 16-bit of TIFF/EXIF tag or'ed with
+
+
0 - for EXIF parsing
+
0x20000 - for Kodak makernotes parsing
+
0x30000 - for Panasonic makernotes parsing
+
0x40000 - for EXIF Interop IFD parsing
+
0x50000 - for EXIF GPS IFD parsing
+
(ifdN + 1) << 20) - for TIFF ifdN
+
+
+
type: tag type (see TIFF/EXIF specs)
+
len: tag length
+
ord: byte order: 0x4949 for intel, 0x4d4d for motorola
+
ifp: pointer to LibRaw_abstract_datastream input stream,
+ positioned to start of data. There is no need to restore data
+ position in callback.
+
+
+
int pre_identify_cb(void *)
+
Called with this pointer as the only arg before calling to
+ LibRaw::identify. If this callback return non-zero value, that means
+ that identify() is not needed and all internal data fields are filled
+ with values.
+
void post_identify_cb(void *)
+
Called after identify() from open_datastream(). May be used to tune
+ internal variables after metadata parse.
+
dcraw_process() callbacks
+
These callbacks are called before/after dcraw_process phases, the only
+ passed parameter is this pointer
+
+
pre_subtractblack_cb - called before black subtraction
+
pre_scalecolors_cb - called before scale_colors() call
+
pre_preinterpolate_cb - called before interpolaton (demosaic)
+
interpolate_bayer_cb - if set, called for bayer demosaic
+ (regardless of params.user_qual value)
+
interpolate_xtrans_cb - if set, called for X-Trans demosaic
+
post_interpolate_cb - called after demosaic step. Note: if this
+ callback is set, standard median_filter() is not called. So, if you
+ need median filtering you should call it from callback function.
+
pre_converttorgb_cb - called after convert_to_rgb()
+
post_converttorgb_cb - called after convert_to_rgb(), so very last
+ processing step.
+
+
+
+
+
Structure libraw_decoder_info_t: RAW decoder name and data format
+
This structure describes RAW format decoder name and data format:
Structure libraw_processed_image_t - result set for
+ dcraw_make_mem_image()/dcraw_make_mem_thumb() functions
+
Structure libraw_processed_image_t is produced by call of
+ dcraw_make_mem_image()/dcraw_make_mem_thumb() and contains in-memory image
+ of interpolated data or thumbnail.
+
Data fields:
+
+
LibRaw_image_formats type
+
This field records type of data, containing in remaining fields of
+ structure.
+
+
LIBRAW_IMAGE_BITMAP - structure contains RGB
+ bitmap. All metadata fields (see below) are valid and describes
+ image data.
+
LIBRAW_IMAGE_JPEG - structure contain
+ in-memory image of JPEG file. Only type, data_size and data fields
+ are valid (and nonzero);
+
+
+
ushort height,width
+
Image size (in pixels). Valid only if type==LIBRAW_IMAGE_BITMAP.
+
ushort colors, bits
+
Number of colors components (1 or 3) and color depth in bits (8 or
+ 16). These fields are valid only if type==LIBRAW_IMAGE_BITMAP.
+
ushort gamma_corrected
+
Is bitmap data gamma-corrected (always 1 for 8-bit data, may be 0 or 1
+ for 16-bit). Valid only if type==LIBRAW_IMAGE_BITMAP.
+
unsigned int data_size
+
Size of data field (in bytes). For bitmap image
+ equal to (height*width*colors * (bits/8)). For JPEG image - exact JPEG
+ size (i.e. extracted thnumbnail size + JPEG header + EXIF header).
+
unsigned char data[]
+
Data array itself. Should be interpreted as RGB triplets for bitmap
+ type and as JPEG file for JPEG type.
+
+
+
Input abstraction layer
+
RAW data input (read) in LibRaw implemented by calling methods of object
+ derived from LibRaw_abstract_datastream abstract
+ class. Full list of methods is described in
+ href="API-CXX.html#datastream">C++ API reference.
+
There is two ready to use implementations of datastream objects:
LibRaw user can create own datastream object derived from
+ LibRaw_abstract_datastream . For example, such object may
+ implement reading RAW data directly from camera (by remote interface).
+ LibRaw can use these objects via
+ LibRaw::open_datastream() interface.
Only C++ API users may use object-oriented
+ interface and implement own input interfaces. For C
+ API users only built-on
+ libraw_open_file()/libraw_open_buffer() shortcuts are
+ available.
+
+
Data fields
+
Definition:
+
class LibRaw_abstract_datastream {...protected: LibRaw_abstract_datastream *substream;}
+
+
Description: Objects derived from
+ LibRaw_abstract_datastream always contains pointer to secondary data
+ stream (substream). This substream initialized internally when needed
+ (really used only for Sony RAW data) and used for temporary switch input
+ stream to temporary memory buffer allocated internally in LibRaw.
All functions returning integer numbers must return either errno or one
+ of the following error codes (see also
+ error code conventions ).
+
Fatal errors (return of such an error code implies
+ that file processing has to be terminated, since the state of data
+ structures is unknown).
+
+
LIBRAW_UNSUFFICIENT_MEMORY
+
Attempt to get memory from the system has failed.
+ All allocated resources will be freed,
+ recycle() will be called, and the LibRaw object will be brought
+ to the state "right after creation."
+
LIBRAW_DATA_ERROR
+
A fatal error emerged during data unpacking.
+ All allocated resources will be freed,
+ recycle() will be called, and the LibRaw object will be brought
+ to the state "right after creation."
+
LIBRAW_IO_ERROR
+
A fatal error emerged during file reading (premature end-of-file
+ encountered or file is corrupt).
+ All allocated resources will be freed,
+ recycle() will be called, and the LibRaw object will be brought
+ to the state "right after creation."
+
LIBRAW_CANCELLED_BY_CALLBACK
+
Processing cancelled due to calling application demand (by returning
+ nonzero code from progress callback
+ ).
+ All allocated resources will be freed,
+ recycle() will be called, and the LibRaw object will be brought
+ to the state "right after creation."
+
LIBRAW_BAD_CROP
+
The incorrect cropping coordinates are set via params.cropbox[]: the
+ left-top corner of cropping rectangle is outside the image. The
+ processing will be cancelled, all allocated resources will be freed, LIBRAW_TOO_BIG
Returned upon an attempt to retrieve a thumbnail from a file
+ containing no preview.
+
LIBRAW_UNSUPPORTED_THUMBNAIL
+
RAW file contains a preview of unsupported format.
+
LIBRAW_INPUT_CLOSED
+
Input stream is not available for reading.
+
LIBRAW_NOT_IMPLEMENTED
+
Decoder for specific RAW storage/compression format is not
+ implemented.
+
LIBRAW_REQUEST_FOR_NONEXISTENT_THUMBNAIL
+
Attempt to retrieve a non-existent thumbnail by (invalid) index.
+
+
+
enum LibRaw_decoder_flags - RAW data format description
+
Depending of capabilities of given data format, the buffer with RAW data
+ may have different layouts:
+
+
LIBRAW_DECODER_HASCURVE
+
This flag is set if decoder uses RAW tone curve and curve data may be
+ modified before call to decoder (i.e. curve values are not read or
+ calculated within decoder).
+
LIBRAW_DECODER_SONYARW2
+
This flag is set if file format is Sony ARW2.3, so sony_arw2_options
+ is applicable.
+
LIBRAW_DECODER_TRYRAWSPEED
+
This flag is set if file format is (possibly) supported by RawSpeed
+ library, so unpack() will try to use it.
+
LIBRAW_DECODER_FIXEDMAXC
+
Do not use automated maximum calculation for this data format.
+
LIBRAW_DECODER_OWNALLOC
+
Decoder allocates data, no need to pass allocated memory to decoder.
+
LIBRAW_DECODER_ADOBECOPYPIXEL
+
Internal flag, special to adobe DNG decoder.
+
LIBRAW_DECODER_LEGACY_WITH_MARGINS
+
Special flag uset for 4-channel (legacy) decoders with black/masked
+ areas
+
LIBRAW_DECODER_3CHANNEL
+
3-component full-color data (not usual 4-component)
+
+
+
enum LibRaw_progress: Current State of LibRaw Object
+
LibRaw::imgdata.progress_flags contains a bit mask describing all stages
+ of file processing that have already been performed.
+
File opening and RAW data extraction phase.
+
+
LIBRAW_PROGRESS_START=0
+
Object just created, no processing carried out.
+
LIBRAW_PROGRESS_OPEN
+
File to be processed has been opened.
+
LIBRAW_PROGRESS_IDENTIFY
+
Data identification performed, format recognized, metadata extracted.
+
LIBRAW_PROGRESS_SIZE_ADJUST
+
Data sizes adjusted (for files that require such adjustment, namely,
+ certain files from Kodak cameras).
+
LIBRAW_PROGRESS_LOAD_RAW
+
RAW data loaded.
+
+
The following flags are set during usage of image processing
+ that has been taken from dcraw.
+
+
LIBRAW_PROGRESS_RAW2_IMAGE
+
imgdata.image array allocated and filled with data.
+
LIBRAW_PROGRESS_REMOVE_ZEROES
+
Zero values removed for cameras that require such removal (Panasonic
+ cameras).
+
LIBRAW_PROGRESS_BAD_PIXELS
+
Bad (dead) pixels removed.
+
LIBRAW_PROGRESS_DARK_FRAME
+
Dark frame subtracted from RAW data.
+
LIBRAW_PROGRESS_FOVEON_INTERPOLATE
+
Interpolation for cameras with a Foveon sensor performed.
+
LIBRAW_PROGRESS_SCALE_COLORS
+
White balance performed.
+
LIBRAW_PROGRESS_PRE_INTERPOLATE
+
Image size reduction (for the half_size mode) performed, as well as
+ copying of 2nd green channel to the 1st one in points where the second
+ channel is present and the first one is absent.
+
LIBRAW_PROGRESS_INTERPOLATE
+
Interpolation (debayer) performed.
+
LIBRAW_PROGRESS_MIX_GREEN
+
Averaging of green channels performed.
+
LIBRAW_PROGRESS_MEDIAN_FILTER
+
Median filtration performed.
+
LIBRAW_PROGRESS_HIGHLIGHTS
+
Work with highlights performed.
+
LIBRAW_PROGRESS_FUJI_ROTATE
+
For images from Fuji cameras, rotation performed (or
+ adjust_sizes_info_only() called).
+
LIBRAW_PROGRESS_FLIP
+
Dimensions recalculated for images shot with a rotated camera
+ (sizes.iwidth/sizes.iheight swapped).
+
LIBRAW_PROGRESS_CONVERT_RGB
+
Conversion into output RGB space performed.
+
LIBRAW_PROGRESS_STRETCH
+
Image dimensions changed for cameras with non-square pixels.
+
LIBRAW_PROGRESS_STAGE17 - LIBRAW_PROGRESS_STAGE27
+
Reserved for possible appearance of other processing stages.
+
+
The following flags are set during loading of thumbnails.
+
LIBRAW_PROGRESS_THUMB_LOAD Thumbnail data have been
+ loaded (for Kodak cameras, the necessary conversions have also been made).
+ LIBRAW_PROGRESS_TRESERVED1 - LIBRAW_PROGRESS_TRESERVED3
+ Reserved for possible future processing stages.
+
+
enum LibRaw_whitebalance_code - names for standard light sources
+
LIBRAW_WBI_lightsource_name, where name and value are standard EXIF light
+ sources.
+
enum LibRaw_camera_mounts - codes for camera mounts
+
Constant name (e.g. LIBRAW_MOUNT_Leica_SL) speaks for itself
+
enum LibRaw_runtime_capabilities - libraw capabilities set at build
+
+
LIBRAW_CAPS_RAWSPEED - compiled with RawSpeed
+
LIBRAW_CAPS_DNGSDK - compiled with Adobe DNG SDK
+
LIBRAW_CAPS_GPRSDK - compiled w/ GoPro GPR SDK
+
LIBRAW_CAPS_UNICODEPATHS - compiled with Windows
+ unicode (wchar_t*) filenames support
+
+
+
enum LibRaw_thumbnail_formats: Thumbnail Data Formats
+
Thumbnail data format is written in the imgdata.thumbnail.tformat data
+ field.
+ Presently LibRaw knows about four thumbnail formats, among which two are
+ unpacked:
+
+
LIBRAW_THUMBNAIL_UNKNOWN
+
Format unknown or thumbnail not yet read.
+
LIBRAW_THUMBNAIL_JPEG
+
The thumbnail buffer contains a JPEG file (read from the RAW file "as
+ is," without any manipulations performed on it).
+
LIBRAW_THUMBNAIL_BITMAP
+
The thumbnail buffer contains the gamma-adjusted RGB bitmap (for Kodak
+ cameras, the gamma correction is performed with allowance for maximum
+ values and the white balance is set in accordance with the camera
+ settings).
+ In this format, each pixel of the image is represented by a 8-bit RGB
+ triplet.
+
LIBRAW_THUMBNAIL_BITMAP16
+
The thumbnail buffer contains the gamma-adjusted 16-bit RGB bitmap. To
+ get this format instead of LIBRAW_THUMBNAIL_BITMAP you
+ need to set LIBRAW_PROCESSING_USE_PPM16_THUMBS in
+ processing options.
+
LIBRAW_THUMBNAIL_LAYER
+
Data format is presently recognized upon opening of RAW file but not
+ supported: not unpacked into LibRaw::unpack_thumb.
+
LIBRAW_THUMBNAIL_ROLLEI
+
Data format is presently recognized upon opening of RAW file but not
+ supported: not unpacked into LibRaw::unpack_thumb.
+
LIBRAW_THUMBNAIL_H265
+
The thumbnail buffer contains a H.265 data frame (read from RAW file
+ as is, no manipulations performed on it).
+
LIBRAW_THUMBNAIL_JPEGXL
+
The thumbnail buffer contains a JPEG-XL data frame (read from RAW file
+ as is, no manipulations performed on it).
+
+
+
Nonstandard Situations (Warnings) during RAW Data Processing
+
Some suspicious situations emerging during image processing are not fatal
+ but may affect the result of data retrieval or postprocessing. Such states
+ are indicated by setting a bit in the imgdata.process_warnings field.
+
+
LIBRAW_WARN_BAD_CAMERA_WB
+
Postprocessing must use white balance of the camera but this balance
+ is not suitable for use.
+
LIBRAW_WARN_NO_METADATA
+
Only for cameras where the metadata are taken from an external JPEG
+ file: metadata extraction has failed.
+
LIBRAW_WARN_NO_JPEGLIB
+
Only for P&S Kodak cameras: data in JPEG format. At the same time,
+ open_file() will return LIBRAW_FILE_UNSUPPORTED.
+
LIBRAW_WARN_NO_EMBEDDED_PROFILE
+
(only if LCMS support compiled in). Caller set embedded input profile
+ use, but no such profile exists in RAW.
+
LIBRAW_WARN_NO_INPUT_PROFILE
+
(only if LCMS support compiled in). Error when opening input profile
+ ICC file.
+
LIBRAW_WARN_BAD_OUTPUT_PROFILE
+
(only if LCMS support compiled in). Error when opening output profile
+ ICC file.
+
LIBRAW_WARN_NO_BADPIXELMAP
+
Error when opening bad pixels map file.
+
LIBRAW_WARN_BAD_DARKFRAME_FILE
+
Error when opening dark frame file.
+
LIBRAW_WARN_BAD_DARKFRAME_DIM
+
Dark frame file either differs in dimensions from RAW-file processed,
+ or have wrong format. Dark frame should be in 16-bit PGM format (one can
+ generate it using simple_dcraw -4 -D).
+
LIBRAW_WARN_RAWSPEED_PROBLEM
+
Problems detected in RawSpeed decompressor. The image data processed
+ by LibRaw own decoder.
+
LIBRAW_WARN_RAWSPEED_UNSUPPORTED
+
This file not supported by RawSpeed (although compatible decoder
+ exists).
+
LIBRAW_WARN_RAWSPEED_PROCESSED
+
Not warning, but information. The file was decoded by RawSpeed.
+
LIBRAW_WARN_FALLBACK_TO_AHD
+
Incorrect/unsupported user_qual was set, AHD demosaic used instead.
+
LIBRAW_WARN_PARSEFUJI_PROCESSED
+
Not really a warning, but flag that fuji parser was used.
+
LIBRAW_DNGSDK_PROCESSED
+
Not really a warning: image was decoded by DNG SDK
+
LIBRAW_DNG_IMAGES_REORDERED
+
DNG sub0images was reordered
+
LIBRAW_DNG_STAGE2_APPLIED
+
DNG Stage2 conversion was performed
+
LIBRAW_DNG_STAGE3_APPLIED
+
DNG Stage3 conversion was performed
+
LIBRAW_WARN_VENDOR_CROP_SUGGESTED
+
If set: unknown/untested RAW image frame size passed to LibRaw, cropping may be incorrect.
+ It is suggested to use LibRaw::adjust_to_raw_inset_crop(1) for vendor specified crop.
+
+
+
+
+
+
enum LibRaw_image_formats - possible types of data, contains in
+ libraw_processed_image_t structure
+
type field of libraw_processed_image_t structure may
+ have one of these values:
+
+
LIBRAW_IMAGE_BITMAP
+
The structure contains RGB-bitmap, metadata described in other fields
+ of libraw_processed_image_t.
+
LIBRAW_IMAGE_JPEG
+
libraw_processed_image_t structure contains JPEG image (in memory).
+ Only data_size field is meaningful.
+
+
+
enum enum LibRaw_processing_options - bit that affects RAW data
+ extraction
+ These flags could be OR'ed with imgdata.params.raw_processing_options:
+
Pentax 4-shot options:
+
+
LIBRAW_RAWOPTIONS_PENTAX_PS_ALLFRAMES - merge all frames for
+ Pentax 4-shot files
+
+
Floating point DNG files:
+
+
LIBRAW_RAWOPTIONS_CONVERTFLOAT_TO_INT - convert FP data to
+ 16-bit integer
+
+
Sony ARQ Files:
+
+
LIBRAW_RAWOPTIONS_ARQ_SKIP_CHANNEL_SWAP - do not perform Sony
+ ARQ channel swap to RGBG channel format, but use RGGB original channel
+ order
+
+
DNG processing flags:
+
+
LIBRAW_RAWOPTIONS_DONT_CHECK_DNG_ILLUMINANT - skip DNG
+ illuminant check when parsing DNG color data (use for compatibility w/
+ older LibRaw versions).
+
LIBRAW_RAWOPTIONS_DNGSDK_ZEROCOPY - do not copy data extracted
+ by Adobe DNG SDK into separate buffer, but use DNG SDK buffer as is.
+
LIBRAW_RAWOPTIONS_DNG_ADD_ENHANCED - if set, LibRaw will add
+ Enhanced DNG frame (NewSubfileType == 16) to the list of available
+ frames.
+
LIBRAW_RAWOPTIONS_DNG_ADD_PREVIEWS - if set, LibRaw will add
+ previews (NewSubfileType == 1) to the frames list.
+
LIBRAW_RAWOPTIONS_DNG_PREFER_LARGEST_IMAGE- By default, DNG
+ frames are not reordered and are available in same order as in DNG
+ (LibRaw traverses IFD/Sub-IFD trees in deep-first order).This bit will
+ prioritize the largest image
LIBRAW_RAWOPTIONS_DNG_ALLOWSIZECHANGE - by default,
+ if image size parsed by DNG SDK does not match image dimensions parsed
+ by LibRaw, processing will stop with LIBRAW_DATA_ERROR code. This flags
+ allows size change in LibRaw::unpack() stage.
+
LIBRAW_RAWOPTIONS_DNG_DISABLEWBADJUST - by default,
+ for DNG images with different per-channel maximums WB adjustment
+ procedure is performed. This flag disables such adjustment.
+
+ Other flags
+
+
LIBRAW_RAWOPTIONS_NO_ROTATE_FOR_KODAK_THUMBNAILS - disable
+ auto-rotation for Kodak PPM bitmaps
LIBRAW_RAWOPTIONS_ZEROFILTERS_FOR_MONOCHROMETIFFS - by default,
+ LibRaw assigns bayer pattern for Monochrome TIFF files (e.g. images from
+ Kodak 760).This does not work as expected if input file is really
+ monochrome (e.g. scan from Imacon X1 in monochrome mode).This flag will
+ force monochrome mode for TIFF RAWs w/o bayer filter tags (so, it will
+ break old Kodak processing). It is better to make it settable via user
+ interaction.
+
LIBRAW_RAWOPTIONS_PROVIDE_NONSTANDARD_WB - If set and
+ when applicable, color.cam_mul[] and color.WB_Coeffs/WBCT_Coeffs will
+ contain WB settings for a non-standard workflow. Right now only Sony
+ DSC-F828 is affected: camera-recorded white balance can't be directly
+ applied to raw data because WB is for RGB, while raw data is RGBE.
+
LIBRAW_RAWOPTIONS_CAMERAWB_FALLBACK_TO_DAYLIGHT - if
+ use_camera_wb is set, but no camera-recorded white balance present in
+ metadata, then fallback to daylight WB (default: fallback to
+ auto-balance).
+
LIBRAW_RAWOPTIONS_CHECK_THUMBNAILS_KNOWN_VENDORS -
+ Some cameras (e.g.Ricoh) may record broken thumbnail in file:data offset
+ plus data size is beyond filecontents. This flag enforces size+offset
+ checks for files from known vendors (this will result into correct but
+ smaller thumbnail selected).
+
LIBRAW_RAWOPTIONS_CHECK_THUMBNAILS_ALL_VENDORS - same
+ is above, but check is performed regardless of vendor (Make tag).
+
LIBRAW_RAWOPTIONS_ALLOW_JPEGXL_PREVIEWS -
+ if set, LibRaw will perceive such previews in the same way as JPEG onesgest preview is
+ selected by default, etc).
+ tformat field for such preview is set to LIBRAW_THUMBNAIL_JPEGXL. Image metadata (width/height/channels count) is not parsed for JPEG-XL previews
+
+
+
+
+
+
enum LibRaw_rawspecial_t - special/non standard RAW extraction modes
+ These flags are applied to imgdata.rawparams:
+
Sony ARW2.3 processing options: (for more details see
+ http://www.rawdigger.com/howtouse/sony-craw-arw2-posterization-detection)
+
+
LIBRAW_RAWSPECIAL_SONYARW2_BASEONLY - decode only base pixels,
+ leave delta pixels as zero;
+
LIBRAW_RAWSPECIAL_SONYARW2_DELTAONLY - decode only delta pixels
+ with base pixels zeroed;
+
LIBRAW_RAWSPECIAL_SONYARW2_DELTAZEROBASE - decode delta pixels,
+ do not add base value;
+
LIBRAW_RAWSPECIAL_SONYARW2_DELTATOVALUE - show possible
+ posterization areas;
Since version 0.9, there is only one LibRaw variants. Older versions have
+ three separate editions (normal, -Lite and -Commercial versions).
+
+
Error Code Conventions and Error Handling
+
The following conventions concern the returned errors:
+
+
All functions that can return an error code have integer type of
+ return data.
+
If there is no error, the return value is 0 (LIBRAW_SUCCESS).
+
If an error has happened in a system call, the return value is errno
+ (a positive number), which can be analyzed using strerror() or similar
+ means.
+
All LibRaw's own error codes are negative; each of these errors
+ belongs to one of two types:
+
+
Non-fatal errors
+
Non-fatal errors do not forbid execution of other functions in the
+ processing succession (e.g., unpack_thumb()
+ can easily return the code corresponding to "preview is absent" but
+ this does not prevent further call of unpack().
+
Fatal errors
+
In the case of fatal errors (memory shortage, input data error,
+ data unpacking failure), the current stage of processing is
+ terminated and all allocated resources are freed.
+ If an attempt to continue processing is made, all subsequent API
+ calls will return the LIBRAW_OUT_OF_ORDER_CALL error.
+ At the same time, the LibRaw instance in which a fatal error has
+ occurred can process the next RAW files in the usual way (by calling
+ open_file() (or other input
+ methods), then unpack(), etc.).
+
+
+
The macro LIBRAW_FATAL_ERROR(error code) checks if an error is fatal
+ or not.
If the program has encountered a nonstandard situation that does not
+ prevent retrieval of some data from a file, it sends a signal by setting
+ the corresponding bit in imgdata.process_warnings.
+ The possible types of warnings are listed
+ and deciphered here.
+
+
Input Layer Abstraction
+
LibRaw uses objects derived from LibRaw_abstract_datastream
+ for data input. Semantics of these objects is similar to 'file with
+ arbitrary seek' object: both read and seek operations are used.
+
Some RAW formats requires temporary switch to another data stream created
+ on top on memory buffer for metadata read. Methods for doing so are
+ implemented in base class LibRaw_abstract_datastream
+ by internal data field substream. Look into source code
+ of LibRaw_file_datastream
+ class in libraw/libraw_datastream.h file for more
+ details.
+ When implementing own datastream classes, you need to take substream
+ into account and pass control to methods of this field if it is active
+ (not NULL).
+
If datastream implementation knows name of input file, it should provide
+ fname() call. This name will be used in error
+ callbacks and in guessing name of JPEG file with metadata (for RAW
+ files with external metadata).
+
For external metadata support input class should implement subfile_open()/subfile_close()
+ methods. .
+ Sample of these methods implementation may be found in LibRaw_file_datastream
+ class (look into libraw/libraw_datastream.h file for
+ details).
+
+
Thread safety
+
Thread safety is ensured if a LibRaw object is created and used within
+ one thread. At the same time, the number of threads (each with its own
+ LibRaw object) is not limited in any way (except by memory requirements).
+
If a LibRaw object is created in one execution thread and used in
+ another, external synchronization is necessary.
+
There is two libraries under Unix environment (Linux/FreeBSD/MacOS):
+ libraw_r.a (thread-safe) and libraw.a (single-threaded, slightly faster).
+
Thread-safe library version stores intermediate unpacker data into LibRaw
+ class data. So, several copies of LibRaw, working in parallel, is
+ possible.
+
Not thread-safe library uses global variable for intermediate data store
+ which is faster but not reenterant. This non-thread-safe library still may
+ be used in multi-threaded apps, but only if exactly one LibRaw class copy
+ exists in program.
+
Windows version is similar to multi-threaded Unix one.
+
+
The Use of C++
+
Exception situations within LibRaw are handled using the C++ exception
+ mechanism. All exceptions are caught inside the library functions and
+ should not penetrate outside.
+
Memory is allocated/freed using functions malloc(calloc)/free rather than
+ new/delete.
+
If C API is used, references to C++ calls new/delete still remain, and so
+ linking with libstdc++(Unix)/....(Windows) is necessary.
+
+
Parameters of the LibRaw::imgdata.params Structure Affecting the
+ Behavior of open_file/unpack/unpack_thumb
+
Most data fields of structure LibRaw::imgdata.params affect only data
+ postprocessing, but there are some exceptions, which have been
+ inherited by the current version of LibRaw from/ dcraw source texts (these
+ dependences will be gradually removed).
+
+
imgdata.params.use_camera_matrix and
+ imgdata.params.use_camera_wb
+
These fields affect loading of RAW data for cameras with a color
+ matrix.
+ Attention! If parameter imgdata.params.use_camera_matrix
+ is not set by the user, it is copied from imgdata.params.use_camera_wb
+ at the stage of file opening.
+
imgdata.params.user_flip
+
If this parameter is greater than or equal to zero, assignment imgdata.sizes.flip
+ = imgdata.params.user_flip is performed at the open_file()
+ stage.
+
imgdata.params.shot_select
+
This parameter makes it possible to select the number of the extracted
+ image for data formats in which storage of several RAW images in one
+ data file is possible.
+
imgdata.params.half_size
+
Affects RAW data loading for Phase One and Sinar backs. Also, it this
+ parameter is set then image bitmap will be reduced by half in each
+ dimension. In later case, all 4 components of bitmap will be filled
+ during data extraction phase.
+
imgdata.params.threshold, imgdata.params.aber
+
If these parameters used, then half-sized bitmap will be used for data
+ unpacking. See above for details.
+
imgdata.params.use_camera_wb
+
Affects loading of white balance matrix for Leaf backs.
+
+
+
Memory Usage
+
+
Stack Usage
+
An instance of the LibRaw class has its own size about 800 Kb;
+ if constructions like LibRaw imageProcessor; are used, this
+ memory is stack-allocated.
+
Methods of class LibRaw (and C API calls) may allocate up to 130-140 Kb
+ of data on the stack (to place auto variables) during their work.
+
Thus, the work of one LibRaw instance may require about 1MB
+ of stack memory. This is not a problem for most contemporary
+ architectures. However, when working in a multithreaded environment, one
+ should not forget to allocate a sufficient amount of memory for the thread
+ stack.
+
In the case of dynamic allocation (LibRaw *iProcessor = new LibRaw;),
+ the requirements to stack memory will decrease by ~800 Kb, which is the
+ size of a class instance). If C API is used, the
+ LibRaw instance is allocated dynamically.
+
+
Dynamic Memory Management
+
LibRaw keeps record of all allocated dynamic memory blocks; in the case
+ of an exceptional situation (fatal error), they are all freed. The code
+ for keeping this record is fairly primitive and not designed to consider
+ allocation of many blocks (in the normal situation, allocation takes place
+ from 2 to 6 times during file processing); this fact should be taken into
+ account by developers trying to add new methods to LibRaw.
+
+
Dynamic Memory Usage
+
LibRaw uses dynamic memory
+
+
for the decoded image;
+
for the decoded thumbnail;
+
for the postprocessed image;
+
for the ICC profile retrieved from the RAW file (if available);
+
for temporary data at the stage of RAW file unpacking;
+
for temporary data at the stage of postprocessing and result output;
+
for reading of the RAW source file (only under Win32).
+
+
+
Memory buffer for the RAW image
+
Decoded RAW data are stored:
+
+
one 16-bit value per pixel for "bayer" images. The masked pixels
+ (black or dark or masked frame) are stored with image data.
+
Free or four 16-bit values for full-color images (Foveon, Linear DNG,
+ Canon sRAW etc.).
+
one,three, or four 32-bit floating point values per pixel for
+ floating-point data.
+
+
The buffer for RAW data is allocated by unpack()
+ call and freed upon calling recycle().
+
+
Memory for the Postprocessed Image
+
On postprocessing stage each pixel contains four 16-bit values, one for
+ each possible color channel (some sensors are actually 4-color).
Memory for the thumbmail is allocated upon calling unpack_thumb()
+ and freed upon calling recycle(). The
+ size of the allocated buffer is precisely adjusted to the thumbnail size,
+ i.e., up to several Mb.
+
+
+
Memory for RAW Unpacking
+
Memory for temporary buffer needed during RAW data unpacking may be
+ allocated during the work of unpack()
+ and freed before completion of this function. The sizes of the allocated
+ buffers are small, up to tens of Kb.
+
+
Memory for Postprocessing
+
During image postprocessing (inherited from dcraw), memory for the
+ histogram (128 Kb) is allocated. This memory is allocated upon calling dcraw_process() and freed upon
+ calling recycle().
+
In addition, during the work of dcraw_process()
+ and during the usage of some available possibilities, like
+
+
rotation of images from FUJI cameras;
+
correction of chromatic aberrations;
+
image size changes (including correction of non-square pixels);
+
highlight recovery;
+
+
a temporary buffer with the size equal to the size of the resultant image
+ (6-8 bytes per pixel for various processing stages) will be allocated. As
+ soon as the intermediate substage of processing is completed, the buffer
+ with the previous copy of the image will be freed.
+ If postprocessing is not used, then temporary buffers are not allocated.
+
+
Memory for File Writing
+
Upon calling dcraw_ppm_tiff_writer(),
+ memory for a single row of the output image is allocated. The allocated
+ memory is freed before the end of this call.
+
+
Unpacking into memory buffer
+
Functions dcraw_make_mem_image()
+ dcraw_make_mem_thumb()
+ (and complementary calls in C-API) allocates memory for entire output
+ datasets (full RGB bitmap and thumbnail, respectively).To free allocated
+ memory use dcraw_clear_mem()
+ function.
+
+
Incompatibilities with dcraw
+
+
Automatic maximum search/brightness adjustment
+
Many camera formats really use less data range, than possible by format
+ nature (bit count). If data maximum estimated incorrectly (too low) this
+ may resuls in colored highlights ('pink clouds') because of data cut at
+ wrong level.
+
To prevent this, LibRaw uses real data maximum from current file if this
+ maximum is larger than format maximum multiplied by
+ imdata.params.adjust_maximum_thr value (default is 0.75).
+
To turn off this feature (and repeat dcraw.c pink clouds) set
+ imdata.params.adjust_maximum_thr to 0.0
+
+
Processing of Thumbnails from Kodak cameras
+
In some Kodak cameras, the preview (thumbnail) is stored in the form of
+ uncorrected image. During its extraction using dcraw -e,
+ the white balance, color conversion, and other settings are the same as
+ those used for extraction of the main RAW data (including defect removal
+ and dark frame subtraction, which is erroneous, since the image size is
+ different).
+ In LibRaw::unpack_thumb() calls, the white balance taken from the camera
+ ("as shot") is used and no settings from imgdata.params are considered.
+
For all other cameras, thumbnails are extracted "as is," without any
+ color conversions, both in dcraw and in LibRaw.
+
+
diff --git a/rtengine/libraw/doc/API-overview.html b/rtengine/libraw/doc/API-overview.html
new file mode 100644
index 000000000..a29014aa9
--- /dev/null
+++ b/rtengine/libraw/doc/API-overview.html
@@ -0,0 +1,66 @@
+
+
+
+ Overview of LibRaw API (C++)
+
+
+
+ [back to Index]
+
Overview of LibRaw API (C++)
+
General Remarks
+
+
The entire processing is carried out by an instance of the LibRaw class, which is an image processor.
+
One image processor can simultaneously process only one data source file, but consecutive processing of any number of files
+is possible.
+
There may be several simultaneously working image processors in a software program (e.g., in different threads), although one
+should remember that each image processor may require much memory.
+
Reading of source data from the RAW file requires virtually no customization (see API Notes for exceptions to this rule).
+
All data extracted from the RAW file are accessible through data fields of the image processor (LibRaw class instance).
+
Although LibRaw is not intended for RAW data postprocessing, the library includes calls that enable complete
+emulation of the dcraw utility.
+
All customization for the processing is performed via data fields of the LibRaw class.
+
+
+
Brief Demonstration
+
+ The example below contains no error processing for the sake of brevity.
+
+
+#include "libraw/libraw.h"
+int process_image(char *file)
+{
+ // Let us create an image processor
+ LibRaw iProcessor;
+
+ // Open the file and read the metadata
+ iProcessor.open_file(file);
+
+ // The metadata are accessible through data fields of the class
+ printf("Image size: %d x %d\n",iProcessor.imgdata.sizes.width,iProcessor.imgdata.sizes.height);
+
+ // Let us unpack the image
+ iProcessor.unpack();
+
+ // Convert from imgdata.rawdata to imgdata.image:
+ iProcessor.raw2image();
+
+ // And let us print its dump; the data are accessible through data fields of the class
+ for(i = 0;i lt; iProcessor.imgdata.sizes.iwidth * iProcessor.imgdata.sizes.iheight; i++)
+ printf("i=%d R=%d G=%d B=%d G2=%d\n",
+ i,
+ iProcessor.imgdata.image[i][0],
+ iProcessor.imgdata.image[i][1],
+ iProcessor.imgdata.image[i][2],
+ iProcessor.imgdata.image[i][3]
+ );
+
+ // Finally, let us free the image processor for work with the next image
+ iProcessor.recycle();
+}
+
+
+
+ [back to Index]
+
+
diff --git a/rtengine/libraw/doc/Install-LibRaw.html b/rtengine/libraw/doc/Install-LibRaw.html
new file mode 100644
index 000000000..3fb1aea0e
--- /dev/null
+++ b/rtengine/libraw/doc/Install-LibRaw.html
@@ -0,0 +1,123 @@
+
+
+
+
+ LibRaw Compilation and Installation
+
+ [back to Index]
+
LibRaw Compilation and Installation
+
LibRaw is distributed in the form of source codes. For further use, they
+ should be compiled (and, if desired, placed into system folders with
+ libraries and include-files).
+
+
Unix Systems (FreeBSD, Linux, Mac OS X)
+
To build the library, you will need a working C++ compiler (gcc 3+ and
+ clang 2+ are OK) and the make utility.
+
Additional libraries (optional):
+
+
zlib (used to decode deflated DNGs)
+
libjpeg8 (used to decode lossy DNGs and several old Kodak cameras)
+
+
LibRaw has been tested on 32- and 64-bit Unix systems working on x86-
+ (and AMD64-) compatible processors. Building and work on other
+ architectures have not been tested.
+
Compilation of Library and Examples
+
Unpack the downloaded distribution package.
+
tar xzvf LibRaw-X.YY.tar.gz
+
+
For GitHub downloads (clones), perform ./configure script generation via
+
autoreconf --install
+
Go to LibRaw directory and run ./configure and make:
+
cd LibRaw-X.YY
+./configure # with optional args
+make
+
+
As a result, you will compile
+
+
Library libraw.a in the lib/ folder
+
Examples in the bin/ folder (source
+ codes of examples are in the samples/ folder).
+
+
In the current version, only static libraries are built:
+
+
libraw.a: non-thread-safe version
+
libraw_r.a: thread-safe
+
+
Build parameters
+
./configure script have some non-standard parameters:
+
+
--enable-openmp
+ --disable-openmp
+
Enable/disable OpenMP support if compiler supports it. OpenMP is
+ enabled by default.
+
--enable-lcms
+ --disable-lcms
+
Enable/disable LCMS color engine support. If enabled, ./configure
+ will try to find lcms library. Both LCMS-1.x and LCMS-2.x are supported
+ LCMS support is enabled by default
+
--enable-examples
+ --disable-examples
+
Enables/disables examples compilation and installation. Enabled by
+ default
+
+
Installation and Usage
+
To install the library, run
+
sudo make install
+
+
It will place the libraries in /usr/local/lib, the include-files
+ in /usr/local/include (subfolder of libraw) and LibRaw samples to
+ /usr/local/bin. You can override installation path by using
+ ./configure script.
+ To use LibRaw, add the following parameters to the compiler call (when
+ building your own projects):
+
+
Path to include-files: -I/usr/local/include
+
Path to libraries: -L/usr/local/lib
+
Library: -lraw (ordinary version) or -lraw_r (thread-safe version).
Unpack the distribution package (if you have got no tar+gzip, take the
+ LibRaw distribution package in the .ZIP format) and go to folder
+ LibRaw-X.YYY.
+
Set the environment parameters so that the compiler/linker would find
+ the libraries and include-files. For Visual C++, this is done by running
+ vcvars32.bat.
+
Run
+ nmake -f Makefile.msvc
+
+
+
You may need to edit Makefile.msvc to provide libjpeg/zlib
+ paths to INCLUDE/LIB.
+
If all paths are set correctly and the include-files/libraries have been
+ found, then the following will be compiled:
+
+
Library libraw_static.lib in folder lib
+
Dynamic library bin/libraw.dll and linking library for it
+ lib/libraw.lib
+
Examples in folder bin/.
+
+
Only the thread-safe library is built under Win32, but it can be used
+ with non-threaded applications as well. All examples are linked with the
+ dynamic library (DLL); if static linking is necessary, one should link
+ applications with library libraw_static.lib and set the preprocessor
+ option /DLIBRAW_NODLL during compilation.
+
Windows-version compiles without LCMS support for now.
+
During building of DLL, all public functions are exported; further, the
+ exported subset may be reduced.
+
Unfortunately, paths to include/ libraries depend on the way Visual C
+ (or other compiler) is installed; therefore, it is impossible to specify
+ some standard paths in Makefile.msvc.
+
Windows Installation
+
No installation under Windows is supported. It is assumed that all DLLs
+ will be supplied together with the software using them (and this software
+ will perform the installation). Accordingly, in building of programs using
+ LibRaw, the paths to libraries, DLLs, and include-files should be
+ specified manually.
+ [back to Index]
+
+
diff --git a/rtengine/libraw/doc/Samples-LibRaw.html b/rtengine/libraw/doc/Samples-LibRaw.html
new file mode 100644
index 000000000..c72a3f945
--- /dev/null
+++ b/rtengine/libraw/doc/Samples-LibRaw.html
@@ -0,0 +1,213 @@
+
+
+
+
+
+
Overview of Examples in the Distribution Package (samples/*)
+
The LibRaw package contains several examples illustrating the use of this
+ library. Their source codes are located in the samples/ folder, and after
+ library build they will be in the bin/ folder:
+
+
raw-identify The only LibRaw call it uses is open_file();
+ further code prints the values of the fields of the imgdata structure.
+ raw-identify -v provides extensive dump of
+ metadata/
+ Command line key -u shows unpacking function name,
+ while -u -f prints function name and masked are sizes.
+ raw-identify -w will print white balance tables stored
+ in RAW file.
+
simple_dcraw A simple "emulation" of dcraw
+ reproducing the behavior of dcraw [-e] [-v] [-T].
+ A simplified version of this example is considered
+ below.
+ -B command-line switch turns on use of open_buffer()
+ API call used via mmap() of input file (Unix only).
+
dcraw_half Demonstrates the use of C
+ API. The example emulates the behavior of dcraw -h
+ (no other control parameters can be specified in this example).
+
dcraw_emu Almost complete emulation of dcraw (except for
+ keys -D -d -E -i -v -e, which are considered in other usage examples).
+ Of most interest is processing of command line keys (copied from dcraw).
+
+
This sample supports additional command-line parameters absent in
+ original dcraw:
+
+
-mmap
+
Use open_buffer()
+ interface. Buffer prepared by mmap() call. This option not supported
+ under Win32.
+
-meme
+
Use open_buffer()
+ interface. Buffer prepared by malloc()+read() calls.
+
-c float-value
+
This key sets params.adjust_maximum_thr
+ parameter.
+ Use -c 0 to completely disable automatic maximum calculation.
+ Default value: 0.75
+
-timing
+
Turns on detailed timing print.
+
-G
+
Turns on "green_matching" mode to suppress color mazes on cameras
+ with different green channels.
+
-B x y w h
+
Crops output to rectangle with width w, height h and x,y
+ coordinates of left upper corner. All coordinates applied before any
+ image rotation.
+
-F
+
Will use FILE I/O (bigfile_datastream) instead on standard
+ LibRaw_file_datastream.
+
-dcbi N
+
Sets number of additional DCB-demosaic iterations (option valid
+ only for -q 4, i.e. for DCB demosaic).
+
-dcbe
+
Turns on DCB color enhance mode (only for DCB demosaic, -q 4).
+
-aexpo e p
+
Turns on exposure correction. e is exposure shift in linear scale
+ from 0.25 (darken 2 stops) to 8.0 (lighten 3 stops). p is highlights
+ preservation amount from 0.0 (no preservation, full clipping) to 1.0
+ (full preservation, S-like curve in highlights).
+
-apentax4shot
+
Will merge 4 frames from Pentax 4-shot RAWs
+
-apentax4shotorder abce
+
Order of frames in pentax 4-shot files (default is 3102)
+
-mmap
+
Use mmap + memory IO instead of file IO (unix only)
+
-disars
+
Disable RawSpeed library (if compiled with this library)
+
-doutputflags N
+
set imgdata.params.output_flags to N
+
-disinterp
+
Do not run interpolation step
+
-dsrawrgb1
+
Disable YCbCr to RGB conversion for sRAW (Cb/Cr interpolation
+ enabled)
+
-dsrawrgb2
+
Disable YCbCr to RGB conversion for sRAW (Cb/Cr interpolation
+ disabled)
+
+
+
half_mt Emulation of dcraw -h. It
+ "understands" the following keys: -a (automatic white balance over the
+ entire image), -w (white balance of the camera), -T (output in the tiff
+ format), and -J n (number of parallel threads launched for image
+ processing).
+ On multiprocessor/multicore computers, the speed gain is notable in the
+ case of mass processing. On a Win32 machine, the example is assembled
+ from the initial file half_mt_win32.c, since work with threads under
+ Windows is fundamentally different and it it easier to copy simple
+ source codes than write one complex code.
unprocessed_raw This sample extracts (mostly)
+ unaltered RAW data including masked pixels data (on supported cameras).
+ If black frame exists and black frame extraction is supported for given
+ format, masked pixels data is added to resulting .TIFF file. Command
+ line options: -q - be quiet, -A -
+ autoscale data (integer multiplier), -g
+ gamma-correction (gamma 2.2) for data (instead of precise linear one), -B
+ turns on black level subtraction
+
4channnels - splits RAW-file into four separate
+ 16-bit grayscale TIFFs (per RAW channel).
+ Command line switches:
+
+
-s N selects N-th image from RAW with multiple
+ images
+
-g gamma correction (gamma 2.2)
+
-A values autoscale by auto-calculated integer
+ factor
+
-B turn off black subtraction
+
-N no RAW curve
+
+
+
multirender_test - very simple example of multiple
+ rendering on one file without reopen.
+
postprocessing_benchmark - will print timings of RAW
+ processing steps
+
+
Example of docmode
+
Below we consider the samples/simple_dcraw.cpp example, which emulates
+ the behavior of dcraw [-e][-v][-t]. To save space, let
+ us assume that keys -t -v are always specified (to avoid comments on
+ command line parsing) and there is always one parameter (name of file),
+ which is the only one and always passed to the program.
+
int main(int ac, char *av[])
+{
+ int i, ret, verbose=0, output_thumbs=0;
+ char outfn[1024],thumbfn[1024];
+ // Creation of image processing object
+ LibRaw RawProcessor;
+ // The date in TIFF is written in the local format; let us specify the timezone for compatibility with dcraw
+ putenv ((char*)"TZ=UTC");
+// Let us define variables for convenient access to fields of RawProcessor
+#define P1 RawProcessor.imgdata.idata
+#define S RawProcessor.imgdata.sizes
+#define C RawProcessor.imgdata.color
+#define T RawProcessor.imgdata.thumbnail
+#define P2 RawProcessor.imgdata.other
+#define OUT RawProcessor.imgdata.params
+ OUT.output_tiff = 1; // Let us output TIFF
+ // Let us open the file
+ if( (ret = RawProcessor.open_file(av[1])) != LIBRAW_SUCCESS)
+ {
+ fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
+ // recycle() is needed only if we want to free the resources right now.
+ // If we process files in a cycle, the next open_file()
+ // will also call recycle(). If a fatal error has happened, it means that recycle()
+ // has already been called (repeated call will not cause any harm either).
+ RawProcessor.recycle();
+ goto end;
+ }
+ // Let us unpack the image
+ if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
+ {
+ fprintf(stderr,"Cannot unpack_thumb %s: %s\n",av[i],libraw_strerror(ret));
+ if(LIBRAW_FATAL_ERROR(ret))
+ goto end;
+ // if there has been a non-fatal error, we will try to continue
+ }
+ // Let us unpack the thumbnail
+ if( (ret = RawProcessor.unpack_thumb() ) != LIBRAW_SUCCESS)
+ {
+ // error processing is completely similar to the previous case
+ fprintf(stderr,"Cannot unpack_thumb %s: %s\n",av[i],libraw_strerror(ret));
+ if(LIBRAW_FATAL_ERROR(ret))
+ goto end;
+ }
+ else // We have successfully unpacked the thumbnail, now let us write it to a file
+ {
+ snprintf(thumbfn,sizeof(thumbfn),"%s.%s",av[i],T.tformat == LIBRAW_THUMBNAIL_JPEG ? "thumb.jpg" : "thumb.ppm");
+ if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_thumb_writer(thumbfn)))
+ {
+ fprintf(stderr,"Cannot write %s: %s\n",thumbfn,libraw_strerror(ret));
+ // in the case of fatal error, we should terminate processing of the current file
+ if(LIBRAW_FATAL_ERROR(ret))
+ goto end;
+ }
+ }
+ // Data unpacking
+ ret = RawProcessor.dcraw_process();
+ if(LIBRAW_SUCCESS != ret ) // error at the previous step
+ {
+ fprintf(stderr,"Cannot do postprocessing on %s: %s\n",av[i],libraw_strerror(ret));
+ if(LIBRAW_FATAL_ERROR(ret))
+ goto end;
+ }
+ else // Successful document processing
+ {
+ snprintf(outfn,sizeof(outfn),"%s.%s", av[i], "tiff");
+ if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
+ fprintf(stderr,"Cannot write %s: error %d\n",outfn,ret);
+ }
+ // we don't evoke recycle() or call the destructor; C++ will do everything for us
+ return 0;
+end:
+ // got here after an error
+ return 1;
+}
+
The proposed project and the software products generated within this project are intended for:
+
+
Developers of RAW converters, including current and new developments
+
Developers of applications that need access to decoded RAW data (for pre-processing, stitching, stacking, color profiling, etc.)
+
Those willing to write their own graphic interface for RAW file processing
+
Developers and enthusiasts creating their own primary and auxiliary data processing algorithms, including
+
+
Interpolation (demosaic),
+
Noise reduction
+
White balance
+
Correction of aberrations and distortions
+
RAW data analysis
+
Comparison of cameras and lenses
+
and so on...
+
+
+
+
Some History
+
The LibRaw project started in 2008. At that time dcraw was very popular as a method of accessing RAW data. It was hard to find a more or less popular camera that was not supported by this utility; while the implementation of RAW data extraction in dcraw was of a very high quality.
+
However, developers and enthusiasts were experiencing a number of difficulties when using dcraw. First, the author of dcraw refused to turn his product into a handy library. Besides, dcraw contains a number of questionable features that may hinder its use without modifications, as well as instances of distortions in the photographic sense of it. As a result, once every several months, with each new release of dcraw, virtually all developers, part of them listed on the dcraw Web site, were to check the differences, figure out the patches, and apply those patches to their dcraw-based code and libraries.
+
As for enthusiasts, the "entry cost" of verifying their own ideas and implementing their own algorithms in such an environment is often unreasonably high: they have to either use the dcraw command line, thus being forced to use the unavoidable early processing stages, or understand the source code and maintain their own library based on it.
+
Thus, the inconveniences of dcraw make the developers' community quite small and halt further evolution and improvement of RAW format converters.
+
Our project started with the idea to get a library based on dcraw, only better. Today we are well past that initial goal, not in the least because dcraw is not actively supported since 2015, and the latest release was published nearly 2 years ago, in May 2016. Since then several distinctly different RAW formats (introduced by Fujifilm, Nikon, Pentax, Samsung, Sigma, Sony) emerged, none of which is supported by dcraw. Additionally, we see it necessary to extract more metadata to help better interpretation of RAW data and to add flexibility to the RAW conversion process.
+
Goals and Objectives
+
We are maintaining LibRaw as a library providing access to decoded raw data and metadata useful for correct interpretation of the said data. Thus:
+
+
To keep on adding RAW decoding for new and previously unsupported cameras
+
To continue the development of a stable and consistent API suitable for other applications (RAW converters, data analyzers, panorama stitchers, etc.)
+
To have RAW processing as separate independent parts (groups of API calls)
+
+
Reading, decoding, and unpacking of RAW data: this is the main functionality of LibRaw
+
Data conversions: interpolation, white balance, etc.: this part of LibRaw is frozen: we ported dcraw functionality, but expect that library users will create own postprocessing code.
+
File output of the processing results. This part is very primitive, only tiff and ppm output is supported.
+
+
+
+
The latter two groups of functions are maintained to provide some postprocessing/saving ability from scratch, without writing own code. We do not have any plans to extend/improve this code.
+
+
To improve the procedures of RAW data retrieval and decoding.
+
To supply other developers with a "framework" (freeware and open-source), e.g., for experimenting with their own methods of RAW data processing (interpolation, noise reduction, white balance, etc.; some directions of the possible efforts are listed above), so that they could create their own GUI programs and interfaces without developing the entire RAW converter.
+
+
LibRaw Release Schedule
+
+
Production releases will be published at intervals of 1-1.5 years. Production releases will be maintained through bugfixes. New cameras will not be added to production releases, but only to snapshots and non-stable/beta releases. Patch (bugfix) releases of production releases should provide API/ABI consistency (so, version 0.21.5 should be binary compatible with 0.21.0).
+
Snapshots are planned to be released every 2-3 quarters. Snapshots will include support for new cameras, stable and tested in our own applications. API calls and internal routines may be changed. No binary compatibility maintained, to upgrade to newer snapshot one need to recompile application that uses it.
+
Non-stable/beta releases with new features, like initial support for some new RAW format that needs extensive testing by the community. No exact schedule, to be published as needed.
+
+
How You Can Help/Participate
+
We welcome any help, however:
+
+
If you are submitting any core functionality extensions/improvements, that is, something that has to do with the decoding of RAW and/or metadata, that would be highly valuable and we will maintain your submission on our own, if necessary; you dont need to be committed.
+
If your contribution adds to post-processing, please be committed to supporting and maintaining such a contribution. Our previous experience with such contributions has been less than positive, exactly because of the lack of maintenance on the part of the contributors. We are unable to maintain such contributions on our own, because our primary goal is to maintain RAW and metadata decoding.
LibRaw is a library for reading RAW files from digital photo cameras (CRW/CR2, NEF, RAF, DNG, MOS, KDC, DCR, etc.; virtually all RAW formats are supported). It pays special attention to correct retrieval of data required for subsequent RAW conversion.
+
The library is intended for embedding in RAW converters, data analyzers, and other programs using RAW files as the initial data.
LibRaw library, Copyright (C) 2008-2024 LibRaw LLC (info@libraw.org)
+ The library includes source code from
+ dcraw.c, Dave Coffin's raw photo decoder
+ Copyright 1997-2016 by Dave Coffin, dcoffin a cybercom o net
+
+
LibRaw is distributed for free under two different licenses:
+ You may use one of these licensing modes and switch between them.
+
+
+
diff --git a/rtengine/libraw/export-dist.sh b/rtengine/libraw/export-dist.sh
new file mode 100755
index 000000000..a462558be
--- /dev/null
+++ b/rtengine/libraw/export-dist.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+DEST=$1
+VERSION=$2
+if test x$VERSION = x ; then
+ VERSION=`./version.sh`
+ echo VERSION set to $VERSION
+fi
+
+if test -d $DEST ; then
+ echo Using $DEST/$VERSION
+else
+ echo Usage: $0 destination-dir
+ exit 1
+fi
+cd ..
+for dir in LibRaw
+do
+ cd $dir
+ git pull origin
+ cd ..
+done
+for dir in LibRaw
+do
+ cd $dir
+ git archive --prefix=$dir-$VERSION/ $VERSION | (cd $DEST; tar xvf - )
+ cd ..
+done
diff --git a/rtengine/libraw/internal/dcraw_defs.h b/rtengine/libraw/internal/dcraw_defs.h
new file mode 100644
index 000000000..b53752511
--- /dev/null
+++ b/rtengine/libraw/internal/dcraw_defs.h
@@ -0,0 +1,66 @@
+/* -*- C++ -*-
+ * Copyright 2019-2024 LibRaw LLC (info@libraw.org)
+ *
+
+ LibRaw is free software; you can redistribute it and/or modify
+ it under the terms of the one of two licenses as you choose:
+
+1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
+ (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
+
+2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
+
+ */
+
+#ifndef DCRAW_DEFS_H
+#define DCRAW_DEFS_H
+
+#include
+#define LIBRAW_LIBRARY_BUILD
+#define LIBRAW_IO_REDEFINED
+#include "libraw/libraw.h"
+#include "libraw/libraw_types.h"
+#include "internal/defines.h"
+#include "internal/var_defines.h"
+
+#define stmread(buf, maxlen, fp) stread(buf, MIN(maxlen, sizeof(buf)), fp)
+#define strbuflen(buf) strnlen(buf, sizeof(buf) - 1)
+#define makeIs(idx) (maker_index == idx)
+#define strnXcat(buf, string) \
+ strncat(buf, string, LIM(sizeof(buf) - strbuflen(buf) - 1, 0, sizeof(buf)))
+
+// DNG was written by:
+#define nonDNG 0
+#define CameraDNG 1
+#define AdobeDNG 2
+
+// Makernote tag type:
+#define is_0x927c 0 /* most cameras */
+#define is_0xc634 2 /* Adobe DNG, Sony SR2, Pentax */
+
+// abbreviations
+#define ilm imgdata.lens.makernotes
+#define icWBC imgdata.color.WB_Coeffs
+#define icWBCCTC imgdata.color.WBCT_Coeffs
+#define imCanon imgdata.makernotes.canon
+#define imFuji imgdata.makernotes.fuji
+#define imHassy imgdata.makernotes.hasselblad
+#define imKodak imgdata.makernotes.kodak
+#define imNikon imgdata.makernotes.nikon
+#define imOly imgdata.makernotes.olympus
+#define imPana imgdata.makernotes.panasonic
+#define imPentax imgdata.makernotes.pentax
+#define imPhaseOne imgdata.makernotes.phaseone
+#define imRicoh imgdata.makernotes.ricoh
+#define imSamsung imgdata.makernotes.samsung
+#define imSony imgdata.makernotes.sony
+#define imCommon imgdata.makernotes.common
+
+
+#define ph1_bits(n) ph1_bithuff(n, 0)
+#define ph1_huff(h) ph1_bithuff(*h, h + 1)
+#define getbits(n) getbithuff(n, 0)
+#define gethuff(h) getbithuff(*h, h + 1)
+
+#endif
diff --git a/rtengine/libraw/internal/dcraw_fileio_defs.h b/rtengine/libraw/internal/dcraw_fileio_defs.h
new file mode 100644
index 000000000..68bd8581f
--- /dev/null
+++ b/rtengine/libraw/internal/dcraw_fileio_defs.h
@@ -0,0 +1,25 @@
+/* -*- C++ -*-
+ * Copyright 2019-2024 LibRaw LLC (info@libraw.org)
+ *
+
+ LibRaw is free software; you can redistribute it and/or modify
+ it under the terms of the one of two licenses as you choose:
+
+1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
+ (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
+
+2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
+
+ */
+
+#ifndef DCRAW_FILEIO_DEFS_H
+#define DCRAW_FILEIO_DEFS_H
+
+#include
+#define LIBRAW_LIBRARY_BUILD
+#include "libraw/libraw.h"
+#include "internal/defines.h"
+#include "internal/var_defines.h"
+
+#endif
diff --git a/rtengine/libraw/internal/defines.h b/rtengine/libraw/internal/defines.h
new file mode 100644
index 000000000..a24666a8d
--- /dev/null
+++ b/rtengine/libraw/internal/defines.h
@@ -0,0 +1,187 @@
+/*
+ Copyright 2008-2024 LibRaw LLC (info@libraw.org)
+
+LibRaw is free software; you can redistribute it and/or modify
+it under the terms of the one of two licenses as you choose:
+
+1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
+ (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
+
+2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+ (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
+
+ This file is generated from Dave Coffin's dcraw.c
+ dcraw.c -- Dave Coffin's raw photo decoder
+ Copyright 1997-2010 by Dave Coffin, dcoffin a cybercom o net
+
+ Look into dcraw homepage (probably http://cybercom.net/~dcoffin/dcraw/)
+ for more information
+*/
+
+#ifndef LIBRAW_INT_DEFINES_H
+#define LIBRAW_INT_DEFINES_H
+#ifndef USE_JPEG
+#define NO_JPEG
+#endif
+
+#define DCRAW_VERSION "9.26"
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#define _USE_MATH_DEFINES
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include