Commit b83ccbff authored by Michael Niedermayer's avatar Michael Niedermayer

Do not crash on frame size changes.

Fixes issue1481.

Originally committed as revision 20730 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent d09f65c7
...@@ -941,6 +941,15 @@ static void do_video_out(AVFormatContext *s, ...@@ -941,6 +941,15 @@ static void do_video_out(AVFormatContext *s,
} }
} }
if( (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) ) {
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)
av_exit(1);
}
if (ost->video_resample) { if (ost->video_resample) {
padding_src = NULL; padding_src = NULL;
final_picture = &ost->pict_tmp; final_picture = &ost->pict_tmp;
...@@ -948,7 +957,6 @@ static void do_video_out(AVFormatContext *s, ...@@ -948,7 +957,6 @@ static void do_video_out(AVFormatContext *s,
|| (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand))) || (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
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));
/* keep bands proportional to the frame size */ /* keep bands proportional to the frame size */
topBand = ((int64_t)ist->st->codec->height * ost->original_topBand / ost->original_height) & ~1; topBand = ((int64_t)ist->st->codec->height * ost->original_topBand / ost->original_height) & ~1;
bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1; bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1;
...@@ -1940,11 +1948,11 @@ static int av_encode(AVFormatContext **output_files, ...@@ -1940,11 +1948,11 @@ static int av_encode(AVFormatContext **output_files,
ost->original_height = icodec->height; ost->original_height = icodec->height;
ost->original_width = icodec->width; ost->original_width = icodec->width;
codec->bits_per_raw_sample= 0;
}
ost->resample_height = icodec->height - (frame_topBand + frame_bottomBand); ost->resample_height = icodec->height - (frame_topBand + frame_bottomBand);
ost->resample_width = icodec->width - (frame_leftBand + frame_rightBand); ost->resample_width = icodec->width - (frame_leftBand + frame_rightBand);
ost->resample_pix_fmt= icodec->pix_fmt; ost->resample_pix_fmt= icodec->pix_fmt;
codec->bits_per_raw_sample= 0;
}
ost->encoding_needed = 1; ost->encoding_needed = 1;
ist->decoding_needed = 1; ist->decoding_needed = 1;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment