demux: ogg: store length as microseconds

This commit is contained in:
Francois Cartegnie 2022-06-16 16:07:22 +02:00 committed by Steve Lhomme
parent fc94fb4e0b
commit ac81e531ac
3 changed files with 11 additions and 10 deletions

View File

@ -241,7 +241,7 @@ static int Open( vlc_object_t * p_this )
if( !p_sys )
return VLC_ENOMEM;
p_sys->i_length = -1;
p_sys->i_length = 0;
p_sys->b_preparsing_done = false;
/* Set exported functions */
@ -760,8 +760,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if( p_sys->i_length > 0 && p_sys->i_pcr != VLC_TICK_INVALID )
{
vlc_tick_t duration = vlc_tick_from_sec( p_sys->i_length );
pos = (double) p_sys->i_pcr / (double) duration;
pos = (double) p_sys->i_pcr / (double) p_sys->i_length;
}
else if( vlc_stream_GetSize( p_demux->s, &size ) == 0 && size > 0 )
{
@ -801,7 +800,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
}
assert( p_sys->i_length > 0 );
i64 = vlc_tick_from_sec( f * p_sys->i_length );
i64 = f * p_sys->i_length;
Ogg_PreparePostSeek( p_sys );
if ( Oggseek_SeektoAbsolutetime( p_demux, p_stream, VLC_TICK_0 + i64 ) >= 0 )
{
@ -817,7 +816,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
if ( p_sys->i_length < 0 )
return demux_vaControlHelper( p_demux->s, 0, -1, p_sys->i_bitrate,
1, i_query, args );
*va_arg( args, vlc_tick_t * ) = vlc_tick_from_sec(p_sys->i_length);
*va_arg( args, vlc_tick_t * ) = p_sys->i_length;
return VLC_SUCCESS;
case DEMUX_GET_TITLE_INFO:

View File

@ -219,8 +219,8 @@ typedef struct
bool b_preparsing_done;
bool b_es_created;
/* Length in second, if available. */
int64_t i_length;
/* Time length, if available. 0 otherwise. */
vlc_tick_t i_length;
bool b_slave;

View File

@ -267,7 +267,7 @@ void Oggseek_ProbeEnd( demux_t *p_demux )
if( i_length != VLC_TICK_INVALID )
{
/* We found at least a page with valid granule */
p_sys->i_length = __MAX( p_sys->i_length, SEC_FROM_VLC_TICK(i_length - VLC_TICK_0) );
p_sys->i_length = __MAX( p_sys->i_length, i_length - VLC_TICK_0 );
goto clean;
}
break;
@ -916,8 +916,10 @@ int Oggseek_SeektoAbsolutetime( demux_t *p_demux, logical_stream_t *p_stream,
}
/* Insert keyframe position into index */
vlc_tick_t index_interval = p_sys->i_length ? ceil(sqrt(p_sys->i_length) / 2) : vlc_tick_from_sec(5);
if ( i_pagepos >= p_stream->i_data_start && (i_sync_time - i_lower_index >= index_interval) )
vlc_tick_t index_interval = p_sys->i_length
? vlc_tick_from_sec( ceil( sqrt( SEC_FROM_VLC_TICK( p_sys->i_length ) ) / 2 ) )
: vlc_tick_from_sec( 5 );
if ( i_pagepos >= p_stream->i_data_start && ( i_sync_time - i_lower_index >= index_interval ) )
OggSeek_IndexAdd( p_stream, i_sync_time, i_pagepos );
OggDebug( msg_Dbg( p_demux, "=================== Seeked To %"PRId64" time %"PRId64, i_pagepos, i_time ) );