Data Structures and Constants

LibRaw data structures are defined in header file libraw/libraw_types.h
Constants used in its work are defined in file libraw/libraw_const.h


  1. Data structures
    1. libraw_data_t: Main Data Structure in LibRaw
    2. Structure libraw_iparams_t: Main Parameters of the Image
    3. Structure libraw_image_sizes_t: Image Dimensions
    4. Structure libraw_colordata_t: Color Information
    5. Structure libraw_imgother_t: Other Parameters of the Image
    6. Structure libraw_rawdata_t: holds unpacked RAW data
    7. Structure libraw_thumbnail_t: Description of Thumbnail
    8. Structure libraw_lensinfo_t - lens data, extracted from EXIF/Makernotes
    9. Structure libraw_output_params_t: Management of dcraw-Style Postprocessing .
    10. Stucture libraw_processed_image_t - result set for dcraw_make_mem_image()/dcraw_make_mem_thumb() functions
  2. Input abstraction layer
  3. Constants
    1. enum LibRaw_errors: Error Codes
    2. enum LibRaw_decoder_flags - RAW data format description
    3. enum LibRaw_progress: Current State of LibRaw Object
    4. enum LibRaw_thumbnail_formats: Thumbnail Data Formats
    5. Nonstandard Situations (Warnings) during RAW Data Processing
    6. enum LibRaw_image_formats - possible types of data, contains in libraw_processed_image_t structure

Data Structures

libraw_data_t: Main Data Structure of LibRaw

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()).
Data fields:

unsigned int progress_flags;
This field records the past phases of image processing .
unsigned int process_warnings;
This field records suspicious situations (warnings) that have emerged during image processing.
libraw_iparams_t idata;
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 readed 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 .
void (LibRaw::*interpolate_bayer)()
Pointer to user-specified bayer interpolation function. If not null, this function to be called instead of standard one specified by user_qual (or not specified)
void (LibRaw::*interpolate_xtrans)()
Pointer to user-specified X-Trans interpolation function. If not null, this function to be called instead of standard one specified by user_qual (or not specified)

Structure libraw_iparams_t: Main Parameters of the Image

char make[64];
Camera manufacturer.
char model[64];
Camera model.
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).
1 for Foveon matrices, 0 for others. Foveon is supported in LibRaw-demosaic-pack-GPL2.
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).

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[5]*cblack[6] correction values.
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).
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 readed 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).
char model2[64];
Firmware revision (for some cameras).
char UniqueCameraModel[64],LocalizedCameraModel[64];
Values from DNG tags with same names.
void *profile;
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 calcluated 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, calbiration matrix and color matrix for two light sources. (see DNG specs for details).
float baseline_exposure;
DNG-files: value of BaselineExposure tag.

Structure libraw_imgother_t: Other Parameters of the Image

Data fields:

float iso_speed;
ISO sensitivity.
float shutter;
Shutter speed.
float 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: longtitude/lattitude/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, readed 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.
Data fields:

LibRaw_thumbnail_formats tformat;
Thumbnail data format. One of the values among enum LibRaw_thumbnail_formats .
ushort twidth, theight;
Dimensions of the preview image in pixels.
unsigned tlength;
Thumbnail length in bytes.
int tcolors;
Number of colors in the preview.
char *thumb;
Pointer to thumbmail, extracted from the data file.

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.

libraw_makernotes_lens_t structure:

  • LensID (if not -1) and CamID (camera id, if non-zero) values are compatible with those used in exiftool, like |0x0010 CanonModelID| and |22 LensType| see or 0x0207/CameraType and 0x0201/LensType (see )
  • 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 ), 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.
  • 'CanonFocalUnits' - an auxiliary field, should not be needed most of the cases. See 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.

libraw_nikonlens_t structure:

Contains additional parameters needed to identify the lens on a Nikon camera using a table - please see Nikon LensID Values at

libraw_dnglens_t structure:

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_output_params_t: Management of dcraw-Style Postprocessing

Structure libraw_output_params_t 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 green 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.
unsigned shot_select;
dcraw keys: -s
Selection of image number for processing (for formats that contain several RAW images in one file).
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.
int highlight;
dcraw keys: -H
0-9: Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild).
int use_auto_wb;
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.
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.
int output_color;
dcraw keys: -o
[0-5] Output colorspace (raw, sRGB, Adobe, Wide, ProPhoto, XYZ).
char* output_profile;
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 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
  • 5 - Modified AHD interpolation by Paul Lee
  • 6 - AFD interpolation (5-pass)
  • 7 - VCD interpolation
  • 8 - Mixed VCD/Modified AHD interpolation
  • 9 - LMMSE interpolation
  • 10 - AMaZE intepolation
  • 11 - DHT intepolation
  • 12 - Modified AHD intepolation (by Anton Petrusevich)
Values 5-9 are useful only if "LibRaw demosaic pack GPL2" compiled in (see README.demosaic-packs in your distribution for details). Value 10 is useful only if LibRaw compiled with "LibRaw demosaic pack GPL3". If some interpolation method is unsupported because LibRaw compiled without corresponding demosaic pack, AHD interpolation will be used and  LIBRAW_WARN_FALLBACK_TO_AHD will be set in process_warniong field.
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 brighness 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.
int dcb_enhance_fl
dcraw keys: none
nonzero: DCB interpolation with enhance interpolated colors.
int fbdd_noiserd
dcraw keys: none
Controls FBDD noise reduction before demosaic.
  • 0 - do not use FBDD noise reduction
  • 1 - light FBDD reduction
  • 2 (and more) - full FBDD reduction
int eeci_refine
dcraw keys: none
nonzero- Use EECI refine for VCD interpolation.
int es_med_passes
dcraw keys: none
Number of edge-sensitive median filter passes after VCD+AHD demosaic. Value above 1 is highly not recommended.
int ca_correc
dcraw keys: none
positive value turns on chromatic aberrations suppression (default:0 i.e. off).
float cared,cablue
dcraw keys: none
If one of these fields is non-zero, then these values will be used instead of automatic ones. Useable range is +-0.1..+-4.0.
int cfaline; float linenoise;
Line noise (banding) reduction.
positive value turns this feature on (default: off).
linenoise - amount of reduction. Useful range is 0.001 to 0.02. Default value is 0.0 i.e. not clean anything.
int cfa_clean; float lclean,cclean;
Reduce impulse noise and Gaussian high frequency.
cfa_clean: positive value turns the feature on (default: off).
lclean,cclean - amount of noise reduction for (L)uminance and (C)olor. Useable range from 0.005 to 0.05, common value 0.01
int cfa_green; float green_thresh;
Reduces maze artifacts produced by bad balance of green channels.
cfa_green: positive value turns the feature on (default: off).
green_thresh - max difference between channels allowed for equalization. Useful range between 0.01 and 0.1.
int exp_correc; float exp_shift,exp_preser;
Exposure correction before demosaic.
  • 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 wf_debanding; float wf_deband_treshold[4];
wf_debanding: 1 turns on banding suppression (slow!), 0 turns it off.
wf_deband_treshold[] - per channel debanding thresholds.
int use_rawspeed;
Turns on using RawSpeed library for data unpacking (only if RawSpeed support compiled in).
int no_auto_scale;
Disables pixel values scaling (call to LibRaw::scale_colors()) in LibRaw::dcraw_process()
int no_interpolation;
Disables call to demosaic code in LibRaw::dcraw_process()
int raw_processing_options
Processing options used on unpack() phase for specific image formats

Sigma Quattro decoding flags:

  • LIBRAW_DP2Q_INTERPOLATERG - turn on R/G channels interpolation
  • LIBRAW_DP2Q_INTERPOLATEAF - turn on data interpolation of low-sensitivity (AF or overexposure control) points on Quattro sensors.

Pentax 4-shot options:

  • LIBRAW_PROCESSING_PENTAX_PS_ALLFRAMES - merge all frames for Pentax 4-shot files

Floating point DNG files:

  • LIBRAW_PROCESSING_CONVERTFLOAT_TO_INT - convert FP data to 16-bit integer

Sony ARW2.3 processing options: (for more details see

  • LIBRAW_PROCESSING_SONYARW2_BASEONLY - decode only base pixels, leave delta pixels as zero;
  • LIBRAW_PROCESSING_SONYARW2_DELTAONLY - decode only delta pixels with base pixels zeroed;
  • LIBRAW_PROCESSING_SONYARW2_DELTAZEROBASE - decode delta pixels, do not add base value;
  • LIBRAW_PROCESSING_SONYARW2_DELTATOVALUE - show possible posterization areas;

Canon/Nikon small RAW (YCC) decoding flags (do not use both at same time):

  • LIBRAW_PROCESSING_SRAW_NO_RGB - disable YCC to RGB conversion
  • LIBRAW_PROCESSING_SRAW_NO_INTERPOLATE - disable missing color values interpolation

Foveon processing flags:

  • LIBRAW_PROCESSING_FORCE_FOVEON_X3F - use X3F tools for foveon processing even if compiled with Demosaic Packs GPL2
int sony_arw2_posterization_thr
If LIBRAW_PROCESSING_SONYARW2_DELTATOVALUE used for arw2_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_decoder_info_t: RAW decoder name and data format

This structure describes RAW format decoder name and data format:

const char *decoder_name
Decoder function name
unsigned decoder_flags
Decoder data format. See list of LibRaw_decoder_flags for details.

Stucture 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.

Datastreams can be used either via LibRaw::open_datastream() call (in this case datastream object should be created an maintained by user) or via LibRaw::open_file() and LibRaw::open_buffer() shortcuts.

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 avaliable.

Data fields


	class LibRaw_abstract_datastream {...protected: LibRaw_abstract_datastream *substream;}

Description: Ojects 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.

Substream usage details described more precisely in own datastream objects creation guide .


enum LibRaw_errors: Error Codes

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).

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."
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."
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."
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."
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, recycle() will be called, and the LibRaw object will be brought to the state "right after creation."

Non-Fatal Errors

No error; function terminated successfully.
An unknown error has been encountered. This code should never be generated.
Unsupported file format (attempt to open a RAW file with a format unknown to the program).
Attempt to retrieve a RAW image with a number absent in the data file (only for formats supporting storage of several images in a file).
API functions have been called in wrong order (e.g., unpack() before open_file() ) or the previous stage has ended with an error (e.g., unpack() is called after open_file() has returned an error).
Returned upon an attempt to retrieve a thumbnail from a file containing no preview.
RAW file contains a preview of unsupported format.

enum LibRaw_decoder_flags - RAW data format description

Depending of capabilities of given data format, the buffer with RAW data may have different layouts:

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).
This flag is set if file format is Sony ARW2.3, so sony_arw2_options is applicable.
This flag is set if file format is (possibly) supported by RawSpeed library, so unpack() will try to use it.
Do not use automated maximum calculation for this data format.
Decoder allocates data, no need to pass allocated memory to decoder.

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.

Object just created, no processing carried out.
File to be processed has been opened.
Data identification performed, format recognized, metadata extracted.
Data sizes adjusted (for files that require such adjustment, namely, certain files from Kodak cameras).
RAW data loaded.

The following flags are set during usage of image processing that has been taken from dcraw.

imgdata.image array allocated and filled with data.
Zero values removed for cameras that require such removal (Panasonic cameras).
Bad (dead) pixels removed.
Dark frame subtracted from RAW data.
Interpolation for cameras with a Foveon sensor performed.
White balance performed.
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.
Interpolation (debayer) performed.
Averaging of green channels performed.
Median filtration performed.
Work with highlights performed.
For images from Fuji cameras, rotation performed (or adjust_sizes_info_only() called).
Dimensions recalculated for images shot with a rotated camera (sizes.iwidth/sizes.iheight swapped).
Conversion into output RGB space performed.
Image dimensions changed for cameras with non-square pixels.
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_DEMOSAICSGPL2 - compiled with Demosaic Pack GPL2
  • LIBRAW_CAPS_DEMOSAICSGPL3 - compiled with Demosaic Pack GPL3

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:

Format unknown or thumbnail not yet read.
The thumbnail buffer contains a JPEG file (read from the RAW file "as is," without any manipulations performed on it).
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.
Data format is presently recognized upon opening of RAW file but not supported: not unpacked into LibRaw::unpack_thumb.
Data format is presently recognized upon opening of RAW file but not supported: not unpacked into LibRaw::unpack_thumb.

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.

Only for cameras with Foveon: extraction of one of data matrices has failed.
Only for cameras with Foveon: extraction of white balance data has failed.
Postprocessing must use white balance of the camera but this balance is not suitable for use.
Only for cameras where the metadata are taken from an external JPEG file: metadata extraction has failed.
Only for P&S Kodak cameras: data in JPEG format. At the same time, open_file() will return LIBRAW_FILE_UNSUPPORTED.
(only if LCMS support compiled in). Caller set embedded input profile use, but no such profile exists in RAW.
(only if LCMS support compiled in). Error when opening input profile ICC file.
(only if LCMS support compiled in). Error when opening output profile ICC file.
Error when opening bad pixels map file.
Error when opening dark frame file.
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).
Problems detected in RawSpeed decompressor. The image data processed by LibRaw own decoder.
This file not supported by RawSpeed (although compatible decoder exists).
Not warning, but information. The file was decoded by RawSpeed.
Incorrect/unsupported user_qual was set, AHD demosaic used instead.

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:

The structure contains RGB-bitmap, metadata described in other fields of libraw_processed_image_t.
libraw_processed_image_t structure contains JPEG image (in memory). Only data_size field is meaningful.