| Index: third_party/libtiff/tif_ojpeg.c
|
| diff --git a/third_party/tiff_v403/tif_ojpeg.c b/third_party/libtiff/tif_ojpeg.c
|
| similarity index 97%
|
| rename from third_party/tiff_v403/tif_ojpeg.c
|
| rename to third_party/libtiff/tif_ojpeg.c
|
| index 0a774a526ea808f01092f2c639a0228792e33b87..cc5449cd656c69ffa60a6f24f1ae42c5867966eb 100644
|
| --- a/third_party/tiff_v403/tif_ojpeg.c
|
| +++ b/third_party/libtiff/tif_ojpeg.c
|
| @@ -1,4 +1,4 @@
|
| -/* $Id: tif_ojpeg.c,v 1.56 2012-05-24 03:15:18 fwarmerdam Exp $ */
|
| +/* $Id: tif_ojpeg.c,v 1.60 2015-05-31 00:38:46 bfriesen 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
|
| @@ -39,7 +39,7 @@
|
| OF THIS SOFTWARE.
|
|
|
| Joris Van Damme and/or AWare Systems may be available for custom
|
| - developement. If you like what you see, and need anything similar or related,
|
| + development. If you like what you see, and need anything similar or related,
|
| contact <info@awaresystems.be>.
|
| */
|
|
|
| @@ -120,7 +120,6 @@
|
| session.
|
| */
|
|
|
| -
|
| #define WIN32_LEAN_AND_MEAN
|
| #define VC_EXTRALEAN
|
|
|
| @@ -142,7 +141,7 @@
|
| * OJPEG_BUFFER: Define the size of the desired buffer here. Should be small enough so as to guarantee
|
| * instant processing, optimal streaming and optimal use of processor cache, but also big
|
| * enough so as to not result in significant call overhead. It should be at least a few
|
| - * bytes to accomodate some structures (this is verified in asserts), but it would not be
|
| + * bytes to accommodate some structures (this is verified in asserts), but it would not be
|
| * sensible to make it this small anyway, and it should be at most 64K since it is indexed
|
| * with uint16. We recommend 2K.
|
| * EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has
|
| @@ -216,13 +215,17 @@ static const TIFFField ojpegFields[] = {
|
| #endif
|
|
|
| #if defined(USE_SYSTEM_LIBJPEG)
|
| +#include <jerror.h>
|
| #include <jpeglib.h>
|
| #elif defined(USE_LIBJPEG_TURBO)
|
| +#include "third_party/libjpeg_turbo/jerror.h"
|
| #include "third_party/libjpeg_turbo/jpeglib.h"
|
| #else
|
| +#include "third_party/libjpeg/jerror.h"
|
| #include "third_party/libjpeg/jpeglib.h"
|
| #endif
|
|
|
| +
|
| typedef struct jpeg_error_mgr jpeg_error_mgr;
|
| typedef struct jpeg_common_struct jpeg_common_struct;
|
| typedef struct jpeg_decompress_struct jpeg_decompress_struct;
|
| @@ -439,8 +442,8 @@ TIFFInitOJPEG(TIFF* tif, int scheme)
|
| }
|
|
|
| /* state block */
|
| - sp = (OJPEGState*)_TIFFmalloc(sizeof(OJPEGState)); // // add (OJPEGState*) cast
|
| - if (sp == NULL)
|
| + sp=_TIFFmalloc(sizeof(OJPEGState));
|
| + if (sp==NULL)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"No space for OJPEG state block");
|
| return(0);
|
| @@ -534,6 +537,8 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap)
|
| uint32 ma;
|
| uint64* mb;
|
| uint32 n;
|
| + const TIFFField* fip;
|
| +
|
| switch(tag)
|
| {
|
| case TIFFTAG_JPEGIFOFFSET:
|
| @@ -603,7 +608,10 @@ OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap)
|
| default:
|
| return (*sp->vsetparent)(tif,tag,ap);
|
| }
|
| - TIFFSetFieldBit(tif,TIFFFieldWithTag(tif,tag)->field_bit);
|
| + fip = TIFFFieldWithTag(tif,tag);
|
| + if( fip == NULL ) /* shouldn't happen */
|
| + return(0);
|
| + TIFFSetFieldBit(tif,fip->field_bit);
|
| tif->tif_flags|=TIFF_DIRTYDIRECT;
|
| return(1);
|
| }
|
| @@ -767,9 +775,8 @@ OJPEGPreDecodeSkipScanlines(TIFF* tif)
|
| uint32 m;
|
| if (sp->skip_buffer==NULL)
|
| {
|
| - // add (uint8*) cast
|
| - sp->skip_buffer = (uint8*)_TIFFmalloc(sp->bytes_per_line);
|
| - if (sp->skip_buffer == NULL)
|
| + sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line);
|
| + if (sp->skip_buffer==NULL)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
| return(0);
|
| @@ -1193,7 +1200,7 @@ OJPEGWriteHeaderInfo(TIFF* tif)
|
| sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines;
|
| sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines;
|
| sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuflen;
|
| - sp->subsampling_convert_ycbcrbuf = (uint8*)_TIFFmalloc(sp->subsampling_convert_ycbcrbuflen); // add (uint8*) cast
|
| + sp->subsampling_convert_ycbcrbuf=_TIFFmalloc(sp->subsampling_convert_ycbcrbuflen);
|
| if (sp->subsampling_convert_ycbcrbuf==0)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
| @@ -1203,7 +1210,7 @@ OJPEGWriteHeaderInfo(TIFF* tif)
|
| sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen;
|
| sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen;
|
| sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_clines;
|
| - sp->subsampling_convert_ycbcrimage = (uint8**)_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen * sizeof(uint8*));// add (uint8**) cast
|
| + sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*));
|
| if (sp->subsampling_convert_ycbcrimage==0)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
| @@ -1430,9 +1437,9 @@ OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif)
|
| TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data");
|
| return(0);
|
| }
|
| - na = sizeof(uint32) + 69;
|
| - nb = (uint8*)_TIFFmalloc(na); // add (uint8*) cast
|
| - if (nb == 0)
|
| + na=sizeof(uint32)+69;
|
| + nb=_TIFFmalloc(na);
|
| + if (nb==0)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
| return(0);
|
| @@ -1487,9 +1494,9 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif)
|
| }
|
| else
|
| {
|
| - na = sizeof(uint32) + 2 + m;
|
| - nb = (uint8*)_TIFFmalloc(na); // add (uint8*) cast
|
| - if (nb == 0)
|
| + na=sizeof(uint32)+2+m;
|
| + nb=_TIFFmalloc(na);
|
| + if (nb==0)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
| return(0);
|
| @@ -1499,14 +1506,17 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif)
|
| nb[sizeof(uint32)+1]=JPEG_MARKER_DHT;
|
| nb[sizeof(uint32)+2]=(m>>8);
|
| nb[sizeof(uint32)+3]=(m&255);
|
| - if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0)
|
| + if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) {
|
| + _TIFFfree(nb);
|
| return(0);
|
| + }
|
| o=nb[sizeof(uint32)+4];
|
| if ((o&240)==0)
|
| {
|
| if (3<o)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
| + _TIFFfree(nb);
|
| return(0);
|
| }
|
| if (sp->dctable[o]!=0)
|
| @@ -1518,12 +1528,14 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif)
|
| if ((o&240)!=16)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
| + _TIFFfree(nb);
|
| return(0);
|
| }
|
| o&=15;
|
| if (3<o)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
| + _TIFFfree(nb);
|
| return(0);
|
| }
|
| if (sp->actable[o]!=0)
|
| @@ -1763,7 +1775,7 @@ OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif)
|
| }
|
| }
|
| oa=sizeof(uint32)+69;
|
| - ob = (uint8*)_TIFFmalloc(oa); // add (uint8*) cast
|
| + ob=_TIFFmalloc(oa);
|
| if (ob==0)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
| @@ -1776,7 +1788,7 @@ OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif)
|
| ob[sizeof(uint32)+3]=67;
|
| ob[sizeof(uint32)+4]=m;
|
| TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET);
|
| - p=(uint32)TIFFReadFile(tif,&ob[sizeof(uint32)+5],64);
|
| + p=TIFFReadFile(tif,&ob[sizeof(uint32)+5],64);
|
| if (p!=64)
|
| return(0);
|
| sp->qtable[m]=ob;
|
| @@ -1819,14 +1831,14 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif)
|
| }
|
| }
|
| TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET);
|
| - p=(uint32)TIFFReadFile(tif,o,16);
|
| + p=TIFFReadFile(tif,o,16);
|
| if (p!=16)
|
| return(0);
|
| q=0;
|
| for (n=0; n<16; n++)
|
| q+=o[n];
|
| ra=sizeof(uint32)+21+q;
|
| - rb = (uint8*)_TIFFmalloc(ra); // add (uint8*) cast
|
| + rb=_TIFFmalloc(ra);
|
| if (rb==0)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
| @@ -1840,7 +1852,7 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif)
|
| rb[sizeof(uint32)+4]=m;
|
| for (n=0; n<16; n++)
|
| rb[sizeof(uint32)+5+n]=o[n];
|
| - p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
|
| + p=TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
|
| if (p!=q)
|
| return(0);
|
| sp->dctable[m]=rb;
|
| @@ -1883,14 +1895,14 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif)
|
| }
|
| }
|
| TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET);
|
| - p=(uint32)TIFFReadFile(tif,o,16);
|
| + p=TIFFReadFile(tif,o,16);
|
| if (p!=16)
|
| return(0);
|
| q=0;
|
| for (n=0; n<16; n++)
|
| q+=o[n];
|
| ra=sizeof(uint32)+21+q;
|
| - rb = (uint8*)_TIFFmalloc(ra); // add (uint8*) cast
|
| + rb=_TIFFmalloc(ra);
|
| if (rb==0)
|
| {
|
| TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
|
| @@ -1904,7 +1916,7 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif)
|
| rb[sizeof(uint32)+4]=(16|m);
|
| for (n=0; n<16; n++)
|
| rb[sizeof(uint32)+5+n]=o[n];
|
| - p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
|
| + p=TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
|
| if (p!=q)
|
| return(0);
|
| sp->actable[m]=rb;
|
| @@ -1962,6 +1974,7 @@ OJPEGReadBufferFill(OJPEGState* sp)
|
| break;
|
| case osibsJpegInterchangeFormat:
|
| sp->in_buffer_source=osibsStrile;
|
| + break;
|
| case osibsStrile:
|
| if (!_TIFFFillStriles( sp->tif )
|
| || sp->tif->tif_dir.td_stripoffset == NULL
|
| @@ -2059,7 +2072,7 @@ OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem)
|
| uint16 n;
|
| assert(len>0);
|
| mlen=len;
|
| - mmem = (uint8*)mem; // add (uint8*) cast
|
| + mmem=mem;
|
| do
|
| {
|
| if (sp->in_buffer_togo==0)
|
| @@ -2461,8 +2474,8 @@ OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo)
|
| TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Premature end of JPEG data");
|
| jpeg_encap_unwind(tif);
|
| }
|
| - sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = len;
|
| - sp->libjpeg_jpeg_source_mgr.next_input_byte = (const JOCTET * )mem; // add (const JOCTET * ) cast
|
| + sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=len;
|
| + sp->libjpeg_jpeg_source_mgr.next_input_byte=mem;
|
| return(1);
|
| }
|
|
|
| @@ -2501,4 +2514,3 @@ OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo)
|
| * fill-column: 78
|
| * End:
|
| */
|
| -
|
|
|