# HG changeset patch # User kostya # Date 1263219713 0 # Node ID f17f2be8f61a47d08a5cce53a452012befc1f5f0 # Parent 7f9d077af2e4b35f4642c0d5bde84e10a19b8598 Fix two RLE buffer size calculations in TSCC decoder. Spotted by Zhongtuan Ma. diff -r 7f9d077af2e4 -r f17f2be8f61a tscc.c --- a/tscc.c Mon Jan 11 10:54:59 2010 +0000 +++ b/tscc.c Mon Jan 11 14:21:53 2010 +0000 @@ -107,7 +107,7 @@ if(zret != Z_DATA_ERROR) - ff_msrle_decode(avctx, (AVPicture*)&c->pic, c->bpp, c->decomp_buf, c->zstream.avail_out); + ff_msrle_decode(avctx, (AVPicture*)&c->pic, c->bpp, c->decomp_buf, c->decomp_size - c->zstream.avail_out); /* make the palette available on the way out */ if (c->avctx->pix_fmt == PIX_FMT_PAL8) { @@ -154,7 +154,8 @@ return -1; } c->bpp = avctx->bits_per_coded_sample; - c->decomp_size = (avctx->width * c->bpp + (avctx->width + 254) / 255 + 2) * avctx->height + 2;//RLE in the 'best' case + // buffer size for RLE 'best' case when 2-byte code preceeds each pixel and there may be padding after it too + c->decomp_size = (((avctx->width * c->bpp + 7) >> 3) + 3 * avctx->width + 2) * avctx->height + 2; /* Allocate decompression buffer */ if (c->decomp_size) {