[FFmpeg-cvslog] mov: Support empty first edit + normal second edit.
Yusuke Nakamura
git at videolan.org
Fri Oct 28 01:47:18 CEST 2011
ffmpeg | branch: master | Yusuke Nakamura <muken.the.vfrmaniac at gmail.com> | Sun Jun 5 02:45:54 2011 +0900| [05e417aa63ef73b3c3a767c334f6c53abdb1ea20] | committer: Michael Niedermayer
mov: Support empty first edit + normal second edit.
(cherry picked from commit df342c91e6cfceb2537c2d1b2442dd685381a0ca)
Reviewed-by: Baptiste Coudurier
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=05e417aa63ef73b3c3a767c334f6c53abdb1ea20
---
libavformat/isom.h | 4 +++-
libavformat/mov.c | 17 ++++++++++-------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 7fc2b54..9269799 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 f1ceb56..03f01e0 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)
More information about the ffmpeg-cvslog
mailing list