Commit 3f579ea2 authored by Sam Hocevar's avatar Sam Hocevar

. correction d'un bug dans l'interface framebuffer

 . d�but de synchro qui marchouille, mais tous mes flux merdent
parent 5d7967a8
......@@ -32,8 +32,8 @@ SYS=LINUX
#SYS=BEOS
# Decoder choice - ?? old decoder will be removed soon
DECODER=old
#DECODER=new
#DECODER=old
DECODER=new
# Debugging mode on or off
DEBUG=1
......
......@@ -29,7 +29,8 @@ typedef struct video_synchro_fifo_s
{
/* type of image to be decoded, and decoding date */
int i_image_type;
mtime_t decode_date;
mtime_t i_decode_date;
mtime_t i_pts;
} video_synchro_fifo_t;
......@@ -40,11 +41,14 @@ typedef struct video_synchro_s
unsigned int i_fifo_start;
unsigned int i_fifo_stop;
/* 0: I
* 1: P
* 2: B
*/
mtime_t decode_time;
/* mean decoding time */
mtime_t i_mean_decode_time;
/* tells whether we accumulated delay */
mtime_t i_delay;
/* dates */
mtime_t i_last_pts;
mtime_t i_last_i_pts;
unsigned int i_images_since_pts;
/* il manquait un compteur */
unsigned int modulo;
......@@ -60,6 +64,9 @@ typedef struct video_synchro_s
video_synchro_tab_t tab_p[6];
video_synchro_tab_t tab_b[6];
double theorical_fps;
double actual_fps;
} video_synchro_t;
/*****************************************************************************
......
......@@ -245,13 +245,18 @@ static int InitThread( vpar_thread_t *p_vpar )
/*
* Initialize the synchro properties
*/
p_vpar->synchro.i_last_i_pts = 0;
p_vpar->synchro.theorical_fps = 30;
p_vpar->synchro.actual_fps = 25;
/* the fifo */
p_vpar->synchro.i_fifo_start = 0;
p_vpar->synchro.i_fifo_stop = 0;
/* the counter */
p_vpar->synchro.modulo = 0;
/* mean decoding time - at least 100 ms */
p_vpar->synchro.decode_time = 500000;
/* mean decoding time - at least 200 ms for a slow machine */
p_vpar->synchro.i_mean_decode_time = 200000;
/* suppose we have no delay */
p_vpar->synchro.i_delay = 0;
/* assume there were about 3 P and 6 B images between I's */
p_vpar->synchro.current_p_count = 1;
p_vpar->synchro.p_count_predict = 3;
......
......@@ -65,17 +65,48 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
float candidate_deviation;
float optimal_deviation;
float predict;
mtime_t i_current_pts;
decoder_fifo_t * decoder_fifo;
/* interpolate the current PTS */
decoder_fifo = p_vpar->bit_stream.p_decoder_fifo;
/* see if the current image has a pts - if not, interpolate */
if( i_current_pts = decoder_fifo->buffer[decoder_fifo->i_start]->i_pts )
{
p_vpar->synchro.i_images_since_pts = 1;
}
else
{
i_current_pts = p_vpar->synchro.i_last_pts
+ (1000000 / p_vpar->synchro.theorical_fps);
p_vpar->synchro.i_images_since_pts++;
}
p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_pts = i_current_pts;
p_vpar->synchro.i_last_pts = i_current_pts;
/* update structures */
switch(i_coding_type)
{
case P_CODING_TYPE:
p_vpar->synchro.current_p_count++;
break;
case B_CODING_TYPE:
p_vpar->synchro.current_b_count++;
break;
case I_CODING_TYPE:
/* update information about images we can decode */
if ( p_vpar->synchro.i_last_i_pts )
{
p_vpar->synchro.theorical_fps = 1000000 * (1 + p_vpar->synchro.current_b_count + p_vpar->synchro.current_p_count) / (i_current_pts - p_vpar->synchro.i_last_i_pts);
}
p_vpar->synchro.i_last_i_pts = i_current_pts;
/* update all the structures for P images */
/* period == 1 */
......@@ -138,12 +169,12 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
p_vpar->synchro.b_count_predict = predict;
p_vpar->synchro.current_b_count = 0;
break;
}
p_vpar->synchro.modulo++;
}
/*****************************************************************************
......@@ -152,24 +183,15 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar,
boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
static int meuh = 1;
static int truc = 0;
// return( 1 );
if( i_coding_type == 1 )
meuh = 1;
if( i_coding_type == 2 )
meuh++;
truc++;
if( truc == 3 )
if( p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_decode_date + ((p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start) & 0xf) * p_vpar->synchro.i_mean_decode_time > mdate() )
{
// while(1);
//fprintf( stderr, "chooser : we are la bourre !\n");
return( i_coding_type == I_CODING_TYPE );
}
return( i_coding_type == I_CODING_TYPE || (i_coding_type == P_CODING_TYPE) && (meuh == 2));
intf_DbgMsg("vpar debug: synchro image %i - modulo is %i\n", i_coding_type, p_vpar->synchro.modulo);
intf_DbgMsg("vpar debug: synchro predict P %e - predict B %e\n", p_vpar->synchro.p_count_predict, p_vpar->synchro.b_count_predict);
return(0);
return( i_coding_type == I_CODING_TYPE );
return( i_coding_type == I_CODING_TYPE || (i_coding_type == P_CODING_TYPE));
}
/*****************************************************************************
......@@ -178,8 +200,6 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
//fprintf ( stderr, "trashing type %i\n", p_vpar->picture.i_coding_type );
vpar_SynchroUpdateStructures (p_vpar, i_coding_type);
}
......@@ -190,16 +210,13 @@ void vpar_SynchroTrash( vpar_thread_t * p_vpar, int i_coding_type,
void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
int i_structure )
{
//fprintf ( stderr, "decoding type %i\n", p_vpar->picture.i_coding_type );
vpar_SynchroUpdateStructures (p_vpar, i_coding_type);
p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].decode_date = mdate();
p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_decode_date = mdate();
p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_stop].i_image_type
= i_coding_type;
p_vpar->synchro.i_fifo_stop = (p_vpar->synchro.i_fifo_stop + 1) & 0xf;
fprintf ( stderr, "%i images in synchro fifo\n", ( p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start ) & 0xf );
}
/*****************************************************************************
......@@ -207,19 +224,14 @@ void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type,
*****************************************************************************/
void vpar_SynchroEnd( vpar_thread_t * p_vpar )
{
mtime_t * p_decode_time;
mtime_t i_decode_time;
fprintf ( stderr, "type %i decoding time was %lli\n",
p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_image_type,
( mdate()
- p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].decode_date )
/ (( p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start ) & 0xf ));
i_decode_time = (mdate() -
p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_decode_date)
/ (p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start & 0x0f);
p_vpar->synchro.decode_time =
( (p_vpar->synchro.decode_time * 3) + (mdate()
- p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].decode_date)
/ (( p_vpar->synchro.i_fifo_stop - p_vpar->synchro.i_fifo_start)
& 0xf) ) >> 2;
p_vpar->synchro.i_mean_decode_time =
( 3 * p_vpar->synchro.i_mean_decode_time + i_decode_time ) / 4;
p_vpar->synchro.i_fifo_start = (p_vpar->synchro.i_fifo_start + 1) & 0xf;
}
......@@ -230,12 +242,17 @@ void vpar_SynchroEnd( vpar_thread_t * p_vpar )
mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
{
decoder_fifo_t * fifo;
mtime_t displaydate;
fifo = p_vpar->bit_stream.p_decoder_fifo;
displaydate = fifo->buffer[fifo->i_start]->i_pts;
mtime_t i_displaydate;
mtime_t i_delay;
i_displaydate =
p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_decode_date;
/* this value should be removed */
i_displaydate += 500000;
i_delay = i_displaydate - mdate();
//fprintf(stderr, "displaying type %i with delay %lli)\n", p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_image_type, i_delay);
if (displaydate) fprintf(stderr, "displaying type %i at %lli, (time %lli, delta %lli)\n", p_vpar->synchro.fifo[p_vpar->synchro.i_fifo_start].i_image_type, displaydate, mdate() + 1000000, displaydate - mdate() - 1000000);
return displaydate;
return i_displaydate;
}
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