[FFmpeg-cvslog] Merge commit 'e1eb0fc960163402bbb4e630185790488f7d28ed'
Matthieu Bouron
git at videolan.org
Thu Jun 23 22:30:14 CEST 2016
ffmpeg | branch: master | Matthieu Bouron <matthieu.bouron at stupeflix.com> | Thu Jun 23 22:02:31 2016 +0200| [b1e1da52fe2e7320363fdaa0cdd276847e25bf53] | committer: Matthieu Bouron
Merge commit 'e1eb0fc960163402bbb4e630185790488f7d28ed'
* commit 'e1eb0fc960163402bbb4e630185790488f7d28ed':
movenc: Use packets in interleaving queues for the duration at the end of fragments
Merged-by: Matthieu Bouron <matthieu.bouron at stupeflix.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b1e1da52fe2e7320363fdaa0cdd276847e25bf53
---
libavformat/avformat.h | 4 ++++
libavformat/internal.h | 10 ++++++++++
libavformat/movenc.c | 22 ++++++++++++++++++++++
libavformat/movenc.h | 1 +
libavformat/mux.c | 11 +++++++++++
libavformat/version.h | 2 +-
6 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f66c39b..4eb1140 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2427,6 +2427,10 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt);
* increasing dts. Callers doing their own interleaving should call
* av_write_frame() instead of this function.
*
+ * Using this function instead of av_write_frame() can give muxers advance
+ * knowledge of future packets, improving e.g. the behaviour of the mp4
+ * muxer for VFR content in fragmenting mode.
+ *
* @param s media file handle
* @param pkt The packet containing the data to be written.
* <br>
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 9901527..6b7f677 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -620,4 +620,14 @@ int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *
*/
int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf);
+/**
+ * Find the next packet in the interleaving queue for the given stream.
+ * The packet is not removed from the interleaving queue, but only
+ * a pointer to it is returned.
+ *
+ * @return a pointer to the next packet, or NULL if no packet is queued
+ * for this stream.
+ */
+const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream);
+
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4e5f65f..0a79836 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4241,6 +4241,25 @@ static int mov_flush_fragment(AVFormatContext *s, int force)
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT))
return 0;
+ // Try to fill in the duration of the last packet in each stream
+ // from queued packets in the interleave queues. If the flushing
+ // of fragments was triggered automatically by an AVPacket, we
+ // already have reliable info for the end of that track, but other
+ // tracks may need to be filled in.
+ for (i = 0; i < s->nb_streams; i++) {
+ MOVTrack *track = &mov->tracks[i];
+ if (!track->end_reliable) {
+ AVPacket *next = ff_interleaved_peek(s, i);
+ if (next) {
+ track->track_duration = next->dts - track->start_dts;
+ if (next->pts != AV_NOPTS_VALUE)
+ track->end_pts = next->pts;
+ else
+ track->end_pts = next->dts;
+ }
+ }
+ }
+
for (i = 0; i < mov->nb_streams; i++) {
MOVTrack *track = &mov->tracks[i];
if (track->entry <= 1)
@@ -4316,6 +4335,7 @@ static int mov_flush_fragment(AVFormatContext *s, int force)
mov->tracks[i].track_duration -
mov->tracks[i].cluster[0].dts;
mov->tracks[i].entry = 0;
+ mov->tracks[i].end_reliable = 0;
}
avio_flush(s->pb);
return 0;
@@ -4395,6 +4415,7 @@ static int mov_flush_fragment(AVFormatContext *s, int force)
track->frag_start += duration;
track->entry = 0;
track->entries_flushed = 0;
+ track->end_reliable = 0;
if (!mov->frag_interleave) {
if (!track->mdat_buf)
continue;
@@ -4760,6 +4781,7 @@ static int mov_write_single_packet(AVFormatContext *s, AVPacket *pkt)
trk->end_pts = pkt->pts;
else
trk->end_pts = pkt->dts;
+ trk->end_reliable = 1;
mov_auto_flush_fragment(s, 0);
}
}
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 1090085..c4fded8 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -115,6 +115,7 @@ typedef struct MOVTrack {
int64_t start_dts;
int64_t start_cts;
int64_t end_pts;
+ int end_reliable;
int hint_track; ///< the track that hints this track, -1 if no hint track is set
int src_track; ///< the track that this hint (or tmcd) track describes
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 8488043..10b2750 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -1041,6 +1041,17 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out,
}
}
+const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream)
+{
+ AVPacketList *pktl = s->internal->packet_buffer;
+ while (pktl) {
+ if (pktl->pkt.stream_index == stream)
+ return &pktl->pkt;
+ pktl = pktl->next;
+ }
+ return NULL;
+}
+
/**
* Interleave an AVPacket correctly so it can be muxed.
* @param out the interleaved packet will be output here
diff --git a/libavformat/version.h b/libavformat/version.h
index 543afbb..544d436 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
// Also please add any ticket numbers that you belive might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 57
#define LIBAVFORMAT_VERSION_MINOR 40
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
======================================================================
diff --cc libavformat/internal.h
index 9901527,bbdfd2f..6b7f677
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@@ -569,55 -442,13 +569,65 @@@ int ffio_open2_wrapper(struct AVFormatC
void ff_format_io_close(AVFormatContext *s, AVIOContext **pb);
/**
+ * Parse creation_time in AVFormatContext metadata if exists and warn if the
+ * parsing fails.
+ *
+ * @param s AVFormatContext
+ * @param timestamp parsed timestamp in microseconds, only set on successful parsing
+ * @param return_seconds set this to get the number of seconds in timestamp instead of microseconds
+ * @return 1 if OK, 0 if the metadata was not present, AVERROR(EINVAL) on parse error
+ */
+int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds);
+
+/**
+ * Standardize creation_time metadata in AVFormatContext to an ISO-8601
+ * timestamp string.
+ *
+ * @param s AVFormatContext
+ * @return <0 on error
+ */
+int ff_standardize_creation_time(AVFormatContext *s);
+
+#define CONTAINS_PAL 2
+/**
+ * Reshuffles the lines to use the user specified stride.
+ *
+ * @param ppkt input and output packet
+ * @return negative error code or
+ * 0 if no new packet was allocated
+ * non-zero if a new packet was allocated and ppkt has to be freed
+ * CONTAINS_PAL if in addition to a new packet the old contained a palette
+ */
+int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters *par, int expected_stride);
+
+/**
+ * Retrieves the palette from a packet, either from side data, or
+ * appended to the video data in the packet itself (raw video only).
+ * It is commonly used after a call to ff_reshuffle_raw_rgb().
+ *
+ * Use 0 for the ret parameter to check for side data only.
+ *
+ * @param pkt pointer to packet before calling ff_reshuffle_raw_rgb()
+ * @param ret return value from ff_reshuffle_raw_rgb(), or 0
+ * @param palette pointer to palette buffer
+ * @return negative error code or
+ * 1 if the packet has a palette, else 0
+ */
+int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette);
+
+/**
+ * Finalize buf into extradata and set its size appropriately.
+ */
+int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf);
+
++/**
+ * Find the next packet in the interleaving queue for the given stream.
+ * The packet is not removed from the interleaving queue, but only
+ * a pointer to it is returned.
+ *
+ * @return a pointer to the next packet, or NULL if no packet is queued
+ * for this stream.
+ */
+ const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream);
+
#endif /* AVFORMAT_INTERNAL_H */
diff --cc libavformat/movenc.h
index 1090085,6c922fb..c4fded8
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@@ -115,9 -106,10 +115,10 @@@ typedef struct MOVTrack
int64_t start_dts;
int64_t start_cts;
int64_t end_pts;
+ int end_reliable;
int hint_track; ///< the track that hints this track, -1 if no hint track is set
- int src_track; ///< the track that this hint track describes
+ int src_track; ///< the track that this hint (or tmcd) track describes
AVFormatContext *rtp_ctx; ///< the format context for the hinting rtp muxer
uint32_t prev_rtp_ts;
int64_t cur_rtp_ts_unwrapped;
diff --cc libavformat/version.h
index 543afbb,1e1105f..544d436
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@@ -29,11 -29,9 +29,11 @@@
#include "libavutil/version.h"
-#define LIBAVFORMAT_VERSION_MAJOR 57
-#define LIBAVFORMAT_VERSION_MINOR 7
-#define LIBAVFORMAT_VERSION_MICRO 1
+// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
+// Also please add any ticket numbers that you belive might be affected here
+#define LIBAVFORMAT_VERSION_MAJOR 57
+#define LIBAVFORMAT_VERSION_MINOR 40
- #define LIBAVFORMAT_VERSION_MICRO 100
++#define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list