* commit '33c859c142ef3f49b7a6227014ad92a680cf4d74':
lavf: ignore attachment streams for interleaving purposes
Conflicts:
libavformat/avformat.h
libavformat/internal.h
libavformat/mux.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -971,6 +971,8 @@ enum AVDurationEstimationMethod { |
971 | 971 |
AVFMT_DURATION_FROM_BITRATE ///< Duration estimated from bitrate (less accurate) |
972 | 972 |
}; |
973 | 973 |
|
974 |
+typedef struct AVFormatInternal AVFormatInternal; |
|
975 |
+ |
|
974 | 976 |
/** |
975 | 977 |
* Format I/O context. |
976 | 978 |
* New fields can be added to the end with minor version bumps. |
... | ... |
@@ -1332,6 +1334,12 @@ typedef struct AVFormatContext { |
1332 | 1332 |
AVRational offset_timebase; |
1333 | 1333 |
|
1334 | 1334 |
/** |
1335 |
+ * An opaque field for libavformat internal usage. |
|
1336 |
+ * Must not be accessed in any way by callers. |
|
1337 |
+ */ |
|
1338 |
+ AVFormatInternal *internal; |
|
1339 |
+ |
|
1340 |
+ /** |
|
1335 | 1341 |
* IO repositioned flag. |
1336 | 1342 |
* This is set by avformat when the underlaying IO context read pointer |
1337 | 1343 |
* is repositioned, for example when doing byte based seeking. |
... | ... |
@@ -46,6 +46,14 @@ typedef struct CodecMime{ |
46 | 46 |
enum AVCodecID id; |
47 | 47 |
} CodecMime; |
48 | 48 |
|
49 |
+struct AVFormatInternal { |
|
50 |
+ /** |
|
51 |
+ * Number of streams relevant for interleaving. |
|
52 |
+ * Muxing only. |
|
53 |
+ */ |
|
54 |
+ int nb_interleaved_streams; |
|
55 |
+}; |
|
56 |
+ |
|
49 | 57 |
#ifdef __GNUC__ |
50 | 58 |
#define dynarray_add(tab, nb_ptr, elem)\ |
51 | 59 |
do {\ |
... | ... |
@@ -320,6 +320,9 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options) |
320 | 320 |
av_log(s, AV_LOG_WARNING, |
321 | 321 |
"Codec for stream %d does not use global headers " |
322 | 322 |
"but container format requires global headers\n", i); |
323 |
+ |
|
324 |
+ if (codec->codec_type != AVMEDIA_TYPE_ATTACHMENT) |
|
325 |
+ s->internal->nb_interleaved_streams++; |
|
323 | 326 |
} |
324 | 327 |
|
325 | 328 |
if (!s->priv_data && of->priv_data_size > 0) { |
... | ... |
@@ -727,7 +730,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, |
727 | 727 |
} |
728 | 728 |
} |
729 | 729 |
|
730 |
- if (s->nb_streams == stream_count) { |
|
730 |
+ if (s->internal->nb_interleaved_streams == stream_count) { |
|
731 | 731 |
flush = 1; |
732 | 732 |
} else if (!flush) { |
733 | 733 |
for (i=0; i < s->nb_streams; i++) { |
... | ... |
@@ -742,7 +745,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, |
742 | 742 |
delta_dts_max= FFMAX(delta_dts_max, delta_dts); |
743 | 743 |
} |
744 | 744 |
} |
745 |
- if (s->nb_streams == stream_count+noninterleaved_count && |
|
745 |
+ if (s->internal->nb_interleaved_streams == stream_count+noninterleaved_count && |
|
746 | 746 |
delta_dts_max > 20*AV_TIME_BASE) { |
747 | 747 |
av_log(s, AV_LOG_DEBUG, "flushing with %d noninterleaved\n", noninterleaved_count); |
748 | 748 |
flush = 1; |
... | ... |
@@ -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 |
/** |
... | ... |
@@ -109,6 +110,13 @@ AVFormatContext *avformat_alloc_context(void) |
109 | 109 |
ic = av_malloc(sizeof(AVFormatContext)); |
110 | 110 |
if (!ic) return ic; |
111 | 111 |
avformat_get_context_defaults(ic); |
112 |
+ |
|
113 |
+ ic->internal = av_mallocz(sizeof(*ic->internal)); |
|
114 |
+ if (!ic->internal) { |
|
115 |
+ avformat_free_context(ic); |
|
116 |
+ return NULL; |
|
117 |
+ } |
|
118 |
+ |
|
112 | 119 |
return ic; |
113 | 120 |
} |
114 | 121 |
|