[vlc-devel] [PATCH] MKV: find the duration in the last Cluster when it's not in the Info header

Denis Charmet typx at dinauz.org
Mon Feb 23 12:29:08 CET 2015


Hi,

Le lundi 23 février 2015 à 11:03:23, Steve Lhomme a écrit :
> +void matroska_segment_c::EnsureDuration()
> +{
> +    if ( i_duration > 0 )
> +        return;
What if the announced duration is bad?
> +
> +    i_duration = -1;
> +
> +    bool b_seekable;
> +
> +    stream_Control( sys.demuxer.s, STREAM_CAN_FASTSEEK, &b_seekable );
A file on a USB 1.1 key will return true.
> +    if ( !b_seekable )
> +    {
> +        msg_Warn( &sys.demuxer, "could not look for the segment duration" );
> +        return;
> +    }
> +
> +    uint64 i_current_position = es.I_O().getFilePointer();
> +    uint64 i_last_cluster_pos = 0;
> +
> +    // find the last Cluster from the Cues
> +    if ( b_cues && i_index > 0 && p_indexes != NULL)
> +    {
> +        i_last_cluster_pos = p_indexes[i_index-1].i_position;
> +    }
> +
> +    // find the last Cluster manually
> +    if ( !i_last_cluster_pos && cluster != NULL )
> +    {
> +        EbmlElement *el;
> +        EbmlParser *ep;
> +
> +        es.I_O().setFilePointer( cluster->GetElementPosition(), seek_beginning );
> +        ep = new EbmlParser( &es , segment, &sys.demuxer );
> +
> +        while( ( el = ep->Get() ) != NULL )
> +        {
> +            if ( MKV_IS_ID( el, KaxCluster ) )
> +            {
> +                i_last_cluster_pos = el->GetElementPosition();
> +            }
> +        }
> +
> +        delete ep;
> +    }
Seeking without Cue does something similar and people already complain
a lot about the seek being slow. I expect a shitstorm if you parse the
whole file and don't let people disable that.

Welcome in my Hell :)

-- 
Denis Charmet - TypX
Le mauvais esprit est un art de vivre



More information about the vlc-devel mailing list