[FFmpeg-cvslog] Rename find_program_from_stream to av_find_program_from_stream and add it to avformat .h

Marton Balint git at videolan.org
Sat Aug 27 22:07:48 CEST 2011


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Mon Aug 22 23:42:19 2011 +0200| [dacd827b81e442a3fbed0628a951c8f15f3591e3] | committer: Michael Niedermayer

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 at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dacd827b81e442a3fbed0628a951c8f15f3591e3
---

 doc/APIchanges         |    3 +++
 libavformat/avformat.h |   12 ++++++++++++
 libavformat/utils.c    |   18 ++++++++++++------
 libavformat/version.h  |    2 +-
 4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index d7ce15f..f3c4b23 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-08-22 - xxxxxx - lavf 53.10.0
+  Add av_find_program_from_stream().
+
 2011-08-20 - xxxxxx - lavu 51.13.0
   Add av_get_media_type_string().
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5e73f8d..e435881 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1233,6 +1233,18 @@ int av_find_stream_info(AVFormatContext *ic);
 int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);
 
 /**
+ * Find the programs which belong to a given stream.
+ *
+ * @param ic    media file handle
+ * @param last  the last found program, the search will start after this
+ *              program, or from the beginning if it is NULL
+ * @param s     stream index
+ * @return the next program which belongs to s, NULL if no program is found or
+ *         the last program is not among the programs of ic.
+ */
+AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s);
+
+/**
  * Find the "best" stream in the file.
  * The best stream is determined according to various heuristics as the most
  * likely to be what the user expects.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index a60fcd9..b935e40 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;
diff --git a/libavformat/version.h b/libavformat/version.h
index a8e516b..6d22be0 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -24,7 +24,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 53
-#define LIBAVFORMAT_VERSION_MINOR  9
+#define LIBAVFORMAT_VERSION_MINOR 10
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list