sout_stream_sys_t *p_sys;
};
-static inline void video_timer_start( encoder_t * p_encoder )
-{
- stats_TimerStart( p_encoder, "encoding video frame",
- STATS_TIMER_VIDEO_FRAME_ENCODING );
-}
-
-static inline void video_timer_stop( encoder_t * p_encoder )
-{
- stats_TimerStop( p_encoder, STATS_TIMER_VIDEO_FRAME_ENCODING );
-}
-
-static inline void video_timer_close( encoder_t * p_encoder )
-{
- stats_TimerDump( p_encoder, STATS_TIMER_VIDEO_FRAME_ENCODING );
- stats_TimerClean( p_encoder, STATS_TIMER_VIDEO_FRAME_ENCODING );
-}
-
static void video_del_buffer_decoder( decoder_t *p_decoder, picture_t *p_pic )
{
VLC_UNUSED(p_decoder);
VLC_UNUSED(p_filter);
}
-static void* EncoderThread( vlc_object_t* p_this )
+static void* EncoderThread( void *obj )
{
- sout_stream_sys_t *p_sys = (sout_stream_sys_t*)p_this;
+ sout_stream_sys_t *p_sys = (sout_stream_sys_t*)obj;
sout_stream_id_t *id = p_sys->id_video;
picture_t *p_pic;
int canc = vlc_savecancel ();
- while( vlc_object_alive (p_sys) && !p_sys->b_error )
+ for( ;; )
{
block_t *p_block;
vlc_mutex_lock( &p_sys->lock_out );
- while( p_sys->i_last_pic == p_sys->i_first_pic )
- {
+ while( !p_sys->b_abort && p_sys->i_last_pic == p_sys->i_first_pic )
vlc_cond_wait( &p_sys->cond, &p_sys->lock_out );
- if( !vlc_object_alive (p_sys) || p_sys->b_error ) break;
- }
- if( !vlc_object_alive (p_sys) || p_sys->b_error )
+
+ if( p_sys->b_abort )
{
vlc_mutex_unlock( &p_sys->lock_out );
break;
p_sys->i_first_pic %= PICTURE_RING_SIZE;
vlc_mutex_unlock( &p_sys->lock_out );
- video_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic );
- video_timer_stop( id->p_encoder );
vlc_mutex_lock( &p_sys->lock_out );
block_ChainAppend( &p_sys->p_buffers, p_block );
p_sys->i_first_pic = 0;
p_sys->i_last_pic = 0;
p_sys->p_buffers = NULL;
- p_sys->b_die = p_sys->b_error = 0;
- if( vlc_thread_create( p_sys, "encoder", EncoderThread, i_priority ) )
+ p_sys->b_abort = 0;
+ if( vlc_clone( &p_sys->thread, EncoderThread, p_sys, i_priority ) )
{
msg_Err( p_stream, "cannot spawn encoder thread" );
module_unneed( id->p_decoder, id->p_decoder->p_module );
if( id->p_encoder->fmt_out.video.i_sar_num <= 0 ||
id->p_encoder->fmt_out.video.i_sar_den <= 0 )
{
- id->p_encoder->fmt_out.video.i_sar_num = id->p_decoder->fmt_out.video.i_sar_num * i_src_width / i_dst_width;
- id->p_encoder->fmt_out.video.i_sar_den = id->p_decoder->fmt_out.video.i_sar_den * i_src_height / i_dst_height;
+ vlc_ureduce( &id->p_decoder->fmt_out.video.i_sar_num,
+ &id->p_decoder->fmt_out.video.i_sar_den,
+ id->p_decoder->fmt_out.video.i_sar_num,
+ id->p_decoder->fmt_out.video.i_sar_den,
+ 0 );
+
+ id->p_encoder->fmt_out.video.i_sar_num = id->p_decoder->fmt_out.video.i_sar_num * i_src_width * i_dst_height;
+ id->p_encoder->fmt_out.video.i_sar_den = id->p_decoder->fmt_out.video.i_sar_den * i_src_height * i_dst_width;
}
vlc_ureduce( &id->p_encoder->fmt_out.video.i_sar_num,
&id->p_encoder->fmt_out.video.i_sar_den,
if( p_stream->p_sys->i_threads >= 1 )
{
vlc_mutex_lock( &p_stream->p_sys->lock_out );
- vlc_object_kill( p_stream->p_sys );
+ p_stream->p_sys->b_abort = true;
vlc_cond_signal( &p_stream->p_sys->cond );
vlc_mutex_unlock( &p_stream->p_sys->lock_out );
- vlc_thread_join( p_stream->p_sys );
+
+ vlc_join( p_stream->p_sys->thread, NULL );
vlc_mutex_destroy( &p_stream->p_sys->lock_out );
vlc_cond_destroy( &p_stream->p_sys->cond );
}
- video_timer_close( id->p_encoder );
-
/* Close decoder */
if( id->p_decoder->p_module )
module_unneed( id->p_decoder, id->p_decoder->p_module );
{
block_t *p_block;
do {
- video_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_video(id->p_encoder, NULL );
- video_timer_stop( id->p_encoder );
block_ChainAppend( out, p_block );
} while( p_block );
}
while( (p_pic = id->p_decoder->pf_decode_video( id->p_decoder, &in )) )
{
- subpicture_t *p_subpic = NULL;
-
- sout_UpdateStatistic( p_stream->p_sout, SOUT_STATISTIC_DECODED_VIDEO, 1 );
if( p_stream->p_sout->i_out_pace_nocontrol && p_sys->b_hurry_up )
{
/* Check if we have a subpicture to overlay */
if( p_sys->p_spu )
- {
- p_subpic = spu_SortSubpictures( p_sys->p_spu, p_pic->date, false );
- /* TODO: get another pic */
- }
-
- /* Overlay subpicture */
- if( p_subpic )
{
video_format_t fmt;
-
- if( picture_IsReferenced( p_pic ) && !filter_chain_GetLength( id->p_f_chain ) )
- {
- /* We can't modify the picture, we need to duplicate it */
- picture_t *p_tmp = video_new_buffer_decoder( id->p_decoder );
- if( p_tmp )
- {
- picture_Copy( p_tmp, p_pic );
- picture_Release( p_pic );
- p_pic = p_tmp;
- }
- }
-
if( filter_chain_GetLength( id->p_f_chain ) > 0 )
fmt = filter_chain_GetFmtOut( id->p_f_chain )->video;
else
fmt = id->p_decoder->fmt_out.video;
- spu_RenderSubpictures( p_sys->p_spu, p_pic, &fmt,
- p_subpic, &id->p_decoder->fmt_out.video, p_pic->date );
+ subpicture_t *p_subpic = spu_Render( p_sys->p_spu, NULL, &fmt, &fmt,
+ p_pic->date, p_pic->date, false );
+
+ /* Overlay subpicture */
+ if( p_subpic )
+ {
+ if( picture_IsReferenced( p_pic ) && !filter_chain_GetLength( id->p_f_chain ) )
+ {
+ /* We can't modify the picture, we need to duplicate it */
+ picture_t *p_tmp = video_new_buffer_decoder( id->p_decoder );
+ if( p_tmp )
+ {
+ picture_Copy( p_tmp, p_pic );
+ picture_Release( p_pic );
+ p_pic = p_tmp;
+ }
+ }
+ if( !p_sys->p_spu_blend )
+ p_sys->p_spu_blend = filter_NewBlend( VLC_OBJECT( p_sys->p_spu ), &fmt );
+ if( p_sys->p_spu_blend )
+ picture_BlendSubpicture( p_pic, p_sys->p_spu_blend, p_subpic );
+ subpicture_Delete( p_subpic );
+ }
}
/* Run user specified filter chain */
{
block_t *p_block;
- video_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_video( id->p_encoder, p_pic );
- video_timer_stop( id->p_encoder );
-
block_ChainAppend( out, p_block );
}
{
block_t *p_block;
p_pic->date = i_pts;
- video_timer_start( id->p_encoder );
p_block = id->p_encoder->pf_encode_video(id->p_encoder, p_pic);
- video_timer_stop( id->p_encoder );
block_ChainAppend( out, p_block );
}
}