[vlc-commits] demux: mp4: work with edit lists with CLOCK_FREQ

Francois Cartegnie git at videolan.org
Fri Jan 5 17:53:58 CET 2018


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Jan  4 17:41:46 2018 +0100| [0be2840fe1e948664c23cb93f04f4021904210b6] | committer: Jean-Baptiste Kempf

demux: mp4: work with edit lists with CLOCK_FREQ

as the track -> movie timescale conversion isn't guaranteed

(cherry picked from commit 35d7ea5e1920ba3b38ac723c83a9be284f3caf10)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=0be2840fe1e948664c23cb93f04f4021904210b6
---

 modules/demux/mp4/libmp4.h | 4 ++--
 modules/demux/mp4/mp4.c    | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index 40ea649f00..9dcd7980cf 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -941,8 +941,8 @@ typedef struct MP4_Box_data_elst_s
 
     uint32_t i_entry_count;
 
-    uint64_t *i_segment_duration;
-    int64_t  *i_media_time;
+    uint64_t *i_segment_duration; /* movie timescale */
+    int64_t  *i_media_time; /* media(track) timescale */
     uint16_t *i_media_rate_integer;
     uint16_t *i_media_rate_fraction;
 
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 9fb204b212..50778092f6 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -317,6 +317,8 @@ static inline int64_t MP4_TrackGetDTS( demux_t *p_demux, mp4_track_t *p_track )
         }
     }
 
+    i_dts = MP4_rescale( i_dts, p_track->i_timescale, CLOCK_FREQ );
+
     /* now handle elst */
     if( p_track->p_elst && p_track->BOXDATA(p_elst)->i_entry_count )
     {
@@ -327,16 +329,16 @@ static inline int64_t MP4_TrackGetDTS( demux_t *p_demux, mp4_track_t *p_track )
               elst->i_media_rate_fraction[p_track->i_elst] > 0 ) &&
             elst->i_media_time[p_track->i_elst] > 0 )
         {
-            i_dts -= elst->i_media_time[p_track->i_elst];
+            i_dts -= MP4_rescale( elst->i_media_time[p_track->i_elst], p_track->i_timescale, CLOCK_FREQ );
         }
 
         /* add i_elst_time */
-        i_dts += MP4_rescale( p_track->i_elst_time, p_sys->i_timescale, p_track->i_timescale );
+        i_dts += MP4_rescale( p_track->i_elst_time, p_sys->i_timescale, CLOCK_FREQ );
 
         if( i_dts < 0 ) i_dts = 0;
     }
 
-    return MP4_rescale( i_dts, p_track->i_timescale, CLOCK_FREQ );
+    return i_dts;
 }
 
 static inline bool MP4_TrackGetPTSDelta( demux_t *p_demux, mp4_track_t *p_track,



More information about the vlc-commits mailing list