[vlc-commits] mux:mp4: the duration passed to mp4mux_GetMoovBox() is an mtime_t

Steve Lhomme git at videolan.org
Thu Jun 14 16:40:53 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Jun 11 17:45:58 2018 +0200| [50bad3eec6b769aa9e46f5ad89426a43be1f6814] | committer: Steve Lhomme

mux:mp4: the duration passed to mp4mux_GetMoovBox() is an mtime_t

We then scale it to the movie and use it scaled.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=50bad3eec6b769aa9e46f5ad89426a43be1f6814
---

 modules/mux/mp4/libmp4mux.c | 15 +++++++--------
 modules/mux/mp4/libmp4mux.h |  2 +-
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/modules/mux/mp4/libmp4mux.c b/modules/mux/mp4/libmp4mux.c
index 7b45db12ca..5b54d50528 100644
--- a/modules/mux/mp4/libmp4mux.c
+++ b/modules/mux/mp4/libmp4mux.c
@@ -1398,7 +1398,7 @@ static bo_t *GetStblBox(vlc_object_t *p_obj, mp4mux_trackinfo_t *p_track, bool b
 }
 
 bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
-                         int64_t i_movie_duration,
+                         mtime_t i_duration,
                          bool b_fragmented, bool b_mov, bool b_64_ext, bool b_stco64 )
 {
     bo_t            *moov, *mvhd;
@@ -1415,17 +1415,16 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
     if(!moov)
         return NULL;
     /* Create general info */
-    if( i_movie_duration == 0 && !b_fragmented )
+    if( i_duration == 0 && !b_fragmented )
     {
         for (unsigned int i = 0; i < i_tracks; i++) {
             mp4mux_trackinfo_t *p_stream = pp_tracks[i];
-            i_movie_duration = __MAX(i_movie_duration, p_stream->i_read_duration);
+            i_duration = __MAX(i_duration, p_stream->i_read_duration);
         }
         if(p_obj)
-            msg_Dbg(p_obj, "movie duration %"PRId64"s", i_movie_duration / CLOCK_FREQ);
-
-        i_movie_duration = i_movie_duration * i_movie_timescale / CLOCK_FREQ;
+            msg_Dbg(p_obj, "movie duration %"PRId64"s", i_duration / CLOCK_FREQ);
     }
+    int64_t i_movie_duration = i_duration * i_movie_timescale / CLOCK_FREQ;
 
     /* *** add /moov/mvhd *** */
     if (!b_64_ext) {
@@ -1796,9 +1795,9 @@ bo_t * mp4mux_GetMoovBox(vlc_object_t *p_obj, mp4mux_trackinfo_t **pp_tracks, un
                 if(mehd)
                 {
                     if(b_64_ext)
-                        bo_add_64be(mehd, i_movie_duration * i_movie_timescale / CLOCK_FREQ);
+                        bo_add_64be(mehd, i_movie_duration);
                     else
-                        bo_add_32be(mehd, i_movie_duration * i_movie_timescale / CLOCK_FREQ);
+                        bo_add_32be(mehd, i_movie_duration);
                     box_gather(mvex, mehd);
                 }
             }
diff --git a/modules/mux/mp4/libmp4mux.h b/modules/mux/mp4/libmp4mux.h
index 12df3017f2..36f8052f9a 100644
--- a/modules/mux/mp4/libmp4mux.h
+++ b/modules/mux/mp4/libmp4mux.h
@@ -85,5 +85,5 @@ void  box_gather  (bo_t *box, bo_t *box2);
 bool mp4mux_CanMux(vlc_object_t *, const es_format_t *, vlc_fourcc_t, bool);
 bo_t *mp4mux_GetFtyp(vlc_fourcc_t, uint32_t, vlc_fourcc_t[], size_t i_fourcc);
 bo_t *mp4mux_GetMoovBox(vlc_object_t *, mp4mux_trackinfo_t **pp_tracks, unsigned int i_tracks,
-                        int64_t i_movie_duration,
+                        mtime_t i_movie_duration,
                         bool b_fragmented, bool b_mov, bool b_64ext, bool b_stco64);



More information about the vlc-commits mailing list