[vlc-commits] [Git][videolan/vlc][master] demux: mp4: fallback on timescale when rate is invalid

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Apr 23 13:01:14 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
38c101e3 by François Cartegnie at 2024-04-23T11:21:16+00:00
demux: mp4: fallback on timescale when rate is invalid

We could, but dont really want to patch audio rate from timescale,
as it could be meaningless for some codecs.

refs #28560

- - - - -


1 changed file:

- modules/demux/mp4/mp4.c


Changes:

=====================================
modules/demux/mp4/mp4.c
=====================================
@@ -3277,6 +3277,7 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
                 case VLC_CODEC_MP2:
                 case VLC_CODEC_MPGA:
                 {
+                    const unsigned i_rate = p_fmt->audio.i_rate ? p_fmt->audio.i_rate : p_track->i_timescale;
                     const MP4_Box_t *p_elst = p_track->p_elst;
                     if( p_elst && BOXDATA(p_elst)->i_entry_count &&
                         BOXDATA(p_elst)->entries[0].i_media_time < 0 )
@@ -3288,14 +3289,14 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
                     else if( p_sys->qt.i_delay_samples > 0 )
                     {
                         p_track->i_decoder_delay =  MP4_rescale_qtime(
-                                    vlc_tick_from_samples( p_sys->qt.i_delay_samples, p_fmt->audio.i_rate ),
+                                    vlc_tick_from_samples( p_sys->qt.i_delay_samples, i_rate ),
                                     p_track->i_timescale );
                     }
                     /* AAC historical Apple decoder delay 2112 > 2048 */
                     else if( p_fmt->i_codec == VLC_CODEC_MP4A )
                     {
                         p_track->i_decoder_delay =  MP4_rescale_qtime(
-                                    vlc_tick_from_samples( 2112, p_fmt->audio.i_rate ),
+                                    vlc_tick_from_samples( 2112, i_rate ),
                                     p_track->i_timescale );
                     }
                     /* Opus has an expected 80ms discard on seek */
@@ -3312,14 +3313,14 @@ static int TrackCreateES( demux_t *p_demux, mp4_track_t *p_track,
                          * https://www.compuphase.com/mp3/mp3loops.htm
                            https://www.iis.fraunhofer.de/content/dam/iis/de/doc/ame/conference/AES-116-Convention_guideline-to-audio-codec-delay_AES116.pdf */
                         p_track->i_decoder_delay =  MP4_rescale_qtime(
-                                    vlc_tick_from_samples( 576, p_fmt->audio.i_rate ),
+                                    vlc_tick_from_samples( 576, i_rate ),
                                     p_track->i_timescale );
                     }
                     else if( p_fmt->i_codec == VLC_CODEC_MPGA ||
                              p_fmt->i_codec == VLC_CODEC_MP2 )
                     {
                         p_track->i_decoder_delay =  MP4_rescale_qtime(
-                                    vlc_tick_from_samples( 240, p_fmt->audio.i_rate ),
+                                    vlc_tick_from_samples( 240, i_rate ),
                                     p_track->i_timescale );
                     }
                 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/38c101e34b5d35e18d2d71e2cc9fb1567ed3b24b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/38c101e34b5d35e18d2d71e2cc9fb1567ed3b24b
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