summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorYusuke Nakamura <muken.the.vfrmaniac@gmail.com>2011-06-05 02:45:54 +0900
committerMichael Niedermayer <michaelni@gmx.at>2011-10-28 01:37:50 +0200
commit05e417aa63ef73b3c3a767c334f6c53abdb1ea20 (patch)
tree3871caf8bb2327c4c8417f29591afcd693a7046c /libavformat
parente7f008a53406e17c91d4fd12ffd140baac2560ff (diff)
mov: Support empty first edit + normal second edit.
(cherry picked from commit df342c91e6cfceb2537c2d1b2442dd685381a0ca) Reviewed-by: Baptiste Coudurier Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/isom.h4
-rw-r--r--libavformat/mov.c17
2 files changed, 13 insertions, 8 deletions
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 7fc2b546f8..9269799e5e 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -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;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index f1ceb56e9f..03f01e05d5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -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)