Revision e96f885a

View differences:

libavcodec/tiff.c
75 75
    }
76 76
}
77 77

  
78
static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src, int size)
79
{
80
    z_stream zstream;
81
    int zret;
82

  
83
    memset(&zstream, 0, sizeof(zstream));
84
    zstream.next_in = src;
85
    zstream.avail_in = size;
86
    zstream.next_out = dst;
87
    zstream.avail_out = *len;
88
    zret = inflateInit(&zstream);
89
    if (zret != Z_OK) {
90
        av_log(NULL, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
91
        return zret;
92
    }
93
    zret = inflate(&zstream, Z_SYNC_FLUSH);
94
    inflateEnd(&zstream);
95
    *len = zstream.total_out;
96
    return zret == Z_STREAM_END ? Z_OK : zret;
97
}
98

  
78 99
static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){
79 100
    int c, line, pixels, code;
80 101
    const uint8_t *ssrc = src;
......
83 104
    uint8_t *zbuf; unsigned long outlen;
84 105

  
85 106
    if(s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE){
107
        int ret;
86 108
        outlen = width * lines;
87 109
        zbuf = av_malloc(outlen);
88
        if(uncompress(zbuf, &outlen, src, size) != Z_OK){
89
            av_log(s->avctx, AV_LOG_ERROR, "Uncompressing failed (%lu of %lu)\n", outlen, (unsigned long)width * lines);
110
        ret = tiff_uncompress(zbuf, &outlen, src, size);
111
        if(ret != Z_OK){
112
            av_log(s->avctx, AV_LOG_ERROR, "Uncompressing failed (%lu of %lu) with error %d\n", outlen, (unsigned long)width * lines, ret);
90 113
            av_free(zbuf);
91 114
            return -1;
92 115
        }

Also available in: Unified diff