Added missing libraw files

git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/libraries/libkdcraw@1076753 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 15 years ago
parent 080528894f
commit 3f38a0b873

@ -0,0 +1,14 @@
# LibRaw definitions
KDE_CXXFLAGS = $(USE_EXCEPTIONS) -DDCRAW_VERBOSE -DUSE_LCMS
INCLUDES = $(all_includes)
# Requires by dcraw implementation from libraw.
KDE_OPTIONS = nofinal
noinst_LTLIBRARIES = libraw.la
libraw_la_CXXFLAGS = -w
libraw_la_SOURCES = src/libraw_cxx.cpp src/libraw_c_api.cpp internal/dcraw_common.cpp internal/dcraw_fileio.cpp internal/foveon.cpp
libraw_la_LDFLAGS = $(LIBJPEG) $(LCMS_LIBS)

File diff suppressed because it is too large Load Diff

@ -0,0 +1,211 @@
/*
GENERATED FILE, DO NOT EDIT
Generated from dcraw/dcraw.c at Tue Apr 7 15:14:50 2009
Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
for copyright information.
*/
#define CLASS LibRaw::
#include "libraw/libraw_types.h"
#define LIBRAW_LIBRARY_BUILD
#include "libraw/libraw.h"
#include "internal/defines.h"
#include "internal/var_defines.h"
/*
Seach from the current directory up to the root looking for
a ".badpixels" file, and fix those pixels now.
*/
void CLASS bad_pixels (char *fname)
{
FILE *fp=0;
char *cp, line[128];
int len, time, row, col, r, c, rad, tot, n, fixed=0;
if (!filters) return;
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_BAD_PIXELS,0,2);
#endif
if (fname)
fp = fopen (fname, "r");
if (!fp)
{
#ifdef LIBRAW_LIBRARY_BUILD
imgdata.process_warnings |= LIBRAW_WARN_NO_BADPIXELMAP;
#endif
return;
}
while (fgets (line, 128, fp)) {
cp = strchr (line, '#');
if (cp) *cp = 0;
if (sscanf (line, "%d %d %d", &col, &row, &time) != 3) continue;
if ((unsigned) col >= width || (unsigned) row >= height) continue;
if (time > timestamp) continue;
for (tot=n=0, rad=1; rad < 3 && n==0; rad++)
for (r = row-rad; r <= row+rad; r++)
for (c = col-rad; c <= col+rad; c++)
if ((unsigned) r < height && (unsigned) c < width &&
(r != row || c != col) && fc(r,c) == fc(row,col)) {
tot += BAYER2(r,c);
n++;
}
BAYER2(row,col) = tot/n;
#ifdef DCRAW_VERBOSE
if (verbose) {
if (!fixed++)
fprintf (stderr,_("Fixed dead pixels at:"));
fprintf (stderr, " %d,%d", col, row);
}
#endif
}
#ifdef DCRAW_VERBOSE
if (fixed) fputc ('\n', stderr);
#endif
fclose (fp);
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_BAD_PIXELS,1,2);
#endif
}
void CLASS subtract (char *fname)
{
FILE *fp;
int dim[3]={0,0,0}, comment=0, number=0, error=0, nd=0, c, row, col;
ushort *pixel;
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_DARK_FRAME,0,2);
#endif
if (!(fp = fopen (fname, "rb"))) {
#ifdef DCRAW_VERBOSE
perror (fname);
#endif
#ifdef LIBRAW_LIBRARY_BUILD
imgdata.process_warnings |= LIBRAW_WARN_BAD_DARKFRAME_FILE;
#endif
return;
}
if (fgetc(fp) != 'P' || fgetc(fp) != '5') error = 1;
while (!error && nd < 3 && (c = fgetc(fp)) != EOF) {
if (c == '#') comment = 1;
if (c == '\n') comment = 0;
if (comment) continue;
if (isdigit(c)) number = 1;
if (number) {
if (isdigit(c)) dim[nd] = dim[nd]*10 + c -'0';
else if (isspace(c)) {
number = 0; nd++;
} else error = 1;
}
}
if (error || nd < 3) {
fprintf (stderr,_("%s is not a valid PGM file!\n"), fname);
fclose (fp); return;
} else if (dim[0] != width || dim[1] != height || dim[2] != 65535) {
#ifdef DCRAW_VERBOSE
fprintf (stderr,_("%s has the wrong dimensions!\n"), fname);
#endif
#ifdef LIBRAW_LIBRARY_BUILD
imgdata.process_warnings |= LIBRAW_WARN_BAD_DARKFRAME_DIM;
#endif
fclose (fp); return;
}
pixel = (ushort *) calloc (width, sizeof *pixel);
merror (pixel, "subtract()");
for (row=0; row < height; row++) {
fread (pixel, 2, width, fp);
for (col=0; col < width; col++)
BAYER(row,col) = MAX (BAYER(row,col) - ntohs(pixel[col]), 0);
}
free (pixel);
black = 0;
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_DARK_FRAME,1,2);
#endif
}
#ifndef NO_LCMS
void CLASS apply_profile (char *input, char *output)
{
char *prof;
cmsHPROFILE hInProfile=0, hOutProfile=0;
cmsHTRANSFORM hTransform;
FILE *fp;
unsigned size;
cmsErrorAction (LCMS_ERROR_SHOW);
if (strcmp (input, "embed"))
hInProfile = cmsOpenProfileFromFile (input, "r");
else if (profile_length) {
#ifndef LIBRAW_LIBRARY_BUILD
prof = (char *) malloc (profile_length);
merror (prof, "apply_profile()");
fseek (ifp, profile_offset, SEEK_SET);
fread (prof, 1, profile_length, ifp);
hInProfile = cmsOpenProfileFromMem (prof, profile_length);
free (prof);
#else
hInProfile = cmsOpenProfileFromMem (imgdata.color.profile, profile_length);
#endif
} else
{
#ifdef LIBRAW_LIBRARY_BUILD
imgdata.process_warnings |= LIBRAW_WARN_NO_EMBEDDED_PROFILE;
#endif
#ifdef DCRAW_VERBOSE
fprintf (stderr,_("%s has no embedded profile.\n"), ifname);
#endif
}
if (!hInProfile)
{
#ifdef LIBRAW_LIBRARY_BUILD
imgdata.process_warnings |= LIBRAW_WARN_NO_INPUT_PROFILE;
#endif
return;
}
if (!output)
hOutProfile = cmsCreate_sRGBProfile();
else if ((fp = fopen (output, "rb"))) {
fread (&size, 4, 1, fp);
fseek (fp, 0, SEEK_SET);
oprof = (unsigned *) malloc (size = ntohl(size));
merror (oprof, "apply_profile()");
fread (oprof, 1, size, fp);
fclose (fp);
if (!(hOutProfile = cmsOpenProfileFromMem (oprof, size))) {
free (oprof);
oprof = 0;
}
#ifdef DCRAW_VERBOSE
} else
fprintf (stderr,_("Cannot open file %s!\n"), output);
#else
}
#endif
if (!hOutProfile)
{
#ifdef LIBRAW_LIBRARY_BUILD
imgdata.process_warnings |= LIBRAW_WARN_BAD_OUTPUT_PROFILE;
#endif
goto quit;
}
#ifdef DCRAW_VERBOSE
if (verbose)
fprintf (stderr,_("Applying color profile...\n"));
#endif
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_APPLY_PROFILE,0,2);
#endif
hTransform = cmsCreateTransform (hInProfile, TYPE_RGBA_16,
hOutProfile, TYPE_RGBA_16, INTENT_PERCEPTUAL, 0);
cmsDoTransform (hTransform, image, image, width*height);
raw_color = 1; /* Don't use rgb_cam with a profile */
cmsDeleteTransform (hTransform);
cmsCloseProfile (hOutProfile);
quit:
cmsCloseProfile (hInProfile);
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_APPLY_PROFILE,1,2);
#endif
}
#endif

@ -0,0 +1,129 @@
/*
GENERATED FILE, DO NOT EDIT
Generated from dcraw/dcraw.c at Tue Apr 7 15:14:48 2009
Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
for copyright information.
*/
#define NO_JPEG
#define VERSION "8.93"
#define _GNU_SOURCE
#define _USE_MATH_DEFINES
#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 <sys/types.h>
#ifdef _OPENMP
#include <omp.h>
#endif
/*
NO_JPEG disables decoding of compressed Kodak DC120 files.
NO_LCMS disables the "-p" option.
*/
#ifndef NO_JPEG
#include <jpeglib.h>
#endif
#ifndef NO_LCMS
#include <lcms.h>
#endif
#ifdef LOCALEDIR
#include <libintl.h>
#define _(String) gettext(String)
#else
#define _(String) (String)
#endif
#ifdef __CYGWIN__
#include <io.h>
#endif
#ifdef WIN32
#include <sys/utime.h>
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#define snprintf _snprintf
#define strcasecmp _stricmp
#define strncasecmp strnicmp
typedef __int64 INT64;
typedef unsigned __int64 UINT64;
#else
#include <unistd.h>
#include <utime.h>
#include <netinet/in.h>
typedef long long INT64;
typedef unsigned long long UINT64;
#endif
#ifdef LJPEG_DECODE
#error Please compile dcraw.c by itself.
#error Do not link it with ljpeg_decode.
#endif
#ifndef LONG_BIT
#define LONG_BIT (8 * sizeof (long))
#endif
#define FORC(cnt) for (c=0; c < cnt; c++)
#define FORC3 FORC(3)
#define FORC4 FORC(4)
#define FORCC FORC(colors)
#define SQR(x) ((x)*(x))
#define ABS(x) (((int)(x) ^ ((int)(x) >> 31)) - ((int)(x) >> 31))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define LIM(x,min,max) MAX(min,MIN(x,max))
#define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y))
#define CLIP(x) LIM(x,0,65535)
#define SWAP(a,b) { a ^= b; a ^= (b ^= a); }
/*
In order to inline this calculation, I make the risky
assumption that all filter patterns can be described
by a repeating pattern of eight rows and two columns
Do not use the FC or BAYER macros with the Leaf CatchLight,
because its pattern is 16x16, not 2x8.
Return values are either 0/1/2/3 = G/M/C/Y or 0/1/2/3 = R/G1/B/G2
PowerShot 600 PowerShot A50 PowerShot Pro70 Pro90 & G1
0xe1e4e1e4: 0x1b4e4b1e: 0x1e4b4e1b: 0xb4b4b4b4:
0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5
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
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
2 M G M G M G 2 Y C Y C Y C 2 C Y C Y C Y
3 C Y C Y C Y 3 G M G M G M 3 G M G M G M
4 C Y C Y C Y 4 Y C Y C Y C
PowerShot A5 5 G M G M G M 5 G M G M G M
0x1e4e1e4e: 6 Y C Y C Y C 6 C Y C Y C Y
7 M G M G M G 7 M G M G M G
0 1 2 3 4 5
0 C Y C Y C Y
1 G M G M G M
2 C Y C Y C Y
3 M G M G M G
All RGB cameras use one of these Bayer grids:
0x16161616: 0x61616161: 0x49494949: 0x94949494:
0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5 0 1 2 3 4 5
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
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
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
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
*/
#define BAYER(row,col) \
image[((row) >> shrink)*iwidth + ((col) >> shrink)][FC(row,col)]
#define BAYER2(row,col) \
image[((row) >> shrink)*iwidth + ((col) >> shrink)][fc(row,col)]

@ -0,0 +1,812 @@
/*
GENERATED FILE, DO NOT EDIT
Generated from dcraw/dcraw.c at Tue Apr 7 15:14:48 2009
Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
for copyright information.
*/
#define CLASS LibRaw::
#include "libraw/libraw_types.h"
#define LIBRAW_IO_REDEFINED
#define LIBRAW_LIBRARY_BUILD
#include "libraw/libraw.h"
#include "internal/defines.h"
#define SRC_USES_SHRINK
#define SRC_USES_BLACK
#define SRC_USES_CURVE
#include "internal/var_defines.h"
#define sget4(s) sget4((uchar *)s)
/* RESTRICTED code starts here */
void CLASS foveon_decoder (unsigned size, unsigned code)
{
#ifndef LIBRAW_NOTHREADS
#define huff tls->foveon_decoder_huff
#else
static unsigned huff[1024];
#endif
struct decode *cur;
int i, len;
if (!code) {
for (i=0; i < size; i++)
huff[i] = get4();
init_decoder();
}
cur = free_decode++;
if (free_decode > first_decode+2048) {
#ifdef LIBRAW_LIBRARY_BUILD
throw LIBRAW_EXCEPTION_DECODE_RAW;
#else
fprintf (stderr,_("%s: decoder table overflow\n"), ifname);
longjmp (failure, 2);
#endif
}
if (code)
for (i=0; i < size; i++)
if (huff[i] == code) {
cur->leaf = i;
return;
}
if ((len = code >> 27) > 26) return;
code = (len+1) << 27 | (code & 0x3ffffff) << 1;
cur->branch[0] = free_decode;
foveon_decoder (size, code);
cur->branch[1] = free_decode;
foveon_decoder (size, code+1);
#ifndef LIBRAW_NOTHREADS
#undef huff
#endif
}
void CLASS foveon_thumb (FILE *tfp)
{
unsigned bwide, row, col, bitbuf=0, bit=1, c, i;
char *buf;
struct decode *dindex;
short pred[3];
bwide = get4();
fprintf (tfp, "P6\n%d %d\n255\n", thumb_width, thumb_height);
if (bwide > 0) {
if (bwide < thumb_width*3) return;
buf = (char *) malloc (bwide);
merror (buf, "foveon_thumb()");
for (row=0; row < thumb_height; row++) {
fread (buf, 1, bwide, ifp);
fwrite (buf, 3, thumb_width, tfp);
}
free (buf);
return;
}
foveon_decoder (256, 0);
for (row=0; row < thumb_height; row++) {
memset (pred, 0, sizeof pred);
if (!bit) get4();
for (bit=col=0; col < thumb_width; col++)
FORC3 {
for (dindex=first_decode; dindex->branch[0]; ) {
if ((bit = (bit-1) & 31) == 31)
for (i=0; i < 4; i++)
bitbuf = (bitbuf << 8) + fgetc(ifp);
dindex = dindex->branch[bitbuf >> bit & 1];
}
pred[c] += dindex->leaf;
fputc (pred[c], tfp);
}
}
}
void CLASS foveon_load_camf()
{
unsigned key, i, val;
fseek (ifp, meta_offset, SEEK_SET);
key = get4();
fread (meta_data, 1, meta_length, ifp);
for (i=0; i < meta_length; i++) {
key = (key * 1597 + 51749) % 244944;
val = key * (INT64) 301593171 >> 24;
meta_data[i] ^= ((((key << 8) - val) >> 1) + val) >> 17;
}
}
void CLASS foveon_load_raw()
{
struct decode *dindex;
short diff[1024];
unsigned bitbuf=0;
int pred[3], fixed, row, col, bit=-1, c, i;
fixed = get4();
read_shorts ((ushort *) diff, 1024);
if (!fixed) foveon_decoder (1024, 0);
for (row=0; row < height; row++) {
memset (pred, 0, sizeof pred);
if (!bit && !fixed && atoi(model+2) < 14) get4();
for (col=bit=0; col < width; col++) {
if (fixed) {
bitbuf = get4();
FORC3 pred[2-c] += diff[bitbuf >> c*10 & 0x3ff];
}
else FORC3 {
for (dindex=first_decode; dindex->branch[0]; ) {
if ((bit = (bit-1) & 31) == 31)
for (i=0; i < 4; i++)
bitbuf = (bitbuf << 8) + fgetc(ifp);
dindex = dindex->branch[bitbuf >> bit & 1];
}
pred[c] += diff[dindex->leaf];
if (pred[c] >> 16 && ~pred[c] >> 16) derror();
}
FORC3 image[row*width+col][c] = pred[c];
}
}
if (document_mode)
for (i=0; i < height*width*4; i++)
if ((short) image[0][i] < 0) image[0][i] = 0;
foveon_load_camf();
}
const char * CLASS foveon_camf_param (const char *block, const char *param)
{
unsigned idx, num;
char *pos, *cp, *dp;
for (idx=0; idx < meta_length; idx += sget4(pos+8)) {
pos = meta_data + idx;
if (strncmp (pos, "CMb", 3)) break;
if (pos[3] != 'P') continue;
if (strcmp (block, pos+sget4(pos+12))) continue;
cp = pos + sget4(pos+16);
num = sget4(cp);
dp = pos + sget4(cp+4);
while (num--) {
cp += 8;
if (!strcmp (param, dp+sget4(cp)))
return dp+sget4(cp+4);
}
}
return 0;
}
void * CLASS foveon_camf_matrix (unsigned dim[3], const char *name)
{
unsigned i, idx, type, ndim, size, *mat;
char *pos, *cp, *dp;
double dsize;
for (idx=0; idx < meta_length; idx += sget4(pos+8)) {
pos = meta_data + idx;
if (strncmp (pos, "CMb", 3)) break;
if (pos[3] != 'M') continue;
if (strcmp (name, pos+sget4(pos+12))) continue;
dim[0] = dim[1] = dim[2] = 1;
cp = pos + sget4(pos+16);
type = sget4(cp);
if ((ndim = sget4(cp+4)) > 3) break;
dp = pos + sget4(cp+8);
for (i=ndim; i--; ) {
cp += 12;
dim[i] = sget4(cp);
}
if ((dsize = (double) dim[0]*dim[1]*dim[2]) > meta_length/4) break;
mat = (unsigned *) malloc ((size = dsize) * 4);
merror (mat, "foveon_camf_matrix()");
for (i=0; i < size; i++)
if (type && type != 6)
mat[i] = sget4(dp + i*4);
else
mat[i] = sget4(dp + i*2) & 0xffff;
return mat;
}
#ifdef LIBRAW_LIBRARY_BUILD
imgdata.process_warnings |= LIBRAW_WARN_FOVEON_NOMATRIX;
#endif
#ifdef DCRAW_VERBOSE
fprintf (stderr,_("%s: \"%s\" matrix not found!\n"), ifname, name);
#endif
return 0;
}
int CLASS foveon_fixed (void *ptr, int size, const char *name)
{
void *dp;
unsigned dim[3];
dp = foveon_camf_matrix (dim, name);
if (!dp) return 0;
memcpy (ptr, dp, size*4);
free (dp);
return 1;
}
float CLASS foveon_avg (short *pix, int range[2], float cfilt)
{
int i;
float val, min=FLT_MAX, max=-FLT_MAX, sum=0;
for (i=range[0]; i <= range[1]; i++) {
sum += val = pix[i*4] + (pix[i*4]-pix[(i-1)*4]) * cfilt;
if (min > val) min = val;
if (max < val) max = val;
}
if (range[1] - range[0] == 1) return sum/2;
return (sum - min - max) / (range[1] - range[0] - 1);
}
short * CLASS foveon_make_curve (double max, double mul, double filt)
{
short *curve;
unsigned i, size;
double x;
if (!filt) filt = 0.8;
size = 4*M_PI*max / filt;
if (size == UINT_MAX) size--;
curve = (short *) calloc (size+1, sizeof *curve);
merror (curve, "foveon_make_curve()");
curve[0] = size;
for (i=0; i < size; i++) {
x = i*filt/max/4;
curve[i+1] = (cos(x)+1)/2 * tanh(i*filt/mul) * mul + 0.5;
}
return curve;
}
void CLASS foveon_make_curves
(short **curvep, float dq[3], float div[3], float filt)
{
double mul[3], max=0;
int c;
FORC3 mul[c] = dq[c]/div[c];
FORC3 if (max < mul[c]) max = mul[c];
FORC3 curvep[c] = foveon_make_curve (max, mul[c], filt);
}
int CLASS foveon_apply_curve (short *curve, int i)
{
if (abs(i) >= curve[0]) return 0;
return i < 0 ? -curve[1-i] : curve[1+i];
}
#ifdef image
#undef image
#endif
#define image ((short(*)[4]) imgdata.image)
void CLASS foveon_interpolate()
{
static const short hood[] = { -1,-1, -1,0, -1,1, 0,-1, 0,1, 1,-1, 1,0, 1,1 };
short *pix, prev[3], *curve[8], (*shrink)[3];
float cfilt=0, ddft[3][3][2], ppm[3][3][3];
float cam_xyz[3][3], correct[3][3], last[3][3], trans[3][3];
float chroma_dq[3], color_dq[3], diag[3][3], div[3];
float (*black)[3], (*sgain)[3], (*sgrow)[3];
float fsum[3], val, frow, num;
int row, col, c, i, j, diff, sgx, irow, sum, min, max, limit;
int dscr[2][2], dstb[4], (*smrow[7])[3], total[4], ipix[3];
int work[3][3], smlast, smred, smred_p=0, dev[3];
int satlev[3], keep[4], active[4];
unsigned dim[3], *badpix;
double dsum=0, trsum[3];
char str[128];
const char* cp;
#ifdef DCRAW_VERBOSE
if (verbose)
fprintf(stderr,_("Foveon interpolation...\n"));
#endif
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,0,9);
#endif
foveon_fixed (dscr, 4, "DarkShieldColRange");
foveon_fixed (ppm[0][0], 27, "PostPolyMatrix");
foveon_fixed (satlev, 3, "SaturationLevel");
foveon_fixed (keep, 4, "KeepImageArea");
foveon_fixed (active, 4, "ActiveImageArea");
foveon_fixed (chroma_dq, 3, "ChromaDQ");
foveon_fixed (color_dq, 3,
foveon_camf_param ("IncludeBlocks", "ColorDQ") ?
"ColorDQ" : "ColorDQCamRGB");
if (foveon_camf_param ("IncludeBlocks", "ColumnFilter"))
foveon_fixed (&cfilt, 1, "ColumnFilter");
memset (ddft, 0, sizeof ddft);
if (!foveon_camf_param ("IncludeBlocks", "DarkDrift")
|| !foveon_fixed (ddft[1][0], 12, "DarkDrift"))
for (i=0; i < 2; i++) {
foveon_fixed (dstb, 4, i ? "DarkShieldBottom":"DarkShieldTop");
for (row = dstb[1]; row <= dstb[3]; row++)
for (col = dstb[0]; col <= dstb[2]; col++)
FORC3 ddft[i+1][c][1] += (short) image[row*width+col][c];
FORC3 ddft[i+1][c][1] /= (dstb[3]-dstb[1]+1) * (dstb[2]-dstb[0]+1);
}
if (!(cp = foveon_camf_param ("WhiteBalanceIlluminants", model2)))
{
#ifdef DCRAW_VERBOSE
fprintf (stderr,_("%s: Invalid white balance \"%s\"\n"), ifname, model2);
#endif
#ifdef LIBRAW_LIBRARY_BUILD
imgdata.process_warnings |= LIBRAW_WARN_FOVEON_INVALIDWB;
#endif
return;
}
foveon_fixed (cam_xyz, 9, cp);
foveon_fixed (correct, 9,
foveon_camf_param ("WhiteBalanceCorrections", model2));
memset (last, 0, sizeof last);
for (i=0; i < 3; i++)
for (j=0; j < 3; j++)
FORC3 last[i][j] += correct[i][c] * cam_xyz[c][j];
#define LAST(x,y) last[(i+x)%3][(c+y)%3]
for (i=0; i < 3; i++)
FORC3 diag[c][i] = LAST(1,1)*LAST(2,2) - LAST(1,2)*LAST(2,1);
#undef LAST
FORC3 div[c] = diag[c][0]*0.3127 + diag[c][1]*0.329 + diag[c][2]*0.3583;
sprintf (str, "%sRGBNeutral", model2);
if (foveon_camf_param ("IncludeBlocks", str))
foveon_fixed (div, 3, str);
num = 0;
FORC3 if (num < div[c]) num = div[c];
FORC3 div[c] /= num;
memset (trans, 0, sizeof trans);
for (i=0; i < 3; i++)
for (j=0; j < 3; j++)
FORC3 trans[i][j] += rgb_cam[i][c] * last[c][j] * div[j];
FORC3 trsum[c] = trans[c][0] + trans[c][1] + trans[c][2];
dsum = (6*trsum[0] + 11*trsum[1] + 3*trsum[2]) / 20;
for (i=0; i < 3; i++)
FORC3 last[i][c] = trans[i][c] * dsum / trsum[i];
memset (trans, 0, sizeof trans);
for (i=0; i < 3; i++)
for (j=0; j < 3; j++)
FORC3 trans[i][j] += (i==c ? 32 : -1) * last[c][j] / 30;
foveon_make_curves (curve, color_dq, div, cfilt);
FORC3 chroma_dq[c] /= 3;
foveon_make_curves (curve+3, chroma_dq, div, cfilt);
FORC3 dsum += chroma_dq[c] / div[c];
curve[6] = foveon_make_curve (dsum, dsum, cfilt);
curve[7] = foveon_make_curve (dsum*2, dsum*2, cfilt);
sgain = (float (*)[3]) foveon_camf_matrix (dim, "SpatialGain");
if (!sgain) return;
sgrow = (float (*)[3]) calloc (dim[1], sizeof *sgrow);
sgx = (width + dim[1]-2) / (dim[1]-1);
black = (float (*)[3]) calloc (height, sizeof *black);
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,1,9);
#endif
for (row=0; row < height; row++) {
for (i=0; i < 6; i++)
ddft[0][0][i] = ddft[1][0][i] +
row / (height-1.0) * (ddft[2][0][i] - ddft[1][0][i]);
FORC3 black[row][c] =
( foveon_avg (image[row*width]+c, dscr[0], cfilt) +
foveon_avg (image[row*width]+c, dscr[1], cfilt) * 3
- ddft[0][c][0] ) / 4 - ddft[0][c][1];
}
memcpy (black, black+8, sizeof *black*8);
memcpy (black+height-11, black+height-22, 11*sizeof *black);
memcpy (last, black, sizeof last);
for (row=1; row < height-1; row++) {
FORC3 if (last[1][c] > last[0][c]) {
if (last[1][c] > last[2][c])
black[row][c] = (last[0][c] > last[2][c]) ? last[0][c]:last[2][c];
} else
if (last[1][c] < last[2][c])
black[row][c] = (last[0][c] < last[2][c]) ? last[0][c]:last[2][c];
memmove (last, last+1, 2*sizeof last[0]);
memcpy (last[2], black[row+1], sizeof last[2]);
}
FORC3 black[row][c] = (last[0][c] + last[1][c])/2;
FORC3 black[0][c] = (black[1][c] + black[3][c])/2;
val = 1 - exp(-1/24.0);
memcpy (fsum, black, sizeof fsum);
for (row=1; row < height; row++)
FORC3 fsum[c] += black[row][c] =
(black[row][c] - black[row-1][c])*val + black[row-1][c];
memcpy (last[0], black[height-1], sizeof last[0]);
FORC3 fsum[c] /= height;
for (row = height; row--; )
FORC3 last[0][c] = black[row][c] =
(black[row][c] - fsum[c] - last[0][c])*val + last[0][c];
memset (total, 0, sizeof total);
for (row=2; row < height; row+=4)
for (col=2; col < width; col+=4) {
FORC3 total[c] += (short) image[row*width+col][c];
total[3]++;
}
for (row=0; row < height; row++)
FORC3 black[row][c] += fsum[c]/2 + total[c]/(total[3]*100.0);
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,2,9);
#endif
for (row=0; row < height; row++) {
for (i=0; i < 6; i++)
ddft[0][0][i] = ddft[1][0][i] +
row / (height-1.0) * (ddft[2][0][i] - ddft[1][0][i]);
pix = image[row*width];
memcpy (prev, pix, sizeof prev);
frow = row / (height-1.0) * (dim[2]-1);
if ((irow = frow) == dim[2]-1) irow--;
frow -= irow;
for (i=0; i < dim[1]; i++)
FORC3 sgrow[i][c] = sgain[ irow *dim[1]+i][c] * (1-frow) +
sgain[(irow+1)*dim[1]+i][c] * frow;
for (col=0; col < width; col++) {
FORC3 {
diff = pix[c] - prev[c];
prev[c] = pix[c];
ipix[c] = pix[c] + floor ((diff + (diff*diff >> 14)) * cfilt
- ddft[0][c][1] - ddft[0][c][0] * ((float) col/width - 0.5)
- black[row][c] );
}
FORC3 {
work[0][c] = ipix[c] * ipix[c] >> 14;
work[2][c] = ipix[c] * work[0][c] >> 14;
work[1][2-c] = ipix[(c+1) % 3] * ipix[(c+2) % 3] >> 14;
}
FORC3 {
for (val=i=0; i < 3; i++)
for ( j=0; j < 3; j++)
val += ppm[c][i][j] * work[i][j];
ipix[c] = floor ((ipix[c] + floor(val)) *
( sgrow[col/sgx ][c] * (sgx - col%sgx) +
sgrow[col/sgx+1][c] * (col%sgx) ) / sgx / div[c]);
if (ipix[c] > 32000) ipix[c] = 32000;
pix[c] = ipix[c];
}
pix += 4;
}
}
free (black);
free (sgrow);
free (sgain);
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,3,9);
#endif
if ((badpix = (unsigned int *) foveon_camf_matrix (dim, "BadPixels"))) {
for (i=0; i < dim[0]; i++) {
col = (badpix[i] >> 8 & 0xfff) - keep[0];
row = (badpix[i] >> 20 ) - keep[1];
if ((unsigned)(row-1) > height-3 || (unsigned)(col-1) > width-3)
continue;
memset (fsum, 0, sizeof fsum);
for (sum=j=0; j < 8; j++)
if (badpix[i] & (1 << j)) {
FORC3 fsum[c] += (short)
image[(row+hood[j*2])*width+col+hood[j*2+1]][c];
sum++;
}
if (sum) FORC3 image[row*width+col][c] = fsum[c]/sum;
}
free (badpix);
}
/* Array for 5x5 Gaussian averaging of red values */
smrow[6] = (int (*)[3]) calloc (width*5, sizeof **smrow);
merror (smrow[6], "foveon_interpolate()");
for (i=0; i < 5; i++)
smrow[i] = smrow[6] + i*width;
/* Sharpen the reds against these Gaussian averages */
for (smlast=-1, row=2; row < height-2; row++) {
while (smlast < row+2) {
for (i=0; i < 6; i++)
smrow[(i+5) % 6] = smrow[i];
pix = image[++smlast*width+2];
for (col=2; col < width-2; col++) {
smrow[4][col][0] =
(pix[0]*6 + (pix[-4]+pix[4])*4 + pix[-8]+pix[8] + 8) >> 4;
pix += 4;
}
}
pix = image[row*width+2];
for (col=2; col < width-2; col++) {
smred = ( 6 * smrow[2][col][0]
+ 4 * (smrow[1][col][0] + smrow[3][col][0])
+ smrow[0][col][0] + smrow[4][col][0] + 8 ) >> 4;
if (col == 2)
smred_p = smred;
i = pix[0] + ((pix[0] - ((smred*7 + smred_p) >> 3)) >> 3);
if (i > 32000) i = 32000;
pix[0] = i;
smred_p = smred;
pix += 4;
}
}
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,4,9);
#endif
/* Adjust the brighter pixels for better linearity */
min = 0xffff;
FORC3 {
i = satlev[c] / div[c];
if (min > i) min = i;
}
limit = min * 9 >> 4;
for (pix=image[0]; pix < image[height*width]; pix+=4) {
if (pix[0] <= limit || pix[1] <= limit || pix[2] <= limit)
continue;
min = max = pix[0];
for (c=1; c < 3; c++) {
if (min > pix[c]) min = pix[c];
if (max < pix[c]) max = pix[c];
}
if (min >= limit*2) {
pix[0] = pix[1] = pix[2] = max;
} else {
i = 0x4000 - ((min - limit) << 14) / limit;
i = 0x4000 - (i*i >> 14);
i = i*i >> 14;
FORC3 pix[c] += (max - pix[c]) * i >> 14;
}
}
/*
Because photons that miss one detector often hit another,
the sum R+G+B is much less noisy than the individual colors.
So smooth the hues without smoothing the total.
*/
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,5,9);
#endif
for (smlast=-1, row=2; row < height-2; row++) {
while (smlast < row+2) {
for (i=0; i < 6; i++)
smrow[(i+5) % 6] = smrow[i];
pix = image[++smlast*width+2];
for (col=2; col < width-2; col++) {
FORC3 smrow[4][col][c] = (pix[c-4]+2*pix[c]+pix[c+4]+2) >> 2;
pix += 4;
}
}
pix = image[row*width+2];
for (col=2; col < width-2; col++) {
FORC3 dev[c] = -foveon_apply_curve (curve[7], pix[c] -
((smrow[1][col][c] + 2*smrow[2][col][c] + smrow[3][col][c]) >> 2));
sum = (dev[0] + dev[1] + dev[2]) >> 3;
FORC3 pix[c] += dev[c] - sum;
pix += 4;
}
}
for (smlast=-1, row=2; row < height-2; row++) {
while (smlast < row+2) {
for (i=0; i < 6; i++)
smrow[(i+5) % 6] = smrow[i];
pix = image[++smlast*width+2];
for (col=2; col < width-2; col++) {
FORC3 smrow[4][col][c] =
(pix[c-8]+pix[c-4]+pix[c]+pix[c+4]+pix[c+8]+2) >> 2;
pix += 4;
}
}
pix = image[row*width+2];
for (col=2; col < width-2; col++) {
for (total[3]=375, sum=60, c=0; c < 3; c++) {
for (total[c]=i=0; i < 5; i++)
total[c] += smrow[i][col][c];
total[3] += total[c];
sum += pix[c];
}
if (sum < 0) sum = 0;
j = total[3] > 375 ? (sum << 16) / total[3] : sum * 174;
FORC3 pix[c] += foveon_apply_curve (curve[6],
((j*total[c] + 0x8000) >> 16) - pix[c]);
pix += 4;
}
}
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,6,9);
#endif
/* Transform the image to a different colorspace */
for (pix=image[0]; pix < image[height*width]; pix+=4) {
FORC3 pix[c] -= foveon_apply_curve (curve[c], pix[c]);
sum = (pix[0]+pix[1]+pix[1]+pix[2]) >> 2;
FORC3 pix[c] -= foveon_apply_curve (curve[c], pix[c]-sum);
FORC3 {
for (dsum=i=0; i < 3; i++)
dsum += trans[c][i] * pix[i];
if (dsum < 0) dsum = 0;
if (dsum > 24000) dsum = 24000;
ipix[c] = dsum + 0.5;
}
FORC3 pix[c] = ipix[c];
}
/* Smooth the image bottom-to-top and save at 1/4 scale */
shrink = (short (*)[3]) calloc ((width/4) * (height/4), sizeof *shrink);
merror (shrink, "foveon_interpolate()");
for (row = height/4; row--; )
for (col=0; col < width/4; col++) {
ipix[0] = ipix[1] = ipix[2] = 0;
for (i=0; i < 4; i++)
for (j=0; j < 4; j++)
FORC3 ipix[c] += image[(row*4+i)*width+col*4+j][c];
FORC3
if (row+2 > height/4)
shrink[row*(width/4)+col][c] = ipix[c] >> 4;
else
shrink[row*(width/4)+col][c] =
(shrink[(row+1)*(width/4)+col][c]*1840 + ipix[c]*141 + 2048) >> 12;
}
/* From the 1/4-scale image, smooth right-to-left */
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,7,9);
#endif
for (row=0; row < (height & ~3); row++) {
ipix[0] = ipix[1] = ipix[2] = 0;
if ((row & 3) == 0)
for (col = width & ~3 ; col--; )
FORC3 smrow[0][col][c] = ipix[c] =
(shrink[(row/4)*(width/4)+col/4][c]*1485 + ipix[c]*6707 + 4096) >> 13;
/* Then smooth left-to-right */
ipix[0] = ipix[1] = ipix[2] = 0;
for (col=0; col < (width & ~3); col++)
FORC3 smrow[1][col][c] = ipix[c] =
(smrow[0][col][c]*1485 + ipix[c]*6707 + 4096) >> 13;
/* Smooth top-to-bottom */
if (row == 0)
memcpy (smrow[2], smrow[1], sizeof **smrow * width);
else
for (col=0; col < (width & ~3); col++)
FORC3 smrow[2][col][c] =
(smrow[2][col][c]*6707 + smrow[1][col][c]*1485 + 4096) >> 13;
/* Adjust the chroma toward the smooth values */
for (col=0; col < (width & ~3); col++) {
for (i=j=30, c=0; c < 3; c++) {
i += smrow[2][col][c];
j += image[row*width+col][c];
}
j = (j << 16) / i;
for (sum=c=0; c < 3; c++) {
ipix[c] = foveon_apply_curve (curve[c+3],
((smrow[2][col][c] * j + 0x8000) >> 16) - image[row*width+col][c]);
sum += ipix[c];
}
sum >>= 3;
FORC3 {
i = image[row*width+col][c] + ipix[c] - sum;
if (i < 0) i = 0;
image[row*width+col][c] = i;
}
}
}
free (shrink);
free (smrow[6]);
for (i=0; i < 8; i++)
free (curve[i]);
#ifdef LIBRAW_LIBRARY_BUILD
RUN_CALLBACK(LIBRAW_PROGRESS_FOVEON_INTERPOLATE,8,9);
#endif
/* Trim off the black border */
active[1] -= keep[1];
active[3] -= 2;
i = active[2] - active[0];
for (row=0; row < active[3]-active[1]; row++)
memcpy (image[row*i], image[(row+active[1])*width+active[0]],
i * sizeof *image);
width = i;
height = row;
}
#undef image
/* RESTRICTED code ends here */
char * CLASS foveon_gets (int offset, char *str, int len)
{
int i;
fseek (ifp, offset, SEEK_SET);
for (i=0; i < len-1; i++)
if ((str[i] = get2()) == 0) break;
str[i] = 0;
return str;
}
void CLASS parse_foveon()
{
int entries, img=0, off, len, tag, save, i, wide, high, pent, poff[256][2];
char name[64], value[64];
order = 0x4949; /* Little-endian */
fseek (ifp, 36, SEEK_SET);
flip = get4();
fseek (ifp, -4, SEEK_END);
fseek (ifp, get4(), SEEK_SET);
if (get4() != 0x64434553) return; /* SECd */
entries = (get4(),get4());
while (entries--) {
off = get4();
len = get4();
tag = get4();
save = ftell(ifp);
fseek (ifp, off, SEEK_SET);
if (get4() != (0x20434553 | (tag << 24))) return;
switch (tag) {
case 0x47414d49: /* IMAG */
case 0x32414d49: /* IMA2 */
fseek (ifp, 12, SEEK_CUR);
wide = get4();
high = get4();
if (wide > raw_width && high > raw_height) {
raw_width = wide;
raw_height = high;
data_offset = off+24;
}
fseek (ifp, off+28, SEEK_SET);
if (fgetc(ifp) == 0xff && fgetc(ifp) == 0xd8
&& thumb_length < len-28) {
thumb_offset = off+28;
thumb_length = len-28;
write_thumb = &CLASS jpeg_thumb;
}
if (++img == 2 && !thumb_length) {
thumb_offset = off+24;
thumb_width = wide;
thumb_height = high;
write_thumb = &CLASS foveon_thumb;
}
break;
case 0x464d4143: /* CAMF */
meta_offset = off+24;
meta_length = len-28;
if (meta_length > 0x20000)
meta_length = 0x20000;
break;
case 0x504f5250: /* PROP */
pent = (get4(),get4());
fseek (ifp, 12, SEEK_CUR);
off += pent*8 + 24;
if ((unsigned) pent > 256) pent=256;
for (i=0; i < pent*2; i++)
poff[0][i] = off + get4()*2;
for (i=0; i < pent; i++) {
foveon_gets (poff[i][0], name, 64);
foveon_gets (poff[i][1], value, 64);
if (!strcmp (name, "ISO"))
iso_speed = atoi(value);
if (!strcmp (name, "CAMMANUF"))
strcpy (make, value);
if (!strcmp (name, "CAMMODEL"))
strcpy (model, value);
if (!strcmp (name, "WB_DESC"))
strcpy (model2, value);
if (!strcmp (name, "TIME"))
timestamp = atoi(value);
if (!strcmp (name, "EXPTIME"))
shutter = atoi(value) / 1000000.0;
if (!strcmp (name, "APERTURE"))
aperture = atof(value);
if (!strcmp (name, "FLENGTH"))
focal_len = atof(value);
}
#ifdef LOCALTIME
timestamp = mktime (gmtime (&timestamp));
#endif
}
fseek (ifp, save, SEEK_SET);
}
is_foveon = 1;
}

@ -0,0 +1,201 @@
/* -*- C++ -*-
* File: libraw_internal_funcs.h
* Copyright 2008 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 14, 2008
*
* LibRaw internal data structures (not visible outside)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _LIBRAW_INTERNAL_FUNCS_H
#define _LIBRAW_INTERNAL_FUNCS_H
#ifndef LIBRAW_LIBRARY_BUILD
#error "This file should be used only for libraw library build"
#else
// inline functions
ushort sget2 (uchar *s);
ushort get2();
unsigned sget4 (uchar *s);
unsigned getint (int type);
float int_to_float (int i);
double getreal (int type);
void read_shorts (ushort *pixel, int count);
// Canon P&S cameras
void canon_600_fixed_wb (int temp);
int canon_600_color (int ratio[2], int mar);
void canon_600_auto_wb();
void canon_600_coeff();
void canon_600_load_raw();
int canon_s2is();
void canon_a5_load_raw();
void parse_ciff (int offset, int length);
void ciff_block_1030();
// LJPEG decoder
unsigned getbits (int nbits);
void init_decoder();
uchar * make_decoder (const uchar *source, int level);
int ljpeg_start (struct jhead *jh, int info_only);
int ljpeg_diff (struct decode *dindex);
ushort * ljpeg_row (int jrow, struct jhead *jh);
// Canon DSLRs
void crw_init_tables (unsigned table);
int canon_has_lowbits();
void canon_compressed_load_raw();
void lossless_jpeg_load_raw();
void canon_sraw_load_raw();
void canon_black(double *);
// Adobe DNG
void adobe_copy_pixel (int row, int col, ushort **rp);
void adobe_dng_load_raw_lj();
void adobe_dng_load_raw_nc();
// Pentax
void pentax_k10_load_raw();
void pentax_tree();
// Nikon (and Minolta Z2)
void nikon_compressed_load_raw();
void nikon_load_raw();
int nikon_is_compressed();
int nikon_e995();
int nikon_e2100();
void nikon_3700();
int minolta_z2();
void nikon_e900_load_raw();
void nikon_e2100_load_raw();
// Fuji
void fuji_load_raw();
void parse_fuji (int offset);
// Rollei
void rollei_load_raw();
void parse_rollei();
// MF backs
int bayer (unsigned row, unsigned col);
void phase_one_flat_field (int is_float, int nc);
void phase_one_correct();
void phase_one_load_raw();
unsigned ph1_bits (int nbits);
void phase_one_load_raw_c();
void hasselblad_load_raw();
void leaf_hdr_load_raw();
void sinar_4shot_load_raw();
void imacon_full_load_raw();
void packed_12_load_raw();
void unpacked_load_raw();
void parse_sinar_ia();
void parse_phase_one (int base);
// Misc P&S cameras
void nokia_load_raw();
unsigned pana_bits (int nbits);
void panasonic_load_raw();
void olympus_e300_load_raw();
void olympus_e410_load_raw();
void olympus_cseries_load_raw();
void minolta_rd175_load_raw();
void casio_qv5700_load_raw();
void quicktake_100_load_raw();
const int* make_decoder_int (const int *source, int level);
int radc_token (int tree);
void kodak_radc_load_raw();
void kodak_jpeg_load_raw();
void kodak_dc120_load_raw();
void eight_bit_load_raw();
void smal_decode_segment (unsigned seg[2][2], int holes);
void smal_v6_load_raw();
int median4 (int *p);
void fill_holes (int holes);
void smal_v9_load_raw();
void parse_riff();
void parse_cine();
void parse_smal (int offset, int fsize);
int parse_jpeg (int offset);
// Kodak
void kodak_262_load_raw();
int kodak_65000_decode (short *out, int bsize);
void kodak_65000_load_raw();
void kodak_rgb_load_raw();
void kodak_yrgb_load_raw();
// It's a Sony (and K&M)
void sony_decrypt (unsigned *data, int len, int start, int key);
void sony_load_raw();
void sony_arw_load_raw();
void sony_arw2_load_raw();
void parse_minolta (int base);
#ifndef NO_FOVEON
// Foveon/Sigma
void foveon_load_camf();
void foveon_load_raw();
const char* foveon_camf_param (const char *block, const char *param);
void * foveon_camf_matrix (unsigned dim[3], const char *name);
int foveon_fixed (void *ptr, int size, const char *name);
float foveon_avg (short *pix, int range[2], float cfilt);
short * foveon_make_curve (double max, double mul, double filt);
void foveon_make_curves(short **curvep, float dq[3], float div[3], float filt);
int foveon_apply_curve (short *curve, int i);
void foveon_interpolate();
char * foveon_gets (int offset, char *str, int len);
void parse_foveon();
#endif
// CAM/RGB
void pseudoinverse (double (*in)[3], double (*out)[3], int size);
void cam_xyz_coeff (double cam_xyz[4][3]);
void adobe_coeff (const char *, const char *);
void simple_coeff (int index);
// Tiff/Exif parsers
void tiff_get (unsigned base,unsigned *tag, unsigned *type, unsigned *len, unsigned *save);
void parse_thumb_note (int base, unsigned toff, unsigned tlen);
void parse_makernote (int base, int uptag);
void parse_exif (int base);
void linear_table (unsigned len);
void parse_kodak_ifd (int base);
int parse_tiff_ifd (int base);
void parse_tiff (int base);
void parse_gps (int base);
void romm_coeff (float romm_cam[3][3]);
void parse_mos (int offset);
void get_timestamp (int reversed);
// External JPEGs, what cameras uses it ?
void parse_external_jpeg();
// The identify
short guess_byte_order (int words);
// Tiff writer
void tiff_set (ushort *ntag, ushort tag, ushort type, int count, int val);
void tiff_head (struct tiff_hdr *th, int full);
#endif
#endif

@ -0,0 +1,181 @@
/* -*- C++ -*-
* File: var_defines.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8, 2008
*
* LibRaw redefinitions of dcraw internal variables
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef VAR_DEFINES_H
#define VAR_DEFINES_H
// imgdata.idata
#define make (imgdata.idata.make)
#define model (imgdata.idata.model)
#define is_raw (imgdata.idata.raw_count)
#define dng_version (imgdata.idata.dng_version)
#define is_foveon (imgdata.idata.is_foveon)
#define colors (imgdata.idata.colors)
#define cdesc (imgdata.idata.cdesc)
#define filters (imgdata.idata.filters)
//imgdata image
#define image (imgdata.image)
// imgdata.sizes
#define raw_height (imgdata.sizes.raw_height)
#define raw_width (imgdata.sizes.raw_width)
#define height (imgdata.sizes.height)
#define width (imgdata.sizes.width)
#define top_margin (imgdata.sizes.top_margin)
#define left_margin (imgdata.sizes.left_margin)
#define bottom_margin (imgdata.sizes.bottom_margin)
#define right_margin (imgdata.sizes.right_margin)
#define iheight (imgdata.sizes.iheight)
#define iwidth (imgdata.sizes.iwidth)
#define pixel_aspect (imgdata.sizes.pixel_aspect)
#define flip (imgdata.sizes.flip)
//imgdata.color
#define white (imgdata.color.white)
#define cam_mul (imgdata.color.cam_mul)
#define pre_mul (imgdata.color.pre_mul)
#define cmatrix (imgdata.color.cmatrix)
#define rgb_cam (imgdata.color.rgb_cam)
#ifndef SRC_USES_CURVE
#define curve (imgdata.color.curve)
#endif
#ifndef SRC_USES_BLACK
#define black (imgdata.color.black)
#endif
#define maximum (imgdata.color.maximum)
#define profile_length (imgdata.color.profile_length)
#define color_flags (imgdata.color.color_flags)
#define ph1 (imgdata.color.phase_one_data)
#define flash_used (imgdata.color.flash_used)
#define canon_ev (imgdata.color.canon_ev)
#define model2 (imgdata.color.model2)
//imgdata.thumbnail
#define thumb_width (imgdata.thumbnail.twidth)
#define thumb_height (imgdata.thumbnail.theight)
#define thumb_length (imgdata.thumbnail.tlength)
//imgdata.others
#define iso_speed (imgdata.other.iso_speed)
#define shutter (imgdata.other.shutter)
#define aperture (imgdata.other.aperture)
#define focal_len (imgdata.other.focal_len)
#define timestamp (imgdata.other.timestamp)
#define shot_order (imgdata.other.shot_order)
#define gpsdata (imgdata.other.gpsdata)
#define desc (imgdata.other.desc)
#define artist (imgdata.other.artist)
//imgdata.output
#define greybox (imgdata.params.greybox)
#define aber (imgdata.params.aber)
#define gamm (imgdata.params.gamm)
#define user_mul (imgdata.params.user_mul)
#define shot_select (imgdata.params.shot_select)
#define bright (imgdata.params.bright)
#define threshold (imgdata.params.threshold)
#define half_size (imgdata.params.half_size)
#define four_color_rgb (imgdata.params.four_color_rgb)
#define document_mode (imgdata.params.document_mode)
#define highlight (imgdata.params.highlight)
//#define verbose (imgdata.params.verbose)
#define use_auto_wb (imgdata.params.use_auto_wb)
#define use_camera_wb (imgdata.params.use_camera_wb)
#define use_camera_matrix (imgdata.params.use_camera_matrix)
#define output_color (imgdata.params.output_color)
#define output_bps (imgdata.params.output_bps)
#define gamma_16bit (imgdata.params.gamma_16bit)
#define output_tiff (imgdata.params.output_tiff)
#define med_passes (imgdata.params.med_passes)
#define no_auto_bright (imgdata.params.no_auto_bright)
#define use_fuji_rotate (imgdata.params.use_fuji_rotate)
#define filtering_mode (imgdata.params.filtering_mode)
//rgb_constants
#define xyz_rgb (rgb_constants.xyz_rgb)
#define d65_white (rgb_constants.d65_white)
//libraw_internal_data.internal_data
#define meta_data (libraw_internal_data.internal_data.meta_data)
#define ifp libraw_internal_data.internal_data.input
#define ifname ((char*)libraw_internal_data.internal_data.input->fname())
#define profile_offset (libraw_internal_data.internal_data.profile_offset)
#define thumb_offset (libraw_internal_data.internal_data.toffset)
//libraw_internal_data.internal_output_params
#define mix_green (libraw_internal_data.internal_output_params.mix_green)
#define raw_color (libraw_internal_data.internal_output_params.raw_color)
#define use_gamma (libraw_internal_data.internal_output_params.use_gamma)
#define zero_is_bad (libraw_internal_data.internal_output_params.zero_is_bad)
#ifndef SRC_USES_SHRINK
#define shrink (libraw_internal_data.internal_output_params.shrink)
#endif
#define fuji_width (libraw_internal_data.internal_output_params.fuji_width)
//libraw_internal_data.output_data
#define histogram (libraw_internal_data.output_data.histogram)
#define oprof (libraw_internal_data.output_data.oprof)
//libraw_internal_data.identify_data
#define exif_cfa (libraw_internal_data.identify_data.olympus_exif_cfa)
#define unique_id (libraw_internal_data.identify_data.unique_id)
#define tiff_nifds (libraw_internal_data.identify_data.tiff_nifds)
#define tiff_flip (libraw_internal_data.identify_data.tiff_flip)
//libraw_internal_data.unpacker_data
#define order (libraw_internal_data.unpacker_data.order)
#define data_error (libraw_internal_data.unpacker_data.data_error)
#define cr2_slice (libraw_internal_data.unpacker_data.cr2_slice)
#define sraw_mul (libraw_internal_data.unpacker_data.sraw_mul)
#define kodak_cbpp (libraw_internal_data.unpacker_data.kodak_cbpp)
#define strip_offset (libraw_internal_data.unpacker_data.strip_offset)
#define data_offset (libraw_internal_data.unpacker_data.data_offset)
#define meta_offset (libraw_internal_data.unpacker_data.meta_offset)
#define meta_length (libraw_internal_data.unpacker_data.meta_length)
#define thumb_misc (libraw_internal_data.unpacker_data.thumb_misc)
#define fuji_layout (libraw_internal_data.unpacker_data.fuji_layout)
#define tiff_samples (libraw_internal_data.unpacker_data.tiff_samples)
#define tiff_bps (libraw_internal_data.unpacker_data.tiff_bps)
#define tiff_compress (libraw_internal_data.unpacker_data.tiff_compress)
#define zero_after_ff (libraw_internal_data.unpacker_data.zero_after_ff)
#define tile_width (libraw_internal_data.unpacker_data.tile_width)
#define tile_length (libraw_internal_data.unpacker_data.tile_length)
#define load_flags (libraw_internal_data.unpacker_data.load_flags)
#ifdef LIBRAW_IO_REDEFINED
#define fread(ptr,size,n,stream) stream->read(ptr,size,n)
#define fseek(stream,o,w) stream->seek(o,w)
#define fseeko(stream,o,w) stream->seek(o,w)
#define ftell(stream) stream->tell()
#define ftello(stream) stream->tell()
#define getc(stream) stream->get_char()
#define fgetc(stream) stream->get_char()
#define fgets(str,n,stream) stream->gets(str,n)
#define fscanf(stream,fmt,ptr) stream->scanf_one(fmt,ptr)
#endif
#endif

@ -0,0 +1,229 @@
/* -*- C++ -*-
* File: libraw.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8, 2008
*
* LibRaw C++ interface
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _LIBRAW_CLASS_H
#define _LIBRAW_CLASS_H
#include <limits.h>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include "libraw_datastream.h"
#include "libraw_types.h"
#include "libraw_const.h"
#include "libraw_internal.h"
#include "libraw_alloc.h"
//#define DCRAW_VERBOSE
#ifdef __cplusplus
extern "C"
{
#endif
DllDef const char *libraw_strerror(int errorcode);
DllDef const char *libraw_strprogress(enum LibRaw_progress);
// LibRaw C API
DllDef libraw_data_t *libraw_init(unsigned int flags);
DllDef int libraw_open_file(libraw_data_t*, const char *);
DllDef int libraw_open_buffer(libraw_data_t*, void * buffer, size_t size);
DllDef int libraw_unpack(libraw_data_t*);
DllDef int libraw_unpack_thumb(libraw_data_t*);
DllDef void libraw_recycle(libraw_data_t*);
DllDef void libraw_close(libraw_data_t*);
// version helpers
DllDef const char* libraw_version();
DllDef int libraw_versionNumber();
// Camera list
DllDef const char** libraw_cameraList();
DllDef int libraw_cameraCount();
DllDef void libraw_set_memerror_handler(libraw_data_t*, memory_callback cb, void *datap);
DllDef void libraw_set_dataerror_handler(libraw_data_t*,data_callback func,void *datap);
DllDef void libraw_set_progress_handler(libraw_data_t*,progress_callback cb,void *datap);
DllDef int libraw_add_masked_borders_to_bitmap(libraw_data_t* lr);
DllDef const char * libraw_unpack_function_name(libraw_data_t* lr);
DllDef int libraw_rotate_fuji_raw(libraw_data_t* lr);
// DCRAW compatibility
DllDef int libraw_adjust_sizes_info_only(libraw_data_t*);
DllDef int libraw_dcraw_document_mode_processing(libraw_data_t*);
DllDef int libraw_dcraw_ppm_tiff_writer(libraw_data_t* lr,const char *filename);
DllDef int libraw_dcraw_thumb_writer(libraw_data_t* lr,const char *fname);
DllDef int libraw_dcraw_process(libraw_data_t* lr);
DllDef libraw_processed_image_t* dcraw_make_mem_image(libraw_data_t* lr, int *errc);
DllDef libraw_processed_image_t* dcraw_make_mem_thumb(libraw_data_t* lr, int *errc);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
class DllDef LibRaw
{
public:
libraw_data_t imgdata;
int verbose;
LibRaw(unsigned int flags = LIBRAW_OPTIONS_NONE);
libraw_output_params_t* output_params_ptr() { return &imgdata.params;}
int open_file(const char *fname);
int open_buffer(void *buffer, size_t size);
int open_datastream(LibRaw_abstract_datastream *);
int unpack(void);
int unpack_thumb(void);
int adjust_sizes_info_only(void);
void set_memerror_handler( memory_callback cb,void *data) {callbacks.memcb_data = data; callbacks.mem_cb = cb; }
void set_dataerror_handler(data_callback func, void *data) { callbacks.datacb_data = data; callbacks.data_cb = func;}
void set_progress_handler(progress_callback pcb, void *data) { callbacks.progresscb_data = data; callbacks.progress_cb = pcb;}
// helpers
static const char* version() { return LIBRAW_VERSION_STR;}
static int versionNumber() { return LIBRAW_VERSION; }
static const char** cameraList();
static int cameraCount();
static const char* strprogress(enum LibRaw_progress);
static const char* strerror(int p) { return libraw_strerror(p);}
// dcraw emulation
int dcraw_document_mode_processing();
int dcraw_ppm_tiff_writer(const char *filename);
int dcraw_thumb_writer(const char *fname);
int dcraw_process(void);
// memory writers
libraw_processed_image_t* dcraw_make_mem_image(int *errcode=NULL);
libraw_processed_image_t* dcraw_make_mem_thumb(int *errcode=NULL);
// free all internal data structures
void recycle();
~LibRaw(void) { recycle(); delete tls; }
int FC(int row,int col) { return (imgdata.idata.filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3);}
int fc (int row, int col);
int add_masked_borders_to_bitmap();
const char *unpack_function_name();
int rotate_fuji_raw();
private:
void* malloc(size_t t);
void* calloc(size_t n,size_t t);
void free(void *p);
void merror (void *ptr, const char *where);
void derror();
// data
LibRaw_TLS *tls;
libraw_internal_data_t libraw_internal_data;
decode first_decode[2048], *second_decode, *free_decode;
tiff_ifd_t tiff_ifd[10];
libraw_memmgr memmgr;
libraw_callbacks_t callbacks;
LibRaw_constants rgb_constants;
void (LibRaw:: *write_thumb)(FILE *),
(LibRaw:: *write_fun)(FILE *);
void (LibRaw:: *load_raw)(),
(LibRaw:: *thumb_load_raw)();
void kodak_thumb_loader();
void write_thumb_ppm_tiff(FILE *); // kodak
void foveon_thumb_loader (void); //Sigma
// moved from implementation level to private: visibility
void init_masked_ptrs();
ushort *get_masked_pointer(int row, int col);
int own_filtering_supported(){ return 0;}
void identify();
void write_ppm_tiff (FILE *ofp);
void convert_to_rgb();
void kodak_ycbcr_load_raw();
void remove_zeroes();
#ifndef NO_LCMS
void apply_profile(char*,char*);
#endif
// Iterpolators
void pre_interpolate();
void border_interpolate (int border);
void lin_interpolate();
void vng_interpolate();
void ppg_interpolate();
void ahd_interpolate();
// Image filters
void bad_pixels(char*);
void subtract(char*);
void hat_transform (float *temp, float *base, int st, int size, int sc);
void wavelet_denoise();
void scale_colors();
void median_filter ();
void blend_highlights();
void recover_highlights();
void fuji_rotate();
void stretch();
// Thmbnail functions
void foveon_thumb (FILE *tfp);
void jpeg_thumb_writer (FILE *tfp,char *thumb,int thumb_length);
void jpeg_thumb (FILE *tfp);
void ppm_thumb (FILE *tfp);
void layer_thumb (FILE *tfp);
void rollei_thumb (FILE *tfp);
void kodak_thumb_load_raw();
// utility for cut'n'pasted code
void foveon_decoder (unsigned size, unsigned code);
unsigned get4();
int flip_index (int row, int col);
void gamma_lut(ushort lut[0x10000]);
// == internal functions
#ifdef LIBRAW_LIBRARY_BUILD
#include "internal/libraw_internal_funcs.h"
#endif
};
#ifdef LIBRAW_LIBRARY_BUILD
#define RUN_CALLBACK(stage,iter,expect) if(callbacks.progress_cb) { \
int rr = (*callbacks.progress_cb)(callbacks.progresscb_data,stage,iter,expect); \
if(rr!=0) throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK; \
}
#endif
#endif // __cplusplus
#endif // _LIBRAW_CLASS_H

@ -0,0 +1,98 @@
/* -*- C++ -*-
* File: libraw_alloc.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 22, 2008
*
* LibRaw C++ interface
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef __LIBRAW_ALLOC_H
#define __LIBRAW_ALLOC_H
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#define bzero(p,sz) memset(p,0,sz)
#endif
#ifdef __cplusplus
#define MSIZE 32
class libraw_memmgr
{
public:
libraw_memmgr()
{
bzero(mems,sizeof(mems));
calloc_cnt=0;
}
void *malloc(size_t sz)
{
void *ptr = ::malloc(sz);
mem_ptr(ptr);
return ptr;
}
void *calloc(size_t n, size_t sz)
{
void *ptr = ::calloc(n,sz);
mem_ptr(ptr);
return ptr;
}
void free(void *ptr)
{
::free(ptr);
forget_ptr(ptr);
}
void cleanup(void)
{
for(int i = 0; i< MSIZE; i++)
if(mems[i])
{
// fprintf(stderr,"Found lost fragment at 0x%x\n",mems[i]);
free(mems[i]);
mems[i] = NULL;
}
}
private:
void *mems[MSIZE];
int calloc_cnt;
void mem_ptr(void *ptr)
{
if(ptr)
for(int i=0;i < MSIZE; i++)
if(!mems[i])
{
mems[i] = ptr;
break;
}
}
void forget_ptr(void *ptr)
{
if(ptr)
for(int i=0;i < MSIZE; i++)
if(mems[i] == ptr)
mems[i] = NULL;
}
};
#endif //C++
#endif

@ -0,0 +1,160 @@
/* -*- C++ -*-
* File: libraw_const.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw error codes
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _LIBRAW_ERRORS_H
#define _LIBRAW_ERRORS_H
enum LibRaw_constructor_flags
{
LIBRAW_OPTIONS_NONE =0,
LIBRAW_OPIONS_NO_MEMERR_CALLBACK=1,
LIBRAW_OPIONS_NO_DATAERR_CALLBACK=1<<1
};
enum LibRaw_warnings
{
LIBRAW_WARN_NONE =0,
LIBRAW_WARN_FOVEON_NOMATRIX =1,
LIBRAW_WARN_FOVEON_INVALIDWB =1<<1,
LIBRAW_WARN_BAD_CAMERA_WB =1<<2,
LIBRAW_WARN_NO_METADATA =1<<3,
LIBRAW_WARN_NO_JPEGLIB = 1<<4,
LIBRAW_WARN_NO_EMBEDDED_PROFILE = 1<<5,
LIBRAW_WARN_NO_INPUT_PROFILE = 1<<6,
LIBRAW_WARN_BAD_OUTPUT_PROFILE= 1<<7,
LIBRAW_WARN_NO_BADPIXELMAP=1<<8,
LIBRAW_WARN_BAD_DARKFRAME_FILE=1<<9,
LIBRAW_WARN_BAD_DARKFRAME_DIM=1<<10
};
enum LibRaw_exceptions
{
LIBRAW_EXCEPTION_NONE =0,
LIBRAW_EXCEPTION_ALLOC =1,
LIBRAW_EXCEPTION_DECODE_RAW =2,
LIBRAW_EXCEPTION_DECODE_JPEG=3,
LIBRAW_EXCEPTION_IO_EOF =4,
LIBRAW_EXCEPTION_IO_CORRUPT =5,
LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK=6
};
enum LibRaw_colorstate
{
LIBRAW_COLORSTATE_UNKNOWN =0,
LIBRAW_COLORSTATE_INIT =1,
LIBRAW_COLORSTATE_CONST =2,
LIBRAW_COLORSTATE_LOADED =3,
LIBRAW_COLORSTATE_CALCULATED=4,
LIBRAW_COLORSTATE_RESERVED1 =5,
LIBRAW_COLORSTATE_RESERVED2 =6,
LIBRAW_COLORSTATE_RESERVED3 =7
};
enum LibRaw_filtering
{
LIBRAW_FILTERING_DEFAULT =0,
LIBRAW_FILTERING_NOZEROES =1, // no remove zeroes
LIBRAW_FILTERING_NOBLACKS =2, // no black subtraction
LIBRAW_FILTERING_NORAWCURVE =4, // no raw data postprocessing (e.g. PhaseOne corrections etc)
LIBRAW_FILTERING_NONE =7, // (_NOZEROES | _NOBLACKS | _NORAWCURVE)
LIBRAW_FILTERING_LIBRAWOWN =(8 | LIBRAW_FILTERING_NONE), // NONE + 8
LIBRAW_FILTERING_AUTOMATIC_BIT =16, // - restore automatic mode after processing
LIBRAW_FILTERING_AUTOMATIC = (LIBRAW_FILTERING_LIBRAWOWN | LIBRAW_FILTERING_AUTOMATIC_BIT)
};
enum LibRaw_progress
{
LIBRAW_PROGRESS_START = 0,
LIBRAW_PROGRESS_OPEN = 1,
LIBRAW_PROGRESS_IDENTIFY = 1<<1,
LIBRAW_PROGRESS_SIZE_ADJUST = 1<<2,
LIBRAW_PROGRESS_LOAD_RAW = 1<<3,
LIBRAW_PROGRESS_REMOVE_ZEROES = 1<<4,
LIBRAW_PROGRESS_BAD_PIXELS = 1<<5,
LIBRAW_PROGRESS_DARK_FRAME = 1<<6,
LIBRAW_PROGRESS_FOVEON_INTERPOLATE = 1<<7,
LIBRAW_PROGRESS_SCALE_COLORS = 1<<8,
LIBRAW_PROGRESS_PRE_INTERPOLATE = 1<<9,
LIBRAW_PROGRESS_INTERPOLATE = 1<<10,
LIBRAW_PROGRESS_MIX_GREEN = 1<<11,
LIBRAW_PROGRESS_MEDIAN_FILTER = 1<<12,
LIBRAW_PROGRESS_HIGHLIGHTS = 1<<13,
LIBRAW_PROGRESS_FUJI_ROTATE = 1<<14,
LIBRAW_PROGRESS_FLIP = 1<<15,
LIBRAW_PROGRESS_APPLY_PROFILE = 1<<16,
LIBRAW_PROGRESS_CONVERT_RGB = 1<<17,
LIBRAW_PROGRESS_STRETCH = 1<<18,
// reserved
LIBRAW_PROGRESS_STAGE19 = 1<<19,
LIBRAW_PROGRESS_STAGE20 = 1<<20,
LIBRAW_PROGRESS_STAGE21 = 1<<21,
LIBRAW_PROGRESS_STAGE22 = 1<<22,
LIBRAW_PROGRESS_STAGE23 = 1<<23,
LIBRAW_PROGRESS_STAGE24 = 1<<24,
LIBRAW_PROGRESS_STAGE25 = 1<<25,
LIBRAW_PROGRESS_STAGE26 = 1<<26,
LIBRAW_PROGRESS_STAGE27 = 1<<27,
LIBRAW_PROGRESS_THUMB_LOAD = 1<<28,
LIBRAW_PROGRESS_TRESERVED1 = 1<<29,
LIBRAW_PROGRESS_TRESERVED2 = 1<<30,
LIBRAW_PROGRESS_TRESERVED3 = 1<<31
};
#define LIBRAW_PROGRESS_THUMB_MASK 0x0fffffff
enum LibRaw_errors
{
LIBRAW_SUCCESS = 0,
LIBRAW_UNSPECIFIED_ERROR=-1,
LIBRAW_FILE_UNSUPPORTED = -2,
LIBRAW_REQUEST_FOR_NONEXISTENT_IMAGE=-3,
LIBRAW_OUT_OF_ORDER_CALL=-4,
LIBRAW_NO_THUMBNAIL=-5,
LIBRAW_UNSUPPORTED_THUMBNAIL=-6,
LIBRAW_CANNOT_ADDMASK=-7,
LIBRAW_UNSUFFICIENT_MEMORY=-100007,
LIBRAW_DATA_ERROR=-100008,
LIBRAW_IO_ERROR=-100009,
LIBRAW_CANCELLED_BY_CALLBACK=-100010
};
#define LIBRAW_FATAL_ERROR(ec) ((ec)<-100000)
enum LibRaw_thumbnail_formats
{
LIBRAW_THUMBNAIL_UNKNOWN=0,
LIBRAW_THUMBNAIL_JPEG=1,
LIBRAW_THUMBNAIL_BITMAP=2,
LIBRAW_THUMBNAIL_LAYER=4,
LIBRAW_THUMBNAIL_ROLLEI=5
};
enum LibRaw_image_formats
{
LIBRAW_IMAGE_BITMAP=1,
LIBRAW_IMAGE_JPEG=2
};
#endif

@ -0,0 +1,303 @@
/* -*- C -*-
* File: libraw_datastream.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sun Jan 18 13:07:35 2009
*
* LibRaw Data stream interface
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef __LIBRAW_DATASTREAM_H
#define __LIBRAW_DATASTREAM_H
#include <stdio.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#ifndef __cplusplus
struct LibRaw_abstract_datastream;
#else // __cplusplus
#include "libraw_const.h"
class LibRaw_buffer_datastream;
class LibRaw_abstract_datastream
{
public:
LibRaw_abstract_datastream(){substream=0;};
virtual ~LibRaw_abstract_datastream(void){if(substream) delete substream;}
virtual int valid(){return 0;}
// file input emulation
virtual int read(void *,size_t, size_t ){ return -1;}
virtual int seek(off_t o, int whence){return -1;}
virtual int tell(){return -1;}
virtual int get_char(){return -1;}
virtual char* gets(char *, int){ return NULL;}
virtual int scanf_one(const char *, void *){return -1;}
virtual int eof(){return -1;}
virtual const char* fname(){ return NULL;};
virtual int subfile_open(const char*){ return EINVAL;}
virtual void subfile_close(){}
virtual int tempbuffer_open(void*, size_t);
virtual void tempbuffer_close()
{
if(substream) delete substream;
substream = NULL;
}
protected:
LibRaw_abstract_datastream *substream;
};
class LibRaw_file_datastream : public LibRaw_abstract_datastream
{
public:
LibRaw_file_datastream(const char *fname)
{
if(fname)
{filename = fname; f = fopen(fname,"rb");}
else
{filename=0;f=0;}
sav=0;
}
virtual ~LibRaw_file_datastream() {if(f)fclose(f); if(sav)fclose(sav);}
virtual int valid() { return f?1:0;}
#define CHK() do {if(!f) throw LIBRAW_EXCEPTION_IO_EOF;}while(0)
virtual int read(void * ptr,size_t size, size_t nmemb)
{
CHK();
return substream?substream->read(ptr,size,nmemb):int(fread(ptr,size,nmemb,f));
}
virtual int eof()
{
CHK();
return substream?substream->eof():feof(f);
}
virtual int seek(off_t o, int whence)
{
CHK();
return substream?substream->seek(o,whence):fseek(f,o,whence);
}
virtual int tell()
{
CHK();
return substream?substream->tell():ftell(f);
}
virtual int get_char()
{
CHK();
return substream?substream->get_char():fgetc(f);
}
virtual char* gets(char *str, int sz)
{
CHK();
return substream?substream->gets(str,sz):fgets(str,sz,f);
}
virtual int scanf_one(const char *fmt, void*val)
{
CHK();
return substream?substream->scanf_one(fmt,val):fscanf(f,fmt,val);
}
virtual const char *fname() { return filename; }
// secondary
virtual int subfile_open(const char *fn)
{
if(sav) return EBUSY;
sav = f;
f = fopen(fn,"rb");
if(!f)
{
f = sav;
sav = NULL;
return ENOENT;
}
else
return 0;
}
virtual void subfile_close()
{
if(!sav) return;
fclose(f);
f = sav;
sav = 0;
}
private:
FILE *f,*sav;
const char *filename;
};
#undef CHK
class LibRaw_buffer_datastream : public LibRaw_abstract_datastream
{
public:
LibRaw_buffer_datastream(void *buffer, size_t bsize)
{
buf = (unsigned char*)buffer; streampos = 0; streamsize = bsize;
}
virtual ~LibRaw_buffer_datastream(){}
virtual int valid() { return buf?1:0;}
virtual int read(void * ptr,size_t sz, size_t nmemb)
{
if(substream) return substream->read(ptr,sz,nmemb);
size_t to_read = sz*nmemb;
if(to_read > streamsize - streampos)
to_read = streamsize-streampos;
if(to_read<1)
return 0;
memmove(ptr,buf+streampos,to_read);
streampos+=to_read;
return int((to_read+sz-1)/sz);
}
virtual int eof()
{
if(substream) return substream->eof();
return streampos >= streamsize;
}
virtual int seek(off_t o, int whence)
{
if(substream) return substream->seek(o,whence);
switch(whence)
{
case SEEK_SET:
if(o<0)
streampos = 0;
else if (size_t(o) > streamsize)
streampos = streamsize;
else
streampos = size_t(o);
return 0;
case SEEK_CUR:
if(o<0)
{
if(size_t(-o) >= streampos)
streampos = 0;
else
streampos += o;
}
else if (o>0)
{
if(o+streampos> streamsize)
streampos = streamsize;
else
streampos += o;
}
return 0;
case SEEK_END:
if(o>0)
streampos = streamsize;
else if ( size_t(-o) > streamsize)
streampos = 0;
else
streampos = streamsize+o;
return 0;
default:
return 0;
}
}
virtual int tell()
{
if(substream) return substream->tell();
return int(streampos);
}
virtual int get_char()
{
if(substream) return substream->get_char();
if(streampos>=streamsize)
return -1;
return buf[streampos++];
}
virtual char* gets(char *s, int sz)
{
if (substream) return substream->gets(s,sz);
unsigned char *psrc,*pdest,*str;
str = (unsigned char *)s;
psrc = buf+streampos;
pdest = str;
while ( (size_t(psrc - buf) < streamsize)
&&
((pdest-str)<sz)
)
{
*pdest = *psrc;
if(*psrc == '\n')
break;
psrc++;
pdest++;
}
if(size_t(psrc-buf) < streamsize)
psrc++;
if((pdest-str)<sz)
*(++pdest)=0;
streampos = psrc - buf;
return s;
}
virtual int scanf_one(const char *fmt, void* val)
{
if(substream) return substream->scanf_one(fmt,val);
int scanf_res;
if(streampos>streamsize) return 0;
scanf_res = sscanf((char*)(buf+streampos),fmt,val);
if(scanf_res>0)
{
int xcnt=0;
while(streampos<streamsize)
{
streampos++;
xcnt++;
if(buf[streampos] == 0
|| buf[streampos]==' '
|| buf[streampos]=='\t'
|| buf[streampos]=='\n'
|| xcnt>24)
break;
}
}
return scanf_res;
}
private:
unsigned char *buf;
size_t streampos,streamsize;
};
inline int LibRaw_abstract_datastream::tempbuffer_open(void *buf, size_t size)
{
if(substream) return EBUSY;
substream = new LibRaw_buffer_datastream(buf,size);
return substream?0:EINVAL;
}
#endif
#endif

@ -0,0 +1,241 @@
/* -*- C++ -*-
* File: libraw_internal.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw internal data structures (not visible outside)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _LIBRAW_INTERNAL_TYPES_H
#define _LIBRAW_INTERNAL_TYPES_H
#include <stdio.h>
#ifdef __cplusplus
#ifndef CLASS
#define CLASS LibRaw::
#endif
#else
// C build
#ifndef CLASS
#define CLASS
#endif
#endif
#ifdef __cplusplus
#include "libraw_datastream.h"
class LibRaw_TLS
{
public:
struct
{
unsigned bitbuf;
int vbits, reset;
}getbits;
struct
{
UINT64 bitbuf;
int vbits;
}ph1_bits;
int make_decoder_leaf;
struct
{
struct decode *dstart[18], *dindex;
const int *s;
}radc_token;
struct
{
unsigned pad[128], p;
}sony_decrypt;
unsigned foveon_decoder_huff[1024];
uchar jpeg_buffer[4096];
struct
{
uchar buf[0x4000];
int vbits, padding;
}pana_bits;
// init - should use in constructor/recycle
void init()
{
getbits.bitbuf = 0; getbits.vbits = getbits.reset = 0;
ph1_bits.bitbuf = 0; ph1_bits.vbits = 0;
pana_bits.vbits = 0;
}
};
class LibRaw_constants
{
public:
static const float d65_white[3];
static const double xyz_rgb[3][3];
};
#endif // __cplusplus
#ifdef WIN32
typedef long off_t;
#endif
typedef struct
{
#ifndef __cplusplus
struct
#endif
LibRaw_abstract_datastream *input;
int input_internal;
// char *ifname;
char *meta_data;
off_t profile_offset;
off_t toffset;
} internal_data_t;
typedef struct
{
unsigned mix_green;
unsigned raw_color;
unsigned use_gamma;
unsigned zero_is_bad;
ushort shrink;
ushort fuji_width;
ushort fwidth,fheight;
} internal_output_params_t;
#define LIBRAW_HISTOGRAM_SIZE 0x2000
typedef struct
{
int (*histogram)[LIBRAW_HISTOGRAM_SIZE];
unsigned *oprof;
} output_data_t;
typedef struct
{
unsigned olympus_exif_cfa;
unsigned unique_id;
unsigned tiff_nifds;
int tiff_flip;
}identify_data_t;
typedef struct
{
short order; // II* / MM* - file word byte order
ushort sraw_mul[4],cr2_slice[3];
unsigned kodak_cbpp;
off_t strip_offset, data_offset;
off_t meta_offset;
unsigned meta_length;
unsigned thumb_misc;
unsigned fuji_layout;
unsigned tiff_samples;
unsigned tiff_bps;
unsigned tiff_compress;
unsigned zero_after_ff;
unsigned tile_width, tile_length,load_flags;
unsigned data_error;
}unpacker_data_t;
typedef struct
{
internal_data_t internal_data;
internal_output_params_t internal_output_params;
output_data_t output_data;
identify_data_t identify_data;
unpacker_data_t unpacker_data;
// callbacks_t callbacks;
} libraw_internal_data_t;
struct decode
{
struct decode *branch[2];
int leaf;
};
struct tiff_ifd_t
{
int t_width, t_height, bps, comp, phint, offset, t_flip, samples, bytes;
};
struct jhead {
int bits, high, wide, clrs, sraw, psv, restart, vpred[6];
struct decode *huff[6];
ushort *row;
};
struct tiff_tag {
ushort tag, type;
int count;
union { char c[4]; short s[2]; int i; } val;
};
struct tiff_hdr {
ushort t_order, magic;
int ifd;
ushort pad, ntag;
struct tiff_tag tag[23];
int nextifd;
ushort pad2, nexif;
struct tiff_tag exif[4];
ushort pad3, ngps;
struct tiff_tag gpst[10];
short bps[4];
int rat[10];
unsigned gps[26];
char t_desc[512], t_make[64], t_model[64], soft[32], date[20], t_artist[64];
};
#ifdef DEBUG_STAGE_CHECKS
#define CHECK_ORDER_HIGH(expected_stage) \
do { if((imgdata.progress_flags & LIBRAW_PROGRESS_THUMB_MASK) >= expected_stage) {fprintf(stderr,"CHECK_HIGH: check %d >= %d\n",imgdata.progress_flags & LIBRAW_PROGRESS_THUMB_MASK,expected_stage);return LIBRAW_OUT_OF_ORDER_CALL;} } while(0)
#define CHECK_ORDER_LOW(expected_stage) \
do { printf("Checking LOW %d/%d : %d\n",imgdata.progress_flags,expected_stage,imgdata.progress_flags<expected_stage); if( (imgdata.progress_flags&LIBRAW_PROGRESS_THUMB_MASK) < expected_stage ) { printf("failed!\n"); return LIBRAW_OUT_OF_ORDER_CALL;} } while(0)
#define CHECK_ORDER_BIT(expected_stage) \
do { if(imgdata.progress_flags & expected_stage) return LIBRAW_OUT_OF_ORDER_CALL; } while(0)
#define SET_PROC_FLAG(stage) do {imgdata.progress_flags |= stage; fprintf(stderr,"SET_FLAG: %d\n",stage); } while (0)
#else
#define CHECK_ORDER_HIGH(expected_stage) \
do { if((imgdata.progress_flags & LIBRAW_PROGRESS_THUMB_MASK) >= expected_stage) \
{return LIBRAW_OUT_OF_ORDER_CALL;} } while(0)
#define CHECK_ORDER_LOW(expected_stage) \
do { if((imgdata.progress_flags&LIBRAW_PROGRESS_THUMB_MASK) < expected_stage) \
return LIBRAW_OUT_OF_ORDER_CALL; } while(0)
#define CHECK_ORDER_BIT(expected_stage) \
do { if(imgdata.progress_flags & expected_stage) return LIBRAW_OUT_OF_ORDER_CALL; } while(0)
#define SET_PROC_FLAG(stage) do {imgdata.progress_flags |= stage;} while (0)
#endif
#endif

@ -0,0 +1,293 @@
/* -*- C++ -*-
* File: libraw_types.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw C data structures
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _LIBRAW_TYPES_H
#define _LIBRAW_TYPES_H
#ifndef WIN32
#include <sys/time.h>
#endif
#include <stdio.h>
#ifdef _OPENMP
#include <omp.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef USE_LCMS
#define NO_LCMS
#endif
#include "libraw_const.h"
#include "libraw_version.h"
typedef long long INT64;
typedef unsigned long long UINT64;
//#define ushort UshORt
typedef unsigned char uchar;
typedef unsigned short ushort;
#ifdef WIN32
#ifdef LIBRAW_NODLL
# define DllDef
#else
# ifdef LIBRAW_BUILDLIB
# define DllDef __declspec( dllexport )
# else
# define DllDef __declspec( dllimport )
# endif
#endif
// NO Win32
#else
# define DllDef
#endif
//class LibRaw;
typedef void (* memory_callback)(void * data, const char *file, const char *where);
DllDef void default_memory_callback(void *data,const char *file, const char *where);
typedef void (*data_callback)(void *data,const char *file, const int offset);
DllDef void default_data_callback(void *data,const char *file, const int offset);
typedef int (* progress_callback) (void *data,enum LibRaw_progress stage, int iteration,int expected);
typedef struct
{
memory_callback mem_cb;
void* memcb_data;
data_callback data_cb;
void* datacb_data;
progress_callback progress_cb;
void *progresscb_data;
} libraw_callbacks_t;
// Output bitmap type
typedef struct
{
enum LibRaw_image_formats type;
ushort height,
width,
colors,
bits,
gamma_corrected;
#ifdef _OPENMP
#pragma omp firstprivate(colors,height,width)
#endif
unsigned int data_size; // ðàçìåð ïîëÿ äàííûõ â áàéòàõ
unsigned char data[1]; // we'll allocate more!
}libraw_processed_image_t;
//Decoded from exif and used in calculations
typedef struct
{
char make[64];
char model[64];
unsigned raw_count;
unsigned dng_version;
unsigned is_foveon;
int colors;
unsigned filters; // camera CFA pattern mask
char cdesc[5];
}libraw_iparams_t;
typedef struct
{
ushort raw_height,
raw_width,
height,
width,
top_margin,
left_margin;
ushort iheight,
iwidth;
#ifdef _OPENMP
#pragma omp firstprivate(iheight,iwidth)
#endif
double pixel_aspect;
int flip;
// masked border sizes
ushort right_margin,bottom_margin; // right masked width and bottom height, inited after idendify()
} libraw_image_sizes_t;
//Phase One data
struct ph1_t
{
int format, key_off, t_black, black_off, split_col, tag_21a;
float tag_210;
};
typedef struct
{
// 32 bits total
unsigned curve_state : 3;
unsigned rgb_cam_state : 3;
unsigned cmatrix_state : 3;
unsigned pre_mul_state : 3;
unsigned cam_mul_state : 3;
unsigned filler : 17;
} color_data_state_t;
typedef struct
{
color_data_state_t color_flags;
ushort white[8][8]; // white block extracted from ciff/CRW
float cam_mul[4]; // camera white balance (from RAW)
float pre_mul[4]; // either set in identify() or calculated. Used on output
float cmatrix[3][4]; // camera color matrix
float rgb_cam[3][4]; // another way to set color matrix
float cam_xyz[4][3]; // Camera to XYZ matrix (DNG coeffs)
ushort curve[0x4001]; // camera tone curve/ljpeg curve
unsigned black;
unsigned maximum;
struct ph1_t phase_one_data;
float flash_used; // canon/CRW only
float canon_ev; // canon/CRW only
char model2[64];
// profile
void *profile;
unsigned profile_length;
}libraw_colordata_t;
typedef struct
{
enum LibRaw_thumbnail_formats tformat;
ushort twidth,
theight;
unsigned tlength;
int tcolors;
// thumbnail buffer
char *thumb;
}libraw_thumbnail_t;
// Decoded from exif/raw, but not used in real calculations
typedef struct
{
float iso_speed;
float shutter;
float aperture;
float focal_len;
time_t timestamp;
unsigned shot_order;
unsigned gpsdata[32];
// string variables
char desc[512],
artist[64];
} libraw_imgother_t;
typedef struct
{
unsigned greybox[4]; /* -A x1 y1 x2 y2 */
double aber[4]; /* -C */
double gamm[5]; /* -g */
float user_mul[4]; /* -r mul0 mul1 mul2 mul3 */
unsigned shot_select; /* -s */
float bright; /* -b */
float threshold; /* -n */
#ifdef _OPENMP
#pragma omp firstprivate(threshold)
#endif
int half_size; /* -h */
int four_color_rgb; /* -f */
int document_mode; /* -d/-D */
int highlight; /* -H */
// int verbose; /* -v */
int use_auto_wb; /* -a */
int use_camera_wb; /* -w */
int use_camera_matrix; /* +M/-M */
int output_color; /* -o */
char *output_profile; /* -o */
char *camera_profile; /* -p */
char *bad_pixels; /* -P */
char *dark_frame; /* -K */
int output_bps; /* -4 */
int gamma_16bit; /* -1 */
int output_tiff; /* -T */
int user_flip; /* -t */
int user_qual; /* -q */
int user_black; /* -k */
int user_sat; /* -S */
int med_passes; /* -m */
float auto_bright_thr;
int no_auto_bright; /* -W */
int use_fuji_rotate;/* -j */
enum LibRaw_filtering filtering_mode;
}libraw_output_params_t;
typedef struct
{
ushort *buffer; // actual pixel buffer size=(raw_width*raw_height - width*height)
ushort *tl; // top left size=(top_margin*left_margin)
ushort *top; // top size=(top_margin*width)
ushort *tr; // top right size=((raw_width-width-left_margin)*top_margin)
ushort *left; // left size=(left_margin*height)
ushort *right; // right size=(raw_width-width-left_margin)*height;
ushort *bl; // bottom left size=(raw_height-height-top_margin)*left_margin
ushort *bottom; // bottom size=(raw_height-height-top_margin)*width
ushort *br; // bottom right size=(raw_height-height-top_margin)*
ushort (*ph1_black)[2]; // Phase One black
}libraw_masked_t;
typedef struct
{
unsigned int progress_flags;
unsigned int process_warnings;
libraw_iparams_t idata;
libraw_image_sizes_t sizes;
libraw_colordata_t color;
libraw_imgother_t other;
libraw_thumbnail_t thumbnail;
libraw_masked_t masked_pixels;
ushort (*image)[4] ;
#ifdef _OPENMP
#pragma omp shared(image)
#endif
libraw_output_params_t params;
// pointer to LibRaw class for use in C calls
void *parent_class;
} libraw_data_t;
#ifdef __cplusplus
}
#endif
#endif

@ -0,0 +1,47 @@
/* -*- C++ -*-
* File: libraw_version.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Mon Sept 8, 2008
*
* LibRaw C++ interface
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef __VERSION_H
#define __VERSION_H
#define LIBRAW_MAJOR_VERSION 0
#define LIBRAW_MINOR_VERSION 7
#define LIBRAW_PATCH_VERSION 2
#define LIBRAW_VERSION_TAIL Release
#define _LIBRAW_VERSION_MAKE(a,b,c,d) #a"."#b"."#c"-"#d
#define LIBRAW_VERSION_MAKE(a,b,c,d) _LIBRAW_VERSION_MAKE(a,b,c,d)
#define LIBRAW_VERSION_STR LIBRAW_VERSION_MAKE(LIBRAW_MAJOR_VERSION,LIBRAW_MINOR_VERSION,LIBRAW_PATCH_VERSION,LIBRAW_VERSION_TAIL)
#define LIBRAW_MAKE_VERSION(major,minor,patch) \
(((major) << 16) | ((minor) << 8) | (patch))
#define LIBRAW_VERSION \
LIBRAW_MAKE_VERSION(LIBRAW_MAJOR_VERSION,LIBRAW_MINOR_VERSION,LIBRAW_PATCH_VERSION)
#define LIBRAW_CHECK_VERSION(major,minor,patch) \
( LibRaw::versionNumber() >= LIBRAW_MAKE_VERSION(major,minor,patch) )
#endif

@ -0,0 +1,187 @@
/* -*- C++ -*-
* File: 4channels.cpp
* Copyright 2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Mon Feb 09, 2009
*
* LibRaw sample
* Generates 4 TIFF file from RAW data, one file per channel
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifndef WIN32
#include <netinet/in.h>
#else
#include <winsock2.h>
#endif
#include "libraw/libraw.h"
#ifdef WIN32
#define snprintf _snprintf
#endif
int main(int ac, char *av[])
{
int i, ret;
int autoscale=0,filtering_mode=LIBRAW_FILTERING_DEFAULT,black_subtraction=1;
char outfn[1024],thumbfn[1024];
LibRaw RawProcessor;
if(ac<2)
{
usage:
printf(
"4channeld - LibRaw %s sample. %d cameras supported\n"
"Usage: %s [-s N] [-g] [-A] [-B] [-N] raw-files....\n"
"\t-s N - select Nth image in file (default=0)\n"
"\t-g - use gamma correction with gamma 2.2 (not precise,use for visual inspection only)\n"
"\t-A - autoscaling (by integer factor)\n"
"\t-B - no black subtraction\n"
"\t-N - no raw curve\n"
,LibRaw::version(),
LibRaw::cameraCount(),
av[0]);
return 0;
}
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
OUT.document_mode=2;
OUT.output_bps=16;
OUT.output_tiff=1;
OUT.user_flip=0;
OUT.no_auto_bright = 1;
OUT.half_size=1;
OUT.filtering_mode= LIBRAW_FILTERING_AUTOMATIC;
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='s' && av[i][2]==0)
{
i++;
OUT.shot_select=atoi(av[i]);
}
else if(av[i][1]=='g' && av[i][2]==0)
OUT.gamma_16bit=1;
else if(av[i][1]=='A' && av[i][2]==0)
autoscale=1;
else if(av[i][1]=='B' && av[i][2]==0)
{
filtering_mode |= (LIBRAW_FILTERING_NOZEROES | LIBRAW_FILTERING_NOBLACKS);
black_subtraction=0;
}
else if(av[i][1]=='N' && av[i][2]==0)
filtering_mode |= LIBRAW_FILTERING_NORAWCURVE;
else
goto usage;
continue;
}
if(filtering_mode)
OUT.filtering_mode = (LibRaw_filtering) filtering_mode;
int r,c;
printf("Processing file %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if(P1.is_foveon)
{
printf("Cannot process foveon image %s\n",av[i]);
continue ;
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
if(black_subtraction && C.black>0)
{
for(int j=0; j<S.iheight*S.iwidth; j++)
for(int c = 0; c< 4; c++)
if(RawProcessor.imgdata.image[j][c]>C.black)
RawProcessor.imgdata.image[j][c]-=C.black;
else
RawProcessor.imgdata.image[j][c]=0;
}
if(autoscale)
{
unsigned max=0,scale;
for(int j=0; j<S.iheight*S.iwidth; j++)
for(int c = 0; c< 4; c++)
if(max < RawProcessor.imgdata.image[j][c])
max = RawProcessor.imgdata.image[j][c];
if (max >0 && max< 1<<15)
{
scale = (1<<16)/max;
printf("Scaling with multiplier=%d (max=%d)\n",scale,max);
for(int j=0; j<S.iheight*S.iwidth; j++)
for(c=0;c<4;c++)
RawProcessor.imgdata.image[j][c] *= scale;
}
printf("Black level (scaled)=%d\n",C.black*scale);
}
else
printf("Black level (unscaled)=%d\n",C.black);
// hack to make dcraw tiff writer happy
int isrgb=(P1.colors==4?0:1);
P1.colors = 1;
S.width = S.iwidth;
S.height = S.iheight;
for (int layer=0;layer<4;layer++)
{
if(layer>0)
{
for (int rc = 0; rc < S.iheight*S.iwidth; rc++)
RawProcessor.imgdata.image[rc][0] = RawProcessor.imgdata.image[rc][layer];
}
char lname[8];
if(isrgb)
{
snprintf(lname,7,"%c",(char*)("RGBG")[layer]);
if(layer==3)
strcat(lname,"2");
}
else
snprintf(lname,7,"%c",(char*)("GCMY")[layer]);
if(OUT.shot_select)
snprintf(outfn,sizeof(outfn),"%s-%d.%s.tiff",av[i],OUT.shot_select,lname);
else
snprintf(outfn,sizeof(outfn),"%s.%s.tiff",av[i],lname);
printf("Writing file %s\n",outfn);
if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));
}
}
return 0;
}

@ -0,0 +1,281 @@
/* -*- C++ -*-
* File: dcraw_emu.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sun Mar 23, 2008
*
* LibRaw simple C++ API (almost complete dcraw emulator)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#ifndef WIN32
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
#endif
#include "libraw/libraw.h"
#ifdef WIN32
#define snprintf _snprintf
#endif
void usage(const char *prog)
{
printf("dcraw_emu: almost complete dcraw emulator\n");
printf("Usage: %s [OPTION]... [FILE]...\n", prog);
printf(
"-v Verbose: print progress messages (repeated -v will add verbosity)\n"
"-w Use camera white balance, if possible\n"
"-a Average the whole image for white balance\n"
"-A <x y w h> Average a grey box for white balance\n"
"-r <r g b g> Set custom white balance\n"
"+M/-M Use/don't use an embedded color matrix\n"
"-C <r b> Correct chromatic aberration\n"
"-P <file> Fix the dead pixels listed in this file\n"
"-K <file> Subtract dark frame (16-bit raw PGM)\n"
"-k <num> Set the darkness level\n"
"-S <num> Set the saturation level\n"
"-n <num> Set threshold for wavelet denoising\n"
"-H [0-9] Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)\n"
"-t [0-7] Flip image (0=none, 3=180, 5=90CCW, 6=90CW)\n"
"-o [0-5] Output colorspace (raw,sRGB,Adobe,Wide,ProPhoto,XYZ)\n"
#ifndef NO_LCMS
"-o file Output ICC profile\n"
"-p file Camera input profile (use \'embed\' for embedded profile)\n"
#endif
"-j Don't stretch or rotate raw pixels\n"
"-W Don't automatically brighten the image\n"
"-b <num> Adjust brightness (default = 1.0)\n"
"-q [0-3] Set the interpolation quality\n"
"-h Half-size color image (twice as fast as \"-q 0\")\n"
"-f Interpolate RGGB as four colors\n"
"-m <num> Apply a 3x3 median filter to R-G and B-G\n"
"-s [0..N-1] Select one raw image from input file\n"
"-4 Write 16-bit linear instead of 8-bit with gamma\n"
"-g pow ts Set gamma curve to gamma pow and toe slope ts (default = 2.222 4.5)\n"
"-T Write TIFF instead of PPM\n"
#ifndef WIN32
"-B Use mmap()-ed buffer instead of plain FILE I/O\n"
#endif
);
exit(1);
}
static int verbosity=0;
int cnt=0;
int my_progress_callback(void *d,enum LibRaw_progress p,int iteration, int expected)
{
char *passed = (char*)(d?d:"default string"); // data passed to callback at set_callback stage
if(verbosity>2) // verbosity set by repeat -v switches
{
printf("CB: %s pass %d of %d (data passed=%s)\n",libraw_strprogress(p),iteration,expected,passed);
}
else if (iteration == 0) // 1st iteration of each step
printf("Starting %s (expecting %d iterations)\n", libraw_strprogress(p),expected);
else if (iteration == expected-1)
printf("%s finished\n",libraw_strprogress(p));
/// if(++cnt>10) return 1; // emulate user termination on 10-th callback call
return 0; // always return 0 to continue processing
}
int main(int argc, char *argv[])
{
if(argc==1) usage(argv[0]);
LibRaw RawProcessor;
int i,arg,c,ret;
char opm,opt,*cp,*sp;
int use_mmap=0, msize;
void *iobuffer;
#define OUT RawProcessor.imgdata.params
argv[argc] = "";
for (arg=1; (((opm = argv[arg][0]) - 2) | 2) == '+'; )
{
opt = argv[arg++][1];
if ((cp = strchr (sp="nbrkStqmHACgU", opt)))
for (i=0; i < "11411111142"[cp-sp]-'0'; i++)
if (!isdigit(argv[arg+i][0]))
{
fprintf (stderr,"Non-numeric argument to \"-%c\"\n", opt);
return 1;
}
switch (opt)
{
case 'v': verbosity++; break;
case 'U': OUT.auto_bright_thr = atof(argv[arg++]); break;
case 'n': OUT.threshold = atof(argv[arg++]); break;
case 'b': OUT.bright = atof(argv[arg++]); break;
case 'P': OUT.bad_pixels = argv[arg++]; break;
case 'K': OUT.dark_frame = argv[arg++]; break;
case 'r':
for(c=0;c<4;c++)
OUT.user_mul[c] = atof(argv[arg++]);
break;
case 'C':
OUT.aber[0] = 1 / atof(argv[arg++]);
OUT.aber[2] = 1 / atof(argv[arg++]);
break;
case 'g':
OUT.gamm[0] = 1 / atof(argv[arg++]);
OUT.gamm[1] = atof(argv[arg++]);
break;
case 'k': OUT.user_black = atoi(argv[arg++]); break;
case 'S': OUT.user_sat = atoi(argv[arg++]); break;
case 't': OUT.user_flip = atoi(argv[arg++]); break;
case 'q': OUT.user_qual = atoi(argv[arg++]); break;
case 'm': OUT.med_passes = atoi(argv[arg++]); break;
case 'H': OUT.highlight = atoi(argv[arg++]); break;
case 's': OUT.shot_select = abs(atoi(argv[arg++])); break;
case 'o':
if(isdigit(argv[arg+1][0]) && !isdigit(argv[arg+1][1]))
OUT.output_color = atoi(argv[arg++]);
#ifndef NO_LCMS
else
OUT.output_profile = argv[arg++];
break;
case 'p': OUT.camera_profile = argv[arg++];
#endif
break;
case 'h': OUT.half_size = 1;
// no break: "-h" implies "-f"
case 'f':
OUT.four_color_rgb = 1;
break;
case 'A': for(c=0; c<4;c++) OUT.greybox[c] = atoi(argv[arg++]);
case 'a': OUT.use_auto_wb = 1; break;
case 'w': OUT.use_camera_wb = 1; break;
case 'M': OUT.use_camera_matrix = (opm == '+'); break;
case 'j': OUT.use_fuji_rotate = 0; break;
case 'W': OUT.no_auto_bright = 1; break;
case 'T': OUT.output_tiff = 1; break;
case '4': OUT.output_bps = 16; break;
case '1': OUT.gamma_16bit = 1; break;
#ifndef WIN32
case 'B': use_mmap = 1; break;
#endif
default:
fprintf (stderr,"Unknown option \"-%c\".\n", opt);
return 1;
}
}
putenv ((char*)"TZ=UTC"); // dcraw compatibility, affects TIFF datestamp field
OUT.filtering_mode = LIBRAW_FILTERING_AUTOMATIC;
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
if(verbosity>1)
RawProcessor.set_progress_handler(my_progress_callback,(void*)"Sample data passed");
#ifdef _OPENMP
if(verbosity)
printf ("Using %d threads\n", omp_get_max_threads());
#endif
for ( ; arg < argc; arg++)
{
char outfn[1024];
if(verbosity) printf("Processing file %s\n",argv[arg]);
#ifndef WIN32
if(use_mmap)
{
int file = open(argv[arg],O_RDONLY);
struct stat st;
if(file<0)
{
fprintf(stderr,"Cannot open %s: %s\n",argv[arg],strerror(errno));
continue;
}
if(fstat(file,&st))
{
fprintf(stderr,"Cannot stat %s: %s\n",argv[arg],strerror(errno));
close(file);
continue;
}
int pgsz = getpagesize();
msize = ((st.st_size+pgsz-1)/pgsz)*pgsz;
iobuffer = mmap(NULL,msize,PROT_READ,MAP_PRIVATE,file,0);
if(!iobuffer)
{
fprintf(stderr,"Cannot mmap %s: %s\n",argv[arg],strerror(errno));
close(file);
continue;
}
close(file);
if( (ret = RawProcessor.open_buffer(iobuffer,st.st_size) != LIBRAW_SUCCESS))
{
fprintf(stderr,"Cannot open_buffer %s: %s\n",argv[arg],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
}
else
#endif
{
if( (ret = RawProcessor.open_file(argv[arg])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",argv[arg],libraw_strerror(ret));
continue; // no recycle b/c open_file will recycle itself
}
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",argv[arg],libraw_strerror(ret));
continue;
}
if (LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_process()))
{
fprintf(stderr,"Cannot do postpocessing on %s: %s\n",argv[arg],libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue;
}
snprintf(outfn,sizeof(outfn),
"%s.%s",
argv[arg], OUT.output_tiff ? "tiff" : (P1.colors>1?"ppm":"pgm"));
if(verbosity) printf("Writing file %s\n",outfn);
if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));
#ifndef WIN32
if(use_mmap && iobuffer)
{
munmap(iobuffer,msize);
iobuffer=0;
}
#endif
RawProcessor.recycle(); // just for show this call
}
return 0;
}

@ -0,0 +1,83 @@
/* -*- C++ -*-
* File: dcraw_half.c
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw C API sample (emulates call to "dcraw -h")
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "libraw/libraw.h"
#define HANDLE_FATAL_ERROR(ret)\
if(ret)\
{\
fprintf(stderr,"%s: libraw %s\n",av[i],libraw_strerror(ret));\
if(LIBRAW_FATAL_ERROR(ret))\
exit(1); \
}\
#define HANDLE_ALL_ERRORS(ret)\
if(ret)\
{\
fprintf(stderr,"%s: libraw %s\n",av[i],libraw_strerror(ret));\
continue; \
}\
int main(int ac, char *av[])
{
int i;
libraw_data_t *iprc = libraw_init(0);
if(!iprc)
{
fprintf(stderr,"Cannot create libraw handle\n");
exit(1);
}
iprc->params.half_size = 1; /* dcraw -h */
for (i=1;i<ac;i++)
{
char outfn[1024];
int ret = libraw_open_file(iprc,av[i]);
HANDLE_ALL_ERRORS(ret);
printf("Processing %s (%s %s)\n",av[i],iprc->idata.make,iprc->idata.model);
ret = libraw_unpack(iprc);
HANDLE_ALL_ERRORS(ret);
ret = libraw_dcraw_process(iprc);
HANDLE_ALL_ERRORS(ret);
strcpy(outfn,av[i]);
strcat(outfn,".ppm");
printf("Writing to %s\n",outfn);
ret = libraw_dcraw_ppm_tiff_writer(iprc,outfn);
HANDLE_FATAL_ERROR(ret);
}
libraw_close(iprc);
return 0;
}

@ -0,0 +1,178 @@
/* -*- C++ -*-
* File: halt_mt.c
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw C API mutithreaded sample (emulates call to "dcraw -h [-w] [-a] [-v]")
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <pthread.h>
#include "libraw/libraw.h"
#define HANDLE_ERRORS(ret) do { \
if(ret) \
{ \
fprintf(stderr,"%s: %s\n",fn,libraw_strerror(ret)); \
if(LIBRAW_FATAL_ERROR(ret)) \
{ \
libraw_close(iprc); \
return -1; \
} \
} \
}while(0)
// global settings
int verbose=0,use_camera_wb=0,use_auto_wb=0,tiff_mode=0;
// global file queue
pthread_mutex_t qm;
char **queue=NULL;
size_t qsize=0,qptr=0;
char *get_next_file()
{
char *ret;
if(!queue) return NULL;
if(qptr>=qsize) return NULL;
pthread_mutex_lock(&qm);
ret = queue[qptr++];
pthread_mutex_unlock(&qm);
return ret;
}
// thread routine
int process_files(void *q)
{
int ret;
int count=0;
char outfn[1024], *fn;
libraw_data_t *iprc = libraw_init(0);
if(!iprc)
{
fprintf(stderr,"Cannot create libraw handle\n");
return -1;
}
while((fn = get_next_file()))
{
iprc->params.half_size = 1; /* dcraw -h */
iprc->params.use_camera_wb = use_camera_wb;
iprc->params.use_auto_wb = use_auto_wb;
iprc->params.output_tiff = tiff_mode;
ret = libraw_open_file(iprc,fn);
if(verbose) fprintf(stderr,"%s: %s/%s\n",fn,iprc->idata.make,iprc->idata.model);
HANDLE_ERRORS(ret);
ret = libraw_unpack(iprc);
HANDLE_ERRORS(ret);
ret = libraw_dcraw_process(iprc);
HANDLE_ERRORS(ret);
snprintf(outfn,1023,"%s.ppm",fn);
if(verbose) fprintf(stderr,"Writing file %s\n",outfn);
ret = libraw_dcraw_ppm_tiff_writer(iprc,outfn);
HANDLE_ERRORS(ret);
count++;
}
libraw_close(iprc);
return count;
}
void usage(const char*p)
{
printf("%s: Multi-threaded LibRaw sample app. Emulates dcraw -h [-w] [-a]\n",p);
printf(
"Options:\n"
"-J n - set parrallel job coun (default 2)\n"
"-v - verbose\n"
"-w - use camera white balance\n"
"-a - average image for white balance\n");
exit(1);
}
int show_files(void *q)
{
char *p;
int cnt = 0;
while(p = get_next_file())
{
printf("%s\n",p);
cnt++;
}
return cnt;
}
int main(int ac, char *av[])
{
int i, thread_count,max_threads = 2;
pthread_t *threads;
if(ac<2)
usage(av[0]);
queue = calloc(ac-1,sizeof(queue[0]));
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='w') use_camera_wb = 1;
if(av[i][1]=='a') use_auto_wb = 1;
if(av[i][1]=='v') verbose = 1;
if(av[i][1]=='T') tiff_mode = 1;
if(av[i][1]=='J')
{
max_threads=atoi(av[++i]);
if(max_threads<1)
{
fprintf(stderr,"Job count should be at least 1\n");
exit(1);
}
}
}
else
queue[qsize++] = av[i];
}
pthread_mutex_init(&qm,NULL);
threads = calloc(max_threads,sizeof(threads[0]));
for(i=0;i<max_threads;i++)
pthread_create(&threads[i],NULL,process_files,NULL);
for(i=0;i<max_threads;i++)
{
int *iptr;
if(threads[i])
{
pthread_join(threads[i],&iptr);
if(iptr)
printf("Thread %d : %d files\n",i,(int)iptr);
}
}
return 0;
}

@ -0,0 +1,212 @@
/* -*- C++ -*-
* File: halt_mt_win32.c
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw C API mutithreaded sample (emulates call to "dcraw -h [-w] [-a] [-v]")
* Win32 version
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <windows.h>
#include "libraw/libraw.h"
#ifdef WIN32
#define snprintf _snprintf
#endif
#define HANDLE_ERRORS(ret) do { \
if(ret) \
{ \
fprintf(stderr,"%s: %s\n",fn,libraw_strerror(ret)); \
if(LIBRAW_FATAL_ERROR(ret)) \
{ \
libraw_close(iprc); \
return -1; \
} \
} \
}while(0)
// global settings
int verbose=0,use_camera_wb=0,use_auto_wb=0,tiff_mode=0;
// global file queue
HANDLE qmutex;
char **queue=NULL;
size_t qsize=0,qptr=0;
char *get_next_file()
{
char *ret;
DWORD dwWaitResult;
if(!queue) return NULL;
if(qptr>=qsize) return NULL;
dwWaitResult = WaitForSingleObject(
qmutex, // handle to mutex
INFINITE); // no time-out interval
switch (dwWaitResult)
{
// The thread got ownership of the mutex
case WAIT_OBJECT_0:
ret = queue[qptr++];
ReleaseMutex(qmutex);
break;
case WAIT_ABANDONED:
return NULL; // cannot obtain the lock
};
return ret;
}
// thread routine
int process_files(void *q)
{
int ret;
int count=0;
char outfn[1024], *fn;
libraw_data_t *iprc = libraw_init(0);
if(!iprc)
{
fprintf(stderr,"Cannot create libraw handle\n");
return -1;
}
while((fn = get_next_file()))
{
iprc->params.half_size = 1; /* dcraw -h */
iprc->params.use_camera_wb = use_camera_wb;
iprc->params.use_auto_wb = use_auto_wb;
iprc->params.output_tiff = tiff_mode;
ret = libraw_open_file(iprc,fn);
if(verbose) fprintf(stderr,"%s: %s/%s\n",fn,iprc->idata.make,iprc->idata.model);
HANDLE_ERRORS(ret);
ret = libraw_unpack(iprc);
HANDLE_ERRORS(ret);
ret = libraw_dcraw_process(iprc);
HANDLE_ERRORS(ret);
snprintf(outfn,1023,"%s.%s",fn,tiff_mode?"tif":"ppm");
if(verbose) fprintf(stderr,"Writing file %s\n",outfn);
ret = libraw_dcraw_ppm_tiff_writer(iprc,outfn);
HANDLE_ERRORS(ret);
count++;
}
libraw_close(iprc);
printf("Processed %d files\n",count);
return 0;
}
void usage(const char*p)
{
printf(
"Options:\n"
"-J n - set parrallel job coun (default 2)\n"
"-v - verbose\n"
"-w - use camera white balance\n"
"-T - output TIFF instead of PPM\n"
"-a - average image for white balance\n");
exit(1);
}
int show_files(void *q)
{
char *p;
int cnt = 0;
while(p = get_next_file())
{
printf("%s\n",p);
cnt++;
}
return cnt;
}
int main(int ac, char *av[])
{
int i,max_threads = 2;
HANDLE *threads;
DWORD ThreadID;
if(ac<2)
usage(av[0]);
queue = calloc(ac-1,sizeof(queue[0]));
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='w') use_camera_wb = 1;
if(av[i][1]=='a') use_auto_wb = 1;
if(av[i][1]=='v') verbose = 1;
if(av[i][1]=='T') tiff_mode = 1;
if(av[i][1]=='J')
{
max_threads=atoi(av[++i]);
if(max_threads<1)
{
fprintf(stderr,"Job count should be at least 1\n");
exit(1);
}
}
}
else
queue[qsize++] = av[i];
}
qmutex = CreateMutex(NULL,FALSE,NULL);
threads = calloc(max_threads,sizeof(threads[0]));
for(i=0;i<max_threads;i++)
{
if (NULL == (threads[i] = CreateThread(
NULL, // default security attributes
0, // default stack size
(LPTHREAD_START_ROUTINE) process_files,
NULL, // no thread function arguments
0, // default creation flags
&ThreadID) // receive thread identifier
)
)
{
printf("CreateThread error: %d\n", GetLastError());
return 1;
}
}
WaitForMultipleObjects(max_threads, threads, TRUE, INFINITE);
// Close thread and mutex handles
for( i=0; i < max_threads; i++ )
CloseHandle(threads[i]);
CloseHandle(qmutex);
return 0;
}

@ -0,0 +1,147 @@
/* -*- C++ -*-
* File: identify.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw C++ demo (emulates dcraw -i [-v])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include "libraw/libraw.h"
#ifdef WIN32
#define snprintf _snprintf
#endif
int main(int ac, char *av[])
{
int verbose = 0, ret,print_unpack=0,print_frame=0;
LibRaw MyCoolRawProcessor;
for (int i=1;i<ac;i++) {
if(av[i][0]=='-')
{
if(av[i][1]=='v' && av[i][2]==0) verbose++;
if(av[i][1]=='u' && av[i][2]==0) print_unpack++;
if(av[i][1]=='f' && av[i][2]==0) print_frame++;
continue;
}
if( (ret = MyCoolRawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
printf("Cannot decode %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle, open_file will recycle
}
if(verbose) {
#define P1 MyCoolRawProcessor.imgdata.idata
#define P2 MyCoolRawProcessor.imgdata.other
#define S MyCoolRawProcessor.imgdata.sizes
#define O MyCoolRawProcessor.imgdata.params
#define C MyCoolRawProcessor.imgdata.color
#define T MyCoolRawProcessor.imgdata.thumbnail
if( (ret = MyCoolRawProcessor.adjust_sizes_info_only()))
{
printf("Cannot decode %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle, open_file will recycle
}
printf ("\nFilename: %s\n", av[i]);
printf ("Timestamp: %s", ctime(&(P2.timestamp)));
printf ("Camera: %s %s\n", P1.make, P1.model);
if (P2.artist[0])
printf ("Owner: %s\n", P2.artist);
if (P1.dng_version) {
printf ("DNG Version: ");
for (int i=24; i >= 0; i -= 8)
printf ("%d%c", P1.dng_version >> i & 255, i ? '.':'\n');
}
printf ("ISO speed: %d\n", (int) P2.iso_speed);
printf ("Shutter: ");
if (P2.shutter > 0 && P2.shutter < 1)
P2.shutter = (printf ("1/"), 1 / P2.shutter);
printf ("%0.1f sec\n", P2.shutter);
printf ("Aperture: f/%0.1f\n", P2.aperture);
printf ("Focal length: %0.1f mm\n", P2.focal_len);
if(C.profile)
printf ("Embedded ICC profile: yes, %d bytes\n", C.profile_length);
else
printf ("Embedded ICC profile: no\n", C.profile_length);
printf ("Number of raw images: %d\n", P1.raw_count);
if (S.pixel_aspect != 1)
printf ("Pixel Aspect Ratio: %0.6f\n", S.pixel_aspect);
if (T.tlength)
printf ("Thumb size: %4d x %d\n", T.twidth, T.theight);
printf ("Full size: %4d x %d\n", S.raw_width, S.raw_height);
printf ("Image size: %4d x %d\n", S.width, S.height);
printf ("Output size: %4d x %d\n", S.iwidth, S.iheight);
printf ("Raw colors: %d", P1.colors);
if (P1.filters)
{
printf ("\nFilter pattern: ");
if (!P1.cdesc[3]) P1.cdesc[3] = 'G';
for (int i=0; i < 16; i++)
putchar (P1.cdesc[MyCoolRawProcessor.fc(i >> 1,i & 1)]);
}
printf ("\nDaylight multipliers:");
for(int c=0;c<P1.colors;c++) printf (" %f", C.pre_mul[c]);
if (C.cam_mul[0] > 0)
{
printf ("\nCamera multipliers:");
for(int c=0;c<4;c++) printf (" %f", C.cam_mul[c]);
}
char *csl[] = {"U","I","CO","L","CA"};
printf("\nColor sources /Legend: (U)nknown, (I)nit, (CO)nstant, (L)oaded, (CA)lculated/:\n");
printf("\tcurve=%s; rgb_cam=%s; cmatrix=%s, pre_mul=%s, cam_mul=%s",
csl[C.color_flags.curve_state],csl[C.color_flags.rgb_cam_state],
csl[C.color_flags.cmatrix_state],csl[C.color_flags.pre_mul_state],
csl[C.color_flags.cam_mul_state]);
putchar ('\n');
printf("Cam->XYZ matrix:\n");
for(int i=0; i< 4; i++)
printf("%6.4f\t%6.4f\t%6.4f\n",C.cam_xyz[i][0],C.cam_xyz[i][1],C.cam_xyz[i][2]);
}
else
{
if(print_unpack)
{
char frame[32]="";
if(print_frame)
snprintf(frame,32,"%dx%dx%dx%d",S.left_margin,S.top_margin,S.right_margin,S.bottom_margin);
printf ("%s\t%s\t%s\t%s/%s\n",
av[i],
MyCoolRawProcessor.unpack_function_name(),
frame,
P1.make, P1.model);
}
else
printf ("%s is a %s %s image.\n", av[i],P1.make, P1.model);
}
MyCoolRawProcessor.recycle();
}// endfor
return 0;
}

@ -0,0 +1,198 @@
/* -*- C++ -*-
* File: mem_image.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw mem_image/mem_thumb API test. Resuls should be same (bitwise) as in dcraw [-4] [-e]
* Testing note: for ppm-thumbnails you should use dcraw -w -e for thumbnail extraction
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "libraw/libraw.h"
#ifdef WIN32
#define snprintf _snprintf
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#else
#include <netinet/in.h>
#endif
// no error reporting, only params check
void write_ppm(libraw_processed_image_t *img, const char *basename)
{
if(!img) return;
// type SHOULD be LIBRAW_IMAGE_BITMAP, but we'll check
if(img->type != LIBRAW_IMAGE_BITMAP) return;
// only 3-color images supported...
if(img->colors != 3) return;
char fn[1024];
snprintf(fn,1024,"%s.ppm",basename);
FILE *f = fopen(fn,"wb");
if(!f) return;
fprintf (f, "P6\n%d %d\n%d\n", img->width, img->height, (1 << img->bits)-1);
/*
NOTE:
data in img->data is not converted to network byte order.
So, we should swap values on some architectures for dcraw compatibility
(unfortunately, xv cannot display 16-bit PPMs with network byte order data
*/
#define SWAP(a,b) { a ^= b; a ^= (b ^= a); }
if (img->bits == 16 && htons(0x55aa) != 0x55aa)
for(int i=0; i< img->data_size; i+=2)
SWAP(img->data[i],img->data[i+1]);
#undef SWAP
fwrite(img->data,img->data_size,1,f);
fclose(f);
}
void write_thumb(libraw_processed_image_t *img, const char *basename)
{
if(!img) return;
if(img->type == LIBRAW_IMAGE_BITMAP)
{
char fnt[1024];
snprintf(fnt,1024,"%s.thumb",basename);
write_ppm(img,fnt);
}
else if (img->type == LIBRAW_IMAGE_JPEG)
{
char fn[1024];
snprintf(fn,1024,"%s.thumb.jpg",basename);
FILE *f = fopen(fn,"wb");
if(!f) return;
fwrite(img->data,img->data_size,1,f);
fclose(f);
}
}
int main(int ac, char *av[])
{
int i, ret, verbose=0, output_thumbs=0;
// don't use fixed size buffers in real apps!
char outfn[1024],thumbfn[1024];
LibRaw RawProcessor;
if(ac<2)
{
printf(
"mem_image - LibRaw sample, to illustrate work for memory buffers. Emulates dcraw [-4] [-1] [-e]\n"
"Usage: %s [-D] [-T] [-v] [-e] raw-files....\n"
"\t-4 - output 16-bit PPM\n"
"\t-1 - gamma-correct 16-bit data\n"
"\t-e - extract thumbnails (same as dcraw -e in separate run)\n",
av[0]);
return 0;
}
putenv ((char*)"TZ=UTC"); // dcraw compatibility, affects TIFF datestamp field
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='4' && av[i][2]==0)
OUT.output_bps = 16;
if(av[i][1]=='1' && av[i][2]==0)
OUT.gamma_16bit = 1;
if(av[i][1]=='e' && av[i][2]==0)
output_thumbs++;
continue;
}
printf("Processing %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
// we should call dcraw_process before thumbnail extraction because for
// some cameras (i.e. Kodak ones) white balance for thumbnal should be set
// from main image settings
ret = RawProcessor.dcraw_process();
if(LIBRAW_SUCCESS !=ret)
{
fprintf(stderr,"Cannot do postpocessing on %s: %s\n",
av[i],libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue;
}
libraw_processed_image_t *image = RawProcessor.dcraw_make_mem_image(&ret);
if(image)
{
write_ppm(image,av[i]);
free(image);
}
else
fprintf(stderr,"Cannot unpack %s to memory buffer: %s\n" , av[i],libraw_strerror(ret));
if(output_thumbs)
{
if( (ret = RawProcessor.unpack_thumb() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack_thumb %s: %s\n",av[i],libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue; // skip to next file
}
else
{
libraw_processed_image_t *thumb = RawProcessor.dcraw_make_mem_thumb(&ret);
if(thumb)
{
write_thumb(thumb,av[i]);
free(thumb);
}
else
fprintf(stderr,"Cannot unpack thumbnail of %s to memory buffer: %s\n" , av[i],libraw_strerror(ret));
}
}
RawProcessor.recycle(); // just for show this call
}
return 0;
}

@ -0,0 +1,213 @@
/* -*- C++ -*-
* File: simple_dcraw.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw simple C++ API (emulates call to "dcraw [-D] [-T] [-v] [-e] [-4]")
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifndef WIN32
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#endif
#include "libraw/libraw.h"
#ifdef WIN32
#define snprintf _snprintf
#endif
int my_progress_callback(void *unused_data,enum LibRaw_progress state,int iter, int expected)
{
if(iter==0)
printf("CB: state=%x, expected %d iterations\n",state,expected);
return 0;
}
int main(int ac, char *av[])
{
int i, ret, verbose=0, output_thumbs=0,use_mmap=0,msize;
void *file_buffer;
// don't use fixed size buffers in real apps!
char outfn[1024],thumbfn[1024];
LibRaw RawProcessor;
if(ac<2)
{
printf(
"simple_dcraw - LibRaw %s sample. Emulates dcraw [-D] [-T] [-v] [-e] [-B]\n"
" %d cameras supported\n"
"Usage: %s [-D] [-T] [-v] [-e] raw-files....\n"
"\t-D - document mode emulation\n"
"\t-4 - 16-bit mode\n"
"\t-v - verbose output\n"
"\t-T - output TIFF files instead of .pgm/ppm\n"
#ifndef WIN32
"\t-B - use mmap()-ed I/O (Unix only)\n"
#endif
"\t-e - extract thumbnails (same as dcraw -e in separate run)\n",LibRaw::version(),
LibRaw::cameraCount(),
av[0]);
return 0;
}
putenv ((char*)"TZ=UTC"); // dcraw compatibility, affects TIFF datestamp field
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='T' && av[i][2]==0)
OUT.output_tiff=1;
if(av[i][1]=='v' && av[i][2]==0)
verbose++;
if(av[i][1]=='e' && av[i][2]==0)
output_thumbs++;
if(av[i][1]=='D' && av[i][2]==0)
OUT.document_mode=2;
if(av[i][1]=='B' && av[i][2]==0)
use_mmap=1;
if(av[i][1]=='4' && av[i][2]==0)
OUT.output_bps=16;
if(av[i][1]=='C' && av[i][2]==0)
RawProcessor.set_progress_handler(my_progress_callback,NULL);
continue;
}
if(verbose) printf("Processing file %s\n",av[i]);
#ifndef WIN32
if(use_mmap)
{
int file = open(av[i],O_RDONLY);
struct stat st;
if(file<0)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],strerror(errno));
continue;
}
if(fstat(file,&st))
{
fprintf(stderr,"Cannot stat %s: %s\n",av[i],strerror(errno));
close(file);
continue;
}
int pgsz = getpagesize();
msize = ((st.st_size+pgsz-1)/pgsz)*pgsz;
file_buffer = mmap(NULL,msize,PROT_READ,MAP_PRIVATE,file,0);
if(!file_buffer)
{
fprintf(stderr,"Cannot mmap %s: %s\n",av[i],strerror(errno));
close(file);
continue;
}
close(file);
if( (ret = RawProcessor.open_buffer(file_buffer,st.st_size) != LIBRAW_SUCCESS))
{
fprintf(stderr,"Cannot open_buffer %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
}
else
#endif
{
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open_file %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
// thumbnail unpacking and output in the middle of main
// image processing - for test purposes!
if(output_thumbs)
{
if( (ret = RawProcessor.unpack_thumb() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack_thumb %s: %s\n",av[i],libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue; // skip to next file
}
else
{
snprintf(thumbfn,sizeof(thumbfn),"%s.%s",
av[i],T.tformat == LIBRAW_THUMBNAIL_JPEG ? "thumb.jpg" : "thumb.ppm");
if(verbose) printf("Writing thumbnail file %s\n",thumbfn);
if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_thumb_writer(thumbfn)))
{
fprintf(stderr,"Cannot write %s: %s\n",thumbfn,libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue;
}
}
}
if(OUT.document_mode)
ret = RawProcessor.dcraw_document_mode_processing();
else
ret = RawProcessor.dcraw_process();
if(LIBRAW_SUCCESS !=ret)
{
fprintf(stderr,"Cannot do postpocessing on %s: %s\n",
av[i],libraw_strerror(ret));
if(LIBRAW_FATAL_ERROR(ret))
continue;
}
snprintf(outfn,sizeof(outfn),
"%s.%s",
av[i], OUT.output_tiff ? "tiff" : (P1.colors>1?"ppm":"pgm"));
if(verbose) printf("Writing file %s\n",outfn);
if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));
#ifndef WIN32
if(use_mmap && file_buffer)
{
munmap(file_buffer,msize);
file_buffer=0;
}
#endif
RawProcessor.recycle(); // just for show this call
}
return 0;
}

@ -0,0 +1,156 @@
/* -*- C++ -*-
* File: unprocessed_raw.cpp
* Copyright 2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Fri Jan 02, 2009
*
* LibRaw sample
* Generates unprocessed raw image: with masked pixels and without black subtraction
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifndef WIN32
#include <netinet/in.h>
#else
#include <winsock2.h>
#endif
#include "libraw/libraw.h"
#ifdef WIN32
#define snprintf _snprintf
#endif
int main(int ac, char *av[])
{
int i, ret;
int verbose=1,autoscale=0;
char outfn[1024],thumbfn[1024];
LibRaw RawProcessor;
if(ac<2)
{
usage:
printf(
"unprocessed_raw - LibRaw %s sample. %d cameras supported\n"
"Usage: %s [-q] [-A] [-g] [-s N] [-N] raw-files....\n"
"\t-q - be quiet\n"
"\t-s N - select Nth image in file (default=0)\n"
"\t-g - use gamma correction with gamma 2.2 (not precise,use for visual inspection only)\n"
"\t-A - autoscaling (by integer factor)\n"
"\t-N - no raw curve\n"
,LibRaw::version(),
LibRaw::cameraCount(),
av[0]);
return 0;
}
#define P1 RawProcessor.imgdata.idata
#define S RawProcessor.imgdata.sizes
#define C RawProcessor.imgdata.color
#define T RawProcessor.imgdata.thumbnail
#define P2 RawProcessor.imgdata.other
#define OUT RawProcessor.imgdata.params
OUT.document_mode=2;
OUT.output_bps=16;
OUT.output_tiff=1;
OUT.user_flip=0;
OUT.no_auto_bright = 1;
OUT.filtering_mode=(LibRaw_filtering)( LIBRAW_FILTERING_NOBLACKS|LIBRAW_FILTERING_NOZEROES);
for (i=1;i<ac;i++)
{
if(av[i][0]=='-')
{
if(av[i][1]=='q' && av[i][2]==0)
verbose=0;
else if(av[i][1]=='A' && av[i][2]==0)
autoscale=1;
else if(av[i][1]=='g' && av[i][2]==0)
OUT.gamma_16bit=1;
else if(av[i][1]=='N' && av[i][2]==0)
OUT.filtering_mode=LIBRAW_FILTERING_NONE;
else if(av[i][1]=='s' && av[i][2]==0)
{
i++;
OUT.shot_select=atoi(av[i]);
}
else
goto usage;
continue;
}
int r,c;
if(verbose) printf("Processing file %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot open %s: %s\n",av[i],libraw_strerror(ret));
continue; // no recycle b/c open file will recycle itself
}
if(verbose)
{
printf("Image size: %dx%d\nRaw size: %dx%d\n",S.width,S.height,S.raw_width,S.raw_height);
printf("Margins: top=%d, left=%d, right=%d, bottom=%d\n",
S.top_margin,S.left_margin,S.right_margin,S.bottom_margin);
}
if( (ret = RawProcessor.unpack() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
if(verbose)
printf("Unpacked....\n");
if( (ret = RawProcessor.add_masked_borders_to_bitmap() ) != LIBRAW_SUCCESS)
{
fprintf(stderr,"Cannot add mask data to bitmap %s\n",av[i]);
}
for(int r=0;r<S.iheight;r++)
for(c=0;c<S.iwidth;c++)
RawProcessor.imgdata.image[r*S.iwidth+c][0]
= RawProcessor.imgdata.image[r*S.iwidth+c][RawProcessor.FC(r,c)];
P1.colors=1;
if(autoscale)
{
unsigned max=0,scale;
for(int j=0; j<S.iheight*S.iwidth; j++)
if(max < RawProcessor.imgdata.image[j][0])
max = RawProcessor.imgdata.image[j][0];
if (max >0 && max< 1<<15)
{
scale = (1<<16)/max;
if(verbose)
printf("Scaling with multiplier=%d (max=%d)\n",scale,max);
for(int j=0; j<S.iheight*S.iwidth; j++)
RawProcessor.imgdata.image[j][0] *= scale;
}
}
if(OUT.shot_select)
snprintf(outfn,sizeof(outfn),"%s-%d.tiff",av[i],OUT.shot_select);
else
snprintf(outfn,sizeof(outfn),"%s.tiff",av[i]);
if(verbose) printf("Writing file %s\n",outfn);
if( LIBRAW_SUCCESS != (ret = RawProcessor.dcraw_ppm_tiff_writer(outfn)))
fprintf(stderr,"Cannot write %s: %s\n",outfn,libraw_strerror(ret));
}
return 0;
}

@ -0,0 +1,143 @@
/* -*- C++ -*-
* File: libraw_c_api.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Created: Sat Mar 8 , 2008
*
* LibRaw C++ interface (implementation)
*/
#include <errno.h>
#include "libraw/libraw.h"
#ifdef __cplusplus
extern "C"
{
#endif
libraw_data_t *libraw_init(unsigned int flags)
{
LibRaw *ret = new LibRaw(flags);
return &(ret->imgdata);
}
const char* libraw_version() { return LibRaw::version();}
const char* libraw_strprogress(enum LibRaw_progress p) { return LibRaw::strprogress(p);}
int libraw_versionNumber() { return LibRaw::versionNumber();}
const char** libraw_cameraList() { return LibRaw::cameraList();}
int libraw_cameraCount() { return LibRaw::cameraCount(); }
const char* libraw_unpack_function_name(libraw_data_t* lr)
{
if(!lr) return "NULL parameter passed";
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->unpack_function_name();
}
int libraw_rotate_fuji_raw(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->rotate_fuji_raw();
}
int libraw_add_masked_borders_to_bitmap(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->add_masked_borders_to_bitmap();
}
int libraw_open_file(libraw_data_t* lr, const char *file)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->open_file(file);
}
int libraw_open_buffer(libraw_data_t* lr, void *buffer, size_t size)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->open_buffer(buffer,size);
}
int libraw_unpack(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->unpack();
}
int libraw_unpack_thumb(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->unpack_thumb();
}
void libraw_recycle(libraw_data_t* lr)
{
if(!lr) return;
LibRaw *ip = (LibRaw*) lr->parent_class;
ip->recycle();
}
void libraw_close(libraw_data_t* lr)
{
if(!lr) return;
LibRaw *ip = (LibRaw*) lr->parent_class;
delete ip;
}
void libraw_set_memerror_handler(libraw_data_t* lr, memory_callback cb,void *data)
{
if(!lr) return;
LibRaw *ip = (LibRaw*) lr->parent_class;
ip->set_memerror_handler(cb,data);
}
void libraw_set_dataerror_handler(libraw_data_t* lr,data_callback func,void *data)
{
if(!lr) return;
LibRaw *ip = (LibRaw*) lr->parent_class;
ip->set_dataerror_handler(func,data);
}
void libraw_set_progress_handler(libraw_data_t* lr, progress_callback cb,void *data)
{
if(!lr) return;
LibRaw *ip = (LibRaw*) lr->parent_class;
ip->set_progress_handler(cb,data);
}
// DCRAW
int libraw_adjust_sizes_info_only(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->adjust_sizes_info_only();
}
int libraw_dcraw_document_mode_processing(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->dcraw_document_mode_processing();
}
int libraw_dcraw_ppm_tiff_writer(libraw_data_t* lr,const char *filename)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->dcraw_ppm_tiff_writer(filename);
}
int libraw_dcraw_thumb_writer(libraw_data_t* lr,const char *fname)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->dcraw_thumb_writer(fname);
}
int libraw_dcraw_process(libraw_data_t* lr)
{
if(!lr) return EINVAL;
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->dcraw_process();
}
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

@ -0,0 +1,51 @@
KDE_OPTIONS = nofinal
METASOURCES = AUTO
# LibRaw definitions
KDE_CXXFLAGS = $(USE_EXCEPTIONS) -DDCRAW_VERBOSE -DUSE_LCMS
INCLUDES = -I../libraw -I../libkdcraw $(all_includes)
check_PROGRAMS = raw2png identify simple_dcraw mem_image dcraw_emu 4channels unprocessed_raw
# -------------------------------------------------------------
raw2png_CFLAGS = $(all_includes)
raw2png_SOURCES = raw2png.cpp
raw2png_LDFLAGS = $(all_libraries) ../libkdcraw/libkdcraw.la
# -------------------------------------------------------------
identify_CFLAGS = $(all_includes)
identify_SOURCES = ../libraw/samples/identify.cpp
identify_LDFLAGS = $(all_libraries) ../libraw/libraw.la
# -------------------------------------------------------------
simple_dcraw_CFLAGS = $(all_includes)
simple_dcraw_SOURCES = ../libraw/samples/simple_dcraw.cpp
simple_dcraw_LDFLAGS = $(all_libraries) ../libraw/libraw.la
# -------------------------------------------------------------
mem_image_CFLAGS = $(all_includes)
mem_image_SOURCES = ../libraw/samples/mem_image.cpp
mem_image_LDFLAGS = $(all_libraries) ../libraw/libraw.la
# -------------------------------------------------------------
dcraw_emu_CFLAGS = $(all_includes)
dcraw_emu_SOURCES = ../libraw/samples/dcraw_emu.cpp
dcraw_emu_LDFLAGS = $(all_libraries) ../libraw/libraw.la
# -------------------------------------------------------------
4channels_CFLAGS = $(all_includes)
4channels_SOURCES = ../libraw/samples/4channels.cpp
4channels_LDFLAGS = $(all_libraries) ../libraw/libraw.la
# -------------------------------------------------------------
unprocessed_raw_CFLAGS = $(all_includes)
unprocessed_raw_SOURCES = ../libraw/samples/unprocessed_raw.cpp
unprocessed_raw_LDFLAGS = $(all_libraries) ../libraw/libraw.la

@ -0,0 +1,123 @@
/* ============================================================
*
* This file is a part of kipi-plugins project
* http://www.kipi-plugins.org
*
* Date : 2008-15-09
* Description : a command line tool to convert RAW file to PNG
*
* Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* This program is free software; you can redistribute it
* and/or modify it under the terms of the GNU General
* Public License as published by the Free Software Foundation;
* either version 2, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* ============================================================ */
// Qt includes.
#include <qstring.h>
#include <qfile.h>
#include <qfileinfo.h>
// KDE includes.
#include "kdeversion.h"
#if KDE_IS_VERSION(4,0,0)
#include "qdebug.h"
#define PRINT_DEBUG qDebug()
#define ENDL
#else
#include "kdebug.h"
#define PRINT_DEBUG kdDebug()
#define ENDL << endl
#endif
// Local includes.
#include "kdcraw.h"
using namespace KDcrawIface;
int main (int argc, char **argv)
{
if(argc != 2)
{
PRINT_DEBUG << "raw2png - RAW Camera Image to PNG Converter" ENDL;
PRINT_DEBUG << "Usage: <rawfile>" ENDL;
return -1;
}
QString filePath(argv[1]);
QFileInfo input(filePath);
QString previewFilePath(input.baseName() + QString(".preview.png"));
QFileInfo previewOutput(previewFilePath);
QString halfFilePath(input.baseName() + QString(".half.png"));
QFileInfo halfOutput(halfFilePath);
QImage image;
DcrawInfoContainer identify;
// -----------------------------------------------------------
PRINT_DEBUG << "raw2png: Identify RAW image from " << input.fileName() ENDL;
KDcraw rawProcessor;
if (!rawProcessor.rawFileIdentify(identify, filePath))
{
PRINT_DEBUG << "raw2png: Idendify RAW image failed. Aborted..." ENDL;
return -1;
}
int width = identify.imageSize.width();
int height = identify.imageSize.height();
PRINT_DEBUG << "raw2png: Raw image info:" ENDL;
PRINT_DEBUG << "--- Date: " << identify.dateTime.toString(Qt::ISODate) ENDL;
PRINT_DEBUG << "--- Make: " << identify.make ENDL;
PRINT_DEBUG << "--- Model: " << identify.model ENDL;
PRINT_DEBUG << "--- Size: " << width << "x" << height ENDL;
PRINT_DEBUG << "--- Filter: " << identify.filterPattern ENDL;
PRINT_DEBUG << "--- Colors: " << identify.rawColors ENDL;
// -----------------------------------------------------------
PRINT_DEBUG << "raw2png: Loading RAW image preview" ENDL;
if (!rawProcessor.loadDcrawPreview(image, filePath))
{
PRINT_DEBUG << "raw2png: Loading RAW image preview failed. Aborted..." ENDL;
return -1;
}
PRINT_DEBUG << "raw2png: Saving preview image to "
<< previewOutput.fileName() << " size ("
<< image.width() << "x" << image.height()
<< ")" ENDL;
image.save(previewFilePath, "PNG");
// -----------------------------------------------------------
PRINT_DEBUG << "raw2png: Loading half RAW image" ENDL;
image = QImage();
if (!rawProcessor.loadHalfPreview(image, filePath))
{
PRINT_DEBUG << "raw2png: Loading half RAW image failed. Aborted..." ENDL;
return -1;
}
PRINT_DEBUG << "raw2png: Saving half image to "
<< halfOutput.fileName() << " size ("
<< image.width() << "x" << image.height()
<< ")" ENDL;
image.save(halfFilePath, "PNG");
return 0;
}

@ -0,0 +1,3 @@
KDE_LANG = pt_BR
SUBDIRS = $(AUTODIRS)
POFILES = AUTO

@ -0,0 +1,413 @@
# translation of libkdcraw.po to Brazilian Portuguese
#
# Luiz Fernando Ranghetti <elchevive@opensuse.org>, 2008.
msgid ""
msgstr ""
"Project-Id-Version: libkdcraw\n"
"POT-Creation-Date: 2008-09-15 08:37+0200\n"
"PO-Revision-Date: 2008-11-27 21:15-0200\n"
"Last-Translator: Luiz Fernando Ranghetti <elchevive@opensuse.org>\n"
"Language-Team: Brazilian Portuguese <kde-i18n-pt_BR@mail.kde.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.4\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: libkdcraw/rcombobox.cpp:73 libkdcraw/rnuminput.cpp:74
#: libkdcraw/rnuminput.cpp:172
msgid "Reset to default value"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:183
msgid "16 bits color depth"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:184
msgid ""
"<p>If enabled, all RAW files will be decoded in 16-bit color depth using a "
"linear gamma curve. To prevent dark picture rendering in the editor, it is "
"recommended to use Color Management in this mode."
"<p>If disabled, all RAW files will be decoded in 8-bit color depth with a "
"BT.709 gamma curve and a 99th-percentile white point. This mode is faster than "
"16-bit decoding."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:203
msgid "Interpolate RGB as four colors"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:204
msgid ""
"<p><b>Interpolate RGB as four colors</b>"
"<p>The default is to assume that all green pixels are the same. If even-row "
"green pixels are more sensitive to ultraviolet light than odd-row this "
"difference causes a mesh pattern in the output; using this option solves this "
"problem with minimal loss of detail."
"<p>To resume, this option blurs the image a little, but it eliminates false 2x2 "
"mesh patterns with VNG quality method or mazes with AHD quality method."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:217
#, c-format
msgid "libraw %1"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:220
msgid "Visit dcraw project website"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:224
msgid "Do not stretch or rotate pixels"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:225
msgid ""
"<p><b>Do not stretch or rotate pixels</b>"
"<p>For Fuji Super CCD cameras, show the image tilted 45 degrees. For cameras "
"with non-square pixels, do not stretch the image to its correct aspect ratio. "
"In any case, this option guarantees that each output pixel corresponds to one "
"RAW pixel."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:235
msgid "Quality:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:237
msgid "Bilinear"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:238
msgid "VNG"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:239
msgid "PPG"
msgstr "PPG"
#: libkdcraw/dcrawsettingswidget.cpp:240
msgid "AHD"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:242
msgid ""
"<p><b>Quality (interpolation)</b>"
"<p>Select here the demosaicing RAW images decoding interpolation method. A "
"demosaicing algorithm is a digital image process used to interpolate a complete "
"image from the partial raw data received from the color-filtered image sensor "
"internal to many digital cameras in form of a matrix of colored pixels. Also "
"known as CFA interpolation or color reconstruction, another common spelling is "
"demosaicing. There are 4 methods to demosaicing RAW images:"
"<p><b>Bilinear</b>: use high-speed but low-quality bilinear interpolation "
"(default - for slow computer). In this method, the red value of a non-red pixel "
"is computed as the average of the adjacent red pixels, and similar for blue and "
"green."
"<p><b>VNG</b>: use Variable Number of Gradients interpolation. This method "
"computes gradients near the pixel of interest and uses the lower gradients "
"(representing smoother and more similar parts of the image) to make an "
"estimate."
"<p><b>PPG</b>: use Patterned Pixel Grouping interpolation. Pixel Grouping uses "
"assumptions about natural scenery in making estimates. It has fewer color "
"artifacts on natural images than the Variable Number of Gradients method."
"<p><b>AHD</b>: use Adaptive Homogeneity-Directed interpolation. This method "
"selects the direction of interpolation so as to maximize a homogeneity metric, "
"thus typically minimizing color artifacts."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:272
msgid "Filter:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:273
msgid ""
"<p><b>Median Filter</b>"
"<p>Set here the passes used by median filter applied after interpolation to "
"Red-Green and Blue-Green channels."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:282
msgid "Demosaicing"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:290
msgid "Method:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:292
msgid "Default D65"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:293
msgid "Camera"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:294
msgid "Automatic"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:295
msgid "Manual"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:297
msgid ""
"<p><b>White Balance Method</b>"
"<p>Configure the raw white balance :"
"<p><b>Default D65</b>: Use a standard daylight D65 white balance (dcraw "
"defaults)"
"<p><b>Camera</b>: Use the white balance specified by the camera. If not "
"available, reverts to default neutral white balance"
"<p><b>Automatic</b>: Calculates an automatic white balance averaging the entire "
"image"
"<p><b>Manual</b>: Set a custom temperature and green level values"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:309
msgid "T(K):"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:310
msgid "<p><b>Temperature</b><p>Set here the color temperature in Kelvin."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:317
msgid "Green:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:318
msgid ""
"<p>Set here the green component to set magenta color cast removal level."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:321
msgid "Highlights:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:323
msgid "Solid white"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:324
msgid "Unclip"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:325
msgid "Blend"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:326
msgid "Rebuild"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:328
msgid ""
"<p><b>Highlights</b>"
"<p>Select here the highlight clipping method:"
"<p><b>Solid white</b>: clip all highlights to solid white"
"<p><b>Unclip</b>: leave highlights unclipped in various shades of pink"
"<p><b>Blend</b>:Blend clipped and unclipped values together for a gradual fade "
"to white"
"<p><b>Rebuild</b>: reconstruct highlights using a level value"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:337
msgid "Level:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:341
msgid ""
"<p><b>Level</b>"
"<p>Specify the reconstruct highlight level. Low values favor whites and high "
"values favor colors."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:345
msgid "Brightness:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:350
msgid ""
"<p><b>Brighness</b>"
"<p>Specify the brightness level of output image.The default value is 1.0 (works "
"in 8-bit mode only)."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:360
msgid "Black:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:361
msgid ""
"<p><b>Black point</b>"
"<p>Use a specific black point value to decode RAW pictures. If you set this "
"option to off, the Black Point value will be automatically computed."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:368
msgid ""
"<p><b>Black point value</b>"
"<p>Specify specific black point value of the output image."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:371
msgid "White:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:372
msgid ""
"<p><b>White point</b>"
"<p>Use a specific white point value to decode RAW pictures. If you set this "
"option to off, the White Point value will be automatically computed."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:379
msgid ""
"<p><b>White point value</b>"
"<p>Specify specific white point value of the output image."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:409
msgid "White Balance"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:417
msgid "Enable noise reduction"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:418
msgid ""
"<p><b>Enable Noise Reduction</b>"
"<p>Use wavelets to erase noise while preserving real detail."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:424
msgid "Threshold:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:425
msgid ""
"<p><b>Threshold</b>"
"<p>Set here the noise reduction threshold value to use."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:428
msgid "Enable Chromatic Aberration correction"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:429
msgid ""
"<p><b>Enable Chromatic Aberration correction</b>"
"<p>Enlarge the raw red and blue layers by the given factors, typically 0.999 to "
"1.001, to correct chromatic aberration."
"<p>"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:433
msgid "Red:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:438
msgid ""
"<p><b>Red multiplier</b>"
"<p>Set here the magnification factor of the red layer"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:441
msgid "Blue:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:446
msgid ""
"<p><b>Blue multiplier</b>"
"<p>Set here the magnification factor of the blue layer"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:461
msgid "Corrections"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:469
msgid "Camera Profile:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:471
msgid "None"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:472
msgid "Embedded"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:473 libkdcraw/dcrawsettingswidget.cpp:492
msgid "Custom"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:475
msgid ""
"<p><b>Camera Profile</b>"
"<p>Select here the input color space used to decode RAW data."
"<p><b>None</b>: no input color profile is used during RAW decoding."
"<p><b>Embedded</b>: use embedded color profile from RAW file if exist."
"<p><b>Custom</b>: use a custom input color space profile."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:483 libkdcraw/dcrawsettingswidget.cpp:513
msgid "ICC Files (*.icc; *.icm)"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:485
msgid "Workspace:"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:487
msgid "Raw (linear)"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:488
msgid "sRGB"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:489
msgid "Adobe RGB"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:490
msgid "Wide Gamut"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:491
msgid "Pro-Photo"
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:494
msgid ""
"<p><b>Workspace</b>"
"<p>Select here the output color space used to decode RAW data."
"<p><b>Raw (linear)</b>: in this mode, no output color space is used during RAW "
"decoding."
"<p><b>sRGB</b>: this is a RGB color space, created cooperatively by "
"Hewlett-Packard and Microsoft. It is the best choice for images destined for "
"the Web and portrait photography."
"<p><b>Adobe RGB</b>: this color space is an extended RGB color space, developed "
"by Adobe. It is used for photography applications such as advertising and fine "
"art."
"<p><b>Wide Gamut</b>: this color space is an expanded version of the Adobe RGB "
"color space."
"<p><b>Pro-Photo</b>: this color space is an RGB color space, developed by "
"Kodak, that offers an especially large gamut designed for use with photographic "
"outputs in mind."
"<p><b>Custom</b>: use a custom output color space profile."
msgstr ""
#: libkdcraw/dcrawsettingswidget.cpp:525
msgid "Color Management"
msgstr ""
Loading…
Cancel
Save