diff --git a/include/vlc.h b/include/vlc.h index ea47bfb85e..5337ff4a85 100644 --- a/include/vlc.h +++ b/include/vlc.h @@ -33,11 +33,13 @@ #include #include +#ifdef VIDEO_X11 #include #include #include #include #include +#endif diff --git a/src/generic_decoder/generic_decoder.c b/src/generic_decoder/generic_decoder.c index 3eed0ef88e..eecb901e76 100644 --- a/src/generic_decoder/generic_decoder.c +++ b/src/generic_decoder/generic_decoder.c @@ -23,8 +23,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/input/input.c b/src/input/input.c index 01146df7df..effc49daed 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -16,10 +16,6 @@ #include #include -#include -#include -#include - #include #include #include diff --git a/src/input/input_ctrl.c b/src/input/input_ctrl.c index 96505db003..3f3ac483bd 100644 --- a/src/input/input_ctrl.c +++ b/src/input/input_ctrl.c @@ -20,9 +20,6 @@ #include #include -#include -#include -#include #include /* ntohs */ #include "common.h" diff --git a/src/input/input_psi.c b/src/input/input_psi.c index f6cf9e6637..9809473b4f 100644 --- a/src/input/input_psi.c +++ b/src/input/input_psi.c @@ -21,8 +21,6 @@ #include #include #include -#include -#include #include "common.h" #include "config.h" diff --git a/src/interface/control.c b/src/interface/control.c index f16bebe819..5e74bb52f5 100644 --- a/src/interface/control.c +++ b/src/interface/control.c @@ -17,8 +17,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/interface/intf_cmd.c b/src/interface/intf_cmd.c index 7e08308b4d..af02111a27 100644 --- a/src/interface/intf_cmd.c +++ b/src/interface/intf_cmd.c @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/interface/intf_ctrl.c b/src/interface/intf_ctrl.c index 6d919a333d..1a4d70fa8a 100644 --- a/src/interface/intf_ctrl.c +++ b/src/interface/intf_ctrl.c @@ -35,8 +35,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/video_decoder/vdec_idct.c b/src/video_decoder/vdec_idct.c index a590a95d27..da8c934b1c 100644 --- a/src/video_decoder/vdec_idct.c +++ b/src/video_decoder/vdec_idct.c @@ -13,8 +13,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/video_decoder/vdec_motion.c b/src/video_decoder/vdec_motion.c index 50258cadf6..1fd1c30564 100644 --- a/src/video_decoder/vdec_motion.c +++ b/src/video_decoder/vdec_motion.c @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/video_decoder/video_decoder.c b/src/video_decoder/video_decoder.c index 0a7365e343..06fa5f789c 100644 --- a/src/video_decoder/video_decoder.c +++ b/src/video_decoder/video_decoder.c @@ -16,8 +16,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/video_parser/video_fifo.c b/src/video_parser/video_fifo.c index 2e46d87db0..5cb176b3c6 100644 --- a/src/video_parser/video_fifo.c +++ b/src/video_parser/video_fifo.c @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/video_parser/video_parser.c b/src/video_parser/video_parser.c index 6435279678..3177681bb3 100644 --- a/src/video_parser/video_parser.c +++ b/src/video_parser/video_parser.c @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" @@ -235,7 +233,13 @@ static int InitThread( vpar_thread_t *p_vpar ) /* * Initialize the synchro properties */ + /* 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; /* 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; diff --git a/src/video_parser/vpar_blocks.c b/src/video_parser/vpar_blocks.c index dd446d011e..2ac9a05945 100644 --- a/src/video_parser/vpar_blocks.c +++ b/src/video_parser/vpar_blocks.c @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/video_parser/vpar_headers.c b/src/video_parser/vpar_headers.c index 310e11b868..159f3dbca2 100644 --- a/src/video_parser/vpar_headers.c +++ b/src/video_parser/vpar_headers.c @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/video_parser/vpar_motion.c b/src/video_parser/vpar_motion.c index 5bf6bbc652..dfd6475050 100644 --- a/src/video_parser/vpar_motion.c +++ b/src/video_parser/vpar_motion.c @@ -14,8 +14,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" diff --git a/src/video_parser/vpar_synchro.c b/src/video_parser/vpar_synchro.c index cf3438c485..a92079c041 100644 --- a/src/video_parser/vpar_synchro.c +++ b/src/video_parser/vpar_synchro.c @@ -12,8 +12,6 @@ #include #include #include -#include -#include #include "config.h" #include "common.h" @@ -51,8 +49,9 @@ float vpar_SynchroUpdateTab( video_synchro_tab_t * tab, int count ) { - tab->mean = ( tab->mean + 3 * count ) / 4; - tab->deviation = ( tab->deviation + 3 * abs (tab->mean - count) ) / 4; + tab->mean = ( tab->mean + MAX_COUNT * count ) / ( MAX_COUNT + 1 ); + tab->deviation = ( tab->deviation + MAX_COUNT * abs (tab->mean - count) ) + / ( MAX_COUNT + 1 ); return tab->deviation; } @@ -78,11 +77,14 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar, case I_CODING_TYPE: /* update all the structures for P images */ + + /* period == 1 */ optimal_deviation = vpar_SynchroUpdateTab( &p_vpar->synchro.tab_p[0], p_vpar->synchro.current_p_count); predict = p_vpar->synchro.tab_p[0].mean; + /* period == 2 */ candidate_deviation = vpar_SynchroUpdateTab( &p_vpar->synchro.tab_p[1 + (p_vpar->synchro.modulo & 0x1)], p_vpar->synchro.current_p_count); @@ -92,6 +94,7 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar, predict = p_vpar->synchro.tab_p[1 + (p_vpar->synchro.modulo & 0x1)].mean; } + /* period == 3 */ candidate_deviation = vpar_SynchroUpdateTab( &p_vpar->synchro.tab_p[3 + (p_vpar->synchro.modulo % 3)], p_vpar->synchro.current_p_count); @@ -106,11 +109,14 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar, /* update all the structures for B images */ + + /* period == 1 */ optimal_deviation = vpar_SynchroUpdateTab( &p_vpar->synchro.tab_b[0], p_vpar->synchro.current_b_count); predict = p_vpar->synchro.tab_b[0].mean; + /* period == 2 */ candidate_deviation = vpar_SynchroUpdateTab( &p_vpar->synchro.tab_b[1 + (p_vpar->synchro.modulo & 0x1)], p_vpar->synchro.current_b_count); @@ -120,6 +126,7 @@ void vpar_SynchroUpdateStructures( vpar_thread_t * p_vpar, predict = p_vpar->synchro.tab_b[1 + (p_vpar->synchro.modulo & 0x1)].mean; } + /* period == 3 */ candidate_deviation = vpar_SynchroUpdateTab( &p_vpar->synchro.tab_b[3 + (p_vpar->synchro.modulo % 3)], p_vpar->synchro.current_b_count); @@ -148,16 +155,16 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type, static int meuh = 1; static int truc = 0; // return( 1 ); -// if( i_coding_type == 1 ) -// meuh = 0; -// if( i_coding_type == 2 ) -// meuh++; + if( i_coding_type == 1 ) + meuh = 1; + if( i_coding_type == 2 ) + meuh++; truc++; if( truc == 3 ) { // while(1); } - return( i_coding_type == I_CODING_TYPE || (i_coding_type == P_CODING_TYPE && meuh == 1) ); + 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); @@ -171,6 +178,8 @@ 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); } @@ -181,7 +190,16 @@ 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_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 ); } /***************************************************************************** @@ -189,12 +207,35 @@ void vpar_SynchroDecode( vpar_thread_t * p_vpar, int i_coding_type, *****************************************************************************/ void vpar_SynchroEnd( vpar_thread_t * p_vpar ) { - -// return mdate() + 700000; + mtime_t * p_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 )); + + 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_fifo_start = (p_vpar->synchro.i_fifo_start + 1) & 0xf; } +/***************************************************************************** + * vpar_SynchroDate : When an image has been decoded, ask for its date + *****************************************************************************/ mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar ) { - return mdate() + 700000; + decoder_fifo_t * fifo; + mtime_t displaydate; + + fifo = p_vpar->bit_stream.p_decoder_fifo; + displaydate = fifo->buffer[fifo->i_start]->i_pts; + + 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; }