Changeset 9d349e1ce5812e1d6e7a754368d240d00efe03e2

Show
Ignore:
Timestamp:
02/27/08 20:46:04 (6 months ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1204141564 +0000
git-parent:

[689d893b4e6d2c86d5b63f5d4c358cf1a09795e0]

git-author:
Rafaël Carré <funman@videolan.org> 1204141564 +0000
Message:

asf demuxer: fix header demuxing & use padding without confusing the user (refs #1404)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/demux/asf/asf.c

    r99fab90 r9d349e1  
    9090 
    9191    unsigned int        i_track; 
    92     asf_track_t         *track[128]; 
     92    asf_track_t         *track[128]; /* track number is stored on 7 bits */ 
    9393 
    9494    int64_t             i_data_begin; 
     
    150150        int i_result; 
    151151 
    152         if( p_demux->b_die ) break; 
     152        if( p_demux->b_die ) 
     153            break; 
     154        if( p_sys->i_data_end >= 0 && 
     155                stream_Tell( p_demux->s ) >= p_sys->i_data_end ) 
     156            return 0; /* EOF */ 
    153157 
    154158        /* Check if we have concatenated files */ 
     
    427431    GETVALUE2b( i_packet_flags >> 3, i_packet_padding_length, 0 ); 
    428432 
     433    if( i_packet_padding_length > i_packet_length ) 
     434    { 
     435        msg_Warn( p_demux, "Too large padding: %d", i_packet_padding_length ); 
     436        goto loop_error_recovery; 
     437    } 
     438 
    429439    i_packet_send_time = GetDWLE( p_peek + i_skip ); i_skip += 4; 
    430440    i_packet_duration  = GetWLE( p_peek + i_skip ); i_skip += 2; 
    431441 
    432 //        i_packet_size_left = i_packet_length;   // XXX data really read 
    433     /* FIXME I have to do that for some file, I don't known why */ 
    434     i_packet_size_left = i_data_packet_min; 
     442    i_packet_size_left = i_packet_length - i_packet_padding_length; 
    435443 
    436444    if( b_packet_multiple_payload ) 
     
    513521        else 
    514522        { 
    515             i_payload_data_length = i_packet_length - 
    516                                         i_packet_padding_length - i_skip; 
    517         } 
    518  
    519         if( i_payload_data_length < 0 || i_skip + i_payload_data_length > i_packet_size_left ) 
     523            i_payload_data_length = i_packet_length - i_skip; 
     524        } 
     525 
     526        if( i_payload_data_length < 0 || i_payload_data_length > i_packet_size_left ) 
    520527        { 
    521528            break; 
     
    617624    if( i_packet_size_left > 0 ) 
    618625    { 
     626        msg_Warn( p_demux, "Didn't read %d bytes in the packet", 
     627                            i_packet_size_left ); 
    619628        if( stream_Read( p_demux->s, NULL, i_packet_size_left ) 
    620629                                                         < i_packet_size_left ) 
    621630        { 
    622             msg_Warn( p_demux, "cannot skip data, EOF ?" ); 
     631            msg_Err( p_demux, "cannot skip data, EOF ?" ); 
    623632            return 0; 
    624633        } 
    625634    } 
     635 
     636    if( i_packet_padding_length > 0 ) 
     637        if( stream_Read( p_demux->s, NULL, i_packet_padding_length ) 
     638                                                    < i_packet_padding_length ) 
     639        { 
     640            msg_Err( p_demux, "cannot skip padding data, EOF ?" ); 
     641            return 0; 
     642        } 
    626643 
    627644    return 1; 
  • modules/demux/asf/libasf.c

    r99fab90 r9d349e1  
    135135static void ASF_FreeObject_Null( asf_object_t *pp_obj ) 
    136136{ 
     137    VLC_UNUSED(pp_obj); 
    137138    return; 
    138139} 
     
    271272    const uint8_t *p_peek; 
    272273 
    273     if( ( i_peek = stream_Peek( s, &p_peek,  104) ) < 104 ) 
     274    if( ( i_peek = stream_Peek( s, &p_peek,  104 ) ) < 104 ) 
    274275    { 
    275276       return VLC_EGENERIC; 
     
    279280    p_fp->i_creation_date = GetQWLE( p_peek + 48 ); 
    280281    p_fp->i_data_packets_count = GetQWLE( p_peek + 56 ); 
    281     p_fp->i_play_duration = GetQWLE( p_peek + 64 ); 
    282     p_fp->i_send_duration = GetQWLE( p_peek + 72 ); 
    283     p_fp->i_preroll = GetQWLE( p_peek + 80 ); 
     282    p_fp->i_send_duration = GetQWLE( p_peek + 64 ); 
     283    p_fp->i_play_duration = GetQWLE( p_peek + 72 ); 
     284    p_fp->i_preroll = GetDWLE( p_peek + 80 ); 
     285    p_fp->i_unknown = GetDWLE( p_peek + 84 ); 
    284286    p_fp->i_flags = GetDWLE( p_peek + 88 ); 
    285287    p_fp->i_min_data_packet_size = GetDWLE( p_peek + 92 ); 
     
    291293            "read \"file properties object\" file_id:" GUID_FMT 
    292294            " file_size:"I64Fd" creation_date:"I64Fd" data_packets_count:" 
    293             I64Fd" play_duration:"I64Fd" send_duration:"I64Fd" preroll:
    294             I64Fd" flags:%d min_data_packet_size:%d max_data_packet_size:%d " 
    295             "max_bitrate:%d", 
     295            I64Fd" send_duration:"I64Fd" play_duration:"I64Fd" preroll:%d
     296            "unknown:%d flags:%d min_data_packet_size:%d " 
     297            "max_data_packet_size:%d max_bitrate:%d", 
    296298            GUID_PRINT( p_fp->i_file_id ), p_fp->i_file_size, 
    297299            p_fp->i_creation_date, p_fp->i_data_packets_count, 
    298             p_fp->i_play_duration, p_fp->i_send_duration, 
    299             p_fp->i_preroll, p_fp->i_flags, 
     300            p_fp->i_send_duration, p_fp->i_play_duration, 
     301            p_fp->i_preroll, p_fp->i_unknown, p_fp->i_flags, 
    300302            p_fp->i_min_data_packet_size, p_fp->i_max_data_packet_size, 
    301303            p_fp->i_max_bitrate ); 
  • modules/demux/asf/libasf.h

    r6ee1e19 r9d349e1  
    199199    uint64_t     i_creation_date; 
    200200    uint64_t     i_data_packets_count; 
     201    uint64_t     i_send_duration; 
    201202    uint64_t     i_play_duration; 
    202     uint64_t     i_send_duration
    203     uint64_t     i_preroll; 
     203    uint32_t     i_preroll
     204    uint32_t     i_unknown; /* ignored, usually 0 */ 
    204205    uint32_t     i_flags; 
    205206    uint32_t     i_min_data_packet_size;