mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-02-17 12:27:18 +00:00
fftools/ffmpeg_filter: split finding an unused stream into a function
Avoids filtering code from digging in demuxer internals.
This commit is contained in:
parent
8c0f516133
commit
ede6794d6a
@ -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);
|
||||
|
@ -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];
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user