1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Support <8-bit ILBM uncompressed bitmaps

Originally committed as revision 21846 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Peter Ross 2010-02-16 09:33:59 +00:00
parent 37a9719a97
commit cbba8fec23

View File

@ -114,6 +114,7 @@ static int decode_frame_ilbm(AVCodecContext *avctx,
IffContext *s = avctx->priv_data; IffContext *s = avctx->priv_data;
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
const uint8_t *buf_end = buf+buf_size;
int y, plane; int y, plane;
if (avctx->reget_buffer(avctx, &s->frame) < 0){ if (avctx->reget_buffer(avctx, &s->frame) < 0){
@ -121,19 +122,14 @@ static int decode_frame_ilbm(AVCodecContext *avctx,
return -1; return -1;
} }
if (buf_size < avctx->width * avctx->height) {
av_log(avctx, AV_LOG_ERROR, "buffer underflow\n");
return -1;
}
for(y = 0; y < avctx->height; y++ ) { for(y = 0; y < avctx->height; y++ ) {
uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ]; uint8_t *row = &s->frame.data[0][ y*s->frame.linesize[0] ];
memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4)); memset(row, 0, avctx->pix_fmt == PIX_FMT_PAL8 ? avctx->width : (avctx->width * 4));
for (plane = 0; plane < avctx->bits_per_coded_sample; plane++) { for (plane = 0; plane < avctx->bits_per_coded_sample && buf < buf_end; plane++) {
if (avctx->pix_fmt == PIX_FMT_PAL8) { if (avctx->pix_fmt == PIX_FMT_PAL8) {
decodeplane8(row, buf, s->planesize, avctx->bits_per_coded_sample, plane); decodeplane8(row, buf, FFMIN(s->planesize, buf_end - buf), avctx->bits_per_coded_sample, plane);
} else { // PIX_FMT_BGR32 } else { // PIX_FMT_BGR32
decodeplane32(row, buf, s->planesize, avctx->bits_per_coded_sample, plane); decodeplane32(row, buf, FFMIN(s->planesize, buf_end - buf), avctx->bits_per_coded_sample, plane);
} }
buf += s->planesize; buf += s->planesize;
} }