Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

dcraw.c File Reference

#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <jpeglib.h>
#include <unistd.h>
#include <netinet/in.h>

Go to the source code of this file.

Classes

struct  decode

Defines

#define _GNU_SOURCE
#define LONG_BIT   (8 * sizeof (long))
#define ushort   UshORt
#define ABS_MAX   ((ushort) -1)
#define RGB_MAX   ((ushort) -1)
#define CLASS
#define FC(row, col)   (filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3)
#define BAYER(row, col)   image[((row) >> shrink)*iwidth + ((col) >> shrink)][FC(row,col)]
#define FORYX   for (y=1; y < 3; y++) for (x=col+1; x >= col; x--)
#define PREDICTOR
#define FMIN(a, b)   ((a) < (b) ? (a) : (b))

Typedefs

typedef long long INT64
typedef unsigned char uchar
typedef unsigned short ushort

Functions

void write_ppm (FILE *)
char * memmem (char *haystack, size_t haystacklen, char *needle, size_t needlelen)
void CLASS merror (void *ptr, char *where)
ushort CLASS fget2 (FILE *f)
int CLASS fget4 (FILE *f)
void CLASS canon_600_load_raw ()
void CLASS canon_a5_load_raw ()
unsigned CLASS getbits (int nbits)
void CLASS init_decoder ()
uchar *CLASS make_decoder (const uchar *source, int level)
void CLASS crw_init_tables (unsigned table)
int CLASS canon_has_lowbits ()
void CLASS canon_compressed_load_raw ()
void CLASS kodak_curve (ushort *curve)
void CLASS lossless_jpeg_load_raw ()
void CLASS nikon_compressed_load_raw ()
void CLASS nikon_load_raw ()
int CLASS nikon_is_compressed ()
int CLASS nikon_e990 ()
int CLASS nikon_e2100 ()
int CLASS minolta_z2 ()
void CLASS nikon_e2100_load_raw ()
void CLASS nikon_e950_load_raw ()
void CLASS fuji_s2_load_raw ()
void CLASS fuji_common_load_raw (int ncol, int icol, int nrow)
void CLASS fuji_s5000_load_raw ()
void CLASS fuji_s7000_load_raw ()
void CLASS fuji_f700_load_raw ()
void CLASS rollei_load_raw ()
void CLASS phase_one_load_raw ()
void CLASS ixpress_load_raw ()
void CLASS packed_12_load_raw ()
void CLASS unpacked_load_raw (int order, int rsh)
void CLASS be_16_load_raw ()
void CLASS be_high_12_load_raw ()
void CLASS be_low_12_load_raw ()
void CLASS be_low_10_load_raw ()
void CLASS le_high_12_load_raw ()
void CLASS olympus_cseries_load_raw ()
void CLASS eight_bit_load_raw ()
void CLASS casio_qv5700_load_raw ()
void CLASS nucore_load_raw ()
const int *CLASS make_decoder_int (const int *source, int level)
int CLASS radc_token (int tree)
void CLASS kodak_radc_load_raw ()
 fill_input_buffer (j_decompress_ptr cinfo)
void CLASS kodak_jpeg_load_raw ()
void CLASS kodak_dc120_load_raw ()
void CLASS kodak_dc20_coeff (float juice)
void CLASS kodak_easy_load_raw ()
void CLASS kodak_compressed_load_raw ()
void CLASS kodak_yuv_load_raw ()
void CLASS sony_decrypt (unsigned *data, int len, int start, int key)
void CLASS sony_load_raw ()
void CLASS sony_rgbe_coeff ()
void CLASS foveon_decoder (unsigned huff[1024], unsigned code)
void CLASS foveon_load_raw ()
int CLASS apply_curve (int i, const int *curve)
void CLASS foveon_interpolate ()
void CLASS bad_pixels ()
int CLASS get_generic_parameter (FILE *fp, const char *name, const char *line, const char *sequence, void *where, int *flag)
int CLASS get_float_parameter (FILE *fp, const char *name, const char *line, float *where, int *flag)
int CLASS get_int_parameter (FILE *fp, const char *name, const char *line, int *where, int *flag)
int get_parameter_value (FILE *fp)
void get_parameters ()
void CLASS scale_colors ()
void CLASS vng_interpolate ()
void thm_interpolate ()
void CLASS tiff_parse_subifd (int base)
void CLASS nef_parse_makernote ()
void CLASS get_timestamp ()
void CLASS nef_parse_exif (int base)
void CLASS parse_tiff (int base)
void CLASS ciff_block_1030 ()
void CLASS parse_ciff (int offset, int length)
void CLASS parse_rollei ()
void CLASS parse_foveon ()
void CLASS foveon_coeff ()
void CLASS canon_rgb_coeff (float juice)
void CLASS nikon_e950_coeff ()
void CLASS gmcy_coeff ()
int CLASS identify ()
void CLASS convert_to_rgb ()
static void calc_rgb_to_hsl (ushort *rgb, double *hue, double *sat, double *lightness)
static double hsl_value (double n1, double n2, double hue)
static void calc_hsl_to_rgb (ushort *rgb, double h, double s, double l)
static double update_saturation (double sat, double adjust)
static double update_contrast (double lum, double adjust)
static void do_hsl_adjust (ushort *rgb)
void CLASS flip_image ()
void CLASS write_psd16 (FILE *ofp)
void CLASS write_ppm16 (FILE *ofp)
void CLASS write_cinelerra (FILE *ofp)
void CLASS write_ppm_16_8 (FILE *ofp)
int CLASS dcraw_main (int argc, char **argv)

Variables

char dcraw_info [1024]
float ** dcraw_data
int dcraw_alpha
FILE * ifp
short order
char * ifname
char make [64]
char model [64]
char model2 [64]
time_t timestamp
int data_offset
int curve_offset
int curve_length
int tiff_data_compression
int kodak_data_compression
int raw_height
int raw_width
int top_margin
int left_margin
int height
int width
int colors
int black
int rgb_max
int iheight
int iwidth
int shrink
int is_canon
int is_cmy
int is_foveon
int use_coeff
int trim
int flip
int xmag
int ymag
int zero_after_ff
unsigned filters
ushort(* image )[4]
ushortwhite [8][8]
void(* load_raw )()
float gamma_val = 0.6
float bright = 1.0
float red_scale = 1.0
float blue_scale = 1.0
int four_color_rgb = 0
int document_mode = 0
int quick_interpolate = 0
int verbose = 0
int use_auto_wb = 0
int use_camera_wb = 0
int use_secondary = 0
float camera_red
float camera_blue
float pre_mul [4]
float coeff [3][4]
float k1 = 1.5
float k2 = 0.5
float juice = 0.0
int histogram [0x2000]
void(* write_fun )(FILE *) = write_ppm
jmp_buf failure
float green_scale = 1.0
float saturation = 1.0
float contrast = 1.0
int autoexposure = 0
int use_pivot = 0
int use_neutral_wb = 0
int alternate_scale = 0
int center_weight = 0
int use_camera_black = 1
int user_black = -1
float pivot_value = 0.75
float exposure_compensation = 0.0
unsigned pivot_point [4]
unsigned pivot_base [4]
float white_point_fraction = 0.99
decode first_decode [2048]
decodesecond_decode [2048]
decodefree_decode [2048]


Define Documentation

#define _GNU_SOURCE
 

Definition at line 18 of file dcraw.c.

#define ABS_MAX   ((ushort) -1)
 

Definition at line 62 of file dcraw.c.

Referenced by scale_colors().

#define BAYER row,
col   )     image[((row) >> shrink)*iwidth + ((col) >> shrink)][FC(row,col)]
 

Definition at line 137 of file dcraw.c.

Referenced by bad_pixels(), canon_600_load_raw(), canon_a5_load_raw(), canon_compressed_load_raw(), casio_qv5700_load_raw(), eight_bit_load_raw(), fuji_common_load_raw(), fuji_f700_load_raw(), fuji_s2_load_raw(), ixpress_load_raw(), kodak_compressed_load_raw(), kodak_dc120_load_raw(), kodak_easy_load_raw(), kodak_jpeg_load_raw(), kodak_radc_load_raw(), lossless_jpeg_load_raw(), nikon_compressed_load_raw(), nikon_e2100_load_raw(), nikon_e950_load_raw(), nikon_load_raw(), nucore_load_raw(), olympus_cseries_load_raw(), packed_12_load_raw(), phase_one_load_raw(), rollei_load_raw(), sony_load_raw(), and unpacked_load_raw().

#define CLASS
 

Definition at line 125 of file dcraw.c.

#define FC row,
col   )     (filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3)
 

Definition at line 134 of file dcraw.c.

Referenced by bad_pixels(), convert_to_rgb(), scale_colors(), and vng_interpolate().

#define FMIN a,
 )     ((a) < (b) ? (a) : (b))
 

Definition at line 4332 of file dcraw.c.

Referenced by calc_rgb_to_hsl(), and update_saturation().

#define FORYX   for (y=1; y < 3; y++) for (x=col+1; x >= col; x--)
 

Definition at line 1197 of file dcraw.c.

Referenced by kodak_radc_load_raw().

#define LONG_BIT   (8 * sizeof (long))
 

Definition at line 55 of file dcraw.c.

Referenced by ciff_block_1030(), and getbits().

#define PREDICTOR
 

Value:

(c ? (buf[c][y-1][x] + buf[c][y][x+1]) / 2 \
: (buf[c][y-1][x+1] + 2*buf[c][y-1][x] + buf[c][y][x+1]) / 4)

Definition at line 1199 of file dcraw.c.

Referenced by kodak_radc_load_raw().

#define RGB_MAX   ((ushort) -1)
 

Definition at line 63 of file dcraw.c.

Referenced by scale_colors().

#define ushort   UshORt
 

Definition at line 58 of file dcraw.c.

Referenced by canon_600_load_raw(), canon_a5_load_raw(), canon_compressed_load_raw(), casio_qv5700_load_raw(), ciff_block_1030(), convert_to_rgb(), foveon_interpolate(), fuji_common_load_raw(), fuji_f700_load_raw(), fuji_s2_load_raw(), ixpress_load_raw(), kodak_compressed_load_raw(), kodak_dc120_load_raw(), kodak_easy_load_raw(), kodak_yuv_load_raw(), lossless_jpeg_load_raw(), nikon_compressed_load_raw(), nikon_e2100_load_raw(), phase_one_load_raw(), scale_colors(), sony_load_raw(), unpacked_load_raw(), vng_interpolate(), write_cinelerra(), write_ppm(), write_ppm16(), write_ppm_16_8(), and write_psd16().


Typedef Documentation

typedef long long INT64
 

Definition at line 46 of file dcraw.c.

typedef unsigned char uchar
 

Definition at line 59 of file dcraw.c.

typedef unsigned short ushort
 

Definition at line 60 of file dcraw.c.


Function Documentation

int CLASS apply_curve int  i,
const int *  curve
 

Definition at line 1636 of file dcraw.c.

Referenced by foveon_interpolate().

void CLASS bad_pixels  ) 
 

Definition at line 1899 of file dcraw.c.

References BAYER, FC, fclose(), fgets(), filters, fopen(), fputc(), height, timestamp, verbose, and width.

Referenced by dcraw_main().

void CLASS be_16_load_raw  ) 
 

Definition at line 1046 of file dcraw.c.

References unpacked_load_raw().

Referenced by identify().

void CLASS be_high_12_load_raw  ) 
 

Definition at line 1051 of file dcraw.c.

References unpacked_load_raw().

Referenced by identify().

void CLASS be_low_10_load_raw  ) 
 

Definition at line 1061 of file dcraw.c.

References unpacked_load_raw().

Referenced by identify().

void CLASS be_low_12_load_raw  ) 
 

Definition at line 1056 of file dcraw.c.

References unpacked_load_raw().

Referenced by identify().

static void calc_hsl_to_rgb ushort rgb,
double  h,
double  s,
double  l
[inline, static]
 

Definition at line 4413 of file dcraw.c.

References hsl_value(), and rgb_max.

Referenced by do_hsl_adjust().

static void calc_rgb_to_hsl ushort rgb,
double *  hue,
double *  sat,
double *  lightness
[inline, static]
 

Definition at line 4334 of file dcraw.c.

References FMIN, and rgb_max.

Referenced by do_hsl_adjust().

void CLASS canon_600_load_raw  ) 
 

Definition at line 251 of file dcraw.c.

References BAYER, black, fread(), height, ifp, ushort, and width.

Referenced by identify().

void CLASS canon_a5_load_raw  ) 
 

Definition at line 281 of file dcraw.c.

References BAYER, black, fread(), height, ifp, raw_width, ushort, and width.

Referenced by identify().

void CLASS canon_compressed_load_raw  ) 
 

Definition at line 485 of file dcraw.c.

References BAYER, black, decode::branch, canon_has_lowbits(), fgetc(), first_decode, fseek(), ftell(), getbits(), height, ifp, decode::leaf, left_margin, merror(), raw_height, raw_width, second_decode, top_margin, ushort, width, and zero_after_ff.

Referenced by identify().

int CLASS canon_has_lowbits  ) 
 

Definition at line 470 of file dcraw.c.

References fread(), fseek(), and ifp.

Referenced by canon_compressed_load_raw().

void CLASS canon_rgb_coeff float  juice  ) 
 

Definition at line 3235 of file dcraw.c.

References coeff, and use_coeff.

Referenced by identify().

void CLASS casio_qv5700_load_raw  ) 
 

Definition at line 1101 of file dcraw.c.

References BAYER, fread(), height, ifp, ushort, and width.

Referenced by identify().

void CLASS ciff_block_1030  ) 
 

Definition at line 3010 of file dcraw.c.

References fget2(), fget4(), ifp, LONG_BIT, ushort, and white.

Referenced by parse_ciff().

void CLASS convert_to_rgb  ) 
 

Definition at line 4281 of file dcraw.c.

References coeff, colors, document_mode, FC, height, histogram, image, is_cmy, rgb_max, trim, use_coeff, ushort, width, write_fun, and write_ppm().

Referenced by dcraw_main().

void CLASS crw_init_tables unsigned  table  ) 
 

Definition at line 394 of file dcraw.c.

References free_decode, init_decoder(), make_decoder(), and second_decode.

Referenced by parse_ciff().

int CLASS dcraw_main int  argc,
char **  argv
 

Definition at line 4800 of file dcraw.c.

References alternate_scale, autoexposure, bad_pixels(), blue_scale, bright, center_weight, contrast, convert_to_rgb(), document_mode, exposure_compensation, failure, fclose(), fileno(), filters, flip, flip_image(), fopen(), four_color_rgb, foveon_interpolate(), gamma_val, green_scale, height, identify(), ifname, ifp, iheight, image, is_foveon, iwidth, juice, k1, k2, make, merror(), model, pivot_value, quick_interpolate, red_scale, saturation, scale_colors(), shrink, trim, use_auto_wb, use_camera_black, use_camera_wb, use_neutral_wb, use_pivot, use_secondary, user_black, verbose, vng_interpolate(), white_point_fraction, width, write_cinelerra(), write_fun, write_ppm(), write_ppm16(), write_ppm_16_8(), and write_psd16().

Referenced by FileCR2::check_sig(), FileCR2::open_file(), and FileCR2::read_frame().

static void do_hsl_adjust ushort rgb  )  [inline, static]
 

Definition at line 4468 of file dcraw.c.

References calc_hsl_to_rgb(), calc_rgb_to_hsl(), contrast, saturation, update_contrast(), and update_saturation().

Referenced by write_cinelerra(), write_ppm(), write_ppm16(), write_ppm_16_8(), and write_psd16().

void CLASS eight_bit_load_raw  ) 
 

Definition at line 1086 of file dcraw.c.

References BAYER, fread(), height, ifp, merror(), raw_width, and width.

Referenced by identify().

ushort CLASS fget2 FILE *  f  ) 
 

Definition at line 222 of file dcraw.c.

References fgetc(), and order.

Referenced by ciff_block_1030(), foveon_load_raw(), identify(), kodak_curve(), lossless_jpeg_load_raw(), nef_parse_exif(), nef_parse_makernote(), nikon_compressed_load_raw(), parse_ciff(), parse_foveon(), parse_tiff(), phase_one_load_raw(), and tiff_parse_subifd().

int CLASS fget4 FILE *  f  ) 
 

Definition at line 237 of file dcraw.c.

References fgetc(), and order.

Referenced by ciff_block_1030(), foveon_load_raw(), identify(), kodak_curve(), nef_parse_exif(), nef_parse_makernote(), parse_ciff(), parse_foveon(), parse_tiff(), phase_one_load_raw(), sony_load_raw(), and tiff_parse_subifd().

fill_input_buffer j_decompress_ptr  cinfo  ) 
 

Definition at line 1274 of file dcraw.c.

References fread(), and ifp.

Referenced by kodak_jpeg_load_raw().

void CLASS flip_image  ) 
 

Definition at line 4481 of file dcraw.c.

References flip, height, image, merror(), width, xmag, and ymag.

Referenced by dcraw_main().

void CLASS foveon_coeff  ) 
 

Definition at line 3216 of file dcraw.c.

References coeff, pre_mul, and use_coeff.

Referenced by identify().

void CLASS foveon_decoder unsigned  huff[1024],
unsigned  code
 

Definition at line 1572 of file dcraw.c.

References decode::branch, failure, first_decode, free_decode, ifname, and decode::leaf.

Referenced by foveon_load_raw().

void CLASS foveon_interpolate  ) 
 

Definition at line 1648 of file dcraw.c.

References apply_curve(), height, image, merror(), ushort, and width.

Referenced by dcraw_main().

void CLASS foveon_load_raw  ) 
 

Definition at line 1598 of file dcraw.c.

References decode::branch, fget2(), fget4(), fgetc(), first_decode, foveon_decoder(), fseek(), height, ifp, image, init_decoder(), decode::leaf, left_margin, raw_height, raw_width, top_margin, and width.

Referenced by identify().

void CLASS fuji_common_load_raw int  ncol,
int  icol,
int  nrow
 

Definition at line 901 of file dcraw.c.

References BAYER, fread(), ifp, and ushort.

Referenced by fuji_s5000_load_raw(), and fuji_s7000_load_raw().

void CLASS fuji_f700_load_raw  ) 
 

Definition at line 934 of file dcraw.c.

References BAYER, fread(), ifp, use_secondary, and ushort.

Referenced by identify().

void CLASS fuji_s2_load_raw  ) 
 

Definition at line 885 of file dcraw.c.

References BAYER, fread(), fseek(), ifp, and ushort.

Referenced by identify().

void CLASS fuji_s5000_load_raw  ) 
 

Definition at line 918 of file dcraw.c.

References fseek(), fuji_common_load_raw(), and ifp.

Referenced by identify().

void CLASS fuji_s7000_load_raw  ) 
 

Definition at line 924 of file dcraw.c.

References fuji_common_load_raw().

Referenced by identify().

int CLASS get_float_parameter FILE *  fp,
const char *  name,
const char *  line,
float *  where,
int *  flag
 

Definition at line 1974 of file dcraw.c.

References get_generic_parameter().

Referenced by get_parameter_value().

int CLASS get_generic_parameter FILE *  fp,
const char *  name,
const char *  line,
const char *  sequence,
void *  where,
int *  flag
 

Definition at line 1954 of file dcraw.c.

References fgets().

Referenced by get_float_parameter(), and get_int_parameter().

int CLASS get_int_parameter FILE *  fp,
const char *  name,
const char *  line,
int *  where,
int *  flag
 

Definition at line 1980 of file dcraw.c.

References get_generic_parameter().

Referenced by get_parameter_value().

int get_parameter_value FILE *  fp  ) 
 

Definition at line 1989 of file dcraw.c.

References blue_scale, bright, coeff, contrast, exposure_compensation, fgets(), flip, gamma_val, get_float_parameter(), get_int_parameter(), green_scale, juice, pivot_value, red_scale, saturation, use_coeff, verbose, and white_point_fraction.

Referenced by get_parameters().

void get_parameters  ) 
 

Definition at line 2092 of file dcraw.c.

References fclose(), fopen(), get_parameter_value(), ifname, and merror().

void CLASS get_timestamp  ) 
 

Definition at line 2853 of file dcraw.c.

References fscanf(), ifp, and timestamp.

Referenced by nef_parse_exif(), and parse_tiff().

unsigned CLASS getbits int  nbits  ) 
 

Definition at line 313 of file dcraw.c.

References fgetc(), ifp, LONG_BIT, and zero_after_ff.

Referenced by canon_compressed_load_raw(), kodak_radc_load_raw(), lossless_jpeg_load_raw(), nikon_compressed_load_raw(), nikon_e950_load_raw(), nikon_load_raw(), olympus_cseries_load_raw(), packed_12_load_raw(), and radc_token().

void CLASS gmcy_coeff  ) 
 

Definition at line 3271 of file dcraw.c.

References coeff, and use_coeff.

Referenced by identify().

static double hsl_value double  n1,
double  n2,
double  hue
[inline, static]
 

Definition at line 4397 of file dcraw.c.

Referenced by calc_hsl_to_rgb().

int CLASS identify  ) 
 

Definition at line 3322 of file dcraw.c.

References be_16_load_raw(), be_high_12_load_raw(), be_low_10_load_raw(), be_low_12_load_raw(), black, blue_scale, camera_blue, camera_red, canon_600_load_raw(), canon_a5_load_raw(), canon_compressed_load_raw(), canon_rgb_coeff(), casio_qv5700_load_raw(), coeff, colors, curve_length, curve_offset, data_offset, dcraw_info, eight_bit_load_raw(), fget2(), fget4(), fgetc(), filters, flip, four_color_rgb, foveon_coeff(), foveon_load_raw(), fread(), fseek(),