~ubuntu-branches/ubuntu/trusty/tiff/trusty

« back to all changes in this revision

Viewing changes to libtiff/tif_thunder.c

  • Committer: Package Import Robot
  • Author(s): Jay Berkenbilt
  • Date: 2012-06-24 13:45:42 UTC
  • mfrom: (15.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20120624134542-u7dltcqwnb6orprf
Tags: 4.0.2-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: tif_thunder.c,v 1.5.2.2 2011-03-21 16:01:28 fwarmerdam Exp $ */
 
1
/* $Id: tif_thunder.c,v 1.12 2011-04-02 20:54:09 bfriesen Exp $ */
2
2
 
3
3
/*
4
4
 * Copyright (c) 1988-1997 Sam Leffler
63
63
          if (npixels++ & 1)                  \
64
64
            *op++ |= lastpixel;               \
65
65
          else                                \
66
 
            op[0] = (tidataval_t) (lastpixel << 4); \
 
66
            op[0] = (uint8) (lastpixel << 4); \
67
67
        }                                     \
68
68
}
69
69
 
85
85
}
86
86
 
87
87
static int
88
 
ThunderDecode(TIFF* tif, tidata_t op, tsize_t maxpixels)
 
88
ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels)
89
89
{
 
90
        static const char module[] = "ThunderDecode";
90
91
        register unsigned char *bp;
91
 
        register tsize_t cc;
 
92
        register tmsize_t cc;
92
93
        unsigned int lastpixel;
93
 
        tsize_t npixels;
 
94
        tmsize_t npixels;
94
95
 
95
96
        bp = (unsigned char *)tif->tif_rawcp;
96
97
        cc = tif->tif_rawcc;
114
115
                        npixels += n;
115
116
                        if (npixels < maxpixels) {
116
117
                                for (; n > 0; n -= 2)
117
 
                                        *op++ = (tidataval_t) lastpixel;
 
118
                                        *op++ = (uint8) lastpixel;
118
119
                        }
119
120
                        if (n == -1)
120
121
                                *--op &= 0xf0;
139
140
                        break;
140
141
                }
141
142
        }
142
 
        tif->tif_rawcp = (tidata_t) bp;
 
143
        tif->tif_rawcp = (uint8*) bp;
143
144
        tif->tif_rawcc = cc;
144
145
        if (npixels != maxpixels) {
145
 
                TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
146
 
                    "ThunderDecode: %s data at scanline %ld (%lu != %lu)",
147
 
                    npixels < maxpixels ? "Not enough" : "Too much",
148
 
                    (long) tif->tif_row, (long) npixels, (long) maxpixels);
 
146
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
 
147
                TIFFErrorExt(tif->tif_clientdata, module,
 
148
                             "%s data at scanline %lu (%I64u != %I64u)",
 
149
                             npixels < maxpixels ? "Not enough" : "Too much",
 
150
                             (unsigned long) tif->tif_row,
 
151
                             (unsigned __int64) npixels,
 
152
                             (unsigned __int64) maxpixels);
 
153
#else
 
154
                TIFFErrorExt(tif->tif_clientdata, module,
 
155
                             "%s data at scanline %lu (%llu != %llu)",
 
156
                             npixels < maxpixels ? "Not enough" : "Too much",
 
157
                             (unsigned long) tif->tif_row,
 
158
                             (unsigned long long) npixels,
 
159
                             (unsigned long long) maxpixels);
 
160
#endif
149
161
                return (0);
150
162
        }
151
 
        return (1);
 
163
 
 
164
        return (1);
152
165
}
153
166
 
154
167
static int
155
 
ThunderDecodeRow(TIFF* tif, tidata_t buf, tsize_t occ, tsample_t s)
 
168
ThunderDecodeRow(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s)
156
169
{
157
 
        tidata_t row = buf;
 
170
        static const char module[] = "ThunderDecodeRow";
 
171
        uint8* row = buf;
158
172
        
159
173
        (void) s;
160
 
        while ((long)occ > 0) {
 
174
        if (occ % tif->tif_scanlinesize)
 
175
        {
 
176
                TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
 
177
                return (0);
 
178
        }
 
179
        while (occ > 0) {
161
180
                if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth))
162
181
                        return (0);
163
182
                occ -= tif->tif_scanlinesize;
164
183
                row += tif->tif_scanlinesize;
165
184
        }
166
 
 
167
 
        return (1);
 
185
        return (1);
168
186
}
169
187
 
170
188
int
171
189
TIFFInitThunderScan(TIFF* tif, int scheme)
172
190
{
173
191
        (void) scheme;
 
192
 
 
193
        tif->tif_setupdecode = ThunderSetupDecode;
174
194
        tif->tif_decoderow = ThunderDecodeRow;
175
 
        tif->tif_decodestrip = ThunderDecodeRow;
176
 
        tif->tif_setupdecode = ThunderSetupDecode;
 
195
        tif->tif_decodestrip = ThunderDecodeRow; 
177
196
        return (1);
178
197
}
179
198
#endif /* THUNDER_SUPPORT */
186
205
 * fill-column: 78
187
206
 * End:
188
207
 */
189