67 return le ? bytestream2_get_le16(gb) : bytestream2_get_be16(gb);
72 return le ? bytestream2_get_le32(gb) : bytestream2_get_be32(gb);
78 case TIFF_BYTE:
return bytestream2_get_byte(gb);
81 default:
return UINT_MAX;
89 z_stream zstream = { 0 };
92 zstream.next_in = src;
93 zstream.avail_in =
size;
94 zstream.next_out = dst;
95 zstream.avail_out = *
len;
96 zret = inflateInit(&zstream);
98 av_log(
NULL, AV_LOG_ERROR,
"Inflate init error: %d\n", zret);
101 zret = inflate(&zstream, Z_SYNC_FLUSH);
102 inflateEnd(&zstream);
103 *len = zstream.total_out;
104 return zret == Z_STREAM_END ? Z_OK : zret;
109 const uint8_t *src,
int size,
int lines)
112 int c,
line, pixels, code;
121 unsigned long outlen;
123 outlen = width * lines;
127 ret = tiff_uncompress(zbuf, &outlen, src, size);
130 "Uncompressing failed (%lu of %lu) with error %d\n", outlen,
131 (
unsigned long)width * lines, ret);
136 for (line = 0; line < lines; line++) {
137 memcpy(dst, src, width);
150 for (line = 0; line < lines; line++) {
152 if (pixels < width) {
169 "Error allocating temporary buffer\n");
174 "Uncompressed fax mode is not supported (yet)\n");
179 memcpy(src2, src, size);
181 for (i = 0; i <
size; i++)
200 for (line = 0; line < lines; line++) {
210 for (i = 0; i <
width; i++)
211 bytestream2_put_byte(&pb,
ff_reverse[bytestream2_get_byte(&s->
gb)]);
215 for (pixels = 0; pixels <
width;) {
216 code = (int8_t)bytestream2_get_byte(&s->
gb);
221 }
else if (code != -128) {
223 c = bytestream2_get_byte(&s->
gb);
260 "This format is not supported (bpp=%d, bppcount=%d)\n",
281 for (i = 0; i < 256; i++)
282 pal[i] = i * 0x010101;
290 unsigned tag, type, count,
off, value = 0;
328 if (count <= 4 &&
type_sizes[type] * count <= 4)
345 "This format is not supported (bpp=%d, %d components)\n",
354 s->
bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
355 ((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
360 for (i = 0; i < count; i++)
371 "Samples per pixel requires a single value, many provided\n");
402 "JPEG compression is not supported\n");
411 if (type ==
TIFF_LONG && value == UINT_MAX)
415 "Incorrect value of rows per strip\n");
463 if (value < 1 || value > 2) {
465 "Unknown FillOrder value %d, trying default one\n", value);
474 if (count / 3 > 256 ||
477 pal_gb[0] = pal_gb[1] = pal_gb[2] = s->
gb;
481 for (i = 0; i < count / 3; i++) {
482 uint32_t p = 0xFF000000;
483 p |= (
tget(&pal_gb[0], type, s->
le) >>
off) << 16;
484 p |= (
tget(&pal_gb[1], type, s->
le) >>
off) << 8;
485 p |=
tget(&pal_gb[2], type, s->
le) >>
off;
523 unsigned soff, ssize;
533 id = bytestream2_get_le16(&s->
gb);
536 else if (
id == 0x4D4D)
550 "The answer to life, universe and everything is not correct!\n");
557 if (off >= UINT_MAX - 14 || avpkt->
size < off + 14) {
563 for (i = 0; i < entries; i++) {
595 for (i = 0; i < s->
height; i += s->
rps) {
602 soff =
tget(&stripdata, s->
sot, le);
606 if (soff > avpkt->
size || ssize > avpkt->
size - soff) {
618 ssize = s->
width * soff;
619 for (i = 0; i < s->
height; i++) {
620 for (j = soff; j < ssize; j++)
621 dst[j] += dst[j - soff];
631 for (j = 0; j < s->
height; j++) {
633 src[i] = 255 - src[i];