summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Schaefer <heikos@users.sourceforge.net>2001-11-13 21:47:57 +0000
committerHeiko Schaefer <heikos@users.sourceforge.net>2001-11-13 21:47:57 +0000
commit96056accd3b60b48527d521b85a3d50d78d3d42f (patch)
treefc93f084460362a7c1fd4162ef1957fd9caefccb
parent40ff01806b091bd7c5419d8f411906d504d33252 (diff)
downloadxine-lib-96056accd3b60b48527d521b85a3d50d78d3d42f.tar.gz
xine-lib-96056accd3b60b48527d521b85a3d50d78d3d42f.tar.bz2
metronom logic changed
CVS patchset: 1030 CVS date: 2001/11/13 21:47:57
-rw-r--r--src/demuxers/demux_mpeg.c25
-rw-r--r--src/liba52/xine_decoder.c6
-rw-r--r--src/libdivx4/xine_decoder.c6
-rw-r--r--src/libdts/xine_decoder.c6
-rw-r--r--src/libffmpeg/xine_decoder.c11
-rw-r--r--src/liblpcm/xine_decoder.c6
-rw-r--r--src/libmad/xine_decoder.c6
-rw-r--r--src/libmpeg2/decode.c21
-rw-r--r--src/libmpeg2/mpeg2.h1
-rw-r--r--src/libmpeg2/xine_decoder.c14
-rw-r--r--src/libvfill/xine_decoder.c8
-rw-r--r--src/libvorbis/xine_decoder.c6
-rw-r--r--src/libw32dll/w32codec.c14
-rw-r--r--src/xine-engine/audio_decoder.c14
-rw-r--r--src/xine-engine/metronom.c123
-rw-r--r--src/xine-engine/metronom.h5
-rw-r--r--src/xine-engine/video_decoder.c43
-rw-r--r--src/xine-engine/video_out.c35
-rw-r--r--src/xine-engine/video_out.h3
-rw-r--r--src/xine-engine/xine_internal.h6
20 files changed, 259 insertions, 100 deletions
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index 67de987c3..8ee0109e5 100644
--- a/src/demuxers/demux_mpeg.c
+++ b/src/demuxers/demux_mpeg.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg.c,v 1.42 2001/11/10 13:48:02 guenter Exp $
+ * $Id: demux_mpeg.c,v 1.43 2001/11/13 21:47:57 heikos Exp $
*
* demultiplexer for mpeg 1/2 program streams
* reads streams of variable blocksizes
@@ -519,6 +519,29 @@ static uint32_t parse_pack(demux_mpeg_t *this) {
buf = read_bytes (this, 3) ;
}
+ /* discontinuity ? */
+ {
+ int32_t scr_diff = scr - this->last_scr;
+ if (abs(scr_diff) > 60000) {
+
+ buf_element_t *buf;
+
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->type = BUF_CONTROL_AVSYNC_RESET;
+ buf->SCR = scr;
+ this->video_fifo->put (this->video_fifo, buf);
+
+ if (this->audio_fifo) {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = BUF_CONTROL_AVSYNC_RESET;
+ buf->SCR = scr;
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+ }
+ this->last_scr = scr;
+ }
+
+
/* system header */
buf = read_bytes (this, 4) ;
diff --git a/src/liba52/xine_decoder.c b/src/liba52/xine_decoder.c
index cc7dcd4f9..d431cc01c 100644
--- a/src/liba52/xine_decoder.c
+++ b/src/liba52/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.7 2001/11/10 13:48:02 guenter Exp $
+ * $Id: xine_decoder.c,v 1.8 2001/11/13 21:47:58 heikos Exp $
*
* stuff needed to turn liba52 into a xine decoder plugin
*/
@@ -469,7 +469,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
a52dec_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "liba52: plugin doesn't support plugin API version %d.\n"
"liba52: this means there's a version mismatch between xine and this "
"liba52: decoder plugin.\nInstalling current plugins should help.\n",
@@ -480,7 +480,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
this = (a52dec_decoder_t *) malloc (sizeof (a52dec_decoder_t));
memset(this, 0, sizeof (a52dec_decoder_t));
- this->audio_decoder.interface_version = 2;
+ this->audio_decoder.interface_version = 3;
this->audio_decoder.can_handle = a52dec_can_handle;
this->audio_decoder.init = a52dec_init;
this->audio_decoder.decode_data = a52dec_decode_data;
diff --git a/src/libdivx4/xine_decoder.c b/src/libdivx4/xine_decoder.c
index 9267c10ad..cbab42157 100644
--- a/src/libdivx4/xine_decoder.c
+++ b/src/libdivx4/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.8 2001/11/03 23:02:43 hrm Exp $
+ * $Id: xine_decoder.c,v 1.9 2001/11/13 21:47:58 heikos Exp $
*
* xine decoder plugin using divx4
*
@@ -371,7 +371,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
decoreFunc libdecore_func = 0;
int version;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "divx4: plugin doesn't support plugin API version %d.\n"
"divx4: this means there's a version mismatch between xine and this "
"divx4: decoder plugin.\nInstalling current plugins should help.\n",
@@ -439,7 +439,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
this = (divx4_decoder_t *) malloc (sizeof (divx4_decoder_t));
- this->video_decoder.interface_version = 2;
+ this->video_decoder.interface_version = 3;
this->video_decoder.can_handle = divx4_can_handle;
this->video_decoder.init = divx4_init;
this->video_decoder.decode_data = divx4_decode_data;
diff --git a/src/libdts/xine_decoder.c b/src/libdts/xine_decoder.c
index b831c15f6..52bf21fd7 100644
--- a/src/libdts/xine_decoder.c
+++ b/src/libdts/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.2 2001/11/10 13:48:02 guenter Exp $
+ * $Id: xine_decoder.c,v 1.3 2001/11/13 21:47:58 heikos Exp $
*
* 04-09-2001 DTS passtrough (C) Joachim Koenig
*
@@ -113,7 +113,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
dts_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "libdts: plugin doesn't support plugin API version %d.\n"
"libdts: this means there's a version mismatch between xine and this "
"libdts: decoder plugin.\nInstalling current plugins should help.\n",
@@ -123,7 +123,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
this = (dts_decoder_t *) malloc (sizeof (dts_decoder_t));
- this->audio_decoder.interface_version = 2;
+ this->audio_decoder.interface_version = 3;
this->audio_decoder.can_handle = dts_can_handle;
this->audio_decoder.init = dts_init;
this->audio_decoder.decode_data = dts_decode_data;
diff --git a/src/libffmpeg/xine_decoder.c b/src/libffmpeg/xine_decoder.c
index e35499055..7c23f4a5f 100644
--- a/src/libffmpeg/xine_decoder.c
+++ b/src/libffmpeg/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.17 2001/11/07 21:35:01 miguelfreitas Exp $
+ * $Id: xine_decoder.c,v 1.18 2001/11/13 21:47:58 heikos Exp $
*
* xine decoder plugin using ffmpeg
*
@@ -318,6 +318,10 @@ static void ff_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
}
}
+static void ff_flush (video_decoder_t *this_gen) {
+
+}
+
static void ff_close (video_decoder_t *this_gen) {
ff_decoder_t *this = (ff_decoder_t *) this_gen;
@@ -339,7 +343,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
ff_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "ffmpeg: plugin doesn't support plugin API version %d.\n"
"ffmpeg: this means there's a version mismatch between xine and this "
"ffmpeg: decoder plugin.\nInstalling current plugins should help.\n",
@@ -350,10 +354,11 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
this = (ff_decoder_t *) malloc (sizeof (ff_decoder_t));
- this->video_decoder.interface_version = 2;
+ this->video_decoder.interface_version = 3;
this->video_decoder.can_handle = ff_can_handle;
this->video_decoder.init = ff_init;
this->video_decoder.decode_data = ff_decode_data;
+ this->video_decoder.flush = ff_flush;
this->video_decoder.close = ff_close;
this->video_decoder.get_identifier = ff_get_id;
this->video_decoder.priority = 5;
diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c
index fa45cd7bd..2f482dd15 100644
--- a/src/liblpcm/xine_decoder.c
+++ b/src/liblpcm/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.13 2001/11/10 13:48:02 guenter Exp $
+ * $Id: xine_decoder.c,v 1.14 2001/11/13 21:47:58 heikos Exp $
*
* 31-8-2001 Added LPCM rate sensing.
* (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk
@@ -146,7 +146,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
lpcm_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "liblpcm: plugin doesn't support plugin API version %d.\n"
"liblpcm: this means there's a version mismatch between xine and this "
"liblpcm: decoder plugin.\nInstalling current plugins should help.\n",
@@ -156,7 +156,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
this = (lpcm_decoder_t *) malloc (sizeof (lpcm_decoder_t));
- this->audio_decoder.interface_version = 2;
+ this->audio_decoder.interface_version = 3;
this->audio_decoder.can_handle = lpcm_can_handle;
this->audio_decoder.init = lpcm_init;
this->audio_decoder.decode_data = lpcm_decode_data;
diff --git a/src/libmad/xine_decoder.c b/src/libmad/xine_decoder.c
index dd775740c..5a621c4a5 100644
--- a/src/libmad/xine_decoder.c
+++ b/src/libmad/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.8 2001/11/10 13:48:02 guenter Exp $
+ * $Id: xine_decoder.c,v 1.9 2001/11/13 21:47:58 heikos Exp $
*
* stuff needed to turn libmad into a xine decoder plugin
*/
@@ -246,7 +246,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
mad_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "libmad: plugin doesn't support plugin API version %d.\n"
"libmad: this means there's a version mismatch between xine and this "
"libmad: decoder plugin.\nInstalling current plugins should help.\n",
@@ -257,7 +257,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
this = (mad_decoder_t *) malloc (sizeof (mad_decoder_t));
- this->audio_decoder.interface_version = 2;
+ this->audio_decoder.interface_version = 3;
this->audio_decoder.can_handle = mad_can_handle;
this->audio_decoder.init = mad_init;
this->audio_decoder.decode_data = mad_decode_data;
diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c
index fb28f5d28..1064e6fed 100644
--- a/src/libmpeg2/decode.c
+++ b/src/libmpeg2/decode.c
@@ -119,8 +119,9 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
picture->current_frame->free (picture->current_frame);
picture->current_frame = NULL;
picture->throwaway_frame = NULL;
- } else if (picture->forward_reference_frame) {
+ } else if (picture->forward_reference_frame && !picture->forward_reference_frame->drawn) {
mpeg2dec->frames_to_drop = picture->forward_reference_frame->draw (picture->forward_reference_frame);
+ picture->forward_reference_frame->drawn = 1;
}
#ifdef ARCH_X86
@@ -256,6 +257,7 @@ static inline int parse_chunk (mpeg2dec_t * mpeg2dec, int code,
picture->backward_reference_frame = picture->current_frame;
}
picture->current_frame->bad_frame = 0;
+ picture->current_frame->drawn = 0;
picture->current_frame->PTS = mpeg2dec->pts;
picture->current_frame->SCR = mpeg2dec->scr;
mpeg2dec->pts = 0;
@@ -354,6 +356,21 @@ int mpeg2_decode_data (mpeg2dec_t * mpeg2dec, uint8_t * current, uint8_t * end,
return ret;
}
+void mpeg2_flush (mpeg2dec_t * mpeg2dec) {
+
+ picture_t *picture = mpeg2dec->picture;
+
+ if (picture->backward_reference_frame && !picture->backward_reference_frame->drawn) {
+ printf ("libmpeg2: blasting out backward reference frame on flush\n");
+ picture->backward_reference_frame->PTS = 0;
+ picture->backward_reference_frame->SCR = mpeg2dec->scr;
+ picture->backward_reference_frame->bad_frame = 0;
+ picture->backward_reference_frame->drawn = 1;
+ picture->backward_reference_frame->draw (picture->backward_reference_frame);
+ }
+
+}
+
void mpeg2_close (mpeg2dec_t * mpeg2dec)
{
picture_t *picture = mpeg2dec->picture;
@@ -389,7 +406,7 @@ void mpeg2_close (mpeg2dec_t * mpeg2dec)
picture->throwaway_frame->free (picture->throwaway_frame);
}
- if (picture->backward_reference_frame) {
+ if (picture->backward_reference_frame && !picture->backward_reference_frame->drawn) {
printf ("libmpeg2: blasting out backward reference frame on close\n");
picture->backward_reference_frame->PTS = 0;
picture->backward_reference_frame->SCR = mpeg2dec->scr;
diff --git a/src/libmpeg2/mpeg2.h b/src/libmpeg2/mpeg2.h
index c4f250f6d..32ea7a72e 100644
--- a/src/libmpeg2/mpeg2.h
+++ b/src/libmpeg2/mpeg2.h
@@ -66,3 +66,4 @@ void mpeg2_find_sequence_header (mpeg2dec_t * mpeg2dec,
uint8_t * data_start, uint8_t * data_end);
+void mpeg2_flush (mpeg2dec_t * mpeg2dec);
diff --git a/src/libmpeg2/xine_decoder.c b/src/libmpeg2/xine_decoder.c
index 5c4885237..e7c9920a3 100644
--- a/src/libmpeg2/xine_decoder.c
+++ b/src/libmpeg2/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.16 2001/11/10 13:48:03 guenter Exp $
+ * $Id: xine_decoder.c,v 1.17 2001/11/13 21:47:58 heikos Exp $
*
* stuff needed to turn libmpeg2 into a xine decoder plugin
*/
@@ -78,6 +78,13 @@ static void mpeg2dec_decode_data (video_decoder_t *this_gen, buf_element_t *buf)
}
+static void mpeg2dec_flush (video_decoder_t *this_gen) {
+ mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
+
+ mpeg2_flush (&this->mpeg2);
+
+}
+
static void mpeg2dec_close (video_decoder_t *this_gen) {
mpeg2dec_decoder_t *this = (mpeg2dec_decoder_t *) this_gen;
@@ -101,7 +108,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
mpeg2dec_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "libmpeg2: plugin doesn't support plugin API version %d.\n"
"libmpeg2: this means there's a version mismatch between xine and this "
"libmpeg2: decoder plugin.\nInstalling current plugins should help.\n",
@@ -112,10 +119,11 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
this = (mpeg2dec_decoder_t *) malloc (sizeof (mpeg2dec_decoder_t));
memset(this, 0, sizeof (mpeg2dec_decoder_t));
- this->video_decoder.interface_version = 2;
+ this->video_decoder.interface_version = 3;
this->video_decoder.can_handle = mpeg2dec_can_handle;
this->video_decoder.init = mpeg2dec_init;
this->video_decoder.decode_data = mpeg2dec_decode_data;
+ this->video_decoder.flush = mpeg2dec_flush;
this->video_decoder.close = mpeg2dec_close;
this->video_decoder.get_identifier = mpeg2dec_get_id;
this->video_decoder.priority = 1;
diff --git a/src/libvfill/xine_decoder.c b/src/libvfill/xine_decoder.c
index 658cfed6b..328f1feb7 100644
--- a/src/libvfill/xine_decoder.c
+++ b/src/libvfill/xine_decoder.c
@@ -107,6 +107,9 @@ static void videofill_decode_data (video_decoder_t *this_gen, buf_element_t *buf
/* printf ("\n"); */
}
+static void videofill_flush (video_decoder_t *this_gen) {
+}
+
static void videofill_close (video_decoder_t *this_gen) {
videofill_decoder_t *this = (videofill_decoder_t *) this_gen;
@@ -122,7 +125,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
videofill_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "videofill: plugin doesn't support plugin API version %d.\n"
"videofill: this means there's a version mismatch between xine and this "
"videofill: decoder plugin.\nInstalling current plugins should help.\n",
@@ -132,10 +135,11 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
this = (videofill_decoder_t *) malloc (sizeof (videofill_decoder_t));
- this->video_decoder.interface_version = 2;
+ this->video_decoder.interface_version = 3;
this->video_decoder.can_handle = videofill_can_handle;
this->video_decoder.init = videofill_init;
this->video_decoder.decode_data = videofill_decode_data;
+ this->video_decoder.flush = videofill_flush;
this->video_decoder.close = videofill_close;
this->video_decoder.get_identifier = videofill_get_id;
this->video_decoder.priority = 2;
diff --git a/src/libvorbis/xine_decoder.c b/src/libvorbis/xine_decoder.c
index 6d2ee9a7e..b03ed6d8b 100644
--- a/src/libvorbis/xine_decoder.c
+++ b/src/libvorbis/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.2 2001/11/10 13:48:03 guenter Exp $
+ * $Id: xine_decoder.c,v 1.3 2001/11/13 21:47:59 heikos Exp $
*
* (ogg/)vorbis audio decoder plugin (libvorbis wrapper) for xine
*/
@@ -228,7 +228,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
vorbis_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "libvorbis: plugin doesn't support plugin API version %d.\n"
"libvorbis: this means there's a version mismatch between xine and this "
"libvorbis: decoder plugin.\nInstalling current plugins should help.\n",
@@ -239,7 +239,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
this = (vorbis_decoder_t *) malloc (sizeof (vorbis_decoder_t));
- this->audio_decoder.interface_version = 2;
+ this->audio_decoder.interface_version = 3;
this->audio_decoder.can_handle = vorbis_can_handle;
this->audio_decoder.init = vorbis_init;
this->audio_decoder.decode_data = vorbis_decode_data;
diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c
index c49971680..9d93508ff 100644
--- a/src/libw32dll/w32codec.c
+++ b/src/libw32dll/w32codec.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: w32codec.c,v 1.40 2001/11/10 13:48:03 guenter Exp $
+ * $Id: w32codec.c,v 1.41 2001/11/13 21:47:59 heikos Exp $
*
* routines for using w32 codecs
*
@@ -533,6 +533,9 @@ static void w32v_decode_data (video_decoder_t *this_gen, buf_element_t *buf) {
}
}
+static void w32v_flush (video_decoder_t *this_gen) {
+}
+
static void w32v_close (video_decoder_t *this_gen) {
w32v_decoder_t *this = (w32v_decoder_t *) this_gen;
@@ -803,7 +806,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
w32v_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "w32codec: plugin doesn't support plugin API version %d.\n"
"w32codec: this means there's a version mismatch between xine and this "
"w32codec: decoder plugin.\nInstalling current input plugins should help.\n",
@@ -816,10 +819,11 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, config_values_t *
this = (w32v_decoder_t *) malloc (sizeof (w32v_decoder_t));
- this->video_decoder.interface_version = 2;
+ this->video_decoder.interface_version = 3;
this->video_decoder.can_handle = w32v_can_handle;
this->video_decoder.init = w32v_init;
this->video_decoder.decode_data = w32v_decode_data;
+ this->video_decoder.flush = w32v_flush;
this->video_decoder.close = w32v_close;
this->video_decoder.get_identifier = w32v_get_id;
this->video_decoder.priority = 1;
@@ -835,7 +839,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
w32a_decoder_t *this ;
- if (iface_version != 2) {
+ if (iface_version != 3) {
printf( "w32codec: plugin doesn't support plugin API version %d.\n"
"w32codec: this means there's a version mismatch between xine and this "
"w32codec: decoder plugin.\nInstalling current input plugins should help.\n",
@@ -848,7 +852,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *
this = (w32a_decoder_t *) malloc (sizeof (w32a_decoder_t));
- this->audio_decoder.interface_version = 2;
+ this->audio_decoder.interface_version = 3;
this->audio_decoder.can_handle = w32a_can_handle;
this->audio_decoder.init = w32a_init;
this->audio_decoder.decode_data = w32a_decode_data;
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c
index 0e920f477..797059eb5 100644
--- a/src/xine-engine/audio_decoder.c
+++ b/src/xine-engine/audio_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: audio_decoder.c,v 1.51 2001/11/10 13:48:03 guenter Exp $
+ * $Id: audio_decoder.c,v 1.52 2001/11/13 21:47:59 heikos Exp $
*
*
* functions that implement audio decoding
@@ -52,14 +52,17 @@ void *audio_decoder_loop (void *this_gen) {
while (running) {
- /* printf ("audio_loop: waiting for package...\n"); */
+#ifdef AUDIO_DECODER_LOG
+ printf ("audio_loop: waiting for package...\n");
+#endif
buf = this->audio_fifo->get (this->audio_fifo);
- /*
+
+#ifdef AUDIO_DECODER_LOG
printf ("audio_loop: got package pts = %d, type = %08x\n",
buf->PTS, buf->type);
- */
+#endif
if (buf->input_pos)
this->cur_input_pos = buf->input_pos;
@@ -140,6 +143,7 @@ void *audio_decoder_loop (void *this_gen) {
if (this->cur_audio_decoder_plugin) {
this->cur_audio_decoder_plugin->close (this->cur_audio_decoder_plugin);
this->cur_audio_decoder_plugin = NULL;
+ this->audio_type = 0;
}
this->metronom->expect_audio_discontinuity (this->metronom);
@@ -274,7 +278,7 @@ void audio_decoder_init (xine_t *this) {
return;
}
- this->audio_fifo = fifo_buffer_new (1500, 8192);
+ this->audio_fifo = fifo_buffer_new (20, 8192);
this->audio_channel = -1;
this->audio_channel_suggested = -1;
this->audio_type = 0;
diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c
index 8e7d593fe..e15907cc0 100644
--- a/src/xine-engine/metronom.c
+++ b/src/xine-engine/metronom.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: metronom.c,v 1.34 2001/11/10 14:57:20 heikos Exp $
+ * $Id: metronom.c,v 1.35 2001/11/13 21:47:59 heikos Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -243,14 +243,13 @@ static void metronom_video_stream_start (metronom_t *this) {
}
this->pts_per_frame = 3000;
+ this->avg_frame_duration = 3000;
this->video_vpts = PREBUFFER_PTS_OFFSET;
- this->video_pts_delta = 0;
-
this->last_video_pts = 0;
this->last_video_scr = 0;
- this->num_video_vpts_guessed = 1;
+ this->num_video_vpts_guessed = 0;
this->video_wrap_offset = PREBUFFER_PTS_OFFSET;
this->wrap_diff_counter = 0;
@@ -362,7 +361,7 @@ static void metronom_audio_stream_end (metronom_t *this) {
/* while (this->video_stream_running) { */
if (this->video_stream_running) {
- printf ("waiting for video to end...\n");
+ printf ("metronom: waiting for video to end...\n");
pthread_cond_wait (&this->video_ended, &this->lock);
}
@@ -375,11 +374,13 @@ static void metronom_set_video_rate (metronom_t *this, uint32_t pts_per_frame) {
this->pts_per_frame = pts_per_frame;
+ this->avg_frame_duration = this->pts_per_frame;
+
pthread_mutex_unlock (&this->lock);
}
static uint32_t metronom_get_video_rate (metronom_t *this) {
- return this->pts_per_frame + this->video_pts_delta;
+ return this->avg_frame_duration;
}
static void metronom_set_audio_rate (metronom_t *this, uint32_t pts_per_smpls) {
@@ -432,8 +433,11 @@ static void metronom_expect_video_discontinuity (metronom_t *this) {
printf("metronom: video vpts adjusted to %d\n", this->video_vpts);
}
- this->num_video_vpts_guessed = 1;
+ this->num_video_vpts_guessed = 0;
this->last_video_pts = this->video_vpts - this->video_wrap_offset;
+
+ this->avg_frame_duration = this->pts_per_frame;
+ this->frames_since_start = 0;
printf ("metronom: video discontinuity => last_video_pts=%d, wrap_offset=%d, video_vpts=%d\n",
this->last_video_pts, this->video_wrap_offset, this->video_vpts);
@@ -443,8 +447,6 @@ static void metronom_expect_video_discontinuity (metronom_t *this) {
static uint32_t metronom_got_video_frame (metronom_t *this, uint32_t pts, uint32_t scr) {
- uint32_t vpts;
-
pthread_mutex_lock (&this->lock);
if (pts) {
@@ -457,19 +459,17 @@ static uint32_t metronom_got_video_frame (metronom_t *this, uint32_t pts, uint32
this->video_stream_starting = 0;
this->video_wrap_offset += this->last_video_pts - pts
- + this->num_video_vpts_guessed
- * (this->pts_per_frame + this->video_pts_delta);
+ + (this->num_video_vpts_guessed+1) * this->avg_frame_duration;
printf ("metronom: video pts discontinuity, pts is %d, last_pts is %d, wrap_offset = %d\n",
pts, this->last_video_pts, this->video_wrap_offset);
+ this->last_video_pts = 0;
}
/*
- * audio and video wrap are not allowed to differ
- * for too long
+ * audio and video wrap are not allowed to differ for too long
*/
-
if ( !this->audio_stream_starting && this->have_audio
&& (this->video_wrap_offset != this->audio_wrap_offset)) {
this->wrap_diff_counter++;
@@ -484,45 +484,100 @@ static uint32_t metronom_got_video_frame (metronom_t *this, uint32_t pts, uint32
else
this->video_wrap_offset = this->audio_wrap_offset;
- printf ("to %d\n", this->video_wrap_offset);
+ printf (" to %d\n", this->video_wrap_offset);
this->wrap_diff_counter = 0;
}
}
- vpts = pts + this->video_wrap_offset;
-
/*
- * calc delta to compensate wrong framerates
+ * calc overall average frame duration (according to pts values)
*/
-
- if (this->last_video_pts && (pts>this->last_video_pts)) {
- int32_t vpts_diff;
+ if (this->frames_since_start && this->last_video_pts) {
+ int current_avg_delta;
- vpts_diff = vpts - this->video_vpts;
+ int weight_old = 9;
+ int weight_new = 1;
- this->video_pts_delta += vpts_diff / (this->num_video_vpts_guessed);
-
- if (abs(this->video_pts_delta) >= MAX_VIDEO_DELTA)
- this->video_pts_delta = 0;
+ /*
+ printf("foo: pts %d, last pts %d\n", pts, this->last_video_pts);
+ */
+
+ if (pts > this->last_video_pts) {
+ current_avg_delta = (pts - this->last_video_pts) / (this->num_video_vpts_guessed + 1);
+
+ /*
+ printf("foo: current_avg_delta %d\n", current_avg_delta);
+ */
+
+ this->avg_frame_duration =
+ (((this->avg_frame_duration * weight_old) + (current_avg_delta * weight_new)) /
+ (weight_old + weight_new));
+ } else {
+ current_avg_delta = (this->last_video_pts - pts) / (this->num_video_vpts_guessed + 1);
+
+ /*
+ printf("foo: current_avg_delta - %d\n", current_avg_delta);
+ */
+
+ this->avg_frame_duration =
+ (((this->avg_frame_duration * weight_old) - (current_avg_delta * weight_new)) /
+ (weight_old + weight_new));
+ }
}
- this->num_video_vpts_guessed = 0;
this->last_video_pts = pts;
- this->video_vpts = vpts;
+ }
+
+ this->video_vpts += this->avg_frame_duration;
+
+ if (pts) {
+ int drift;
+ int delta = this->video_vpts - this->video_wrap_offset - pts;
+
+#ifdef METRONOM_LOG
+ printf("metronom: delta: %d\n", delta);
+#endif
+
+ /* does xine need this ?!
+ if (abs (delta) > 30000) {
+
+ discontinuity
+
+ this->video_vpts = pts + this->this->video_wrap_offset;
+
+ printf ("metronom: disc. detected\n");
+
+
+ } else {
+ */
+
+ if (this->num_video_vpts_guessed > 10)
+ this->num_video_vpts_guessed = 10;
+
+ drift = delta / 20 * (this->num_video_vpts_guessed + 1);
+#ifdef METRONOM_LOG
+ printf("metronom: compensating drift: %d\n", drift);
+#endif
+
+ this->video_vpts -= drift;
+
+ this->num_video_vpts_guessed = 0;
} else
- vpts = this->video_vpts;
+ this->num_video_vpts_guessed++;
- this->video_vpts += this->pts_per_frame + this->video_pts_delta;
- this->num_video_vpts_guessed++ ;
+ this->frames_since_start++;
#ifdef METRONOM_LOG
- printf ("metronom: video vpts for %10d : %10d\n", pts, vpts);
+ printf("metronom: stats: %d num guessed, %d avg_frame_duration. %d frames since start\n",
+ this->num_video_vpts_guessed, this->avg_frame_duration, this->frames_since_start);
+
+ printf ("metronom: video vpts for %10d : %10d\n", pts, this->video_vpts);
#endif
pthread_mutex_unlock (&this->lock);
- return vpts + this->av_offset;
+ return this->video_vpts + this->av_offset;
}
static void metronom_expect_audio_discontinuity (metronom_t *this) {
@@ -581,7 +636,7 @@ static uint32_t metronom_got_audio_samples (metronom_t *this, uint32_t pts,
+ this->num_audio_samples_guessed
* (this->audio_pts_delta + this->pts_per_smpls) / AUDIO_SAMPLE_NUM ;
- printf ("metronom: audio pts discontinuity, pts is %d, last_pts is %d, wrap_offset = %d\n",
+ printf ("metronom: audio pts discontinuity/start, pts is %d, last_pts is %d, wrap_offset = %d\n",
pts, this->last_audio_pts, this->audio_wrap_offset);
}
diff --git a/src/xine-engine/metronom.h b/src/xine-engine/metronom.h
index 097983f09..22b02f892 100644
--- a/src/xine-engine/metronom.h
+++ b/src/xine-engine/metronom.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: metronom.h,v 1.13 2001/11/10 13:48:03 guenter Exp $
+ * $Id: metronom.h,v 1.14 2001/11/13 21:47:59 heikos Exp $
*
* metronom: general pts => virtual calculation/assoc
*
@@ -198,7 +198,6 @@ struct metronom_s {
uint32_t last_video_pts;
uint32_t last_video_scr;
int num_video_vpts_guessed;
- int32_t video_pts_delta;
uint32_t last_audio_pts;
uint32_t last_audio_scr;
@@ -228,6 +227,8 @@ struct metronom_s {
pthread_cond_t video_ended;
pthread_cond_t audio_ended;
+ int frames_since_start;
+ int avg_frame_duration;
};
metronom_t *metronom_init (int have_audio);
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index bd4a53caf..20a59d96b 100644
--- a/src/xine-engine/video_decoder.c
+++ b/src/xine-engine/video_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_decoder.c,v 1.62 2001/11/10 13:48:03 guenter Exp $
+ * $Id: video_decoder.c,v 1.63 2001/11/13 21:47:59 heikos Exp $
*
*/
@@ -33,6 +33,10 @@
#include "monitor.h"
#include <sched.h>
+/*
+#define VIDEO_DECODER_LOG
+*/
+
static spu_decoder_t* update_spu_decoder(xine_t *this, int type) {
int streamtype = (type>>16) & 0xFF;
spu_decoder_t *spu_decoder = this->spu_decoder_plugins [streamtype];
@@ -68,15 +72,41 @@ void *video_decoder_loop (void *this_gen) {
while (running) {
- /* printf ("video_decoder: getting buffer...\n"); */
+#ifdef VIDEO_DECODER_LOG
+ printf ("video_decoder: getting buffer...\n");
+#endif
+
+ /*
+
+ I dont know if this will ever work - highly experimental,
+ let xine itself detect when to insert still images
+
+ if (!this->video_fifo->first) {
+
+#ifdef VIDEO_DECODER_LOG
+ printf ("video_decoder: ... inserting still ...\n");
+#endif
+
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+
+ buf->type = BUF_VIDEO_FILL ;
+ buf->PTS = 0;
+ buf->SCR = 0;
+ this->cur_input_pos = 0;
+ this->cur_input_time = 0;
+
+ } else */
buf = this->video_fifo->get (this->video_fifo);
+
if (buf->input_pos)
this->cur_input_pos = buf->input_pos;
if (buf->input_time)
this->cur_input_time = buf->input_time;
- /* printf ("video_decoder: got buffer 0x%08x\n", buf->type); */
+#ifdef VIDEO_DECODER_LOG
+ printf ("video_decoder: got buffer 0x%08x\n", buf->type);
+#endif
switch (buf->type & 0xffff0000) {
case BUF_CONTROL_START:
@@ -166,11 +196,8 @@ void *video_decoder_loop (void *this_gen) {
case BUF_CONTROL_AVSYNC_RESET:
printf ("video_decoder: discontinuity ahead\n");
- /* fixme ? */
- if (this->cur_video_decoder_plugin) {
- this->cur_video_decoder_plugin->close (this->cur_video_decoder_plugin);
- this->cur_video_decoder_plugin = NULL;
- }
+ if (this->cur_video_decoder_plugin)
+ this->cur_video_decoder_plugin->flush (this->cur_video_decoder_plugin);
this->metronom->expect_video_discontinuity (this->metronom);
break;
diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c
index cd274d291..c13b34583 100644
--- a/src/xine-engine/video_out.c
+++ b/src/xine-engine/video_out.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out.c,v 1.52 2001/11/10 13:48:03 guenter Exp $
+ * $Id: video_out.c,v 1.53 2001/11/13 21:47:59 heikos Exp $
*
*/
@@ -36,6 +36,10 @@
#include "utils.h"
#include "monitor.h"
+/*
+#define VIDEO_OUT_LOG
+*/
+
#define NUM_FRAME_BUFFERS 15
struct img_buf_fifo_s {
@@ -201,8 +205,10 @@ static void *video_out_loop (void *this_gen) {
cur_pts = this->metronom->get_current_time (this->metronom);
xprintf (VERBOSE|VIDEO, "video_out : video loop iteration at audio pts %d\n", cur_pts);
- /*printf ("video_out : video loop iteration at audio pts %d\n", cur_pts);
- fflush (stdout); */
+
+#ifdef VIDEO_OUT_LOG
+ printf ("video_out : video loop iteration at audio pts %d\n", cur_pts);
+#endif
img = this->display_img_buf_queue->first;
@@ -226,12 +232,9 @@ static void *video_out_loop (void *this_gen) {
"it's too old (diff : %d > %d).\n",pts,diff,
this->pts_per_half_frame);
- /*
- fprintf (stderr,
- "video_out : throwing away image with pts %d because "
+ printf ( "video_out : throwing away image with pts %d because "
"it's too old (diff : %d > %d).\n",pts,diff,
this->pts_per_half_frame);
- */
this->num_frames_discarded++;
@@ -256,10 +259,9 @@ static void *video_out_loop (void *this_gen) {
* time to display frame 0 ?
*/
- /*
+#ifdef VIDEO_OUT_LOG
printf ("video_out: diff %d\n", diff);
- fflush(stdout);
- */
+#endif
if (diff<0) {
profiler_stop_count (prof_video_out);
@@ -271,10 +273,13 @@ static void *video_out_loop (void *this_gen) {
* remove frame from display queue and show it
*/
- xprintf (VERBOSE|VIDEO, "video_out : displaying image with pts = %d (diff=%d)\n", pts, diff);
+#ifdef VIDEO_OUT_LOG
+ printf ("video_out : displaying image with pts = %d (diff=%d)\n", pts, diff);
+#endif
img = vo_remove_from_img_buf_queue (this->display_img_buf_queue);
+
if (!img) {
profiler_stop_count (prof_video_out);
continue;
@@ -287,7 +292,9 @@ static void *video_out_loop (void *this_gen) {
img->display_locked = 0;
pthread_mutex_unlock (&img->mutex);
- xprintf (VERBOSE|VIDEO, "video_out : passing to video driver, image with pts = %d\n", pts);
+#ifdef VIDEO_OUT_LOG
+ printf ("video_out : passing to video driver, image with pts = %d\n", pts);
+#endif
if (this->overlay_source) {
/* This is the only way for the spu decoder to get pts values
@@ -471,10 +478,10 @@ static int vo_frame_draw (vo_frame_t *img) {
pic_vpts = this->metronom->got_video_frame (this->metronom, img->PTS, img->SCR);
- /*
+#ifdef VIDEO_OUT_LOG
printf ("video_out: got image %d. vpts for picture is %d (pts was %d)\n",
img, pic_vpts, img->PTS);
- */
+#endif
img->PTS = pic_vpts;
this->num_frames_delivered++;
diff --git a/src/xine-engine/video_out.h b/src/xine-engine/video_out.h
index 26ed87b8a..a57e2bba1 100644
--- a/src/xine-engine/video_out.h
+++ b/src/xine-engine/video_out.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_out.h,v 1.27 2001/11/10 13:48:03 guenter Exp $
+ * $Id: video_out.h,v 1.28 2001/11/13 21:47:59 heikos Exp $
*
*
* xine version of video_out.h
@@ -62,6 +62,7 @@ struct vo_frame_s {
uint32_t PTS;
uint32_t SCR;
int bad_frame; /* e.g. frame skipped or based on skipped frame */
+ int drawn;
uint8_t *base[3];
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 9c4783617..99628c7e5 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_internal.h,v 1.53 2001/10/25 00:47:03 miguelfreitas Exp $
+ * $Id: xine_internal.h,v 1.54 2001/11/13 21:47:59 heikos Exp $
*
*/
@@ -52,7 +52,7 @@ extern "C" {
#define INPUT_PLUGIN_MAX 50
#define DEMUXER_PLUGIN_MAX 50
#define DECODER_PLUGIN_MAX 256
-#define DECODER_PLUGIN_IFACE_VERSION 2
+#define DECODER_PLUGIN_IFACE_VERSION 3
#define AUDIO_OUT_PLUGIN_MAX 50
#define VIDEO_OUT_PLUGIN_MAX 50
#define XINE_MAX_EVENT_LISTENERS 50
@@ -77,6 +77,8 @@ struct video_decoder_s {
void (*decode_data) (video_decoder_t *this, buf_element_t *buf);
+ void (*flush) (video_decoder_t *this);
+
void (*close) (video_decoder_t *this);
char* (*get_identifier) (void);