Commit 05e417aa authored by Yusuke Nakamura's avatar Yusuke Nakamura Committed by Michael Niedermayer

mov: Support empty first edit + normal second edit.

(cherry picked from commit df342c91e6cfceb2537c2d1b2442dd685381a0ca)

Reviewed-by: Baptiste Coudurier
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent e7f008a5
......@@ -109,7 +109,9 @@ typedef struct MOVStreamContext {
unsigned int keyframe_count;
int *keyframes;
int time_scale;
int64_t time_offset; ///< time offset of the first edit list entry
int64_t empty_duration; ///< empty duration of the first edit list entry
int64_t start_time; ///< start time of the media
int64_t time_offset; ///< time offset of the edit list entries
int current_sample;
unsigned int bytes_per_frame;
unsigned int samples_per_frame;
......
......@@ -1651,9 +1651,10 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
uint64_t stream_size = 0;
/* adjust first dts according to edit list */
if (sc->time_offset && mov->time_scale > 0) {
if (sc->time_offset < 0)
sc->time_offset = av_rescale(sc->time_offset, sc->time_scale, mov->time_scale);
if ((sc->empty_duration || sc->start_time) && mov->time_scale > 0) {
if (sc->empty_duration)
sc->empty_duration = av_rescale(sc->empty_duration, sc->time_scale, mov->time_scale);
sc->time_offset = sc->start_time - sc->empty_duration;
current_dts = -sc->time_offset;
if (sc->ctts_data && sc->stts_data &&
sc->ctts_data[0].duration / FFMAX(sc->stts_data[0].duration, 1) > 16) {
......@@ -2297,7 +2298,7 @@ free_and_return:
static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
MOVStreamContext *sc;
int i, edit_count, version;
int i, edit_count, version, edit_start_index = 0;
if (c->fc->nb_streams < 1)
return 0;
......@@ -2321,9 +2322,11 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom)
time = (int32_t)avio_rb32(pb); /* media time */
}
avio_rb32(pb); /* Media rate */
if (i == 0 && time >= -1) {
sc->time_offset = time != -1 ? time : -duration;
}
if (i == 0 && time == -1) {
sc->empty_duration = duration;
edit_start_index = 1;
} else if (i == edit_start_index && time >= 0)
sc->start_time = time;
}
if (edit_count > 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment