Changeset 14aec2164042b834c59c5ba53c0ea6def78a79cd

Show
Ignore:
Timestamp:
10/21/02 11:18:37 (6 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1035191917 +0000
git-parent:

[df45b8c5e0549eb599fe4ee643e901ddff9f9eb0]

git-author:
Laurent Aimar <fenrir@videolan.org> 1035191917 +0000
Message:
  • configure.ac.in Makefile.am: enable asf demuxer plugin
  • modules/demux/asf/*: some clean up
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac.in

    rec8c631 r14aec21  
    10411041then 
    10421042  PLUGINS="${PLUGINS} avi" 
     1043fi 
     1044 
     1045dnl 
     1046dnl  ASF demux plugin 
     1047dnl 
     1048AC_ARG_ENABLE(asf, 
     1049  [  --enable-asf            ASF demux module (default enabled)]) 
     1050if test "x${enable_asf}" != "xno" 
     1051then 
     1052  PLUGINS="${PLUGINS} asf" 
    10431053fi 
    10441054 
  • modules/Makefile.am

    r9a5df48 r14aec21  
    3333    demux/aac/Modules.am \ 
    3434    demux/avi/Modules.am \ 
     35    demux/asf/Modules.am \ 
    3536    demux/mp4/Modules.am \ 
    3637    demux/mpeg/Modules.am \ 
  • modules/demux/asf/asf.c

    rc72215f r14aec21  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: asf.c,v 1.1 2002/10/20 17:22:33 fenrir Exp $ 
     5 * $Id: asf.c,v 1.2 2002/10/21 09:18:37 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 *  
     
    8484 
    8585    /* a little test to see if it could be a asf stream */ 
    86     if( input_Peek( p_input, &p_peek, 16 ) < 8
     86    if( input_Peek( p_input, &p_peek, 16 ) < 16
    8787    { 
    8888        msg_Warn( p_input, "ASF v1.0 plugin discarded (cannot peek)" ); 
     
    104104    } 
    105105    memset( p_demux, 0, sizeof( demux_sys_t ) ); 
    106     p_input->p_demux_data = p_demux; 
    107         
    108106 
    109107    /* Now load all object ( except raw data ) */ 
     
    123121    } 
    124122    
    125     if( !( p_demux->p_fp = ASF_FindObject( (asf_object_t*)p_demux->root.p_hdr, 
     123    if( !( p_demux->p_fp = ASF_FindObject( p_demux->root.p_hdr, 
    126124                                    &asf_object_file_properties_guid, 0 ) ) ) 
    127125    { 
     
    140138    } 
    141139     
    142     p_demux->i_streams = ASF_CountObject( (asf_object_t*)p_demux->root.p_hdr,  
     140    p_demux->i_streams = ASF_CountObject( p_demux->root.p_hdr,  
    143141                                          &asf_object_stream_properties_guid ); 
    144142    if( !p_demux->i_streams ) 
     
    177175        asf_object_stream_properties_t *p_sp; 
    178176         
    179         p_sp = (asf_object_stream_properties_t*) 
    180                     ASF_FindObject( (asf_object_t*)p_demux->root.p_hdr, 
    181                                     &asf_object_stream_properties_guid, 
    182                                     i_stream ); 
    183  
    184         p_stream = p_demux->stream[p_sp->i_stream_number] = malloc( sizeof( asf_stream_t ) ); 
     177        p_sp = ASF_FindObject( p_demux->root.p_hdr, 
     178                               &asf_object_stream_properties_guid, 
     179                               i_stream ); 
     180 
     181        p_stream =  
     182            p_demux->stream[p_sp->i_stream_number] =  
     183                malloc( sizeof( asf_stream_t ) ); 
    185184        memset( p_stream, 0, sizeof( asf_stream_t ) ); 
    186185        p_stream->p_sp = p_sp; 
     
    219218            switch( i_codec ) 
    220219            { 
     220                case( 0x01 ): 
     221                    p_stream->p_es->i_fourcc =  
     222                        VLC_FOURCC( 'a', 'r', 'a', 'w' ); 
     223                    break; 
    221224                case( 0x50 ): 
    222225                case( 0x55 ): 
     
    277280    vlc_mutex_unlock( &p_input->stream.stream_lock ); 
    278281 
    279     // go to first packet 
    280282    p_demux->i_data_begin = p_demux->root.p_data->i_object_pos + 50; 
    281283    if( p_demux->root.p_data->i_object_size != 0 ) 
     
    288290        p_demux->i_data_end = -1; 
    289291    } 
     292 
     293 
     294    // go to first packet 
    290295    ASF_SeekAbsolute( p_input, p_demux->i_data_begin ); 
    291296    return( 0 ); 
     
    296301 *****************************************************************************/ 
    297302#define GETVALUE2b( bits, var, def ) \ 
    298     switch( bits ) \ 
     303    switch( (bits)&0x03 ) \ 
    299304    { \ 
    300305        case 1: var = p_peek[i_skip]; i_skip++; break; \ 
     
    314319    { 
    315320        off_t i_offset; 
     321         
    316322        i_offset = ASF_TellAbsolute( p_input ) - p_demux->i_data_begin; 
    317  
     323         
    318324        if( i_offset  < 0 ) 
    319325        { 
     
    325331 
    326332        p_demux->i_time = 0; 
    327         for( i = 0; i < 127 ; i++ ) 
     333        for( i = 0; i < 128 ; i++ ) 
    328334        { 
    329335#define p_stream p_demux->stream[i] 
     
    344350    /* update pcr XXX in mpeg scale so in 90000 unit/s */ 
    345351    p_demux->i_pcr = p_demux->i_time * 9 / 100; 
    346      
    347 //    /* we will read 100ms for each stream so */ 
    348 //    p_demux->i_time += 100 * 1000; 
    349352 
    350353    for( i = 0; i < 10; i++ ) // parse 10 packets 
     
    410413 
    411414        /* read some value */ 
    412         GETVALUE2b( ( i_packet_flags >> 5 )&0x3, i_packet_length, i_data_packet_min ); 
    413         GETVALUE2b( ( i_packet_flags >> 1 )&0x3, i_packet_sequence, 0 ); 
    414         GETVALUE2b( ( i_packet_flags >> 3 )&0x3, i_packet_padding_length, 0 ); 
     415        GETVALUE2b( i_packet_flags >> 5, i_packet_length, i_data_packet_min ); 
     416        GETVALUE2b( i_packet_flags >> 1, i_packet_sequence, 0 ); 
     417        GETVALUE2b( i_packet_flags >> 3, i_packet_padding_length, 0 ); 
    415418 
    416419        i_packet_send_time = GetDWLE( p_peek + i_skip ); i_skip += 4; 
     
    450453            i_skip++; 
    451454             
    452             GETVALUE2b( ( i_packet_property >> 4 )&0x03, i_media_object_number, 0 ); 
    453             GETVALUE2b( ( i_packet_property >> 2 )&0x03, i_tmp, 0 ); 
    454             GETVALUE2b( i_packet_property&0x03, i_replicated_data_length, 0 ); 
     455            GETVALUE2b( i_packet_property >> 4, i_media_object_number, 0 ); 
     456            GETVALUE2b( i_packet_property >> 2, i_tmp, 0 ); 
     457            GETVALUE2b( i_packet_property, i_replicated_data_length, 0 ); 
    455458             
    456459            if( i_replicated_data_length > 1 ) // should be at least 8 bytes 
     
    491494            } 
    492495             
     496#if 0 
    493497             msg_Dbg( p_input,  
    494498                      "payload(%d/%d) stream_number:%d media_object_number:%d media_object_offset:%d replicated_data_length:%d payload_data_length %d", 
     
    500504                      i_replicated_data_length,  
    501505                      i_payload_data_length ); 
    502             
     506#endif 
    503507 
    504508            if( !( p_stream = p_demux->stream[i_stream_number] ) ) 
     
    516520 
    517521 
    518             for( i_payload_data_pos = 0; i_payload_data_pos < i_payload_data_length; i_payload_data_pos += i_sub_payload_data_length ) 
     522            for( i_payload_data_pos = 0;  
     523                 i_payload_data_pos < i_payload_data_length &&  
     524                        i_packet_size_left > 0;  
     525                 i_payload_data_pos += i_sub_payload_data_length ) 
    519526            { 
    520527                data_packet_t  *p_data; 
     
    531538                } 
    532539 
    533  
    534                 if( p_stream->p_pes && i_media_object_offset == 0 ) // I don't use i_media_object_number, sould I ? 
    535                 { 
    536                     // send complete packet to decoder 
     540                /* FIXME I don't use i_media_object_number, sould I ? */ 
     541                if( p_stream->p_pes && i_media_object_offset == 0 )                 { 
     542                    /* send complete packet to decoder */ 
    537543                    if( p_stream->p_pes->i_pes_size > 0 ) 
    538544                    { 
     
    544550                if( !p_stream->p_pes )  // add a new PES 
    545551                { 
    546                     mtime_t i_date; 
    547552                    p_stream->i_time = ( (mtime_t)i_pts + i_payload * (mtime_t)i_pts_delta ); 
    548553                     
     
    582587 
    583588                i_skip = 0; 
    584                 if( i_packet_size_left <= 0 ) 
     589                if( i_packet_size_left > 0 ) 
    585590                { 
    586                     break; 
    587                 } 
    588                 if( input_Peek( p_input, &p_peek, i_packet_size_left ) < i_packet_size_left ) 
    589                 { 
    590                     // EOF ? 
    591                     msg_Err( p_input, "cannot peek, EOF ?" ); 
    592                     return( 0 ); 
    593                 } 
    594  
    595  
    596             } 
    597             if( i_packet_size_left <= 0 ) 
    598             { 
    599                 break; 
    600             } 
    601         } 
    602          
    603 loop_ok: 
     591                    if( input_Peek( p_input, &p_peek, i_packet_size_left ) < i_packet_size_left ) 
     592                    { 
     593                        // EOF ? 
     594                        msg_Warn( p_input, "cannot peek, EOF ?" ); 
     595                        return( 0 ); 
     596                    } 
     597                } 
     598            } 
     599        } 
     600         
    604601        if( i_packet_size_left > 0 ) 
    605602        { 
    606603            if( !ASF_SkipBytes( p_input, i_packet_size_left ) ) 
    607604            { 
    608                 msg_Err( p_input, "cannot skip data, EOF ?" ); 
     605                msg_Warn( p_input, "cannot skip data, EOF ?" ); 
    609606                return( 0 ); 
    610607            } 
    611608        } 
    612  
    613609 
    614610        continue; 
     
    623619        ASF_SkipBytes( p_input, i_data_packet_min ); 
    624620 
    625         continue; 
    626621    }   // loop over packet 
    627622     
    628623    p_demux->i_time = 0; 
    629     for( i = 0; i < 127 ; i++ ) 
     624    for( i = 0; i < 128 ; i++ ) 
    630625    { 
    631626#define p_stream p_demux->stream[i] 
     
    650645    input_thread_t *  p_input = (input_thread_t *)p_this; 
    651646    demux_sys_t *p_demux = p_input->p_demux_data; 
     647    int i_stream; 
    652648     
    653649    msg_Dbg( p_input, "Freeing all memory" ); 
    654650    ASF_FreeObjectRoot( p_input, &p_demux->root ); 
     651    for( i_stream = 0; i_stream < 128; i_stream++ ) 
     652    { 
     653#define p_stream p_demux->stream[i_stream] 
     654        if( p_stream ) 
     655        { 
     656            if( p_stream->p_pes ) 
     657            { 
     658                input_DeletePES( p_input->p_method_data, p_stream->p_pes ); 
     659            } 
     660            free( p_stream ); 
     661        } 
     662#undef p_stream 
     663    } 
    655664     
    656665#undef FREE 
  • modules/demux/asf/libasf.c

    rc72215f r14aec21  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: libasf.c,v 1.1 2002/10/20 17:22:33 fenrir Exp $ 
     5 * $Id: libasf.c,v 1.2 2002/10/21 09:18:37 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 *  
     
    893893} 
    894894 
    895 int  ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid ) 
     895int  __ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid ) 
    896896{ 
    897897    int i_count; 
     
    916916} 
    917917 
    918 asf_object_t *ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number ) 
     918void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number ) 
    919919{ 
    920920    asf_object_t *p_child; 
  • modules/demux/asf/libasf.h

    rc72215f r14aec21  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: libasf.h,v 1.1 2002/10/20 17:22:33 fenrir Exp $ 
     5 * $Id: libasf.h,v 1.2 2002/10/21 09:18:37 fenrir Exp $ 
    66 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
    77 *  
     
    441441void ASF_FreeObjectRoot( input_thread_t *p_input, 
    442442                         asf_object_root_t *p_root ); 
    443  
    444 int  ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid ); 
    445 asf_object_t *ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number ); 
    446  
    447  
     443#define ASF_CountObject( a, b ) __ASF_CountObject( (asf_object_t*)(a), b ) 
     444int  __ASF_CountObject( asf_object_t *p_obj, const guid_t *p_guid ); 
     445 
     446#define ASF_FindObject( a, b, c )  __ASF_FindObject( (asf_object_t*)(a), b, c ) 
     447void *__ASF_FindObject( asf_object_t *p_obj, const guid_t *p_guid, int i_number ); 
     448 
     449