Those streams should never get any packets by definition.
Anton Khirnov authored on 2014/01/20 21:59:06... | ... |
@@ -796,6 +796,8 @@ typedef struct AVChapter { |
796 | 796 |
AVDictionary *metadata; |
797 | 797 |
} AVChapter; |
798 | 798 |
|
799 |
+typedef struct AVFormatInternal AVFormatInternal; |
|
800 |
+ |
|
799 | 801 |
/** |
800 | 802 |
* Format I/O context. |
801 | 803 |
* New fields can be added to the end with minor version bumps. |
... | ... |
@@ -1049,6 +1051,11 @@ typedef struct AVFormatContext { |
1049 | 1049 |
*/ |
1050 | 1050 |
AVRational offset_timebase; |
1051 | 1051 |
|
1052 |
+ /** |
|
1053 |
+ * An opaque field for libavformat internal usage. |
|
1054 |
+ * Must not be accessed in any way by callers. |
|
1055 |
+ */ |
|
1056 |
+ AVFormatInternal *internal; |
|
1052 | 1057 |
} AVFormatContext; |
1053 | 1058 |
|
1054 | 1059 |
typedef struct AVPacketList { |
... | ... |
@@ -42,6 +42,14 @@ typedef struct CodecMime{ |
42 | 42 |
enum AVCodecID id; |
43 | 43 |
} CodecMime; |
44 | 44 |
|
45 |
+struct AVFormatInternal { |
|
46 |
+ /** |
|
47 |
+ * Number of streams relevant for interleaving. |
|
48 |
+ * Muxing only. |
|
49 |
+ */ |
|
50 |
+ int nb_interleaved_streams; |
|
51 |
+}; |
|
52 |
+ |
|
45 | 53 |
void ff_dynarray_add(intptr_t **tab_ptr, int *nb_ptr, intptr_t elem); |
46 | 54 |
|
47 | 55 |
#ifdef __GNUC__ |
... | ... |
@@ -232,6 +232,9 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options) |
232 | 232 |
av_log(s, AV_LOG_WARNING, |
233 | 233 |
"Codec for stream %d does not use global headers " |
234 | 234 |
"but container format requires global headers\n", i); |
235 |
+ |
|
236 |
+ if (codec->codec_type != AVMEDIA_TYPE_ATTACHMENT) |
|
237 |
+ s->internal->nb_interleaved_streams++; |
|
235 | 238 |
} |
236 | 239 |
|
237 | 240 |
if (!s->priv_data && of->priv_data_size > 0) { |
... | ... |
@@ -541,7 +544,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, |
541 | 541 |
for (i = 0; i < s->nb_streams; i++) |
542 | 542 |
stream_count += !!s->streams[i]->last_in_packet_buffer; |
543 | 543 |
|
544 |
- if (stream_count && (s->nb_streams == stream_count || flush)) { |
|
544 |
+ if (stream_count && (s->internal->nb_interleaved_streams == stream_count || flush)) { |
|
545 | 545 |
pktl = s->packet_buffer; |
546 | 546 |
*out = pktl->pkt; |
547 | 547 |
|
... | ... |
@@ -19,6 +19,7 @@ |
19 | 19 |
*/ |
20 | 20 |
#include "avformat.h" |
21 | 21 |
#include "avio_internal.h" |
22 |
+#include "internal.h" |
|
22 | 23 |
#include "libavutil/opt.h" |
23 | 24 |
|
24 | 25 |
/** |
... | ... |
@@ -100,6 +101,13 @@ AVFormatContext *avformat_alloc_context(void) |
100 | 100 |
ic = av_malloc(sizeof(AVFormatContext)); |
101 | 101 |
if (!ic) return ic; |
102 | 102 |
avformat_get_context_defaults(ic); |
103 |
+ |
|
104 |
+ ic->internal = av_mallocz(sizeof(*ic->internal)); |
|
105 |
+ if (!ic->internal) { |
|
106 |
+ avformat_free_context(ic); |
|
107 |
+ return NULL; |
|
108 |
+ } |
|
109 |
+ |
|
103 | 110 |
return ic; |
104 | 111 |
} |
105 | 112 |
|