diff options
author | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2011-09-25 17:19:15 +0200 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@ag.or.at> | 2011-09-25 17:21:46 +0200 |
commit | ef8756dab2b266e70ccd84bc1573642c0da01984 (patch) | |
tree | fc34e97b1bc88a2c77533b4de6091676c2f73948 | |
parent | baad01d8b4bfe63c7c4e571ed553f7845d78d9c0 (diff) | |
download | ffmpeg-ef8756dab2b266e70ccd84bc1573642c0da01984.tar.gz |
Support LZW and ZLIB compressed 4bpp tiff samples.
Fixes ticket #439 and ticket #440.
-rw-r--r-- | libavcodec/tiff.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index eeafa8bb6e..342b0d02b2 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -129,6 +129,16 @@ static void av_always_inline horizontal_fill(unsigned int bpp, uint8_t* dst, } } +static void av_always_inline split_nibbles(uint8_t *dst, const uint8_t *src, + int width) +{ + while (--width >= 0) { + // src == dst for LZW + dst[width * 2 + 1] = src[width] & 0xF; + dst[width * 2 + 0] = src[width] >> 4; + } +} + 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; const uint8_t *ssrc = src; @@ -148,7 +158,11 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin } src = zbuf; for(line = 0; line < lines; line++){ - memcpy(dst, src, width); + if(s->bpp == 4){ + split_nibbles(dst, src, width); + }else{ + memcpy(dst, src, width); + } dst += stride; src += width; } @@ -238,6 +252,8 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", pixels, width); return -1; } + if(s->bpp == 4) + split_nibbles(dst, dst, width); break; } dst += stride; |