Avoids filtering code from digging in demuxer internals. --- fftools/ffmpeg.h | 5 +++++ fftools/ffmpeg_demux.c | 10 ++++++++++ fftools/ffmpeg_filter.c | 8 +------- 3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 3c7991c73a..9cb7198dfd 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -882,6 +882,11 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt); void ist_output_add(InputStream *ist, OutputStream *ost); void ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple); +/** + * Find an unused input stream of given type. + */ +InputStream *ist_find_unused(enum AVMediaType type); + /* iterate over all input streams in all input files; * pass NULL to start iteration */ InputStream *ist_iter(InputStream *prev); diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 0a37cc7c25..b93e171037 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -130,6 +130,16 @@ static Demuxer *demuxer_from_ifile(InputFile *f) return (Demuxer*)f; } +InputStream *ist_find_unused(enum AVMediaType type) +{ + for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) { + if (ist->par->codec_type == type && ist->discard && + ist->user_set_discard != AVDISCARD_ALL) + return ist; + } + return NULL; +} + static void report_new_stream(Demuxer *d, const AVPacket *pkt) { AVStream *st = d->f.ctx->streams[pkt->stream_index]; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 274eefe11c..8cc76209d0 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -420,13 +420,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in) exit_program(1); } } else { - /* find the first unused stream of corresponding type */ - for (ist = ist_iter(NULL); ist; ist = ist_iter(ist)) { - if (ist->user_set_discard == AVDISCARD_ALL) - continue; - if (ist->dec_ctx->codec_type == type && ist->discard) - break; - } + ist = ist_find_unused(type); if (!ist) { av_log(NULL, AV_LOG_FATAL, "Cannot find a matching stream for " "unlabeled input pad %d on filter %s\n", in->pad_idx, -- 2.39.2 _______________________________________________ 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".