1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

movenc: Use start_dts/cts instead of cluster[0] for writing edit lists

This allows writing edit lists even when track->entry == 0, if
the start times have been set.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2014-11-03 20:34:27 +02:00
parent 724cbea719
commit c725faebda

View File

@ -1613,8 +1613,8 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
track->timescale, AV_ROUND_UP); track->timescale, AV_ROUND_UP);
int version = duration < INT32_MAX ? 0 : 1; int version = duration < INT32_MAX ? 0 : 1;
int entry_size, entry_count, size; int entry_size, entry_count, size;
int64_t delay, start_ct = track->cluster[0].cts; int64_t delay, start_ct = track->start_cts;
delay = av_rescale_rnd(track->cluster[0].dts + start_ct, MOV_TIMESCALE, delay = av_rescale_rnd(track->start_dts + start_ct, MOV_TIMESCALE,
track->timescale, AV_ROUND_DOWN); track->timescale, AV_ROUND_DOWN);
version |= delay < INT32_MAX ? 0 : 1; version |= delay < INT32_MAX ? 0 : 1;
@ -1650,7 +1650,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
* special meaning. Normally start_ct should end up positive or zero * special meaning. Normally start_ct should end up positive or zero
* here, but use FFMIN in case dts is a a small positive integer * here, but use FFMIN in case dts is a a small positive integer
* rounded to 0 when represented in MOV_TIMESCALE units. */ * rounded to 0 when represented in MOV_TIMESCALE units. */
start_ct = -FFMIN(track->cluster[0].dts, 0); start_ct = -FFMIN(track->start_dts, 0);
/* Note, this delay is calculated from the pts of the first sample, /* Note, this delay is calculated from the pts of the first sample,
* ensuring that we don't reduce the duration for cases with * ensuring that we don't reduce the duration for cases with
* dts<0 pts=0. */ * dts<0 pts=0. */
@ -1774,9 +1774,9 @@ static int mov_write_trak_tag(AVIOContext *pb, MOVMuxContext *mov,
avio_wb32(pb, 0); /* size */ avio_wb32(pb, 0); /* size */
ffio_wfourcc(pb, "trak"); ffio_wfourcc(pb, "trak");
mov_write_tkhd_tag(pb, mov, track, st); mov_write_tkhd_tag(pb, mov, track, st);
if (track->entry && if (track->start_dts != AV_NOPTS_VALUE &&
(track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS || (track->mode == MODE_PSP || track->flags & MOV_TRACK_CTTS ||
track->cluster[0].dts || is_clcp_track(track))) { track->start_dts || is_clcp_track(track))) {
if (mov->use_editlist) if (mov->use_editlist)
mov_write_edts_tag(pb, mov, track); // PSP Movies require edts box mov_write_edts_tag(pb, mov, track); // PSP Movies require edts box
else if ((track->entry && track->cluster[0].dts) || track->mode == MODE_PSP || is_clcp_track(track)) else if ((track->entry && track->cluster[0].dts) || track->mode == MODE_PSP || is_clcp_track(track))