Report when zlib support is missing.
Luca Barbato authored on 2013/06/03 10:51:05... | ... |
@@ -111,6 +111,35 @@ static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src, |
111 | 111 |
*len = zstream.total_out; |
112 | 112 |
return zret == Z_STREAM_END ? Z_OK : zret; |
113 | 113 |
} |
114 |
+ |
|
115 |
+static int tiff_unpack_zlib(TiffContext *s, uint8_t *dst, int stride, |
|
116 |
+ const uint8_t *src, int size, |
|
117 |
+ int width, int lines) |
|
118 |
+{ |
|
119 |
+ uint8_t *zbuf; |
|
120 |
+ unsigned long outlen; |
|
121 |
+ int ret, line; |
|
122 |
+ outlen = width * lines; |
|
123 |
+ zbuf = av_malloc(outlen); |
|
124 |
+ if (!zbuf) |
|
125 |
+ return AVERROR(ENOMEM); |
|
126 |
+ ret = tiff_uncompress(zbuf, &outlen, src, size); |
|
127 |
+ if (ret != Z_OK) { |
|
128 |
+ av_log(s->avctx, AV_LOG_ERROR, |
|
129 |
+ "Uncompressing failed (%lu of %lu) with error %d\n", outlen, |
|
130 |
+ (unsigned long)width * lines, ret); |
|
131 |
+ av_free(zbuf); |
|
132 |
+ return AVERROR_UNKNOWN; |
|
133 |
+ } |
|
134 |
+ src = zbuf; |
|
135 |
+ for (line = 0; line < lines; line++) { |
|
136 |
+ memcpy(dst, src, width); |
|
137 |
+ dst += stride; |
|
138 |
+ src += width; |
|
139 |
+ } |
|
140 |
+ av_free(zbuf); |
|
141 |
+ return 0; |
|
142 |
+} |
|
114 | 143 |
#endif |
115 | 144 |
|
116 | 145 |
static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
... | ... |
@@ -123,33 +152,16 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, |
123 | 123 |
if (size <= 0) |
124 | 124 |
return AVERROR_INVALIDDATA; |
125 | 125 |
|
126 |
-#if CONFIG_ZLIB |
|
127 | 126 |
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) { |
128 |
- uint8_t *zbuf; |
|
129 |
- unsigned long outlen; |
|
130 |
- int ret; |
|
131 |
- outlen = width * lines; |
|
132 |
- zbuf = av_malloc(outlen); |
|
133 |
- if (!zbuf) |
|
134 |
- return AVERROR(ENOMEM); |
|
135 |
- ret = tiff_uncompress(zbuf, &outlen, src, size); |
|
136 |
- if (ret != Z_OK) { |
|
137 |
- av_log(s->avctx, AV_LOG_ERROR, |
|
138 |
- "Uncompressing failed (%lu of %lu) with error %d\n", outlen, |
|
139 |
- (unsigned long)width * lines, ret); |
|
140 |
- av_free(zbuf); |
|
141 |
- return AVERROR_UNKNOWN; |
|
142 |
- } |
|
143 |
- src = zbuf; |
|
144 |
- for (line = 0; line < lines; line++) { |
|
145 |
- memcpy(dst, src, width); |
|
146 |
- dst += stride; |
|
147 |
- src += width; |
|
148 |
- } |
|
149 |
- av_free(zbuf); |
|
150 |
- return 0; |
|
151 |
- } |
|
127 |
+#if CONFIG_ZLIB |
|
128 |
+ return tiff_unpack_zlib(s, dst, stride, src, size, width, lines); |
|
129 |
+#else |
|
130 |
+ av_log(s->avctx, AV_LOG_ERROR, |
|
131 |
+ "zlib support not enabled, " |
|
132 |
+ "deflate compression not supported\n"); |
|
133 |
+ return AVERROR(ENOSYS); |
|
152 | 134 |
#endif |
135 |
+ } |
|
153 | 136 |
if (s->compr == TIFF_LZW) { |
154 | 137 |
if ((ret = ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF)) < 0) { |
155 | 138 |
av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n"); |