mirror of https://git.ffmpeg.org/ffmpeg.git
tiff: refactor deflate support in a separate function
Report when zlib support is missing.
This commit is contained in:
parent
f8a4d5e970
commit
103937681d
|
@ -111,23 +111,14 @@ static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src,
|
||||||
*len = zstream.total_out;
|
*len = zstream.total_out;
|
||||||
return zret == Z_STREAM_END ? Z_OK : zret;
|
return zret == Z_STREAM_END ? Z_OK : zret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
|
static int tiff_unpack_zlib(TiffContext *s, uint8_t *dst, int stride,
|
||||||
const uint8_t *src, int size, int lines)
|
const uint8_t *src, int size,
|
||||||
|
int width, int lines)
|
||||||
{
|
{
|
||||||
int c, line, pixels, code, ret;
|
|
||||||
const uint8_t *ssrc = src;
|
|
||||||
int width = ((s->width * s->bpp) + 7) >> 3;
|
|
||||||
|
|
||||||
if (size <= 0)
|
|
||||||
return AVERROR_INVALIDDATA;
|
|
||||||
|
|
||||||
#if CONFIG_ZLIB
|
|
||||||
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
|
|
||||||
uint8_t *zbuf;
|
uint8_t *zbuf;
|
||||||
unsigned long outlen;
|
unsigned long outlen;
|
||||||
int ret;
|
int ret, line;
|
||||||
outlen = width * lines;
|
outlen = width * lines;
|
||||||
zbuf = av_malloc(outlen);
|
zbuf = av_malloc(outlen);
|
||||||
if (!zbuf)
|
if (!zbuf)
|
||||||
|
@ -150,6 +141,27 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
|
||||||
|
const uint8_t *src, int size, int lines)
|
||||||
|
{
|
||||||
|
int c, line, pixels, code, ret;
|
||||||
|
const uint8_t *ssrc = src;
|
||||||
|
int width = ((s->width * s->bpp) + 7) >> 3;
|
||||||
|
|
||||||
|
if (size <= 0)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
|
if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
|
||||||
|
#if CONFIG_ZLIB
|
||||||
|
return tiff_unpack_zlib(s, dst, stride, src, size, width, lines);
|
||||||
|
#else
|
||||||
|
av_log(s->avctx, AV_LOG_ERROR,
|
||||||
|
"zlib support not enabled, "
|
||||||
|
"deflate compression not supported\n");
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (s->compr == TIFF_LZW) {
|
if (s->compr == TIFF_LZW) {
|
||||||
if ((ret = ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF)) < 0) {
|
if ((ret = ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF)) < 0) {
|
||||||
av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");
|
av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n");
|
||||||
|
|
Loading…
Reference in New Issue