[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: ts: use unsigned offsets for probing
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Wed Sep 10 19:38:44 UTC 2025
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
7a6cb54f by François Cartegnie at 2025-09-10T19:08:48+00:00
demux: ts: use unsigned offsets for probing
- - - - -
d26c0f56 by François Cartegnie at 2025-09-10T19:08:48+00:00
demux: ts: avoid resync when probing end
- - - - -
1 changed file:
- modules/demux/mpeg/ts.c
Changes:
=====================================
modules/demux/mpeg/ts.c
=====================================
@@ -2166,16 +2166,22 @@ int ProbeStart( demux_t *p_demux, int i_program )
{
demux_sys_t *p_sys = p_demux->p_sys;
const uint64_t i_initial_pos = vlc_stream_Tell( p_sys->stream );
- int64_t i_stream_size = stream_Size( p_sys->stream );
+ uint64_t i_stream_size;
+ if( vlc_stream_GetSize( p_sys->stream, &i_stream_size ) != VLC_SUCCESS )
+ return VLC_EGENERIC;
+
+ if( i_stream_size < p_sys->i_packet_size )
+ return VLC_EGENERIC;
- int i_probe_count = 0;
- int64_t i_pos;
+ unsigned i_probe_count = 0;
+ uint64_t i_pos;
bool b_found = false;
do
{
- i_pos = (int64_t)p_sys->i_packet_size * i_probe_count;
- i_pos = __MIN( i_pos, i_stream_size );
+ i_pos = p_sys->i_packet_size * i_probe_count;
+ if( i_pos > i_stream_size - p_sys->i_packet_size )
+ break;
if( vlc_stream_Seek( p_sys->stream, i_pos ) )
return VLC_EGENERIC;
@@ -2199,16 +2205,26 @@ int ProbeEnd( demux_t *p_demux, int i_program )
{
demux_sys_t *p_sys = p_demux->p_sys;
const uint64_t i_initial_pos = vlc_stream_Tell( p_sys->stream );
- int64_t i_stream_size = stream_Size( p_sys->stream );
+ uint64_t i_stream_size;
+ if( vlc_stream_GetSize( p_sys->stream, &i_stream_size ) != VLC_SUCCESS )
+ return VLC_EGENERIC;
- int i_probe_count = PROBE_CHUNK_COUNT;
- int64_t i_pos;
+ unsigned i_probe_count = PROBE_CHUNK_COUNT;
+ uint64_t i_pos;
bool b_found = false;
+ const uint64_t i_sync_align_offset = i_initial_pos % p_sys->i_packet_size;
do
{
- i_pos = i_stream_size - (p_sys->i_packet_size * i_probe_count);
- i_pos = __MAX( i_pos, 0 );
+ i_pos = p_sys->i_packet_size * i_probe_count;
+ if( i_stream_size > i_pos )
+ i_pos = i_stream_size - i_pos;
+ else
+ i_pos = 0;
+
+ /* Avoid resyncing, as the starting point should be packet aligned */
+ if( i_pos % p_sys->i_packet_size != i_sync_align_offset )
+ i_pos = i_pos - (i_pos % p_sys->i_packet_size) + i_sync_align_offset;
if( vlc_stream_Seek( p_sys->stream, i_pos ) )
return VLC_EGENERIC;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/155b790003953cc787172f71b2d1aeaded25446b...d26c0f56a254610d7991a5e83f853ef452dd8e9b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/155b790003953cc787172f71b2d1aeaded25446b...d26c0f56a254610d7991a5e83f853ef452dd8e9b
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