X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffmpeg.c;h=738fb7b922a38dd5231c46ab8547d1aee2d4e64b;hb=2b95602e93226bd269676b0edcda5322b5be8444;hp=89755863e4b1f96ccaceff9bba0de2eb738aa7ec;hpb=2ecc5b70fb53d0e2e74b51d1d598af8c842afc68;p=ffmpeg diff --git a/ffmpeg.c b/ffmpeg.c index 89755863e4b..738fb7b922a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1078,7 +1078,7 @@ static void do_video_out(AVFormatContext *s, AVFrame *in_picture, int *frame_size) { - int nb_frames, i, ret; + int nb_frames, i, ret, resample_changed; AVFrame *final_picture, *formatted_picture, *resampling_dst; AVCodecContext *enc, *dec; double sync_ipts; @@ -1126,14 +1126,16 @@ static void do_video_out(AVFormatContext *s, final_picture = formatted_picture; resampling_dst = &ost->pict_tmp; - if ( ost->resample_height != ist->st->codec->height - || ost->resample_width != ist->st->codec->width - || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { + resample_changed = ost->resample_width != dec->width || + ost->resample_height != dec->height || + ost->resample_pix_fmt != dec->pix_fmt; + + if (resample_changed) { av_log(NULL, AV_LOG_INFO, "Input stream #%d.%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n", ist->file_index, ist->index, - ost->resample_width , ost->resample_height , avcodec_get_pix_fmt_name(ost->resample_pix_fmt), - ist->st->codec->width, ist->st->codec->height, avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt)); + ost->resample_width, ost->resample_height, avcodec_get_pix_fmt_name(ost->resample_pix_fmt), + dec->width , dec->height , avcodec_get_pix_fmt_name(dec->pix_fmt)); if(!ost->video_resample) ffmpeg_exit(1); } @@ -1141,10 +1143,7 @@ static void do_video_out(AVFormatContext *s, #if !CONFIG_AVFILTER if (ost->video_resample) { final_picture = &ost->pict_tmp; - if( ost->resample_height != ist->st->codec->height - || ost->resample_width != ist->st->codec->width - || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { - + if (resample_changed) { /* initialize a new scaler context */ sws_freeContext(ost->img_resample_ctx); ost->img_resample_ctx = sws_getContext( @@ -2172,9 +2171,9 @@ static int transcode(AVFormatContext **output_files, fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); ffmpeg_exit(1); } - ost->video_resample = (codec->width != icodec->width || - codec->height != icodec->height || - (codec->pix_fmt != icodec->pix_fmt)); + ost->video_resample = codec->width != icodec->width || + codec->height != icodec->height || + codec->pix_fmt != icodec->pix_fmt; if (ost->video_resample) { #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp);