[FFmpeg-devel] [PATCH] MpegEncContext must be initialized before calling ff_h263_decode_init
Reimar Döffinger
Reimar.Doeffinger
Sat Jun 27 14:40:26 CEST 2009
On Sat, Jun 27, 2009 at 11:19:48AM +0200, Reimar D?ffinger wrote:
> Hello,
> ff_h263_decode_init calls MPV_common_init which then need mb_width to
> calculate mb_stride.
> So my conclusion is, MpegEncContext needs to be initialized before
> calling this function.
> This is probably what issue1233 is about.
>
> Index: libavcodec/vc1dec.c
> ===================================================================
> --- libavcodec/vc1dec.c (revision 19281)
> +++ libavcodec/vc1dec.c (working copy)
> @@ -2997,12 +2997,19 @@
> avctx->idct_algo=FF_IDCT_WMV2;
> }
>
> + avctx->coded_width = avctx->width;
> + avctx->coded_height = avctx->height;
> +
> + avctx->has_b_frames= !!(avctx->max_b_frames);
> + s->low_delay = !avctx->has_b_frames;
> +
> + s->mb_width = (avctx->coded_width+15)>>4;
> + s->mb_height = (avctx->coded_height+15)>>4;
> +
Note that this is actually wrong and pointless, it is
s->width and s->height that must be set, and mb_width and mb_height will
be overridden (which IMHO means that this code is not supposed to set
them at all).
I haven't yet tested it, but maybe something like this is more like it?
Index: libavcodec/vc1dec.c
===================================================================
--- libavcodec/vc1dec.c (revision 19281)
+++ libavcodec/vc1dec.c (working copy)
@@ -3075,8 +3075,11 @@
avctx->has_b_frames= !!(avctx->max_b_frames);
s->low_delay = !avctx->has_b_frames;
- s->mb_width = (avctx->coded_width+15)>>4;
- s->mb_height = (avctx->coded_height+15)>>4;
+ /* Adjust for size possibly changed during initialization */
+ MPV_common_end(s);
+ s->width = avctx->coded_width;
+ s->height = avctx->coded_height;
+ MPV_common_init(s);
/* Allocate mb bitplanes */
v->mv_type_mb_plane = av_malloc(s->mb_stride * s->mb_height);
More information about the ffmpeg-devel
mailing list