[SCM] libav/experimental: add ff_find_stream_index
siretart at users.alioth.debian.org
siretart at users.alioth.debian.org
Sun Jun 30 17:20:49 UTC 2013
The following commit has been merged in the experimental branch:
commit 141de5a9c141ab82ff453d4e9bb27fd4e25da1ea
Author: Peter Ross <pross at xvid.org>
Date: Sun Dec 26 01:24:51 2010 +0000
add ff_find_stream_index
Originally committed as revision 26092 to svn://svn.ffmpeg.org/ffmpeg/trunk
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index af2ee9d..d37a1d8 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -21,6 +21,7 @@
#include "libavutil/common.h"
#include "avformat.h"
+#include "internal.h"
#include "gxf.h"
struct gxf_stream_info {
@@ -77,10 +78,9 @@ static int gxf_probe(AVProbeData *p) {
static int get_sindex(AVFormatContext *s, int id, int format) {
int i;
AVStream *st = NULL;
- for (i = 0; i < s->nb_streams; i++) {
- if (s->streams[i]->id == id)
- return i;
- }
+ i = ff_find_stream_index(s, id);
+ if (i >= 0)
+ return i;
st = av_new_stream(s, id);
if (!st)
return AVERROR(ENOMEM);
diff --git a/libavformat/internal.h b/libavformat/internal.h
index d723f09..b401d35 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -220,4 +220,10 @@ typedef void (*ff_parse_key_val_cb)(void *context, const char *key,
void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
void *context);
+/**
+ * Find stream index based on format-specific stream ID
+ * @return stream index, or < 0 on error
+ */
+int ff_find_stream_index(AVFormatContext *s, int id);
+
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 61aa7d4..58e06e8 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3806,3 +3806,12 @@ void ff_parse_key_value(const char *str, ff_parse_key_val_cb callback_get_buf,
}
}
+int ff_find_stream_index(AVFormatContext *s, int id)
+{
+ int i;
+ for (i = 0; i < s->nb_streams; i++) {
+ if (s->streams[i]->id == id)
+ return i;
+ }
+ return -1;
+}
--
Libav/FFmpeg packaging
More information about the pkg-multimedia-commits
mailing list