Sync from SUSE:SLFO:Main dcraw revision 8997fb911317f27102cbd1d4cd1a5b1e

This commit is contained in:
Adrian Schröter 2024-05-03 12:00:36 +02:00
commit 5cd871ac23
21 changed files with 7146 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1267
README Normal file

File diff suppressed because it is too large Load Diff

3
README.openSUSE Normal file
View File

@ -0,0 +1,3 @@
To prevent name clashes, following tools from dcraw were renamed:
parse -> dcparse

37
badpixels Normal file
View File

@ -0,0 +1,37 @@
# .badpixels file for my Canon PowerShot G2, serial no. 4624504380
# dcraw will use this file if run in the same directory, or in any
# subdirectory.
# Always use "dcraw -d -j -t 0" when locating bad pixels!!
# Format is: pixel column, pixel row, UNIX time of death
# This pixel went bad between August 1 and 4, 2002
962 91 1028350000
# This pixel went bad between January 9 and 30, 2003
902 877 1043000000
# These are only visible in low light, so I haven't dated them:
621 943 0
1285 1067 0
1286 1067 0
2181 1532 0
# I swept these up 4/19/2005
763 36 1110000000
1827 466 1110000000
# low light
198 1288 1110000000
346 328 1110000000
429 273 1110000000
621 943 1110000000
624 874 1110000000
848 400 1110000000
1682 1686 1110000000
1892 1250 1110000000
2234 484 1110000000
2242 618 1110000000
555 698 1135100000 # December 20-21, 2005
640 157 1139000000 # February 2-5, 2006

80
clean_crw.c Normal file
View File

@ -0,0 +1,80 @@
/*
Because they are parsed from the end, Canon CRW files
become unreadable if garbage data is appended to them, as
often happens when files are recovered from damaged media.
This program truncates CRW files to the correct size.
Copyright 2005 by Dave Coffin, dcoffin a cybercom o net
Free for all uses.
$Revision$
$Date$
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
unsigned char *buffer;
int get4 (int i)
{
if (buffer[0] == 'I')
return buffer[i+3] << 24 | buffer[i+2] << 16 | buffer[i+1] << 8 | buffer[i];
else
return buffer[i] << 24 | buffer[i+1] << 16 | buffer[i+2] << 8 | buffer[i+3];
}
int main (int argc, char **argv)
{
int arg, size, end, diff, status=1;
unsigned char *fname;
FILE *fp;
if (argc == 1)
fprintf (stderr, "Usage: %s crw_0001.crw crw_0002.crw ...\n", argv[0]);
for (arg=1; arg < argc; arg++) {
status = 1;
fp = fopen (argv[arg], "rb");
fseek (fp, 0, SEEK_END);
size = ftell(fp);
buffer = malloc (size + strlen(argv[arg]) + 10);
if (!buffer) {
fprintf (stderr, "Cannot allocate memory!\n");
return 2;
}
fname = buffer + size;
sprintf (fname, "%s.clean", argv[arg]);
fseek (fp, 0, SEEK_SET);
fread (buffer, 1, size, fp);
fclose (fp);
if (strncmp (buffer, "II\x1a\0\0\0HEAPCCDR", 14) &&
strncmp (buffer, "MM\0\0\0\x1aHEAPCCDR", 14)) {
fprintf (stderr, "%s is not a CRW file!\n", argv[arg]);
free (buffer);
continue;
}
for (end=size; end > 0xa0000; end--) {
diff = end - get4(end-4);
if (diff > 50 && diff < 120 && diff % 10 == 2) {
status = 0;
break;
}
}
if (status)
fprintf (stderr, "Failed to clean %s\n", argv[arg]);
else {
if ((fp = fopen (fname, "wb"))) {
fprintf (stderr, "Writing %s\n", fname);
fwrite (buffer, 1, end, fp);
fclose (fp);
} else {
perror (fname);
status = 1;
}
}
free (buffer);
}
return status;
}

BIN
dcraw-9.28.0.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,14 @@
diff -urNp old/dcraw.c new/dcraw.c
--- old/dcraw.c 2018-07-11 10:33:06.280425391 +0200
+++ new/dcraw.c 2018-07-11 10:45:52.722922118 +0200
@@ -2250,6 +2250,10 @@ void CLASS kodak_radc_load_raw()
((short *)buf)[i] = 2048;
for (row=0; row < height; row+=4) {
FORC3 mul[c] = getbits(6);
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!mul[0] || !mul[1] || !mul[2])
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
FORC3 {
val = ((0x1000000/last[c] + 0x7ff) >> 12) * mul[c];
s = val > 65564 ? 10:12;

View File

@ -0,0 +1,21 @@
diff -urNp old/dcraw.c new/dcraw.c
--- old/dcraw.c 2018-07-11 10:53:51.141803505 +0200
+++ new/dcraw.c 2018-07-11 11:30:08.850528389 +0200
@@ -2627,8 +2627,15 @@ void CLASS kodak_65000_load_raw()
len = MIN (256, width-col);
ret = kodak_65000_decode (buf, len);
for (i=0; i < len; i++)
- if ((RAW(row,col+i) = curve[ret ? buf[i] :
- (pred[i & 1] += buf[i])]) >> 12) derror();
+ {
+ int idx = ret ? buf[i] : (pred[i & 1] += buf[i]);
+ if(idx >=0 && idx <= 0xffff)
+ {
+ if ((RAW(row,col+i) = curve[idx]) >> 12) derror();
+ }
+ else
+ derror();
+ }
}
}

View File

@ -0,0 +1,39 @@
Author: Filip Hroch <hroch@physics.muni.cz>
Description: stack-based buffer overflow bug
--- a/dcraw.c
+++ b/dcraw.c
@@ -8345,9 +8345,15 @@
{
UINT64 bitbuf=0;
int vbits, col, i, c;
- ushort img[2][2064];
+ ushort *img;
double sum[]={0,0};
+#define IMG2D(row,col) \
+ img[(row)*width+(col)]
+
+ img = (ushort *) malloc(2*width*sizeof(ushort));
+ merror (img, "find_green()");
+
FORC(2) {
fseek (ifp, c ? off1:off0, SEEK_SET);
for (vbits=col=0; col < width; col++) {
@@ -8356,13 +8362,14 @@
for (i=0; i < bite; i+=8)
bitbuf |= (unsigned) (fgetc(ifp) << i);
}
- img[c][col] = bitbuf << (64-bps-vbits) >> (64-bps);
+ IMG2D(c,col) = bitbuf << (64-bps-vbits) >> (64-bps);
}
}
FORC(width-1) {
- sum[ c & 1] += ABS(img[0][c]-img[1][c+1]);
- sum[~c & 1] += ABS(img[1][c]-img[0][c+1]);
+ sum[ c & 1] += ABS(IMG2D(0,c)-IMG2D(1,c+1));
+ sum[~c & 1] += ABS(IMG2D(1,c)-IMG2D(0,c+1));
}
+ free(img);
return 100 * log(sum[0]/sum[1]);
}

125
dcraw-CVE-2018-5801.patch Normal file
View File

@ -0,0 +1,125 @@
diff -urNp old/dcraw.c new/dcraw.c
--- old/dcraw.c 2018-06-14 12:38:10.519964843 +0200
+++ new/dcraw.c 2018-06-14 13:31:46.304679761 +0200
@@ -1248,6 +1248,10 @@ void CLASS nikon_load_raw()
void CLASS nikon_yuv_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
int row, col, yuv[4], rgb[3], b, c;
UINT64 bitbuf=0;
@@ -1889,6 +1893,10 @@ void CLASS sinar_4shot_load_raw()
unpacked_load_raw();
return;
}
+#ifdef LIBRAW_LIBRARY_BUILD
+ else if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
pixel = (ushort *) calloc (raw_width, sizeof *pixel);
merror (pixel, "sinar_4shot_load_raw()");
for (shot=0; shot < 4; shot++) {
@@ -2188,6 +2196,11 @@ void CLASS quicktake_100_load_raw()
void CLASS kodak_radc_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ // All kodak radc images are 768x512
+ if(width>768 || raw_width>768 || height > 512 || raw_height>512 )
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
static const char src[] = {
1,1, 2,3, 3,4, 4,2, 5,7, 6,5, 7,6, 7,8,
1,0, 2,1, 3,3, 4,4, 5,2, 6,7, 7,6, 8,5, 8,8,
@@ -2348,6 +2361,10 @@ void CLASS gamma_curve (double pwr, doub
void CLASS lossy_dng_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
JSAMPARRAY buf;
@@ -2444,6 +2461,10 @@ void CLASS eight_bit_load_raw()
void CLASS kodak_c330_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
uchar *pixel;
int row, col, y, cb, cr, rgb[3], c;
@@ -2469,6 +2490,10 @@ void CLASS kodak_c330_load_raw()
void CLASS kodak_c603_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
uchar *pixel;
int row, col, y, cb, cr, rgb[3], c;
@@ -2596,6 +2621,10 @@ void CLASS kodak_65000_load_raw()
void CLASS kodak_ycbcr_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
short buf[384], *bp;
int row, col, len, c, i, j, k, y[2][2], cb, cr, rgb[3];
ushort *ip;
@@ -2624,6 +2653,10 @@ void CLASS kodak_ycbcr_load_raw()
void CLASS kodak_rgb_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
short buf[768], *bp;
int row, col, len, c, i, rgb[3];
ushort *ip=image[0];
@@ -2640,6 +2673,10 @@ void CLASS kodak_rgb_load_raw()
void CLASS kodak_thumb_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
int row, col;
colors = thumb_misc >> 5;
for (row=0; row < height; row++)
@@ -3109,6 +3146,10 @@ void CLASS foveon_thumb()
void CLASS foveon_sd_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
struct decode *dindex;
short diff[1024];
unsigned bitbuf=0;
@@ -3156,6 +3197,10 @@ void CLASS foveon_huff (ushort *huff)
void CLASS foveon_dp_load_raw()
{
+#ifdef LIBRAW_LIBRARY_BUILD
+ if(!image)
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
+#endif
unsigned c, roff[4], row, col, diff;
ushort huff[512], vpred[2][2], hpred[2];

17
dcraw-CVE-2021-3624.patch Normal file
View File

@ -0,0 +1,17 @@
--- dcraw/dcraw.c 2022-04-12 14:29:23.791896447 +0200
+++ dcraw/dcraw.c 2022-04-12 14:59:50.767180929 +0200
@@ -3289,7 +3289,13 @@
}
} else if (type == 4) {
free (meta_data);
- meta_data = (char *) malloc (meta_length = wide*high*3/2);
+ meta_data = NULL;
+ meta_length = wide*high*3/2;
+ if (meta_length/wide != high*3/2) {
+ fprintf(stderr, "Potential buffer overflow (meta_length %u, wide %u, high %u). Bailing out...\n", meta_length, wide, high);
+ longjmp(failure, 2);
+ }
+ meta_data = (char *) malloc (meta_length);
merror (meta_data, "foveon_load_camf()");
foveon_huff (huff);
get4();

24
dcraw-glibc-2.38.patch Normal file
View File

@ -0,0 +1,24 @@
Index: dcraw/parse.c
===================================================================
--- dcraw.orig/parse.c
+++ dcraw/parse.c
@@ -1213,7 +1213,7 @@ void parse_qt (int level, int end)
}
}
-char *memmem (char *haystack, size_t haystacklen,
+static char *my_memmem (char *haystack, size_t haystacklen,
char *needle, size_t needlelen)
{
char *c;
@@ -1239,8 +1239,8 @@ void identify()
tread (head, 1, 32, ifp);
tseek (ifp, 0, SEEK_END);
fsize = ftell(ifp);
- if ((cp = memmem (head, 32, "MMMM", 4)) ||
- (cp = memmem (head, 32, "IIII", 4))) {
+ if ((cp = my_memmem (head, 32, "MMMM", 4)) ||
+ (cp = my_memmem (head, 32, "IIII", 4))) {
parse_phase_one (cp-head);
if (cp-head) parse_tiff (0,0);
} else if (order == 0x4949 || order == 0x4d4d) {

532
dcraw.changes Normal file
View File

@ -0,0 +1,532 @@
-------------------------------------------------------------------
Mon Aug 7 09:53:25 UTC 2023 - Dirk Müller <dmueller@suse.com>
- add dcraw-glibc-2.38.patch to fix prototype clash on memmem with glibc 2.38+
-------------------------------------------------------------------
Tue Apr 12 11:30:56 UTC 2022 - Fridrich Strba <fstrba@suse.com>
- Added patches:
* iowrappers.patch
+ Written wrappers of fread(),fwrite(),fseek() library functions
which check their return values. If an input/output failure is
detected, dcraw immediately exits with non-zero status and
prints a descriptive message (bsc#1097973, CVE-2018-5805;
bsc#1097974, CVE-2018-5806; bsc#1117622, CVE-2018-19565;
bsc#1117517, CVE-2018-19566; bsc#1117512, CVE-2018-19567;
bsc#1117436, CVE-2018-19568)
* dcraw-CVE-2021-3624.patch
+ Bail out if integer overflow happened and the allocated buffer
would be too small (bsc#1189642, CVE-2021-3624)
-------------------------------------------------------------------
Sun Aug 16 22:39:47 UTC 2020 - Matthias Eliasson <elimat@opensuse.org>
- Update to version 9.28.0:
dcraw - revision 1.478
* Caught up on two years' worth of new cameras.
- Update upstream URL to new address
- Add patches for CVEs:
* dcraw-CVE-2017-13735.patch (CVE-2017-13735, bsc#1056170)
* dcraw-CVE-2017-14608.patch (CVE-2017-14608, bsc#1063798)
* dcraw-CVE-2018-19655.patch (CVE-2018-19655, bsc#1117896)
* dcraw-CVE-2018-5801.patch (CVE-2018-5801, bsc#1084690)
- Run spec-cleaner
* Remove package groups
-------------------------------------------------------------------
Fri Aug 5 22:12:55 UTC 2016 - asterios.dramis@gmail.com
- Update to version 9.27.0:
dcraw - revision 1.477
* Added "-o 6" for ACES colorspace.
* Copied color matrices from DNG Converter 9.5.1.
* Support the Canon EOS 80D & IXUS 160, Fuji X-E2 & X-E2S &
X-Pro2.
-------------------------------------------------------------------
Mon Jul 20 07:34:22 UTC 2015 - fstrba@suse.com
- Update to version 9.26.0:
* fixes:
dcraw revision 1.476
* Support the Blackmagic URSA, Nokia N9, and Photron BC2-HD.
* Support the Canon EOS 750D, 760D, EOS M, and sRAW/mRAW for EOS 5DS R.
* When there's a tie for largest raw image, "-s" says which to decode.
* Fixed null-byte warnings in TIFF output.
dcraw revision 1.475
* Use typecasts instead of [0] to flatten multi-dimensional arrays.
dcraw revision 1.474
* Updated color matrices, support the Canon EOS 5DS.
-------------------------------------------------------------------
Fri Feb 27 22:05:35 UTC 2015 - asterios.dramis@gmail.com
- Update to version 9.24.2:
dcraw - revision 1.473
* Canon multi-exposure files are already white-balanced.
* Moved border_interpolate() to the end of xtrans_interpolate().
From version 9.24.1:
* No visible changes.
From version 9.24.0:
dcraw - revision 1.471
* Support all format options of the Nikon D4S and D810.
* Guess which filter pattern OmniVision cameras use.
dcparse - revision 1.77
* Display OmniVision's MakerNote.
From version 9.23.0:
dcraw - revision 1.470
* Fixed data errors with Olympus E-M5MarkII HR images.
* Support the Lenovo A820.
* Copied color matrices from DNG Converter 8.7.1.
* Support pre-release Sonys and Canons that lack a proper model
name.
* Support the Samsung NX1 (yet another compression algorithm).
* Read camera white balance in all professional Kodak cameras.
* Reduced zippering in Fuji X-Trans interpolation.
* Support YCbCr files from the Kodak C330.
* Support Hasselblad multi-shot files.
dcparse - revision 1.76
* Parse Redcine and Canon EOS QuickTime movies.
-------------------------------------------------------------------
Tue Jul 15 17:59:16 UTC 2014 - asterios.dramis@gmail.com
- Update to version 9.22:
dcraw - revision 1.467
* Correctly handle Fuji X-Trans images in DNG format.
* Copied color matrices from DNG Converter 8.5.
From version 9.21:
dcraw - revision 1.465
* In colorcheck(), darken sample squares and do a second pass for exact white
balance.
* Removed C99 dependency in Phase One code.
* Correctly dereference TIFF type 13 (SubIFD) tags.
* Removed redundant strings.
* Support Lossy DNG files that lack an OpcodeList2 tag.
* Decode DNG files made from Fuji X-Trans photos.
* Support the Canon G1 X Mark II, Nikon P340, Samsing NX mini.
* Patched in Anders Torger's code for Phase One correction.
* Correctly crop all Sony cameras, read Panasonic blacklevels.
-------------------------------------------------------------------
Mon Feb 17 21:56:48 UTC 2014 - asterios.dramis@gmail.com
- Update to version 9.20:
dcraw - revision 1.461
* Fixed Sony A700 black level.
* Added three temporary color matrices.
* Use Little CMS version 2.
* Support the Kodak 12-megapixel camera(s).
* Can now use "-M" with a DNG file that embeds a bad color matrix.
* Improved support for Nokia cameraphones.
* Support the Alcatel 5235D, Powershot G16 and S120, Pentax K-3, etc.
* Added tone curve for Canon RMF files.
* Copied color matrices from DNG Converter 8.3.
* Support blacklevel patterns up to 64x64.
dcparse - revision 1.75
* Read the Pentax K-3 MakerNote.
- Renamed README.SuSE to README.openSUSE.
- Added new build requirement liblcms2-devel (removed liblcms-devel).
-------------------------------------------------------------------
Sun Jun 16 20:54:03 UTC 2013 - asterios.dramis@gmail.com
- Update to version 9.19:
dcraw - revision 1.456
* Fix green spots when half-sizing Fuji X-Trans images.
* Support the Baumer TXG14, OmniVision OV5647 (Raspberry Pi), and Samsung
NX2000.
From version 9.18:
dcraw - revision 1.455
* Support the Fuji HS50, X20, X100S, SL1000, Samsung NX300, Canon A3300 and
EOS C500, and Olympus XZ-10.
* Added Frank Markesteijn's X-Trans demosaic algorithm.
* Lowercased the names of all camera makers.
* Hardened dcraw against corrupt input files.
* Tableized away large chunks of code in identify().
- Removed dcraw.1.patch (not needed anymore).
-------------------------------------------------------------------
Fri Jan 18 12:52:55 UTC 2013 - postadal@suse.cz
- Update to version 9.17:
dcraw - revision 1.454
* Copied color matrices from DNG Converter 7.3.
* Support the Canon EOS 6D, 1DX, SX50, Casio EX-ZR100, Fuji X-E1 & XF1,
Pentax K-5 II (s), and Samsung EX2F
- updated update_dcraw script to be able to work with dcraw tarball
-------------------------------------------------------------------
Mon Jul 30 20:44:51 UTC 2012 - asterios.dramis@gmail.com
- Update to version 9.16:
dcraw - revision 1.452
* Measured saturation level on the Canon EOS-1D X.
* Support the Samsung NX1000 and Sony RX100.
* Support the Canon EOS 650D, Samsung NX20, and Sigma SD1.
-------------------------------------------------------------------
Tue Jun 26 17:57:13 UTC 2012 - asterios.dramis@gmail.com
- Update to version 9.15:
dcraw - revision 1.449
* Fixed gravity sensor for Canon 5D Mark III with Firmware Version 1.1.x.
* Decode CAMF and IMAG blocks from Sigma SD15 and DP cameras. Added "-E" and
"-I" options to support raw pixel substitution. Support Adobe Lossy DNG and
the Imacon Flexframe 3f format. Support the Canon G1-X, 1D-X, 5D Mark III,
the Fuji X-Pro1, X-S1, and many others.
* Support the Casio EX-Z500.
dcparse - revision 1.74
* Decode CAMF blocks from Sigma SD15 and DP cameras.
- Dropped dcraw-omp.patch (wasn't used anyway).
-------------------------------------------------------------------
Tue Mar 27 08:41:25 UTC 2012 - cfarrell@suse.com
- license update: GPL-2.0+
Use option (b) from dcraw.c
-------------------------------------------------------------------
Fri Dec 23 18:52:51 UTC 2011 - asterios.dramis@gmail.com
- Update to version 9.12:
dcraw - revision 1.446
* Support the Canon S100, Nikon 1 J1 and V1, Panasonic GX1, Fuji X10, and
Samsung NX200 with color matrices from DNG Converter 6.6.
-------------------------------------------------------------------
Fri Oct 7 19:34:48 UTC 2011 - asterios.dramis@gmail.com
- Update to version 9.11:
dcraw - revision 1.445
* Copied new color matrices from DNG Converter 6.5.
- Spec file updates:
* Changes based on spec-cleaner run.
* Removed support for openSUSE < 11.3.
-------------------------------------------------------------------
Sun Sep 18 17:17:12 UTC 2011 - jengelh@medozas.de
- Remove redundant tags/sections from specfile
(cf. packaging guidelines)
-------------------------------------------------------------------
Wed Aug 3 21:04:01 UTC 2011 - asterios.dramis@gmail.com
- updated to version 9.10
dcraw - revision 1.444
* Support ARRIRAW and Redcode R3D raw formats (video only).
* Support the Leica D-LUX 5 and V-LUX 2, Panasonic G3 and GF3, Olympus E-P3,
Sony NEX-C3 and SLT-A35, and Canon SX30.
* Updated support for Nikon encrypted WB and Canon sRAW/mRAW.
- Spec file updates:
* Added libjasper-devel in BuildRequires:.
-------------------------------------------------------------------
Sat May 14 12:05:25 UTC 2011 - asterios.dramis@gmail.com
- updated to version 9.08
dcraw - revision 1.443
* Support the Fuji HS20EXR/F550EXR, Kodak Z990, Leaf AFi-II 12, Nikon D5100
and Samsung NX11 and NX100.
dcparse - revision 1.73
* Improved parsing of Fuji images.
- Spec file updates:
* Small fix if suse_version is not set.
-------------------------------------------------------------------
Mon Apr 4 20:18:58 UTC 2011 - asterios.dramis@gmail.com
- updated to version 9.07 (dcraw revision 1.442)
* Support the Hasselblad 9044x6732 back, Leaf 1068x1464 back, Fuji X100 and
Canon 600D and 1100D.
-------------------------------------------------------------------
Wed Mar 23 19:09:55 UTC 2011 - asterios.dramis@gmail.com
- updated to version 9.06
* Support the Nikon D3100 & D7000 & P7000, Panasonic FZ40 & FZ100 & LX5,
Samsung WB2000, Nokia X2, Canon SX120 & PowerShot G12, Hasselblad H4D,
Pentax 645D & K-5 & K-r, Sony SLT-A33 & SLT-A55V, Canon SX20 IS, Samsung
EX1, Sony A450, Kodak Z981, Olympus E-P2, Panasonic G2 & GF1, Samsung WB550
and NX10, Casio EX-Z1050, Fuji HS10, Canon EOS 550D / Digital Rebel T2i /
Kiss Digital X4.
* Support high-ISO images from the Samsung WB2000.
* Read correct camera WB from Nikon NRW and Samsung SRW files.
* Copied color matrices from Adobe DNG Converter 6.3.
* Fixed rotation for Kodak EasyShare and some Canon EOS photos.
* Get Fuji HS10 black level from the metadata.
* Built color matrices for the Sony NEX-3 and NEX-5.
* Support A100 images modified by Sony software.
* Split the darkness level into four separate color channels.
- Replaced dcraw.c and dcraw.1 with the package tarball provided from the official
site.
- Added clean_crw and fuji_green programs.
- Added rawphoto.c file in the documentation (gimp-plugin).
- Removed dcwrap program (no longer provided from the official site).
- Spec file updates:
* Changed version numbering scheme (used the one from the tarball provided).
* Changes based on rpmdevtools templates and spec-cleaner run.
* Added description for dcraw-omp.patch based on openSUSE Patches Guidelines.
* Added gettext-runtime in BuildRequires:.
* Added dcraw-lang package.
* Compile also fujiturn16 program (to rotate 48-bit PPM images).
* Updates in %prep, %build, %install and %files sections based also on Fedora
and Debian packages.
- Rebased dcraw-omp.patch to apply cleanly.
- Added a patch for dcraw.1 to fix "macro `LO' not defined" rpm post build
check warning.
- Added a patch for fuji_green.c to fix gcc implicit declaration warning.
-------------------------------------------------------------------
Sun May 2 00:56:47 CEST 2010 - postadal@suse.cz
- updated to RCS 1.432
* Support the Canon EOS-1D Mark IV and PowerShots G11 and S90,
Casio EX-Z750, Pentax K-x, Fuji SX200EXR, Sony A550, Sony DSLR-A850,
Canon EOS 7D, Casio EX-Z850, Canon A470, G11, Nikon D3000,
Panasonic FZ35/FZ38, Casio Z60, Casio Z75, Kodak Z980, Pentax K-7,
Olympus X200,D560Z,C350Z
* Correctly crop Nikon D300S photos
* Support camera WB for the Kodak EasyShare Z980 and Z1015
* Decode all packed 10-bit and 12-bit formats in one function
* Copied color matrices from Adobe DNG Converter 5.4
-------------------------------------------------------------------
Sun Nov 15 16:39:58 CET 2009 - meissner@suse.de
- rediffed OMP patch to get fuzz-0
-------------------------------------------------------------------
Thu Aug 6 16:11:05 CEST 2009 - postadal@suse.cz
- updated to RCS 1.425
* Support the Phase One P45+, Casio EX-S20, Samsung S850, Agfa DC-833m,
Panasonic DMC-GH1, Canon SX1, SX110,, EOS 500D/Rebel T1i/Kiss X3,
Motorola PIXL, Kodak Z1015, Olympus E-30, Pentax K2000/K-m, Hasselblad V96C,
Samsung S85, Leaf AFi 7, Panasonic FX150 and G1, Canon PowerShot G10,
Panasonics LX3 and FZ28, Nikons D90 and P6000, Canon EOS 50D, Sony A900,
* When sampling dark pixels, don't get too close to the light pixels
* Linearize the Apple Quicktake, Kodak DC40/DC50, and Logitech Fotoman Pixtura
* Added "-g" option for custom gamma curves
* Support 3672 x 2486 images from the Panasonic DMC-FZ50
* Correctly handle negative pixels in split NEF files
* Support GPS-tagged ORFs and anonymous DNGs
* Support the sRAW1 and sRAW2 modes of the Canon EOS 50D and 5D Mark II
- updated omp.patch
-------------------------------------------------------------------
Sun Sep 7 22:40:44 CEST 2008 - postadal@suse.cz
- updated to RCS 1.404
* Support the Kodak C603, Nikon D700, Canon EOS 1000D,
Canon PowerShot SD300, and Olympus E-520, SONY A300
* Removed useless code from ppg_interpolate()
* Don't crash on corrupt CR2 files
* Extract the largest JPEG from any X3F file
* Fixed camera WB on the A200
* Set model-specific saturation levels in adobe_coeff()
-------------------------------------------------------------------
Sun Apr 13 22:57:10 CEST 2008 - postadal@suse.cz
- updated to RCS 1.401
* Copy GPS data into thumbnails and TIFF output
* Support the Apple QuickTake 200, Fuji IS-1, Sony DSLR-A350,
Pentax K20D, Nokia N95, and Canon PowerShots A460, A530, and A650
Canon EOS 450D, Nikon D60, and Fuji S100FS, Olympus E-420
* Copied new matrices from Adobe DNG Converter 4.4
* fixed sRAW support (broke Fuji DNG files)
- added omp.patch to speed up decoding (-fomp disabled by default)
-------------------------------------------------------------------
Tue Feb 12 10:54:10 CET 2008 - postadal@suse.cz
- updated to RCS 1.398
* Added the "-P" and "-S" options
* Support the Sony DSLR-A200 and the PowerShots A720 and S5 IS
* Support the Panasonic DMC-L10, added the "-W" option
* Cropped four columns from the Nikon D3
* Abolished the getrat() macro, support the Hasselblad H3D
* Added the Olympus E-3 and adjusted a few maximums
* Support the AVT F-080C, Canon EOS 40D, Canon EOS-1Ds Mark III,
Canon PowerShot G9, Nikon Coolpix S6, Nikon D3, Nikon D300,
Panasonic DMC-FZ18, and Sony DSLR-A700
* Support the new Canon sRAW CR2 format
* Added median filtering after interpolation
* Use fseeko() and ftello() only when needed
* Reject TIFF files with unsupported Compression tags
-------------------------------------------------------------------
Fri Aug 3 17:16:18 CEST 2007 - postadal@suse.cz
- updated to RCS 1.390
* Added Patterned Pixel Grouping interpolation
* Support 3096x2103 mode for the Panasonic DMC-FZ8.
* Added "-C" option to correct chromatic aberration.
* Support the Hasselblad CFV, Kodak EasyShare C330, and Nikon D40X.
* Use a switch statement for Leica and Panasonic models.
* Output seven new TIFF tags, including ImageDescription and Artist.
* Generated color matrices for the Apple QuickTake and Phase One H 20.
* Copied new matrices from Adobe DNG Converter 4.1.
* Added "-M" option and improved PPG interpolation.
* Reports of corruption in 16-bit linear DNGs were false.
* Support all Lossless JPEG predictors.
* Reject 8-bit grayscale TIFFs.
* Decode raw CINE files, which may exceed 2GB.
* Error-check the "-s" option, and enable "-s all".
* Support camera WB for the Canon EOS-1D and EOS-1DS.
* Use full output range for "-H 2".
* Added color matrix for the Canon PowerShot A640.
* When they differ, use DateTimeOriginal instead of DateTime.
-------------------------------------------------------------------
Thu May 3 14:31:24 CEST 2007 - postadal@suse.cz
- updated to RCS 1.379
* Offer blended highlights with the "-H 2" option
* Set "shot_order" for ORF and CR2 files
* Added "-A" option to select a rectangle for white balance
* Protect against overflow attacks on malloc() or calloc()
* Nucore raw formats are not used outside Nucore, so drop them
* Support the Canon PowerShots A630 and A640, Panasonic DMC-FZ8,
* Sigma SD14, Apple QuickTake 100 & 150, Mamiya ZD, Casio QV-R41,
Olympus E-410 and Pentax Optio 750Z
- fixed doc permissions
-------------------------------------------------------------------
Wed Apr 25 02:12:58 CEST 2007 - postadal@suse.cz
- updated to RCS 1.377
* Added a color matrix for the Fuji S6000fd
* Set aspect ratio for the Kodak DC20 and DC25
* Replaced bilateral filter with wavelet denoising
* Fixed incompatibility between "-f" and "-p"
* Fixed strange color casts with the Polaroid x530
* Added Adobe matrices for the Nikon D40 and Pentax K10D
* Found larger JPEG thumbs for Nikon D100,D1H,D1X,D2H,D2X,E5000,E5700
* Support the Canon EOS-1D Mark III, Olympus SP550UZ, Fuji FinePix S5Pro
* Use the "a trous" wavelet transform instead of the JPEG2000 method
* Apply sqrt() to denoise highlights and shadows evenly
* Optimized AHD interpolation to take 22% less time
* Better detect and reject non-raw TIFFs
- fixed dcraw permission
-------------------------------------------------------------------
Thu Feb 8 12:29:52 CET 2007 - postadal@suse.cz
- updated to RCS 1.364
* Built a color matrix for Canon PowerShot S3 IS, Canon PowerShot A610
* Added Olympus SP510UZ, Panasonic DMC-L1, Leica Digilux 3,
Casio EX-Z4, Kodak DCS200, Canon PowerShots A620, S3 IS, Pentax K10D,
Canon PowerShot A610
* Suport Olympus E-400, Sinar 4-shot and Sinar IA file format
* Added "-K" option for dark-frame subtraction
* Get the Olympus black level from the ORF metadata.
* Found a more reliable way to identify 4775936-byte images
-------------------------------------------------------------------
Mon Oct 16 22:47:15 CEST 2006 - postadal@suse.cz
- updated to RCS 1.353
* added support for Pentax K100D, Nikon D200, D80, E3200,
Canon EOS 400D, Panasonic DMC-LX2, DMC-FZ50
* correctly display long exposure times for CRW files
* added color matrices from Adobe DNG Converter 3.5
* display the focal length of Canon CRW images
-------------------------------------------------------------------
Thu Aug 17 17:35:46 CEST 2006 - postadal@suse.cz
- updated to RCS 1.340
* improved support for the Olympus E-330
-------------------------------------------------------------------
Wed Aug 2 12:35:19 CEST 2006 - postadal@suse.cz
- updated to RCS 1.338
* added "-H 2" option for rudimentary highlight recovery
* new "-T" option provides TIFF output with metadata and ICC profile
* replaced "-r" and "-l" options with raw white balance
* added support for Imacon Ixpress 22-Mp, Leaf Aptus 75, Leica D-Lux 2,
Sony DSLR-A100, Minolta DiMAGE G530, Sinar 4080x4080, Samsung GX-1S
* fixed camera WB for Canon EOS 10D, 300D, and clones
* added camera WB for the Kodak DCS Pro SLR models, Imacon Ixpress,
Kodak P850/P880
-------------------------------------------------------------------
Sun Mar 26 15:56:10 CEST 2006 - postadal@suse.cz
- updated to RCS 1.319
* new color matrix for the Nikon E700, E800, and E950
* new "-D" option to output unscaled raw pixels (totally raw)
* fixed defective pixels and columns in Phase One images
-------------------------------------------------------------------
Thu Feb 9 22:12:25 CET 2006 - dmueller@suse.de
- update to RCS 1.315 (#112733)
-------------------------------------------------------------------
Wed Feb 8 02:36:13 CET 2006 - dmueller@suse.de
- update to RCS 1.314:
Updated color matrices based on Adobe DNG Converter 3.3.
Added Kodak ProPhoto D65 as an output option.
-------------------------------------------------------------------
Thu Jan 26 12:29:16 CET 2006 - sbrabec@suse.cz
- Updated to dcraw v8, RCS 1.313.
- Added simple update_dcraw script.
-------------------------------------------------------------------
Wed Jan 25 21:35:24 CET 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
-------------------------------------------------------------------
Wed Jan 11 15:56:34 CET 2006 - adrian@suse.de
- add stack protector compiler flag
-------------------------------------------------------------------
Thu Oct 13 13:48:05 CEST 2005 - postadal@suse.cz
- update to RCS 1.290
* added as default new interpolation algorithm AHD
(Adaptive homogeneity-directed demosaicing algorithm)
* new Bilateral filtering to remove color noises in CIELAB space
- update dcraw.1, fujiturn, dcparse (parse.c)
- removed crwfixdates (fixdates.c) superseded by "dcraw -z"
-------------------------------------------------------------------
Tue Jun 7 12:00:09 CEST 2005 - adrian@suse.de
- update to RCS 1.263
- compile with -fno-strict-aliasing to avoid compiler errors
-------------------------------------------------------------------
Fri Jun 3 12:46:05 CEST 2005 - postadal@suse.cz
- Updated to current version on maintainers website.
RCS version 1.262.
-------------------------------------------------------------------
Fri Feb 4 15:43:01 CET 2005 - meissner@suse.de
- Updated to current version on maintainers website.
RCS version 1.234.
-------------------------------------------------------------------
Thu Aug 26 14:05:18 CEST 2004 - sbrabec@suse.cz
- Updated to dcraw RCS version 1.200.
- Added more tools and documentation.
-------------------------------------------------------------------
Wed Jun 16 10:48:17 CEST 2004 - adrian@suse.de
- initial package of version 1.194

167
dcraw.spec Normal file
View File

@ -0,0 +1,167 @@
#
# spec file for package dcraw
#
# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: dcraw
Version: 9.28.0
Release: 0
Summary: Raw Digital Photo Decoding
License: GPL-2.0-or-later
URL: https://www.dechifro.org/dcraw/
#*** NOTE: run "sh update_dcraw" to update to latest version of the following sources ("wget", "rcs" and "lynx" packages are required for the update).
Source0: https://www.dechifro.org/dcraw/archive/dcraw-%{version}.tar.gz
Source1: README
# http://www.cybercom.net/~dcoffin/dcraw/.badpixels
Source2: badpixels
Source3: https://www.dechifro.org/dcraw/clean_crw.c
Source4: https://www.dechifro.org/dcraw/fuji_green.c
Source5: https://www.dechifro.org/dcraw/fujiturn.c
Source6: https://www.dechifro.org/dcraw/parse.c
Source7: https://www.dechifro.org/dcraw/rawphoto.c
#***
Source100: README.openSUSE
Source101: update_dcraw
# PATCH-FIX-OPENSUSE fuji_green.c_fix_gcc_warnings.patch asterios.dramis@gmail.com -- Fix gcc implicit declaration warning
Patch0: fuji_green.c_fix_gcc_warnings.patch
# PATCH-FIX-UPSTREAM dcraw-CVE-2017-13735.patch
Patch1: dcraw-CVE-2017-13735.patch
# PATCH-FIX-UPSTREAM dcraw-CVE-2017-14608.patch
Patch2: dcraw-CVE-2017-14608.patch
# PATCH-FIX-UPSTREAM dcraw-CVE-2018-19655.patch
Patch3: dcraw-CVE-2018-19655.patch
# PATCH-FIX-UPSTREAM dcraw-CVE-2018-5801.patch
Patch4: dcraw-CVE-2018-5801.patch
Patch5: iowrappers.patch
Patch6: dcraw-CVE-2021-3624.patch
Patch7: dcraw-glibc-2.38.patch
BuildRequires: gettext-runtime
BuildRequires: libjasper-devel
BuildRequires: libjpeg-devel
BuildRequires: liblcms2-devel
Recommends: %{name}-lang = %{version}
%description
Command line tools for raw digital photo decoding and processing.
%lang_package
%prep
%setup -q -n %{name}
cp -a %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} .
%patch0
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
export CFLAGS="%{optflags} -fno-strict-aliasing -fstack-protector-all"
for file in *.c ; do
LDFLAGS=
OTHERFLAGS=
if test $file = dcraw.c ; then
LDFLAGS="-lm -ljasper -ljpeg -llcms2 -DLOCALEDIR=\""%{_datadir}/locale"\""
fi
if test $file = fuji_green.c ; then
LDFLAGS="-lm"
fi
gcc $CFLAGS $OTHERFLAGS -o ${file%.c} $file $LDFLAGS
done
# Compile with -D_16BIT to rotate 48-bit PPM images
gcc $CFLAGS -D_16BIT -o fujiturn16 fujiturn.c
# Build language catalogs
for catsrc in dcraw_*.po ; do
lang="${catsrc%.po}"
lang="${lang#dcraw_}"
msgfmt -o "dcraw_${lang}.mo" "$catsrc"
done
%install
install -d -m 0755 %{buildroot}%{_bindir}
install -d -m 0755 %{buildroot}%{_mandir}/man1
install -pm 0755 dcraw %{buildroot}%{_bindir}/
install -pm 0644 dcraw.1 %{buildroot}%{_mandir}/man1/
install -pm 0755 clean_crw %{buildroot}%{_bindir}/
install -pm 0755 fuji_green %{buildroot}%{_bindir}/
install -pm 0755 fujiturn %{buildroot}%{_bindir}/
install -pm 0755 fujiturn16 %{buildroot}%{_bindir}/
install -pm 0755 parse %{buildroot}%{_bindir}/dcparse
# Install language catalogs
for catalog in dcraw_*.mo ; do
lang="${catalog%.mo}"
lang="${lang#dcraw_}"
install -d -m 0755 "%{buildroot}%{_datadir}/locale/${lang}/LC_MESSAGES"
install -pm 0644 "$catalog" "%{buildroot}%{_datadir}/locale/${lang}/LC_MESSAGES/dcraw.mo"
done
# Install localized manpages
for manpage in dcraw_*.1 ; do
lang="${manpage%.1}"
lang="${lang#dcraw_}"
install -d -m 0755 "%{buildroot}%{_mandir}/${lang}/man1"
install -pm 0644 "${manpage}" "%{buildroot}%{_mandir}/${lang}/man1/dcraw.1"
done
# Documentation
cp -a %{SOURCE1} %{SOURCE2} %{SOURCE7} %{SOURCE100} .
mv badpixels .badpixels
%find_lang %{name} --with-man
%files
%doc .badpixels README README.openSUSE rawphoto.c
%{_bindir}/clean_crw
%{_bindir}/dcparse
%{_bindir}/dcraw
%{_bindir}/fuji_green
%{_bindir}/fujiturn
%{_bindir}/fujiturn16
%{_mandir}/man1/dcraw.1%{?ext_man}
%files lang -f %{name}.lang
%dir %{_mandir}/ca
%dir %{_mandir}/ca/man1
%dir %{_mandir}/cs
%dir %{_mandir}/cs/man1
%dir %{_mandir}/da
%dir %{_mandir}/da/man1
%dir %{_mandir}/eo
%dir %{_mandir}/eo/man1
%dir %{_mandir}/hu
%dir %{_mandir}/hu/man1
%dir %{_mandir}/pl
%dir %{_mandir}/pl/man1
%dir %{_mandir}/pt
%dir %{_mandir}/pt/man1
%dir %{_mandir}/ro
%dir %{_mandir}/ro/man1
%dir %{_mandir}/sv
%dir %{_mandir}/sv/man1
%dir %{_mandir}/zh_CN
%dir %{_mandir}/zh_CN/man1
%dir %{_mandir}/zh_TW
%dir %{_mandir}/zh_TW/man1
%changelog

375
fuji_green.c Normal file
View File

@ -0,0 +1,375 @@
/*
fuji_green -- read Fuji green pixels
$Revision: 1.2 $
$Date: 2006/03/01 01:46:47 $
*/
#include <ctype.h>
#include <math.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ushort UshORt
typedef unsigned char uchar;
typedef unsigned short ushort;
FILE *ifp;
short order;
char *ifname, make[64], model[64];
int data_offset, raw_height, raw_width, height, width;
int fuji_layout, fuji_secondary, use_secondary=0, verbose=0;
ushort *image;
void (*load_raw)();
float bright=1.0;
void write_ppm(FILE *);
void (*write_fun)(FILE *) = write_ppm;
jmp_buf failure;
#define CLASS
void CLASS merror (void *ptr, char *where)
{
if (ptr) return;
fprintf (stderr, "%s: Out of memory in %s\n", ifname, where);
longjmp (failure, 1);
}
ushort CLASS get2()
{
uchar a, b;
a = fgetc(ifp);
b = fgetc(ifp);
if (order == 0x4949) /* "II" means little-endian */
return a + (b << 8);
else /* "MM" means big-endian */
return (a << 8) + b;
}
int CLASS get4()
{
uchar a, b, c, d;
a = fgetc(ifp);
b = fgetc(ifp);
c = fgetc(ifp);
d = fgetc(ifp);
if (order == 0x4949)
return a + (b << 8) + (c << 16) + (d << 24);
else
return (a << 24) + (b << 16) + (c << 8) + d;
}
/*
Faster than calling get2() multiple times.
*/
void CLASS read_shorts (ushort *pixel, int count)
{
fread (pixel, 2, count, ifp);
if ((order == 0x4949) == (ntohs(0x1234) == 0x1234))
swab (pixel, pixel, count*2);
}
void CLASS fuji_load_raw()
{
ushort *pixel, *img;
int row, col;
pixel = calloc (raw_width, 2);
merror (pixel, "fuji_load_raw()");
for (row=0; row < height; row++)
if (fuji_layout) {
read_shorts (image+row*width, width);
fseek (ifp, (raw_width*2 - width)*2, SEEK_CUR);
} else {
read_shorts (pixel, raw_width);
for (img=image+row*width, col=0; col < width; col++)
img[col] = pixel[col*2+1];
}
free (pixel);
}
void CLASS parse_fuji (int offset)
{
unsigned entries, tag, len, save;
fseek (ifp, offset, SEEK_SET);
entries = get4();
if (entries > 255) return;
while (entries--) {
tag = get2();
len = get2();
save = ftell(ifp);
if (tag == 0x100) {
raw_height = get2();
raw_width = get2();
} else if (tag == 0x121) {
height = get2();
width = get2();
} else if (tag == 0x130)
fuji_layout = fgetc(ifp) >> 7;
fseek (ifp, save+len, SEEK_SET);
}
if (fuji_layout) {
height *= 2;
width /= 2;
}
}
void CLASS parse_tiff (int base)
{
int doff, entries, tag, type, len, save;
fseek (ifp, base, SEEK_SET);
order = get2();
get2(); /* Should be 42 for standard TIFF */
while ((doff = get4())) {
fseek (ifp, doff+base, SEEK_SET);
entries = get2();
while (entries--) {
tag = get2();
type = get2();
len = get4();
save = ftell(ifp)+4;
fseek (ifp, base+get4(), SEEK_SET);
switch (tag) {
case 0x10f: /* Make tag */
fgets (make, 64, ifp);
break;
case 0x110: /* Model tag */
fgets (model, 64, ifp);
}
fseek (ifp, save, SEEK_SET);
}
}
}
int CLASS identify()
{
char head[32], *c;
int thumb_offset;
make[0] = model[0] = 0;
data_offset = raw_height = raw_width = height = width = 0;
fuji_secondary = 0;
order = 0x4d4d;
fread (head, 1, 32, ifp);
if (memcmp (head, "FUJIFILM", 8)) return 1;
fseek (ifp, 84, SEEK_SET);
thumb_offset = get4();
fseek (ifp, 92, SEEK_SET);
parse_fuji (get4());
if (thumb_offset > 120) {
fseek (ifp, 120, SEEK_SET);
fuji_secondary = get4() && 1;
}
fseek (ifp, 100, SEEK_SET);
data_offset = get4();
parse_tiff (thumb_offset+12);
c = model + strlen(model); /* Remove trailing spaces */
while (*--c == ' ') *c = 0;
if (!strcmp(model,"FinePix S5100") ||
!strcmp(model,"FinePix S5500")) return 1;
load_raw = fuji_load_raw;
if (!strcmp(model+7,"S2Pro")) {
strcpy (model+7," S2Pro");
height = 2144;
width = 2880;
}
data_offset += (raw_height - height + 1)*raw_width - width;
if (fuji_secondary)
data_offset += use_secondary * ( strcmp(model+7," S3Pro")
? (raw_width *= 2) : raw_height*raw_width*2 );
data_offset += fuji_layout*raw_width*2;
width >>= !fuji_layout;
height >>= fuji_layout;
fseek (ifp, data_offset, SEEK_SET);
return 0;
}
void CLASS write_ppm (FILE *ofp)
{
int i, size, val, total, histogram[0x2000];
float white, r;
uchar lut[0x10000];
memset (histogram, 0, sizeof histogram);
size = width * height;
for (i = 0; i < size; i++)
histogram[image[i] >> 4]++;
i = size * 0.01; /* 99th percentile white point */
for (val=0x2000, total=0; --val; )
if ((total += histogram[val]) > i) break;
white = (val << 4) / bright;
for (i=0; i < 0x10000; i++) {
r = i / white;
val = (r <= 0.018 ? r*4.5 : pow(r,0.45)*1.099-0.099) * 256;
if (val > 255) val = 255;
lut[i] = val;
}
fprintf (ofp, "P5\n%d %d\n255\n", width, height);
for (i=0; i < size; i++)
fputc (lut[image[i]], ofp);
}
void CLASS write_raw16 (FILE *ofp)
{
if (ntohs(0x1234) != 0x1234)
swab (image, image, width*height*2);
fwrite (image, width*height, 2, ofp);
}
void CLASS write_ppm16 (FILE *ofp)
{
fprintf (ofp, "P5\n%d %d\n%d\n", width, height, 65535);
write_raw16 (ofp);
}
void CLASS write_psd (FILE *ofp)
{
char head[] = {
'8','B','P','S', /* signature */
0,1,0,0,0,0,0,0, /* version and reserved */
0,1, /* number of channels */
0,0,0,0, /* height, big-endian */
0,0,0,0, /* width, big-endian */
0,16, /* 16-bit color */
0,1, /* mode (1=grey, 3=rgb) */
0,0,0,0, /* color mode data */
0,0,0,0, /* image resources */
0,0,0,0, /* layer/mask info */
0,0 }; /* no compression */
int hw[2];
hw[0] = htonl(height*2); /* write the header */
hw[1] = htonl(width*2);
memcpy (head+14, hw, sizeof hw);
fwrite (head, 40, 1, ofp);
write_raw16 (ofp);
}
int CLASS main (int argc, char **argv)
{
int arg, status=0;
int identify_only=0, write_to_stdout=0;
char opt, *ofname, *cp;
const char *write_ext = ".pgm";
FILE *ofp = stdout;
if (argc == 1) {
fprintf (stderr,
"\nFuji Green channel output"
"\nby Dave Coffin, dcoffin a cybercom o net"
"\n\nUsage: %s [options] file1 file2 ...\n"
"\nValid options:"
"\n-v Print verbose messages"
"\n-c Write image data to standard output"
"\n-i Identify files without decoding them"
"\n-s Use secondary pixels if available"
"\n-b <num> Set brightness (default = 1.0)"
"\n-2 Write 8-bit non-linear PGM (default)"
"\n-4 Write 16-bit linear PGM"
"\n-3 Write 16-bit linear PSD (Adobe Photoshop)"
"\n\n", argv[0]);
return 1;
}
argv[argc] = "";
for (arg=1; argv[arg][0] == '-'; ) {
opt = argv[arg++][1];
if (strchr ("b", opt) && !isdigit(argv[arg][0])) {
fprintf (stderr, "\"-%c\" requires a numeric argument.\n", opt);
return 1;
}
switch (opt) {
case 'v': verbose = 1; break;
case 'i': identify_only = 1; break;
case 'c': write_to_stdout = 1; break;
case 's': use_secondary = 1; break;
case 'b': bright = atof(argv[arg++]); break;
case '2': write_fun = write_ppm; break;
case '4': write_fun = write_ppm16; break;
case '3': write_fun = write_psd; write_ext = ".psd"; break;
default:
fprintf (stderr, "Unknown option \"-%c\".\n", opt);
return 1;
}
}
if (arg == argc) {
fprintf (stderr, "No files to process.\n");
return 1;
}
if (write_to_stdout) {
if (isatty(1)) {
fprintf (stderr, "Will not write an image to the terminal!\n");
return 1;
}
#if defined(WIN32) || defined(DJGPP)
if (setmode(1,O_BINARY) < 0) {
perror("setmode()");
return 1;
}
#endif
}
for ( ; arg < argc; arg++) {
status = 1;
image = NULL;
if (setjmp (failure)) {
if (fileno(ifp) > 2) fclose (ifp);
if (fileno(ofp) > 2) fclose (ofp);
if (image) free (image);
status = 1;
continue;
}
ifname = argv[arg];
if (!(ifp = fopen (ifname, "rb"))) {
perror (ifname);
continue;
}
if ((status = identify())) {
fprintf (stderr, "%s: unsupported file format.\n", ifname);
fclose (ifp);
continue;
}
if (identify_only) {
fprintf (stderr, "%s is a %s %s image.\n", ifname, make, model);
fclose (ifp);
continue;
}
image = calloc (height * width, sizeof *image);
merror (image, "main()");
if (verbose)
fprintf (stderr,
"Loading %s %s image from %s...\n", make, model, ifname);
(*load_raw)();
fclose (ifp);
ofname = malloc (strlen(ifname) + 16);
merror (ofname, "main()");
if (write_to_stdout)
strcpy (ofname, "standard output");
else {
strcpy (ofname, ifname);
if ((cp = strrchr (ofname, '.'))) *cp = 0;
strcat (ofname, write_ext);
ofp = fopen (ofname, "wb");
if (!ofp) {
status = 1;
perror (ofname);
goto cleanup;
}
}
if (verbose)
fprintf (stderr, "Writing data to %s...\n", ofname);
(*write_fun)(ofp);
if (ofp != stdout)
fclose (ofp);
cleanup:
free (ofname);
free (image);
}
return status;
}

View File

@ -0,0 +1,11 @@
--- fuji_green.c.orig 2006-03-01 03:46:47.000000000 +0200
+++ fuji_green.c 2011-03-22 21:26:43.871000023 +0200
@@ -11,6 +11,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <netinet/in.h>
#define ushort UshORt
typedef unsigned char uchar;

102
fujiturn.c Normal file
View File

@ -0,0 +1,102 @@
/*
fujiturn.c by Dave Coffin
UNIX filter to correct the 45-degree rotation in images from
Fuji digital cameras. Compile with -D_16BIT to rotate 48-bit
PPM images. Sample usage:
dcraw -c -j dscf0000.raf | fujiturn | pnmscale 0.70710678 > dscf0000.ppm
$Revision: 1.6 $
$Date: 2005/04/29 16:35:42 $
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#ifdef _16BIT
typedef unsigned short value;
#else
typedef unsigned char value;
#define ntohs(x) (x)
#define htons(x) (x)
#endif
void merror (void *ptr, char *what)
{
if (ptr) return;
fprintf (stderr, "Not enough memory for %s\n", what);
exit(1);
}
int main()
{
FILE *ifp, *ofp;
value (*in)[3], (*mid)[3], (*pix)[3], (*out)[3];
char nl;
int maxval, i, j, iwide, ihigh, owide, ohigh;
unsigned irow, icol, orow, ocol;
#if defined(WIN32) || defined(DJGPP)
if (setmode(0,O_BINARY) < 0) perror("setmode(0)");
if (setmode(1,O_BINARY) < 0) perror("setmode(1)");
#endif
ifp = stdin;
ofp = stdout;
if (fscanf (ifp, "P6 %d %d %d%c", &iwide, &ihigh, &maxval, &nl) != 4
|| abs(iwide - ihigh) > 1) {
fprintf (stderr, "Input is not a Fuji image processed by dcraw.\n");
exit(1);
}
i = (maxval > 255) ? 16 : 8;
j = 8 * sizeof (value);
if (i != j) {
fprintf (stderr, "Input is %d-bit, fujiturn is %d-bit\n", i, j);
exit(1);
}
in = calloc (iwide, sizeof *in);
merror (in, "input array");
fread (in, iwide, sizeof *in, ifp);
for (i = 0; i < iwide; i++)
if (in[i][0] || in[i][1] || in[i][2]) break;
ohigh = (iwide - i) * 2 - 4;
for (i = iwide; --i;)
if (in[i][0] || in[i][1] || in[i][2]) break;
owide = i;
mid = calloc (ohigh * owide, sizeof *mid);
merror (mid, "middle array");
for (irow = 0; irow < ihigh; irow++) {
for (icol = 0; icol < iwide; icol++) {
orow = irow + icol - owide + 5;
ocol = (icol - irow + owide - 1)/2;
if (orow < ohigh && ocol < owide)
for (i = 0; i < 3; i++)
mid[orow*owide+ocol][i] = ntohs(in[icol][i]);
}
fread (in, iwide, sizeof *in, ifp);
}
free(in);
out = calloc (2*owide, sizeof *out);
merror (out, "output array");
fprintf (ofp, "P6\n%d %d\n%d\n", owide*2, ohigh, maxval);
for (orow = 0; orow < ohigh; orow++) {
for (ocol = 0; ocol < owide*2; ocol++) {
pix = mid + orow*owide + ocol/2;
if ((orow+ocol) & 1) {
if (orow-1 < ohigh-2 && ocol-1 < owide*2-2)
for (i = 0; i < 3; i++)
out[ocol][i] = htons (
( pix[-owide][i] + pix[0-(orow&1)][i] +
pix[ owide][i] + pix[1-(orow&1)][i] ) >> 2);
} else
for