updated libtiff to 3.9.5 (ticket #1271)

This commit is contained in:
Vadim Pisarevsky 2011-08-03 07:51:40 +00:00
parent c8378fa4c4
commit 217f345e66
15 changed files with 227 additions and 140 deletions

View File

@ -1,4 +1,4 @@
/* $Id: tif_color.c,v 1.12.2.1 2010-06-08 18:50:41 bfriesen Exp $ */ /* $Id: tif_color.c,v 1.12.2.2 2010-12-14 02:23:09 faxguy Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -183,13 +183,18 @@ void
TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr, TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr,
uint32 *r, uint32 *g, uint32 *b) uint32 *r, uint32 *g, uint32 *b)
{ {
int32 i;
/* XXX: Only 8-bit YCbCr input supported for now */ /* XXX: Only 8-bit YCbCr input supported for now */
Y = HICLAMP(Y, 255), Cb = CLAMP(Cb, 0, 255), Cr = CLAMP(Cr, 0, 255); Y = HICLAMP(Y, 255), Cb = CLAMP(Cb, 0, 255), Cr = CLAMP(Cr, 0, 255);
*r = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]]; i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr];
*g = ycbcr->clamptab[ycbcr->Y_tab[Y] *r = CLAMP(i, 0, 255);
+ (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT)]; i = ycbcr->Y_tab[Y]
*b = ycbcr->clamptab[ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]]; + (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT);
*g = CLAMP(i, 0, 255);
i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb];
*b = CLAMP(i, 0, 255);
} }
/* /*

View File

@ -1,4 +1,4 @@
/* $Id: tif_dir.c,v 1.75.2.5 2010-06-09 21:15:27 bfriesen Exp $ */ /* $Id: tif_dir.c,v 1.75.2.6 2010-07-02 09:49:23 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -163,7 +163,9 @@ _TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap)
* work in with its normal work. * work in with its normal work.
*/ */
if (tif->tif_flags & TIFF_SWAB) { if (tif->tif_flags & TIFF_SWAB) {
if (td->td_bitspersample == 16) if (td->td_bitspersample == 8)
tif->tif_postdecode = _TIFFNoPostDecode;
else if (td->td_bitspersample == 16)
tif->tif_postdecode = _TIFFSwab16BitData; tif->tif_postdecode = _TIFFSwab16BitData;
else if (td->td_bitspersample == 24) else if (td->td_bitspersample == 24)
tif->tif_postdecode = _TIFFSwab24BitData; tif->tif_postdecode = _TIFFSwab24BitData;

View File

@ -1,4 +1,4 @@
/* $Id: tif_dirread.c,v 1.92.2.9 2010-06-14 00:21:46 fwarmerdam Exp $ */ /* $Id: tif_dirread.c,v 1.92.2.15 2010-12-31 16:12:40 olivier Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -54,7 +54,7 @@ static float TIFFFetchRational(TIFF*, TIFFDirEntry*);
static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*); static int TIFFFetchNormalTag(TIFF*, TIFFDirEntry*);
static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, uint16*); static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, uint16*);
static int TIFFFetchPerSampleLongs(TIFF*, TIFFDirEntry*, uint32*); static int TIFFFetchPerSampleLongs(TIFF*, TIFFDirEntry*, uint32*);
static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*); static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*, double*);
static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*); static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*);
static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**); static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**);
static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*); static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*);
@ -83,6 +83,7 @@ TIFFReadDirectory(TIFF* tif)
const TIFFFieldInfo* fip; const TIFFFieldInfo* fip;
size_t fix; size_t fix;
uint16 dircount; uint16 dircount;
uint16 previous_tag = 0;
int diroutoforderwarning = 0, compressionknown = 0; int diroutoforderwarning = 0, compressionknown = 0;
int haveunknowntags = 0; int haveunknowntags = 0;
@ -105,7 +106,20 @@ TIFFReadDirectory(TIFF* tif)
tif->tif_name, tif->tif_nextdiroff); tif->tif_name, tif->tif_nextdiroff);
return 0; return 0;
} }
{
TIFFDirEntry* ma;
uint16 mb;
for (ma=dir, mb=0; mb<dircount; ma++, mb++)
{
TIFFDirEntry* na;
uint16 nb;
for (na=ma+1, nb=mb+1; nb<dircount; na++, nb++)
{
if (ma->tdir_tag==na->tdir_tag)
na->tdir_tag=IGNORE;
}
}
}
tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */
/* /*
* Setup default value and then make a pass over * Setup default value and then make a pass over
@ -163,23 +177,24 @@ TIFFReadDirectory(TIFF* tif)
if (dp->tdir_tag == IGNORE) if (dp->tdir_tag == IGNORE)
continue; continue;
if (fix >= tif->tif_nfields)
fix = 0;
/* /*
* Silicon Beach (at least) writes unordered * Silicon Beach (at least) writes unordered
* directory tags (violating the spec). Handle * directory tags (violating the spec). Handle
* it here, but be obnoxious (maybe they'll fix it?). * it here, but be obnoxious (maybe they'll fix it?).
*/ */
if (dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag) { if (dp->tdir_tag < previous_tag) {
if (!diroutoforderwarning) { if (!diroutoforderwarning) {
TIFFWarningExt(tif->tif_clientdata, module, TIFFWarningExt(tif->tif_clientdata, module,
"%s: invalid TIFF directory; tags are not sorted in ascending order", "%s: invalid TIFF directory; tags are not sorted in ascending order",
tif->tif_name); tif->tif_name);
diroutoforderwarning = 1; diroutoforderwarning = 1;
} }
fix = 0; /* O(n^2) */
} }
previous_tag = dp->tdir_tag;
if (fix >= tif->tif_nfields ||
dp->tdir_tag < tif->tif_fieldinfo[fix]->field_tag)
fix = 0; /* O(n^2) */
while (fix < tif->tif_nfields && while (fix < tif->tif_nfields &&
tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag) tif->tif_fieldinfo[fix]->field_tag < dp->tdir_tag)
fix++; fix++;
@ -465,11 +480,18 @@ TIFFReadDirectory(TIFF* tif)
} }
break; break;
case TIFFTAG_SMINSAMPLEVALUE: case TIFFTAG_SMINSAMPLEVALUE:
{
double minv = 0.0, maxv = 0.0;
if (!TIFFFetchPerSampleAnys(tif, dp, &minv, &maxv) ||
!TIFFSetField(tif, dp->tdir_tag, minv))
goto bad;
}
break;
case TIFFTAG_SMAXSAMPLEVALUE: case TIFFTAG_SMAXSAMPLEVALUE:
{ {
double dv = 0.0; double minv = 0.0, maxv = 0.0;
if (!TIFFFetchPerSampleAnys(tif, dp, &dv) || if (!TIFFFetchPerSampleAnys(tif, dp, &minv, &maxv) ||
!TIFFSetField(tif, dp->tdir_tag, dv)) !TIFFSetField(tif, dp->tdir_tag, maxv))
goto bad; goto bad;
} }
break; break;
@ -593,8 +615,7 @@ TIFFReadDirectory(TIFF* tif)
} }
if (!TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) if (!TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL))
{ {
if ((td->td_photometric==PHOTOMETRIC_RGB) if (td->td_photometric==PHOTOMETRIC_RGB)
|| (td->td_photometric==PHOTOMETRIC_YCBCR))
{ {
TIFFWarningExt(tif->tif_clientdata, TIFFWarningExt(tif->tif_clientdata,
"TIFFReadDirectory", "TIFFReadDirectory",
@ -603,13 +624,22 @@ TIFFReadDirectory(TIFF* tif)
if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3))
goto bad; goto bad;
} }
else if ((td->td_photometric==PHOTOMETRIC_MINISWHITE) if (td->td_photometric==PHOTOMETRIC_YCBCR)
|| (td->td_photometric==PHOTOMETRIC_MINISBLACK))
{ {
TIFFWarningExt(tif->tif_clientdata, TIFFWarningExt(tif->tif_clientdata,
"TIFFReadDirectory", "TIFFReadDirectory",
"SamplesPerPixel tag is missing, " "SamplesPerPixel tag is missing, "
"assuming correct SamplesPerPixel value is 1"); "applying correct SamplesPerPixel value of 3");
if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3))
goto bad;
}
else if ((td->td_photometric==PHOTOMETRIC_MINISWHITE)
|| (td->td_photometric==PHOTOMETRIC_MINISBLACK))
{
/*
* SamplesPerPixel tag is missing, but is not required
* by spec. Assume correct SamplesPerPixel value of 1.
*/
if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,1)) if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,1))
goto bad; goto bad;
} }
@ -620,9 +650,15 @@ TIFFReadDirectory(TIFF* tif)
*/ */
if (td->td_photometric == PHOTOMETRIC_PALETTE && if (td->td_photometric == PHOTOMETRIC_PALETTE &&
!TIFFFieldSet(tif, FIELD_COLORMAP)) { !TIFFFieldSet(tif, FIELD_COLORMAP)) {
if ( tif->tif_dir.td_bitspersample>=8 && tif->tif_dir.td_samplesperpixel==3)
tif->tif_dir.td_photometric = PHOTOMETRIC_RGB;
else if (tif->tif_dir.td_bitspersample>=8)
tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK;
else {
MissingRequired(tif, "Colormap"); MissingRequired(tif, "Colormap");
goto bad; goto bad;
} }
}
/* /*
* OJPEG hack: * OJPEG hack:
* We do no further messing with strip/tile offsets/bytecounts in OJPEG * We do no further messing with strip/tile offsets/bytecounts in OJPEG
@ -1086,6 +1122,7 @@ CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count)
"incorrect count for field \"%s\" (%u, expecting %u); tag trimmed", "incorrect count for field \"%s\" (%u, expecting %u); tag trimmed",
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name,
dir->tdir_count, count); dir->tdir_count, count);
dir->tdir_count = count;
return (1); return (1);
} }
return (1); return (1);
@ -1420,7 +1457,7 @@ TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir)
case TIFF_SHORT: case TIFF_SHORT:
case TIFF_SSHORT: case TIFF_SSHORT:
{ {
uint16 v[2]={0,0}; uint16 v[2];
return TIFFFetchShortArray(tif, dir, v) return TIFFFetchShortArray(tif, dir, v)
&& TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); && TIFFSetField(tif, dir->tdir_tag, v[0], v[1]);
} }
@ -1822,11 +1859,11 @@ TIFFFetchPerSampleLongs(TIFF* tif, TIFFDirEntry* dir, uint32* pl)
} }
/* /*
* Fetch samples/pixel ANY values for the specified tag and verify that all * Fetch samples/pixel ANY values for the specified tag and returns their min
* values are the same. * and max.
*/ */
static int static int
TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl) TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* minv, double* maxv)
{ {
uint16 samples = tif->tif_dir.td_samplesperpixel; uint16 samples = tif->tif_dir.td_samplesperpixel;
int status = 0; int status = 0;
@ -1844,17 +1881,16 @@ TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl)
if( samples < check_count ) if( samples < check_count )
check_count = samples; check_count = samples;
*minv = *maxv = v[0];
for (i = 1; i < check_count; i++) for (i = 1; i < check_count; i++)
if (v[i] != v[0]) { {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, if (v[i] < *minv)
"Cannot handle different per-sample values for field \"%s\"", *minv = v[i];
_TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); if (v[i] > *maxv)
goto bad; *maxv = v[i];
} }
*pl = v[0];
status = 1; status = 1;
} }
bad:
if (v && v != buf) if (v && v != buf)
_TIFFfree(v); _TIFFfree(v);
} }

View File

@ -1,4 +1,4 @@
/* $Id: tif_dirwrite.c,v 1.37.2.7 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_dirwrite.c,v 1.37.2.9 2011-02-25 15:28:30 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -42,6 +42,7 @@ extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*);
static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*); static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*);
static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32); static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32);
static void TIFFSetupShort(TIFF*, ttag_t, TIFFDirEntry*, uint16); static void TIFFSetupShort(TIFF*, ttag_t, TIFFDirEntry*, uint16);
static int TIFFSetupBytePair(TIFF*, ttag_t, TIFFDirEntry*);
static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*); static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*);
static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*); static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*);
static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*); static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*);
@ -291,12 +292,6 @@ _TIFFWriteDirectory(TIFF* tif, int done)
_TIFFSampleToTagType(tif), fip->field_tag, dir)) _TIFFSampleToTagType(tif), fip->field_tag, dir))
goto bad; goto bad;
break; break;
case FIELD_PAGENUMBER:
case FIELD_HALFTONEHINTS:
case FIELD_YCBCRSUBSAMPLING:
if (!TIFFSetupShortPair(tif, fip->field_tag, dir))
goto bad;
break;
case FIELD_INKNAMES: case FIELD_INKNAMES:
if (!TIFFWriteInkNames(tif, dir)) if (!TIFFWriteInkNames(tif, dir))
goto bad; goto bad;
@ -336,12 +331,22 @@ _TIFFWriteDirectory(TIFF* tif, int done)
} }
break; break;
default: default:
/* XXX: Should be fixed and removed. */ /*
if (fip->field_tag == TIFFTAG_DOTRANGE) { * XXX: Should be fixed and removed. See comments
* related to these tags in tif_dir.c.
*/
if (fip->field_tag == TIFFTAG_PAGENUMBER
|| fip->field_tag == TIFFTAG_HALFTONEHINTS
|| fip->field_tag == TIFFTAG_YCBCRSUBSAMPLING
|| fip->field_tag == TIFFTAG_DOTRANGE) {
if (fip->field_type == TIFF_BYTE) {
if (!TIFFSetupBytePair(tif, fip->field_tag, dir))
goto bad;
} else if (fip->field_type == TIFF_SHORT) {
if (!TIFFSetupShortPair(tif, fip->field_tag, dir)) if (!TIFFSetupShortPair(tif, fip->field_tag, dir))
goto bad; goto bad;
} }
else if (!TIFFWriteNormalTag(tif, dir, fip)) } else if (!TIFFWriteNormalTag(tif, dir, fip))
goto bad; goto bad;
break; break;
} }
@ -875,6 +880,23 @@ TIFFWritePerSampleAnys(TIFF* tif,
} }
#undef NITEMS #undef NITEMS
/*
* Setup a pair of bytes that are returned by
* value, rather than as a reference to an array.
*/
static int
TIFFSetupBytePair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir)
{
char v[2];
TIFFGetField(tif, tag, &v[0], &v[1]);
dir->tdir_tag = (uint16) tag;
dir->tdir_type = (uint16) TIFF_BYTE;
dir->tdir_count = 2;
return (TIFFWriteByteArray(tif, dir, v));
}
/* /*
* Setup a pair of shorts that are returned by * Setup a pair of shorts that are returned by
* value, rather than as a reference to an array. * value, rather than as a reference to an array.
@ -1019,7 +1041,7 @@ TIFFWriteRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v)
while (fv < 1L<<(31-3) && den < 1L<<(31-3)) while (fv < 1L<<(31-3) && den < 1L<<(31-3))
fv *= 1<<3, den *= 1L<<3; fv *= 1<<3, den *= 1L<<3;
} }
t[2*i+0] = (uint32) (sign * (fv + 0.5)); t[2*i+0] = (uint32) (sign * (int32)(fv + 0.5));
t[2*i+1] = den; t[2*i+1] = den;
} }
status = TIFFWriteData(tif, dir, (char *)t); status = TIFFWriteData(tif, dir, (char *)t);

View File

@ -1,4 +1,4 @@
/* $Id: tif_fax3.h,v 1.5.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_fax3.h,v 1.5.2.3 2011-03-10 20:22:33 fwarmerdam Exp $ */
/* /*
* Copyright (c) 1990-1997 Sam Leffler * Copyright (c) 1990-1997 Sam Leffler
@ -478,6 +478,12 @@ done1d: \
break; \ break; \
case S_VL: \ case S_VL: \
CHECK_b1; \ CHECK_b1; \
if (b1 <= (int) (a0 + TabEnt->Param)) { \
if (b1 < (int) (a0 + TabEnt->Param) || pa != thisrun) { \
unexpected("VL", a0); \
goto eol2d; \
} \
} \
SETVALUE(b1 - a0 - TabEnt->Param); \ SETVALUE(b1 - a0 - TabEnt->Param); \
b1 -= *--pb; \ b1 -= *--pb; \
break; \ break; \

View File

@ -1,4 +1,4 @@
/* $Id: tif_getimage.c,v 1.63.2.4 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_getimage.c,v 1.63.2.6 2010-07-02 13:38:27 dron Exp $ */
/* /*
* Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Sam Leffler
@ -1846,6 +1846,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile)
DECLAREContigPutFunc(putcontig8bitYCbCr22tile) DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
{ {
uint32* cp2; uint32* cp2;
int32 incr = 2*toskew+w;
(void) y; (void) y;
fromskew = (fromskew / 2) * 6; fromskew = (fromskew / 2) * 6;
cp2 = cp+w+toskew; cp2 = cp+w+toskew;
@ -1872,8 +1873,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile)
cp2 ++ ; cp2 ++ ;
pp += 6; pp += 6;
} }
cp += toskew*2+w; cp += incr;
cp2 += toskew*2+w; cp2 += incr;
pp += fromskew; pp += fromskew;
h-=2; h-=2;
} }
@ -1939,6 +1940,7 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile)
DECLAREContigPutFunc(putcontig8bitYCbCr12tile) DECLAREContigPutFunc(putcontig8bitYCbCr12tile)
{ {
uint32* cp2; uint32* cp2;
int32 incr = 2*toskew+w;
(void) y; (void) y;
fromskew = (fromskew / 2) * 4; fromskew = (fromskew / 2) * 4;
cp2 = cp+w+toskew; cp2 = cp+w+toskew;
@ -1953,8 +1955,8 @@ DECLAREContigPutFunc(putcontig8bitYCbCr12tile)
cp2 ++; cp2 ++;
pp += 4; pp += 4;
} while (--x); } while (--x);
cp += toskew*2+w; cp += incr;
cp2 += toskew*2+w; cp2 += incr;
pp += fromskew; pp += fromskew;
h-=2; h-=2;
} }
@ -2397,7 +2399,7 @@ PickContigCase(TIFFRGBAImage* img)
} }
break; break;
case PHOTOMETRIC_YCBCR: case PHOTOMETRIC_YCBCR:
if (img->bitspersample == 8) if ((img->bitspersample==8) && (img->samplesperpixel==3))
{ {
if (initYCbCrConversion(img)!=0) if (initYCbCrConversion(img)!=0)
{ {

View File

@ -1,4 +1,4 @@
/* $Id: tif_jpeg.c,v 1.50.2.9 2010-06-14 02:47:16 fwarmerdam Exp $ */ /* $Id: tif_jpeg.c,v 1.50.2.17 2011-01-04 02:51:17 faxguy Exp $ */
/* /*
* Copyright (c) 1994-1997 Sam Leffler * Copyright (c) 1994-1997 Sam Leffler
@ -988,8 +988,15 @@ JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
tsize_t nrows; tsize_t nrows;
(void) s; (void) s;
nrows = cc / sp->bytesperline;
if (cc % sp->bytesperline)
TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline not read");
if( nrows > (int) sp->cinfo.d.image_height )
nrows = sp->cinfo.d.image_height;
/* data is expected to be read in multiples of a scanline */ /* data is expected to be read in multiples of a scanline */
if ( (nrows = sp->cinfo.d.image_height) ) { if (nrows) {
/* Cb,Cr both have sampling factors 1, so this is correct */ /* Cb,Cr both have sampling factors 1, so this is correct */
JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width;
int samples_per_clump = sp->samplesperclump; int samples_per_clump = sp->samplesperclump;
@ -1064,7 +1071,7 @@ JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
} }
} }
else else
{ // 12-bit { /* 12-bit */
int value_pairs = (sp->cinfo.d.output_width int value_pairs = (sp->cinfo.d.output_width
* sp->cinfo.d.num_components) / 2; * sp->cinfo.d.num_components) / 2;
int iPair; int iPair;
@ -1087,8 +1094,7 @@ JPEGDecodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
* TODO: resolve this */ * TODO: resolve this */
buf += sp->bytesperline; buf += sp->bytesperline;
cc -= sp->bytesperline; cc -= sp->bytesperline;
nrows -= sp->v_sampling; } while (--nrows > 0);
} while (nrows > 0);
#ifdef JPEG_LIB_MK1 #ifdef JPEG_LIB_MK1
_TIFFfree(tmpbuf); _TIFFfree(tmpbuf);
@ -1352,8 +1358,15 @@ JPEGPreEncode(TIFF* tif, tsample_t s)
sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling;
sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling;
} else { } else {
if ((td->td_photometric == PHOTOMETRIC_MINISWHITE || td->td_photometric == PHOTOMETRIC_MINISBLACK) && td->td_samplesperpixel == 1)
sp->cinfo.c.in_color_space = JCS_GRAYSCALE;
else if (td->td_photometric == PHOTOMETRIC_RGB)
sp->cinfo.c.in_color_space = JCS_RGB;
else if (td->td_photometric == PHOTOMETRIC_SEPARATED && td->td_samplesperpixel == 4)
sp->cinfo.c.in_color_space = JCS_CMYK;
else
sp->cinfo.c.in_color_space = JCS_UNKNOWN; sp->cinfo.c.in_color_space = JCS_UNKNOWN;
if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space))
return (0); return (0);
/* jpeg_set_colorspace set all sampling factors to 1 */ /* jpeg_set_colorspace set all sampling factors to 1 */
} }
@ -1523,7 +1536,7 @@ JPEGEncodeRaw(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
sp->scancount = 0; sp->scancount = 0;
} }
tif->tif_row += sp->v_sampling; tif->tif_row += sp->v_sampling;
buf += sp->bytesperline; buf += bytesperclumpline;
nrows -= sp->v_sampling; nrows -= sp->v_sampling;
} }
return (1); return (1);

View File

@ -1,4 +1,4 @@
/* $Id: tif_ojpeg.c,v 1.24.2.6 2010-06-08 23:29:51 bfriesen Exp $ */ /* $Id: tif_ojpeg.c,v 1.24.2.8 2010-12-11 21:25:04 faxguy Exp $ */
/* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0 /* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0
specification is now totally obsolete and deprecated for new applications and specification is now totally obsolete and deprecated for new applications and
@ -1537,7 +1537,6 @@ OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id)
OJPEGReadSkip(sp,4); OJPEGReadSkip(sp,4);
else else
{ {
/* TODO: probably best to also add check on allowed upper bound, especially x, may cause buffer overflow otherwise i think */
/* Y: Number of lines */ /* Y: Number of lines */
if (OJPEGReadWord(sp,&p)==0) if (OJPEGReadWord(sp,&p)==0)
return(0); return(0);
@ -1555,6 +1554,11 @@ OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 marker_id)
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected width"); TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected width");
return(0); return(0);
} }
if ((uint32)p>sp->strile_width)
{
TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data image width exceeds expected image width");
return(0);
}
sp->sof_x=p; sp->sof_x=p;
} }
/* Nf: Number of image components in frame */ /* Nf: Number of image components in frame */
@ -1918,8 +1922,14 @@ OJPEGReadBufferFill(OJPEGState* sp)
{ {
if (sp->in_buffer_file_pos>=sp->file_size) if (sp->in_buffer_file_pos>=sp->file_size)
sp->in_buffer_file_pos=0; sp->in_buffer_file_pos=0;
else if (sp->tif->tif_dir.td_stripbytecount==NULL)
sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos;
else else
{ {
if (sp->tif->tif_dir.td_stripbytecount == 0) {
TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing");
return(0);
}
sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile]; sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile];
if (sp->in_buffer_file_togo==0) if (sp->in_buffer_file_togo==0)
sp->in_buffer_file_pos=0; sp->in_buffer_file_pos=0;

View File

@ -1,4 +1,4 @@
/* $Id: tif_open.c,v 1.33.2.1 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_open.c,v 1.33.2.2 2010-12-06 16:54:22 faxguy Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -304,7 +304,7 @@ TIFFClientOpen(
/* /*
* Read in TIFF header. * Read in TIFF header.
*/ */
if (tif->tif_mode & O_TRUNC || if ((m & O_TRUNC) ||
!ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) { !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeader))) {
if (tif->tif_mode == O_RDONLY) { if (tif->tif_mode == O_RDONLY) {
TIFFErrorExt(tif->tif_clientdata, name, TIFFErrorExt(tif->tif_clientdata, name,

View File

@ -1,4 +1,4 @@
/* $Id: tif_print.c,v 1.36.2.4 2010-06-08 18:50:42 bfriesen Exp $ */ /* $Id: tif_print.c,v 1.36.2.5 2010-07-06 14:05:30 dron Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -115,8 +115,6 @@ static int
_TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag, _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag,
uint32 value_count, void *raw_data) uint32 value_count, void *raw_data)
{ {
//TIFFDirectory *td = &tif->tif_dir;
switch (tag) switch (tag)
{ {
case TIFFTAG_INKSET: case TIFFTAG_INKSET:
@ -132,10 +130,6 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, ttag_t tag,
break; break;
} }
return 1; return 1;
case TIFFTAG_DOTRANGE:
fprintf(fd, " Dot Range: %u-%u\n",
((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
return 1;
case TIFFTAG_WHITEPOINT: case TIFFTAG_WHITEPOINT:
fprintf(fd, " White Point: %g-%g\n", fprintf(fd, " White Point: %g-%g\n",
((float *)raw_data)[0], ((float *)raw_data)[1]); return 1; ((float *)raw_data)[0], ((float *)raw_data)[1]); return 1;

View File

@ -1,4 +1,4 @@
/* $Id: tif_strip.c,v 1.19.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* $Id: tif_strip.c,v 1.19.2.3 2010-12-15 00:50:30 faxguy Exp $ */
/* /*
* Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Sam Leffler
@ -124,9 +124,9 @@ TIFFVStripSize(TIFF* tif, uint32 nrows)
uint16 ycbcrsubsampling[2]; uint16 ycbcrsubsampling[2];
tsize_t w, scanline, samplingarea; tsize_t w, scanline, samplingarea;
TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING, TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
ycbcrsubsampling + 0, ycbcrsubsampling + 0,
ycbcrsubsampling + 1 ); ycbcrsubsampling + 1);
samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1]; samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1];
if (samplingarea == 0) { if (samplingarea == 0) {
@ -234,27 +234,23 @@ TIFFScanlineSize(TIFF* tif)
&& !isUpSampled(tif)) { && !isUpSampled(tif)) {
uint16 ycbcrsubsampling[2]; uint16 ycbcrsubsampling[2];
TIFFGetField(tif, TIFFTAG_YCBCRSUBSAMPLING, TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
ycbcrsubsampling + 0, ycbcrsubsampling + 0,
ycbcrsubsampling + 1); ycbcrsubsampling + 1);
if (ycbcrsubsampling[0] == 0) { if (ycbcrsubsampling[0]*ycbcrsubsampling[1] == 0) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name, TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Invalid YCbCr subsampling"); "Invalid YCbCr subsampling");
return 0; return 0;
} }
scanline = TIFFroundup(td->td_imagewidth, /* number of sample clumps per line */
scanline = TIFFhowmany(td->td_imagewidth,
ycbcrsubsampling[0]); ycbcrsubsampling[0]);
scanline = TIFFhowmany8(multiply(tif, scanline, /* number of samples per line */
td->td_bitspersample, scanline = multiply(tif, scanline,
"TIFFScanlineSize")); ycbcrsubsampling[0]*ycbcrsubsampling[1] + 2,
return ((tsize_t) "TIFFScanlineSize");
summarize(tif, scanline,
multiply(tif, 2,
scanline / ycbcrsubsampling[0],
"TIFFVStripSize"),
"TIFFVStripSize"));
} else { } else {
scanline = multiply(tif, td->td_imagewidth, scanline = multiply(tif, td->td_imagewidth,
td->td_samplesperpixel, td->td_samplesperpixel,
@ -308,7 +304,7 @@ TIFFNewScanlineSize(TIFF* tif)
&& !isUpSampled(tif)) { && !isUpSampled(tif)) {
uint16 ycbcrsubsampling[2]; uint16 ycbcrsubsampling[2];
TIFFGetField(tif, TIFFTAG_YCBCRSUBSAMPLING, TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING,
ycbcrsubsampling + 0, ycbcrsubsampling + 0,
ycbcrsubsampling + 1); ycbcrsubsampling + 1);

View File

@ -1,4 +1,4 @@
/* $Id: tif_thunder.c,v 1.5.2.1 2010-06-08 18:50:43 bfriesen Exp $ */ /* $Id: tif_thunder.c,v 1.5.2.2 2011-03-21 16:01:28 fwarmerdam Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -25,6 +25,7 @@
*/ */
#include "tiffiop.h" #include "tiffiop.h"
#include <assert.h>
#ifdef THUNDER_SUPPORT #ifdef THUNDER_SUPPORT
/* /*
* TIFF Library. * TIFF Library.
@ -57,10 +58,30 @@ static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 };
#define SETPIXEL(op, v) { \ #define SETPIXEL(op, v) { \
lastpixel = (v) & 0xf; \ lastpixel = (v) & 0xf; \
if ( npixels < maxpixels ) \
{ \
if (npixels++ & 1) \ if (npixels++ & 1) \
*op++ |= lastpixel; \ *op++ |= lastpixel; \
else \ else \
op[0] = (tidataval_t) (lastpixel << 4); \ op[0] = (tidataval_t) (lastpixel << 4); \
} \
}
static int
ThunderSetupDecode(TIFF* tif)
{
static const char module[] = "ThunderSetupDecode";
if( tif->tif_dir.td_bitspersample != 4 )
{
TIFFErrorExt(tif->tif_clientdata, module,
"Wrong bitspersample value (%d), Thunder decoder only supports 4bits per sample.",
(int) tif->tif_dir.td_bitspersample );
return 0;
}
return (1);
} }
static int static int
@ -142,6 +163,7 @@ ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
occ -= tif->tif_scanlinesize; occ -= tif->tif_scanlinesize;
row += tif->tif_scanlinesize; row += tif->tif_scanlinesize;
} }
return (1); return (1);
} }
@ -151,6 +173,7 @@ TIFFInitThunderScan(TIFF* tif, int scheme)
(void) scheme; (void) scheme;
tif->tif_decoderow = ThunderDecodeRow; tif->tif_decoderow = ThunderDecodeRow;
tif->tif_decodestrip = ThunderDecodeRow; tif->tif_decodestrip = ThunderDecodeRow;
tif->tif_setupdecode = ThunderSetupDecode;
return (1); return (1);
} }
#endif /* THUNDER_SUPPORT */ #endif /* THUNDER_SUPPORT */
@ -163,3 +186,4 @@ TIFFInitThunderScan(TIFF* tif, int scheme)
* fill-column: 78 * fill-column: 78
* End: * End:
*/ */

View File

@ -1,4 +1,4 @@
/* $Id: tiffiop.h,v 1.51.2.6 2010-06-12 02:55:16 bfriesen Exp $ */ /* $Id: tiffiop.h,v 1.51.2.7 2011-03-21 21:09:19 fwarmerdam Exp $ */
/* /*
* Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1988-1997 Sam Leffler
@ -61,8 +61,11 @@ extern void *lfind(const void *, const void *, size_t *, size_t,
Libtiff itself does not require a 64-bit type, but bundled TIFF Libtiff itself does not require a 64-bit type, but bundled TIFF
utilities may use it. utilities may use it.
*/ */
#if !defined(__xlC__) && !defined(__xlc__) // Already defined there (#2301)
typedef TIFF_INT64_T int64; typedef TIFF_INT64_T int64;
typedef TIFF_UINT64_T uint64; typedef TIFF_UINT64_T uint64;
#endif
#include "tiffio.h" #include "tiffio.h"
#include "tif_dir.h" #include "tif_dir.h"

View File

@ -1,4 +1,4 @@
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.9.4\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." #define TIFFLIB_VERSION_STR "LIBTIFF, Version 3.9.5\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/* /*
* This define can be used in code that requires * This define can be used in code that requires
* compilation-related definitions specific to a * compilation-related definitions specific to a
@ -6,4 +6,4 @@
* version checking should be done based on the * version checking should be done based on the
* string returned by TIFFGetVersion. * string returned by TIFFGetVersion.
*/ */
#define TIFFLIB_VERSION 20100615 #define TIFFLIB_VERSION 20110409

36
3rdparty/readme.txt vendored
View File

@ -11,7 +11,6 @@ libjpeg 6b (6.2) - The Independent JPEG Group's JPEG software.
HAVE_JPEG preprocessor flag must be set to make highgui use libjpeg. HAVE_JPEG preprocessor flag must be set to make highgui use libjpeg.
On UNIX systems configure script takes care of it. On UNIX systems configure script takes care of it.
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
libpng 1.4.3 - Portable Network Graphics library. libpng 1.4.3 - Portable Network Graphics library.
Copyright (C) 1998-2010, Glenn Randers-Pehrson. Copyright (C) 1998-2010, Glenn Randers-Pehrson.
@ -20,15 +19,13 @@ libpng 1.4.3 - Portable Network Graphics library.
HAVE_PNG preprocessor flag must be set to make highgui use libpng. HAVE_PNG preprocessor flag must be set to make highgui use libpng.
On UNIX systems configure script takes care of it. On UNIX systems configure script takes care of it.
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
libtiff 3.9.4 - Tag Image File Format (TIFF) Software libtiff 3.9.5 - Tag Image File Format (TIFF) Software
Copyright (c) 1988-1997 Sam Leffler Copyright (c) 1988-1997 Sam Leffler
Copyright (c) 1991-1997 Silicon Graphics, Inc. Copyright (c) 1991-1997 Silicon Graphics, Inc.
See libtiff home page http://www.libtiff.org See libtiff home page http://www.libtiff.org
for details and links to the source code for details and links to the source code
HAVE_TIFF preprocessor flag must be set to make highgui use libtiff. HAVE_TIFF preprocessor flag must be set to make highgui use libtiff.
On UNIX systems configure script takes care of it. On UNIX systems configure script takes care of it.
@ -42,9 +39,7 @@ zlib 1.2.5 - General purpose LZ77 compression library
No preprocessor definition is needed to make highgui use this library - No preprocessor definition is needed to make highgui use this library -
it is included automatically if either libpng or libtiff are used. it is included automatically if either libpng or libtiff are used.
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
jasper-1.900.1 - JasPer is a collection of software jasper-1.900.1 - JasPer is a collection of software
(i.e., a library and application programs) for the coding (i.e., a library and application programs) for the coding
and manipulation of images. This software can handle image data in a and manipulation of images. This software can handle image data in a
@ -61,9 +56,7 @@ jasper-1.900.1 - JasPer is a collection of software
(lib/libjasper*). To get the latest source code, (lib/libjasper*). To get the latest source code,
please, visit the project homepage: please, visit the project homepage:
http://www.ece.uvic.ca/~mdadams/jasper/ http://www.ece.uvic.ca/~mdadams/jasper/
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
openexr-1.4.0 - OpenEXR is a high dynamic-range (HDR) image file format developed openexr-1.4.0 - OpenEXR is a high dynamic-range (HDR) image file format developed
by Industrial Light & Magic for use in computer imaging applications. by Industrial Light & Magic for use in computer imaging applications.
@ -73,34 +66,15 @@ openexr-1.4.0 - OpenEXR is a high dynamic-range (HDR) image file format develope
The project homepage: http://www.openexr.com/ The project homepage: http://www.openexr.com/
OpenCV on Windows does not include openexr codec by default. OpenCV does not include openexr codec.
To add it, you will need to recompile highgui with OpenEXR support To add it, you will need install OpenEXR, reconfigure OpenCV
using VS.NET2003 or VS.NET2005 (MSVC6 can not compile it): using CMake (make sure OpenEXR library is found) and the rebuild OpenCV.
1) download binaries (e.g. openexr-1.4.0-vs2005.zip)
from the official site.
2) copy
half.lib, iex.lib, ilmimf.lib ilmthread.lib imath.lib to
_graphics/lib
3) copy include/openexr/*.h to _graphics/include/openexr
4) open _make/opencv.sln
5) in highgui/_highgui.h uncomment
#define HAVE_ILMIMF 1
6) build debug/release configurations of highgui.
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------
ffmpeg-0.8.0 - FFmpeg is a complete, cross-platform solution to record,
ffmpeg-0.6.0 - FFmpeg is a complete, cross-platform solution to record,
convert and stream audio and video. It includes libavcodec - convert and stream audio and video. It includes libavcodec -
the leading audio/video codec library, and also libavformat, libavutils and the leading audio/video codec library, and also libavformat, libavutils and
other helper libraries that are used by OpenCV (in highgui module) to other helper libraries that are used by OpenCV (in highgui module) to
read and write video files. read and write video files.
The project homepage: http://ffmpeg.org/ The project homepage: http://ffmpeg.org/
------------------------------------------------------------------------------------
videoInput-0.1995 - Video capturing library for Windows using DirectShow as backend
Written by Theodore Watson
http://muonics.net/school/spring05/videoInput/
------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------