From 8da5d3dc3792b6992e4794351125279f05c8ba0e Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Mon, 28 Sep 2009 05:17:20 +0000 Subject: [PATCH] Finally distinguish TIFF_CCITT_RLE and TIFF_G3 1-D case, so both of them will be decoded correctly. This fixes issue 1423. Originally committed as revision 20065 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/faxcompr.c | 5 +++-- libavcodec/faxcompr.h | 2 +- libavcodec/tiff.c | 4 +--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/faxcompr.c b/libavcodec/faxcompr.c index 215616309d..fb2ae1612f 100644 --- a/libavcodec/faxcompr.c +++ b/libavcodec/faxcompr.c @@ -269,7 +269,7 @@ static int find_group3_syncmarker(GetBitContext *gb, int srcsize) int ff_ccitt_unpack(AVCodecContext *avctx, const uint8_t *src, int srcsize, - uint8_t *dst, int height, int stride, enum TiffCompr compr) + uint8_t *dst, int height, int stride, enum TiffCompr compr, int opts) { int j; GetBitContext gb; @@ -293,9 +293,10 @@ int ff_ccitt_unpack(AVCodecContext *avctx, return -1; } }else{ + int g3d1 = (compr == TIFF_G3) && !(opts & 1); if(compr!=TIFF_CCITT_RLE && find_group3_syncmarker(&gb, srcsize*8) < 0) break; - if(compr==TIFF_CCITT_RLE || get_bits1(&gb)) + if(compr==TIFF_CCITT_RLE || g3d1 || get_bits1(&gb)) ret = decode_group3_1d_line(avctx, &gb, avctx->width, runs, runend); else ret = decode_group3_2d_line(avctx, &gb, avctx->width, runs, runend, ref); diff --git a/libavcodec/faxcompr.h b/libavcodec/faxcompr.h index 5f0a222e72..2f7926c05b 100644 --- a/libavcodec/faxcompr.h +++ b/libavcodec/faxcompr.h @@ -40,6 +40,6 @@ void ff_ccitt_unpack_init(void); */ int ff_ccitt_unpack(AVCodecContext *avctx, const uint8_t *src, int srcsize, - uint8_t *dst, int height, int stride, enum TiffCompr compr); + uint8_t *dst, int height, int stride, enum TiffCompr compr, int opts); #endif /* AVCODEC_FAXCOMPR_H */ diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 536b74f391..39a11f7c2c 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -146,13 +146,11 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin src2[i] = ff_reverse[src[i]]; } memset(src2+size, 0, FF_INPUT_BUFFER_PADDING_SIZE); - if(s->compr == TIFF_G3 && !(s->fax_opts & 1)) - s->compr = TIFF_CCITT_RLE; switch(s->compr){ case TIFF_CCITT_RLE: case TIFF_G3: case TIFF_G4: - ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, s->compr); + ret = ff_ccitt_unpack(s->avctx, src2, size, dst, lines, stride, s->compr, s->fax_opts); break; } av_free(src2);