[FFmpeg-devel] [PATCH] ffmpeg: factorize resampling condition check in do_video_out()
Stefano Sabatini
stefano.sabatini-lala at poste.it
Sun Apr 17 01:43:25 CEST 2011
Simplify and improve readability.
Signed-off-by: Stefano Sabatini <stefano.sabatini-lala at poste.it>
---
ffmpeg.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/ffmpeg.c b/ffmpeg.c
index 820b1f8..3359da4 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1131,7 +1131,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;
@@ -1179,10 +1179,12 @@ 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) ) {
- av_log(NULL, AV_LOG_INFO,
+ resample_changed = ost->resample_height != dec->height ||
+ ost->resample_width != dec->width ||
+ ost->resample_pix_fmt!= dec->pix_fmt;
+
+ if (resample_changed) {
+ av_log(NULL, AV_LOG_WARNING,
"Input stream #%d.%d frame size changed from s:%dx%d fmt:%s to s:%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),
@@ -1194,10 +1196,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);
sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
--
1.7.2.3
More information about the ffmpeg-devel
mailing list