Commit 9aa797cd authored by Stefano Sabatini's avatar Stefano Sabatini Committed by Anton Khirnov

ffmpeg: factorize resampling condition check in do_video_out()

Simplify and improve readability.
Signed-off-by: 's avatarStefano Sabatini <stefano.sabatini-lala@poste.it>
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent c29c2eea
...@@ -1078,7 +1078,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -1078,7 +1078,7 @@ static void do_video_out(AVFormatContext *s,
AVFrame *in_picture, AVFrame *in_picture,
int *frame_size) int *frame_size)
{ {
int nb_frames, i, ret; int nb_frames, i, ret, resample_changed;
AVFrame *final_picture, *formatted_picture, *resampling_dst; AVFrame *final_picture, *formatted_picture, *resampling_dst;
AVCodecContext *enc, *dec; AVCodecContext *enc, *dec;
double sync_ipts; double sync_ipts;
...@@ -1126,9 +1126,11 @@ static void do_video_out(AVFormatContext *s, ...@@ -1126,9 +1126,11 @@ static void do_video_out(AVFormatContext *s,
final_picture = formatted_picture; final_picture = formatted_picture;
resampling_dst = &ost->pict_tmp; resampling_dst = &ost->pict_tmp;
if ( ost->resample_height != ist->st->codec->height resample_changed = ost->resample_width != dec->width ||
|| ost->resample_width != ist->st->codec->width ost->resample_height != dec->height ||
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) { ost->resample_pix_fmt != dec->pix_fmt;
if (resample_changed) {
av_log(NULL, AV_LOG_INFO, 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", "Input stream #%d.%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
ist->file_index, ist->index, ist->file_index, ist->index,
...@@ -1141,10 +1143,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -1141,10 +1143,7 @@ static void do_video_out(AVFormatContext *s,
#if !CONFIG_AVFILTER #if !CONFIG_AVFILTER
if (ost->video_resample) { if (ost->video_resample) {
final_picture = &ost->pict_tmp; final_picture = &ost->pict_tmp;
if( ost->resample_height != ist->st->codec->height if (resample_changed) {
|| ost->resample_width != ist->st->codec->width
|| (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
/* initialize a new scaler context */ /* initialize a new scaler context */
sws_freeContext(ost->img_resample_ctx); sws_freeContext(ost->img_resample_ctx);
ost->img_resample_ctx = sws_getContext( ost->img_resample_ctx = sws_getContext(
......
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