mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Update libtiff to release v4.0.2
This commit is contained in:
parent
e9392d1466
commit
35a869f6f0
6
3rdparty/libtiff/CMakeLists.txt
vendored
6
3rdparty/libtiff/CMakeLists.txt
vendored
@ -89,7 +89,11 @@ endif(WIN32)
|
||||
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-unused-but-set-variable -Wmissing-prototypes -Wmissing-declarations -Wundef -Wunused -Wsign-compare
|
||||
-Wcast-align -Wshadow -Wno-maybe-uninitialized -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter /wd4100 /wd4244 /wd4706 /wd4127 /wd4701 /wd4018 /wd4267 /wd4306 /wd4305 /wd4312 /wd4311 /wd4703)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-declarations -Wunused-parameter)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4100 /wd4127 /wd4311 /wd4701 /wd4706) # vs2005
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4267 /wd4305 /wd4306) # vs2008 Win64
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4703) # vs2012
|
||||
|
||||
if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR CV_ICC))
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
|
21
3rdparty/libtiff/COPYRIGHT
vendored
Normal file
21
3rdparty/libtiff/COPYRIGHT
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Copyright (c) 1988-1997 Sam Leffler
|
||||
Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this software and
|
||||
its documentation for any purpose is hereby granted without fee, provided
|
||||
that (i) the above copyright notices and this permission notice appear in
|
||||
all copies of the software and related documentation, and (ii) the names of
|
||||
Sam Leffler and Silicon Graphics may not be used in any advertising or
|
||||
publicity relating to the software without the specific, prior written
|
||||
permission of Sam Leffler and Silicon Graphics.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
||||
ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
OF THIS SOFTWARE.
|
5753
3rdparty/libtiff/ChangeLog
vendored
Normal file
5753
3rdparty/libtiff/ChangeLog
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
3rdparty/libtiff/tif_aux.c
vendored
8
3rdparty/libtiff/tif_aux.c
vendored
@ -325,8 +325,8 @@ _TIFFUInt64ToFloat(uint64 ui64)
|
||||
if (i.part.high >= 0) {
|
||||
return (float)i.value;
|
||||
} else {
|
||||
double df;
|
||||
df = (double)i.value;
|
||||
long double df;
|
||||
df = (long double)i.value;
|
||||
df += 18446744073709551616.0; /* adding 2**64 */
|
||||
return (float)df;
|
||||
}
|
||||
@ -341,8 +341,8 @@ _TIFFUInt64ToDouble(uint64 ui64)
|
||||
if (i.part.high >= 0) {
|
||||
return (double)i.value;
|
||||
} else {
|
||||
double df;
|
||||
df = (double)i.value;
|
||||
long double df;
|
||||
df = (long double)i.value;
|
||||
df += 18446744073709551616.0; /* adding 2**64 */
|
||||
return (double)df;
|
||||
}
|
||||
|
390
3rdparty/libtiff/tif_dir.c
vendored
390
3rdparty/libtiff/tif_dir.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_dir.c,v 1.108 2012-02-01 01:51:00 fwarmerdam Exp $ */
|
||||
/* $Id: tif_dir.c,v 1.113 2012-06-14 20:32:53 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -122,6 +122,10 @@ setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v)
|
||||
#undef EXTRASAMPLE_COREL_UNASSALPHA
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirm we have "samplesperpixel" ink names separated by \0. Returns
|
||||
* zero if the ink names are not as expected.
|
||||
*/
|
||||
static uint32
|
||||
checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
|
||||
{
|
||||
@ -132,9 +136,9 @@ checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
|
||||
const char* ep = s+slen;
|
||||
const char* cp = s;
|
||||
for (; i > 0; i--) {
|
||||
for (; *cp != '\0'; cp++)
|
||||
if (cp >= ep)
|
||||
goto bad;
|
||||
for (; cp < ep && *cp != '\0'; cp++) {}
|
||||
if (cp >= ep)
|
||||
goto bad;
|
||||
cp++; /* skip \0 */
|
||||
}
|
||||
return ((uint32)(cp-s));
|
||||
@ -157,8 +161,20 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
int status = 1;
|
||||
uint32 v32, i, v;
|
||||
char* s;
|
||||
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
|
||||
uint32 standard_tag = tag;
|
||||
|
||||
switch (tag) {
|
||||
/*
|
||||
* We want to force the custom code to be used for custom
|
||||
* fields even if the tag happens to match a well known
|
||||
* one - important for reinterpreted handling of standard
|
||||
* tag values in custom directories (ie. EXIF)
|
||||
*/
|
||||
if (fip->field_bit == FIELD_CUSTOM) {
|
||||
standard_tag = 0;
|
||||
}
|
||||
|
||||
switch (standard_tag) {
|
||||
case TIFFTAG_SUBFILETYPE:
|
||||
td->td_subfiletype = (uint32) va_arg(ap, uint32);
|
||||
break;
|
||||
@ -423,7 +439,6 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
default: {
|
||||
TIFFTagValue *tv;
|
||||
int tv_size, iCustom;
|
||||
const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
|
||||
|
||||
/*
|
||||
* This can happen if multiple images are open with different
|
||||
@ -550,102 +565,99 @@ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((fip->field_passcount
|
||||
|| fip->field_writecount == TIFF_VARIABLE
|
||||
|| fip->field_writecount == TIFF_VARIABLE2
|
||||
|| fip->field_writecount == TIFF_SPP
|
||||
|| tv->count > 1)
|
||||
&& fip->field_tag != TIFFTAG_PAGENUMBER
|
||||
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
|
||||
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
|
||||
&& fip->field_tag != TIFFTAG_DOTRANGE) {
|
||||
if (fip->field_tag == TIFFTAG_DOTRANGE
|
||||
&& strcmp(fip->field_name,"DotRange") == 0) {
|
||||
/* TODO: This is an evil exception and should not have been
|
||||
handled this way ... likely best if we move it into
|
||||
the directory structure with an explicit field in
|
||||
libtiff 4.1 and assign it a FIELD_ value */
|
||||
uint16 v[2];
|
||||
v[0] = (uint16)va_arg(ap, int);
|
||||
v[1] = (uint16)va_arg(ap, int);
|
||||
_TIFFmemcpy(tv->value, &v, 4);
|
||||
}
|
||||
|
||||
else if (fip->field_passcount
|
||||
|| fip->field_writecount == TIFF_VARIABLE
|
||||
|| fip->field_writecount == TIFF_VARIABLE2
|
||||
|| fip->field_writecount == TIFF_SPP
|
||||
|| tv->count > 1) {
|
||||
_TIFFmemcpy(tv->value, va_arg(ap, void *),
|
||||
tv->count * tv_size);
|
||||
} else {
|
||||
/*
|
||||
* XXX: The following loop required to handle
|
||||
* TIFFTAG_PAGENUMBER, TIFFTAG_HALFTONEHINTS,
|
||||
* TIFFTAG_YCBCRSUBSAMPLING and TIFFTAG_DOTRANGE tags.
|
||||
* These tags are actually arrays and should be passed as
|
||||
* array pointers to TIFFSetField() function, but actually
|
||||
* passed as a list of separate values. This behaviour
|
||||
* must be changed in the future!
|
||||
*/
|
||||
int i;
|
||||
char *val = (char *)tv->value;
|
||||
assert( tv->count == 1 );
|
||||
|
||||
for (i = 0; i < tv->count; i++, val += tv_size) {
|
||||
switch (fip->field_type) {
|
||||
case TIFF_BYTE:
|
||||
case TIFF_UNDEFINED:
|
||||
{
|
||||
uint8 v = (uint8)va_arg(ap, int);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SBYTE:
|
||||
{
|
||||
int8 v = (int8)va_arg(ap, int);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SHORT:
|
||||
{
|
||||
uint16 v = (uint16)va_arg(ap, int);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SSHORT:
|
||||
{
|
||||
int16 v = (int16)va_arg(ap, int);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
case TIFF_IFD:
|
||||
{
|
||||
uint32 v = va_arg(ap, uint32);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SLONG:
|
||||
{
|
||||
int32 v = va_arg(ap, int32);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_LONG8:
|
||||
case TIFF_IFD8:
|
||||
{
|
||||
uint64 v = va_arg(ap, uint64);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SLONG8:
|
||||
{
|
||||
int64 v = va_arg(ap, int64);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
case TIFF_FLOAT:
|
||||
{
|
||||
float v = (float)va_arg(ap, double);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_DOUBLE:
|
||||
{
|
||||
double v = va_arg(ap, double);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_TIFFmemset(val, 0, tv_size);
|
||||
status = 0;
|
||||
break;
|
||||
switch (fip->field_type) {
|
||||
case TIFF_BYTE:
|
||||
case TIFF_UNDEFINED:
|
||||
{
|
||||
uint8 v = (uint8)va_arg(ap, int);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SBYTE:
|
||||
{
|
||||
int8 v = (int8)va_arg(ap, int);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SHORT:
|
||||
{
|
||||
uint16 v = (uint16)va_arg(ap, int);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SSHORT:
|
||||
{
|
||||
int16 v = (int16)va_arg(ap, int);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
case TIFF_IFD:
|
||||
{
|
||||
uint32 v = va_arg(ap, uint32);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SLONG:
|
||||
{
|
||||
int32 v = va_arg(ap, int32);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_LONG8:
|
||||
case TIFF_IFD8:
|
||||
{
|
||||
uint64 v = va_arg(ap, uint64);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_SLONG8:
|
||||
{
|
||||
int64 v = va_arg(ap, int64);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
case TIFF_FLOAT:
|
||||
{
|
||||
float v = (float)va_arg(ap, double);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
case TIFF_DOUBLE:
|
||||
{
|
||||
double v = va_arg(ap, double);
|
||||
_TIFFmemcpy(val, &v, tv_size);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_TIFFmemset(val, 0, tv_size);
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -795,8 +807,20 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
{
|
||||
TIFFDirectory* td = &tif->tif_dir;
|
||||
int ret_val = 1;
|
||||
uint32 standard_tag = tag;
|
||||
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
|
||||
|
||||
/*
|
||||
* We want to force the custom code to be used for custom
|
||||
* fields even if the tag happens to match a well known
|
||||
* one - important for reinterpreted handling of standard
|
||||
* tag values in custom directories (ie. EXIF)
|
||||
*/
|
||||
if (fip->field_bit == FIELD_CUSTOM) {
|
||||
standard_tag = 0;
|
||||
}
|
||||
|
||||
switch (tag) {
|
||||
switch (standard_tag) {
|
||||
case TIFFTAG_SUBFILETYPE:
|
||||
*va_arg(ap, uint32*) = td->td_subfiletype;
|
||||
break;
|
||||
@ -971,8 +995,6 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
break;
|
||||
default:
|
||||
{
|
||||
const TIFFField* fip =
|
||||
TIFFFindField(tif, tag, TIFF_ANY);
|
||||
int i;
|
||||
|
||||
/*
|
||||
@ -1013,84 +1035,85 @@ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
|
||||
*va_arg(ap, uint16*) = (uint16)tv->count;
|
||||
*va_arg(ap, void **) = tv->value;
|
||||
ret_val = 1;
|
||||
} else if (fip->field_tag == TIFFTAG_DOTRANGE
|
||||
&& strcmp(fip->field_name,"DotRange") == 0) {
|
||||
/* TODO: This is an evil exception and should not have been
|
||||
handled this way ... likely best if we move it into
|
||||
the directory structure with an explicit field in
|
||||
libtiff 4.1 and assign it a FIELD_ value */
|
||||
*va_arg(ap, uint16*) = ((uint16 *)tv->value)[0];
|
||||
*va_arg(ap, uint16*) = ((uint16 *)tv->value)[1];
|
||||
ret_val = 1;
|
||||
} else {
|
||||
if ((fip->field_type == TIFF_ASCII
|
||||
if (fip->field_type == TIFF_ASCII
|
||||
|| fip->field_readcount == TIFF_VARIABLE
|
||||
|| fip->field_readcount == TIFF_VARIABLE2
|
||||
|| fip->field_readcount == TIFF_SPP
|
||||
|| tv->count > 1)
|
||||
&& fip->field_tag != TIFFTAG_PAGENUMBER
|
||||
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
|
||||
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
|
||||
&& fip->field_tag != TIFFTAG_DOTRANGE) {
|
||||
|| tv->count > 1) {
|
||||
*va_arg(ap, void **) = tv->value;
|
||||
ret_val = 1;
|
||||
} else {
|
||||
int j;
|
||||
char *val = (char *)tv->value;
|
||||
|
||||
for (j = 0; j < tv->count;
|
||||
j++, val += _TIFFDataSize(tv->info->field_type)) {
|
||||
switch (fip->field_type) {
|
||||
case TIFF_BYTE:
|
||||
case TIFF_UNDEFINED:
|
||||
*va_arg(ap, uint8*) =
|
||||
*(uint8 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SBYTE:
|
||||
*va_arg(ap, int8*) =
|
||||
*(int8 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SHORT:
|
||||
*va_arg(ap, uint16*) =
|
||||
*(uint16 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SSHORT:
|
||||
*va_arg(ap, int16*) =
|
||||
*(int16 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
case TIFF_IFD:
|
||||
*va_arg(ap, uint32*) =
|
||||
*(uint32 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SLONG:
|
||||
*va_arg(ap, int32*) =
|
||||
*(int32 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_LONG8:
|
||||
case TIFF_IFD8:
|
||||
*va_arg(ap, uint64*) =
|
||||
*(uint64 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SLONG8:
|
||||
*va_arg(ap, int64*) =
|
||||
*(int64 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
case TIFF_FLOAT:
|
||||
*va_arg(ap, float*) =
|
||||
*(float *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_DOUBLE:
|
||||
*va_arg(ap, double*) =
|
||||
*(double *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
default:
|
||||
ret_val = 0;
|
||||
break;
|
||||
}
|
||||
assert( tv->count == 1 );
|
||||
switch (fip->field_type) {
|
||||
case TIFF_BYTE:
|
||||
case TIFF_UNDEFINED:
|
||||
*va_arg(ap, uint8*) =
|
||||
*(uint8 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SBYTE:
|
||||
*va_arg(ap, int8*) =
|
||||
*(int8 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SHORT:
|
||||
*va_arg(ap, uint16*) =
|
||||
*(uint16 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SSHORT:
|
||||
*va_arg(ap, int16*) =
|
||||
*(int16 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_LONG:
|
||||
case TIFF_IFD:
|
||||
*va_arg(ap, uint32*) =
|
||||
*(uint32 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SLONG:
|
||||
*va_arg(ap, int32*) =
|
||||
*(int32 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_LONG8:
|
||||
case TIFF_IFD8:
|
||||
*va_arg(ap, uint64*) =
|
||||
*(uint64 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_SLONG8:
|
||||
*va_arg(ap, int64*) =
|
||||
*(int64 *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_RATIONAL:
|
||||
case TIFF_SRATIONAL:
|
||||
case TIFF_FLOAT:
|
||||
*va_arg(ap, float*) =
|
||||
*(float *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
case TIFF_DOUBLE:
|
||||
*va_arg(ap, double*) =
|
||||
*(double *)val;
|
||||
ret_val = 1;
|
||||
break;
|
||||
default:
|
||||
ret_val = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1214,6 +1237,35 @@ TIFFCreateDirectory(TIFF* tif)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray)
|
||||
{
|
||||
TIFFDefaultDirectory(tif);
|
||||
|
||||
/*
|
||||
* Reset the field definitions to match the application provided list.
|
||||
* Hopefully TIFFDefaultDirectory() won't have done anything irreversable
|
||||
* based on it's assumption this is an image directory.
|
||||
*/
|
||||
_TIFFSetupFields(tif, infoarray);
|
||||
|
||||
tif->tif_diroff = 0;
|
||||
tif->tif_nextdiroff = 0;
|
||||
tif->tif_curoff = 0;
|
||||
tif->tif_row = (uint32) -1;
|
||||
tif->tif_curstrip = (uint32) -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
TIFFCreateEXIFDirectory(TIFF* tif)
|
||||
{
|
||||
const TIFFFieldArray* exifFieldArray;
|
||||
exifFieldArray = _TIFFGetExifFields();
|
||||
return TIFFCreateCustomDirectory(tif, exifFieldArray);
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup a default directory structure.
|
||||
*/
|
||||
|
3
3rdparty/libtiff/tif_fax3.c
vendored
3
3rdparty/libtiff/tif_fax3.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_fax3.c,v 1.72 2010-06-09 17:17:13 bfriesen Exp $ */
|
||||
/* $Id: tif_fax3.c,v 1.73 2012-06-13 00:27:20 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990-1997 Sam Leffler
|
||||
@ -526,6 +526,7 @@ Fax3SetupState(TIFF* tif)
|
||||
"for Group 3/4 run arrays");
|
||||
if (dsp->runs == NULL)
|
||||
return (0);
|
||||
memset( dsp->runs, 0, TIFFSafeMultiply(uint32,nruns,2));
|
||||
dsp->curruns = dsp->runs;
|
||||
if (needsRefLine)
|
||||
dsp->refruns = dsp->runs + nruns;
|
||||
|
168
3rdparty/libtiff/tif_getimage.c
vendored
168
3rdparty/libtiff/tif_getimage.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_getimage.c,v 1.78 2011-02-23 21:46:09 fwarmerdam Exp $ */
|
||||
/* $Id: tif_getimage.c,v 1.82 2012-06-06 00:17:49 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@ -692,6 +692,7 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
unsigned char* p2;
|
||||
unsigned char* pa;
|
||||
tmsize_t tilesize;
|
||||
tmsize_t bufsize;
|
||||
int32 fromskew, toskew;
|
||||
int alpha = img->alpha;
|
||||
uint32 nrow;
|
||||
@ -699,12 +700,17 @@ gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
int colorchannels;
|
||||
|
||||
tilesize = TIFFTileSize(tif);
|
||||
buf = (unsigned char*) _TIFFmalloc((alpha?4:3)*tilesize);
|
||||
bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,tilesize);
|
||||
if (bufsize == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtTileSeparate");
|
||||
return (0);
|
||||
}
|
||||
buf = (unsigned char*) _TIFFmalloc(bufsize);
|
||||
if (buf == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "No space for tile buffer");
|
||||
return (0);
|
||||
}
|
||||
_TIFFmemset(buf, 0, (alpha?4:3)*tilesize);
|
||||
_TIFFmemset(buf, 0, bufsize);
|
||||
p0 = buf;
|
||||
p1 = p0 + tilesize;
|
||||
p2 = p1 + tilesize;
|
||||
@ -917,17 +923,23 @@ gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h)
|
||||
uint32 rowsperstrip, offset_row;
|
||||
uint32 imagewidth = img->width;
|
||||
tmsize_t stripsize;
|
||||
tmsize_t bufsize;
|
||||
int32 fromskew, toskew;
|
||||
int alpha = img->alpha;
|
||||
int ret = 1, flip, colorchannels;
|
||||
|
||||
stripsize = TIFFStripSize(tif);
|
||||
p0 = buf = (unsigned char *)_TIFFmalloc((alpha?4:3)*stripsize);
|
||||
bufsize = TIFFSafeMultiply(tmsize_t,alpha?4:3,stripsize);
|
||||
if (bufsize == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in %s", "gtStripSeparate");
|
||||
return (0);
|
||||
}
|
||||
p0 = buf = (unsigned char *)_TIFFmalloc(bufsize);
|
||||
if (buf == 0) {
|
||||
TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer");
|
||||
return (0);
|
||||
}
|
||||
_TIFFmemset(buf, 0, (alpha?4:3)*stripsize);
|
||||
_TIFFmemset(buf, 0, bufsize);
|
||||
p1 = p0 + stripsize;
|
||||
p2 = p1 + stripsize;
|
||||
pa = (alpha?(p2+stripsize):NULL);
|
||||
@ -1196,6 +1208,26 @@ DECLAREContigPutFunc(putgreytile)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 8-bit greyscale with associated alpha => colormap/RGBA
|
||||
*/
|
||||
DECLAREContigPutFunc(putagreytile)
|
||||
{
|
||||
int samplesperpixel = img->samplesperpixel;
|
||||
uint32** BWmap = img->BWmap;
|
||||
|
||||
(void) y;
|
||||
while (h-- > 0) {
|
||||
for (x = w; x-- > 0;)
|
||||
{
|
||||
*cp++ = BWmap[*pp][0] & (*(pp+1) << 24 | ~A1);
|
||||
pp += samplesperpixel;
|
||||
}
|
||||
cp += toskew;
|
||||
pp += fromskew;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 16-bit greyscale => colormap/RGB
|
||||
*/
|
||||
@ -1494,6 +1526,26 @@ DECLARESepPutFunc(putRGBAAseparate8bittile)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 8-bit unpacked CMYK samples => RGBA
|
||||
*/
|
||||
DECLARESepPutFunc(putCMYKseparate8bittile)
|
||||
{
|
||||
(void) img; (void) y;
|
||||
while (h-- > 0) {
|
||||
uint32 rv, gv, bv, kv;
|
||||
for (x = w; x-- > 0;) {
|
||||
kv = 255 - *a++;
|
||||
rv = (kv*(255-*r++))/255;
|
||||
gv = (kv*(255-*g++))/255;
|
||||
bv = (kv*(255-*b++))/255;
|
||||
*cp++ = PACK4(rv,gv,bv,255);
|
||||
}
|
||||
SKEW4(r, g, b, a, fromskew);
|
||||
cp += toskew;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 8-bit unpacked samples => RGBA w/ unassociated alpha
|
||||
*/
|
||||
@ -2461,7 +2513,10 @@ PickContigCase(TIFFRGBAImage* img)
|
||||
img->put.contig = put16bitbwtile;
|
||||
break;
|
||||
case 8:
|
||||
img->put.contig = putgreytile;
|
||||
if (img->alpha && img->samplesperpixel == 2)
|
||||
img->put.contig = putagreytile;
|
||||
else
|
||||
img->put.contig = putgreytile;
|
||||
break;
|
||||
case 4:
|
||||
img->put.contig = put4bitbwtile;
|
||||
@ -2540,58 +2595,65 @@ PickSeparateCase(TIFFRGBAImage* img)
|
||||
img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate;
|
||||
img->put.separate = NULL;
|
||||
switch (img->photometric) {
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
/* greyscale images processed pretty much as RGB by gtTileSeparate */
|
||||
case PHOTOMETRIC_RGB:
|
||||
switch (img->bitspersample) {
|
||||
case 8:
|
||||
if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
|
||||
img->put.separate = putRGBAAseparate8bittile;
|
||||
else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
|
||||
{
|
||||
if (BuildMapUaToAa(img))
|
||||
img->put.separate = putRGBUAseparate8bittile;
|
||||
}
|
||||
else
|
||||
img->put.separate = putRGBseparate8bittile;
|
||||
break;
|
||||
case 16:
|
||||
if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
|
||||
{
|
||||
if (BuildMapBitdepth16To8(img))
|
||||
img->put.separate = putRGBAAseparate16bittile;
|
||||
}
|
||||
else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
|
||||
{
|
||||
if (BuildMapBitdepth16To8(img) &&
|
||||
BuildMapUaToAa(img))
|
||||
img->put.separate = putRGBUAseparate16bittile;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BuildMapBitdepth16To8(img))
|
||||
img->put.separate = putRGBseparate16bittile;
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_MINISWHITE:
|
||||
case PHOTOMETRIC_MINISBLACK:
|
||||
/* greyscale images processed pretty much as RGB by gtTileSeparate */
|
||||
case PHOTOMETRIC_RGB:
|
||||
switch (img->bitspersample) {
|
||||
case 8:
|
||||
if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
|
||||
img->put.separate = putRGBAAseparate8bittile;
|
||||
else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
|
||||
{
|
||||
if (BuildMapUaToAa(img))
|
||||
img->put.separate = putRGBUAseparate8bittile;
|
||||
}
|
||||
else
|
||||
img->put.separate = putRGBseparate8bittile;
|
||||
break;
|
||||
case 16:
|
||||
if (img->alpha == EXTRASAMPLE_ASSOCALPHA)
|
||||
{
|
||||
if (BuildMapBitdepth16To8(img))
|
||||
img->put.separate = putRGBAAseparate16bittile;
|
||||
}
|
||||
else if (img->alpha == EXTRASAMPLE_UNASSALPHA)
|
||||
{
|
||||
if (BuildMapBitdepth16To8(img) &&
|
||||
BuildMapUaToAa(img))
|
||||
img->put.separate = putRGBUAseparate16bittile;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (BuildMapBitdepth16To8(img))
|
||||
img->put.separate = putRGBseparate16bittile;
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_YCBCR:
|
||||
if ((img->bitspersample==8) && (img->samplesperpixel==3))
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_SEPARATED:
|
||||
if (img->bitspersample == 8 && img->samplesperpixel == 4)
|
||||
{
|
||||
img->alpha = 1; // Not alpha, but seems like the only way to get 4th band
|
||||
img->put.separate = putCMYKseparate8bittile;
|
||||
}
|
||||
break;
|
||||
case PHOTOMETRIC_YCBCR:
|
||||
if ((img->bitspersample==8) && (img->samplesperpixel==3))
|
||||
{
|
||||
if (initYCbCrConversion(img)!=0)
|
||||
{
|
||||
if (initYCbCrConversion(img)!=0)
|
||||
{
|
||||
uint16 hs, vs;
|
||||
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
|
||||
switch ((hs<<4)|vs) {
|
||||
case 0x11:
|
||||
img->put.separate = putseparate8bitYCbCr11tile;
|
||||
break;
|
||||
/* TODO: add other cases here */
|
||||
}
|
||||
uint16 hs, vs;
|
||||
TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs);
|
||||
switch ((hs<<4)|vs) {
|
||||
case 0x11:
|
||||
img->put.separate = putseparate8bitYCbCr11tile;
|
||||
break;
|
||||
/* TODO: add other cases here */
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ((img->get!=NULL) && (img->put.separate!=NULL));
|
||||
}
|
||||
|
99
3rdparty/libtiff/tif_jpeg.c
vendored
99
3rdparty/libtiff/tif_jpeg.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_jpeg.c,v 1.105 2012-02-01 01:51:00 fwarmerdam Exp $ */
|
||||
/* $Id: tif_jpeg.c,v 1.108 2012-06-05 03:24:30 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994-1997 Sam Leffler
|
||||
@ -1095,50 +1095,13 @@ JPEGPreDecode(TIFF* tif, uint16 s)
|
||||
/* Component 0 should have expected sampling factors */
|
||||
if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling ||
|
||||
sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) {
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
"Improper JPEG sampling factors %d,%d\n"
|
||||
"Apparently should be %d,%d.",
|
||||
sp->cinfo.d.comp_info[0].h_samp_factor,
|
||||
sp->cinfo.d.comp_info[0].v_samp_factor,
|
||||
sp->h_sampling, sp->v_sampling);
|
||||
|
||||
/*
|
||||
* There are potential security issues here
|
||||
* for decoders that have already allocated
|
||||
* buffers based on the expected sampling
|
||||
* factors. Lets check the sampling factors
|
||||
* dont exceed what we were expecting.
|
||||
*/
|
||||
if (sp->cinfo.d.comp_info[0].h_samp_factor
|
||||
> sp->h_sampling
|
||||
|| sp->cinfo.d.comp_info[0].v_samp_factor
|
||||
> sp->v_sampling) {
|
||||
TIFFErrorExt(tif->tif_clientdata,
|
||||
module,
|
||||
"Cannot honour JPEG sampling factors"
|
||||
" that exceed those specified.");
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: Files written by the Intergraph software
|
||||
* has different sampling factors stored in the
|
||||
* TIFF tags and in the JPEG structures. We will
|
||||
* try to deduce Intergraph files by the presense
|
||||
* of the tag 33918.
|
||||
*/
|
||||
if (!TIFFFindField(tif, 33918, TIFF_ANY)) {
|
||||
TIFFWarningExt(tif->tif_clientdata, module,
|
||||
"Decompressor will try reading with "
|
||||
"sampling %d,%d.",
|
||||
sp->cinfo.d.comp_info[0].h_samp_factor,
|
||||
sp->cinfo.d.comp_info[0].v_samp_factor);
|
||||
|
||||
sp->h_sampling = (uint16)
|
||||
sp->cinfo.d.comp_info[0].h_samp_factor;
|
||||
sp->v_sampling = (uint16)
|
||||
sp->cinfo.d.comp_info[0].v_samp_factor;
|
||||
}
|
||||
TIFFErrorExt(tif->tif_clientdata, module,
|
||||
"Improper JPEG sampling factors %d,%d\n"
|
||||
"Apparently should be %d,%d.",
|
||||
sp->cinfo.d.comp_info[0].h_samp_factor,
|
||||
sp->cinfo.d.comp_info[0].v_samp_factor,
|
||||
sp->h_sampling, sp->v_sampling);
|
||||
return (0);
|
||||
}
|
||||
/* Rest should have sampling factors 1,1 */
|
||||
for (ci = 1; ci < sp->cinfo.d.num_components; ci++) {
|
||||
@ -1160,11 +1123,11 @@ JPEGPreDecode(TIFF* tif, uint16 s)
|
||||
if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
|
||||
sp->photometric == PHOTOMETRIC_YCBCR &&
|
||||
sp->jpegcolormode == JPEGCOLORMODE_RGB) {
|
||||
/* Convert YCbCr to RGB */
|
||||
/* Convert YCbCr to RGB */
|
||||
sp->cinfo.d.jpeg_color_space = JCS_YCbCr;
|
||||
sp->cinfo.d.out_color_space = JCS_RGB;
|
||||
} else {
|
||||
/* Suppress colorspace handling */
|
||||
/* Suppress colorspace handling */
|
||||
sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN;
|
||||
sp->cinfo.d.out_color_space = JCS_UNKNOWN;
|
||||
if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
|
||||
@ -1349,8 +1312,8 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
|
||||
#if defined(JPEG_LIB_MK1_OR_12BIT)
|
||||
unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) *
|
||||
sp->cinfo.d.output_width *
|
||||
sp->cinfo.d.num_components);
|
||||
sp->cinfo.d.output_width *
|
||||
sp->cinfo.d.num_components);
|
||||
if(tmpbuf==NULL) {
|
||||
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
|
||||
"Out of memory");
|
||||
@ -1362,10 +1325,10 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
jpeg_component_info *compptr;
|
||||
int ci, clumpoffset;
|
||||
|
||||
if( cc < sp->bytesperline * sp->v_sampling ) {
|
||||
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
|
||||
"application buffer not large enough for all data.");
|
||||
return 0;
|
||||
if( cc < sp->bytesperline ) {
|
||||
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
|
||||
"application buffer not large enough for all data.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Reload downsampled-data buffer if needed */
|
||||
@ -1381,20 +1344,25 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
*/
|
||||
clumpoffset = 0; /* first sample in clump */
|
||||
for (ci = 0, compptr = sp->cinfo.d.comp_info;
|
||||
ci < sp->cinfo.d.num_components;
|
||||
ci++, compptr++) {
|
||||
ci < sp->cinfo.d.num_components;
|
||||
ci++, compptr++) {
|
||||
int hsamp = compptr->h_samp_factor;
|
||||
int vsamp = compptr->v_samp_factor;
|
||||
int ypos;
|
||||
|
||||
for (ypos = 0; ypos < vsamp; ypos++) {
|
||||
JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos];
|
||||
JDIMENSION nclump;
|
||||
#if defined(JPEG_LIB_MK1_OR_12BIT)
|
||||
JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset;
|
||||
#else
|
||||
JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset;
|
||||
if (cc < clumpoffset + samples_per_clump*(clumps_per_line-1) + hsamp) {
|
||||
TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw",
|
||||
"application buffer not large enough for all data, possible subsampling issue");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
JDIMENSION nclump;
|
||||
|
||||
if (hsamp == 1) {
|
||||
/* fast path for at least Cb and Cr */
|
||||
@ -1405,7 +1373,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
} else {
|
||||
int xpos;
|
||||
|
||||
/* general case */
|
||||
/* general case */
|
||||
for (nclump = clumps_per_line; nclump-- > 0; ) {
|
||||
for (xpos = 0; xpos < hsamp; xpos++)
|
||||
outptr[xpos] = *inptr++;
|
||||
@ -1428,9 +1396,9 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* 12-bit */
|
||||
{ /* 12-bit */
|
||||
int value_pairs = (sp->cinfo.d.output_width
|
||||
* sp->cinfo.d.num_components) / 2;
|
||||
* sp->cinfo.d.num_components) / 2;
|
||||
int iPair;
|
||||
for( iPair = 0; iPair < value_pairs; iPair++ )
|
||||
{
|
||||
@ -1438,7 +1406,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
JSAMPLE *in_ptr = (JSAMPLE *) (tmpbuf + iPair * 2);
|
||||
out_ptr[0] = (in_ptr[0] & 0xff0) >> 4;
|
||||
out_ptr[1] = ((in_ptr[0] & 0xf) << 4)
|
||||
| ((in_ptr[1] & 0xf00) >> 8);
|
||||
| ((in_ptr[1] & 0xf00) >> 8);
|
||||
out_ptr[2] = ((in_ptr[1] & 0xff) >> 0);
|
||||
}
|
||||
}
|
||||
@ -1447,12 +1415,9 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
|
||||
sp->scancount ++;
|
||||
tif->tif_row += sp->v_sampling;
|
||||
/*
|
||||
buf += clumps_per_line*samples_per_clump;
|
||||
cc -= clumps_per_line*samples_per_clump;
|
||||
*/
|
||||
buf += sp->bytesperline * sp->v_sampling;
|
||||
cc -= sp->bytesperline * sp->v_sampling;
|
||||
|
||||
buf += sp->bytesperline;
|
||||
cc -= sp->bytesperline;
|
||||
|
||||
nrows -= sp->v_sampling;
|
||||
} while (nrows > 0);
|
||||
@ -1465,7 +1430,7 @@ JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
||||
|
||||
/* Close down the decompressor if done. */
|
||||
return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height
|
||||
|| TIFFjpeg_finish_decompress(sp);
|
||||
|| TIFFjpeg_finish_decompress(sp);
|
||||
}
|
||||
|
||||
|
||||
|
11
3rdparty/libtiff/tif_ojpeg.c
vendored
11
3rdparty/libtiff/tif_ojpeg.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_ojpeg.c,v 1.54 2011-05-31 17:05:07 bfriesen Exp $ */
|
||||
/* $Id: tif_ojpeg.c,v 1.56 2012-05-24 03:15:18 fwarmerdam Exp $ */
|
||||
|
||||
/* WARNING: The type of JPEG encapsulation defined by the TIFF Version 6.0
|
||||
specification is now totally obsolete and deprecated for new applications and
|
||||
@ -1146,7 +1146,9 @@ OJPEGWriteHeaderInfo(TIFF* tif)
|
||||
OJPEGState* sp=(OJPEGState*)tif->tif_data;
|
||||
uint8** m;
|
||||
uint32 n;
|
||||
assert(sp->libjpeg_session_active==0);
|
||||
/* if a previous attempt failed, don't try again */
|
||||
if (sp->libjpeg_session_active != 0)
|
||||
return 0;
|
||||
sp->out_state=ososSoi;
|
||||
sp->restart_index=0;
|
||||
jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr));
|
||||
@ -1954,6 +1956,11 @@ OJPEGReadBufferFill(OJPEGState* sp)
|
||||
case osibsJpegInterchangeFormat:
|
||||
sp->in_buffer_source=osibsStrile;
|
||||
case osibsStrile:
|
||||
if (!_TIFFFillStriles( sp->tif )
|
||||
|| sp->tif->tif_dir.td_stripoffset == NULL
|
||||
|| sp->tif->tif_dir.td_stripbytecount == NULL)
|
||||
return 0;
|
||||
|
||||
if (sp->in_buffer_next_strile==sp->in_buffer_strile_count)
|
||||
sp->in_buffer_source=osibsEof;
|
||||
else
|
||||
|
74
3rdparty/libtiff/tif_pixarlog.c
vendored
74
3rdparty/libtiff/tif_pixarlog.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_pixarlog.c,v 1.35 2011-01-06 16:00:23 fwarmerdam Exp $ */
|
||||
/* $Id: tif_pixarlog.c,v 1.37 2012-05-24 23:21:45 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996-1997 Sam Leffler
|
||||
@ -120,9 +120,9 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op,
|
||||
if (n >= stride) {
|
||||
mask = CODE_MASK;
|
||||
if (stride == 3) {
|
||||
t0 = ToLinearF[cr = wp[0]];
|
||||
t1 = ToLinearF[cg = wp[1]];
|
||||
t2 = ToLinearF[cb = wp[2]];
|
||||
t0 = ToLinearF[cr = (wp[0] & mask)];
|
||||
t1 = ToLinearF[cg = (wp[1] & mask)];
|
||||
t2 = ToLinearF[cb = (wp[2] & mask)];
|
||||
op[0] = t0;
|
||||
op[1] = t1;
|
||||
op[2] = t2;
|
||||
@ -139,10 +139,10 @@ horizontalAccumulateF(uint16 *wp, int n, int stride, float *op,
|
||||
op[2] = t2;
|
||||
}
|
||||
} else if (stride == 4) {
|
||||
t0 = ToLinearF[cr = wp[0]];
|
||||
t1 = ToLinearF[cg = wp[1]];
|
||||
t2 = ToLinearF[cb = wp[2]];
|
||||
t3 = ToLinearF[ca = wp[3]];
|
||||
t0 = ToLinearF[cr = (wp[0] & mask)];
|
||||
t1 = ToLinearF[cg = (wp[1] & mask)];
|
||||
t2 = ToLinearF[cb = (wp[2] & mask)];
|
||||
t3 = ToLinearF[ca = (wp[3] & mask)];
|
||||
op[0] = t0;
|
||||
op[1] = t1;
|
||||
op[2] = t2;
|
||||
@ -186,9 +186,9 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op,
|
||||
if (n >= stride) {
|
||||
mask = CODE_MASK;
|
||||
if (stride == 3) {
|
||||
t0 = ToLinearF[cr = wp[0]] * SCALE12;
|
||||
t1 = ToLinearF[cg = wp[1]] * SCALE12;
|
||||
t2 = ToLinearF[cb = wp[2]] * SCALE12;
|
||||
t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12;
|
||||
t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12;
|
||||
t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12;
|
||||
op[0] = CLAMP12(t0);
|
||||
op[1] = CLAMP12(t1);
|
||||
op[2] = CLAMP12(t2);
|
||||
@ -205,10 +205,10 @@ horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op,
|
||||
op[2] = CLAMP12(t2);
|
||||
}
|
||||
} else if (stride == 4) {
|
||||
t0 = ToLinearF[cr = wp[0]] * SCALE12;
|
||||
t1 = ToLinearF[cg = wp[1]] * SCALE12;
|
||||
t2 = ToLinearF[cb = wp[2]] * SCALE12;
|
||||
t3 = ToLinearF[ca = wp[3]] * SCALE12;
|
||||
t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12;
|
||||
t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12;
|
||||
t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12;
|
||||
t3 = ToLinearF[ca = (wp[3] & mask)] * SCALE12;
|
||||
op[0] = CLAMP12(t0);
|
||||
op[1] = CLAMP12(t1);
|
||||
op[2] = CLAMP12(t2);
|
||||
@ -250,9 +250,9 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op,
|
||||
if (n >= stride) {
|
||||
mask = CODE_MASK;
|
||||
if (stride == 3) {
|
||||
op[0] = ToLinear16[cr = wp[0]];
|
||||
op[1] = ToLinear16[cg = wp[1]];
|
||||
op[2] = ToLinear16[cb = wp[2]];
|
||||
op[0] = ToLinear16[cr = (wp[0] & mask)];
|
||||
op[1] = ToLinear16[cg = (wp[1] & mask)];
|
||||
op[2] = ToLinear16[cb = (wp[2] & mask)];
|
||||
n -= 3;
|
||||
while (n > 0) {
|
||||
wp += 3;
|
||||
@ -263,10 +263,10 @@ horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op,
|
||||
op[2] = ToLinear16[(cb += wp[2]) & mask];
|
||||
}
|
||||
} else if (stride == 4) {
|
||||
op[0] = ToLinear16[cr = wp[0]];
|
||||
op[1] = ToLinear16[cg = wp[1]];
|
||||
op[2] = ToLinear16[cb = wp[2]];
|
||||
op[3] = ToLinear16[ca = wp[3]];
|
||||
op[0] = ToLinear16[cr = (wp[0] & mask)];
|
||||
op[1] = ToLinear16[cg = (wp[1] & mask)];
|
||||
op[2] = ToLinear16[cb = (wp[2] & mask)];
|
||||
op[3] = ToLinear16[ca = (wp[3] & mask)];
|
||||
n -= 4;
|
||||
while (n > 0) {
|
||||
wp += 4;
|
||||
@ -345,9 +345,9 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op,
|
||||
if (n >= stride) {
|
||||
mask = CODE_MASK;
|
||||
if (stride == 3) {
|
||||
op[0] = ToLinear8[cr = wp[0]];
|
||||
op[1] = ToLinear8[cg = wp[1]];
|
||||
op[2] = ToLinear8[cb = wp[2]];
|
||||
op[0] = ToLinear8[cr = (wp[0] & mask)];
|
||||
op[1] = ToLinear8[cg = (wp[1] & mask)];
|
||||
op[2] = ToLinear8[cb = (wp[2] & mask)];
|
||||
n -= 3;
|
||||
while (n > 0) {
|
||||
n -= 3;
|
||||
@ -358,10 +358,10 @@ horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op,
|
||||
op[2] = ToLinear8[(cb += wp[2]) & mask];
|
||||
}
|
||||
} else if (stride == 4) {
|
||||
op[0] = ToLinear8[cr = wp[0]];
|
||||
op[1] = ToLinear8[cg = wp[1]];
|
||||
op[2] = ToLinear8[cb = wp[2]];
|
||||
op[3] = ToLinear8[ca = wp[3]];
|
||||
op[0] = ToLinear8[cr = (wp[0] & mask)];
|
||||
op[1] = ToLinear8[cg = (wp[1] & mask)];
|
||||
op[2] = ToLinear8[cb = (wp[2] & mask)];
|
||||
op[3] = ToLinear8[ca = (wp[3] & mask)];
|
||||
n -= 4;
|
||||
while (n > 0) {
|
||||
n -= 4;
|
||||
@ -396,9 +396,9 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op,
|
||||
mask = CODE_MASK;
|
||||
if (stride == 3) {
|
||||
op[0] = 0;
|
||||
t1 = ToLinear8[cb = wp[2]];
|
||||
t2 = ToLinear8[cg = wp[1]];
|
||||
t3 = ToLinear8[cr = wp[0]];
|
||||
t1 = ToLinear8[cb = (wp[2] & mask)];
|
||||
t2 = ToLinear8[cg = (wp[1] & mask)];
|
||||
t3 = ToLinear8[cr = (wp[0] & mask)];
|
||||
op[1] = t1;
|
||||
op[2] = t2;
|
||||
op[3] = t3;
|
||||
@ -416,10 +416,10 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op,
|
||||
op[3] = t3;
|
||||
}
|
||||
} else if (stride == 4) {
|
||||
t0 = ToLinear8[ca = wp[3]];
|
||||
t1 = ToLinear8[cb = wp[2]];
|
||||
t2 = ToLinear8[cg = wp[1]];
|
||||
t3 = ToLinear8[cr = wp[0]];
|
||||
t0 = ToLinear8[ca = (wp[3] & mask)];
|
||||
t1 = ToLinear8[cb = (wp[2] & mask)];
|
||||
t2 = ToLinear8[cg = (wp[1] & mask)];
|
||||
t3 = ToLinear8[cr = (wp[0] & mask)];
|
||||
op[0] = t0;
|
||||
op[1] = t1;
|
||||
op[2] = t2;
|
||||
@ -673,7 +673,7 @@ PixarLogSetupDecode(TIFF* tif)
|
||||
td->td_rowsperstrip), sizeof(uint16));
|
||||
if (tbuf_size == 0)
|
||||
return (0); /* TODO: this is an error return without error report through TIFFErrorExt */
|
||||
sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size);
|
||||
sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16));
|
||||
if (sp->tbuf == NULL)
|
||||
return (0);
|
||||
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
|
||||
|
145
3rdparty/libtiff/tif_print.c
vendored
145
3rdparty/libtiff/tif_print.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_print.c,v 1.54 2011-04-02 20:54:09 bfriesen Exp $ */
|
||||
/* $Id: tif_print.c,v 1.59 2012-06-13 01:08:51 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -34,6 +34,9 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static void
|
||||
_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars);
|
||||
|
||||
static const char *photoNames[] = {
|
||||
"min-is-white", /* PHOTOMETRIC_MINISWHITE */
|
||||
"min-is-black", /* PHOTOMETRIC_MINISBLACK */
|
||||
@ -135,34 +138,51 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip,
|
||||
}
|
||||
|
||||
static int
|
||||
_TIFFPrettyPrintField(TIFF* tif, FILE* fd, uint32 tag,
|
||||
_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag,
|
||||
uint32 value_count, void *raw_data)
|
||||
{
|
||||
(void) tif;
|
||||
|
||||
/* do not try to pretty print auto-defined fields */
|
||||
if (strncmp(fip->field_name,"Tag ", 4) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case TIFFTAG_INKSET:
|
||||
fprintf(fd, " Ink Set: ");
|
||||
switch (*((uint16*)raw_data)) {
|
||||
if (value_count == 2 && fip->field_type == TIFF_SHORT) {
|
||||
fprintf(fd, " Ink Set: ");
|
||||
switch (*((uint16*)raw_data)) {
|
||||
case INKSET_CMYK:
|
||||
fprintf(fd, "CMYK\n");
|
||||
break;
|
||||
default:
|
||||
fprintf(fd, "%u (0x%x)\n",
|
||||
*((uint16*)raw_data),
|
||||
*((uint16*)raw_data));
|
||||
*((uint16*)raw_data),
|
||||
*((uint16*)raw_data));
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
case TIFFTAG_DOTRANGE:
|
||||
fprintf(fd, " Dot Range: %u-%u\n",
|
||||
((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
|
||||
return 1;
|
||||
if (value_count == 2 && fip->field_type == TIFF_SHORT) {
|
||||
fprintf(fd, " Dot Range: %u-%u\n",
|
||||
((uint16*)raw_data)[0], ((uint16*)raw_data)[1]);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case TIFFTAG_WHITEPOINT:
|
||||
fprintf(fd, " White Point: %g-%g\n",
|
||||
((float *)raw_data)[0], ((float *)raw_data)[1]);
|
||||
return 1;
|
||||
if (value_count == 2 && fip->field_type == TIFF_RATIONAL) {
|
||||
fprintf(fd, " White Point: %g-%g\n",
|
||||
((float *)raw_data)[0], ((float *)raw_data)[1]);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
case TIFFTAG_XMLPACKET:
|
||||
{
|
||||
uint32 i;
|
||||
@ -182,19 +202,25 @@ _TIFFPrettyPrintField(TIFF* tif, FILE* fd, uint32 tag,
|
||||
" RichTIFFIPTC Data: <present>, %lu bytes\n",
|
||||
(unsigned long) value_count * 4);
|
||||
return 1;
|
||||
|
||||
case TIFFTAG_PHOTOSHOP:
|
||||
fprintf(fd, " Photoshop Data: <present>, %lu bytes\n",
|
||||
(unsigned long) value_count);
|
||||
return 1;
|
||||
|
||||
case TIFFTAG_ICCPROFILE:
|
||||
fprintf(fd, " ICC Profile: <present>, %lu bytes\n",
|
||||
(unsigned long) value_count);
|
||||
return 1;
|
||||
|
||||
case TIFFTAG_STONITS:
|
||||
fprintf(fd,
|
||||
" Sample to Nits conversion factor: %.4e\n",
|
||||
*((double*)raw_data));
|
||||
return 1;
|
||||
if (value_count == 1 && fip->field_type == TIFF_DOUBLE) {
|
||||
fprintf(fd,
|
||||
" Sample to Nits conversion factor: %.4e\n",
|
||||
*((double*)raw_data));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -364,9 +390,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
fprintf(fd, " Ink Names: ");
|
||||
i = td->td_samplesperpixel;
|
||||
sep = "";
|
||||
for (cp = td->td_inknames; i > 0; cp = strchr(cp,'\0')+1, i--) {
|
||||
for (cp = td->td_inknames;
|
||||
i > 0 && cp < td->td_inknames + td->td_inknameslen;
|
||||
cp = strchr(cp,'\0')+1, i--) {
|
||||
int max_chars =
|
||||
td->td_inknameslen - (cp - td->td_inknames);
|
||||
fputs(sep, fd);
|
||||
_TIFFprintAscii(fd, cp);
|
||||
_TIFFprintAsciiBounded(fd, cp, max_chars);
|
||||
sep = ", ";
|
||||
}
|
||||
fputs("\n", fd);
|
||||
@ -449,14 +479,16 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE))
|
||||
fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue);
|
||||
if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) {
|
||||
int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
|
||||
fprintf(fd, " SMin Sample Value:");
|
||||
for (i = 0; i < td->td_samplesperpixel; ++i)
|
||||
for (i = 0; i < count; ++i)
|
||||
fprintf(fd, " %g", td->td_sminsamplevalue[i]);
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) {
|
||||
int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
|
||||
fprintf(fd, " SMax Sample Value:");
|
||||
for (i = 0; i < td->td_samplesperpixel; ++i)
|
||||
for (i = 0; i < count; ++i)
|
||||
fprintf(fd, " %g", td->td_smaxsamplevalue[i]);
|
||||
fprintf(fd, "\n");
|
||||
}
|
||||
@ -548,8 +580,19 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
continue;
|
||||
|
||||
if(fip->field_passcount) {
|
||||
if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
|
||||
if (fip->field_readcount == TIFF_VARIABLE2 ) {
|
||||
if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1)
|
||||
continue;
|
||||
} else if (fip->field_readcount == TIFF_VARIABLE2 ) {
|
||||
uint16 small_value_count;
|
||||
if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1)
|
||||
continue;
|
||||
value_count = small_value_count;
|
||||
} else {
|
||||
assert (fip->field_readcount == TIFF_VARIABLE
|
||||
|| fip->field_readcount == TIFF_VARIABLE2);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (fip->field_readcount == TIFF_VARIABLE
|
||||
|| fip->field_readcount == TIFF_VARIABLE2)
|
||||
@ -558,21 +601,23 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
value_count = td->td_samplesperpixel;
|
||||
else
|
||||
value_count = fip->field_readcount;
|
||||
if ((fip->field_type == TIFF_ASCII
|
||||
|| fip->field_readcount == TIFF_VARIABLE
|
||||
|| fip->field_readcount == TIFF_VARIABLE2
|
||||
|| fip->field_readcount == TIFF_SPP
|
||||
|| value_count > 1)
|
||||
&& fip->field_tag != TIFFTAG_PAGENUMBER
|
||||
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
|
||||
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
|
||||
&& fip->field_tag != TIFFTAG_DOTRANGE) {
|
||||
if (fip->field_tag == TIFFTAG_DOTRANGE
|
||||
&& strcmp(fip->field_name,"DotRange") == 0) {
|
||||
/* TODO: This is an evil exception and should not have been
|
||||
handled this way ... likely best if we move it into
|
||||
the directory structure with an explicit field in
|
||||
libtiff 4.1 and assign it a FIELD_ value */
|
||||
static uint16 dotrange[2];
|
||||
raw_data = dotrange;
|
||||
TIFFGetField(tif, tag, dotrange+0, dotrange+1);
|
||||
} else if (fip->field_type == TIFF_ASCII
|
||||
|| fip->field_readcount == TIFF_VARIABLE
|
||||
|| fip->field_readcount == TIFF_VARIABLE2
|
||||
|| fip->field_readcount == TIFF_SPP
|
||||
|| value_count > 1) {
|
||||
if(TIFFGetField(tif, tag, &raw_data) != 1)
|
||||
continue;
|
||||
} else if (fip->field_tag != TIFFTAG_PAGENUMBER
|
||||
&& fip->field_tag != TIFFTAG_HALFTONEHINTS
|
||||
&& fip->field_tag != TIFFTAG_YCBCRSUBSAMPLING
|
||||
&& fip->field_tag != TIFFTAG_DOTRANGE) {
|
||||
} else {
|
||||
raw_data = _TIFFmalloc(
|
||||
_TIFFDataSize(fip->field_type)
|
||||
* value_count);
|
||||
@ -581,26 +626,6 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
_TIFFfree(raw_data);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* XXX: Should be fixed and removed,
|
||||
* see the notes related to
|
||||
* TIFFTAG_PAGENUMBER,
|
||||
* TIFFTAG_HALFTONEHINTS,
|
||||
* TIFFTAG_YCBCRSUBSAMPLING and
|
||||
* TIFFTAG_DOTRANGE tags in tif_dir.c.
|
||||
*/
|
||||
char *tmp;
|
||||
raw_data = _TIFFmalloc(
|
||||
_TIFFDataSize(fip->field_type)
|
||||
* value_count);
|
||||
tmp = raw_data;
|
||||
mem_alloc = 1;
|
||||
if(TIFFGetField(tif, tag, tmp,
|
||||
tmp + _TIFFDataSize(fip->field_type)) != 1) {
|
||||
_TIFFfree(raw_data);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -610,7 +635,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
* _TIFFPrettyPrintField() fall down and print it as
|
||||
* any other tag.
|
||||
*/
|
||||
if (!_TIFFPrettyPrintField(tif, fd, tag, value_count, raw_data))
|
||||
if (!_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, raw_data))
|
||||
_TIFFPrintField(fd, fip, value_count, raw_data);
|
||||
|
||||
if(mem_alloc)
|
||||
@ -648,7 +673,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
|
||||
void
|
||||
_TIFFprintAscii(FILE* fd, const char* cp)
|
||||
{
|
||||
for (; *cp != '\0'; cp++) {
|
||||
_TIFFprintAsciiBounded( fd, cp, strlen(cp));
|
||||
}
|
||||
|
||||
static void
|
||||
_TIFFprintAsciiBounded(FILE* fd, const char* cp, int max_chars)
|
||||
{
|
||||
for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) {
|
||||
const char* tp;
|
||||
|
||||
if (isprint((int)*cp)) {
|
||||
|
41
3rdparty/libtiff/tif_read.c
vendored
41
3rdparty/libtiff/tif_read.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_read.c,v 1.38 2011-12-09 03:29:10 fwarmerdam Exp $ */
|
||||
/* $Id: tif_read.c,v 1.40 2012-06-01 00:55:09 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -93,6 +93,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
|
||||
|
||||
if( unused_data > 0 )
|
||||
{
|
||||
assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
|
||||
memmove( tif->tif_rawdata, tif->tif_rawcp, unused_data );
|
||||
}
|
||||
|
||||
@ -120,6 +121,7 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
|
||||
- tif->tif_rawdataoff - tif->tif_rawdataloaded;
|
||||
}
|
||||
|
||||
assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
|
||||
cc = TIFFReadFile(tif, tif->tif_rawdata + unused_data, to_read);
|
||||
|
||||
if (cc != to_read) {
|
||||
@ -145,8 +147,10 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
|
||||
tif->tif_rawcp = tif->tif_rawdata;
|
||||
|
||||
if (!isFillOrder(tif, td->td_fillorder) &&
|
||||
(tif->tif_flags & TIFF_NOBITREV) == 0)
|
||||
(tif->tif_flags & TIFF_NOBITREV) == 0) {
|
||||
assert((tif->tif_flags&TIFF_BUFFERMMAP)==0);
|
||||
TIFFReverseBits(tif->tif_rawdata + unused_data, to_read );
|
||||
}
|
||||
|
||||
/*
|
||||
** When starting a strip from the beginning we need to
|
||||
@ -522,8 +526,11 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
* buffer (if they try to, the application will get a
|
||||
* fault since the file is mapped read-only).
|
||||
*/
|
||||
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
|
||||
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
|
||||
_TIFFfree(tif->tif_rawdata);
|
||||
tif->tif_rawdata = NULL;
|
||||
tif->tif_rawdatasize = 0;
|
||||
}
|
||||
tif->tif_flags &= ~TIFF_MYBUFFER;
|
||||
/*
|
||||
* We must check for overflow, potentially causing
|
||||
@ -565,6 +572,14 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
tif->tif_rawdata = tif->tif_base + (tmsize_t)td->td_stripoffset[strip];
|
||||
tif->tif_rawdataoff = 0;
|
||||
tif->tif_rawdataloaded = (tmsize_t) bytecount;
|
||||
|
||||
/*
|
||||
* When we have tif_rawdata reference directly into the memory mapped file
|
||||
* we need to be pretty careful about how we use the rawdata. It is not
|
||||
* a general purpose working buffer as it normally otherwise is. So we
|
||||
* keep track of this fact to avoid using it improperly.
|
||||
*/
|
||||
tif->tif_flags |= TIFF_BUFFERMMAP;
|
||||
} else {
|
||||
/*
|
||||
* Expand raw data buffer, if needed, to hold data
|
||||
@ -589,6 +604,11 @@ TIFFFillStrip(TIFF* tif, uint32 strip)
|
||||
if (!TIFFReadBufferSetup(tif, 0, bytecountm))
|
||||
return (0);
|
||||
}
|
||||
if (tif->tif_flags&TIFF_BUFFERMMAP) {
|
||||
tif->tif_curstrip = NOSTRIP;
|
||||
if (!TIFFReadBufferSetup(tif, 0, bytecountm))
|
||||
return (0);
|
||||
}
|
||||
if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata,
|
||||
bytecountm, module) != bytecountm)
|
||||
return (0);
|
||||
@ -809,8 +829,11 @@ TIFFFillTile(TIFF* tif, uint32 tile)
|
||||
* buffer (if they try to, the application will get a
|
||||
* fault since the file is mapped read-only).
|
||||
*/
|
||||
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata)
|
||||
if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
|
||||
_TIFFfree(tif->tif_rawdata);
|
||||
tif->tif_rawdata = NULL;
|
||||
tif->tif_rawdatasize = 0;
|
||||
}
|
||||
tif->tif_flags &= ~TIFF_MYBUFFER;
|
||||
/*
|
||||
* We must check for overflow, potentially causing
|
||||
@ -831,6 +854,7 @@ TIFFFillTile(TIFF* tif, uint32 tile)
|
||||
tif->tif_base + (tmsize_t)td->td_stripoffset[tile];
|
||||
tif->tif_rawdataoff = 0;
|
||||
tif->tif_rawdataloaded = (tmsize_t) bytecount;
|
||||
tif->tif_flags |= TIFF_BUFFERMMAP;
|
||||
} else {
|
||||
/*
|
||||
* Expand raw data buffer, if needed, to hold data
|
||||
@ -855,6 +879,12 @@ TIFFFillTile(TIFF* tif, uint32 tile)
|
||||
if (!TIFFReadBufferSetup(tif, 0, bytecountm))
|
||||
return (0);
|
||||
}
|
||||
if (tif->tif_flags&TIFF_BUFFERMMAP) {
|
||||
tif->tif_curtile = NOTILE;
|
||||
if (!TIFFReadBufferSetup(tif, 0, bytecountm))
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata,
|
||||
bytecountm, module) != bytecountm)
|
||||
return (0);
|
||||
@ -886,10 +916,13 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
|
||||
static const char module[] = "TIFFReadBufferSetup";
|
||||
|
||||
assert((tif->tif_flags&TIFF_NOREADRAW)==0);
|
||||
tif->tif_flags &= ~TIFF_BUFFERMMAP;
|
||||
|
||||
if (tif->tif_rawdata) {
|
||||
if (tif->tif_flags & TIFF_MYBUFFER)
|
||||
_TIFFfree(tif->tif_rawdata);
|
||||
tif->tif_rawdata = NULL;
|
||||
tif->tif_rawdatasize = 0;
|
||||
}
|
||||
if (bp) {
|
||||
tif->tif_rawdatasize = size;
|
||||
|
10
3rdparty/libtiff/tif_strip.c
vendored
10
3rdparty/libtiff/tif_strip.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_strip.c,v 1.34 2011-04-02 20:54:09 bfriesen Exp $ */
|
||||
/* $Id: tif_strip.c,v 1.35 2012-06-06 05:33:55 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@ -107,11 +107,13 @@ TIFFVStripSize64(TIFF* tif, uint32 nrows)
|
||||
}
|
||||
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
|
||||
ycbcrsubsampling+1);
|
||||
if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) ||
|
||||
((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4)))
|
||||
if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
|
||||
||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid YCbCr subsampling");
|
||||
"Invalid YCbCr subsampling (%dx%d)",
|
||||
ycbcrsubsampling[0],
|
||||
ycbcrsubsampling[1] );
|
||||
return 0;
|
||||
}
|
||||
samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
|
||||
|
11
3rdparty/libtiff/tif_tile.c
vendored
11
3rdparty/libtiff/tif_tile.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_tile.c,v 1.22 2010-07-01 15:33:28 dron Exp $ */
|
||||
/* $Id: tif_tile.c,v 1.23 2012-06-06 05:33:55 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991-1997 Sam Leffler
|
||||
@ -203,12 +203,13 @@ TIFFVTileSize64(TIFF* tif, uint32 nrows)
|
||||
uint64 samplingrow_size;
|
||||
TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0,
|
||||
ycbcrsubsampling+1);
|
||||
assert((ycbcrsubsampling[0]==1)||(ycbcrsubsampling[0]==2)||(ycbcrsubsampling[0]==4));
|
||||
assert((ycbcrsubsampling[1]==1)||(ycbcrsubsampling[1]==2)||(ycbcrsubsampling[1]==4));
|
||||
if (ycbcrsubsampling[0]*ycbcrsubsampling[1]==0)
|
||||
if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4)
|
||||
||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4))
|
||||
{
|
||||
TIFFErrorExt(tif->tif_clientdata,module,
|
||||
"Invalid YCbCr subsampling");
|
||||
"Invalid YCbCr subsampling (%dx%d)",
|
||||
ycbcrsubsampling[0],
|
||||
ycbcrsubsampling[1] );
|
||||
return 0;
|
||||
}
|
||||
samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2;
|
||||
|
8
3rdparty/libtiff/tif_unix.c
vendored
8
3rdparty/libtiff/tif_unix.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tif_unix.c,v 1.22 2010-03-10 18:56:49 bfriesen Exp $ */
|
||||
/* $Id: tif_unix.c,v 1.23 2012-06-01 21:40:59 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -186,7 +186,11 @@ TIFFOpen(const char* name, const char* mode)
|
||||
|
||||
fd = open(name, m, 0666);
|
||||
if (fd < 0) {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
if (errno > 0 && strerror(errno) != NULL ) {
|
||||
TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) );
|
||||
} else {
|
||||
TIFFErrorExt(0, module, "%s: Cannot open", name);
|
||||
}
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
|
||||
|
5
3rdparty/libtiff/tiffio.h
vendored
5
3rdparty/libtiff/tiffio.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tiffio.h,v 1.89 2012-02-18 16:20:26 bfriesen Exp $ */
|
||||
/* $Id: tiffio.h,v 1.90 2012-06-06 04:58:00 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -392,6 +392,8 @@ extern int TIFFSetupStrips(TIFF *);
|
||||
extern int TIFFWriteCheck(TIFF*, int, const char *);
|
||||
extern void TIFFFreeDirectory(TIFF*);
|
||||
extern int TIFFCreateDirectory(TIFF*);
|
||||
extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*);
|
||||
extern int TIFFCreateEXIFDirectory(TIFF*);
|
||||
extern int TIFFLastDirectory(TIFF*);
|
||||
extern int TIFFSetDirectory(TIFF*, uint16);
|
||||
extern int TIFFSetSubDirectory(TIFF*, uint64);
|
||||
@ -400,6 +402,7 @@ extern int TIFFSetField(TIFF*, uint32, ...);
|
||||
extern int TIFFVSetField(TIFF*, uint32, va_list);
|
||||
extern int TIFFUnsetField(TIFF*, uint32);
|
||||
extern int TIFFWriteDirectory(TIFF *);
|
||||
extern int TIFFWriteCustomDirectory(TIFF *, uint64 *);
|
||||
extern int TIFFCheckpointDirectory(TIFF *);
|
||||
extern int TIFFRewriteDirectory(TIFF *);
|
||||
|
||||
|
5
3rdparty/libtiff/tiffiop.h
vendored
5
3rdparty/libtiff/tiffiop.h
vendored
@ -1,4 +1,4 @@
|
||||
/* $Id: tiffiop.h,v 1.82 2011-02-18 20:53:05 fwarmerdam Exp $ */
|
||||
/* $Id: tiffiop.h,v 1.84 2012-05-30 01:50:17 fwarmerdam Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -121,6 +121,7 @@ struct tiff {
|
||||
#define TIFF_BUF4WRITE 0x100000 /* rawcc bytes are for writing */
|
||||
#define TIFF_DIRTYSTRIP 0x200000 /* stripoffsets/stripbytecount dirty*/
|
||||
#define TIFF_PERSAMPLE 0x400000 /* get/set per sample tags as arrays */
|
||||
#define TIFF_BUFFERMMAP 0x800000 /* read buffer (tif_rawdata) points into mmap() memory */
|
||||
uint64 tif_diroff; /* file offset of current directory */
|
||||
uint64 tif_nextdiroff; /* file offset of following directory */
|
||||
uint64* tif_dirlist; /* list of offsets to already seen directories to prevent IFD looping */
|
||||
@ -250,7 +251,7 @@ struct tiff {
|
||||
#define TIFFroundup_64(x, y) (TIFFhowmany_64(x,y)*(y))
|
||||
|
||||
/* Safe multiply which returns zero if there is an integer overflow */
|
||||
#define TIFFSafeMultiply(t,v,m) ((((t)m != (t)0) && (((t)((v*m)/m)) == (t)v)) ? (t)(v*m) : (t)0)
|
||||
#define TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0)
|
||||
|
||||
#define TIFFmax(A,B) ((A)>(B)?(A):(B))
|
||||
#define TIFFmin(A,B) ((A)<(B)?(A):(B))
|
||||
|
4
3rdparty/libtiff/tiffvers.h
vendored
4
3rdparty/libtiff/tiffvers.h
vendored
@ -1,4 +1,4 @@
|
||||
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
|
||||
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.2\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
|
||||
/*
|
||||
* This define can be used in code that requires
|
||||
* compilation-related definitions specific to a
|
||||
@ -6,4 +6,4 @@
|
||||
* version checking should be done based on the
|
||||
* string returned by TIFFGetVersion.
|
||||
*/
|
||||
#define TIFFLIB_VERSION 20120218
|
||||
#define TIFFLIB_VERSION 20120615
|
||||
|
Loading…
Reference in New Issue
Block a user