[vlc-devel] [PATCH 3/3] mpeg/es demuxer : get last block out of the packetizer
Rafaël Carré
rafael.carre at gmail.com
Tue Jul 19 04:16:40 CEST 2011
refs: #3178
---
modules/demux/mpeg/es.c | 33 +++++++++++++++++++++------------
1 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c
index a66f9f6..58f3185 100644
--- a/modules/demux/mpeg/es.c
+++ b/modules/demux/mpeg/es.c
@@ -257,12 +257,12 @@ static int OpenVideo( vlc_object_t *p_this )
static int Demux( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
+ int ret = VLC_SUCCESS;
block_t *p_block_out = p_sys->p_packetized_data;
if( p_block_out )
p_sys->p_packetized_data = NULL;
- else if( Parse( p_demux, &p_block_out ) )
- return 0;
+ else ret = Parse( p_demux, &p_block_out );
while( p_block_out )
{
@@ -302,7 +302,11 @@ static int Demux( demux_t *p_demux )
p_block_out = p_next;
}
- return 1;
+
+ if (ret) /* eof */
+ es_out_Send( p_demux->out, p_sys->p_es, NULL );
+
+ return ret ? 0 : 1;
}
/*****************************************************************************
@@ -398,7 +402,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
static int Parse( demux_t *p_demux, block_t **pp_output )
{
demux_sys_t *p_sys = p_demux->p_sys;
- block_t *p_block_in, *p_block_out;
+ block_t *p_block, *p_block_out;
*pp_output = NULL;
@@ -410,19 +414,21 @@ static int Parse( demux_t *p_demux, block_t **pp_output )
stream_Read( p_demux->s, NULL, 1 );
}
- if( ( p_block_in = stream_Block( p_demux->s, p_sys->i_packet_size ) ) == NULL )
- return VLC_EGENERIC;
+ p_block = stream_Block( p_demux->s, p_sys->i_packet_size );
- if( p_sys->codec.b_use_word && !p_sys->b_big_endian && p_block_in->i_buffer > 0 )
+ if( p_block )
{
- /* Convert to big endian */
- swab( p_block_in->p_buffer, p_block_in->p_buffer, p_block_in->i_buffer );
- }
+ if( p_sys->codec.b_use_word && !p_sys->b_big_endian && p_block->i_buffer > 0 )
+ {
+ /* Convert to big endian */
+ swab( p_block->p_buffer, p_block->p_buffer, p_block->i_buffer );
+ }
- p_block_in->i_pts = p_block_in->i_dts = p_sys->b_start || p_sys->b_initial_sync_failed ? VLC_TS_0 : VLC_TS_INVALID;
+ p_block->i_pts = p_block->i_dts = p_sys->b_start || p_sys->b_initial_sync_failed ? VLC_TS_0 : VLC_TS_INVALID;
+ }
p_sys->b_initial_sync_failed = p_sys->b_start; /* Only try to resync once */
- while( ( p_block_out = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer, &p_block_in ) ) )
+ while( ( p_block_out = p_sys->p_packetizer->pf_packetize( p_sys->p_packetizer, p_block ? &p_block : NULL ) ) )
{
p_sys->b_initial_sync_failed = false;
while( p_block_out )
@@ -459,6 +465,9 @@ static int Parse( demux_t *p_demux, block_t **pp_output )
}
}
+ if( !p_block )
+ return VLC_EGENERIC;
+
if( p_sys->b_initial_sync_failed )
msg_Dbg( p_demux, "did not sync on first block" );
p_sys->b_start = false;
--
1.7.4.1
More information about the vlc-devel
mailing list