[FFmpeg-devel] [PATCH] indeo3: realloc buffers on size change
Reimar Döffinger
Reimar.Doeffinger
Mon Jul 6 14:39:06 CEST 2009
Hello,
this fixes i32/smclocki32.avi.1.0 from issue 1240, the buffers were
initially allocated for size 0x32, thus had size 0.
This obviously crashed when the size changed to 32x32, and attached
patch fixes it.
-------------- next part --------------
Index: libavcodec/indeo3.c
===================================================================
--- libavcodec/indeo3.c (revision 19354)
+++ libavcodec/indeo3.c (working copy)
@@ -107,6 +107,7 @@
unsigned int bufsize = luma_pixels * 2 + luma_width * 3 +
(chroma_pixels + chroma_width) * 4;
+ av_freep(&s->buf);
if(!(s->buf = av_malloc(bufsize)))
return AVERROR(ENOMEM);
s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width;
@@ -975,9 +976,10 @@
return ret;
}
-static int iv_decode_frame(Indeo3DecodeContext *s,
+static int iv_decode_frame(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
+ Indeo3DecodeContext *s = avctx->priv_data;
unsigned int image_width, image_height,
chroma_width, chroma_height;
unsigned long flags, cb_offset, data_size,
@@ -994,8 +996,19 @@
image_height = bytestream_get_le16(&buf_pos);
image_width = bytestream_get_le16(&buf_pos);
- if(avcodec_check_dimensions(NULL, image_width, image_height))
+ if(avcodec_check_dimensions(avctx, image_width, image_height))
return -1;
+ if (image_width != avctx->width || image_height != avctx->height) {
+ int ret;
+ avcodec_set_dimensions(avctx, image_width, image_height);
+ s->width = avctx->width;
+ s->height = avctx->height;
+ ret = iv_alloc_frames(s);
+ if (ret < 0) {
+ s->width = s->height = 0;
+ return ret;
+ }
+ }
chroma_height = ((image_height >> 2) + 3) & 0x7ffc;
chroma_width = ((image_width >> 2) + 3) & 0x7ffc;
@@ -1070,7 +1083,7 @@
uint8_t *src, *dest;
int y;
- if (iv_decode_frame(s, buf, buf_size) < 0)
+ if (iv_decode_frame(avctx, buf, buf_size) < 0)
return -1;
if(s->frame.data[0])
More information about the ffmpeg-devel
mailing list