Commit c1094d99 authored by Christophe Massiot's avatar Christophe Massiot

Synchro de base.

parent 2f30d77a
......@@ -18,6 +18,7 @@
/*****************************************************************************
* video_synchro_t and video_synchro_tab_s : timers for the video synchro
*****************************************************************************/
#if 0
typedef struct video_synchro_tab_s
{
double mean;
......@@ -77,6 +78,18 @@ typedef struct video_synchro_s
double actual_fps;
} video_synchro_t;
#else
typedef struct video_synchro_s
{
int kludge_level, kludge_p, kludge_b, kludge_nbp, kludge_nbb;
int kludge_nbframes;
mtime_t kludge_date, kludge_prevdate;
int i_coding_type;
} video_synchro_t;
#define SYNC_TOLERATE 10000 /* 10 ms */
#define SYNC_DELAY 100000
#endif
/*****************************************************************************
* Prototypes
......
......@@ -245,6 +245,7 @@ static int InitThread( vpar_thread_t *p_vpar )
/*
* Initialize the synchro properties
*/
#if 0
p_vpar->synchro.i_last_decode_pts = 0;
p_vpar->synchro.i_last_display_pts = 0;
p_vpar->synchro.i_images_since_pts = 0;
......@@ -280,6 +281,13 @@ static int InitThread( vpar_thread_t *p_vpar )
p_vpar->synchro.tab_b[i_dummy].mean = 6;
p_vpar->synchro.tab_b[i_dummy].deviation = .5;
}
#else
p_vpar->synchro.kludge_level = 5;
p_vpar->synchro.kludge_nbp = p_vpar->synchro.kludge_p = 5;
p_vpar->synchro.kludge_nbb = p_vpar->synchro.kludge_b = 6;
p_vpar->synchro.kludge_b = 0;
p_vpar->synchro.kludge_prevdate = 0;
#endif
/* Mark thread as running and return */
intf_DbgMsg("vpar debug: InitThread(%p) succeeded\n", p_vpar);
......
......@@ -156,13 +156,25 @@ static void __inline__ ReferenceUpdate( vpar_thread_t * p_vpar,
vout_UnlinkPicture( p_vpar->p_vout, p_vpar->sequence.p_forward );
if( p_vpar->sequence.p_backward != NULL )
{
#if 0
vout_DatePicture( p_vpar->p_vout, p_vpar->sequence.p_backward,
vpar_SynchroDate( p_vpar ) );
#else
mtime_t date;
date = vpar_SynchroDate( p_vpar );
vout_DatePicture( p_vpar->p_vout, p_vpar->sequence.p_backward,
date );
if( p_vpar->synchro.i_coding_type == I_CODING_TYPE )
vpar_SynchroKludge( p_vpar, date );
#endif
}
p_vpar->sequence.p_forward = p_vpar->sequence.p_backward;
p_vpar->sequence.p_backward = p_newref;
if( p_newref != NULL )
vout_LinkPicture( p_vpar->p_vout, p_newref );
#if 1
p_vpar->synchro.i_coding_type = i_coding_type;
#endif
}
else if( p_newref != NULL )
{
......
......@@ -43,6 +43,7 @@
* Local prototypes
*/
#if 0
/*****************************************************************************
* vpar_SynchroUpdateTab : Update a mean table in the synchro structure
*****************************************************************************/
......@@ -398,3 +399,120 @@ mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
return i_displaydate;
}
#else
/* synchro a deux balles backportee du decodeur de reference. NE MARCHE PAS
AVEC LES IMAGES MONOTRAMES */
boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
switch (i_coding_type)
{
case B_CODING_TYPE:
if ((p_vpar->synchro.kludge_level <= p_vpar->synchro.kludge_nbp))
{
p_vpar->synchro.kludge_b++;
return( 0 );
}
if (p_vpar->synchro.kludge_b %
(p_vpar->synchro.kludge_nbb /
(p_vpar->synchro.kludge_level - p_vpar->synchro.kludge_nbp)))
{
p_vpar->synchro.kludge_b++;
return( 0 );
}
p_vpar->synchro.kludge_b++;
return( 1 );
case P_CODING_TYPE:
if (p_vpar->synchro.kludge_p++ >= p_vpar->synchro.kludge_level)
{
return( 0 );
}
return( 1 );
default:
return( 1 );
}
}
void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
if (DECODER_FIFO_START(p_vpar->fifo)->b_has_pts)
{
p_vpar->synchro.kludge_nbframes = 0;
p_vpar->synchro.kludge_date = DECODER_FIFO_START(p_vpar->fifo)->i_pts;
DECODER_FIFO_START(p_vpar->fifo)->b_has_pts = 0;
}
else
p_vpar->synchro.kludge_nbframes++;
}
void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
if (DECODER_FIFO_START(p_vpar->fifo)->b_has_pts)
{
p_vpar->synchro.kludge_nbframes = 0;
p_vpar->synchro.kludge_date = DECODER_FIFO_START(p_vpar->fifo)->i_pts;
DECODER_FIFO_START(p_vpar->fifo)->b_has_pts = 0;
}
else
p_vpar->synchro.kludge_nbframes++;
}
mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
{
return( p_vpar->synchro.kludge_date
+ p_vpar->synchro.kludge_nbframes*1000000/(p_vpar->sequence.r_frame_rate ) );
}
void vpar_SynchroEnd( vpar_thread_t * p_vpar )
{
}
void vpar_SynchroKludge( vpar_thread_t * p_vpar, mtime_t date )
{
mtime_t show_date;
int temp = p_vpar->synchro.kludge_level;
p_vpar->synchro.kludge_nbp = p_vpar->synchro.kludge_p ? p_vpar->synchro.kludge_p : 5;
p_vpar->synchro.kludge_nbb = p_vpar->synchro.kludge_b ? p_vpar->synchro.kludge_b : 6;
show_date = date - mdate();
p_vpar->synchro.kludge_p = 0;
p_vpar->synchro.kludge_b = 0;
if (show_date < (SYNC_DELAY - SYNC_TOLERATE) && show_date <= p_vpar->synchro.kludge_prevdate)
{
p_vpar->synchro.kludge_level--;
if (p_vpar->synchro.kludge_level < 0)
p_vpar->synchro.kludge_level = 0;
else if (p_vpar->synchro.kludge_level >
p_vpar->synchro.kludge_nbp + p_vpar->synchro.kludge_nbb)
p_vpar->synchro.kludge_level = p_vpar->synchro.kludge_nbp + p_vpar->synchro.kludge_nbb;
#ifdef DEBUG
if (temp != p_vpar->synchro.kludge_level)
intf_DbgMsg("vdec debug: Level changed from %d to %d (%Ld)\n",
temp, p_vpar->synchro.kludge_level, show_date );
#endif
}
else if (show_date > (SYNC_DELAY + SYNC_TOLERATE) && show_date >= p_vpar->synchro.kludge_prevdate)
{
p_vpar->synchro.kludge_level++;
if (p_vpar->synchro.kludge_level > p_vpar->synchro.kludge_nbp + p_vpar->synchro.kludge_nbb)
p_vpar->synchro.kludge_level = p_vpar->synchro.kludge_nbp + p_vpar->synchro.kludge_nbb;
#ifdef DEBUG
if (temp != p_vpar->synchro.kludge_level)
intf_DbgMsg("vdec debug: Level changed from %d to %d (%Ld)\n",
temp, p_vpar->synchro.kludge_level, show_date );
#endif
}
p_vpar->synchro.kludge_prevdate = show_date;
if ((p_vpar->synchro.kludge_level - p_vpar->synchro.kludge_nbp) > p_vpar->synchro.kludge_nbb)
p_vpar->synchro.kludge_level = p_vpar->synchro.kludge_nbb + p_vpar->synchro.kludge_nbp;
}
#endif
\ No newline at end of file
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