[FFmpeg-devel] [PATCH] avoid crashes if input stream size changes without using -r
Reimar Döffinger
Reimar.Doeffinger
Sun Jul 5 14:41:51 CEST 2009
On Sun, Jul 05, 2009 at 01:45:45PM +0200, Reimar D?ffinger wrote:
> Hello,
> I don't know why, but currently FFmpeg only checks for an input stream
> size change when it is using resizing.
> Which means when you not use resizing it passes incorrectly size frames
> to the encoder and just crashes, as demonstrated by
> vp62/smclockvp62hsp.avi.1.0 from issue 1240.
> Here the container resolution is 32x65568 but the codec changes it to
> 32x32 - passing that 32x32 frame to e.g. the raw encoder (for framecrc)
> initialized for 32x65568 obviously crashes.
> Attached patch mostly just moves some code around to avoid this and
> print an error instead.
> Index: ffmpeg.c
> ===================================================================
> --- ffmpeg.c (revision 19346)
> +++ ffmpeg.c (working copy)
> @@ -861,6 +861,7 @@
> int *frame_size)
> {
> int nb_frames, i, ret;
> + int size_change;
> int64_t topBand, bottomBand, leftBand, rightBand;
> AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
> AVFrame picture_crop_temp, picture_pad_temp;
> @@ -935,14 +936,22 @@
> }
> }
>
> + size_change = (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
> + || (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
> + || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt);
> + if(size_change) {
> + fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\n", ist->file_index, ist->index, ist->st->codec->width, ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));
> + if (!ost->video_resample) {
> + if (exit_on_error)
> + av_exit(1);
> + return;
> + }
> + }
Sorry, that's of course nonsense, resample_width/resample_height etc.
are never set when resampling is not used so this just breaks things
completely.
I still think that something _similar_ to that is needed, I just don't
know which are the right variables...
More information about the ffmpeg-devel
mailing list