summaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2019-05-19 00:43:29 +0200
committerMarton Balint <cus@passwd.hu>2019-05-24 21:39:07 +0200
commitf9271d0158122c9e043b7d83f691884b65ec1ba5 (patch)
tree37ae29059c502700204bc2b92bfafe284b1ff8f2 /libavformat/utils.c
parent50789e356d65270698d0d8495323ebe76a46091a (diff)
downloadffmpeg-streaming-f9271d0158122c9e043b7d83f691884b65ec1ba5.zip
ffmpeg-streaming-f9271d0158122c9e043b7d83f691884b65ec1ba5.tar.gz
avformat/utils: fix stream ordering for program ID stream specifiers
Fixes a regression introduced in dbfd042983eed8586d4048795c00af820f5b6b1f. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6ef9423..3d764c1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -5107,7 +5107,7 @@ AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *f
* >0 if st is a matching stream
*/
static int match_stream_specifier(AVFormatContext *s, AVStream *st,
- const char *spec, const char **indexptr)
+ const char *spec, const char **indexptr, AVProgram **p)
{
int match = 1; /* Stores if the specifier matches so far. */
while (*spec) {
@@ -5162,6 +5162,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
for (j = 0; j < s->programs[i]->nb_stream_indexes; j++) {
if (st->index == s->programs[i]->stream_index[j]) {
found = 1;
+ if (p)
+ *p = s->programs[i];
i = s->nb_programs;
break;
}
@@ -5264,8 +5266,10 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
int ret, index;
char *endptr;
const char *indexptr = NULL;
+ AVProgram *p = NULL;
+ int nb_streams;
- ret = match_stream_specifier(s, st, spec, &indexptr);
+ ret = match_stream_specifier(s, st, spec, &indexptr, &p);
if (ret < 0)
goto error;
@@ -5283,11 +5287,13 @@ int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
return (index == st->index);
/* If we requested a matching stream index, we have to ensure st is that. */
- for (int i = 0; i < s->nb_streams && index >= 0; i++) {
- ret = match_stream_specifier(s, s->streams[i], spec, NULL);
+ nb_streams = p ? p->nb_stream_indexes : s->nb_streams;
+ for (int i = 0; i < nb_streams && index >= 0; i++) {
+ AVStream *candidate = p ? s->streams[p->stream_index[i]] : s->streams[i];
+ ret = match_stream_specifier(s, candidate, spec, NULL, NULL);
if (ret < 0)
goto error;
- if (ret > 0 && index-- == 0 && st == s->streams[i])
+ if (ret > 0 && index-- == 0 && st == candidate)
return 1;
}
return 0;
OpenPOWER on IntegriCloud