[FFmpeg-cvslog] tiff: support zlib with invertedFillOrder

Piotr Bandurski git at videolan.org
Sun Dec 9 01:01:40 CET 2012


ffmpeg | branch: master | Piotr Bandurski <ami_stuff at o2.pl> | Sat Dec  8 22:36:57 2012 +0100| [7f01247572987ba7e657c081601bba0b4855e936] | committer: Michael Niedermayer

tiff: support zlib with invertedFillOrder

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7f01247572987ba7e657c081601bba0b4855e936
---

 libavcodec/tiff.c |   18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 64e4e41..286cbc2 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -405,18 +405,31 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
 
 #if CONFIG_ZLIB
     if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE) {
-        uint8_t *zbuf;
+        uint8_t *src2 = NULL, *zbuf;
         unsigned long outlen;
-        int ret;
+        int i, ret;
         outlen = width * lines;
         zbuf = av_malloc(outlen);
         if (!zbuf)
             return AVERROR(ENOMEM);
+        if (s->fill_order) {
+            src2 = av_malloc((unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE);
+            if (!src2) {
+                av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
+                av_free(zbuf);
+                return AVERROR(ENOMEM);
+            }
+            for (i = 0; i < size; i++)
+                src2[i] = ff_reverse[src[i]];
+            memset(src2 + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+            src = src2;
+        }
         ret = tiff_uncompress(zbuf, &outlen, src, size);
         if (ret != Z_OK) {
             av_log(s->avctx, AV_LOG_ERROR,
                    "Uncompressing failed (%lu of %lu) with error %d\n", outlen,
                    (unsigned long)width * lines, ret);
+            av_free(src2);
             av_free(zbuf);
             return -1;
         }
@@ -430,6 +443,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride,
             dst += stride;
             src += width;
         }
+        av_free(src2);
         av_free(zbuf);
         return 0;
     }



More information about the ffmpeg-cvslog mailing list