From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_mux_init: simplify inner loop in map_auto_{video, audio}
Date: Thu, 17 Nov 2022 11:16:35 +0100
Message-ID: <20221117101640.6789-5-anton@khirnov.net> (raw)
In-Reply-To: <20221117101640.6789-1-anton@khirnov.net>
Skip unusable streams early and do not compute any scores for them.
---
fftools/ffmpeg_mux_init.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index e460e7603f..6db70cc852 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -869,15 +869,18 @@ static void map_auto_video(Muxer *mux, const OptionsContext *o)
for (int i = 0; i < ifile->nb_streams; i++) {
int score;
ist = input_streams[ifile->ist_index + i];
+
+ if (ist->user_set_discard == AVDISCARD_ALL ||
+ ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
+ continue;
+
score = ist->st->codecpar->width * ist->st->codecpar->height
+ 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((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 > file_best_score) {
+
+ if (score > file_best_score) {
if((qcr==MKTAG('A', 'P', 'I', 'C')) && !(ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
continue;
file_best_score = score;
@@ -913,13 +916,15 @@ static void map_auto_audio(Muxer *mux, const OptionsContext *o)
for (int i = 0; i < ifile->nb_streams; i++) {
int score;
ist = input_streams[ifile->ist_index + i];
+
+ if (ist->user_set_discard == AVDISCARD_ALL ||
+ ist->st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
+ continue;
+
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) {
+ if (score > file_best_score) {
file_best_score = score;
file_best_idx = ifile->ist_index + i;
}
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-11-17 10:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 10:16 [FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg: move freeing an input stream into a separate function Anton Khirnov
2022-11-17 10:16 ` [FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg: drop an arbitrary condition Anton Khirnov
2022-11-17 10:16 ` [FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg: stop inventing fake source information Anton Khirnov
2022-11-17 10:16 ` [FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg: replace OutputStream.source_index with a pointer to InputStream Anton Khirnov
2022-11-17 10:16 ` Anton Khirnov [this message]
2022-11-17 10:16 ` [FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg: remove the input_streams global Anton Khirnov
2022-11-17 10:16 ` [FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg: do not assume input streams exist Anton Khirnov
2022-11-17 10:16 ` [FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg: declare loop variables inside loops in transcode_init() Anton Khirnov
2022-11-17 10:16 ` [FFmpeg-devel] [PATCH 09/10] fftools/ffmpeg: _-prefix variables in MATCH_PER_STREAM_OPT() Anton Khirnov
2022-11-17 10:16 ` [FFmpeg-devel] [PATCH 10/10] fftools/ffmpeg_mux_init: postpone matching -disposition to streams Anton Khirnov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221117101640.6789-5-anton@khirnov.net \
--to=anton@khirnov.net \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git