avformat/utils: Move av_find_program_from_stream to avformat.c

It is potentially used with both demuxers and muxers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-05-07 07:27:36 +02:00
parent 9163faecd3
commit 1c0912c26e
2 changed files with 15 additions and 15 deletions

View File

@ -261,6 +261,21 @@ void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned idx)
}
}
AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
{
for (unsigned i = 0; i < ic->nb_programs; i++) {
if (ic->programs[i] == last) {
last = NULL;
} else {
if (!last)
for (unsigned j = 0; j < ic->programs[i]->nb_stream_indexes; j++)
if (ic->programs[i]->stream_index[j] == s)
return ic->programs[i];
}
}
return NULL;
}
/**
* Matches a stream specifier (but ignores requested index).
*

View File

@ -341,21 +341,6 @@ int ff_alloc_extradata(AVCodecParameters *par, int size)
return 0;
}
AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
{
for (unsigned i = 0; i < ic->nb_programs; i++) {
if (ic->programs[i] == last) {
last = NULL;
} else {
if (!last)
for (unsigned j = 0; j < ic->programs[i]->nb_stream_indexes; j++)
if (ic->programs[i]->stream_index[j] == s)
return ic->programs[i];
}
}
return NULL;
}
int av_find_best_stream(AVFormatContext *ic, enum AVMediaType type,
int wanted_stream_nb, int related_stream,
const AVCodec **decoder_ret, int flags)