Changeset 2feaca935ad991eba56614fa18373d7f9d0ec553

Show
Ignore:
Timestamp:
12/12/04 01:04:04 (4 years ago)
Author:
Sigmund Augdal Helberg <sigmunau@videolan.org>
git-committer:
Sigmund Augdal Helberg <sigmunau@videolan.org> 1102809844 +0000
git-parent:

[c2d4afc452c3f81b654661c53223b178f861ad12]

git-author:
Sigmund Augdal Helberg <sigmunau@videolan.org> 1102809844 +0000
Message:

mpga.c: check/hack to make duration available after preparse

Files:

Legend:

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

    ra90a19a r2feaca9  
    7373    int i_xing_bitrate_avg; 
    7474    int i_xing_frame_samples; 
     75    block_t *p_block_in, *p_block_out; 
    7576}; 
    7677 
     
    115116    demux_t     *p_demux = (demux_t*)p_this; 
    116117    demux_sys_t *p_sys; 
    117     vlc_bool_t  b_forced = VLC_FALSE; 
     118    vlc_bool_t  b_forced = VLC_FALSE; 
    118119 
    119120    uint32_t     header; 
     
    121122    module_t    *p_id3; 
    122123    vlc_meta_t  *p_meta = NULL; 
     124    block_t     *p_block_in, *p_block_out; 
    123125 
    124126    if( p_demux->psz_path ) 
     
    267269    } 
    268270 
     271    if( ( p_block_in = stream_Block( p_demux->s, MPGA_PACKET_SIZE ) ) == NULL ) 
     272    { 
     273        return VLC_EGENERIC; 
     274    } 
     275    p_block_in->i_pts = p_block_in->i_dts = 1; 
     276    p_block_out = p_sys->p_packetizer->pf_packetize( 
     277        p_sys->p_packetizer, &p_block_in ); 
     278     
     279    p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE; 
     280    p_sys->p_es = es_out_Add( p_demux->out, 
     281                              &p_sys->p_packetizer->fmt_out); 
     282    p_sys->i_bitrate_avg = p_sys->p_packetizer->fmt_out.i_bitrate; 
     283     
     284    if( p_sys->i_xing_bytes && p_sys->i_xing_frames && 
     285        p_sys->i_xing_frame_samples ) 
     286    { 
     287        p_sys->i_bitrate_avg = p_sys->i_xing_bytes * I64C(8) * 
     288            p_sys->p_packetizer->fmt_out.audio.i_rate / 
     289            p_sys->i_xing_frames / p_sys->i_xing_frame_samples; 
     290    } 
     291 
     292    p_sys->p_block_in = p_block_in; 
     293    p_sys->p_block_out = p_block_out; 
     294 
    269295    return VLC_SUCCESS; 
    270296} 
     
    279305    demux_sys_t *p_sys = p_demux->p_sys; 
    280306    block_t *p_block_in, *p_block_out; 
    281  
    282     if( ( p_block_in = stream_Block( p_demux->s, MPGA_PACKET_SIZE ) ) == NULL ) 
    283     { 
    284         return 0; 
    285     } 
    286  
    287     p_block_in->i_pts = p_block_in->i_dts = p_sys->b_start ? 1 : 0; 
    288     p_sys->b_start = VLC_FALSE; 
    289  
    290     while( (p_block_out = p_sys->p_packetizer->pf_packetize( 
    291                                           p_sys->p_packetizer, &p_block_in )) ) 
     307    if( p_sys->b_start ) 
     308    { 
     309        p_sys->b_start = VLC_FALSE; 
     310        p_block_in = p_sys->p_block_in; 
     311        p_block_out = p_sys->p_block_out; 
     312    } 
     313    else 
     314    { 
     315        if( ( p_block_in = stream_Block( p_demux->s, MPGA_PACKET_SIZE ) ) 
     316            == NULL ) 
     317        { 
     318            return 0; 
     319        } 
     320        p_block_in->i_pts = p_block_in->i_dts = 0; 
     321        p_block_out = p_sys->p_packetizer->pf_packetize( 
     322            p_sys->p_packetizer, &p_block_in ); 
     323    } 
     324 
     325 
     326    while( p_block_out ) 
    292327    { 
    293328        while( p_block_out ) 
    294329        { 
    295330            block_t *p_next = p_block_out->p_next; 
    296  
    297             if( p_sys->p_es == NULL ) 
    298             { 
    299                 p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE; 
    300                 p_sys->p_es = es_out_Add( p_demux->out, 
    301                                           &p_sys->p_packetizer->fmt_out); 
    302  
    303                 p_sys->i_bitrate_avg = p_sys->p_packetizer->fmt_out.i_bitrate; 
    304  
    305                 if( p_sys->i_xing_bytes && p_sys->i_xing_frames && 
    306                     p_sys->i_xing_frame_samples ) 
    307                 { 
    308                     p_sys->i_bitrate_avg = p_sys->i_xing_bytes * I64C(8) * 
    309                         p_sys->p_packetizer->fmt_out.audio.i_rate / 
    310                         p_sys->i_xing_frames / p_sys->i_xing_frame_samples; 
    311                 } 
    312             } 
    313331 
    314332            es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block_out->i_dts ); 
     
    320338            p_block_out = p_next; 
    321339        } 
     340        p_block_out = p_sys->p_packetizer->pf_packetize( 
     341            p_sys->p_packetizer, &p_block_in ); 
    322342    } 
    323343    return 1;