Do not bother computing the score for streams that are going to be skipped. This is easier to follow. --- fftools/ffmpeg_opt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index afef23919c..eebb678e5e 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2218,6 +2218,11 @@ static int open_output_file(OptionsContext *o, const char *filename) double score; ist = input_streams[i]; + if (ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO || + ist->user_set_discard == AVDISCARD_ALL || + (qcr == MKTAG('A', 'P', 'I', 'C') && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))) + continue; + /* base score is just the area in pixels */ score = (double)ist->st->codecpar->width * ist->st->codecpar->height; /* add a fractional part favoring higher bitrate among same-area streams */ @@ -2230,14 +2235,10 @@ static int open_output_file(OptionsContext *o, const char *filename) if (ist->st->disposition & AV_DISPOSITION_DEFAULT) score = DBL_MAX; - if (ist->user_set_discard == AVDISCARD_ALL) - continue; if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) score = 1; - if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && - score > best_score) { - if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)) - continue; + + if (score > best_score) { best_score = score; idx = i; } -- 2.28.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".