Mercurial > libavcodec.hg
comparison tscc.c @ 10845:f17f2be8f61a libavcodec
Fix two RLE buffer size calculations in TSCC decoder.
Spotted by Zhongtuan Ma.
author | kostya |
---|---|
date | Mon, 11 Jan 2010 14:21:53 +0000 |
parents | d7ed9dcc78e3 |
children | 8a4984c5cacc |
comparison
equal
deleted
inserted
replaced
10844:7f9d077af2e4 | 10845:f17f2be8f61a |
---|---|
105 return -1; | 105 return -1; |
106 } | 106 } |
107 | 107 |
108 | 108 |
109 if(zret != Z_DATA_ERROR) | 109 if(zret != Z_DATA_ERROR) |
110 ff_msrle_decode(avctx, (AVPicture*)&c->pic, c->bpp, c->decomp_buf, c->zstream.avail_out); | 110 ff_msrle_decode(avctx, (AVPicture*)&c->pic, c->bpp, c->decomp_buf, c->decomp_size - c->zstream.avail_out); |
111 | 111 |
112 /* make the palette available on the way out */ | 112 /* make the palette available on the way out */ |
113 if (c->avctx->pix_fmt == PIX_FMT_PAL8) { | 113 if (c->avctx->pix_fmt == PIX_FMT_PAL8) { |
114 memcpy(c->pic.data[1], c->avctx->palctrl->palette, AVPALETTE_SIZE); | 114 memcpy(c->pic.data[1], c->avctx->palctrl->palette, AVPALETTE_SIZE); |
115 if (c->avctx->palctrl->palette_changed) { | 115 if (c->avctx->palctrl->palette_changed) { |
152 case 32: avctx->pix_fmt = PIX_FMT_RGB32; break; | 152 case 32: avctx->pix_fmt = PIX_FMT_RGB32; break; |
153 default: av_log(avctx, AV_LOG_ERROR, "Camtasia error: unknown depth %i bpp\n", avctx->bits_per_coded_sample); | 153 default: av_log(avctx, AV_LOG_ERROR, "Camtasia error: unknown depth %i bpp\n", avctx->bits_per_coded_sample); |
154 return -1; | 154 return -1; |
155 } | 155 } |
156 c->bpp = avctx->bits_per_coded_sample; | 156 c->bpp = avctx->bits_per_coded_sample; |
157 c->decomp_size = (avctx->width * c->bpp + (avctx->width + 254) / 255 + 2) * avctx->height + 2;//RLE in the 'best' case | 157 // buffer size for RLE 'best' case when 2-byte code preceeds each pixel and there may be padding after it too |
158 c->decomp_size = (((avctx->width * c->bpp + 7) >> 3) + 3 * avctx->width + 2) * avctx->height + 2; | |
158 | 159 |
159 /* Allocate decompression buffer */ | 160 /* Allocate decompression buffer */ |
160 if (c->decomp_size) { | 161 if (c->decomp_size) { |
161 if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) { | 162 if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) { |
162 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); | 163 av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); |