update libraw to 0.9.1 (hackish)

foven support was removed

Signed-off-by: Andrew Randrianasulu <randrianasulu@gmail.com>
pull/10/head
Andrew Randrianasulu 2 years ago
parent e7d30e84d1
commit d3870f170b

File diff suppressed because it is too large Load Diff

@ -392,7 +392,7 @@ bool KDcraw::loadFromDcraw(const TQString& filePath, TQByteArray &imageData,
if (m_rawDecodingSettings.gamma16bit)
{
// 16 bits color depth auto-gamma is not implemented in dcraw.
raw.imgdata.params.gamma_16bit = 1;
//raw.imgdata.params.gamma_16bit = 1;
}
if (m_rawDecodingSettings.sixteenBitsImage)

File diff suppressed because it is too large Load Diff

@ -1,33 +1,36 @@
/*
GENERATED FILE, DO NOT EDIT
Generated from dcraw/dcraw.c at Tue Apr 7 15:14:50 2009
Generated from dcraw/dcraw.c at Sat May 15 11:10:17 2010
Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
for copyright information.
*/
#line 3976 "dcraw/dcraw.c"
#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"
#line 3986 "dcraw/dcraw.c"
/*
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)
void CLASS bad_pixels (const char *cfname)
{
FILE *fp=0;
char *cp, line[128];
char *fname, *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 (cfname)
fp = fopen (cfname, "r");
#line 4029 "dcraw/dcraw.c"
if (!fp)
{
#ifdef LIBRAW_LIBRARY_BUILD
@ -67,7 +70,7 @@ void CLASS bad_pixels (char *fname)
#endif
}
void CLASS subtract (char *fname)
void CLASS subtract (const char *fname)
{
FILE *fp;
int dim[3]={0,0,0}, comment=0, number=0, error=0, nd=0, c, row, col;
@ -123,9 +126,10 @@ void CLASS subtract (char *fname)
RUN_CALLBACK(LIBRAW_PROGRESS_DARK_FRAME,1,2);
#endif
}
#line 9550 "dcraw/dcraw.c"
#ifndef NO_LCMS
void CLASS apply_profile (char *input, char *output)
void CLASS apply_profile (const char *input, const char *output)
{
char *prof;
cmsHPROFILE hInProfile=0, hOutProfile=0;
@ -133,9 +137,7 @@ void CLASS apply_profile (char *input, char *output)
FILE *fp;
unsigned size;
#if LCMS_VERSION < 2000
cmsErrorAction (LCMS_ERROR_SHOW);
#endif
if (strcmp (input, "embed"))
hInProfile = cmsOpenProfileFromFile (input, "r");
else if (profile_length) {

@ -1,17 +1,19 @@
/*
GENERATED FILE, DO NOT EDIT
Generated from dcraw/dcraw.c at Tue Apr 7 15:14:48 2009
Generated from dcraw/dcraw.c at Sat May 15 11:10:07 2010
Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
for copyright information.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#line 27 "dcraw/dcraw.c"
#define NO_JPEG
#define DCRAW_VERSION "8.93"
#define _USE_MATH_DEFINES
#line 32 "dcraw/dcraw.c"
#define VERSION "8.99"
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#define _USE_MATH_DEFINES
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@ -24,7 +26,6 @@
#include <string.h>
#include <time.h>
#include <sys/types.h>
#ifdef _OPENMP
#include <omp.h>
#endif
@ -36,7 +37,7 @@
#include <jpeglib.h>
#endif
#ifndef NO_LCMS
#include LCMS_HEADER
#include <lcms.h>
#endif
#ifdef LOCALEDIR
#include <libintl.h>
@ -44,6 +45,7 @@
#else
#define _(String) (String)
#endif
#line 77 "dcraw/dcraw.c"
#ifdef __CYGWIN__
#include <io.h>
#endif
@ -54,14 +56,12 @@
#define snprintf _snprintf
#define strcasecmp _stricmp
#define strncasecmp strnicmp
typedef __int64 INT64;
typedef unsigned __int64 UINT64;
#line 91 "dcraw/dcraw.c"
#else
#include <unistd.h>
#include <utime.h>
#include <netinet/in.h>
typedef long long INT64;
typedef unsigned long long UINT64;
#line 99 "dcraw/dcraw.c"
#endif
#ifdef LJPEG_DECODE
@ -72,6 +72,7 @@ typedef unsigned long long UINT64;
#ifndef LONG_BIT
#define LONG_BIT (8 * sizeof (long))
#endif
#line 175 "dcraw/dcraw.c"
#define FORC(cnt) for (c=0; c < cnt; c++)
#define FORC3 FORC(3)
#define FORC4 FORC(4)
@ -125,8 +126,8 @@ typedef unsigned long long UINT64;
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
*/
#line 233 "dcraw/dcraw.c"
#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)]

@ -1,9 +1,10 @@
/*
GENERATED FILE, DO NOT EDIT
Generated from dcraw/dcraw.c at Tue Apr 7 15:14:48 2009
Generated from dcraw/dcraw.c at Wed Dec 30 14:11:09 2009
Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c)
for copyright information.
*/
#if 0
#define CLASS LibRaw::
#include "libraw/libraw_types.h"
@ -16,6 +17,9 @@
#define SRC_USES_CURVE
#include "internal/var_defines.h"
#define sget4(s) sget4((uchar *)s)
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
/* RESTRICTED code starts here */
@ -32,7 +36,8 @@ void CLASS foveon_decoder (unsigned size, unsigned code)
if (!code) {
for (i=0; i < size; i++)
huff[i] = get4();
init_decoder();
memset (first_decode, 0, sizeof first_decode);
free_decode = first_decode;
}
cur = free_decode++;
if (free_decode > first_decode+2048) {
@ -61,7 +66,7 @@ void CLASS foveon_decoder (unsigned size, unsigned code)
#endif
}
void CLASS foveon_thumb (FILE *tfp)
void CLASS foveon_thumb()
{
unsigned bwide, row, col, bitbuf=0, bit=1, c, i;
char *buf;
@ -69,14 +74,14 @@ void CLASS foveon_thumb (FILE *tfp)
short pred[3];
bwide = get4();
fprintf (tfp, "P6\n%d %d\n255\n", thumb_width, thumb_height);
fprintf (ofp, "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);
fwrite (buf, 3, thumb_width, ofp);
}
free (buf);
return;
@ -95,7 +100,7 @@ void CLASS foveon_thumb (FILE *tfp)
dindex = dindex->branch[bitbuf >> bit & 1];
}
pred[c] += dindex->leaf;
fputc (pred[c], tfp);
fputc (pred[c], ofp);
}
}
}
@ -315,7 +320,7 @@ void CLASS foveon_interpolate()
foveon_fixed (chroma_dq, 3, "ChromaDQ");
foveon_fixed (color_dq, 3,
foveon_camf_param ("IncludeBlocks", "ColorDQ") ?
"ColorDQ" : "ColorDTQCamRGB");
"ColorDQ" : "ColorDQCamRGB");
if (foveon_camf_param ("IncludeBlocks", "ColumnFilter"))
foveon_fixed (&cfilt, 1, "ColumnFilter");
@ -810,3 +815,4 @@ void CLASS parse_foveon()
}
is_foveon = 1;
}
#endif

@ -1,6 +1,6 @@
/*
/* -*- C++ -*-
* File: libraw_internal_funcs.h
* Copyright 2008 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2009 LibRaw LLC (info@libraw.org)
* Created: Sat Mar 14, 2008
*
* LibRaw internal data structures (not visible outside)
@ -17,8 +17,8 @@
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef _LIBRAW_INTERNAL_FUNCS_H
@ -43,32 +43,33 @@
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);
unsigned getbithuff (int nbits, ushort *huff);
ushort* make_decoder_ref (const uchar **source);
ushort* make_decoder (const uchar *source);
int ljpeg_start (struct jhead *jh, int info_only);
int ljpeg_diff (struct decode *dindex);
void ljpeg_end(struct jhead *jh);
int ljpeg_diff (ushort *huff);
ushort * ljpeg_row (int jrow, struct jhead *jh);
unsigned ph1_bithuff (int nbits, ushort *huff);
// Canon DSLRs
void crw_init_tables (unsigned table);
void crw_init_tables (unsigned table, ushort *huff[2]);
int canon_has_lowbits();
void canon_compressed_load_raw();
void lossless_jpeg_load_raw();
void canon_sraw_load_raw();
void canon_black(double *);
void canon_black(double *, int nblack);
// 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_load_raw();
void pentax_tree();
// Nikon (and Minolta Z2)
@ -79,7 +80,6 @@
int nikon_e2100();
void nikon_3700();
int minolta_z2();
void nikon_e900_load_raw();
void nikon_e2100_load_raw();
// Fuji
@ -104,7 +104,8 @@
void leaf_hdr_load_raw();
void sinar_4shot_load_raw();
void imacon_full_load_raw();
void packed_12_load_raw();
void packed_load_raw();
float find_green(int,int,int,int);
void unpacked_load_raw();
void parse_sinar_ia();
void parse_phase_one (int base);
@ -113,11 +114,9 @@
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_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);
@ -149,23 +148,6 @@
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]);

@ -1,6 +1,6 @@
/*
/* -*- C++ -*-
* File: var_defines.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2009 LibRaw LLC (info@libraw.org)
* Created: Sat Mar 8, 2008
*
* LibRaw redefinitions of dcraw internal variables
@ -17,8 +17,8 @@
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#ifndef VAR_DEFINES_H
@ -29,7 +29,6 @@
#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)
@ -64,6 +63,7 @@
#define black (imgdata.color.black)
#endif
#define maximum (imgdata.color.maximum)
#define channel_maximum (imgdata.color.channel_maximum)
#define profile_length (imgdata.color.profile_length)
#define color_flags (imgdata.color.color_flags)
#define ph1 (imgdata.color.phase_one_data)
@ -122,6 +122,7 @@
#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 ofp libraw_internal_data.internal_data.output
#define profile_offset (libraw_internal_data.internal_data.profile_offset)
#define thumb_offset (libraw_internal_data.internal_data.toffset)
@ -172,6 +173,9 @@
#define fseeko(stream,o,w) stream->seek(o,w)
#define ftell(stream) stream->tell()
#define ftello(stream) stream->tell()
#ifdef getc
#undef getc
#endif
#define getc(stream) stream->get_char()
#define fgetc(stream) stream->get_char()
#define fgets(str,n,stream) stream->gets(str,n)

@ -1,31 +1,30 @@
/*
/* -*- C++ -*-
* File: libraw.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#ifndef _LIBRAW_CLASS_H
#define _LIBRAW_CLASS_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#ifdef __linux__
#define _FILE_OFFSET_BITS 64
#endif
#include <limits.h>
@ -40,15 +39,13 @@
#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
/* 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);
@ -56,10 +53,10 @@ 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
/* version helpers */
DllDef const char* libraw_version();
DllDef int libraw_versionNumber();
// Camera list
/* Camera list */
DllDef const char** libraw_cameraList();
DllDef int libraw_cameraCount();
@ -70,14 +67,14 @@ DllDef int libraw_add_masked_borders_to_bitmap(libraw_data_t*
DllDef const char * libraw_unpack_function_name(libraw_data_t* lr);
DllDef int libraw_rotate_fuji_raw(libraw_data_t* lr);
// DCRAW compatibility
/* 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);
DllDef libraw_processed_image_t* libraw_dcraw_make_mem_image(libraw_data_t* lr, int *errc);
DllDef libraw_processed_image_t* libraw_dcraw_make_mem_thumb(libraw_data_t* lr, int *errc);
#ifdef __cplusplus
}
@ -102,30 +99,33 @@ class DllDef LibRaw
int unpack_thumb(void);
int adjust_sizes_info_only(void);
int adjust_maximum();
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; }
/* helpers */
static const char* version();
static int versionNumber();
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
static const char* strerror(int 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
/* 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
/* free all internal data structures */
void recycle();
~LibRaw(void) { recycle(); delete tls; }
int COLOR(int row, int col) { return libraw_internal_data.internal_output_params.fuji_width? FCF(row,col):FC(row,col);}
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();
@ -134,14 +134,25 @@ class DllDef LibRaw
int rotate_fuji_raw();
private:
int FCF(int row,int col) {
int rr,cc;
if (libraw_internal_data.unpacker_data.fuji_layout) {
rr = libraw_internal_data.internal_output_params.fuji_width - 1 - col + (row >> 1);
cc = col + ((row+1) >> 1);
} else {
rr = libraw_internal_data.internal_output_params.fuji_width - 1 + row - (col >> 1);
cc = row + ((col+1) >> 1);
}
return FC(rr,cc);
}
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;
@ -150,30 +161,27 @@ class DllDef LibRaw
libraw_callbacks_t callbacks;
LibRaw_constants rgb_constants;
void (LibRaw:: *write_thumb)(FILE *),
(LibRaw:: *write_fun)(FILE *);
void (LibRaw:: *write_thumb)(),
(LibRaw:: *write_fun)();
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
void write_thumb_ppm_tiff(FILE *);
// 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 identify2(unsigned, char*);
void write_ppm_tiff ();
void convert_to_rgb();
void kodak_ycbcr_load_raw();
void remove_zeroes();
#ifndef NO_LCMS
void apply_profile(char*,char*);
void apply_profile(const char*,const char*);
#endif
// Iterpolators
void pre_interpolate();
void border_interpolate (int border);
void lin_interpolate();
@ -181,9 +189,8 @@ class DllDef LibRaw
void ppg_interpolate();
void ahd_interpolate();
// Image filters
void bad_pixels(char*);
void subtract(char*);
void bad_pixels(const char*);
void subtract(const char*);
void hat_transform (float *temp, float *base, int st, int size, int sc);
void wavelet_denoise();
void scale_colors();
@ -194,24 +201,18 @@ class DllDef LibRaw
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 jpeg_thumb ();
void ppm_thumb ();
void layer_thumb ();
void rollei_thumb ();
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]);
void gamma_curve (double pwr, double ts, int mode, int imax);
// == internal functions
#ifdef LIBRAW_LIBRARY_BUILD
#include "internal/libraw_internal_funcs.h"
@ -227,7 +228,7 @@ class DllDef LibRaw
#endif
#endif // __cplusplus
#endif /* __cplusplus */
#endif // _LIBRAW_CLASS_H
#endif /* _LIBRAW_CLASS_H */

@ -1,24 +1,22 @@
/*
/* -*- C++ -*-
* File: libraw_alloc.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#ifndef __LIBRAW_ALLOC_H
@ -26,9 +24,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef WIN32
#define bzero(p,sz) memset(p,0,sz)
#endif
#ifdef __cplusplus
@ -39,7 +34,7 @@ class libraw_memmgr
public:
libraw_memmgr()
{
bzero(mems,sizeof(mems));
memset(mems,0,sizeof(mems));
calloc_cnt=0;
}
void *malloc(size_t sz)
@ -64,7 +59,6 @@ class libraw_memmgr
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;
}
@ -93,6 +87,6 @@ class libraw_memmgr
};
#endif //C++
#endif /* C++ */
#endif

@ -1,29 +1,29 @@
/*
/* -*- C++ -*-
* File: libraw_const.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#ifndef _LIBRAW_ERRORS_H
#define _LIBRAW_ERRORS_H
#define LIBRAW_DEFAULT_ADJUST_MAXIMUM_THRESHOLD 0.75
#define LIBRAW_DEFAULT_AUTO_BRIGHTNESS_THRESHOLD 0.01
enum LibRaw_constructor_flags
{
LIBRAW_OPTIONS_NONE =0,
@ -34,8 +34,6 @@ enum LibRaw_constructor_flags
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,
@ -74,12 +72,12 @@ enum LibRaw_colorstate
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_NOZEROES =1,
LIBRAW_FILTERING_NOBLACKS =2,
LIBRAW_FILTERING_NORAWCURVE =4,
LIBRAW_FILTERING_NONE =7,
LIBRAW_FILTERING_LIBRAWOWN =(8 | LIBRAW_FILTERING_NONE),
LIBRAW_FILTERING_AUTOMATIC_BIT =16,
LIBRAW_FILTERING_AUTOMATIC = (LIBRAW_FILTERING_LIBRAWOWN | LIBRAW_FILTERING_AUTOMATIC_BIT)
};
@ -94,7 +92,6 @@ enum LibRaw_progress
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,
@ -106,7 +103,7 @@ enum LibRaw_progress
LIBRAW_PROGRESS_APPLY_PROFILE = 1<<16,
LIBRAW_PROGRESS_CONVERT_RGB = 1<<17,
LIBRAW_PROGRESS_STRETCH = 1<<18,
// reserved
/* reserved */
LIBRAW_PROGRESS_STAGE19 = 1<<19,
LIBRAW_PROGRESS_STAGE20 = 1<<20,
LIBRAW_PROGRESS_STAGE21 = 1<<21,
@ -119,7 +116,8 @@ enum LibRaw_progress
LIBRAW_PROGRESS_THUMB_LOAD = 1<<28,
LIBRAW_PROGRESS_TRESERVED1 = 1<<29,
LIBRAW_PROGRESS_TRESERVED2 = 1<<30
LIBRAW_PROGRESS_TRESERVED2 = 1<<30,
LIBRAW_PROGRESS_TRESERVED3 = 1<<31
};
#define LIBRAW_PROGRESS_THUMB_MASK 0x0fffffff
@ -152,8 +150,8 @@ enum LibRaw_thumbnail_formats
enum LibRaw_image_formats
{
LIBRAW_IMAGE_BITMAP=1,
LIBRAW_IMAGE_JPEG=2
LIBRAW_IMAGE_JPEG=1,
LIBRAW_IMAGE_BITMAP=2
};
#endif

@ -1,24 +1,22 @@
/* -*- C -*-
* File: libraw_datastream.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#ifndef __LIBRAW_DATASTREAM_H
@ -33,9 +31,10 @@
struct LibRaw_abstract_datastream;
#else // __cplusplus
#else /* __cplusplus */
#include "libraw_const.h"
#include "libraw_types.h"
class LibRaw_buffer_datastream;
@ -45,10 +44,9 @@ class LibRaw_abstract_datastream
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 seek(INT64 , int ){return -1;}
virtual INT64 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;}
@ -96,15 +94,31 @@ class LibRaw_file_datastream : public LibRaw_abstract_datastream
CHK();
return substream?substream->eof():feof(f);
}
virtual int seek(off_t o, int whence)
virtual int seek(INT64 o, int whence)
{
CHK();
return substream?substream->seek(o,whence):fseek(f,o,whence);
#if defined (WIN32)
#if __MSVCRT_VERSION__ >= 0x800
return substream?substream->seek(o,whence):_fseeki64(f,o,whence);
#else
return substream?substream->seek(o,whence):fseek(f,(size_t)o,whence);
#endif
#else
return substream?substream->seek(o,whence):fseeko(f,o,whence);
#endif
}
virtual int tell()
virtual INT64 tell()
{
CHK();
#if defined (WIN32)
#if __MSVCRT_VERSION__ >= 0x800
return substream?substream->tell():_ftelli64(f);
#else
return substream?substream->tell():ftell(f);
#endif
#else
return substream?substream->tell():ftello(f);
#endif
}
virtual int get_char()
{
@ -124,7 +138,6 @@ class LibRaw_file_datastream : public LibRaw_abstract_datastream
virtual const char *fname() { return filename; }
// secondary
virtual int subfile_open(const char *fn)
{
if(sav) return EBUSY;
@ -181,7 +194,7 @@ class LibRaw_buffer_datastream : public LibRaw_abstract_datastream
return streampos >= streamsize;
}
virtual int seek(off_t o, int whence)
virtual int seek(INT64 o, int whence)
{
if(substream) return substream->seek(o,whence);
switch(whence)
@ -200,14 +213,14 @@ class LibRaw_buffer_datastream : public LibRaw_abstract_datastream
if(size_t(-o) >= streampos)
streampos = 0;
else
streampos += o;
streampos += (size_t)o;
}
else if (o>0)
{
if(o+streampos> streamsize)
streampos = streamsize;
else
streampos += o;
streampos += (size_t)o;
}
return 0;
case SEEK_END:
@ -216,17 +229,17 @@ class LibRaw_buffer_datastream : public LibRaw_abstract_datastream
else if ( size_t(-o) > streamsize)
streampos = 0;
else
streampos = streamsize+o;
streampos = streamsize+(size_t)o;
return 0;
default:
return 0;
}
}
virtual int tell()
virtual INT64 tell()
{
if(substream) return substream->tell();
return int(streampos);
return INT64(streampos);
}
virtual int get_char()

@ -1,24 +1,22 @@
/*
/* -*- C++ -*-
* File: libraw_internal.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#ifndef _LIBRAW_INTERNAL_TYPES_H
@ -33,7 +31,6 @@
#endif
#else
// C build
#ifndef CLASS
#define CLASS
#endif
@ -47,7 +44,7 @@
class LibRaw_TLS
{
public:
struct
struct
{
unsigned bitbuf;
int vbits, reset;
@ -58,17 +55,10 @@ public:
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
{
@ -76,7 +66,6 @@ public:
int vbits, padding;
}pana_bits;
// init - should use in constructor/recycle
void init()
{
getbits.bitbuf = 0; getbits.vbits = getbits.reset = 0;
@ -92,11 +81,8 @@ class LibRaw_constants
static const float d65_white[3];
static const double xyz_rgb[3][3];
};
#endif // __cplusplus
#endif /* __cplusplus */
#ifdef WIN32
typedef long off_t;
#endif
typedef struct
{
@ -104,11 +90,11 @@ typedef struct
struct
#endif
LibRaw_abstract_datastream *input;
FILE *output;
int input_internal;
// char *ifname;
char *meta_data;
off_t profile_offset;
off_t toffset;
INT64 profile_offset;
INT64 toffset;
} internal_data_t;
@ -116,7 +102,6 @@ typedef struct
{
unsigned mix_green;
unsigned raw_color;
unsigned use_gamma;
unsigned zero_is_bad;
ushort shrink;
ushort fuji_width;
@ -140,11 +125,11 @@ typedef struct
typedef struct
{
short order; // II* / MM* - file word byte order
short order;
ushort sraw_mul[4],cr2_slice[3];
unsigned kodak_cbpp;
off_t strip_offset, data_offset;
off_t meta_offset;
INT64 strip_offset, data_offset;
INT64 meta_offset;
unsigned meta_length;
unsigned thumb_misc;
unsigned fuji_layout;
@ -165,7 +150,6 @@ typedef struct
output_data_t output_data;
identify_data_t identify_data;
unpacker_data_t unpacker_data;
// callbacks_t callbacks;
} libraw_internal_data_t;
@ -183,8 +167,7 @@ struct tiff_ifd_t
struct jhead {
int bits, high, wide, clrs, sraw, psv, restart, vpred[6];
struct decode *huff[6];
ushort *row;
ushort *huff[6], *free[4], *row;
};
struct tiff_tag {
ushort tag, type;

@ -1,38 +1,37 @@
/*
/* -*- C++ -*-
* File: libraw_types.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#ifndef _LIBRAW_TYPES_H
#define _LIBRAW_TYPES_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/types.h>
#ifndef WIN32
#include <sys/time.h>
#endif
#include <stdio.h>
#ifdef _OPENMP
#ifdef _MSC_VER
#error OpenMP is not supported under MS Visual Studio
#endif
#include <omp.h>
#endif
@ -48,9 +47,14 @@ extern "C" {
#include "libraw_const.h"
#include "libraw_version.h"
#ifdef WIN32
typedef __int64 INT64;
typedef unsigned __int64 UINT64;
#else
typedef long long INT64;
typedef unsigned long long UINT64;
//#define ushort UshORt
#endif
typedef unsigned char uchar;
typedef unsigned short ushort;
@ -64,13 +68,11 @@ typedef unsigned short ushort;
# 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);
@ -94,7 +96,6 @@ typedef struct
void *progresscb_data;
} libraw_callbacks_t;
// Output bitmap type
typedef struct
{
@ -102,14 +103,17 @@ typedef struct
ushort height,
width,
colors,
bits,
gamma_corrected;
unsigned int data_size; // ðàçìåð ïîëÿ äàííûõ â áàéòàõ
unsigned char data[1]; // we'll allocate more!
bits;
#ifdef LIBRAW_LIBRARY_BUILD
#ifdef _OPENMP
#pragma omp firstprivate(colors,height,width)
#endif
#endif
unsigned int data_size;
unsigned char data[1];
}libraw_processed_image_t;
//Decoded from exif and used in calculations
typedef struct
{
char make[64];
@ -117,10 +121,9 @@ typedef struct
unsigned raw_count;
unsigned dng_version;
unsigned is_foveon;
int colors;
unsigned filters; // camera CFA pattern mask
unsigned filters;
char cdesc[5];
}libraw_iparams_t;
@ -135,15 +138,18 @@ typedef struct
left_margin;
ushort iheight,
iwidth;
#ifdef LIBRAW_LIBRARY_BUILD
#ifdef _OPENMP
#pragma omp firstprivate(iheight,iwidth)
#endif
#endif
double pixel_aspect;
int flip;
// masked border sizes
ushort right_margin,bottom_margin; // right masked width and bottom height, inited after idendify()
ushort right_margin,bottom_margin;
} libraw_image_sizes_t;
//Phase One data
struct ph1_t
{
int format, key_off, t_black, black_off, split_col, tag_21a;
@ -153,7 +159,6 @@ struct ph1_t
typedef struct
{
// 32 bits total
unsigned curve_state : 3;
unsigned rgb_cam_state : 3;
unsigned cmatrix_state : 3;
@ -165,20 +170,20 @@ typedef struct
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
ushort white[8][8];
float cam_mul[4];
float pre_mul[4];
float cmatrix[3][4];
float rgb_cam[3][4];
float cam_xyz[4][3];
ushort curve[0x10000];
unsigned black;
unsigned maximum;
unsigned channel_maximum[4];
struct ph1_t phase_one_data;
float flash_used; // canon/CRW only
float canon_ev; // canon/CRW only
float flash_used;
float canon_ev;
char model2[64];
// profile
void *profile;
unsigned profile_length;
}libraw_colordata_t;
@ -191,11 +196,9 @@ typedef struct
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;
@ -205,7 +208,6 @@ typedef struct
time_t timestamp;
unsigned shot_order;
unsigned gpsdata[32];
// string variables
char desc[512],
artist[64];
} libraw_imgother_t;
@ -214,16 +216,20 @@ typedef struct
{
unsigned greybox[4]; /* -A x1 y1 x2 y2 */
double aber[4]; /* -C */
double gamm[5]; /* -g */
double gamm[6]; /* -g */
float user_mul[4]; /* -r mul0 mul1 mul2 mul3 */
unsigned shot_select; /* -s */
float bright; /* -b */
float threshold; /* -n */
#ifdef LIBRAW_LIBRARY_BUILD
#ifdef _OPENMP
#pragma omp firstprivate(threshold)
#endif
#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 */
@ -233,7 +239,6 @@ typedef struct
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 */
@ -242,6 +247,7 @@ typedef struct
int med_passes; /* -m */
float auto_bright_thr;
float adjust_maximum_thr;
int no_auto_bright; /* -W */
int use_fuji_rotate;/* -j */
enum LibRaw_filtering filtering_mode;
@ -249,16 +255,16 @@ typedef struct
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
ushort *buffer;
ushort *tl;
ushort *top;
ushort *tr;
ushort *left;
ushort *right;
ushort *bl;
ushort *bottom;
ushort *br;
ushort (*ph1_black)[2];
}libraw_masked_t;
typedef struct
@ -272,8 +278,12 @@ typedef struct
libraw_thumbnail_t thumbnail;
libraw_masked_t masked_pixels;
ushort (*image)[4] ;
#ifdef LIBRAW_LIBRARY_BUILD
#ifdef _OPENMP
#pragma omp shared(image)
#endif
#endif
libraw_output_params_t params;
// pointer to LibRaw class for use in C calls
void *parent_class;
} libraw_data_t;

@ -1,32 +1,31 @@
/*
/* -*- C++ -*-
* File: libraw_version.h
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See the file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See the file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See the file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#ifndef __VERSION_H
#define __VERSION_H
#define LIBRAW_MAJOR_VERSION 0
#define LIBRAW_MINOR_VERSION 7
#define LIBRAW_PATCH_VERSION 2
#define LIBRAW_MINOR_VERSION 9
#define LIBRAW_PATCH_VERSION 1
#define LIBRAW_VERSION_TAIL Release
#define _LIBRAW_VERSION_MAKE(a,b,c,d) #a"."#b"."#c"-"#d

@ -1,25 +1,26 @@
/*
/* -*- C++ -*-
* File: 4channels.cpp
* Copyright 2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
#include <string.h>
@ -39,8 +40,8 @@
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];
int autoscale=0,filtering_mode=LIBRAW_FILTERING_DEFAULT,black_subtraction=1, use_gamma=0;
char outfn[1024];
LibRaw RawProcessor;
if(ac<2)
@ -85,7 +86,7 @@ int main(int ac, char *av[])
OUT.shot_select=atoi(av[i]);
}
else if(av[i][1]=='g' && av[i][2]==0)
OUT.gamma_16bit=1;
use_gamma = 1;
else if(av[i][1]=='A' && av[i][2]==0)
autoscale=1;
else if(av[i][1]=='B' && av[i][2]==0)
@ -99,20 +100,18 @@ int main(int ac, char *av[])
goto usage;
continue;
}
if(!use_gamma)
OUT.gamm[0] = OUT.gamm[1] = 1;
if(filtering_mode)
OUT.filtering_mode = (LibRaw_filtering) filtering_mode;
int r,c;
int 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));
@ -165,12 +164,12 @@ int main(int ac, char *av[])
char lname[8];
if(isrgb)
{
snprintf(lname,7,"%c",(char*)("RGBG")[layer]);
snprintf(lname,7,"%c",((char*)("RGBG"))[layer]);
if(layer==3)
strcat(lname,"2");
}
else
snprintf(lname,7,"%c",(char*)("GCMY")[layer]);
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);

@ -0,0 +1,2 @@
all:
(cd ..; make all_samples)

@ -0,0 +1,2 @@
See ../doc/Samples-LibRaw-rus.html and ../doc/Samples-LibRaw-eng.html

@ -1,29 +1,26 @@
/*
/* -*- C++ -*-
* File: dcraw_emu.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* Created: Sun Mar 23, 2008
*
* LibRaw simple C++ API (almost complete dcraw emulator)
* LibRaw simple C++ API sample: 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@ -41,15 +38,13 @@
#define snprintf _snprintf
#endif
#ifdef _OPENMP
#include <omp.h>
#endif
void usage(const char *prog)
{
printf("dcraw_emu: almost complete dcraw emulator\n");
printf("Usage: %s [OPTION]... [FILE]...\n", prog);
printf(
"-c float-num Set adjust maximum threshold (default 0.75)\n"
"-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"
@ -77,7 +72,8 @@ void usage(const char *prog)
"-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"
"-4 Linear 16-bit, same as \"-6 -W -g 1 1\""
"-6 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
@ -121,12 +117,12 @@ int main(int argc, char *argv[])
#define OUT RawProcessor.imgdata.params
argv[argc] = "";
argv[argc] = (char*)"";
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 ((cp = strchr (sp=(char*)"cnbrkStqmHACgU", opt)))
for (i=0; i < "111411111142"[cp-sp]-'0'; i++)
if (!isdigit(argv[arg+i][0]))
{
fprintf (stderr,"Non-numeric argument to \"-%c\"\n", opt);
@ -135,7 +131,7 @@ int main(int argc, char *argv[])
switch (opt)
{
case 'v': verbosity++; break;
case 'c': OUT.adjust_maximum_thr = atof(argv[arg++]); 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;
@ -161,7 +157,7 @@ int main(int argc, char *argv[])
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]))
if(isdigit(argv[arg][0]) && !isdigit(argv[arg][1]))
OUT.output_color = atoi(argv[arg++]);
#ifndef NO_LCMS
else
@ -182,8 +178,8 @@ int main(int argc, char *argv[])
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;
case '4': OUT.gamm[0] = OUT.gamm[1] = OUT.no_auto_bright = 1; /* no break here! */
case '6': OUT.output_bps = 16; break;
#ifndef WIN32
case 'B': use_mmap = 1; break;
#endif
@ -269,7 +265,10 @@ int main(int argc, char *argv[])
"%s.%s",
argv[arg], OUT.output_tiff ? "tiff" : (P1.colors>1?"ppm":"pgm"));
if(verbosity) printf("Writing file %s\n",outfn);
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));

@ -1,24 +1,24 @@
/*
/* -*- C++ -*-
* File: dcraw_half.c
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* Created: Sat Mar 8 , 2008
*
* LibRaw C API sample (emulates call to "dcraw -h")
* LibRaw C API sample: emulates "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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
#include <string.h>
@ -48,7 +48,7 @@ int main(int ac, char *av[])
{
int i;
libraw_data_t *iprc = libraw_init(0);
if(!iprc)
{
fprintf(stderr,"Cannot create libraw handle\n");

@ -1,24 +1,24 @@
/*
/* -*- C++ -*-
* File: halt_mt.c
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* Created: Sat Mar 8 , 2008
*
* LibRaw C API mutithreaded sample (emulates call to "dcraw -h [-w] [-a] [-v]")
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
#include <string.h>
@ -35,16 +35,14 @@
if(LIBRAW_FATAL_ERROR(ret)) \
{ \
libraw_close(iprc); \
return -1; \
return NULL ; \
} \
} \
}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;
@ -61,8 +59,7 @@ char *get_next_file()
}
// thread routine
int process_files(void *q)
void * process_files(void *q)
{
int ret;
int count=0;
@ -72,7 +69,7 @@ int process_files(void *q)
if(!iprc)
{
fprintf(stderr,"Cannot create libraw handle\n");
return -1;
return NULL ;
}
while((fn = get_next_file()))
@ -101,7 +98,7 @@ int process_files(void *q)
count++;
}
libraw_close(iprc);
return count;
return NULL;
}
void usage(const char*p)
@ -120,7 +117,7 @@ int show_files(void *q)
{
char *p;
int cnt = 0;
while(p = get_next_file())
while((p = get_next_file()))
{
printf("%s\n",p);
cnt++;
@ -131,7 +128,7 @@ int show_files(void *q)
int main(int ac, char *av[])
{
int i, thread_count,max_threads = 2;
int i, max_threads = 2;
pthread_t *threads;
if(ac<2)
usage(av[0]);
@ -168,9 +165,7 @@ int main(int ac, char *av[])
int *iptr;
if(threads[i])
{
pthread_join(threads[i],&iptr);
if(iptr)
printf("Thread %d : %d files\n",i,(int)iptr);
pthread_join(threads[i],(void*)&iptr);
}
}

@ -1,25 +1,24 @@
/*
/* -*- C++ -*-
* File: halt_mt_win32.c
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* Created: Sat Mar 8 , 2008
*
* LibRaw C API mutithreaded sample (emulates call to "dcraw -h [-w] [-a] [-v]")
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
#include <string.h>

@ -1,25 +1,24 @@
/*
/* -*- C++ -*-
* File: mem_image.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
* LibRaw mem_image/mem_thumb API test. Results should be same (bitwise) to dcraw [-4] [-6] [-e]
* Testing note: for ppm-thumbnails you should use dcraw -w -e for thumbnail extraction
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
#include <string.h>
@ -58,7 +57,7 @@ void write_ppm(libraw_processed_image_t *img, const char *basename)
*/
#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)
for(unsigned i=0; i< img->data_size; i+=2)
SWAP(img->data[i],img->data[i+1]);
#undef SWAP
@ -91,10 +90,9 @@ void write_thumb(libraw_processed_image_t *img, const char *basename)
int main(int ac, char *av[])
{
int i, ret, verbose=0, output_thumbs=0;
int i, ret, output_thumbs=0;
// don't use fixed size buffers in real apps!
char outfn[1024],thumbfn[1024];
LibRaw RawProcessor;
@ -103,8 +101,8 @@ int main(int ac, char *av[])
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-6 - output 16-bit PPM\n"
"\t-4 - linear 16-bit data\n"
"\t-e - extract thumbnails (same as dcraw -e in separate run)\n",
av[0]);
return 0;
@ -124,10 +122,13 @@ int main(int ac, char *av[])
{
if(av[i][0]=='-')
{
if(av[i][1]=='4' && av[i][2]==0)
if(av[i][1]=='6' && 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]=='4' && av[i][2]==0)
{
OUT.output_bps = 16;
OUT.gamm[0] = OUT.gamm[1] = OUT.no_auto_bright = 1;
}
if(av[i][1]=='e' && av[i][2]==0)
output_thumbs++;
continue;
@ -139,7 +140,6 @@ int main(int ac, char *av[])
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));

@ -1,24 +1,24 @@
/*
/* -*- C++ -*-
* File: identify.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* Created: Sat Mar 8 , 2008
*
* LibRaw C++ demo (emulates dcraw -i [-v])
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
@ -88,7 +88,7 @@ int main(int ac, char *av[])
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 ("Embedded ICC profile: no\n");
printf ("Number of raw images: %d\n", P1.raw_count);
if (S.pixel_aspect != 1)
@ -114,7 +114,7 @@ int main(int ac, char *av[])
printf ("\nCamera multipliers:");
for(int c=0;c<4;c++) printf (" %f", C.cam_mul[c]);
}
char *csl[] = {"U","I","CO","L","CA"};
const 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],

@ -1,24 +1,24 @@
/*
/* -*- C++ -*-
* File: simple_dcraw.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
* LibRaw simple C++ API: emulates call to "dcraw [-D] [-T] [-v] [-e] [-4]"
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
#include <string.h>

@ -1,25 +1,24 @@
/*
/* -*- C++ -*-
* File: unprocessed_raw.cpp
* Copyright 2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* 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., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <stdio.h>
#include <string.h>
@ -39,8 +38,8 @@
int main(int ac, char *av[])
{
int i, ret;
int verbose=1,autoscale=0;
char outfn[1024],thumbfn[1024];
int verbose=1,autoscale=0,use_gamma=0;
char outfn[1024];
LibRaw RawProcessor;
if(ac<2)
@ -82,7 +81,7 @@ int main(int ac, char *av[])
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;
use_gamma = 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)
@ -94,7 +93,9 @@ int main(int ac, char *av[])
goto usage;
continue;
}
int r,c;
int c;
if(!use_gamma)
OUT.gamm[0] = OUT.gamm[1] = 1;
if(verbose) printf("Processing file %s\n",av[i]);
if( (ret = RawProcessor.open_file(av[i])) != LIBRAW_SUCCESS)
{
@ -113,6 +114,7 @@ int main(int ac, char *av[])
fprintf(stderr,"Cannot unpack %s: %s\n",av[i],libraw_strerror(ret));
continue;
}
if(verbose)
printf("Unpacked....\n");
@ -120,10 +122,13 @@ int main(int ac, char *av[])
{
fprintf(stderr,"Cannot add mask data to bitmap %s\n",av[i]);
}
// move all pixel data to component 0
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)];
= RawProcessor.imgdata.image[r*S.iwidth+c][RawProcessor.COLOR(r,c)];
P1.colors=1;
if(autoscale)
@ -142,6 +147,7 @@ int main(int ac, char *av[])
RawProcessor.imgdata.image[j][0] *= scale;
}
}
if(OUT.shot_select)
snprintf(outfn,sizeof(outfn),"%s-%d.tiff",av[i],OUT.shot_select);

@ -0,0 +1,2 @@
all:
(cd ..; make library)

@ -1,9 +1,25 @@
/*
/* -*- C++ -*-
* File: libraw_c_api.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* Created: Sat Mar 8 , 2008
*
* LibRaw C++ interface (implementation)
* LibRaw C interface
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <errno.h>
#include "libraw/libraw.h"
@ -110,7 +126,6 @@ extern "C"
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;
@ -137,6 +152,18 @@ extern "C"
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->dcraw_process();
}
libraw_processed_image_t *libraw_dcraw_make_mem_image(libraw_data_t* lr,int *errc)
{
if(!lr) { if(errc) *errc=EINVAL; return NULL;}
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->dcraw_make_mem_image(errc);
}
libraw_processed_image_t *libraw_dcraw_make_mem_thumb(libraw_data_t* lr,int *errc)
{
if(!lr) { if(errc) *errc=EINVAL; return NULL;}
LibRaw *ip = (LibRaw*) lr->parent_class;
return ip->dcraw_make_mem_thumb(errc);
}
#ifdef __cplusplus
}

@ -1,9 +1,22 @@
/*
/* -*- C++ -*-
* File: libraw_cxx.cpp
* Copyright 2008-2009 Alex Tutubalin <lexa@lexa.ru>
* Copyright 2008-2010 LibRaw LLC (info@libraw.org)
* Created: Sat Mar 8 , 2008
*
* LibRaw C++ interface (implementation)
LibRaw is free software; you can redistribute it and/or modify
it under the terms of the one of three licenses as you choose:
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
(See file LICENSE.LGPL provided in LibRaw distribution archive for details).
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
(See file LICENSE.CDDL provided in LibRaw distribution archive for details).
3. LibRaw Software License 27032010
(See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
*/
#include <errno.h>
@ -113,6 +126,11 @@ const float LibRaw_constants::d65_white[3] = { 0.950456, 1, 1.088754 };
} \
}while(0)
const char* LibRaw::version() { return LIBRAW_VERSION_STR;}
int LibRaw::versionNumber() { return LIBRAW_VERSION; }
const char* LibRaw::strerror(int p) { return libraw_strerror(p);}
void LibRaw::derror()
{
if (!libraw_internal_data.unpacker_data.data_error && libraw_internal_data.internal_data.input)
@ -131,21 +149,25 @@ void LibRaw::derror()
throw LIBRAW_EXCEPTION_IO_CORRUPT;
}
}
libraw_internal_data.unpacker_data.data_error = 1;
libraw_internal_data.unpacker_data.data_error++;
}
#define ZERO(a) memset(&a,0,sizeof(a))
LibRaw:: LibRaw(unsigned int flags)
{
double aber[4] = {1,1,1,1};
double gamm[5] = { 0.45,4.5,0,0,0 };
double gamm[6] = { 0.45,4.5,0,0,0,0 };
unsigned greybox[4] = { 0, 0, UINT_MAX, UINT_MAX };
#ifdef DCRAW_VERBOSE
verbose = 1;
#else
verbose = 0;
#endif
bzero(&imgdata,sizeof(imgdata));
bzero(&libraw_internal_data,sizeof(libraw_internal_data));
bzero(&callbacks,sizeof(callbacks));
ZERO(imgdata);
ZERO(libraw_internal_data);
ZERO(callbacks);
callbacks.mem_cb = (flags & LIBRAW_OPIONS_NO_MEMERR_CALLBACK) ? NULL: &default_memory_callback;
callbacks.data_cb = (flags & LIBRAW_OPIONS_NO_DATAERR_CALLBACK)? NULL : &default_data_callback;
memmove(&imgdata.params.aber,&aber,sizeof(aber));
@ -161,7 +183,8 @@ LibRaw:: LibRaw(unsigned int flags)
imgdata.params.output_color=1;
imgdata.params.output_bps=8;
imgdata.params.use_fuji_rotate=1;
imgdata.params.auto_bright_thr = 0.01;
imgdata.params.auto_bright_thr = LIBRAW_DEFAULT_AUTO_BRIGHTNESS_THRESHOLD;
imgdata.params.adjust_maximum_thr= LIBRAW_DEFAULT_ADJUST_MAXIMUM_THRESHOLD;
imgdata.parent_class = this;
imgdata.progress_flags = 0;
tls = new LibRaw_TLS;
@ -228,11 +251,10 @@ void LibRaw:: recycle()
FREE(imgdata.masked_pixels.buffer);
FREE(imgdata.masked_pixels.ph1_black);
#undef FREE
#define ZERO(a) bzero(&a,sizeof(a))
ZERO(imgdata.masked_pixels);
ZERO(imgdata.sizes);
ZERO(imgdata.color);
ZERO(libraw_internal_data.internal_output_params);
#undef ZERO
memmgr.cleanup();
imgdata.thumbnail.tformat = LIBRAW_THUMBNAIL_UNKNOWN;
imgdata.progress_flags = 0;
@ -245,65 +267,86 @@ const char * LibRaw::unpack_function_name()
if(!load_raw) return "Function not set";
// sorted names order
if (load_raw == &LibRaw::adobe_dng_load_raw_lj) return "adobe_dng_load_raw_lj()";
if (load_raw == &LibRaw::adobe_dng_load_raw_nc) return "adobe_dng_load_raw_nc()";
if (load_raw == &LibRaw::canon_600_load_raw) return "canon_600_load_raw()";
if (load_raw == &LibRaw::canon_a5_load_raw) return "canon_a5_load_raw()";
if (load_raw == &LibRaw::canon_compressed_load_raw) return "canon_compressed_load_raw()";
if (load_raw == &LibRaw::canon_sraw_load_raw) return "canon_sraw_load_raw()";
if (load_raw == &LibRaw::casio_qv5700_load_raw ) return "casio_qv5700_load_raw()";
if (load_raw == &LibRaw::eight_bit_load_raw ) return "eight_bit_load_raw()";
if (load_raw == &LibRaw::foveon_load_raw ) return "foveon_load_raw()";
if (load_raw == &LibRaw::fuji_load_raw ) return "fuji_load_raw()";
if (load_raw == &LibRaw::adobe_dng_load_raw_lj) return "adobe_dng_load_raw_lj()"; //+
if (load_raw == &LibRaw::adobe_dng_load_raw_nc) return "adobe_dng_load_raw_nc()"; //+
if (load_raw == &LibRaw::canon_600_load_raw) return "canon_600_load_raw()"; //+
if (load_raw == &LibRaw::canon_compressed_load_raw) return "canon_compressed_load_raw()"; //+
if (load_raw == &LibRaw::canon_sraw_load_raw) return "canon_sraw_load_raw()"; //+
if (load_raw == &LibRaw::eight_bit_load_raw ) return "eight_bit_load_raw()"; //+
if (load_raw == &LibRaw::fuji_load_raw ) return "fuji_load_raw()"; //+
// 10
if (load_raw == &LibRaw::hasselblad_load_raw ) return "hasselblad_load_raw()";
if (load_raw == &LibRaw::imacon_full_load_raw ) return "imacon_full_load_raw()";
if (load_raw == &LibRaw::kodak_262_load_raw ) return "kodak_262_load_raw()";
if (load_raw == &LibRaw::kodak_65000_load_raw ) return "kodak_65000_load_raw()";
if (load_raw == &LibRaw::kodak_dc120_load_raw ) return "kodak_dc120_load_raw()";
if (load_raw == &LibRaw::kodak_jpeg_load_raw ) return "kodak_jpeg_load_raw()";
if (load_raw == &LibRaw::kodak_radc_load_raw ) return "kodak_radc_load_raw()";
if (load_raw == &LibRaw::kodak_rgb_load_raw ) return "kodak_rgb_load_raw()";
if (load_raw == &LibRaw::kodak_yrgb_load_raw ) return "kodak_yrgb_load_raw()";
if (load_raw == &LibRaw::kodak_ycbcr_load_raw ) return "kodak_ycbcr_load_raw()";
if (load_raw == &LibRaw::hasselblad_load_raw ) return "hasselblad_load_raw()"; //+
if (load_raw == &LibRaw::imacon_full_load_raw ) return "imacon_full_load_raw()"; //+ (untested)
if (load_raw == &LibRaw::kodak_262_load_raw ) return "kodak_262_load_raw()"; //+
if (load_raw == &LibRaw::kodak_65000_load_raw ) return "kodak_65000_load_raw()";//+
if (load_raw == &LibRaw::kodak_dc120_load_raw ) return "kodak_dc120_load_raw()"; //+
if (load_raw == &LibRaw::kodak_jpeg_load_raw ) return "kodak_jpeg_load_raw()"; //+ (untested)
if (load_raw == &LibRaw::kodak_radc_load_raw ) return "kodak_radc_load_raw()"; //+
if (load_raw == &LibRaw::kodak_rgb_load_raw ) return "kodak_rgb_load_raw()"; //+ (untested)
if (load_raw == &LibRaw::kodak_yrgb_load_raw ) return "kodak_yrgb_load_raw()"; //+
if (load_raw == &LibRaw::kodak_ycbcr_load_raw ) return "kodak_ycbcr_load_raw()"; //+ (untested)
// 20
if (load_raw == &LibRaw::leaf_hdr_load_raw ) return "leaf_hdr_load_raw()";
if (load_raw == &LibRaw::lossless_jpeg_load_raw) return "lossless_jpeg_load_raw()";
if (load_raw == &LibRaw::minolta_rd175_load_raw ) return "minolta_rd175_load_raw()";
if (load_raw == &LibRaw::nikon_compressed_load_raw) return "nikon_compressed_load_raw()";
if (load_raw == &LibRaw::nikon_e900_load_raw ) return "nikon_e900_load_raw()";
if (load_raw == &LibRaw::nokia_load_raw ) return "nokia_load_raw()";
if (load_raw == &LibRaw::olympus_e300_load_raw ) return "olympus_e300_load_raw()";
if (load_raw == &LibRaw::olympus_e410_load_raw ) return "olympus_e410_load_raw()";
if (load_raw == &LibRaw::packed_12_load_raw ) return "packed_12_load_raw()";
if (load_raw == &LibRaw::panasonic_load_raw ) return "panasonic_load_raw()";
if (load_raw == &LibRaw::leaf_hdr_load_raw ) return "leaf_hdr_load_raw()"; //+
if (load_raw == &LibRaw::lossless_jpeg_load_raw) return "lossless_jpeg_load_raw()"; //+
if (load_raw == &LibRaw::minolta_rd175_load_raw ) return "minolta_rd175_load_raw()"; //+
if (load_raw == &LibRaw::nikon_compressed_load_raw) return "nikon_compressed_load_raw()";//+
if (load_raw == &LibRaw::nokia_load_raw ) return "nokia_load_raw()";//+ (untested)
if (load_raw == &LibRaw::olympus_load_raw ) return "olympus_load_raw()"; //+
if (load_raw == &LibRaw::packed_load_raw ) return "packed_load_raw()"; //+
if (load_raw == &LibRaw::panasonic_load_raw ) return "panasonic_load_raw()";//+
// 30
if (load_raw == &LibRaw::pentax_k10_load_raw ) return "pentax_k10_load_raw()";
if (load_raw == &LibRaw::phase_one_load_raw ) return "phase_one_load_raw()";
if (load_raw == &LibRaw::phase_one_load_raw_c ) return "phase_one_load_raw_c()";
if (load_raw == &LibRaw::quicktake_100_load_raw ) return "quicktake_100_load_raw()";
if (load_raw == &LibRaw::rollei_load_raw ) return "rollei_load_raw()";
if (load_raw == &LibRaw::sinar_4shot_load_raw ) return "sinar_4shot_load_raw()";
if (load_raw == &LibRaw::smal_v6_load_raw ) return "smal_v6_load_raw()";
if (load_raw == &LibRaw::smal_v9_load_raw ) return "smal_v9_load_raw()";
if (load_raw == &LibRaw::sony_load_raw ) return "sony_load_raw()";
if (load_raw == &LibRaw::sony_arw_load_raw ) return "sony_arw_load_raw()";
if (load_raw == &LibRaw::pentax_load_raw ) return "pentax_load_raw()"; //+
if (load_raw == &LibRaw::phase_one_load_raw ) return "phase_one_load_raw()"; //+
if (load_raw == &LibRaw::phase_one_load_raw_c ) return "phase_one_load_raw_c()"; //+
if (load_raw == &LibRaw::quicktake_100_load_raw ) return "quicktake_100_load_raw()";//+ (untested)
if (load_raw == &LibRaw::rollei_load_raw ) return "rollei_load_raw()"; //+ (untested)
if (load_raw == &LibRaw::sinar_4shot_load_raw ) return "sinar_4shot_load_raw()";//+
if (load_raw == &LibRaw::smal_v6_load_raw ) return "smal_v6_load_raw()";//+ (untested)
if (load_raw == &LibRaw::smal_v9_load_raw ) return "smal_v9_load_raw()";//+ (untested)
if (load_raw == &LibRaw::sony_load_raw ) return "sony_load_raw()"; //+
if (load_raw == &LibRaw::sony_arw_load_raw ) return "sony_arw_load_raw()";//+
// 40
if (load_raw == &LibRaw::sony_arw2_load_raw ) return "sony_arw2_load_raw()";
if (load_raw == &LibRaw::unpacked_load_raw ) return "unpacked_load_raw()";
if (load_raw == &LibRaw::sony_arw2_load_raw ) return "sony_arw2_load_raw()";//+
if (load_raw == &LibRaw::unpacked_load_raw ) return "unpacked_load_raw()"; //+
// 42 total
return "Unknown unpack function";
}
int LibRaw::adjust_maximum()
{
int i;
ushort real_max;
float auto_threshold;
if(O.adjust_maximum_thr < 0.00001)
return LIBRAW_SUCCESS;
else if (O.adjust_maximum_thr > 0.99999)
auto_threshold = LIBRAW_DEFAULT_ADJUST_MAXIMUM_THRESHOLD;
else
auto_threshold = O.adjust_maximum_thr;
real_max = C.channel_maximum[0];
for(i = 1; i< 4; i++)
if(real_max < C.channel_maximum[i])
real_max = C.channel_maximum[i];
if (real_max > 0 && real_max < C.maximum && real_max > C.maximum* auto_threshold)
{
C.maximum = real_max;
}
return LIBRAW_SUCCESS;
}
void LibRaw:: merror (void *ptr, const char *where)
{
@ -410,7 +453,6 @@ void LibRaw:: init_masked_ptrs()
M.br = M.bottom + (S.width * S.bottom_margin);
}
int LibRaw::add_masked_borders_to_bitmap()
{
CHECK_ORDER_HIGH(LIBRAW_PROGRESS_PRE_INTERPOLATE);
@ -419,7 +461,7 @@ int LibRaw::add_masked_borders_to_bitmap()
if(S.width != S.iwidth || S.height!=S.iheight)
return LIBRAW_CANNOT_ADDMASK;
if(P1.is_foveon || !P1.filters)
if(!P1.filters)
return LIBRAW_CANNOT_ADDMASK;
if(!imgdata.image)
@ -443,7 +485,7 @@ int LibRaw::add_masked_borders_to_bitmap()
{
ushort *p = get_masked_pointer(r,c);
if(p)
newimage[r*S.raw_width+c][FC(r,c)] = *p;
newimage[r*S.raw_width+c][COLOR(r,c)] = *p;
}
// middle rows
for (r=S.top_margin; r<S.top_margin+S.height;r++)
@ -453,18 +495,20 @@ int LibRaw::add_masked_borders_to_bitmap()
{
ushort *p = get_masked_pointer(r,c);
if(p)
newimage[r*S.raw_width+c][FC(r,c)] = *p;
newimage[r*S.raw_width+c][COLOR(r,c)] = *p;
}
for(c=S.left_margin; c<S.left_margin+S.iwidth;c++)
{
int col = c - S.left_margin;
newimage[r*S.raw_width+c][FC(r,c)] = imgdata.image[row*S.iwidth+col][FC(row,col)];
newimage[r*S.raw_width+c][COLOR(r,c)] = imgdata.image[row*S.iwidth+col][COLOR(r,c)];
// for(int cc=0;cc<4;cc++)
// newimage[r*S.raw_width+c][cc] = imgdata.image[row*S.iwidth+col][cc];
}
for(c=S.left_margin+S.iwidth;c<S.raw_width;c++)
{
ushort *p = get_masked_pointer(r,c);
if(p)
newimage[r*S.raw_width+c][FC(r,c)] = *p;
newimage[r*S.raw_width+c][COLOR(r,c)] = *p;
}
}
// bottom rows
@ -473,7 +517,7 @@ int LibRaw::add_masked_borders_to_bitmap()
{
ushort *p = get_masked_pointer(r,c);
if(p)
newimage[r*S.raw_width+c][FC(r,c)] = *p;
newimage[r*S.raw_width+c][COLOR(r,c)] = *p;
}
free(imgdata.image);
imgdata.image=newimage;
@ -562,10 +606,10 @@ int LibRaw::open_datastream(LibRaw_abstract_datastream *stream)
int saved_raw_width = S.raw_width;
int saved_width = S.width;
// from packed_12_load_raw
if ((load_raw == &LibRaw:: packed_12_load_raw) && (S.raw_width * 2 >= S.width * 3))
if ((load_raw == &LibRaw:: packed_load_raw) && (S.raw_width * 8U >= S.width * libraw_internal_data.unpacker_data.tiff_bps))
{
// raw_width is in bytes!
S.raw_width = S.raw_width * 2 / 3;
S.raw_width = S.raw_width * 8 / libraw_internal_data.unpacker_data.tiff_bps;
}
else if (S.pixel_aspect < 0.95 || S.pixel_aspect > 1.05)
{
@ -667,8 +711,6 @@ int LibRaw::unpack(void)
merror (libraw_internal_data.internal_data.meta_data, "LibRaw::unpack()");
}
ID.input->seek(libraw_internal_data.unpacker_data.data_offset, SEEK_SET);
// foveon_load_raw produces different data for document_mode, we'll
// deal with it in dcraw_document_mode_processing
int save_document_mode = O.document_mode;
O.document_mode = 0;
@ -706,17 +748,6 @@ int LibRaw::dcraw_document_mode_processing(void)
O.filtering_mode = LIBRAW_FILTERING_AUTOMATIC_BIT; // turn on black and zeroes filtering
O.document_mode = 2;
if(P1.is_foveon)
{
// filter image data for foveon document mode
short *iptr = (short *)imgdata.image;
for (int i=0; i < S.height*S.width*4; i++)
{
if ((short) iptr[i] < 0)
iptr[i] = 0;
}
SET_PROC_FLAG(LIBRAW_PROGRESS_FOVEON_INTERPOLATE);
}
O.use_fuji_rotate = 0;
if (!(O.filtering_mode & LIBRAW_FILTERING_NOZEROES) && IO.zero_is_bad)
@ -754,14 +785,14 @@ int LibRaw::dcraw_document_mode_processing(void)
}
SET_PROC_FLAG(LIBRAW_PROGRESS_MIX_GREEN);
if (!P1.is_foveon && P1.colors == 3)
if ( P1.colors == 3)
median_filter();
SET_PROC_FLAG(LIBRAW_PROGRESS_MEDIAN_FILTER);
if (!P1.is_foveon && O.highlight == 2)
if ( O.highlight == 2)
blend_highlights();
if (!P1.is_foveon && O.highlight > 2)
if ( O.highlight > 2)
recover_highlights();
SET_PROC_FLAG(LIBRAW_PROGRESS_HIGHLIGHTS);
@ -829,13 +860,12 @@ libraw_processed_image_t * LibRaw::dcraw_make_mem_thumb(int *errcode)
return NULL;
}
bzero(ret,sizeof(libraw_processed_image_t));
memset(ret,0,sizeof(libraw_processed_image_t));
ret->type = LIBRAW_IMAGE_BITMAP;
ret->height = T.theight;
ret->width = T.twidth;
ret->colors = 3;
ret->bits = 8;
ret->gamma_corrected = 1;
ret->data_size = T.tlength;
memmove(ret->data,T.thumb,T.tlength);
if(errcode) *errcode= 0;
@ -858,7 +888,7 @@ libraw_processed_image_t * LibRaw::dcraw_make_mem_thumb(int *errcode)
return NULL;
}
bzero(ret,sizeof(libraw_processed_image_t));
memset(ret,0,sizeof(libraw_processed_image_t));
ret->type = LIBRAW_IMAGE_JPEG;
ret->data_size = dsize;
@ -901,11 +931,19 @@ libraw_processed_image_t *LibRaw::dcraw_make_mem_image(int *errcode)
return NULL;
}
if(!libraw_internal_data.output_data.histogram)
if(libraw_internal_data.output_data.histogram)
{
libraw_internal_data.output_data.histogram =
(int (*)[LIBRAW_HISTOGRAM_SIZE]) malloc(sizeof(*libraw_internal_data.output_data.histogram)*4);
merror(libraw_internal_data.output_data.histogram,"LibRaw::dcraw_make_mem_image()");
int perc, val, total, t_white=0x2000,c;
perc = S.width * S.height * 0.01; /* 99th percentile white level */
if (IO.fuji_width) perc /= 2;
if (!((O.highlight & ~2) || O.no_auto_bright))
for (t_white=c=0; c < P1.colors; c++) {
for (val=0x2000, total=0; --val > 32; )
if ((total += libraw_internal_data.output_data.histogram[c][val]) > perc) break;
if (t_white < val) t_white = val;
}
gamma_curve (O.gamm[0], O.gamm[1], 2, (t_white << 3)/O.bright);
}
unsigned ds = S.height * S.width * (O.output_bps/8) * P1.colors;
@ -915,7 +953,7 @@ libraw_processed_image_t *LibRaw::dcraw_make_mem_image(int *errcode)
if(errcode) *errcode= ENOMEM;
return NULL;
}
bzero(ret,sizeof(libraw_processed_image_t));
memset(ret,0,sizeof(libraw_processed_image_t));
// metadata init
int s_iheight = S.iheight;
@ -935,18 +973,16 @@ libraw_processed_image_t *LibRaw::dcraw_make_mem_image(int *errcode)
ret->width = S.width;
ret->colors = P1.colors;
ret->bits = O.output_bps;
ret->gamma_corrected = (O.output_bps == 8)?1:O.gamma_16bit;
ret->data_size = ds;
// Cut'n'paste from write_tiff_ppm, should be generalized later
uchar *bufp = ret->data;
uchar *ppm;
ushort *ppm2,lut16[0x10000];
ushort *ppm2;
int c, row, col, soff, rstep, cstep;
if (ret->bits == 8 || ret->gamma_corrected ) gamma_lut (lut16);
soff = flip_index (0, 0);
cstep = flip_index (0, 1) - soff;
rstep = flip_index (1, 0) - flip_index (0, S.width);
@ -957,11 +993,9 @@ libraw_processed_image_t *LibRaw::dcraw_make_mem_image(int *errcode)
ppm2 = (ushort*) (ppm = bufp);
for (col=0; col < ret->width; col++, soff += cstep)
if (ret->bits == 8)
FORCC ppm [col*ret->colors+c] = lut16[imgdata.image[soff][c]]/256;
else if(ret->gamma_corrected)
FORCC ppm2[col*ret->colors+c] = lut16[imgdata.image[soff][c]];
else
FORCC ppm2[col*ret->colors+c] = imgdata.image[soff][c];
FORCC ppm [col*ret->colors+c] = imgdata.color.curve[imgdata.image[soff][c]]>>8;
else
FORCC ppm2[col*ret->colors+c] = imgdata.color.curve[imgdata.image[soff][c]];
bufp+=ret->colors*(ret->bits/8)*ret->width;
}
if(errcode) *errcode= 0;
@ -1001,8 +1035,10 @@ int LibRaw::dcraw_ppm_tiff_writer(const char *filename)
(int (*)[LIBRAW_HISTOGRAM_SIZE]) malloc(sizeof(*libraw_internal_data.output_data.histogram)*4);
merror(libraw_internal_data.output_data.histogram,"LibRaw::dcraw_ppm_tiff_writer()");
}
write_ppm_tiff(f);
libraw_internal_data.internal_data.output = f;
write_ppm_tiff();
SET_PROC_FLAG(LIBRAW_PROGRESS_FLIP);
libraw_internal_data.internal_data.output = NULL;
fclose(f);
return 0;
}
@ -1059,7 +1095,7 @@ void LibRaw::kodak_thumb_loader()
scale_mul[3] = scale_mul[1];
size_t size = S.height * S.width;
for (int i=0; i < size*4 ; i++)
for (unsigned i=0; i < size*4 ; i++)
{
val = imgdata.image[0][i];
if(!val) continue;
@ -1087,15 +1123,16 @@ void LibRaw::kodak_thumb_loader()
for (col=0; col < S.width; col++, img+=4)
{
out[0] = out[1] = out[2] = 0;
for(int c=0;c<3;c++)
int c;
for(c=0;c<3;c++)
{
out[0] += out_cam[0][c] * img[c];
out[1] += out_cam[1][c] * img[c];
out[2] += out_cam[2][c] * img[c];
}
for(int c=0; c<3; c++)
for(c=0; c<3; c++)
img[c] = CLIP((int) out[c]);
for(int c=0; c<P1.colors;c++)
for(c=0; c<P1.colors;c++)
t_hist[c][img[c] >> 3]++;
}
@ -1103,13 +1140,27 @@ void LibRaw::kodak_thumb_loader()
// from gamma_lut
int (*save_hist)[LIBRAW_HISTOGRAM_SIZE] = libraw_internal_data.output_data.histogram;
libraw_internal_data.output_data.histogram = t_hist;
ushort *lut16 = (ushort*)calloc(0x10000,sizeof(ushort));
merror(lut16,"LibRaw::kodak_thumb_loader()");
gamma_lut(lut16);
// make curve output curve!
ushort (*t_curve) = (ushort*) calloc(sizeof(C.curve),1);
merror (t_curve, "LibRaw::kodak_thumb_loader()");
memmove(t_curve,C.curve,sizeof(C.curve));
memset(C.curve,0,sizeof(C.curve));
{
int perc, val, total, t_white=0x2000,c;
perc = S.width * S.height * 0.01; /* 99th percentile white level */
if (IO.fuji_width) perc /= 2;
if (!((O.highlight & ~2) || O.no_auto_bright))
for (t_white=c=0; c < P1.colors; c++) {
for (val=0x2000, total=0; --val > 32; )
if ((total += libraw_internal_data.output_data.histogram[c][val]) > perc) break;
if (t_white < val) t_white = val;
}
gamma_curve (O.gamm[0], O.gamm[1], 2, (t_white << 3)/O.bright);
}
libraw_internal_data.output_data.histogram = save_hist;
free(t_hist);
// from write_ppm_tiff - copy pixels into bitmap
@ -1134,10 +1185,13 @@ void LibRaw::kodak_thumb_loader()
char *ppm = T.thumb + row*S.width*P1.colors;
for (int col=0; col < S.width; col++, soff += cstep)
for(int c = 0; c < P1.colors; c++)
ppm [col*P1.colors+c] = lut16[imgdata.image[soff][c]]/256;
ppm [col*P1.colors+c] = imgdata.color.curve[imgdata.image[soff][c]]>>8;
}
}
free(lut16);
memmove(C.curve,t_curve,sizeof(C.curve));
free(t_curve);
// restore variables
free(imgdata.image);
imgdata.image = s_image;
@ -1163,62 +1217,6 @@ void LibRaw::kodak_thumb_loader()
#undef SWAP
void LibRaw::foveon_thumb_loader (void)
{
unsigned bwide, row, col, bitbuf=0, bit=1, c, i;
struct decode *dindex;
short pred[3];
if(T.thumb) free(T.thumb);
T.thumb = NULL;
bwide = get4();
if (bwide > 0)
{
if (bwide < T.twidth*3) return;
T.thumb = (char*)malloc(3*T.twidth * T.theight);
merror (T.thumb, "foveon_thumb()");
char *buf = (char*)malloc(bwide);
merror (buf, "foveon_thumb()");
for (row=0; row < T.theight; row++)
{
ID.input->read(buf, 1, bwide);
memmove(T.thumb+(row*T.twidth*3),buf,T.twidth*3);
}
free(buf);
T.tlength = 3*T.twidth * T.theight;
T.tformat = LIBRAW_THUMBNAIL_BITMAP;
return;
}
else
{
foveon_decoder (256, 0);
T.thumb = (char*)malloc(3*T.twidth * T.theight);
char *bufp = T.thumb;
merror (T.thumb, "foveon_thumb()");
for (row=0; row < T.theight; row++)
{
memset (pred, 0, sizeof pred);
if (!bit) get4();
for (bit=col=0; col < T.twidth; col++)
for(c=0;c<3;c++)
{
for (dindex=first_decode; dindex->branch[0]; )
{
if ((bit = (bit-1) & 31) == 31)
for (i=0; i < 4; i++)
bitbuf = (bitbuf << 8) + ID.input->get_char();
dindex = dindex->branch[bitbuf >> bit & 1];
}
pred[c] += dindex->leaf;
(*bufp++)=pred[c];
}
}
T.tformat = LIBRAW_THUMBNAIL_BITMAP;
T.tlength = 3*T.twidth * T.theight;
}
return;
}
// Äîñòàåò thumbnail èç ôàéëà, ñòàâèò thumb_format â ñîîòâåòñòâèè ñ ôîðìàòîì
@ -1268,14 +1266,6 @@ int LibRaw::unpack_thumb(void)
return 0;
}
else if (write_thumb == &LibRaw::foveon_thumb)
{
foveon_thumb_loader();
// may return with error, so format is set in
// foveon thumb loader itself
SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD);
return 0;
}
// else if -- all other write_thumb cases!
else
{
@ -1392,7 +1382,6 @@ int LibRaw::rotate_fuji_raw(void)
{
for(col=0;col<S.width;col++)
{
if (libraw_internal_data.unpacker_data.fuji_layout) {
r = IO.fuji_width - 1 - col + (row >> 1);
c = col + ((row+1) >> 1);
@ -1400,8 +1389,8 @@ int LibRaw::rotate_fuji_raw(void)
r = IO.fuji_width - 1 + row - (col >> 1);
c = row + ((col+1) >> 1);
}
newimage[((r) >> IO.shrink)*fiwidth + ((c) >> IO.shrink)][FC(r,c)] =
imgdata.image[((row) >> IO.shrink)*S.iwidth + ((col) >> IO.shrink)][FC(r,c)];
newimage[((r) >> IO.shrink)*fiwidth + ((c) >> IO.shrink)][FCF(row,col)] =
imgdata.image[((row) >> IO.shrink)*S.iwidth + ((col) >> IO.shrink)][FCF(row,col)];
}
}
// restore fuji sizes!
@ -1429,6 +1418,7 @@ int LibRaw::dcraw_process(void)
try {
adjust_maximum();
if(IO.fwidth)
rotate_fuji_raw();
@ -1464,13 +1454,8 @@ int LibRaw::dcraw_process(void)
if (O.user_black >= 0) C.black = O.user_black;
if (O.user_sat > 0) C.maximum = O.user_sat;
if (P1.is_foveon && !O.document_mode)
{
foveon_interpolate();
SET_PROC_FLAG(LIBRAW_PROGRESS_FOVEON_INTERPOLATE);
}
if (!P1.is_foveon && O.document_mode < 2)
if ( O.document_mode < 2)
{
scale_colors();
SET_PROC_FLAG(LIBRAW_PROGRESS_SCALE_COLORS);
@ -1498,26 +1483,24 @@ int LibRaw::dcraw_process(void)
SET_PROC_FLAG(LIBRAW_PROGRESS_MIX_GREEN);
}
if(!P1.is_foveon)
if (P1.colors == 3)
{
if (P1.colors == 3)
{
median_filter();
SET_PROC_FLAG(LIBRAW_PROGRESS_MEDIAN_FILTER);
}
if (O.highlight == 2)
{
blend_highlights();
SET_PROC_FLAG(LIBRAW_PROGRESS_HIGHLIGHTS);
}
if (O.highlight > 2)
{
recover_highlights();
SET_PROC_FLAG(LIBRAW_PROGRESS_HIGHLIGHTS);
}
median_filter();
SET_PROC_FLAG(LIBRAW_PROGRESS_MEDIAN_FILTER);
}
if (O.highlight == 2)
{
blend_highlights();
SET_PROC_FLAG(LIBRAW_PROGRESS_HIGHLIGHTS);
}
if (O.highlight > 2)
{
recover_highlights();
SET_PROC_FLAG(LIBRAW_PROGRESS_HIGHLIGHTS);
}
if (O.use_fuji_rotate)
{
fuji_rotate();
@ -1558,6 +1541,7 @@ int LibRaw::dcraw_process(void)
static const char *static_camera_list[] =
{
"Adobe Digital Negative (DNG)",
"AgfaPhoto DC-833m",
"Apple QuickTake 100",
"Apple QuickTake 150",
"Apple QuickTake 200",
@ -1571,7 +1555,10 @@ static const char *static_camera_list[] =
"Canon PowerShot A5 Zoom",
"Canon PowerShot A50",
"Canon PowerShot A460 (CHDK hack)",
"Canon PowerShot A470 (CHDK hack)",
"Canon PowerShot A530 (CHDK hack)",
"Canon PowerShot A570 (CHDK hack)",
"Canon PowerShot A590 (CHDK hack)",
"Canon PowerShot A610 (CHDK hack)",
"Canon PowerShot A620 (CHDK hack)",
"Canon PowerShot A630 (CHDK hack)",
@ -1581,6 +1568,7 @@ static const char *static_camera_list[] =
"Canon PowerShot A720 IS (CHDK hack)",
"Canon PowerShot Pro70",
"Canon PowerShot Pro90 IS",
"Canon PowerShot Pro1",
"Canon PowerShot G1",
"Canon PowerShot G2",
"Canon PowerShot G3",
@ -1589,6 +1577,7 @@ static const char *static_camera_list[] =
"Canon PowerShot G7 (CHDK hack)",
"Canon PowerShot G9",
"Canon PowerShot G10",
"Canon PowerShot G11",
"Canon PowerShot S2 IS (CHDK hack)",
"Canon PowerShot S3 IS (CHDK hack)",
"Canon PowerShot S5 IS (CHDK hack)",
@ -1599,11 +1588,14 @@ static const char *static_camera_list[] =
"Canon PowerShot S50",
"Canon PowerShot S60",
"Canon PowerShot S70",
"Canon PowerShot Pro1",
"Canon PowerShot S90",
"Canon PowerShot SX1 IS",
"Canon PowerShot SX110 IS (CHDK hack)",
"Canon EOS D30",
"Canon EOS D60",
"Canon EOS 5D",
"Canon EOS 5D Mark II",
"Canon EOS 7D",
"Canon EOS 10D",
"Canon EOS 20D",
"Canon EOS 30D",
@ -1613,13 +1605,15 @@ static const char *static_camera_list[] =
"Canon EOS 350D / Digital Rebel XT / Kiss Digital N",
"Canon EOS 400D / Digital Rebel XTi / Kiss Digital X",
"Canon EOS 450D / Digital Rebel XSi / Kiss Digital X2",
"Canon EOS 500D / Digital Rebel T1i / Kiss Digital X3",
"Canon EOS 1000D / Digital Rebel XS / Kiss Digital F",
"Canon EOS D2000C",
"Canon EOS-1D",
"Canon EOS-1DS",
"Canon EOS-1D Mark II",
"Canon EOS-1D Mark III",
"Canon EOS-1D Mark II N",
"Canon EOS-1D Mark III",
"Canon EOS-1D Mark IV",
"Canon EOS-1Ds Mark II",
"Canon EOS-1Ds Mark III",
"Casio QV-2000UX",
@ -1630,10 +1624,15 @@ static const char *static_camera_list[] =
"Casio QV-R41",
"Casio QV-R51",
"Casio QV-R61",
"Casio EX-S20",
"Casio EX-S100",
"Casio EX-Z4",
"Casio EX-Z50",
"Casio EX-Z55",
"Casio EX-Z60",
"Casio EX-Z75",
"Casio EX-Z750",
"Casio EX-Z850",
"Casio Exlim Pro 505",
"Casio Exlim Pro 600",
"Casio Exlim Pro 700",
@ -1659,6 +1658,7 @@ static const char *static_camera_list[] =
"Fuji FinePix S7000",
"Fuji FinePix S9000/S9500",
"Fuji FinePix S9100/S9600",
"Fuji FinePix S200EXR",
"Fuji IS-1",
"Hasselblad CFV",
"Hasselblad H3D",
@ -1702,6 +1702,8 @@ static const char *static_camera_list[] =
"Kodak C603",
"Kodak P850",
"Kodak P880",
"Kodak Z980",
"Kodak Z1015",
"Kodak KAI-0340",
"Konica KD-400Z",
"Konica KD-510Z",
@ -1745,6 +1747,7 @@ static const char *static_camera_list[] =
"Minolta DiMAGE Z2",
"Minolta Alpha/Dynax/Maxxum 5D",
"Minolta Alpha/Dynax/Maxxum 7D",
"Motorola PIXL",
"Nikon D1",
"Nikon D1H",
"Nikon D1X",
@ -1765,7 +1768,10 @@ static const char *static_camera_list[] =
"Nikon D100",
"Nikon D200",
"Nikon D300",
"Nikon D300s",
"Nikon D700",
"Nikon D3000",
"Nikon D5000",
"Nikon E700 (\"DIAG RAW\" hack)",
"Nikon E800 (\"DIAG RAW\" hack)",
"Nikon E880 (\"DIAG RAW\" hack)",
@ -1796,10 +1802,12 @@ static const char *static_camera_list[] =
"Olympus C740UZ",
"Olympus C770UZ",
"Olympus C8080WZ",
"Olympus X200,D560Z,C350Z",
"Olympus E-1",
"Olympus E-3",
"Olympus E-10",
"Olympus E-20",
"Olympus E-30",
"Olympus E-300",
"Olympus E-330",
"Olympus E-400",
@ -1808,6 +1816,8 @@ static const char *static_camera_list[] =
"Olympus E-500",
"Olympus E-510",
"Olympus E-520",
"Olympus E-620",
"Olympus E-P1",
"Olympus SP310",
"Olympus SP320",
"Olympus SP350",
@ -1820,9 +1830,11 @@ static const char *static_camera_list[] =
"Panasonic DMC-FZ18",
"Panasonic DMC-FZ28",
"Panasonic DMC-FZ30",
"Panasonic DMC-FZ35/FZ38",
"Panasonic DMC-FZ50",
"Panasonic DMC-FX150",
"Panasonic DMC-G1",
"Panasonic DMC-GH1",
"Panasonic DMC-L1",
"Panasonic DMC-L10",
"Panasonic DMC-LC1",
@ -1840,6 +1852,8 @@ static const char *static_camera_list[] =
"Pentax K100D Super",
"Pentax K200D",
"Pentax K2000/K-m",
"Pentax K-x",
"Pentax K-7",
"Pentax Optio S",
"Pentax Optio S4",
"Pentax Optio 33WR",
@ -1852,17 +1866,15 @@ static const char *static_camera_list[] =
"Phase One P 25",
"Phase One P 30",
"Phase One P 45",
"Phase One P 45+",
"Pixelink A782",
"Polaroid x530",
"Rollei d530flex",
"RoverShot 3320af",
"Samsung GX-1S",
"Samsung GX-10",
"Samsung S85 (hacked)",
"Samsung S850 (hacked)",
"Sarnoff 4096x5440",
"Sigma SD9",
"Sigma SD10",
"Sigma SD14",
"Sinar 3072x2048",
"Sinar 4080x4080",
"Sinar 4080x5440",
@ -1876,11 +1888,17 @@ static const char *static_camera_list[] =
"Sony DSLR-A100",
"Sony DSLR-A200",
"Sony DSLR-A300",
"Sony DSLR-A330",
"Sony DSLR-A350",
"Sony DSLR-A380",
"Sony DSLR-A500",
"Sony DSLR-A550",
"Sony DSLR-A700",
"Sony DSLR-A850",
"Sony DSLR-A900",
"Sony XCD-SX910CR",
"STV680 VGA",
NULL
};
@ -1908,8 +1926,6 @@ const char * LibRaw::strprogress(enum LibRaw_progress p)
return "Removing dead pixels";
case LIBRAW_PROGRESS_DARK_FRAME:
return "Subtracting dark frame data";
case LIBRAW_PROGRESS_FOVEON_INTERPOLATE:
return "Interpolating Foveon sensor data";
case LIBRAW_PROGRESS_SCALE_COLORS:
return "Scaling colors";
case LIBRAW_PROGRESS_PRE_INTERPOLATE:

Loading…
Cancel
Save