summaryrefslogtreecommitdiff
path: root/src/xine-engine
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-11-12 18:40:50 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-11-12 18:40:50 +0000
commit5caae571ccadaaf00a90d4ec321c5ab4b4cc4191 (patch)
tree76f5a2032230468f0321cdccd221768b419ffec0 /src/xine-engine
parent1083056bd34700d1b21171cabf507eab1620be27 (diff)
downloadxine-lib-5caae571ccadaaf00a90d4ec321c5ab4b4cc4191.tar.gz
xine-lib-5caae571ccadaaf00a90d4ec321c5ab4b4cc4191.tar.bz2
merge metronom's improvements (inform decoders about discontinuities)
http://sourceforge.net/mailarchive/forum.php?thread_id=1297475&forum_id=7131 CVS patchset: 3250 CVS date: 2002/11/12 18:40:50
Diffstat (limited to 'src/xine-engine')
-rw-r--r--src/xine-engine/audio_decoder.c6
-rw-r--r--src/xine-engine/audio_decoder.h10
-rw-r--r--src/xine-engine/metronom.c68
-rw-r--r--src/xine-engine/metronom.h9
-rw-r--r--src/xine-engine/video_decoder.c13
-rw-r--r--src/xine-engine/video_decoder.h12
6 files changed, 36 insertions, 82 deletions
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c
index 82dc22baf..a7258618e 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.88 2002/10/31 16:58:14 mroi Exp $
+ * $Id: audio_decoder.c,v 1.89 2002/11/12 18:40:54 miguelfreitas Exp $
*
*
* functions that implement audio decoding
@@ -152,10 +152,14 @@ void *audio_decoder_loop (void *stream_gen) {
break;
case BUF_CONTROL_DISCONTINUITY:
+ if (stream->audio_decoder_plugin)
+ stream->audio_decoder_plugin->discontinuity (stream->audio_decoder_plugin);
stream->metronom->handle_audio_discontinuity (stream->metronom, DISC_RELATIVE, buf->disc_off);
break;
case BUF_CONTROL_NEWPTS:
+ if (stream->audio_decoder_plugin)
+ stream->audio_decoder_plugin->discontinuity (stream->audio_decoder_plugin);
if (buf->decoder_flags && BUF_FLAG_SEEK) {
stream->metronom->handle_audio_discontinuity (stream->metronom, DISC_STREAMSEEK, buf->disc_off);
} else {
diff --git a/src/xine-engine/audio_decoder.h b/src/xine-engine/audio_decoder.h
index fff415312..847ff9736 100644
--- a/src/xine-engine/audio_decoder.h
+++ b/src/xine-engine/audio_decoder.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: audio_decoder.h,v 1.5 2002/10/17 17:43:44 mroi Exp $
+ * $Id: audio_decoder.h,v 1.6 2002/11/12 18:40:54 miguelfreitas Exp $
*
* xine audio decoder plugin interface
*
@@ -29,7 +29,7 @@
#include <inttypes.h>
#include "buffer.h"
-#define AUDIO_DECODER_IFACE_VERSION 10
+#define AUDIO_DECODER_IFACE_VERSION 11
/*
* generic xine audio decoder plugin interface
@@ -79,6 +79,12 @@ struct audio_decoder_s {
void (*reset) (audio_decoder_t *this);
/*
+ * inform decoder that a time reference discontinuity has happened.
+ * that is, it must forget any currently held pts value
+ */
+ void (*discontinuity) (audio_decoder_t *this);
+
+ /*
* close down, free all resources
*/
void (*dispose) (audio_decoder_t *this);
diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c
index b8f750540..78b044b05 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.99 2002/11/10 13:33:16 mroi Exp $
+ * $Id: metronom.c,v 1.100 2002/11/12 18:40:54 miguelfreitas Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -260,24 +260,15 @@ static void metronom_set_audio_rate (metronom_t *this, int64_t pts_per_smpls) {
}
static int64_t metronom_got_spu_packet (metronom_t *this, int64_t pts) {
- int64_t vpts, video_vpts, vpts_old, vpts_new;
+ int64_t vpts;
pthread_mutex_lock (&this->lock);
- vpts_old = pts + this->old_vpts_offset;
- vpts_new = pts + this->vpts_offset;
- video_vpts = this->video_vpts;
if (pts >= 0 ) {
- if ( abs(vpts_old - video_vpts) > abs(vpts_new - video_vpts) ) {
- vpts = vpts_new;
- } else {
- vpts = vpts_old;
- }
- /* printf ("metronom: WARNING:got_spu_packet: vpts=%lld, old offset=%lld, new offset=%lld, video_vpts=%lld\n", vpts, vpts_old, vpts_new, video_vpts); */
+ vpts = pts + this->vpts_offset;
} else {
/* pts < 0 */
vpts = this->vpts_offset;
- /* printf ("metronom: WARNING:got_spu_packet: vpts_offset=%lld\n", vpts); */
}
pthread_mutex_unlock (&this->lock);
@@ -325,30 +316,12 @@ static void metronom_handle_video_discontinuity (metronom_t *this, int type,
printf ("metronom: video_vpts: %lld, audio_vpts: %lld\n", this->video_vpts, this->audio_vpts);
#endif
-/* What does this stuff ?
- diff = this->video_vpts - this->audio_vpts;
- if (abs(diff) > AV_DIFF_TOLERANCE) {
- if (this->video_vpts > this->audio_vpts)
- this->audio_vpts = this->video_vpts;
- else
- this->video_vpts = this->audio_vpts;
- } else {
- this->video_drift = diff;
- this->video_drift_step = diff / 30;
- }
-*/
- this->old_vpts_offset = this->vpts_offset;
-
switch (type) {
case DISC_STREAMSTART:
#ifdef LOG
printf ("metronom: DISC_STREAMSTART\n");
#endif
this->vpts_offset = this->video_vpts;
- this->video_discontinuity_pts = disc_off;
- this->audio_discontinuity_pts = disc_off;
- this->in_video_discontinuity = 0;
- this->in_audio_discontinuity = 0;
this->force_audio_jump = 1;
this->force_video_jump = 1;
this->video_drift = 0;
@@ -358,10 +331,6 @@ static void metronom_handle_video_discontinuity (metronom_t *this, int type,
printf ("metronom: DISC_ABSOLUTE\n");
#endif
this->vpts_offset = this->video_vpts - disc_off;
- this->video_discontinuity_pts = disc_off;
- this->audio_discontinuity_pts = disc_off;
- this->in_video_discontinuity = 30;
- this->in_audio_discontinuity = 30;
this->force_audio_jump = 0;
this->force_video_jump = 0;
break;
@@ -370,10 +339,6 @@ static void metronom_handle_video_discontinuity (metronom_t *this, int type,
printf ("metronom: DISC_RELATIVE\n");
#endif
this->vpts_offset = this->vpts_offset - disc_off;
- this->video_discontinuity_pts = this->video_vpts - this->vpts_offset;
- this->audio_discontinuity_pts = this->audio_vpts - this->vpts_offset;
- this->in_video_discontinuity = 30;
- this->in_audio_discontinuity = 30;
this->force_audio_jump = 0;
this->force_video_jump = 0;
break;
@@ -382,10 +347,6 @@ static void metronom_handle_video_discontinuity (metronom_t *this, int type,
printf ("metronom: DISC_STREAMSEEK\n");
#endif
this->vpts_offset = this->video_vpts - disc_off;
- this->video_discontinuity_pts = disc_off;
- this->audio_discontinuity_pts = disc_off;
- this->in_video_discontinuity = 30;
- this->in_audio_discontinuity = 30;
this->force_audio_jump = 1;
this->force_video_jump = 1;
this->video_drift = 0;
@@ -411,16 +372,6 @@ static void metronom_got_video_frame (metronom_t *this, vo_frame_t *img) {
printf("metronom: got_video_frame pts = %lld\n", pts );
#endif
- if (this->in_video_discontinuity) {
- this->in_video_discontinuity--;
-
- if (pts && (pts > this->video_discontinuity_pts)) {
- this->in_video_discontinuity = 0;
- } else {
- pts = 0; /* ignore pts during discontinuities */
- }
- }
-
this->img_cpt++;
if (pts) {
@@ -542,16 +493,6 @@ static int64_t metronom_got_audio_samples (metronom_t *this, int64_t pts,
pthread_mutex_lock (&this->lock);
- if (this->in_audio_discontinuity) {
- this->in_audio_discontinuity--;
-
- if (pts && (pts > this->audio_discontinuity_pts)) {
- this->in_audio_discontinuity = 0;
- } else {
- pts = 0; /* ignore pts during discontinuities */
- }
- }
-
if (pts) {
vpts = pts + this->vpts_offset;
diff = this->audio_vpts - vpts;
@@ -785,7 +726,6 @@ metronom_t * metronom_init (int have_audio, xine_stream_t *stream) {
this->av_offset = 0;
this->vpts_offset = 0;
- this->old_vpts_offset = 0;
/* initialize video stuff */
@@ -793,7 +733,6 @@ metronom_t * metronom_init (int have_audio, xine_stream_t *stream) {
this->video_drift = 0;
this->video_drift_step = 0;
this->video_discontinuity_count = 0;
- this->in_video_discontinuity = 0;
this->discontinuity_handled_count = 0;
pthread_cond_init (&this->video_discontinuity_reached, NULL);
this->img_duration = 3000;
@@ -805,7 +744,6 @@ metronom_t * metronom_init (int have_audio, xine_stream_t *stream) {
this->have_audio = have_audio;
this->audio_vpts = PREBUFFER_PTS_OFFSET;
- this->in_audio_discontinuity = 0;
this->audio_discontinuity_count = 0;
pthread_cond_init (&this->audio_discontinuity_reached, NULL);
diff --git a/src/xine-engine/metronom.h b/src/xine-engine/metronom.h
index 85d0c5eb6..0471d1209 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.39 2002/10/29 16:02:49 mroi Exp $
+ * $Id: metronom.h,v 1.40 2002/11/12 18:40:55 miguelfreitas Exp $
*
* metronom: general pts => virtual calculation/assoc
*
@@ -217,7 +217,6 @@ struct metronom_s {
int64_t audio_vpts;
int64_t vpts_offset;
- int64_t old_vpts_offset;
int64_t video_drift;
int64_t video_drift_step;
@@ -245,12 +244,6 @@ struct metronom_s {
int force_video_jump;
int force_audio_jump;
- int64_t video_discontinuity_pts;
- int64_t audio_discontinuity_pts;
-
- int in_video_discontinuity;
- int in_audio_discontinuity;
-
int64_t img_duration;
int img_cpt;
int64_t last_video_pts;
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index 23a4a17eb..7252818b5 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.108 2002/11/02 15:18:40 mroi Exp $
+ * $Id: video_decoder.c,v 1.109 2002/11/12 18:40:55 miguelfreitas Exp $
*
*/
@@ -244,18 +244,25 @@ void *video_decoder_loop (void *stream_gen) {
#ifdef LOG
printf ("video_decoder: discontinuity ahead\n");
#endif
-
+ if (stream->video_decoder_plugin) {
+ stream->video_decoder_plugin->discontinuity (stream->video_decoder_plugin);
+ }
+
stream->video_in_discontinuity = 1;
stream->metronom->handle_video_discontinuity (stream->metronom, DISC_RELATIVE, buf->disc_off);
stream->video_in_discontinuity = 0;
+
break;
case BUF_CONTROL_NEWPTS:
#ifdef LOG
printf ("video_decoder: new pts %lld\n", buf->disc_off);
#endif
+ if (stream->video_decoder_plugin) {
+ stream->video_decoder_plugin->discontinuity (stream->video_decoder_plugin);
+ }
stream->video_in_discontinuity = 1;
@@ -265,7 +272,7 @@ void *video_decoder_loop (void *stream_gen) {
stream->metronom->handle_video_discontinuity (stream->metronom, DISC_ABSOLUTE, buf->disc_off);
}
stream->video_in_discontinuity = 0;
-
+
break;
case BUF_CONTROL_AUDIO_CHANNEL:
diff --git a/src/xine-engine/video_decoder.h b/src/xine-engine/video_decoder.h
index 24a5f650d..022371128 100644
--- a/src/xine-engine/video_decoder.h
+++ b/src/xine-engine/video_decoder.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_decoder.h,v 1.5 2002/10/17 17:43:44 mroi Exp $
+ * $Id: video_decoder.h,v 1.6 2002/11/12 18:40:55 miguelfreitas Exp $
*
* xine video decoder plugin interface
*
@@ -29,7 +29,7 @@
#include <inttypes.h>
#include "buffer.h"
-#define VIDEO_DECODER_IFACE_VERSION 11
+#define VIDEO_DECODER_IFACE_VERSION 12
/*
* generic xine video decoder plugin interface
@@ -79,6 +79,12 @@ struct video_decoder_s {
void (*reset) (video_decoder_t *this);
/*
+ * inform decoder that a time reference discontinuity has happened.
+ * that is, it must forget any currently held pts value
+ */
+ void (*discontinuity) (video_decoder_t *this);
+
+ /*
* flush out any frames that are still stored in the decoder
*/
void (*flush) (video_decoder_t *this);
@@ -86,7 +92,7 @@ struct video_decoder_s {
/*
* close down, free all resources
*/
- void (*dispose) (video_decoder_t *this);
+ void (*dispose) (video_decoder_t *this);
void *node; /*used by plugin loader */