~ubuntu-branches/ubuntu/saucy/darktable/saucy

« back to all changes in this revision

Viewing changes to src/external/LibRaw/internal/defines.h

  • Committer: Bazaar Package Importer
  • Author(s): David Bremner
  • Date: 2011-08-02 21:32:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110802213231-r9v63trgyk1e822j
Tags: 0.9.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
  Copyright 2008-2010 LibRaw LLC (info@libraw.org)
 
3
 
 
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:
 
6
 
 
7
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
 
8
   (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
 
9
 
 
10
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
 
11
   (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
 
12
 
 
13
3. LibRaw Software License 27032010
 
14
   (See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
 
15
 
 
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
 
19
 
 
20
   Look into dcraw homepage (probably http://cybercom.net/~dcoffin/dcraw/)
 
21
   for more information
 
22
*/
 
23
 
 
24
#define NO_JPEG
 
25
#define VERSION "9.05"
 
26
 
 
27
#ifndef _GNU_SOURCE
 
28
#define _GNU_SOURCE
 
29
#endif
 
30
#define _USE_MATH_DEFINES
 
31
#include <ctype.h>
 
32
#include <errno.h>
 
33
#include <fcntl.h>
 
34
#include <float.h>
 
35
#include <limits.h>
 
36
#include <math.h>
 
37
#include <setjmp.h>
 
38
#include <stdio.h>
 
39
#include <stdlib.h>
 
40
#include <string.h>
 
41
#include <time.h>
 
42
#include <sys/types.h>
 
43
 
 
44
/*
 
45
   NO_JPEG disables decoding of compressed Kodak DC120 files.
 
46
   NO_LCMS disables the "-p" option.
 
47
 */
 
48
#ifndef NO_JPEG
 
49
#include <jpeglib.h>
 
50
#endif
 
51
#ifdef LOCALEDIR
 
52
#include <libintl.h>
 
53
#define _(String) gettext(String)
 
54
#else
 
55
#define _(String) (String)
 
56
#endif
 
57
#ifdef __CYGWIN__
 
58
#include <io.h>
 
59
#endif
 
60
#ifdef WIN32
 
61
#include <sys/utime.h>
 
62
#include <winsock2.h>
 
63
#pragma comment(lib, "ws2_32.lib")
 
64
#define snprintf _snprintf
 
65
#define strcasecmp _stricmp
 
66
#define strncasecmp strnicmp
 
67
#else
 
68
#include <unistd.h>
 
69
#include <utime.h>
 
70
#include <netinet/in.h>
 
71
#endif
 
72
 
 
73
#ifdef LJPEG_DECODE
 
74
#error Please compile dcraw.c by itself.
 
75
#error Do not link it with ljpeg_decode.
 
76
#endif
 
77
 
 
78
#ifndef LONG_BIT
 
79
#define LONG_BIT (8 * sizeof (long))
 
80
#endif
 
81
#define FORC(cnt) for (c=0; c < cnt; c++)
 
82
#define FORC3 FORC(3)
 
83
#define FORC4 FORC(4)
 
84
#define FORCC FORC(colors)
 
85
 
 
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; }
 
94
 
 
95
/*
 
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
 
99
 
 
100
   Do not use the FC or BAYER macros with the Leaf CatchLight,
 
101
   because its pattern is 16x16, not 2x8.
 
102
 
 
103
   Return values are either 0/1/2/3 = G/M/C/Y or 0/1/2/3 = R/G1/B/G2
 
104
 
 
105
        PowerShot 600   PowerShot A50   PowerShot Pro70 Pro90 & G1
 
106
        0xe1e4e1e4:     0x1b4e4b1e:     0x1e4b4e1b:     0xb4b4b4b4:
 
107
 
 
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
 
117
          0 1 2 3 4 5
 
118
        0 C Y C Y C Y
 
119
        1 G M G M G M
 
120
        2 C Y C Y C Y
 
121
        3 M G M G M G
 
122
 
 
123
   All RGB cameras use one of these Bayer grids:
 
124
 
 
125
        0x16161616:     0x61616161:     0x49494949:     0x94949494:
 
126
 
 
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
 
132
 */
 
133
 
 
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)]