2
Copyright 2008-2010 LibRaw LLC (info@libraw.org)
4
LibRaw is free software; you can redistribute it and/or modify
5
it under the terms of the one of three licenses as you choose:
7
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
8
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
10
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
11
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
13
3. LibRaw Software License 27032010
14
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
16
This file is generated from Dave Coffin's dcraw.c
17
dcraw.c -- Dave Coffin's raw photo decoder
18
Copyright 1997-2010 by Dave Coffin, dcoffin a cybercom o net
20
Look into dcraw homepage (probably http://cybercom.net/~dcoffin/dcraw/)
25
#define VERSION "9.05"
30
#define _USE_MATH_DEFINES
42
#include <sys/types.h>
45
NO_JPEG disables decoding of compressed Kodak DC120 files.
46
NO_LCMS disables the "-p" option.
53
#define _(String) gettext(String)
55
#define _(String) (String)
61
#include <sys/utime.h>
63
#pragma comment(lib, "ws2_32.lib")
64
#define snprintf _snprintf
65
#define strcasecmp _stricmp
66
#define strncasecmp strnicmp
70
#include <netinet/in.h>
74
#error Please compile dcraw.c by itself.
75
#error Do not link it with ljpeg_decode.
79
#define LONG_BIT (8 * sizeof (long))
81
#define FORC(cnt) for (c=0; c < cnt; c++)
84
#define FORCC FORC(colors)
86
#define SQR(x) ((x)*(x))
87
#define ABS(x) (((int)(x) ^ ((int)(x) >> 31)) - ((int)(x) >> 31))
88
#define MIN(a,b) ((a) < (b) ? (a) : (b))
89
#define MAX(a,b) ((a) > (b) ? (a) : (b))
90
#define LIM(x,min,max) MAX(min,MIN(x,max))
91
#define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y))
92
#define CLIP(x) LIM(x,0,65535)
93
#define SWAP(a,b) { a=a+b; b=a-b; a=a-b; }
96
In order to inline this calculation, I make the risky
97
assumption that all filter patterns can be described
98
by a repeating pattern of eight rows and two columns
100
Do not use the FC or BAYER macros with the Leaf CatchLight,
101
because its pattern is 16x16, not 2x8.
103
Return values are either 0/1/2/3 = G/M/C/Y or 0/1/2/3 = R/G1/B/G2
105
PowerShot 600 PowerShot A50 PowerShot Pro70 Pro90 & G1
106
0xe1e4e1e4: 0x1b4e4b1e: 0x1e4b4e1b: 0xb4b4b4b4:
108
0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5
109
0 G M G M G M 0 C Y C Y C Y 0 Y C Y C Y C 0 G M G M G M
110
1 C Y C Y C Y 1 M G M G M G 1 M G M G M G 1 Y C Y C Y C
111
2 M G M G M G 2 Y C Y C Y C 2 C Y C Y C Y
112
3 C Y C Y C Y 3 G M G M G M 3 G M G M G M
113
4 C Y C Y C Y 4 Y C Y C Y C
114
PowerShot A5 5 G M G M G M 5 G M G M G M
115
0x1e4e1e4e: 6 Y C Y C Y C 6 C Y C Y C Y
116
7 M G M G M G 7 M G M G M G
123
All RGB cameras use one of these Bayer grids:
125
0x16161616: 0x61616161: 0x49494949: 0x94949494:
127
0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5
128
0 B G B G B G 0 G R G R G R 0 G B G B G B 0 R G R G R G
129
1 G R G R G R 1 B G B G B G 1 R G R G R G 1 G B G B G B
130
2 B G B G B G 2 G R G R G R 2 G B G B G B 2 R G R G R G
131
3 G R G R G R 3 B G B G B G 3 R G R G R G 3 G B G B G B
134
#define BAYER(row,col) \
135
image[((row) >> shrink)*iwidth + ((col) >> shrink)][FC(row,col)]
136
#define BAYER2(row,col) \
137
image[((row) >> shrink)*iwidth + ((col) >> shrink)][fc(row,col)]