/* Misc init */
packetizer_Init( &p_sys->packetizer,
p_mp2v_startcode, sizeof(p_mp2v_startcode),
- NULL, 0,
+ NULL, 0, 4,
PacketizeReset, PacketizeParse, PacketizeValidate, p_dec );
p_sys->p_seq = NULL;
p_sys->pp_last = &p_sys->p_frame;
p_sys->b_frame_slice = false;
- p_sys->i_dts = p_sys->i_pts = 0;
+ p_sys->i_dts = p_sys->i_pts = VLC_TS_INVALID;
p_sys->i_frame_rate = 1;
p_sys->i_frame_rate_base = 1;
p_sys->i_progressive_frame = 0;
p_sys->b_inited = 0;
- p_sys->i_interpolated_dts = 0;
- p_sys->i_last_ref_pts = 0;
+ p_sys->i_interpolated_dts = VLC_TS_INVALID;
+ p_sys->i_last_ref_pts = VLC_TS_INVALID;
p_sys->b_second_field = 0;
p_sys->b_discontinuity = false;
p_sys->pp_last = &p_sys->p_frame;
p_sys->b_frame_slice = false;
}
- p_sys->i_dts = 0;
- p_sys->i_pts = 0;
- p_sys->i_interpolated_dts = 0;
- p_sys->i_last_ref_pts = 0;
+ p_sys->i_dts =
+ p_sys->i_pts =
+ p_sys->i_interpolated_dts =
+ p_sys->i_last_ref_pts = VLC_TS_INVALID;
}
static block_t *PacketizeParse( void *p_private, bool *pb_ts_used, block_t *p_block )
decoder_t *p_dec = p_private;
/* Check if we have a picture start code */
- *pb_ts_used = p_block->i_buffer >= 4 && p_block->p_buffer[3] == 0x00;
+ *pb_ts_used = p_block->p_buffer[3] == 0x00;
return ParseMPEGBlock( p_dec, p_block );
}
/* We've just started the stream, wait for the first PTS.
* We discard here so we can still get the sequence header. */
- if( p_sys->i_dts <= 0 && p_sys->i_pts <= 0 &&
- p_sys->i_interpolated_dts <= 0 )
+ if( p_sys->i_dts <= VLC_TS_INVALID && p_sys->i_pts <= VLC_TS_INVALID &&
+ p_sys->i_interpolated_dts <= VLC_TS_INVALID )
{
msg_Dbg( p_dec, "need a starting pts/dts" );
return VLC_EGENERIC;
}
/* When starting the stream we can have the first frame with
- * a null DTS (i_interpolated_pts is initialized to 0) */
- if( !p_au->i_dts )
+ * an invalid DTS (i_interpolated_pts is initialized to VLC_TS_INVALID) */
+ if( p_au->i_dts <= VLC_TS_INVALID )
p_au->i_dts = p_au->i_pts;
return VLC_SUCCESS;
{
/* Trivial case (DTS == PTS) */
/* Correct interpolated dts when we receive a new pts/dts */
- if( p_sys->i_pts > 0 ) p_sys->i_interpolated_dts = p_sys->i_pts;
- if( p_sys->i_dts > 0 ) p_sys->i_interpolated_dts = p_sys->i_dts;
+ if( p_sys->i_pts > VLC_TS_INVALID )
+ p_sys->i_interpolated_dts = p_sys->i_pts;
+ if( p_sys->i_dts > VLC_TS_INVALID )
+ p_sys->i_interpolated_dts = p_sys->i_dts;
}
else
{
/* Correct interpolated dts when we receive a new pts/dts */
- if( p_sys->i_last_ref_pts > 0 && !p_sys->b_second_field )
+ if(p_sys->i_last_ref_pts > VLC_TS_INVALID && !p_sys->b_second_field)
p_sys->i_interpolated_dts = p_sys->i_last_ref_pts;
- if( p_sys->i_dts > 0 ) p_sys->i_interpolated_dts = p_sys->i_dts;
+ if( p_sys->i_dts > VLC_TS_INVALID )
+ p_sys->i_interpolated_dts = p_sys->i_dts;
if( !p_sys->b_second_field )
p_sys->i_last_ref_pts = p_sys->i_pts;
p_sys->i_interpolated_dts += i_duration;
/* Set PTS only if we have a B frame or if it comes from the stream */
- if( p_sys->i_pts > 0 )
+ if( p_sys->i_pts > VLC_TS_INVALID )
{
p_pic->i_pts = p_sys->i_pts;
}
}
else
{
- p_pic->i_pts = 0;
+ p_pic->i_pts = VLC_TS_INVALID;
}
switch ( p_sys->i_picture_type )
if( p_sys->p_seq &&
p_sys->i_seq_old > p_sys->i_frame_rate/p_sys->i_frame_rate_base )
{
- /* Usefull for mpeg1: repeat sequence header every second */
+ /* Useful for mpeg1: repeat sequence header every second */
block_ChainLastAppend( &p_sys->pp_last, block_Duplicate( p_sys->p_seq ) );
if( p_sys->p_ext )
{
* of aspect ratio change, we're screwed. --Meuuh
*/
#if 0
- p_dec->fmt_out.video.i_aspect =
+ p_dec->fmt_out.video.i_sar_num =
mpeg2_aspect[p_sys->i_aspect_ratio_info][0] *
- VOUT_ASPECT_FACTOR /
- mpeg2_aspect[p_sys->i_aspect_ratio_info][1];
+ p_dec->fmt_out.video.i_height;
+ p_dec->fmt_out.video.i_sar_den =
+ mpeg2_aspect[p_sys->i_aspect_ratio_info][1] *
+ p_dec->fmt_out.video.i_width;
#endif
}
}
else if( p_frag->p_buffer[3] == 0xb2 && p_frag->i_buffer > 4 )
{
- cc_Extract( &p_sys->cc, &p_frag->p_buffer[4], p_frag->i_buffer - 4 );
+ cc_Extract( &p_sys->cc, p_sys->i_top_field_first,
+ &p_frag->p_buffer[4], p_frag->i_buffer - 4 );
}
else if( p_frag->p_buffer[3] == 0x00 )
{