[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: mp4: use fonction to convert movie time to milliseconds

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Aug 25 08:12:55 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
cd60aa71 by Steve Lhomme at 2025-08-25T07:56:28+00:00
demux: mp4: use fonction to convert movie time to milliseconds

- - - - -
b251b0a7 by Steve Lhomme at 2025-08-25T07:56:28+00:00
demux: mp4: handle integer overflow in movietime_to_ms()

Similar to how it's done in MP4_rescale().

Fixes #29259

- - - - -


1 changed file:

- modules/demux/mp4/fragments.c


Changes:

=====================================
modules/demux/mp4/fragments.c
=====================================
@@ -94,6 +94,21 @@ bool MP4_Fragments_Index_Lookup( mp4_fragments_index_t *p_index, stime_t *pi_tim
 }
 
 #ifdef MP4_VERBOSE
+static inline int64_t movietime_to_ms(stime_t time, uint32_t i_movie_timescale)
+{
+    if( i_movie_timescale == INT64_C( 1000 ) )
+        return time;
+
+    if( time <= INT64_MAX / INT64_C( 1000 ) )
+        return time * INT64_C( 1000 ) / i_movie_timescale;
+
+    /* overflow */
+    int64_t q = time / i_movie_timescale;
+    int64_t r = time % i_movie_timescale;
+    return q * INT64_C( 1000 ) + r * INT64_C( 1000 ) / i_movie_timescale;
+    return INT64_C( 1000 ) * time / i_movie_timescale;
+}
+
 void MP4_Fragments_Index_Dump( vlc_object_t *p_obj, const mp4_fragments_index_t *p_index,
                                uint32_t i_movie_timescale )
 {
@@ -112,7 +127,7 @@ void MP4_Fragments_Index_Dump( vlc_object_t *p_obj, const mp4_fragments_index_t
             char *psz_start = NULL;
             if( 0 < asprintf( &psz_start, "%s [%u]%"PRId64"ms ",
                       (psz_starts) ? psz_starts : "", j,
-                  INT64_C( 1000 ) * p_index->p_times[i * p_index->i_tracks + j] / i_movie_timescale ) )
+                  movietime_to_ms(p_index->p_times[i * p_index->i_tracks + j], i_movie_timescale) ) )
             {
                 free( psz_starts );
                 psz_starts = psz_start;
@@ -121,7 +136,7 @@ void MP4_Fragments_Index_Dump( vlc_object_t *p_obj, const mp4_fragments_index_t
 
         msg_Dbg( p_obj, "fragment offset @%"PRId64" %"PRId64"ms, start %s",
                  p_index->pi_pos[i],
-                 INT64_C( 1000 ) * i_end / i_movie_timescale, psz_starts );
+                 movietime_to_ms( i_end, i_movie_timescale ), psz_starts );
 
         free( psz_starts );
     }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dd8256bfdb821871b7e25e32d5fb325cb679c5e6...b251b0a7e811bfa0b0550824a8e5e571947afd6c

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/dd8256bfdb821871b7e25e32d5fb325cb679c5e6...b251b0a7e811bfa0b0550824a8e5e571947afd6c
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list