[vlc-devel] [PATCH] Adding caf file demuxer module.

Rémi Denis-Courmont remi at remlab.net
Thu Sep 26 21:37:51 CEST 2013


Le mercredi 25 septembre 2013 22:22:44 Matthias Keiser a écrit :
>+ typedef struct frame_span_t
>+{
>+    int64_t i_frames;
>+    int64_t i_samples;
>+    int64_t i_bytes;
>+    int64_t i_desc_bytes;
>+} frame_span_t;
>+
>+typedef struct packet_table_t
>+{
>+    int64_t i_num_packets;
>+    int64_t i_num_valid_frames;
>+    int32_t i_num_priming_frames;
>+    int32_t i_num_remainder_frames;
>+    int64_t i_descriptions_start;
>+} packet_table_t;
>+
>+struct demux_sys_t
>+{
>+    es_format_t  fmt;
>+    es_out_id_t *es;
>+
>+    int64_t i_data_offset;
>+    int64_t i_data_size;
>+
>+    frame_span_t position;
>+    packet_table_t packet_table;
>+};

Why signed integers?

> +static int ParseVarLenInteger( const uint8_t *p_buff,

> uint64_t i_buff_len,

size_t. Your address space cannot hold larger buffers anyway.

> int64_t *pi_value_out, int32_t *i_len_out )

This should presumably be an uint64_t * instead. Consider adding the restrict 
qualifier as appropriate.

> +{
> +    *i_len_out = 0;
> +
> +    uint64_t i_value = 0;
> +    bool finished = false;
> +
> +    for( uint32_t i = 0; i < i_buff_len; i++ )
> +    {
> +        if( (( i_value >> 32 ) << 7 ) > INT32_MAX )
> +        {
> +            return VLC_EGENERIC; /* overflow */
> +        }
> +        uint8_t i_byte = p_buff[i];
> +        i_value = ( i_value << 7 ) | ( i_byte & 0x7f );
> +
> +        ( *i_len_out )++;
> +
> +        if( !( i_byte & 0x80 ))
> +        {
> +            finished = true;
> +            break;
> +        }
> +    }
> +
> +    if( !finished )
> +    {
> +        return VLC_EGENERIC;
> +    }
> +
> +    *pi_value_out = i_value;
> +
> +    return VLC_SUCCESS;
> +}
> +


> +static inline vlc_fourcc_t ReadFOURCC( const uint8_t *p )
> +{
> +    return VLC_FOURCC( p[0], p[1], p[2], p[3] );

GetDWLE?


> +static int ReadDescChunk( demux_t *p_demux )
> +{
> +    demux_sys_t *p_sys = ( demux_sys_t * )p_demux->p_sys;

Cast should not be needed.


-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list