[FFmpeg-cvslog] r26092 - in trunk/libavformat: gxf.c internal.h utils.c
pross
subversion
Sun Dec 26 02:24:51 CET 2010
Author: pross
Date: Sun Dec 26 02:24:51 2010
New Revision: 26092
Log:
add ff_find_stream_index
Modified:
trunk/libavformat/gxf.c
trunk/libavformat/internal.h
trunk/libavformat/utils.c
Modified: trunk/libavformat/gxf.c
==============================================================================
--- trunk/libavformat/gxf.c Sun Dec 26 02:23:44 2010 (r26091)
+++ trunk/libavformat/gxf.c Sun Dec 26 02:24:51 2010 (r26092)
@@ -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);
Modified: trunk/libavformat/internal.h
==============================================================================
--- trunk/libavformat/internal.h Sun Dec 26 02:23:44 2010 (r26091)
+++ trunk/libavformat/internal.h Sun Dec 26 02:24:51 2010 (r26092)
@@ -220,4 +220,10 @@ typedef void (*ff_parse_key_val_cb)(void
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 */
Modified: trunk/libavformat/utils.c
==============================================================================
--- trunk/libavformat/utils.c Sun Dec 26 02:23:44 2010 (r26091)
+++ trunk/libavformat/utils.c Sun Dec 26 02:24:51 2010 (r26092)
@@ -3806,3 +3806,12 @@ void ff_parse_key_value(const char *str,
}
}
+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;
+}
More information about the ffmpeg-cvslog
mailing list