[vlc-commits] [Git][videolan/vlc][3.0.x] 6 commits: demux:mp4: the local i_time in FragGetMoofByTfraIndex() is not an mtime_t
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun May 25 08:47:04 UTC 2025
Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC
Commits:
8cdf86bf by Steve Lhomme at 2025-05-25T07:58:53+00:00
demux:mp4: the local i_time in FragGetMoofByTfraIndex() is not an mtime_t
(cherry picked from commit c43b6de185878ea645982dcd0e8d1ddee240f769) (edited)
edited:
- in 4.0 it was done when mtime_t was still used
- - - - -
1f4c5ba3 by Steve Lhomme at 2025-05-25T07:58:53+00:00
demux: mp4: handle moof time outside of FragSeekLoadFragment()
(cherry picked from commit a9a8b3d0ded548ba7a20b571b4ece26c7cd508e6)
- - - - -
db25f697 by Steve Lhomme at 2025-05-25T07:58:53+00:00
demux: mp4: always set the p_sample_offset_pts to i_ctsdelta
The assignment is the same in all if/else cases.
(cherry picked from commit 58bbde65b1116a4784714691a1082646b3d5221e)
- - - - -
3ea20f62 by Steve Lhomme at 2025-05-25T07:58:53+00:00
demux: mp4: only set p_sys->i_nztime once for moov
(cherry picked from commit 656fc6e0094300f970d6ce92af6a65b1f1e10974)
- - - - -
4991e43d by Steve Lhomme at 2025-05-25T07:58:53+00:00
demux: mp4: remove redundant call
The same call is done below.
(cherry picked from commit 33384c7a9493f6671ef3b0954807d9ed048fba98)
- - - - -
09ded3f4 by Steve Lhomme at 2025-05-25T07:58:53+00:00
libmp4: always read the tfra data into 64 bits variables
We need to handle the worst case scenario anyway.
It should not take that much more memory and that avoids
casting pointers.
(cherry picked from commit 3e4bec57cfc24826aca3a80730353017156c14e8)
- - - - -
3 changed files:
- modules/demux/mp4/libmp4.c
- modules/demux/mp4/libmp4.h
- modules/demux/mp4/mp4.c
Changes:
=====================================
modules/demux/mp4/libmp4.c
=====================================
@@ -4280,9 +4280,9 @@ static int MP4_ReadBox_tfra( stream_t *p_stream, MP4_Box_t *p_box )
p_tfra->i_length_size_of_trun_num = ( i_lengths & 0x0c ) >> 2;
p_tfra->i_length_size_of_sample_num = i_lengths & 0x03;
- size_t size = 4 + 4*p_tfra->i_version; /* size in {4, 8} */
- p_tfra->p_time = calloc( i_number_of_entries, size );
- p_tfra->p_moof_offset = calloc( i_number_of_entries, size );
+ size_t size;
+ p_tfra->p_time = calloc( i_number_of_entries, sizeof(*p_tfra->p_time) );
+ p_tfra->p_moof_offset = calloc( i_number_of_entries, sizeof(*p_tfra->p_moof_offset) );
size = 1 + p_tfra->i_length_size_of_traf_num; /* size in [|1, 4|] */
if ( size == 3 ) size++;
@@ -4310,8 +4310,8 @@ static int MP4_ReadBox_tfra( stream_t *p_stream, MP4_Box_t *p_box )
{
if ( i_read < i_fields_length + 16 )
break;
- MP4_GET8BYTES( *((uint64_t *)&p_tfra->p_time[i*2]) );
- MP4_GET8BYTES( *((uint64_t *)&p_tfra->p_moof_offset[i*2]) );
+ MP4_GET8BYTES( p_tfra->p_time[i] );
+ MP4_GET8BYTES( p_tfra->p_moof_offset[i] );
}
else
{
@@ -4335,22 +4335,11 @@ static int MP4_ReadBox_tfra( stream_t *p_stream, MP4_Box_t *p_box )
#ifdef MP4_ULTRA_VERBOSE
for( i = 0; i < i_number_of_entries; i++ )
{
- if( p_tfra->i_version == 0 )
- {
- msg_Dbg( p_stream, "tfra[%"PRIu32"] time[%"PRIu32"]: %"PRIu32", "
- "moof_offset[%"PRIu32"]: %"PRIu32"",
- p_tfra->i_track_ID,
- i, p_tfra->p_time[i],
- i, p_tfra->p_moof_offset[i] );
- }
- else
- {
- msg_Dbg( p_stream, "tfra[%"PRIu32"] time[%"PRIu32"]: %"PRIu64", "
- "moof_offset[%"PRIu32"]: %"PRIu64"",
- p_tfra->i_track_ID,
- i, ((uint64_t *)(p_tfra->p_time))[i],
- i, ((uint64_t *)(p_tfra->p_moof_offset))[i] );
- }
+ msg_Dbg( p_stream, "tfra[%"PRIu32"] time[%"PRIu32"]: %"PRIu64", "
+ "moof_offset[%"PRIu32"]: %"PRIu64"",
+ p_tfra->i_track_ID,
+ i, p_tfra->p_time[i],
+ i, p_tfra->p_moof_offset[i] );
}
#endif
#ifdef MP4_VERBOSE
=====================================
modules/demux/mp4/libmp4.h
=====================================
@@ -1577,8 +1577,8 @@ typedef struct
uint8_t i_length_size_of_trun_num;
uint8_t i_length_size_of_sample_num;
- uint32_t *p_time;
- uint32_t *p_moof_offset;
+ uint64_t *p_time;
+ uint64_t *p_moof_offset;
uint8_t *p_traf_number;
uint8_t *p_trun_number;
uint8_t *p_sample_number;
=====================================
modules/demux/mp4/mp4.c
=====================================
@@ -1666,7 +1666,7 @@ static uint32_t FragGetMoofSequenceNumber( MP4_Box_t *p_moof )
return 0;
}
-static int FragSeekLoadFragment( demux_t *p_demux, uint32_t i_moox, stime_t i_moox_time )
+static int FragSeekLoadFragment( demux_t *p_demux, uint32_t i_moox )
{
demux_sys_t *p_sys = p_demux->p_sys;
MP4_Box_t *p_moox;
@@ -1700,15 +1700,6 @@ static int FragSeekLoadFragment( demux_t *p_demux, uint32_t i_moox, stime_t i_mo
p_sys->context.p_fragment_atom = p_moox;
p_sys->context.i_current_box_type = i_moox;
- if( i_moox == ATOM_moof )
- {
- FragPrepareChunk( p_demux, p_moox, NULL, i_moox_time, true );
- p_sys->context.i_lastseqnumber = FragGetMoofSequenceNumber( p_moox );
-
- p_sys->i_nztime = FragGetDemuxTimeFromTracksTime( p_sys );
- p_sys->i_pcr = VLC_TICK_INVALID;
- }
-
msg_Dbg( p_demux, "seeked to %4.4s at pos %" PRIu64, (char *) &i_moox, p_moox->i_pos );
return VLC_SUCCESS;
}
@@ -1855,11 +1846,23 @@ static int FragSeekToTime( demux_t *p_demux, vlc_tick_t i_nztime, bool b_accurat
}
/* Context is killed on success */
- if( FragSeekLoadFragment( p_demux, i_segment_type, i_segment_time ) != VLC_SUCCESS )
+ if( FragSeekLoadFragment( p_demux, i_segment_type ) != VLC_SUCCESS )
{
p_sys->b_error = (vlc_stream_Seek( p_demux->s, i_backup_pos ) != VLC_SUCCESS);
return VLC_EGENERIC;
}
+ if( i_segment_type == ATOM_moof )
+ {
+ MP4_Box_t *p_moox = p_sys->context.p_fragment_atom;
+ FragPrepareChunk( p_demux, p_moox, NULL, i_segment_time, true );
+ p_sys->context.i_lastseqnumber = FragGetMoofSequenceNumber( p_moox );
+
+ p_sys->i_nztime = FragGetDemuxTimeFromTracksTime( p_sys );
+ }
+ else
+ {
+ p_sys->i_nztime = i_sync_time;
+ }
p_sys->i_pcr = VLC_TICK_INVALID;
@@ -1868,7 +1871,6 @@ static int FragSeekToTime( demux_t *p_demux, vlc_tick_t i_nztime, bool b_accurat
if( i_segment_type == ATOM_moov )
{
MP4_TrackSeek( p_demux, &p_sys->track[i], i_sync_time );
- p_sys->i_nztime = i_sync_time;
p_sys->i_pcr = VLC_TICK_INVALID;
}
else
@@ -2800,12 +2802,12 @@ static int TrackCreateSamplesIndex( demux_t *p_demux,
int64_t i_ctsdelta = ctts->pi_sample_offset[i_index] + i_cts_shift;
if( i_ctsdelta < 0 ) /* should not */
i_ctsdelta = 0;
+ ck->p_sample_offset_pts[i] = i_ctsdelta;
if ( i_current_index_samples_left )
{
if ( i_current_index_samples_left > i_sample_count )
{
ck->p_sample_count_pts[i] = i_sample_count;
- ck->p_sample_offset_pts[i] = i_ctsdelta;
i_current_index_samples_left -= i_sample_count;
i_sample_count = 0;
assert( i == ck->i_entries_pts - 1 );
@@ -2814,7 +2816,6 @@ static int TrackCreateSamplesIndex( demux_t *p_demux,
else
{
ck->p_sample_count_pts[i] = i_current_index_samples_left;
- ck->p_sample_offset_pts[i] = i_ctsdelta;
i_sample_count -= i_current_index_samples_left;
i_current_index_samples_left = 0;
i_index++;
@@ -2825,7 +2826,6 @@ static int TrackCreateSamplesIndex( demux_t *p_demux,
if ( ctts->pi_sample_count[i_index] > i_sample_count )
{
ck->p_sample_count_pts[i] = i_sample_count;
- ck->p_sample_offset_pts[i] = i_ctsdelta;
i_current_index_samples_left = ctts->pi_sample_count[i_index] - i_sample_count;
i_sample_count = 0;
assert( i == ck->i_entries_pts - 1 );
@@ -2834,13 +2834,10 @@ static int TrackCreateSamplesIndex( demux_t *p_demux,
else
{
ck->p_sample_count_pts[i] = ctts->pi_sample_count[i_index];
- ck->p_sample_offset_pts[i] = i_ctsdelta;
i_sample_count -= ctts->pi_sample_count[i_index];
i_index++;
}
}
-
-
}
}
}
@@ -4906,18 +4903,8 @@ static int FragGetMoofByTfraIndex( demux_t *p_demux, const vlc_tick_t i_target_t
stime_t i_track_target_time = MP4_rescale_qtime( i_target_time, p_track->i_timescale );
for ( uint32_t i = 0; i<p_data->i_number_of_entries; i += ( p_data->i_version == 1 ) ? 2 : 1 )
{
- vlc_tick_t i_time;
- uint64_t i_offset;
- if ( p_data->i_version == 1 )
- {
- i_time = *((uint64_t *)(p_data->p_time + i));
- i_offset = *((uint64_t *)(p_data->p_moof_offset + i));
- }
- else
- {
- i_time = p_data->p_time[i];
- i_offset = p_data->p_moof_offset[i];
- }
+ stime_t i_time = p_data->p_time[i];
+ uint64_t i_offset = p_data->p_moof_offset[i];
if ( i_time >= i_track_target_time )
{
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6360e4f5f7ab0128a1563ffa717f32d5b7692582...09ded3f4092c662c7e962faf4358e14e292297db
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6360e4f5f7ab0128a1563ffa717f32d5b7692582...09ded3f4092c662c7e962faf4358e14e292297db
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