diff options
author | Marton Balint <cus@passwd.hu> | 2011-08-22 23:42:19 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-08-27 22:06:09 +0200 |
commit | dacd827b81e442a3fbed0628a951c8f15f3591e3 (patch) | |
tree | b2e4f820c34fc3a4d777e3ec9a68517c0f88eb90 /libavformat/utils.c | |
parent | 941bb552c6e08b40eb7d7842df19285cd650edd0 (diff) | |
download | ffmpeg-dacd827b81e442a3fbed0628a951c8f15f3591e3.tar.gz |
Rename find_program_from_stream to av_find_program_from_stream and add it to avformat.h
Also extend the functionality to use the last found program to start the search
after that program.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index a60fcd9706..b935e402b8 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2574,14 +2574,20 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) return ret; } -static AVProgram *find_program_from_stream(AVFormatContext *ic, int s) +AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s) { int i, j; - for (i = 0; i < ic->nb_programs; i++) - for (j = 0; j < ic->programs[i]->nb_stream_indexes; j++) - if (ic->programs[i]->stream_index[j] == s) - return ic->programs[i]; + for (i = 0; i < ic->nb_programs; i++) { + if (ic->programs[i] == last) { + last = NULL; + } else { + if (!last) + for (j = 0; j < ic->programs[i]->nb_stream_indexes; j++) + if (ic->programs[i]->stream_index[j] == s) + return ic->programs[i]; + } + } return NULL; } @@ -2598,7 +2604,7 @@ int av_find_best_stream(AVFormatContext *ic, AVCodec *decoder = NULL, *best_decoder = NULL; if (related_stream >= 0 && wanted_stream_nb < 0) { - AVProgram *p = find_program_from_stream(ic, related_stream); + AVProgram *p = av_find_program_from_stream(ic, NULL, related_stream); if (p) { program = p->stream_index; nb_streams = p->nb_stream_indexes; |