[back to Index]

# LibRaw Project Goals and Objectives

## Contents

1. Who May Be Interested in This Project
2. Goals and Objectives
3. LibRaw Support Principles
4. Implemented Improvements of dcraw
5. Planned Improvements

## Who May Be Interested in This Project

The proposed project and the software products generated within this project are intended for

- Developers of RAW converters, including current and new developments
- 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 (de-Bayer),
  - Noise reduction
  - White balance
  - Correction of aberrations and distortions
  - Color conversions (e.g., creation, editing and application of camera profiles )
  - RAW data analysis
  - Comparison of cameras and lenses
  - and so on...

Among the few existing implementations of RAW converters, those based on the dcraw utility by Dave Coffin are the most used. It is hard to find a more or less popular camera that is not supported by this utility; while the implementation of RAW data extraction in dcraw is of a very high quality.

However, developers and enthusiasts who use or are going to use dcraw for fulfilling the above-listed and similar objectives encounter a number of difficulties. First, the author of dcraw refuses to turn his product into a handy library, yet permitting anybody else to do so. Besides, dcraw contains a number of questionable features which 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, virtually all developers, part of them listed on the dcraw Web site, independently convert each subsequent release of the software into the library.

As for enthusiasts, the "entry cost" of verifying their own ideas and implementing their own algorithms 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.

## Goals and Objectives

We are going to create LibRaw in order to "get a library based on dcraw, only better". Thus:

1. To "librarize" dcraw, i.e., to develop a stable and consistent API suitable for other applications (RAW converters, data analyzers, panorama stitchers, etc.).
2. To divide processing into 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.
   - File output of the processing results.
   The latter two groups of functions are maintained primarily for dcraw compatibility testing.
3. To improve the procedures of RAW data retrieval and decoding (see below for details)
4. 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.
5. To ensure easy modification for code synchronization with dcraw releases.

## LibRaw Support Principles

1. To reproduce the functionality of dcraw using its source code as the basis for our work; to achieve binary identity of results generated by dcraw and by LibRaw-based utilities, provided the same processing settings are used.
2. To eliminate the shortcomings of dcraw (see sections Implemented Improvements of dcraw and Planned Improvements).
3. To monitor future improvements in dcraw (support of new cameras, error correction, use of better algorithms) and import them from dcraw to LibRaw.
4. API modifications: the planned improvements will require extending of the API. Such changes will be introduced in the form of large change-sets, while the compatibility mode supporting older applications based on the legacy API set will be preserved as long as possible.

## Implemented Improvements of dcraw

As of the time of writing, additional improvements to the dcraw source code have been introduced into LibRaw:

- All global variables have been removed (while linking the thread-safe version, static variables of functions have been removed as well).
- Thread safety. An example of its use in the multithreaded model is included into the library distribution package.
- Data extracted from a RAW file is already somewhat structured: geometry is separated from color data. This work has not yet been completed; it will be continued simultaneously with the work on improvement of EXIF processing.
- Retrieval of RAW data and thumbnail can be performed in two or three API calls with a very simple program interface.
- Work with color information: color data (white balance coefficients, tone curve, etc.) has flags referencing the source of this information: retrieved from RAW data, calculated from the image itself, or taken from the code as constants.
- ICC profile is extracted (for those RAW files that contain it).
- The image itself and the thumbnail can be retrieved by successive calls, without reopening the file or relaunching the library.
- The required amount of RAM is somewhat lower.
- Work with black subtraction:: it is possible to turn off black level subtraction.
- Processing of the black frame: black subtraction and zero pixel cleaning already can be turned off. Code for accurate black level calculation and banding suppression is planned.
- The maximum values may also be nonidentical for different channels; accordingly, these values are calculated at the stage of RAW data unpacking and output within the framework of the API. Calculation of the maximum values for a given camera sample at a specified sensitivity (converter calibration) is to be done in the application that calls LibRaw.

## Planned Improvements

The dcraw code needs significant modifications and additions:

- Single-pass unpacking of RAW files containing several image variants/planes: for applicable cameras (Fuji cameras, cameras with 4-shot/16-shot modes), several planes of the same image will be extracted.
- Data unpacking verifications for the widest possible set of file formats. According to some studies, dcraw does not completely ensure correct unpacking of some data formats.
- Processing of the EXIF/Makernote data: retrieval of large data amounts, including
  - Extraction of the maximum possible amount of color data (white balance settings, profile, tone curve, contrast settings, etc.)
  - Color data generalization: reduction of color data from different cameras "to a common denominator" in order to facilitate color processing (without loss of quality)
  - Extraction of camera data (firmware version, serial number)
  - Extraction of photographic data (lens used, focusing distance, focus points and their coordinates, etc.)
  - Extraction of the bulk EXIF data set without analyzing the structure in order to facilitate copying of that EXIF data to output files.
- Generalization of work with complex formats, including
  - RAW files from Fuji cameras (with two sets of sensors)
  - RAW files from digital backs with 4-shot and 16-shot modes.

At the same time, we are not planning any modifications or extensions of the dcraw data processing code (de-Bayer, color conversions, etc.); all of this is up to the calling application. Standard processing modes included in dcraw will be preserved for an indefinite time in the set of dcraw-emulating API calls, with the exception of LCMS and libjpeg support, as well as certain processing stages of minor importance.

[back to Index]

Last modified: Mon Jul 11 20:20:12 MSD 2011