* vpar_synchro.c : frame dropping routines
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: vpar_synchro.c,v 1.72 2001/01/15 13:25:09 massiot Exp $
+ * $Id: vpar_synchro.c,v 1.78 2001/01/18 05:13:23 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
#include "video_output.h"
#include "video_decoder.h"
+#include "vdec_motion.h"
#include "../video_decoder/vdec_idct.h"
-#include "../video_decoder/vdec_motion.h"
-#include "../video_decoder/vpar_blocks.h"
+#include "vpar_blocks.h"
#include "../video_decoder/vpar_headers.h"
#include "../video_decoder/vpar_synchro.h"
#include "../video_decoder/video_parser.h"
/* Error margins */
#define DELTA (int)(0.040*CLOCK_FREQ)
-#define PTS_THRESHOLD (int)(0.030*CLOCK_FREQ)
#define DEFAULT_NB_P 5
#define DEFAULT_NB_B 1
p_vpar->synchro.b_dropped_last = 0;
p_vpar->synchro.current_pts = mdate() + DEFAULT_PTS_DELAY;
p_vpar->synchro.backward_pts = 0;
+ p_vpar->synchro.i_current_period = p_vpar->synchro.i_backward_period = 0;
#ifdef STATS
p_vpar->synchro.i_trashed_pic = p_vpar->synchro.i_not_chosen_pic =
p_vpar->synchro.i_pic = 0;
#endif
now = mdate();
- period = 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
+ period = 1000000 * 1001 / p_vpar->sequence.i_frame_rate;
vlc_mutex_lock( &p_vpar->p_vout->change_lock );
tau_yuv = p_vpar->p_vout->render_time;
* vpar_SynchroNewPicture: Update stream structure and PTS
*****************************************************************************/
void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type,
- boolean_t b_repeat_field )
+ int i_repeat_field )
{
- mtime_t period = 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
+ mtime_t period = 1000000 * 1001 / p_vpar->sequence.i_frame_rate;
switch( i_coding_type )
{
break;
}
- if( b_repeat_field )
- {
- /* MPEG-2 repeat_first_field */
- /* FIXME : this is not exactly what we should do, repeat_first_field
- * only regards the next picture */
- p_vpar->synchro.current_pts += period + (period >> 1);
- }
- else
- {
- p_vpar->synchro.current_pts += period;
- }
+ p_vpar->synchro.current_pts += p_vpar->synchro.i_current_period
+ * (period >> 1);
+#define PTS_THRESHOLD (period >> 2)
if( i_coding_type == B_CODING_TYPE )
{
+ /* A video frame can be displayed 1, 2 or 3 times, according to
+ * repeat_first_field, top_field_first, progressive_sequence and
+ * progressive_frame. */
+ p_vpar->synchro.i_current_period = i_repeat_field;
+
if( p_vpar->sequence.next_pts )
{
if( p_vpar->sequence.next_pts - p_vpar->synchro.current_pts
}
else
{
+ p_vpar->synchro.i_current_period = p_vpar->synchro.i_backward_period;
+ p_vpar->synchro.i_backward_period = i_repeat_field;
+
if( p_vpar->synchro.backward_pts )
{
if( p_vpar->sequence.next_dts &&
{
intf_WarnMsg( 2,
"vpar synchro warning: backward_pts != dts (%lld)",
- p_vpar->synchro.backward_pts
- - p_vpar->sequence.next_dts );
+ p_vpar->sequence.next_dts
+ - p_vpar->synchro.backward_pts );
}
-
if( p_vpar->synchro.backward_pts - p_vpar->synchro.current_pts
> PTS_THRESHOLD
|| p_vpar->synchro.current_pts - p_vpar->synchro.backward_pts
p_vpar->sequence.next_pts = 0;
}
}
+#undef PTS_THRESHOLD
#ifdef STATS
p_vpar->synchro.i_pic++;