if( id->p_encoder->fmt_out.video.i_sar_num <= 0 ||
id->p_encoder->fmt_out.video.i_sar_den <= 0 )
{
- 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,
+ vlc_ureduce( &id->p_encoder->fmt_out.video.i_sar_num,
+ &id->p_encoder->fmt_out.video.i_sar_den,
+ (uint64_t)id->p_decoder->fmt_out.video.i_sar_num * i_src_width * i_dst_height,
+ (uint64_t)id->p_decoder->fmt_out.video.i_sar_den * i_src_height * i_dst_width,
+ 0 );
+ }
+ else
+ {
+ vlc_ureduce( &id->p_encoder->fmt_out.video.i_sar_num,
+ &id->p_encoder->fmt_out.video.i_sar_den,
+ id->p_encoder->fmt_out.video.i_sar_num,
+ 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_encoder->fmt_out.video.i_sar_num,
- &id->p_encoder->fmt_out.video.i_sar_den,
- id->p_encoder->fmt_out.video.i_sar_num,
- id->p_encoder->fmt_out.video.i_sar_den,
- 0 );
id->p_encoder->fmt_in.video.i_sar_num =
id->p_encoder->fmt_out.video.i_sar_num;
picture_t *p_pic, *p_pic2 = NULL;
*out = NULL;
- if( in == NULL )
+ if( unlikely( in == NULL ) )
{
if( p_sys->i_threads == 0 )
{
if( p_stream->p_sout->i_out_pace_nocontrol && p_sys->b_hurry_up )
{
mtime_t current_date = mdate();
- if( current_date + 50000 > p_pic->date )
+ if( unlikely( current_date + 50000 > p_pic->date ) )
{
msg_Dbg( p_stream, "late picture skipped (%"PRId64")",
current_date + 50000 - p_pic->date );
mtime_t i_pts;
i_pts = date_Get( &id->interpolated_pts ) + 1;
- if ( p_pic->date - i_pts > MASTER_SYNC_MAX_DRIFT
- || p_pic->date - i_pts < -MASTER_SYNC_MAX_DRIFT )
+ if ( unlikely( p_pic->date - i_pts > MASTER_SYNC_MAX_DRIFT
+ || p_pic->date - i_pts < -MASTER_SYNC_MAX_DRIFT ) )
{
msg_Dbg( p_stream, "drift is too high, resetting master sync" );
date_Set( &id->interpolated_pts, p_pic->date );
/* Set the pts of the frame being encoded */
p_pic->date = i_pts;
- if( i_video_drift < (i_master_drift - 50000) )
+ if( unlikely( i_video_drift < (i_master_drift - 50000) ) )
{
#if 0
msg_Dbg( p_stream, "dropping frame (%i)",
picture_Release( p_pic );
continue;
}
- else if( i_video_drift > (i_master_drift + 50000) )
+ else if( unlikely( i_video_drift > (i_master_drift + 50000) ) )
{
#if 0
msg_Dbg( p_stream, "adding frame (%i)",
if( id->p_f_chain )
p_pic = filter_chain_VideoFilter( id->p_f_chain, p_pic );
+ /* Run user specified filter chain */
+ if( id->p_uf_chain )
+ p_pic = filter_chain_VideoFilter( id->p_uf_chain, p_pic );
+
/*
* Encoding
*/
/* Check if we have a subpicture to overlay */
if( p_sys->p_spu )
{
- video_format_t fmt;
- 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;
+ video_format_t fmt = id->p_encoder->fmt_in.video;
+ if( fmt.i_visible_width <= 0 || fmt.i_visible_height <= 0 )
+ {
+ fmt.i_visible_width = fmt.i_width;
+ fmt.i_visible_height = fmt.i_height;
+ fmt.i_x_offset = 0;
+ fmt.i_y_offset = 0;
+ }
subpicture_t *p_subpic = spu_Render( p_sys->p_spu, NULL, &fmt, &fmt,
p_pic->date, p_pic->date, false );
{
/* 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 )
+ if( likely( p_tmp ) )
{
picture_Copy( p_tmp, p_pic );
picture_Release( p_pic );
p_pic = p_tmp;
}
}
- if( !p_sys->p_spu_blend )
+ if( unlikely( !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 )
+ if( likely( 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 */
- if( id->p_uf_chain )
- p_pic = filter_chain_VideoFilter( id->p_uf_chain, p_pic );
-
if( p_sys->i_threads == 0 )
{
block_t *p_block;
if( p_sys->b_master_sync )
{
mtime_t i_pts = date_Get( &id->interpolated_pts ) + 1;
- if ( p_pic->date - i_pts > MASTER_SYNC_MAX_DRIFT
- || p_pic->date - i_pts < -MASTER_SYNC_MAX_DRIFT )
+ if (unlikely ( p_pic->date - i_pts > MASTER_SYNC_MAX_DRIFT
+ || p_pic->date - i_pts < -MASTER_SYNC_MAX_DRIFT ) )
{
msg_Dbg( p_stream, "drift is too high, resetting master sync" );
date_Set( &id->interpolated_pts, p_pic->date );
{
/* We can't modify the picture, we need to duplicate it */
p_pic2 = video_new_buffer_decoder( id->p_decoder );
- if( p_pic2 != NULL )
+ if( unlikely( p_pic2 != NULL ) )
{
picture_Copy( p_pic2, p_pic );
p_pic2->date = i_pts;
if( p_sys->f_fps > 0 )
{
- id->p_encoder->fmt_out.video.i_frame_rate = (p_sys->f_fps * 1000) + 0.5;
+ id->p_encoder->fmt_out.video.i_frame_rate = (p_sys->f_fps * ENC_FRAMERATE_BASE) + 0.5;
id->p_encoder->fmt_out.video.i_frame_rate_base = ENC_FRAMERATE_BASE;
}