summaryrefslogtreecommitdiff
path: root/third_party/libtiff/tif_ojpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libtiff/tif_ojpeg.c')
-rw-r--r--third_party/libtiff/tif_ojpeg.c79
1 files changed, 56 insertions, 23 deletions
diff --git a/third_party/libtiff/tif_ojpeg.c b/third_party/libtiff/tif_ojpeg.c
index 276d562dfb..e128887bf6 100644
--- a/third_party/libtiff/tif_ojpeg.c
+++ b/third_party/libtiff/tif_ojpeg.c
@@ -1,4 +1,4 @@
-/* $Id: tif_ojpeg.c,v 1.60 2015-05-31 00:38:46 bfriesen Exp $ */
+/* $Id: tif_ojpeg.c,v 1.65 2016-09-04 21:32:56 erouault 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
@@ -75,7 +75,7 @@
OJPEGSubsamplingCorrect, making no note of any other data, reporting no warnings
or errors, up to the point where either these values are read, or it's clear they
aren't there. This means that some of the data is read twice, but we feel speed
- in correcting these values is important enough to warrant this sacrifice. Allthough
+ in correcting these values is important enough to warrant this sacrifice. Although
there is currently no define or other configuration mechanism to disable this behaviour,
the actual header scanning is build to robustly respond with error report if it
should encounter an uncorrected mismatch of subsampling values. See
@@ -84,7 +84,7 @@
The restart interval and restart markers are the most tricky part... The restart
interval can be specified in a tag. It can also be set inside the input JPEG stream.
It can be used inside the input JPEG stream. If reading from strile data, we've
- consistenly discovered the need to insert restart markers in between the different
+ consistently discovered the need to insert restart markers in between the different
striles, as is also probably the most likely interpretation of the original TIFF 6.0
specification. With all this setting of interval, and actual use of markers that is not
predictable at the time of valid JPEG header assembly, the restart thing may turn
@@ -113,7 +113,7 @@
planarconfig is not separate (vast majority). We may one day use that to build
converters to JPEG, and/or to new-style JPEG compression inside TIFF.
- A dissadvantage is the lack of random access to the individual striles. This is the
+ A disadvantage is the lack of random access to the individual striles. This is the
reason for much of the complicated restart-and-position stuff inside OJPEGPreDecode.
Applications would do well accessing all striles in order, as this will result in
a single sequential scan of the input stream, and no restarting of LibJpeg decoding
@@ -135,7 +135,7 @@
* The default mode, without JPEG_ENCAP_EXTERNAL, implements the call encapsulators
* here, internally, with normal longjump.
* SETJMP, LONGJMP, JMP_BUF: On some machines/environments a longjump equivalent is
- * conviniently available, but still it may be worthwhile to use _setjmp or sigsetjmp
+ * conveniently available, but still it may be worthwhile to use _setjmp or sigsetjmp
* in place of plain setjmp. These macros will make it easier. It is useless
* to fiddle with these if you define JPEG_ENCAP_EXTERNAL.
* OJPEG_BUFFER: Define the size of the desired buffer here. Should be small enough so as to guarantee
@@ -200,7 +200,7 @@ static const TIFFField ojpegFields[] = {
Libjpeg's jmorecfg.h defines INT16 and INT32, but only if XMD_H is
not defined. Unfortunately, the MinGW and Borland compilers include
a typedef for INT32, which causes a conflict. MSVC does not include
- a conficting typedef given the headers which are included.
+ a conflicting typedef given the headers which are included.
*/
#if defined(__BORLANDC__) || defined(__MINGW32__)
# define XMD_H 1
@@ -1090,7 +1090,7 @@ OJPEGReadHeaderInfo(TIFF* tif)
TIFFErrorExt(tif->tif_clientdata,module,"Incompatible vertical subsampling and image strip/tile length");
return(0);
}
- sp->restart_interval=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))*(sp->strile_length/(sp->subsampling_ver*8));
+ sp->restart_interval=(uint16)(((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))*(sp->strile_length/(sp->subsampling_ver*8)));
}
if (OJPEGReadHeaderInfoSec(tif)==0)
return(0);
@@ -1112,7 +1112,7 @@ OJPEGReadSecondarySos(TIFF* tif, uint16 s)
assert(s<3);
assert(sp->sos_end[0].log!=0);
assert(sp->sos_end[s].log==0);
- sp->plane_sample_offset=s-1;
+ sp->plane_sample_offset=(uint8)(s-1);
while(sp->sos_end[sp->plane_sample_offset].log==0)
sp->plane_sample_offset--;
sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source;
@@ -1390,7 +1390,8 @@ OJPEGReadHeaderInfoSec(TIFF* tif)
static int
OJPEGReadHeaderInfoSecStreamDri(TIFF* tif)
{
- /* this could easilly cause trouble in some cases... but no such cases have occured sofar */
+ /* This could easily cause trouble in some cases... but no such cases have
+ occurred so far */
static const char module[]="OJPEGReadHeaderInfoSecStreamDri";
OJPEGState* sp=(OJPEGState*)tif->tif_data;
uint16 m;
@@ -1788,7 +1789,7 @@ OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif)
ob[sizeof(uint32)+3]=67;
ob[sizeof(uint32)+4]=m;
TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET);
- p=TIFFReadFile(tif,&ob[sizeof(uint32)+5],64);
+ p=(uint32)TIFFReadFile(tif,&ob[sizeof(uint32)+5],64);
if (p!=64)
{
_TIFFfree(ob);
@@ -1836,7 +1837,7 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif)
}
}
TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET);
- p=TIFFReadFile(tif,o,16);
+ p=(uint32)TIFFReadFile(tif,o,16);
if (p!=16)
return(0);
q=0;
@@ -1852,12 +1853,12 @@ OJPEGReadHeaderInfoSecTablesDcTable(TIFF* tif)
*(uint32*)rb=ra;
rb[sizeof(uint32)]=255;
rb[sizeof(uint32)+1]=JPEG_MARKER_DHT;
- rb[sizeof(uint32)+2]=((19+q)>>8);
+ rb[sizeof(uint32)+2]=(uint8)((19+q)>>8);
rb[sizeof(uint32)+3]=((19+q)&255);
rb[sizeof(uint32)+4]=m;
for (n=0; n<16; n++)
rb[sizeof(uint32)+5+n]=o[n];
- p=TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
+ p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
if (p!=q)
{
_TIFFfree(rb);
@@ -1905,7 +1906,7 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif)
}
}
TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET);
- p=TIFFReadFile(tif,o,16);
+ p=(uint32)TIFFReadFile(tif,o,16);
if (p!=16)
return(0);
q=0;
@@ -1921,12 +1922,12 @@ OJPEGReadHeaderInfoSecTablesAcTable(TIFF* tif)
*(uint32*)rb=ra;
rb[sizeof(uint32)]=255;
rb[sizeof(uint32)+1]=JPEG_MARKER_DHT;
- rb[sizeof(uint32)+2]=((19+q)>>8);
+ rb[sizeof(uint32)+2]=(uint8)((19+q)>>8);
rb[sizeof(uint32)+3]=((19+q)&255);
rb[sizeof(uint32)+4]=(16|m);
for (n=0; n<16; n++)
rb[sizeof(uint32)+5+n]=o[n];
- p=TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
+ p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q);
if (p!=q)
{
_TIFFfree(rb);
@@ -2293,10 +2294,10 @@ OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len)
/* P */
sp->out_buffer[4]=8;
/* Y */
- sp->out_buffer[5]=(sp->sof_y>>8);
+ sp->out_buffer[5]=(uint8)(sp->sof_y>>8);
sp->out_buffer[6]=(sp->sof_y&255);
/* X */
- sp->out_buffer[7]=(sp->sof_x>>8);
+ sp->out_buffer[7]=(uint8)(sp->sof_x>>8);
sp->out_buffer[8]=(sp->sof_x&255);
/* Nf */
sp->out_buffer[9]=sp->samples_per_pixel_per_plane;
@@ -2409,7 +2410,12 @@ OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len)
static int
jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo)
{
- return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_create_decompress(cinfo),1));
+ if( SETJMP(sp->exit_jmpbuf) )
+ return 0;
+ else {
+ jpeg_create_decompress(cinfo);
+ return 1;
+ }
}
#endif
@@ -2417,7 +2423,12 @@ jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo)
static int
jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image)
{
- return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_header(cinfo,require_image),1));
+ if( SETJMP(sp->exit_jmpbuf) )
+ return 0;
+ else {
+ jpeg_read_header(cinfo,require_image);
+ return 1;
+ }
}
#endif
@@ -2425,7 +2436,12 @@ jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 requ
static int
jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo)
{
- return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_start_decompress(cinfo),1));
+ if( SETJMP(sp->exit_jmpbuf) )
+ return 0;
+ else {
+ jpeg_start_decompress(cinfo);
+ return 1;
+ }
}
#endif
@@ -2433,7 +2449,12 @@ jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo)
static int
jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines)
{
- return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_scanlines(cinfo,scanlines,max_lines),1));
+ if( SETJMP(sp->exit_jmpbuf) )
+ return 0;
+ else {
+ jpeg_read_scanlines(cinfo,scanlines,max_lines);
+ return 1;
+ }
}
#endif
@@ -2441,7 +2462,12 @@ jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* s
static int
jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines)
{
- return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_raw_data(cinfo,data,max_lines),1));
+ if( SETJMP(sp->exit_jmpbuf) )
+ return 0;
+ else {
+ jpeg_read_raw_data(cinfo,data,max_lines);
+ return 1;
+ }
}
#endif
@@ -2503,6 +2529,10 @@ OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_b
jpeg_encap_unwind(tif);
}
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable : 4702 ) /* unreachable code */
+#endif
static boolean
OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired)
{
@@ -2512,6 +2542,9 @@ OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desi
jpeg_encap_unwind(tif);
return(0);
}
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
static void
OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo)