[vlc-devel] [PATCH] Fix TTA inaccurate seek

Alexandre Janniaux ajanni at videolabs.io
Thu Mar 12 14:49:15 CET 2020


Hi,

Thanks you for your work! I don't have the knowledge to
completely review your patch but here are a few points:

You seem to completely change the indentation, and use tabs
instead of spaces, it should probably be fixed.

The «inaccurate» probably need to be explained in the commit
message too.

Regards,
--
Alexandre Janniaux
Videolabs

On Thu, Mar 12, 2020 at 12:49:29PM +0800, vincent.163 at outlook.com wrote:
> From: vincent163 <vincent.163 at outlook.com>
>
> ---
>  modules/demux/tta.c | 37 +++++++++++++------------------------
>  1 file changed, 13 insertions(+), 24 deletions(-)
>
> diff --git a/modules/demux/tta.c b/modules/demux/tta.c
> index 81c162cd25..db2cfbc629 100644
> --- a/modules/demux/tta.c
> +++ b/modules/demux/tta.c
> @@ -234,34 +234,23 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
>
>          case DEMUX_GET_POSITION:
>              pf = va_arg( args, double * );
> -            i64 = stream_Size( p_demux->s ) - p_sys->i_start;
> -            if( i64 > 0 )
> -            {
> -                *pf = (double)(vlc_stream_Tell( p_demux->s ) - p_sys->i_start )/ (double)i64;
> -            }
> -            else
> -            {
> -                *pf = 0.0;
> -            }
> +			*pf = (double)p_sys->i_currentframe / (double)p_sys->i_totalframes;
>              return VLC_SUCCESS;
>
>          case DEMUX_SET_POSITION:
> +		{
>              f = va_arg( args, double );
> -            i64 = (int64_t)(f * (stream_Size( p_demux->s ) - p_sys->i_start));
> -            if( i64 > 0 )
> -            {
> -                int64_t tmp = 0;
> -                uint32_t i;
> -                for( i=0; i < p_sys->i_totalframes && tmp+p_sys->pi_seektable[i] < i64; i++)
> -                {
> -                    tmp += p_sys->pi_seektable[i];
> -                }
> -                if( vlc_stream_Seek( p_demux->s, tmp+p_sys->i_start ) )
> -                    return VLC_EGENERIC;
> -                p_sys->i_currentframe = i;
> -                return VLC_SUCCESS;
> -            }
> -            return VLC_EGENERIC;
> +			uint32_t j = (uint32_t)(f * p_sys->i_totalframes);
> +			i64 = p_sys->i_start;
> +			for( uint32_t i=0; i<j; i++)
> +			{
> +				i64 += p_sys->pi_seektable[i];
> +			}
> +			if( vlc_stream_Seek( p_demux->s, i64 ) )
> +				return VLC_EGENERIC;
> +			p_sys->i_currentframe = j;
> +			return VLC_SUCCESS;
> +		}
>
>          case DEMUX_GET_LENGTH:
>              *va_arg( args, vlc_tick_t * ) =
> --
> 2.17.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list