}
avio_wb32(pb, 0x00010000);
} else {
- start_ct = -FFMIN(track->cluster[0].dts, 0); //FFMIN needed due to rounding
+ /* Avoid accidentally ending up with start_ct = -1 which has got a
+ * special meaning. Normally start_ct should end up positive or zero
+ * here, but use FFMIN in case dts is a a small positive integer
+ * 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);
duration += delay;
}