summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-12 22:48:17 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-10-12 22:48:49 +0200
commit687cc836ea0114b188bb088ae6df85daeb9acd4f (patch)
tree016d1be0fd26b61271f0d0e83e6e2749293547a1 /libavformat
parent031285dedf6638f0a84c2c4eb947d00f3fb32f2f (diff)
parent95ee4e2ce774e0339632d067161596bf3dadfc72 (diff)
Merge commit '95ee4e2ce774e0339632d067161596bf3dadfc72'
* commit '95ee4e2ce774e0339632d067161596bf3dadfc72': movenc: Add some comments explaining subtle details in writing the edit lists Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/movenc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c7fc12da82..df18de80ef 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2211,6 +2211,11 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track)
avio_wb32(pb, entry_count);
if (delay > 0) { /* add an empty edit to delay presentation */
+ /* In the positive delay case, the delay includes the cts
+ * offset, and the second edit list entry below trims out
+ * the same amount from the actual content. This makes sure
+ * that the offsetted last sample is included in the edit
+ * list duration as well. */
if (version == 1) {
avio_wb64(pb, delay);
avio_wb64(pb, -1);
@@ -2226,6 +2231,9 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVTrack *track)
* rounded to 0 when represented in MOV_TIMESCALE units. */
av_assert0(av_rescale_rnd(track->cluster[0].dts, MOV_TIMESCALE, track->timescale, AV_ROUND_DOWN) <= 0);
start_ct = -FFMIN(track->cluster[0].dts, 0);
+ /* Note, this delay is calculated from the pts of the first sample,
+ * ensuring that we don't reduce the duration for cases with
+ * dts<0 pts=0. */
duration += delay;
}