[FFmpeg-cvslog] lavf: ignore attachment streams for interleaving purposes

Anton Khirnov git at videolan.org
Tue Feb 4 16:07:42 CET 2014


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Jan 20 13:59:06 2014 +0100| [33c859c142ef3f49b7a6227014ad92a680cf4d74] | committer: Anton Khirnov

lavf: ignore attachment streams for interleaving purposes

Those streams should never get any packets by definition.

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

 libavformat/avformat.h |    7 +++++++
 libavformat/internal.h |    8 ++++++++
 libavformat/mux.c      |    5 ++++-
 libavformat/options.c  |    8 ++++++++
 libavformat/utils.c    |    1 +
 5 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 50e4f5c..00380d7 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -796,6 +796,8 @@ typedef struct AVChapter {
     AVDictionary *metadata;
 } AVChapter;
 
+typedef struct AVFormatInternal AVFormatInternal;
+
 /**
  * Format I/O context.
  * New fields can be added to the end with minor version bumps.
@@ -1049,6 +1051,11 @@ typedef struct AVFormatContext {
      */
     AVRational offset_timebase;
 
+    /**
+     * An opaque field for libavformat internal usage.
+     * Must not be accessed in any way by callers.
+     */
+    AVFormatInternal *internal;
 } AVFormatContext;
 
 typedef struct AVPacketList {
diff --git a/libavformat/internal.h b/libavformat/internal.h
index e92f476..0e7eb36 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -42,6 +42,14 @@ typedef struct CodecMime{
     enum AVCodecID id;
 } CodecMime;
 
+struct AVFormatInternal {
+    /**
+     * Number of streams relevant for interleaving.
+     * Muxing only.
+     */
+    int nb_interleaved_streams;
+};
+
 void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem);
 
 #ifdef __GNUC__
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 24c4932..06dacea 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -232,6 +232,9 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
             av_log(s, AV_LOG_WARNING,
                    "Codec for stream %d does not use global headers "
                    "but container format requires global headers\n", i);
+
+        if (codec->codec_type != AVMEDIA_TYPE_ATTACHMENT)
+            s->internal->nb_interleaved_streams++;
     }
 
     if (!s->priv_data && of->priv_data_size > 0) {
@@ -541,7 +544,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
     for (i = 0; i < s->nb_streams; i++)
         stream_count += !!s->streams[i]->last_in_packet_buffer;
 
-    if (stream_count && (s->nb_streams == stream_count || flush)) {
+    if (stream_count && (s->internal->nb_interleaved_streams == stream_count || flush)) {
         pktl = s->packet_buffer;
         *out = pktl->pkt;
 
diff --git a/libavformat/options.c b/libavformat/options.c
index d99f04a..a5646df 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -19,6 +19,7 @@
  */
 #include "avformat.h"
 #include "avio_internal.h"
+#include "internal.h"
 #include "libavutil/opt.h"
 
 /**
@@ -100,6 +101,13 @@ AVFormatContext *avformat_alloc_context(void)
     ic = av_malloc(sizeof(AVFormatContext));
     if (!ic) return ic;
     avformat_get_context_defaults(ic);
+
+    ic->internal = av_mallocz(sizeof(*ic->internal));
+    if (!ic->internal) {
+        avformat_free_context(ic);
+        return NULL;
+    }
+
     return ic;
 }
 
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 01215ef..fca588b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2633,6 +2633,7 @@ void avformat_free_context(AVFormatContext *s)
     av_freep(&s->chapters);
     av_dict_free(&s->metadata);
     av_freep(&s->streams);
+    av_freep(&s->internal);
     av_free(s);
 }
 



More information about the ffmpeg-cvslog mailing list