diff options
author | Anton Khirnov <anton@khirnov.net> | 2022-06-20 14:18:37 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2022-07-28 16:37:16 +0200 |
commit | ff40d9e8ed135610223845725aca7e1913af9af9 (patch) | |
tree | 60a599e98c18d5ced14836b7ec41c952c90d1a70 | |
parent | b898dc89340ba34a5f45e084fd65b00419591d47 (diff) |
fftools/ffmpeg_opt: reduce indentation in map_auto_audio()
Fix indentation after the previous commit. Also use an early return to
save one extra indentation level.
-rw-r--r-- | fftools/ffmpeg_opt.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index e426768f7c..174b1dd0eb 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2545,38 +2545,39 @@ static void map_auto_audio(OutputFile *of, AVFormatContext *oc, OptionsContext *o) { InputStream *ist; + int best_score = 0, idx = -1; /* audio: most channels */ - if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_AUDIO) != AV_CODEC_ID_NONE) { - int best_score = 0, idx = -1; - for (int j = 0; j < nb_input_files; j++) { - InputFile *ifile = input_files[j]; - int file_best_score = 0, file_best_idx = -1; - for (int i = 0; i < ifile->nb_streams; i++) { - int score; - ist = input_streams[ifile->ist_index + i]; - score = ist->st->codecpar->ch_layout.nb_channels - + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) - + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); - if (ist->user_set_discard == AVDISCARD_ALL) - continue; - if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && - score > file_best_score) { - file_best_score = score; - file_best_idx = ifile->ist_index + i; - } - } - if (file_best_idx >= 0) { - file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); - if (file_best_score > best_score) { - best_score = file_best_score; - idx = file_best_idx; - } - } + if (av_guess_codec(oc->oformat, NULL, oc->url, NULL, AVMEDIA_TYPE_AUDIO) == AV_CODEC_ID_NONE) + return; + + for (int j = 0; j < nb_input_files; j++) { + InputFile *ifile = input_files[j]; + int file_best_score = 0, file_best_idx = -1; + for (int i = 0; i < ifile->nb_streams; i++) { + int score; + ist = input_streams[ifile->ist_index + i]; + score = ist->st->codecpar->ch_layout.nb_channels + + 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) + + 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); + if (ist->user_set_discard == AVDISCARD_ALL) + continue; + if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && + score > file_best_score) { + file_best_score = score; + file_best_idx = ifile->ist_index + i; } - if (idx >= 0) - new_audio_stream(o, oc, idx); } + if (file_best_idx >= 0) { + file_best_score -= 5000000*!!(input_streams[file_best_idx]->st->disposition & AV_DISPOSITION_DEFAULT); + if (file_best_score > best_score) { + best_score = file_best_score; + idx = file_best_idx; + } + } + } + if (idx >= 0) + new_audio_stream(o, oc, idx); } static int open_output_file(OptionsContext *o, const char *filename) |