Commit 211100f4 authored by Laurent Aimar's avatar Laurent Aimar

* all: improved perfs (using block_ChainLastAppend).

parent 62b37956
...@@ -112,6 +112,7 @@ static inline block_t *block_Realloc( block_t *p_block, int i_pre, int i_body ) ...@@ -112,6 +112,7 @@ static inline block_t *block_Realloc( block_t *p_block, int i_pre, int i_body )
return p_block->pf_realloc( p_block, i_pre, i_body ); return p_block->pf_realloc( p_block, i_pre, i_body );
} }
VLC_EXPORT( void, block_ChainAppend, ( block_t **, block_t * ) ); VLC_EXPORT( void, block_ChainAppend, ( block_t **, block_t * ) );
VLC_EXPORT( void, block_ChainLastAppend, ( block_t ***ppp_last, block_t * ) );
VLC_EXPORT( void, block_ChainRelease, ( block_t * ) ); VLC_EXPORT( void, block_ChainRelease, ( block_t * ) );
VLC_EXPORT( int, block_ChainExtract, ( block_t *, void *, int ) ); VLC_EXPORT( int, block_ChainExtract, ( block_t *, void *, int ) );
VLC_EXPORT( block_t *, block_ChainGather, ( block_t * ) ); VLC_EXPORT( block_t *, block_ChainGather, ( block_t * ) );
......
...@@ -186,8 +186,10 @@ typedef struct ...@@ -186,8 +186,10 @@ typedef struct
es_format_t fmt; es_format_t fmt;
es_out_id_t *id; es_out_id_t *id;
block_t *p_pes; block_t *p_pes;
block_t **pp_last;
es_mpeg4_descriptor_t *p_mpeg4desc; es_mpeg4_descriptor_t *p_mpeg4desc;
int b_gather;
} ts_es_t; } ts_es_t;
typedef struct typedef struct
...@@ -790,7 +792,9 @@ static void PIDInit( ts_pid_t *pid, vlc_bool_t b_psi, ts_psi_t *p_owner ) ...@@ -790,7 +792,9 @@ static void PIDInit( ts_pid_t *pid, vlc_bool_t b_psi, ts_psi_t *p_owner )
es_format_Init( &pid->es->fmt, UNKNOWN_ES, 0 ); es_format_Init( &pid->es->fmt, UNKNOWN_ES, 0 );
pid->es->id = NULL; pid->es->id = NULL;
pid->es->p_pes = NULL; pid->es->p_pes = NULL;
pid->es->pp_last = &pid->es->p_pes;
pid->es->p_mpeg4desc = NULL; pid->es->p_mpeg4desc = NULL;
pid->es->b_gather = VLC_FALSE;
} }
} }
...@@ -857,6 +861,7 @@ static void ParsePES ( demux_t *p_demux, ts_pid_t *pid ) ...@@ -857,6 +861,7 @@ static void ParsePES ( demux_t *p_demux, ts_pid_t *pid )
/* remove the pes from pid */ /* remove the pes from pid */
pid->es->p_pes = NULL; pid->es->p_pes = NULL;
pid->es->pp_last = &pid->es->p_pes;
/* FIXME find real max size */ /* FIXME find real max size */
i_max = block_ChainExtract( p_pes, header, 30 ); i_max = block_ChainExtract( p_pes, header, 30 );
...@@ -1003,9 +1008,16 @@ static void ParsePES ( demux_t *p_demux, ts_pid_t *pid ) ...@@ -1003,9 +1008,16 @@ static void ParsePES ( demux_t *p_demux, ts_pid_t *pid )
p_pes->i_pts = i_pts * 100 / 9; p_pes->i_pts = i_pts * 100 / 9;
} }
if( pid->es->b_gather )
{
/* For mpeg4/mscodec we first gather the packet. /* For mpeg4/mscodec we first gather the packet.
* This will make ffmpeg a lot happier */ * This will make ffmpeg a lot happier */
p_block = block_ChainGather( p_pes ); p_block = block_ChainGather( p_pes );
}
else
{
p_block = p_pes;
}
for( i = 0; i < pid->i_extra_es; i++ ) for( i = 0; i < pid->i_extra_es; i++ )
{ {
...@@ -1154,7 +1166,7 @@ static vlc_bool_t GatherPES( demux_t *p_demux, ts_pid_t *pid, block_t *p_bk ) ...@@ -1154,7 +1166,7 @@ static vlc_bool_t GatherPES( demux_t *p_demux, ts_pid_t *pid, block_t *p_bk )
i_ret = VLC_TRUE; i_ret = VLC_TRUE;
} }
pid->es->p_pes = p_bk; block_ChainLastAppend( &pid->es->pp_last, p_bk );
} }
else else
{ {
...@@ -1167,7 +1179,7 @@ static vlc_bool_t GatherPES( demux_t *p_demux, ts_pid_t *pid, block_t *p_bk ) ...@@ -1167,7 +1179,7 @@ static vlc_bool_t GatherPES( demux_t *p_demux, ts_pid_t *pid, block_t *p_bk )
{ {
/* TODO check if when have gathered enough packets to form a /* TODO check if when have gathered enough packets to form a
* PES (ie read PES size)*/ * PES (ie read PES size)*/
block_ChainAppend( &pid->es->p_pes, p_bk ); block_ChainLastAppend( &pid->es->pp_last, p_bk );
} }
} }
} }
...@@ -1196,6 +1208,7 @@ static int PIDFillFormat( ts_pid_t *pid, int i_stream_type ) ...@@ -1196,6 +1208,7 @@ static int PIDFillFormat( ts_pid_t *pid, int i_stream_type )
break; break;
case 0x10: /* MPEG4 (video) */ case 0x10: /* MPEG4 (video) */
es_format_Init( fmt, VIDEO_ES, VLC_FOURCC( 'm', 'p', '4', 'v' ) ); es_format_Init( fmt, VIDEO_ES, VLC_FOURCC( 'm', 'p', '4', 'v' ) );
pid->es->b_gather = VLC_TRUE;
break; break;
case 0x1B: /* H264 <- check transport syntax/needed descriptor */ case 0x1B: /* H264 <- check transport syntax/needed descriptor */
es_format_Init( fmt, VIDEO_ES, VLC_FOURCC( 'h', '2', '6', '4' ) ); es_format_Init( fmt, VIDEO_ES, VLC_FOURCC( 'h', '2', '6', '4' ) );
...@@ -1230,8 +1243,12 @@ static int PIDFillFormat( ts_pid_t *pid, int i_stream_type ) ...@@ -1230,8 +1243,12 @@ static int PIDFillFormat( ts_pid_t *pid, int i_stream_type )
es_format_Init( fmt, AUDIO_ES, VLC_FOURCC( 's', 'd', 'd', 'b' ) ); es_format_Init( fmt, AUDIO_ES, VLC_FOURCC( 's', 'd', 'd', 'b' ) );
break; break;
case 0x06: /* PES_PRIVATE (fixed later) */
case 0xa0: /* MSCODEC vlc (video) (fixed later) */ case 0xa0: /* MSCODEC vlc (video) (fixed later) */
es_format_Init( fmt, UNKNOWN_ES, 0 );
pid->es->b_gather = VLC_TRUE;
break;
case 0x06: /* PES_PRIVATE (fixed later) */
default: default:
es_format_Init( fmt, UNKNOWN_ES, 0 ); es_format_Init( fmt, UNKNOWN_ES, 0 );
break; break;
...@@ -1849,6 +1866,7 @@ static void PMTCallBack( demux_t *p_demux, dvbpsi_pmt_t *p_pmt ) ...@@ -1849,6 +1866,7 @@ static void PMTCallBack( demux_t *p_demux, dvbpsi_pmt_t *p_pmt )
p_es->fmt = pid->es->fmt; p_es->fmt = pid->es->fmt;
p_es->id = NULL; p_es->id = NULL;
p_es->p_pes = NULL; p_es->p_pes = NULL;
p_es->pp_last = &p_es->p_pes;
p_es->p_mpeg4desc = NULL; p_es->p_mpeg4desc = NULL;
p_es->fmt.psz_language = malloc( 4 ); p_es->fmt.psz_language = malloc( 4 );
......
...@@ -82,6 +82,8 @@ struct decoder_sys_t ...@@ -82,6 +82,8 @@ struct decoder_sys_t
/* Current frame being built */ /* Current frame being built */
block_t *p_frame; block_t *p_frame;
block_t **pp_last;
vlc_bool_t b_frame_slice; vlc_bool_t b_frame_slice;
mtime_t i_pts; mtime_t i_pts;
mtime_t i_dts; mtime_t i_dts;
...@@ -147,6 +149,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -147,6 +149,7 @@ static int Open( vlc_object_t *p_this )
p_sys->p_seq = NULL; p_sys->p_seq = NULL;
p_sys->p_ext = NULL; p_sys->p_ext = NULL;
p_sys->p_frame = NULL; p_sys->p_frame = NULL;
p_sys->pp_last = &p_sys->p_frame;
p_sys->b_frame_slice = VLC_FALSE; p_sys->b_frame_slice = VLC_FALSE;
p_sys->i_dts = p_sys->i_pts = 0; p_sys->i_dts = p_sys->i_pts = 0;
...@@ -216,6 +219,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block ) ...@@ -216,6 +219,7 @@ static block_t *Packetize( decoder_t *p_dec, block_t **pp_block )
p_sys->i_state = STATE_NOSYNC; p_sys->i_state = STATE_NOSYNC;
if( p_sys->p_frame ) block_ChainRelease( p_sys->p_frame ); if( p_sys->p_frame ) block_ChainRelease( p_sys->p_frame );
p_sys->p_frame = NULL; p_sys->p_frame = NULL;
p_sys->pp_last = &p_sys->p_frame;
p_sys->b_frame_slice = VLC_FALSE; p_sys->b_frame_slice = VLC_FALSE;
block_Release( *pp_block ); block_Release( *pp_block );
return NULL; return NULL;
...@@ -332,6 +336,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag ) ...@@ -332,6 +336,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
msg_Dbg( p_dec, "waiting for sequence start" ); msg_Dbg( p_dec, "waiting for sequence start" );
if( p_sys->p_frame ) block_ChainRelease( p_sys->p_frame ); if( p_sys->p_frame ) block_ChainRelease( p_sys->p_frame );
p_sys->p_frame = NULL; p_sys->p_frame = NULL;
p_sys->pp_last = &p_sys->p_frame;
p_sys->b_frame_slice = VLC_FALSE; p_sys->b_frame_slice = VLC_FALSE;
} }
...@@ -440,6 +445,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag ) ...@@ -440,6 +445,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
/* Reset context */ /* Reset context */
p_sys->p_frame = NULL; p_sys->p_frame = NULL;
p_sys->pp_last = &p_sys->p_frame;
p_sys->b_frame_slice = VLC_FALSE; p_sys->b_frame_slice = VLC_FALSE;
} }
...@@ -453,12 +459,10 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag ) ...@@ -453,12 +459,10 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
p_sys->i_seq_old > p_sys->i_frame_rate/p_sys->i_frame_rate_base ) p_sys->i_seq_old > p_sys->i_frame_rate/p_sys->i_frame_rate_base )
{ {
/* Usefull for mpeg1: repeat sequence header every second */ /* Usefull for mpeg1: repeat sequence header every second */
block_ChainAppend( &p_sys->p_frame, block_ChainLastAppend( &p_sys->pp_last, block_Duplicate( p_sys->p_seq ) );
block_Duplicate( p_sys->p_seq ) );
if( p_sys->p_ext ) if( p_sys->p_ext )
{ {
block_ChainAppend( &p_sys->p_frame, block_ChainLastAppend( &p_sys->pp_last, block_Duplicate( p_sys->p_ext ) );
block_Duplicate( p_sys->p_ext ) );
} }
p_sys->i_seq_old = 0; p_sys->i_seq_old = 0;
...@@ -572,7 +576,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag ) ...@@ -572,7 +576,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
} }
/* Append the block */ /* Append the block */
block_ChainAppend( &p_sys->p_frame, p_frag ); block_ChainLastAppend( &p_sys->pp_last, p_frag );
return p_pic; return p_pic;
} }
...@@ -239,7 +239,6 @@ block_t *__block_New( vlc_object_t *p_obj, int i_size ) ...@@ -239,7 +239,6 @@ block_t *__block_New( vlc_object_t *p_obj, int i_size )
void block_ChainAppend( block_t **pp_list, block_t *p_block ) void block_ChainAppend( block_t **pp_list, block_t *p_block )
{ {
if( *pp_list == NULL ) if( *pp_list == NULL )
{ {
*pp_list = p_block; *pp_list = p_block;
...@@ -256,6 +255,18 @@ void block_ChainAppend( block_t **pp_list, block_t *p_block ) ...@@ -256,6 +255,18 @@ void block_ChainAppend( block_t **pp_list, block_t *p_block )
} }
} }
void block_ChainLastAppend( block_t ***ppp_last, block_t *p_block )
{
block_t *p_last = p_block;
/* Append the block */
**ppp_last = p_block;
/* Update last pointer */
while( p_last->p_next ) p_last = p_last->p_next;
*ppp_last = &p_last->p_next;
}
void block_ChainRelease( block_t *p_block ) void block_ChainRelease( block_t *p_block )
{ {
while( p_block ) while( p_block )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment