Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: third_party/libtiff/tif_next.c

Issue 1563103002: XFA: Upgrade to libtiff 4.0.6. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rename to libtiff Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libtiff/tif_lzw.c ('k') | third_party/libtiff/tif_ojpeg.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* $Id: tif_next.c,v 1.13 2010-03-10 18:56:48 bfriesen Exp $ */ 1 /* $Id: tif_next.c,v 1.16 2014-12-29 12:09:11 erouault Exp $ */
2 2
3 /* 3 /*
4 * Copyright (c) 1988-1997 Sam Leffler 4 * Copyright (c) 1988-1997 Sam Leffler
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc. 5 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 * 6 *
7 * Permission to use, copy, modify, distribute, and sell this software and 7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided 8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in 9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the names of 10 * all copies of the software and related documentation, and (ii) the names of
11 * Sam Leffler and Silicon Graphics may not be used in any advertising or 11 * Sam Leffler and Silicon Graphics may not be used in any advertising or
12 * publicity relating to the software without the specific, prior written 12 * publicity relating to the software without the specific, prior written
13 * permission of Sam Leffler and Silicon Graphics. 13 * permission of Sam Leffler and Silicon Graphics.
14 * 14 *
15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 * 18 *
19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 * OF THIS SOFTWARE. 24 * OF THIS SOFTWARE.
25 */ 25 */
26
26 #include "tiffiop.h" 27 #include "tiffiop.h"
27 #ifdef NEXT_SUPPORT 28 #ifdef NEXT_SUPPORT
28 /* 29 /*
29 * TIFF Library. 30 * TIFF Library.
30 * 31 *
31 * NeXT 2-bit Grey Scale Compression Algorithm Support 32 * NeXT 2-bit Grey Scale Compression Algorithm Support
32 */ 33 */
33 34
34 #define SETPIXEL(op, v) { \ 35 #define SETPIXEL(op, v) { \
35 switch (npixels++ & 3) { \ 36 switch (npixels++ & 3) { \
(...skipping 27 matching lines...) Expand all
63 *op++ = 0xff; 64 *op++ = 0xff;
64 65
65 bp = (unsigned char *)tif->tif_rawcp; 66 bp = (unsigned char *)tif->tif_rawcp;
66 cc = tif->tif_rawcc; 67 cc = tif->tif_rawcc;
67 scanline = tif->tif_scanlinesize; 68 scanline = tif->tif_scanlinesize;
68 if (occ % scanline) 69 if (occ % scanline)
69 { 70 {
70 TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); 71 TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
71 return (0); 72 return (0);
72 } 73 }
73 » for (row = buf; occ > 0; occ -= scanline, row += scanline) { 74 » for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {
74 n = *bp++, cc--; 75 n = *bp++, cc--;
75 switch (n) { 76 switch (n) {
76 case LITERALROW: 77 case LITERALROW:
77 /* 78 /*
78 * The entire scanline is given as literal values. 79 * The entire scanline is given as literal values.
79 */ 80 */
80 if (cc < scanline) 81 if (cc < scanline)
81 goto bad; 82 goto bad;
82 _TIFFmemcpy(row, bp, scanline); 83 _TIFFmemcpy(row, bp, scanline);
83 bp += scanline; 84 bp += scanline;
84 cc -= scanline; 85 cc -= scanline;
85 break; 86 break;
86 case LITERALSPAN: { 87 case LITERALSPAN: {
87 tmsize_t off; 88 tmsize_t off;
88 /* 89 /*
89 * The scanline has a literal span that begins at some 90 * The scanline has a literal span that begins at some
90 * offset. 91 * offset.
91 */ 92 */
93 if( cc < 4 )
94 goto bad;
92 off = (bp[0] * 256) + bp[1]; 95 off = (bp[0] * 256) + bp[1];
93 n = (bp[2] * 256) + bp[3]; 96 n = (bp[2] * 256) + bp[3];
94 if (cc < 4+n || off+n > scanline) 97 if (cc < 4+n || off+n > scanline)
95 goto bad; 98 goto bad;
96 _TIFFmemcpy(row+off, bp+4, n); 99 _TIFFmemcpy(row+off, bp+4, n);
97 bp += 4+n; 100 bp += 4+n;
98 cc -= 4+n; 101 cc -= 4+n;
99 break; 102 break;
100 } 103 }
101 default: { 104 default: {
102 uint32 npixels = 0, grey; 105 uint32 npixels = 0, grey;
103 uint32 imagewidth = tif->tif_dir.td_imagewidth; 106 uint32 imagewidth = tif->tif_dir.td_imagewidth;
107 if( isTiled(tif) )
108 imagewidth = tif->tif_dir.td_tilewidth;
104 109
105 /* 110 /*
106 * The scanline is composed of a sequence of constant 111 * The scanline is composed of a sequence of constant
107 * color ``runs''. We shift into ``run mode'' and 112 * color ``runs''. We shift into ``run mode'' and
108 * interpret bytes as codes of the form 113 * interpret bytes as codes of the form
109 * <color><npixels> until we've filled the scanline. 114 * <color><npixels> until we've filled the scanline.
110 */ 115 */
111 op = row; 116 op = row;
112 for (;;) { 117 for (;;) {
113 grey = (uint32)((n>>6) & 0x3); 118 grey = (uint32)((n>>6) & 0x3);
(...skipping 17 matching lines...) Expand all
131 } 136 }
132 tif->tif_rawcp = (uint8*) bp; 137 tif->tif_rawcp = (uint8*) bp;
133 tif->tif_rawcc = cc; 138 tif->tif_rawcc = cc;
134 return (1); 139 return (1);
135 bad: 140 bad:
136 TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld", 141 TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld",
137 (long) tif->tif_row); 142 (long) tif->tif_row);
138 return (0); 143 return (0);
139 } 144 }
140 145
146 static int
147 NeXTPreDecode(TIFF* tif, uint16 s)
148 {
149 static const char module[] = "NeXTPreDecode";
150 TIFFDirectory *td = &tif->tif_dir;
151 (void)s;
152
153 if( td->td_bitspersample != 2 )
154 {
155 TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSa mple = %d",
156 td->td_bitspersample);
157 return (0);
158 }
159 return (1);
160 }
161
141 int 162 int
142 TIFFInitNeXT(TIFF* tif, int scheme) 163 TIFFInitNeXT(TIFF* tif, int scheme)
143 { 164 {
144 (void) scheme; 165 (void) scheme;
166 tif->tif_predecode = NeXTPreDecode;
145 tif->tif_decoderow = NeXTDecode; 167 tif->tif_decoderow = NeXTDecode;
146 tif->tif_decodestrip = NeXTDecode; 168 tif->tif_decodestrip = NeXTDecode;
147 tif->tif_decodetile = NeXTDecode; 169 tif->tif_decodetile = NeXTDecode;
148 return (1); 170 return (1);
149 } 171 }
150 #endif /* NEXT_SUPPORT */ 172 #endif /* NEXT_SUPPORT */
151 173
152 /* vim: set ts=8 sts=8 sw=8 noet: */ 174 /* vim: set ts=8 sts=8 sw=8 noet: */
153 /* 175 /*
154 * Local Variables: 176 * Local Variables:
155 * mode: c 177 * mode: c
156 * c-basic-offset: 8 178 * c-basic-offset: 8
157 * fill-column: 78 179 * fill-column: 78
158 * End: 180 * End:
159 */ 181 */
160
OLDNEW
« no previous file with comments | « third_party/libtiff/tif_lzw.c ('k') | third_party/libtiff/tif_ojpeg.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698