Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 4f1594edf46b1cade0946ff9ff078094 > files > 22

LibRaw-devel-0.9.1-9.fc14.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>LibRaw: Data Structures and Constants</title>
  <meta http-equiv="content-type" content="text/html; charset=windows-1251">
  </head>

  <body>
    <a href=index-eng.html>[back to Index]</a>
    <h1>LibRaw: Data Structures and Constants</h1>
    <p>
      LibRaw data structures are defined in header file libraw/libraw_types.h<br/>
      Constants used in its work are defined in file libraw/libraw_const.h
    </p>
    <h2>Contents:</h2>
    <ol>
      <li><a href="#datastruct">Data structures</a>
        <ol>
          <li><a href="#libraw_data_t">libraw_data_t: Main Data Structure in LibRaw</a></li>
          <li><a href="#libraw_iparams_t">Structure libraw_iparams_t: Main Parameters of the Image</a></li>
          <li><a href="#libraw_image_sizes_t">Structure libraw_image_sizes_t: Image Dimensions</a></li>
          <li><a href="#libraw_colordata_t">Structure libraw_colordata_t: Color Information</a></li>
          <li><a href="#color_data_state_t">Structure  color_data_state_t: Description of Color Data Source</a></li>
          <li><a href="#libraw_imgother_t">Structure  libraw_imgother_t: Other Parameters of the Image</a></li>
          <li><a href="#libraw_thumbnail_t">Structure libraw_thumbnail_t: Description of Thumbnail</a></li>
          <li><a href="#libraw_output_params_t">Structure libraw_output_params_t: Management of dcraw-Style Postprocessing</a>.</li>
          <li><a href="#libraw_masked_t">Structure libraw_masked_t - black (masked) pixels data</a></li>
          <li><a href="#libraw_processed_image_t">Stucture libraw_processed_image_t - result set for  dcraw_make_mem_image()/dcraw_make_mem_thumb() functions</a></li>
        </ol>
      </li>
      <li>
        <a href="#datastream">Input abstraction layer</a>
        <ul>
          <li><a href="#datastream_data">Data fields</a></li>
        </ul>
      </li>
      <li><a href="#const">Constants</a>
        <ol>
          <li><a href="#LibRaw_errors">enum LibRaw_errors: Error Codes</a></li>       
          <li><a href="#progress">enum LibRaw_progress: Current State of LibRaw Object</a></li>
          <li><a href="#LibRaw_thumbnail_formats">enum LibRaw_thumbnail_formats: Thumbnail Data Formats</a></li>
          <li><a href="#warnings">Nonstandard Situations (Warnings) during RAW Data Processing</a></li>
          <li><a href="#LibRaw_colorstate">enum LibRaw_colorstate: Type of Color Data Source</a>.</li> 
          <li><a href="#LibRaw_filtering">enum LibRaw_filtering - RAW data filtering settings</a></li> 
          <li><a href="#LibRaw_image_formats">enum LibRaw_image_formats - possible types of data, contains in  libraw_processed_image_t structure</a>
        </ol>
      </li>
    </ol>

    <a name="datastruct"></a>
    <h2>Data Structures</h2>
    <a name="libraw_data_t"></a>
    <h3>libraw_data_t: Main Data Structure of LibRaw</h3>
    <p>
      Structure libraw_data_t is a &quot;wrapping&quot; for data structures accessible to the user of the library.<br/>
      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()).<br/>
     Data fields:
    </p>
    <dl>
      <dt><b>unsigned int                progress_flags;</b></dt>
      <dd>
        This field records the past <a href="#progress">phases of image processing</a>.
      </dd>
      <dt><b>unsigned int                progress_flags;</b></dt>
      <dd>
        This field records <a href="#warnings">suspicious situations (warnings)</a> that have emerged during image processing.
      </dd>
      <dt><b>libraw_iparams_t            idata;</b></dt>
      <dd>
        The structure describes the main image parameters retrieved from the RAW file. Fields of this structure 
are described in detail <a href="#libraw_iparams_t">below</a>.
      </dd>
      <dt><b>libraw_image_sizes_t        sizes;</b></dt>
      <dd>
        The structure describes the geometrical parameters of the image. Fields of this structure
 are described in detail <a href="#libraw_image_sizes_t">below</a>.
      </dd>
      <dt><b>libraw_colordata_t          color;</b></dt>
      <dd>
   The structure contains color data retrieved from the file. Fields of this structure
are described in detail <a href="#libraw_colordata_t">below</a>.
      </dd>
      <dt><b>libraw_imgother_t           other;</b></dt>
      <dd>
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 <a href="#libraw_imgother_t">below</a>.
      </dd>
      <dt><b>libraw_thumbnail_t          thumbnail;</b></dt>
      <dd>
        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 <a href="#libraw_thumbnail_t">below</a>.
      </dd>
      <dt><b>libraw_masked_t             masked_pixels;</b></dt>
      <dd>
        Structure containing pixel data for black (masked) border pixels.
        Fields of this structure are described <a href="#libraw_masked_t">below</a>. It is filled
        when unpack() is called.

      </dd>
      <dt><b>ushort                      (*image)[4];</b></dt>
      <dd>
        The memory area that contains the image pixels per se. It is filled when unpack() is called. 
      </dd>

      <dt><b>libraw_output_params_t     params;</b></dt>
      <dd>
        Data structure intended for management of image postprocessing (using the dcraw emulator).
Fields of this structure are described in detail <a href="#libraw_iparams_t">below</a>.
      </dd>
    </dl>
    <a name="libraw_iparams_t"></a>
    <h3> Structure libraw_iparams_t: Main Parameters of the Image</h3>
    <p>

    </p>
    <dl>
      <dt><b>char        make[64];</b></dt>
      <dd>
        Camera manufacturer.
      </dd>
      <dt><b>char        model[64];</b></dt>
      <dd>
        Camera model.
      </dd>
      <dt><b>unsigned    raw_count;</b></dt>
      <dd>
        Number of  RAW images in file (0 means that the file has not been recognized).
      </dd>
      <dt><b>unsigned    dng_version;</b></dt>
      <dd>
        DNG version (for the DNG format).
      </dd>
      </dd>
      <dt><b>int         colors;</b></dt>
      <dd>
        Number of colors in the file.
      </dd>
      <dt><b>unsigned    filters;</b></dt>
      <dd>
        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.
      </dd>
      <dt><b>char        cdesc[5];</b></dt>
      <dd>
        Description of colors numbered from 0 to 3 (RGBG,RGBE,GMCY, or GBTG). 
      </dd>
    </dl>
    <a name="libraw_image_sizes_t"></a>
    <h3>Structure libraw_image_sizes_t: Image Dimensions</h3>
    <p>Structure libraw_image_sizes_t is a collection of all file data that describe the size of the image.<br/>
      Data fields: 
      </p>
    <dl>
      <dt><b>ushort    raw_height, raw_width;</b></dt>
      <dd>
        Full size of RAW image (including the frame) in pixels.
      </dd>
      <dt><b>ushort    height, width;</b></dt>
      <dd>
       Size of visible (&quot;meaningful&quot;) part of the image (without the frame). 
      </dd>
      <dt><b>ushort    top_margin, left_margin;</b></dt>
      <dd>
        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).
      </dd>
      <dt><b>ushort    bottom_margin, right_margin;</b></dt>
      <dd>
        Width (in pixels) of bottom and right part of masked pixels area.
      </dd>
      <dt><b>ushort      iheight, iwidth;</b></dt>
      <dd>
        Size of the output image (may differ from height/width for cameras that require image rotation or have non-square pixels). 
      </dd>
      <dt><b>double      pixel_aspect;</b></dt>
      <dd>
      Pixel width/height ratio. If it is not unity, scaling of the image along one of the axes is required during output. 
       </dd>
      <dt><b>int         flip;</b></dt>
      <dd>
        Image orientation (0 if does not require rotation; 3 if requires 180-deg rotation; 5 if 90 deg counterclockwise, 6 if 90 deg clockwise). 
      </dd>
    </dl>
    <a name="libraw_colordata_t"></a>
    <h3>Structure libraw_colordata_t: Color Information</h3>
    <p>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. <br/>    
     Data fields:
    </p>
    <dl>
      <dt><b>color_data_state_t   color_flags;</b></dt>
      <dd>
        Data structure describing the sources of color data. Described <a href="#color_data_state_t">below</a> in more detail.
      </dd>
      <dt><b>ushort      white[8][8];</b></dt>
      <dd>
     Block of white pixels extracted from files CIFF/CRW. Not extracted for other formats. Used to calculate white
balance coefficients.
      </dd>
      <dt><b>float       cam_xyz[4][3]; </b></dt>
      <dd>
        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).
      </dd>
      <dt><b>float       cam_mul[4]; </b></dt>
      <dd>
        White balance coefficients (as shot). Either read from file or calculated.
      </dd>
      <dt><b>float       pre_mul[4]; </b></dt>
      <dd>
        White balance coefficients for daylight (daylight balance). Either read from file, or calculated on the basis of file data, 
or taken from hardcoded constants.
      </dd>
      <dt><b>float       cmatrix[3][4];</b></dt>
      <dd>
        White balance matrix. Read from file for some cameras, calculated for others.
      </dd>
      <dt><b>float       rgb_cam[3][4];</b></dt>
      <dd>
        Another white balance matrix, read from file for Leaf and Kodak cameras.
      </dd>
      <dt><b>ushort      curve[0x4001];</b></dt>
      <dd>
        Camera tone curve, read from file for Nikon, Sony and some other cameras.
      </dd>
      <dt><b>unsigned    black;</b></dt>
      <dd>
      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. 
      </dd>
      <dt><b>unsigned    maximum;</b></dt>
      <dd>
       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 <b>params.adjust_maximum_thr</b>
        is set to nonzero).
      </dd>
      <dt><b>unsigned    channel_maximum[4];</b></dt>
      <dd>
       Per channel maximum pixel value. Calculated from RAW data on unpack stage.
      </dd>
      <dt><b>ph1_t       phase_one_data;</b></dt>
      <dd>
        Color data block that is read for Phase One cameras.
      </dd>
      <dt><b>float       flash_used;</b></dt>
      <dt><b>float       canon_ev;</b></dt>
      <dd>
        Fields used for white balance calculations (for some P&amp;S Canon cameras).
      </dd>
      <dt><b>char          model2[64];</b></dt>
      <dd>
        Firmware revision (for some cameras).
      </dd>
      <dt><b>void    *profile;</b></dt>
      <dd>
        Pointer to the retrieved ICC profile (if it is present in the RAW file).
      </dd>
      <dt><b>unsigned    profile_length;</b></dt>
      <dd>
        Length of ICC profile in bytes.
      </dd>
    </dl>
    <a name="color_data_state_t"></a>
    <h3>Structure  color_data_state_t: Description of Color Data Source</h3>
    <p>This structure (actually, a bit field) describes the source of color data for each field of structure <a
 href="#libraw_colordata_t">libraw_colordata_t</a>, which may be obtained from different data sources.<br/>
      Data fields:
    </p>
    <pre>
        unsigned curve_state        : 3;
        unsigned rgb_cam_state      : 3;
        unsigned cmatrix_state      : 3;
        unsigned pre_mul_state      : 3;
        unsigned cam_mul_state      : 3;
    </pre>
    <p>
   Each field assumes one of the values that are possible for enum <a href="#LibRaw_colorstate">LibRaw_colorstate</a>. 
    </p>
    <a name="libraw_imgother_t"></a>
    <h3>Structure  libraw_imgother_t: Other Parameters of the Image</h3>
    <p>
      Structure libraw_imgother_t is a collection of data that have been read from the RAW file but are not needed for image postprocessing.<br/>
      Data fields:
    </p>
    <dl>
      <dt><b>float       iso_speed; </b></dt>
      <dd>
        ISO sensitivity.
      </dd>
      <dt><b>float       shutter;</b></dt>
      <dd>
        Shutter speed.
      </dd>
      <dt><b>float       aperture;</b></dt>
      <dd>
        Aperture.
      </dd>
      <dt><b>float       focal_len;</b></dt>
      <dd>
        Focal length.
      </dd>
      <dt><b>time_t      timestamp; </b></dt>
      <dd>
        Date of shooting.
      </dd>
      <dt><b>unsigned    shot_order;</b></dt>
      <dd>
        Serial number of image.
      </dd>
      <dt><b>unsigned    gpsdata[32];</b></dt>
      <dd>
        GPS data.
      </dd>
      <dt><b>char        desc[512];</b></dt>
      <dd>
        Image description.
      </dd>
      <dt><b>char          artist[64];</b></dt>
      <dd>
        Author of image.
      </dd>
    </dl>
    
    <a name="libraw_thumbnail_t"></a>
    <h3>Structure libraw_thumbnail_t: Description of Thumbnail</h3>
    <p>Structure libraw_thumbnail_t describes all parameters associated with the preview saved in the RAW file.<br/>
      Data fields:
    </p>
    <dl>
      <dt><b>LibRaw_thumbnail_formats tformat;</b></dt>
      <dd>
        Thumbnail data format. One of the values among enum <a
          href="#LibRaw_thumbnail_formats">LibRaw_thumbnail_formats</a>. 
      </dd>
      <dt><b>ushort      twidth, theight;</b></dt>
      <dd>
        Dimensions of the preview image in pixels.
      </dd>
      <dt><b>unsigned    tlength;</b></dt>
      <dd>
        Thumbnail length in bytes.
      </dd>
      <dt><b>int         tcolors;</b></dt>
      <dd>
        Number of colors in the preview.
      </dd>
      <dt><b>char       *thumb;</b></dt>
      <dd>
        Pointer to thumbmail, extracted from the data file.
      </dd>
    </dl>

    <a name="libraw_output_params_t"></a>
    <h3>Structure libraw_output_params_t: Management of dcraw-Style Postprocessing</h3>
    <p>Structure libraw_output_params_t is used for management of dcraw-compatible calls dcraw_process(),
      dcraw_ppm_tiff_writer(), dcraw_thumb_writer(), and dcraw_document_mode_processing(). Fields of this structure
correspond to command line keys of dcraw.<br/>
      Data fields:
    </p>
    <dl>
      <dt><b>unsigned    greybox[4];</b></dt>
      <dd>
        <b>dcraw keys:</b> -A  x1 y1 x2 y2 <br/>
       4 numbers corresponding to the coordinates (in pixels) of the rectangle that is used to calculate the white balance.
      </dd>
      <dt><b>double      aber[4];</b></dt>
      <dd>
        <b>dcraw keys:</b>         -C <br/>
        Correction of chromatic aberrations; the only specified values are<br/>
        aber[0], the red multiplier<br/>
        aber[2], the green multiplier.
        For some formats, it affects <a href=API-notes-eng.html>RAW data reading</a>, since correction of aberrations
changes the output size.
      </dd>
      <dt><b>double      gamm[6];</b></dt>
      <dd>
        <b>dcraw keys:</b>         -g power toe_slope <br/>
        Sets user gamma-curve. Library user should set first two fields of gamm array:<br/>
        gamm[0] -  <b>inverted</b> gamma value)<br/>
        gamm[1] - slope for linear part (so called toe slope). Set to zero for simple power curve.
        <br/>
        Remaining 4 values are filled automatically.
        <p>
          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.
      </dd>
      <dt><b>float       user_mul[4];</b></dt>
      <dd>
        <b>dcraw keys:</b>     -r mul0 mul1 mul2 mul3 <br/>
        4 multipliers (r,g,b,g) of the user's white balance.
      </dd>
      <dt><b>unsigned    shot_select, multi_out;</b></dt>
      <dd>
        <b>dcraw keys:</b>  -s <br/>
        Selection of image number for processing (for formats that contain several RAW images in one file). The
        multi_out ( -s all) mode should be programmed by the user, since dcraw_process() does not support it. 
      </dd>
      <dt><b>float       bright;</b></dt>
      <dd>
        <b>dcraw keys:</b>          -b <br/>
        Brightness (default 1.0).
      </dd>
      <dt><b>float       threshold;</b></dt>
      <dd>
        <b>dcraw keys:</b>        -n <br/>
        Parameter for noise reduction through wavelet denoising.
      </dd>
      <dt><b>int         half_size;</b></dt>
      <dd>
        <b>dcraw keys:</b>       -h <br/>
        Outputs the image in 50% size. For some formats, it affects <a href=API-notes-eng.html>RAW data reading</a>. 
      </dd>
      <dt><b>int         four_color_rgb;</b></dt>
      <dd>
        <b>dcraw keys:</b>  -f <br/>
     Switches on separate interpolations for two green components.
      </dd>
      <dt><b>int         document_mode;</b></dt>
      <dd>
        <b>dcraw keys:</b>   -d/-D <br/>
         0: standard processing (with white balance)<br/>
         1: corresponds to -d (without color processing or debayer)<br/>
         2: corresponds to -D (-d without white balance).
      </dd>
      <dt><b>int         highlight;</b></dt>
      <dd>
        <b>dcraw keys:</b>       -H <br/>
         0-9: Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild).
      </dd>
      <dt><b>int         use_auto_wb;</b></dt>
      <dd>
        <b>dcraw keys:</b>     -a <br/>
       Use automatic white balance obtained after averaging over the entire image.
      </dd>
      <dt><b>int         use_camera_wb;</b></dt>
      <dd>
        <b>dcraw keys:</b>   -w <br/>
        If possible, use the white balance from the camera.
      </dd>
      <dt><b>int         use_camera_matrix;</b></dt>
      <dd>
        <b>dcraw keys:</b>  +M/-M <br/>
        Use (1)/don't use camera color matrix.
      </dd>
      <dt><b>int         output_color;</b></dt>
      <dd>
        <b>dcraw keys:</b>    -o <br/>
        [0-5]  Output colorspace (raw, sRGB, Adobe, Wide, ProPhoto, XYZ).
      </dd>
      <dt><b>char*         output_profile;</b></dt>
      <dd>
        <b>dcraw keys:</b>    -o filename<br/>
        Path to output profile ICC file (used only if LibRaw compiled with LCMS support)
      </dd>
      <dt><b>char*         camera_profile;</b></dt>
      <dd>
        <b>dcraw keys:</b>    -o file<br/>
        Path to input (camera) profile ICC file (or 'embed' for embedded profile). Used only if LCMS support compiled in.
      </dd>
      <dt><b>char*         bad_pixels;</b></dt>
      <dd>
        <b>dcraw keys:</b>    -P file<br/>
        Path to file with bad pixels map (in dcraw format: "column row date-of-pixel-death-in-UNIX-format", one pixel
        per row).
      </dd>
      <dt><b>char*         dark_frame;</b></dt>
      <dd>
        <b>dcraw keys:</b>    -K file<br/>
        Path to dark frame file (in 16-bit PGM format)
      </dd>
      <dt><b>enum LibRaw_filtering  filtering_mode;</b></dt>
      <dd>
        <b>dcraw keys:</b>     none <br/>
        Sets RAW data filtering mode (black level subtraction, zero pixels cleaning, tone curve processing)
        See details in <a href=API-notes-eng.html#filtering>filtration modes description</a> and in 
        <a href="#LibRaw_filtering">mode list below</a>.
      </dd>
      <dt><b>int         output_bps;</b></dt>
      <dd>
        <b>dcraw keys:</b>      -4 <br/>
        8 bit (default)/16 bit (key -4).
      </dd>
      <dt><b>int         output_tiff;</b></dt>
      <dd>
        <b>dcraw keys:</b>     -T <br/>
        0/1: output PPM/TIFF.
      </dd>
      <dt><b>int         user_flip;</b></dt>
      <dd>
        <b>dcraw keys:</b>       -t <br/>
        [0-7]  Flip image (0=none, 3=180, 5=90CCW, 6=90CW).
        Default -1, which means taking the corresponding value from RAW. <br/>
        For some formats, <a href=API-notes-eng.html>affects RAW data reading</a>, e.g., unpacking of thumbnails
      from Kodak cameras.
      </dd>
      <dt><b>int         user_qual;</b></dt>
      <dd>
        <b>dcraw keys:</b>       -q <br/>
        0-3: interpolation quality (0 - linear, 1- VNG, 2 - PPG, 3 - AHD). 
      </dd>
      <dt><b>int         user_black;</b></dt>
      <dd>
        <b>dcraw keys:</b>      -k <br/>
        User black level.
      </dd>
      <dt><b>int         user_sat;</b></dt>
      <dd>
        <b>dcraw keys:</b>        -S <br/>
        Saturation adjustment.
      </dd>
      <dt><b>int         med_passes;</b></dt>
      <dd>
        <b>dcraw keys:</b>      -m <br/>
        Number of median filter passes.
      </dd>
      <dt><b>int         no_auto_bright;</b></dt>
      <dd>
        <b>dcraw keys:</b>  -W <br/>
        Don't use automatic increase of brightness by histogram.
      </dd>
      <dt><b>float         auto_bright_thr;</b></dt>
      <dd>
        <b>dcraw keys:</b>none<br/>
        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.
      </dd>
      <dt><b>float         adjust_maximum_thr;</b></dt>
      <dd>
        <b>dcraw keys:</b>none<br/>
        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.
        <br/>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.
        <br/>
        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).
      </dd>
      <dt><b>int         use_fuji_rotate;</b></dt>
      <dd>
        <b>dcraw keys:</b> -j <br/>
         Default -1 (use), 0 - don't use rotation for cameras on a Fuji sensor.
      </dd>
      <dt><b>char        *bpfile;</b></dt>
      <dd>
        <b>dcraw keys:</b>         -P <br/>
        Name of file with bad pixel map.
      </dd>
      <dt><b>char        *dark_frame;</b></dt>
      <dd>
        <b>dcraw keys:</b>     -K <br/>
         Name of file with dark frame.
      </dd>
    </dl>
    <a name="libraw_masked_t"></a>
    <h3>Structure libraw_masked_t - saved masked pixels (black frame) data</h3>
    <p>
      Structure libraw_masked_t designed for storing pixel data for dark frame (black or masked pixels, not included
      in active image sensor area). These pixel values can be used for black level subtraction, noise and banding
      removal and so on.<br/>
      Unlike imgdata.image bitmap which has 4-component pixels, masked pixel data stored in 1-component 16-bit values.
      Different parts of border are stored in different buffers within libraw_masked_t structure, see picture:
    </p>
    <center><img src=corner-scheme.png width="600" height="400" border=1/></center>
    <p>
      Data fields:
    </p>
    <dl>
      <dt><b>ushort  *buffer;</b></dt>
      <dd>Whole allocated buffer. Buffer size is (raw_width*raw_height - width*height).
        </dd>
      <dt><b>ushort  *tl;</b></dt>
      <dd>Pointer to part of buffer designated for storing top-left corner of black frame.
        Data size equal to (top_margin*left_margin).
        </dd>
      <dt><b>ushort  *top;</b></dt>
      <dd>Pointer to part of buffer for storing top part of black frame. Size is (top_margin*width).
      </dd>
      <dt><b>ushort  *tr;</b></dt>
      <dd>Pointer to right top corned data. Size is (top_margin*right_margin).
        </dd>
      <dt><b>ushort  *left;</b></dt>
      <dd>Pointer to pixel data of left frame side. (left_margin*height) pixels.
      </dd>
      <dt><b>ushort  *right;</b></dt>
      <dd>Right side of frame. (right_margin*height) pixels.
      </dd>
      <dt><b>ushort  *bl;</b></dt>
      <dd>Bottom left corner of frame. (bottom_margin*left_margin) pixels.
        </dd>
      <dt><b>ushort  *bottom;</b></dt>
      <dd>Bottom side of frame. Pixel count is (bottom_margin*width).
      </dd>
      <dt><b>ushort  *br;</b></dt>
      <dd>Bottom right corner with (bottom_margin*right_margin) pixels.
        </dd>
      <dt><b>ushort  (*ph1_black)[2];</b</dt>
      <dd>Buffer containing black level data, read from RAW file. Each item contains two elements, one for
        left half-row, one for right half row. Number of items is equal to row count.
        </dd>
    </dl>
    <p>Some cameras does not provide dark frame data. In this case buffer for frame data is not allocated and
      all pointers are initialized to zero.
      Also, structure data is not allocated if image is extracted into half-sized bitmap (i.e. if half_size,
      wavelet threshold or aber[] fields is set in processing options).<br/>
      Some cameras provides not full masked frame, but only several sides of it (only left and top for Canons, only
      left and right for some Nikons and so on). In this case all structure fields are initialized, but allocated
      size for this part of frame is equal to zero and corresponding size parameter (top_/left_/bottom_/right_margin)
      is set too zero too.
    </p>

    <a name="libraw_processed_image_t"></a>
    <h3>Stucture libraw_processed_image_t - result set for  dcraw_make_mem_image()/dcraw_make_mem_thumb() functions</h3>
    <p>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.<br/>
      Data fields:
    </p>
    <dl>
      <dt><b>LibRaw_image_formats type</b></dt>
      <dd> This field records type of data, containing in remaining fields of structure.
        <ul>
          <li><b>LIBRAW_IMAGE_BITMAP</b> - structure contains RGB bitmap. All metadata fields (see below) are valid
            and describes image data.
          <li><b>LIBRAW_IMAGE_JPEG</b> - structure contain in-memory image of JPEG file. Only type, data_size and
            data fields are valid (and nonzero);
        </ul>
      </dd>
      <dt><b>ushort height,width</b></dt>
      <dd> Image size (in pixels). Valid only if  type==LIBRAW_IMAGE_BITMAP.</dd>
      <dt><b>ushort colors, bits</b></dt>
      <dd> 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.
        </dd>
      <dt><b>ushort gamma_corrected</b></dt>
      <dd> 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.</dd>
      <dt><b>unsigned int data_size</b></dt>
      <dd> Size of <b>data</b> 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).
      </dd>
      <dt><b>unsigned char data[]</b></dt>
      <dd> Data array itself. Should be interpreted as RGB triplets for bitmap type and as JPEG file for JPEG type.
        </dd>
      </dl>

    <a name="datastream"></a>
    <h2>Input abstraction layer</h2>
    <p>
      RAW data input (read) in LibRaw implemented by calling methods of object derived from 
      <b>LibRaw_abstract_datastream</b> abstract class. Full list of methods is described in 
        href="API-CXX-eng.html#datastream">C++ API reference</a>. 
    </p>
    <p>
      There is two ready to use implementations of datastream objects:
    </p>
    <ul>
      <li><a href="API-CXX-eng.html#file_datastream">LibRaw_file_datastream</a> - file input (filename provided 
        to LibRaw).</li>
      <li><a href="API-CXX-eng.html#buffer_datastream">LibRaw_buffer_datastream</a> - input from memory buffer.</li>
    </ul>
    <p>
      LibRaw user can create own datastream object derived from 
      <a href="API-CXX-eng.html#datastream">LibRaw_abstract_datastream</a>. For example, such object may
      implement reading RAW data directly from camera (by remote interface). LibRaw can use these
      objects via 
      <a href="API-CXX-eng.html#open_datastream">LibRaw::open_datastream()</a> interface.
    </p>
    <p>
      Datastreams can be used either via 
      <a href="API-CXX-eng.html#open_datastream">LibRaw::open_datastream()</a> call (in this case datastream
      object should be created an maintained by user) or via 
      <a href="API-CXX-eng.html#open_file">LibRaw::open_file()</a> and
      <a href="API-CXX-eng.html#open_buffer">LibRaw::open_buffer()</a> shortcuts.
    </p>
    <p>
      Only <a href="API-CXX-eng.html">C++ API</a> users may use object-oriented interface and
      implement own input interfaces. For <a href="API-C-eng.html">C API</a> users only
      built-on <b>libraw_open_file()/libraw_open_buffer()</b> shortcuts are avaliable.
    </p>
    <a name="datastream_data"></a>
    <h3>Data fields</h3>
    <p>Definition:</p>
    <pre>
class LibRaw_abstract_datastream {
...
protected:
    LibRaw_abstract_datastream *substream;
}
</pre>
    <p><b>Description:</b>
      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.
    </p>
    <p>
      Substream usage details described more precisely in 
      <a href="API-CXX-eng.html#own_datastreams">own datastream objects creation guide</a>.
    </p>

    <a name="const"></a>
    <h2>Constants</h2>
    <a name=LibRaw_errors></a>
    <h3>enum LibRaw_errors: Error Codes</h3>
    <p>All functions returning integer numbers must return either errno or one of the following error codes (see also <a
        href="API-notes-eng.html#errors">error code conventions</a>).</p>
    <p><b>Fatal errors</b> (return of such an error code implies that file processing has to be terminated, since
the state of data structures is unknown).</p>
    <dl>
      <dt><b> LIBRAW_UNSUFFICIENT_MEMORY</b></dt>
      <dd>Attempt to get memory from the system has failed.<br/>
      All allocated resources will be freed, <a href="API-CXX-eng.html#recycle">recycle()</a> will be called, and the LibRaw 
object will be brought to the state &quot;right after creation.&quot;
        </dd>
    <dt><b>LIBRAW_DATA_ERROR</b></dt>
      <dd>A fatal error emerged during data unpacking.<br/>
        All allocated resources will be freed, <a href="API-CXX-eng.html#recycle">recycle()</a> will be called, and the LibRaw 
object will be brought to the state &quot;right after creation.&quot;
      </dd>
    <dt><b>LIBRAW_IO_ERROR</b></dt>
      <dd>A fatal error emerged during file reading (premature end-of-file encountered or file is corrupt).<br/>
        All allocated resources will be freed, <a href="API-CXX-eng.html#recycle">recycle()</a> will be called, and the LibRaw 
object will be brought to the state &quot;right after creation.&quot;
        </dd>
    <dt><b>LIBRAW_CANCELLED_BY_CALLBACK</b></dt>
      <dd>Processing cancelled due to calling application demand (by returning nonzero code from 
        <a  href=API-CXX-eng.html#progress">progress callback</a>).<br/>
        All allocated resources will be freed, <a href="API-CXX-eng.html#recycle">recycle()</a> will be called, and
        the LibRaw  object will be brought to the state &quot;right after creation.&quot;
        </dd>
    </dl>
    <p><b>Non-Fatal Errors</b></p>
    <dl>
      <dt><b>LIBRAW_SUCCESS=0</b></dt>
      <dd>No error; function terminated successfully.</dd>
      <dt><b>LIBRAW_UNSPECIFIED_ERROR</b></dt>
      <dd>An unknown error has been encountered. This code should never be generated.</dd>
      <dt><b>LIBRAW_FILE_UNSUPPORTED</b></dt>
      <dd>Unsupported file format (attempt to open a RAW file with a format unknown to the program).</dd>
      <dt><b>LIBRAW_REQUEST_FOR_NONEXISTENT_IMAGE</b></dt>
      <dd>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).</dd>
      <dt><b>LIBRAW_OUT_OF_ORDER_CALL</b></dt>
      <dd>API functions have been called in wrong order (e.g., <a href="API-CXX-eng.html#unpack">unpack()</a> before
        <a href="API-CXX-eng.html#open_file">open_file()</a>) or the previous stage has ended with an error (e.g.,
         <a href="API-CXX-eng.html#unpack">unpack()</a> is called after <a
          href="API-CXX-eng.html#open_file">open_file()</a> has returned an error).
      </dd> 
      <dt><b>LIBRAW_NO_THUMBNAIL</b></dt>
      <dd>Returned upon an attempt to retrieve a thumbnail from a file containing no preview.</dd>
      <dt><b>LIBRAW_UNSUPPORTED_THUMBNAIL</b></dt>
      <dd>RAW file contains a preview of unsupported format.</dd>
    </dl>

    <a name="progress"></a>    
    <h3>enum LibRaw_progress: Current State of LibRaw Object</h3>
    <p>LibRaw::imgdata.progress_flags contains a bit mask describing all stages of file processing that have already been performed.
    </p>
    <p><b>File opening and RAW data extraction phase.</b></p>
    <dl>
      <dt><b>LIBRAW_PROGRESS_START=0</b></dt>
      <dd>
        Object just created, no processing carried out.
      </dd>
      <dt><b>LIBRAW_PROGRESS_OPEN</b></dt>
      <dd>
        File to be processed has been opened.
      </dd>
      <dt><b>LIBRAW_PROGRESS_IDENTIFY</b></dt>
      <dd>
        Data identification performed, format recognized, metadata extracted.
      </dd>
      <dt><b>LIBRAW_PROGRESS_SIZE_ADJUST</b></dt>
      <dd>
        Data sizes adjusted (for files that require such adjustment, namely, certain files from Kodak cameras). 
      </dd>
      <dt><b>LIBRAW_PROGRESS_LOAD_RAW</b></dt>
      <dd>
        RAW data loaded.
      </dd>
    </dl>
    <p><b>The following flags are set during usage of image processing that has been taken from dcraw.</b></p>
    <dl>
      <dt><b>LIBRAW_PROGRESS_REMOVE_ZEROES</b></dt>
      <dd>
        Zero values removed for cameras that require such removal (Panasonic cameras).
      </dd>
      <dt><b>LIBRAW_PROGRESS_BAD_PIXELS</b></dt>
      <dd>
        Bad (dead) pixels removed.
      </dd>
      <dt><b>LIBRAW_PROGRESS_DARK_FRAME</b></dt>
      <dd>
        Dark frame subtracted from RAW data.
      </dd>
      <dt><b>LIBRAW_PROGRESS_SCALE_COLORS</b></dt>
      <dd>
        White balance performed.
      </dd>
      <dt><b>LIBRAW_PROGRESS_PRE_INTERPOLATE</b></dt>
      <dd>
       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. 
      </dd>
      <dt><b>LIBRAW_PROGRESS_INTERPOLATE</b></dt>
      <dd>
        Interpolation (debayer) performed.
      </dd>
      <dt><b>LIBRAW_PROGRESS_MIX_GREEN</b></dt>
      <dd>
        Averaging of green channels performed.
       </dd>
      <dt><b>LIBRAW_PROGRESS_MEDIAN_FILTER</b></dt>
      <dd>
        Median filtration performed.
      </dd>
      <dt><b>LIBRAW_PROGRESS_HIGHLIGHTS</b></dt>
      <dd>
        Work with highlights performed.
      </dd>
      <dt><b>LIBRAW_PROGRESS_FUJI_ROTATE</b></dt>
      <dd>
        For images from Fuji cameras, rotation performed (or adjust_sizes_info_only() called).
      </dd>
      <dt><b>LIBRAW_PROGRESS_FLIP</b></dt>
      <dd>
        Dimensions recalculated for images shot with a rotated camera (sizes.iwidth/sizes.iheight swapped).
      </dd>
      <dt><b>LIBRAW_PROGRESS_CONVERT_RGB</b></dt>
      <dd>
        Conversion into output RGB space performed.
      </dd>
      <dt><b>LIBRAW_PROGRESS_STRETCH</b></dt>
      <dd>
        Image dimensions changed for cameras with non-square pixels.
      </dd>
      <dt><b>LIBRAW_PROGRESS_STAGE17 - LIBRAW_PROGRESS_STAGE27</b></dt>
      <dd>
        Reserved for possible appearance of other processing stages.
      </dd>
    </dl>
    <p><b>The following flags are set during loading of thumbnails.</b></p>
      <dt><b>LIBRAW_PROGRESS_THUMB_LOAD</b></dt>
      <dd>
        Thumbnail data have been loaded (for Kodak cameras, the necessary conversions have also been made).
      </dd>
      <dt><b>LIBRAW_PROGRESS_TRESERVED1 - LIBRAW_PROGRESS_TRESERVED3</b></dt>
      <dd>
        Reserved for possible future processing stages.
      </dd>
    </dl>
    
    <a name="LibRaw_thumbnail_formats"></a>
    <h3>enum LibRaw_thumbnail_formats: Thumbnail Data Formats</h3>
    <p>Thumbnail data format is written in the imgdata.thumbnail.tformat data field.<br/>
      Presently LibRaw knows about four thumbnail formats, among which two are unpacked:
    </p>
    <dl>
      <dt><b>LIBRAW_THUMBNAIL_UNKNOWN</b></dt>
      <dd>Format unknown or thumbnail  not yet read.
      </dd>
      <dt><b>LIBRAW_THUMBNAIL_JPEG</b></dt>
      <dd>The thumbnail buffer contains a JPEG file (read from the RAW file &quot;as is,&quot; without any manipulations performed on it). 
      </dd>
      <dt><b>LIBRAW_THUMBNAIL_BITMAP</b></dt>
      <dd>
        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).<br/>
        In this format, each pixel of the image is represented by a 8-bit RGB triplet.
      </dd>
      <dt><b>LIBRAW_THUMBNAIL_LAYER</b></dt>
      <dd>
        Data format is presently recognized upon opening of RAW file but not supported: not unpacked into LibRaw::unpack_thumb.
      </dd>
      <dt><b>LIBRAW_THUMBNAIL_ROLLEI</b></dt>
      <dd>
        Data format is presently recognized upon opening of RAW file but not supported: not unpacked into LibRaw::unpack_thumb. 
      </dd>
    </dl>
    <a name="warnings"></a>
    <h3>Nonstandard Situations (Warnings) during RAW Data Processing</h3>
    <p>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.</p>
    <dl>
      <dt><b>LIBRAW_WARN_BAD_CAMERA_WB</b></dt>
      <dd>
       Postprocessing must use white balance of the camera but this balance is not suitable for use.
      </dd>
      <dt><b>LIBRAW_WARN_NO_METADATA</b></dt>
      <dd>
        Only for cameras where the metadata are taken from an external JPEG file: metadata extraction has failed.
      </dd>
      <dt><b>LIBRAW_WARN_NO_JPEGLIB</b></dt>
      <dd>
        Only for P&S Kodak cameras: data in JPEG format. At the same time, open_file() will return LIBRAW_FILE_UNSUPPORTED.
     </dd>
      <dt><b>LIBRAW_WARN_NO_EMBEDDED_PROFILE</b></dt>
      <dd>
        (only if LCMS support compiled in).
        Caller set embedded input profile use, but no such profile exists in RAW.
      </dd>
      <dt><b>LIBRAW_WARN_NO_INPUT_PROFILE</b></dt>
      <dd>
        (only if LCMS support compiled in).
        Error when opening input profile ICC file.
      </dd>
      <dt><b>LIBRAW_WARN_BAD_OUTPUT_PROFILE</b></dt>
      <dd>
        (only if LCMS support compiled in).
        Error when opening output profile ICC file.
      </dd>
      <dt><b>LIBRAW_WARN_NO_BADPIXELMAP</b></dt>
      <dd>
        Error when opening bad pixels map file.
      </dd>
      <dt><b>LIBRAW_WARN_BAD_DARKFRAME_FILE</b></dt>
      <dd>
        Error when opening dark frame file.
      </dd>
      <dt><b>LIBRAW_WARN_BAD_DARKFRAME_DIM</b></dt>
      <dd>
        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).
      </dd>
    </dl>
    <a name="LibRaw_filtering"></a>
    <h3>enum LibRaw_filtering - RAW data filtering settings</h3>
    <p>
      This enum describes possible RAW data filtration modes during data unpacking and postprocessing.
      Usage recommendations are described in <a href="API-notes-eng.html#filtering">API comments</a>. 
      Filtering mode should be set by altering <b>filtering_mode</b> option before 
      <a href="API-CXX-eng.html#unpack">unpack()</a> is called.
    </p>
    <dl>
      <dt><b>LIBRAW_FILTERING_DEFAULT</b></dt>
      <dd>Default value: dcraw filtration mode (for compatibility with previous LibRaw versions without
        data filtering options).
      </dd>
      <dt><b>LIBRAW_FILTERING_NOZEROES</b></dt>
      <dd>
        If this bit set, then zero values in RAW data will not be cleared (averaged). Zero averaging
        is needed for some cameras, such as Point-and-Shot Canon cameras, Panasonic cameras and some other.
      </dd>
      <dt><b>LIBRAW_FILTERING_NOBLACK</b></dt>
      <dd>
        If this bit is set, then no black level subtraction will be done on unpacking stage (for cameras
        with black subtraction on unpacking stage: e.g. Canon cameras). Also, if this bit is set, then 
        automatically calculated black level (this value is subtracted on postprocessing stage) is set
        to zero. This bit does not affects black subtraction set via <b>user_black</b> option.
      </dd>
      <dt><b>LIBRAW_FILTERING_NORAWCURVE</b></dt>
      <dd>
        This bit turns off tone curve processing (for tone curves read from file metadata or calculated from
        constants). This setting is supported only for bayer-pattern cameras with tone curve;
      </dd>
      <dt><b>LIBRAW_FILTERING_NONE</b></dt>
      <dd>
        Equal to  (LIBRAW_FILTERING_NOZEROES|LIBRAW_FILTERING_NOBLACK|LIBRAW_FILTERING_NORAWCURVE)
      </dd>
      <dt><b>LIBRAW_FILTERING_LIBRAWOWN</b></dt>
      <dd>
        This bit turns on LibRaw specialized functions for data filtering. These funcions will be made
        individually for each camera model (and, possibly, firmware version). For now, no such subroutines
        ready, so this parameter is reserved for future.
      </dd>
      <dt><b>LIBRAW_FILTERING_AUTOMATIC</b></dt>
      <dd>
        Equals to LIBRAW_FILTERING_LIBRAWOWN with fallback to LIBRAW_FILTERING_DEFAULT if no
        specialized filtering function exists for given camera. 
      </dd>
      <dt><b>LIBRAW_FILTERING_AUTOMATIC_BIT</b></dt>
      <dd>
        This bit reserved for LIBRAW_FILTERING_AUTOMATIC support.
      </dd>
    </dl>
    <p>
      Best possible setting for common RAW-processing software is LIBRAW_FILTERING_AUTOMATIC. 
      For RAW analyzers we recommend use LIBRAW_FILTERING_NONE or LIBRAW_FILTERING_NOBLACK.
    </p>

    <a name="LibRaw_colorstate"></a>
    <h3>enum LibRaw_colorstate:  Types of Color Data Source</h3>
    <p>For each type of retrieved color information (see above for description of structure imgdata.color.color_flags), the
data source is recorded. The possible values are listed below. 
    </p>
    <dl>
      <dt><b>LIBRAW_COLORSTATE_UNKNOWN</b></dt>  
      <dd>
        Data source unknown.
      </dd>
      <dt><b>LIBRAW_COLORSTATE_INIT</b></dt>  
      <dd>
        Data field initialized by default (the same value for all cameras) before opening the RAW file.
      </dd>
      <dt><b>LIBRAW_COLORSTATE_CONST</b></dt>    
      <dd>
        Data source is a hardcoded constant.
      </dd>
      <dt><b>LIBRAW_COLORSTATE_LOADED</b></dt>   
      <dd>
        Data loaded from RAW file.
      </dd>
      <dt><b>LIBRAW_COLORSTATE_CALCULATED</b></dt>
      <dd>
        Data calculated on the basis of RAW data.
      </dd>
      <dt><b>LIBRAW_COLORSTATE_RESERVED1-LIBRAW_COLORSTATE_RESERVED3</b></dt>
      <dd>
        Reserved.
      </dd>
    </dl>
    <a name="LibRaw_image_formats"></a>
    <h3>enum LibRaw_image_formats - possible types of data, contains in  libraw_processed_image_t structure</h3>
    <p><b>type</b> field of  libraw_processed_image_t structure may have one of these values:
      </p>
    <dl>
      <dt><b>LIBRAW_IMAGE_BITMAP</b></dt>    
      <dd>
        The structure contains RGB-bitmap, metadata described in other fields of  libraw_processed_image_t.
      </dd>
      <dt><b>LIBRAW_IMAGE_JPEG</b></dt>    
      <dd>
        libraw_processed_image_t structure contains JPEG image (in memory). Only data_size field is meaningful.
      </dd>
    </dl>


    <a href=index-eng.html>[back to Index]</a>
    <hr>
    <address><a href="mailto:info@libraw.org">LibRaw Team</a></address>
<!-- Created: Sun Mar 16 14:42:41 MSK 2008 -->
<!-- hhmts start -->
Last modified: Wed Apr 21 09:04:26 MSD 2010
<!-- hhmts end -->
  </body>
</html>