Changeset 396d77133092ff6a127824ac3a669192e8a8b07d

Show
Ignore:
Timestamp:
08/10/05 22:07:20 (3 years ago)
Author:
Jean-Paul Saman <jpsaman@videolan.org>
git-committer:
Jean-Paul Saman <jpsaman@videolan.org> 1123704440 +0000
git-parent:

[af44196ee69a672807560c64b3a3359e8101ff17]

git-author:
Jean-Paul Saman <jpsaman@videolan.org> 1123704440 +0000
Message:

Flagging BLOCK_FLAG_DISCONTINUITY for every PID in the input when the slider is moved on the GUI or a jump in the stream is made. It is also propagated to the mpegvideo packetizer. The packetizer has a new mode to sync on I-frame boundary after such a jump. It avoids sending some broken frames to the client. (Forward port of branches/0.8.1-jpsaman-thedj revision 11067 and 11842.)

Files:

Legend:

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

    rfafb8f9 r396d771  
    22 * ts.c: Transport Stream input module for VLC. 
    33 ***************************************************************************** 
    4  * Copyright (C) 2004-2005 the VideoLAN team 
     4 * Copyright (C) 2004-2005 VideoLAN (Centrale Réseaux) and its contributors 
    55 * $Id$ 
    66 * 
     
    16141614    const vlc_bool_t b_payload    = p[3]&0x10; 
    16151615    const int        i_cc         = p[3]&0x0f;   /* continuity counter */ 
     1616    vlc_bool_t       b_discontinuity = VLC_FALSE;/* discontinuity */     
    16161617 
    16171618    /* transport_scrambling_control is ignored */ 
    1618  
    16191619    int         i_skip = 0; 
    16201620    vlc_bool_t  i_ret  = VLC_FALSE; 
     
    16611661                          "ignored", pid->i_pid ); 
    16621662            } 
     1663            /* discontinuity indicator found in stream */ 
     1664            b_discontinuity = p[5]&0x80 ? VLC_TRUE : VLC_FALSE; 
     1665            if( p[5]&0x40 ) 
     1666                msg_Dbg( p_demux, "random access indicator (pid=%d) ", pid->i_pid ); 
    16631667        } 
    16641668    } 
     
    16711675        *   test the content ? 
    16721676     */ 
    1673  
    16741677    i_diff = ( i_cc - pid->i_cc )&0x0f; 
    16751678    if( b_payload && i_diff == 1 ) 
     
    16851688            pid->i_cc = i_cc; 
    16861689        } 
    1687         else if( i_diff != 0
     1690        else if( i_diff != 0 && !b_discontinuity
    16881691        { 
    16891692            /* FIXME what to do when discontinuity_indicator is set ? */ 
     
    16921695 
    16931696            pid->i_cc = i_cc; 
    1694  
    16951697            if( pid->es->p_pes && pid->es->fmt.i_cat != VIDEO_ES ) 
    16961698            { 
     
    17581760        } 
    17591761    } 
    1760  
     1762     
     1763    if( b_discontinuity && pid->es->p_pes ) 
     1764    { 
     1765        msg_Warn( p_demux, "discontinuity indicator (pid=%d) ", 
     1766                     pid->i_pid ); 
     1767        pid->es->p_pes->i_flags |= BLOCK_FLAG_DISCONTINUITY; 
     1768    } 
    17611769    return i_ret; 
    17621770} 
     
    19501958    if( i_iod_tag != 0x02 ) 
    19511959    { 
     1960#ifdef DEBUG     
    19521961        fprintf( stderr, "\n ERR: tag %02x != 0x02", i_iod_tag ); 
     1962#endif         
    19531963        return p_iod; 
    19541964    } 
  • modules/mux/mpeg/ts.c

    r32b36df r396d771  
    22 * ts.c: MPEG-II TS Muxer 
    33 ***************************************************************************** 
    4  * Copyright (C) 2001, 2002 the VideoLAN team 
     4 * Copyright (C) 2001-2005 VideoLAN (Centrale Réseaux) and its contributors 
    55 * $Id$ 
    66 * 
     
    271271    int             i_stream_id; 
    272272    int             i_continuity_counter; 
     273    vlc_bool_t      b_discontinuity; 
    273274 
    274275    /* to be used for carriege of DIV3 */ 
     
    654655    p_stream->i_codec = p_input->p_fmt->i_codec; 
    655656    p_stream->i_continuity_counter    = 0; 
     657    p_stream->b_discontinuity         = VLC_FALSE; 
    656658    p_stream->i_decoder_specific_info = 0; 
    657659    p_stream->p_decoder_specific_info = NULL; 
     
    15691571 
    15701572    p_stream->i_continuity_counter = (p_stream->i_continuity_counter+1)%16; 
     1573    p_stream->b_discontinuity = (p_pes->i_flags & BLOCK_FLAG_DISCONTINUITY); 
    15711574 
    15721575    if( b_adaptation_field ) 
     
    15821585            p_ts->p_buffer[4] = 7 + i_stuffing; 
    15831586            p_ts->p_buffer[5] = 0x10;   /* flags */ 
     1587            if( p_stream->b_discontinuity ) 
     1588            { 
     1589                p_ts->p_buffer[5] |= 0x80; /* flag TS dicontinuity */ 
     1590                p_stream->b_discontinuity = VLC_FALSE; 
     1591            }             
    15841592            p_ts->p_buffer[6] = ( 0 )&0xff; 
    15851593            p_ts->p_buffer[7] = ( 0 )&0xff; 
     
    16461654    return p_ts; 
    16471655} 
    1648  
    16491656 
    16501657static void TSSetPCR( block_t *p_ts, mtime_t i_dts ) 
     
    18011808            { 
    18021809                p_ts->p_buffer[5] = 0x00; 
     1810                if( p_stream->b_discontinuity ) 
     1811                { 
     1812                    p_ts->p_buffer[5] |= 0x80; 
     1813                    p_stream->b_discontinuity = VLC_FALSE; 
     1814                } 
    18031815                for( i = 6; i < 6 + i_stuffing - 2; i++ ) 
    18041816                { 
  • modules/packetizer/mpegvideo.c

    r130e829 r396d771  
    22 * mpegvideo.c: parse and packetize an MPEG1/2 video stream 
    33 ***************************************************************************** 
    4  * Copyright (C) 2001, 2002 the VideoLAN team 
     4 * Copyright (C) 2001-2005 VideoLAN (Centrale Réseaux) and its contributors 
    55 * $Id$ 
    66 * 
     
    88 *          Eric Petit <titer@videolan.org> 
    99 *          Gildas Bazin <gbazin@videolan.org> 
     10 *          Jean-Paul Saman <jpsaman #_at_# m2x dot nl> 
    1011 * 
    1112 * This program is free software; you can redistribute it and/or modify 
     
    4950#include "vlc_block_helper.h" 
    5051 
     52#define SYNC_INTRAFRAME_TEXT N_("Sync on intraframe") 
     53#define SYNC_INTRAFRAME_LONGTEXT N_("Normally the packetizer would " \ 
     54    "sync on the next full frame. This flags instructs the packetizer " \ 
     55    "to sync on the first intraframe found.") 
     56 
    5157/***************************************************************************** 
    5258 * Module descriptor 
     
    6167    set_capability( "packetizer", 50 ); 
    6268    set_callbacks( Open, Close ); 
     69 
     70    add_bool( "packetizer-mpegvideo-sync-iframe", 1, NULL, SYNC_INTRAFRAME_TEXT, 
     71              SYNC_INTRAFRAME_LONGTEXT, VLC_TRUE ); 
    6372vlc_module_end(); 
    6473 
     
    113122    /* Number of pictures since last sequence header */ 
    114123    int i_seq_old; 
    115  
     124     
     125    /* Sync behaviour */ 
     126    vlc_bool_t  b_sync_on_intra_frame; 
     127    vlc_bool_t  b_discontinuity; 
    116128}; 
    117129 
     
    175187    p_sys->i_last_ref_pts = 0; 
    176188 
     189    p_sys->b_discontinuity = VLC_FALSE; 
     190    p_sys->b_sync_on_intra_frame = var_CreateGetBool( p_dec, "packetizer-mpegvideo-sync-iframe" ); 
     191    if( p_sys->b_sync_on_intra_frame ) 
     192        msg_Dbg( p_dec, "syncing happens on intraframe now." ); 
     193         
    177194    return VLC_SUCCESS; 
    178195} 
     
    200217        block_ChainRelease( p_sys->p_frame ); 
    201218    } 
     219     
     220    var_Destroy( p_dec, "packetizer-mpegvideo-sync-iframe" ); 
    202221 
    203222    free( p_sys ); 
     
    220239    { 
    221240        p_sys->i_state = STATE_NOSYNC; 
    222         if( p_sys->p_frame ) block_ChainRelease( p_sys->p_frame ); 
     241        p_sys->b_discontinuity = VLC_TRUE; 
     242        if( p_sys->p_frame ) 
     243            block_ChainRelease( p_sys->p_frame );         
    223244        p_sys->p_frame = NULL; 
    224245        p_sys->pp_last = &p_sys->p_frame; 
     
    295316            } 
    296317 
     318            /* If a discontinuity has been encountered, then wait till 
     319             * the next Intra frame before continuing with packetizing */ 
     320            if( p_sys->b_discontinuity && 
     321                p_sys->b_sync_on_intra_frame ) 
     322            { 
     323                if( p_pic->i_flags & BLOCK_FLAG_TYPE_I ) 
     324                { 
     325                    msg_Dbg( p_dec, "synced on Intra frame" ); 
     326                    p_sys->b_discontinuity = VLC_FALSE; 
     327                    p_pic->i_flags |= BLOCK_FLAG_DISCONTINUITY; 
     328                } 
     329                else 
     330                { 
     331                    p_sys->i_state = STATE_NOSYNC; 
     332                    break; 
     333                } 
     334            } 
     335             
    297336            /* We've just started the stream, wait for the first PTS. 
    298337             * We discard here so we can still get the sequence header. */ 
  • src/input/es_out.c

    rc6a7622 r396d771  
    66 * 
    77 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 
     8 *          Jean-Paul Saman <jpsaman #_at_# m2x dot nl> 
    89 * 
    910 * This program is free software; you can redistribute it and/or modify 
     
    6465    es_out_pgrm_t *p_pgrm; 
    6566 
    66     /* */ 
     67    /* Signal a discontinuity in the timeline for every PID */ 
     68    vlc_bool_t b_discontinuity; 
     69 
     70    /* Misc. */ 
    6771    int64_t i_preroll_end; 
    6872 
     
    277281    { 
    278282        es_out_id_t *es = p_sys->es[i]; 
    279  
     283        es->b_discontinuity = VLC_TRUE; /* signal discontinuity */ 
     284         
    280285        /* Send a dummy block to let decoder know that 
    281286         * there is a discontinuity */ 
     
    670675    es_format_Copy( &es->fmt, fmt ); 
    671676    es->i_preroll_end = -1; 
     677    es->b_discontinuity = VLC_FALSE; 
    672678 
    673679    switch( fmt->i_cat ) 
     
    10321038 
    10331039    p_block->i_rate = p_input->i_rate; 
     1040    if( es->b_discontinuity ) 
     1041    { 
     1042        p_block->i_flags |= BLOCK_FLAG_DISCONTINUITY; 
     1043        es->b_discontinuity = VLC_FALSE; 
     1044    } 
    10341045 
    10351046    /* TODO handle mute */