vlc | branch: master | Francois Cartegnie <[email protected]> | Wed Oct 23 13:59:15 2013 +0900| [3bd43453cd53e9fdd4646eff5f8387d20833be65] | committer: Francois Cartegnie
demux: ogg: eos workaround for seeking (fix #9601) > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3bd43453cd53e9fdd4646eff5f8387d20833be65 --- modules/demux/ogg.c | 54 ++++++++++++++++++++++++++++++++------------------- modules/demux/ogg.h | 6 ++---- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/modules/demux/ogg.c b/modules/demux/ogg.c index 8676171..9f1893c 100644 --- a/modules/demux/ogg.c +++ b/modules/demux/ogg.c @@ -242,10 +242,16 @@ static int Demux( demux_t * p_demux ) bool b_skipping = false; bool b_canseek; + int i_active_streams = p_sys->i_streams; + for ( int i; i < p_sys->i_streams; i++ ) + { + if ( p_sys->pp_stream[i]->b_finished ) + i_active_streams--; + } - if( p_sys->i_eos == p_sys->i_streams ) + if ( i_active_streams == 0 ) { - if( p_sys->i_eos ) + if ( p_sys->i_streams ) /* All finished */ { msg_Dbg( p_demux, "end of a group of logical streams" ); /* We keep the ES to try reusing it in Ogg_BeginningOfStream @@ -258,7 +264,6 @@ static int Demux( demux_t * p_demux ) Ogg_EndOfStream( p_demux ); } - p_sys->i_eos = 0; if( Ogg_BeginningOfStream( p_demux ) != VLC_SUCCESS ) return 0; @@ -314,9 +319,14 @@ static int Demux( demux_t * p_demux ) } } - /* FIXME that eos handling is innapropriate with seeking and concatenated streams */ - if ( ogg_page_granulepos( &p_sys->current_page ) != 0 ) /* skel workaround */ - p_sys->i_eos++; + for( i_stream = 0; i_stream < p_sys->i_streams; i_stream++ ) + { + if ( p_sys->pp_stream[i_stream]->i_serial_no == ogg_page_serialno( &p_sys->current_page ) ) + { + p_sys->pp_stream[i_stream]->b_finished = true; + break; + } + } } } @@ -346,6 +356,7 @@ static int Demux( demux_t * p_demux ) es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0); } + /* Does fail if serialno differs */ if( ogg_stream_pagein( &p_stream->os, &p_sys->current_page ) != 0 ) { continue; @@ -353,6 +364,9 @@ static int Demux( demux_t * p_demux ) } + /* clear the finished flag if pages after eos (ex: after a seek) */ + if ( ! ogg_page_eos( &p_sys->current_page ) ) p_stream->b_finished = false; + DemuxDebug( if ( p_stream->fmt.i_cat == VIDEO_ES ) msg_Dbg(p_demux, "DEMUX READ pageno %ld g%"PRId64" (%d packets) cont %d %ld bytes eos %d ", @@ -645,9 +659,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) /* forbid seeking if we haven't initialized all logical bitstreams yet; if we allowed, some headers would not get backed up and decoder init would fail, making that logical stream unusable */ - if( p_sys->i_bos > 0 ) + for ( int i=0; i< p_sys->i_streams; i++ ) { - return VLC_EGENERIC; + if ( p_sys->pp_stream[i]->b_initializing ) + return VLC_EGENERIC; } p_stream = Ogg_GetSelectedStream( p_demux ); @@ -718,9 +733,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) case DEMUX_SET_SEEKPOINT: { const int i_seekpoint = (int)va_arg( args, int ); - if( i_seekpoint > p_sys->i_seekpoints || p_sys->i_bos > 0 ) + if( i_seekpoint > p_sys->i_seekpoints ) return VLC_EGENERIC; + for ( int i=0; i< p_sys->i_streams; i++ ) + { + if ( p_sys->pp_stream[i]->b_initializing ) + return VLC_EGENERIC; + } + i64 = p_sys->pp_seekpoints[i_seekpoint]->i_time_offset; p_stream = Ogg_GetSelectedStream( p_demux ); @@ -1023,7 +1044,7 @@ static void Ogg_DecodePacket( demux_t *p_demux, p_stream->p_headers, p_stream->i_headers ); /* we're not at BOS anymore for this logical stream */ - p_ogg->i_bos--; + p_stream->b_initializing = false; } } @@ -1734,20 +1755,13 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux ) p_ogg->i_streams--; } + /* we'll need to get all headers */ + p_ogg->pp_stream[i_stream]->b_initializing |= p_ogg->pp_stream[i_stream]->b_force_backup; + if( Ogg_ReadPage( p_demux, &p_ogg->current_page ) != VLC_SUCCESS ) return VLC_EGENERIC; } - /* we'll need to get all headers for all of those streams - that we have to backup headers for */ - p_ogg->i_bos = 0; - for( i_stream = 0; i_stream < p_ogg->i_streams; i_stream++ ) - { - if( p_ogg->pp_stream[i_stream]->b_force_backup ) - p_ogg->i_bos++; - } - - /* This is the first data page, which means we are now finished * with the initial pages. We just need to store it in the relevant * bitstream. */ diff --git a/modules/demux/ogg.h b/modules/demux/ogg.h index 1d54256..a65168d 100644 --- a/modules/demux/ogg.h +++ b/modules/demux/ogg.h @@ -72,6 +72,8 @@ typedef struct logical_stream_s mtime_t i_previous_pcr; /* Misc */ + bool b_initializing; + bool b_finished; bool b_reinit; bool b_oggds; int i_granule_shift; @@ -130,10 +132,6 @@ struct demux_sys_t * the sub-streams */ mtime_t i_pcr; - /* stream state */ - int i_bos; /* Begnning of stream, tell the demux to look for elementary streams. */ - int i_eos; - /* bitrate */ int i_bitrate; bool b_partial_bitrate; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
