|
| 1 | +diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c |
| 2 | +index bfa345b3d8..f445686d0d 100644 |
| 3 | +--- a/libavcodec/tiff.c |
| 4 | ++++ b/libavcodec/tiff.c |
| 5 | +@@ -28,10 +28,6 @@ |
| 6 | + #if CONFIG_ZLIB |
| 7 | + #include <zlib.h> |
| 8 | + #endif |
| 9 | +-#if CONFIG_LZMA |
| 10 | +-#define LZMA_API_STATIC |
| 11 | +-#include <lzma.h> |
| 12 | +-#endif |
| 13 | + |
| 14 | + #include <float.h> |
| 15 | + |
| 16 | +@@ -559,71 +555,6 @@ static int tiff_unpack_zlib(TiffContext *s, AVFrame *p, uint8_t *dst, int stride |
| 17 | + } |
| 18 | + #endif |
| 19 | + |
| 20 | +-#if CONFIG_LZMA |
| 21 | +-static int tiff_uncompress_lzma(uint8_t *dst, uint64_t *len, const uint8_t *src, |
| 22 | +- int size) |
| 23 | +-{ |
| 24 | +- lzma_stream stream = LZMA_STREAM_INIT; |
| 25 | +- lzma_ret ret; |
| 26 | +- |
| 27 | +- stream.next_in = src; |
| 28 | +- stream.avail_in = size; |
| 29 | +- stream.next_out = dst; |
| 30 | +- stream.avail_out = *len; |
| 31 | +- ret = lzma_stream_decoder(&stream, UINT64_MAX, 0); |
| 32 | +- if (ret != LZMA_OK) { |
| 33 | +- av_log(NULL, AV_LOG_ERROR, "LZMA init error: %d\n", ret); |
| 34 | +- return ret; |
| 35 | +- } |
| 36 | +- ret = lzma_code(&stream, LZMA_RUN); |
| 37 | +- lzma_end(&stream); |
| 38 | +- *len = stream.total_out; |
| 39 | +- return ret == LZMA_STREAM_END ? LZMA_OK : ret; |
| 40 | +-} |
| 41 | +- |
| 42 | +-static int tiff_unpack_lzma(TiffContext *s, AVFrame *p, uint8_t *dst, int stride, |
| 43 | +- const uint8_t *src, int size, int width, int lines, |
| 44 | +- int strip_start, int is_yuv) |
| 45 | +-{ |
| 46 | +- uint64_t outlen = width * (uint64_t)lines; |
| 47 | +- int ret, line; |
| 48 | +- uint8_t *buf = av_malloc(outlen); |
| 49 | +- if (!buf) |
| 50 | +- return AVERROR(ENOMEM); |
| 51 | +- if (s->fill_order) { |
| 52 | +- if ((ret = deinvert_buffer(s, src, size)) < 0) { |
| 53 | +- av_free(buf); |
| 54 | +- return ret; |
| 55 | +- } |
| 56 | +- src = s->deinvert_buf; |
| 57 | +- } |
| 58 | +- ret = tiff_uncompress_lzma(buf, &outlen, src, size); |
| 59 | +- if (ret != LZMA_OK) { |
| 60 | +- av_log(s->avctx, AV_LOG_ERROR, |
| 61 | +- "Uncompressing failed (%"PRIu64" of %"PRIu64") with error %d\n", outlen, |
| 62 | +- (uint64_t)width * lines, ret); |
| 63 | +- av_free(buf); |
| 64 | +- return AVERROR_UNKNOWN; |
| 65 | +- } |
| 66 | +- src = buf; |
| 67 | +- for (line = 0; line < lines; line++) { |
| 68 | +- if (s->bpp < 8 && s->avctx->pix_fmt == AV_PIX_FMT_PAL8) { |
| 69 | +- horizontal_fill(s, s->bpp, dst, 1, src, 0, width, 0); |
| 70 | +- } else { |
| 71 | +- memcpy(dst, src, width); |
| 72 | +- } |
| 73 | +- if (is_yuv) { |
| 74 | +- unpack_yuv(s, p, dst, strip_start + line); |
| 75 | +- line += s->subsampling[1] - 1; |
| 76 | +- } |
| 77 | +- dst += stride; |
| 78 | +- src += width; |
| 79 | +- } |
| 80 | +- av_free(buf); |
| 81 | +- return 0; |
| 82 | +-} |
| 83 | +-#endif |
| 84 | +- |
| 85 | + static int tiff_unpack_fax(TiffContext *s, uint8_t *dst, int stride, |
| 86 | + const uint8_t *src, int size, int width, int lines) |
| 87 | + { |
| 88 | +@@ -796,14 +727,9 @@ static int tiff_unpack_strip(TiffContext *s, AVFrame *p, uint8_t *dst, int strid |
| 89 | + #endif |
| 90 | + } |
| 91 | + if (s->compr == TIFF_LZMA) { |
| 92 | +-#if CONFIG_LZMA |
| 93 | +- return tiff_unpack_lzma(s, p, dst, stride, src, size, width, lines, |
| 94 | +- strip_start, is_yuv); |
| 95 | +-#else |
| 96 | + av_log(s->avctx, AV_LOG_ERROR, |
| 97 | + "LZMA support not enabled\n"); |
| 98 | + return AVERROR(ENOSYS); |
| 99 | +-#endif |
| 100 | + } |
| 101 | + if (s->compr == TIFF_LZW) { |
| 102 | + if (s->fill_order) { |
| 103 | +@@ -1374,12 +1300,8 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame) |
| 104 | + s->is_jpeg = 1; |
| 105 | + break; |
| 106 | + case TIFF_LZMA: |
| 107 | +-#if CONFIG_LZMA |
| 108 | +- break; |
| 109 | +-#else |
| 110 | + av_log(s->avctx, AV_LOG_ERROR, "LZMA not compiled in\n"); |
| 111 | + return AVERROR(ENOSYS); |
| 112 | +-#endif |
| 113 | + default: |
| 114 | + av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", |
| 115 | + s->compr); |
0 commit comments