summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorcorey <corey@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-02-07 20:22:44 +0000
committercorey <corey@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-02-07 20:22:44 +0000
commit15debd85d2181b75d1e2a1e0e0ffeed4b98f821f (patch)
treef7322d7d1585a290d33f0d83194e502a374b3061 /libmpdemux
parent5d1bccd70c0c9fd25c9d60fea303234ce2b609c9 (diff)
downloadmpv-15debd85d2181b75d1e2a1e0e0ffeed4b98f821f.tar.bz2
mpv-15debd85d2181b75d1e2a1e0e0ffeed4b98f821f.tar.xz
1. Include audio_delay as an argument to demux_seek.
2. Modify demux_seek_avi to adjust the audio/video stream positions so that mplayer/mencoder will instantly be in sync even when -delay is specified. Other demuxers could be modified similarly in the future. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17554 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_asf.c2
-rw-r--r--libmpdemux/demux_avi.c9
-rw-r--r--libmpdemux/demux_avs.c2
-rw-r--r--libmpdemux/demux_demuxers.c8
-rw-r--r--libmpdemux/demux_film.c2
-rw-r--r--libmpdemux/demux_fli.c2
-rw-r--r--libmpdemux/demux_lavf.c4
-rw-r--r--libmpdemux/demux_mf.c2
-rw-r--r--libmpdemux/demux_mov.c2
-rw-r--r--libmpdemux/demux_mpg.c2
-rw-r--r--libmpdemux/demux_nsv.c2
-rw-r--r--libmpdemux/demux_nuv.c2
-rw-r--r--libmpdemux/demux_pva.c2
-rw-r--r--libmpdemux/demux_rawdv.c2
-rw-r--r--libmpdemux/demux_real.c2
-rw-r--r--libmpdemux/demux_realaud.c2
-rw-r--r--libmpdemux/demux_ts.c2
-rw-r--r--libmpdemux/demux_ty.c2
-rw-r--r--libmpdemux/demux_vqf.c2
-rw-r--r--libmpdemux/demux_y4m.c2
-rw-r--r--libmpdemux/demuxer.c2
-rw-r--r--libmpdemux/demuxer.h2
22 files changed, 30 insertions, 29 deletions
diff --git a/libmpdemux/demux_asf.c b/libmpdemux/demux_asf.c
index a072b1c640..dd8d1a90e6 100644
--- a/libmpdemux/demux_asf.c
+++ b/libmpdemux/demux_asf.c
@@ -369,7 +369,7 @@ static int demux_asf_fill_buffer(demuxer_t *demux, demux_stream_t *ds){
extern void skip_audio_frame(sh_audio_t *sh_audio);
-static void demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,int flags){
+static void demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
sh_audio_t *sh_audio=d_audio->sh;
diff --git a/libmpdemux/demux_avi.c b/libmpdemux/demux_avi.c
index 6febdd160c..21ab48dc6c 100644
--- a/libmpdemux/demux_avi.c
+++ b/libmpdemux/demux_avi.c
@@ -618,7 +618,7 @@ static demuxer_t* demux_open_avi(demuxer_t* demuxer){
//extern float initial_pts_delay;
-void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags){
+void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
avi_priv_t *priv=demuxer->priv;
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
@@ -706,8 +706,8 @@ void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags){
curr_audio_pos/=align;
curr_audio_pos*=align;
#else
- curr_audio_pos=(priv->avi_video_pts)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale;
- curr_audio_pos-=sh_audio->audio.dwStart;
+ /* immediate seeking to audio position, including when streams are delayed */
+ curr_audio_pos=(priv->avi_video_pts + audio_delay)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale;
curr_audio_pos*=sh_audio->audio.dwSampleSize;
#endif
@@ -733,7 +733,8 @@ void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags){
} else {
// VBR audio
- int chunks=(priv->avi_video_pts)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale;
+ /* immediate seeking to audio position, including when streams are delayed */
+ int chunks=(priv->avi_video_pts + audio_delay)*(float)sh_audio->audio.dwRate/(float)sh_audio->audio.dwScale;
audio_chunk_pos=0;
// find audio chunk pos:
diff --git a/libmpdemux/demux_avs.c b/libmpdemux/demux_avs.c
index bc3829da4d..7c8de70225 100644
--- a/libmpdemux/demux_avs.c
+++ b/libmpdemux/demux_avs.c
@@ -375,7 +375,7 @@ static void demux_close_avs(demuxer_t* demuxer)
}
}
-static void demux_seek_avs(demuxer_t *demuxer, float rel_seek_secs,int flags)
+static void demux_seek_avs(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
{
demux_stream_t *d_video=demuxer->video;
sh_video_t *sh_video=d_video->sh;
diff --git a/libmpdemux/demux_demuxers.c b/libmpdemux/demux_demuxers.c
index a3e294a04c..092be8d505 100644
--- a/libmpdemux/demux_demuxers.c
+++ b/libmpdemux/demux_demuxers.c
@@ -57,7 +57,7 @@ static int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds) {
return 0;
}
-static void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,int flags) {
+static void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags) {
dd_priv_t* priv;
float pos;
priv=demuxer->priv;
@@ -66,13 +66,13 @@ static void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,int flags
priv->sd->stream->eof = 0;
// Seek video
- demux_seek(priv->vd,rel_seek_secs,flags);
+ demux_seek(priv->vd,rel_seek_secs,audio_delay,flags);
// Get the new pos
pos = demuxer->video->pts;
if(priv->ad != priv->vd) {
sh_audio_t* sh = (sh_audio_t*)demuxer->audio->sh;
- demux_seek(priv->ad,pos,1);
+ demux_seek(priv->ad,pos,audio_delay,1);
// In case the demuxer don't set pts
if(!demuxer->audio->pts)
demuxer->audio->pts = pos-((ds_tell_pts(demuxer->audio)-sh->a_in_buffer_len)/(float)sh->i_bps);
@@ -80,7 +80,7 @@ static void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,int flags
}
if(priv->sd != priv->vd)
- demux_seek(priv->sd,pos,1);
+ demux_seek(priv->sd,pos,audio_delay,1);
}
diff --git a/libmpdemux/demux_film.c b/libmpdemux/demux_film.c
index a15a252e84..04e5b95481 100644
--- a/libmpdemux/demux_film.c
+++ b/libmpdemux/demux_film.c
@@ -46,7 +46,7 @@ typedef struct _film_data_t
unsigned int film_version;
} film_data_t;
-static void demux_seek_film(demuxer_t *demuxer, float rel_seek_secs, int flags)
+static void demux_seek_film(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
{
film_data_t *film_data = (film_data_t *)demuxer->priv;
int new_current_chunk=(flags&1)?0:film_data->current_chunk;
diff --git a/libmpdemux/demux_fli.c b/libmpdemux/demux_fli.c
index 2b23835c52..6750a256b4 100644
--- a/libmpdemux/demux_fli.c
+++ b/libmpdemux/demux_fli.c
@@ -22,7 +22,7 @@ typedef struct _fli_frames_t {
unsigned int *frame_size;
} fli_frames_t;
-static void demux_seek_fli(demuxer_t *demuxer,float rel_seek_secs,int flags){
+static void demux_seek_fli(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
fli_frames_t *frames = (fli_frames_t *)demuxer->priv;
sh_video_t *sh_video = demuxer->video->sh;
int newpos=(flags&1)?0:frames->current_frame;
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index d22f627021..c5a6556c20 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -389,9 +389,9 @@ static int demux_lavf_fill_buffer(demuxer_t *demux, demux_stream_t *dsds){
return 1;
}
-static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, int flags){
+static void demux_seek_lavf(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags){
lavf_priv_t *priv = demuxer->priv;
- mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %d)\n", demuxer, rel_seek_secs, flags);
+ mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_seek_lavf(%p, %f, %f, %d)\n", demuxer, rel_seek_secs, audio_delay, flags);
#if LIBAVFORMAT_BUILD < 4619
av_seek_frame(priv->avfc, -1, priv->last_pts + rel_seek_secs*AV_TIME_BASE);
diff --git a/libmpdemux/demux_mf.c b/libmpdemux/demux_mf.c
index 5139640faa..771101f3d2 100644
--- a/libmpdemux/demux_mf.c
+++ b/libmpdemux/demux_mf.c
@@ -15,7 +15,7 @@
#include "stheader.h"
#include "mf.h"
-static void demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,int flags){
+static void demux_seek_mf(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
mf_t * mf = (mf_t *)demuxer->priv;
sh_video_t * sh_video = demuxer->video->sh;
int newpos = (flags & 1)?0:mf->curr_frame;
diff --git a/libmpdemux/demux_mov.c b/libmpdemux/demux_mov.c
index ae2b06abe5..3537ce39ce 100644
--- a/libmpdemux/demux_mov.c
+++ b/libmpdemux/demux_mov.c
@@ -2007,7 +2007,7 @@ if(trak->samplesize){
return pts;
}
-static void demux_seek_mov(demuxer_t *demuxer,float pts,int flags){
+static void demux_seek_mov(demuxer_t *demuxer,float pts,float audio_delay,int flags){
mov_priv_t* priv=demuxer->priv;
demux_stream_t* ds;
mov_track_t* trak;
diff --git a/libmpdemux/demux_mpg.c b/libmpdemux/demux_mpg.c
index 9b11dc88a1..647ece7e83 100644
--- a/libmpdemux/demux_mpg.c
+++ b/libmpdemux/demux_mpg.c
@@ -676,7 +676,7 @@ do{
extern void skip_audio_frame(sh_audio_t *sh_audio);
-void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags){
+void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,float audio_delay, int flags){
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
sh_audio_t *sh_audio=d_audio->sh;
diff --git a/libmpdemux/demux_nsv.c b/libmpdemux/demux_nsv.c
index 92942599e5..94a0e3f68f 100644
--- a/libmpdemux/demux_nsv.c
+++ b/libmpdemux/demux_nsv.c
@@ -34,7 +34,7 @@ typedef struct {
/**
* Seeking still to be implemented
*/
-static void demux_seek_nsv ( demuxer_t *demuxer, float rel_seek_secs, int flags )
+static void demux_seek_nsv ( demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags )
{
// seeking is not yet implemented
}
diff --git a/libmpdemux/demux_nuv.c b/libmpdemux/demux_nuv.c
index a09ad71d7a..4263c0ef25 100644
--- a/libmpdemux/demux_nuv.c
+++ b/libmpdemux/demux_nuv.c
@@ -63,7 +63,7 @@ static int nearestBitrate(int bitrate) {
/**
* Seek to a position relative to the current position, indicated in time.
*/
-static void demux_seek_nuv ( demuxer_t *demuxer, float rel_seek_secs, int flags )
+static void demux_seek_nuv ( demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags )
{
#define MAX_TIME 1000000
nuv_priv_t* priv = demuxer->priv;
diff --git a/libmpdemux/demux_pva.c b/libmpdemux/demux_pva.c
index 0ad8faf87a..419536d3dc 100644
--- a/libmpdemux/demux_pva.c
+++ b/libmpdemux/demux_pva.c
@@ -466,7 +466,7 @@ int pva_get_payload(demuxer_t * d,pva_payload_t * payload)
return 1;
}
-static void demux_seek_pva(demuxer_t * demuxer,float rel_seek_secs,int flags)
+static void demux_seek_pva(demuxer_t * demuxer,float rel_seek_secs,float audio_delay,int flags)
{
int total_bitrate=0;
off_t dest_offset;
diff --git a/libmpdemux/demux_rawdv.c b/libmpdemux/demux_rawdv.c
index 1d4886ff98..8163a34fc0 100644
--- a/libmpdemux/demux_rawdv.c
+++ b/libmpdemux/demux_rawdv.c
@@ -36,7 +36,7 @@ typedef struct
dv_decoder_t *decoder;
} rawdv_frames_t;
-static void demux_seek_rawdv(demuxer_t *demuxer,float rel_seek_secs,int flags)
+static void demux_seek_rawdv(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags)
{
rawdv_frames_t *frames = (rawdv_frames_t *)demuxer->priv;
sh_video_t *sh_video = demuxer->video->sh;
diff --git a/libmpdemux/demux_real.c b/libmpdemux/demux_real.c
index a4acc6fe4f..2f7e9bc574 100644
--- a/libmpdemux/demux_real.c
+++ b/libmpdemux/demux_real.c
@@ -1825,7 +1825,7 @@ static void demux_close_real(demuxer_t *demuxer)
}
/* please upload RV10 samples WITH INDEX CHUNK */
-static void demux_seek_real(demuxer_t *demuxer, float rel_seek_secs, int flags)
+static void demux_seek_real(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
{
real_priv_t *priv = demuxer->priv;
demux_stream_t *d_audio = demuxer->audio;
diff --git a/libmpdemux/demux_realaud.c b/libmpdemux/demux_realaud.c
index 2d4a1672e9..1346e34bc2 100644
--- a/libmpdemux/demux_realaud.c
+++ b/libmpdemux/demux_realaud.c
@@ -341,7 +341,7 @@ static void demux_close_ra(demuxer_t *demuxer)
#if 0
/* please upload RV10 samples WITH INDEX CHUNK */
-int demux_seek_ra(demuxer_t *demuxer, float rel_seek_secs, int flags)
+int demux_seek_ra(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
{
real_priv_t *priv = demuxer->priv;
demux_stream_t *d_audio = demuxer->audio;
diff --git a/libmpdemux/demux_ts.c b/libmpdemux/demux_ts.c
index 9e73c01408..be3adfcafb 100644
--- a/libmpdemux/demux_ts.c
+++ b/libmpdemux/demux_ts.c
@@ -3071,7 +3071,7 @@ extern int videobuf_code_len;
extern int sync_video_packet(demux_stream_t *);
extern int skip_video_packet(demux_stream_t *);
-static void demux_seek_ts(demuxer_t *demuxer, float rel_seek_secs, int flags)
+static void demux_seek_ts(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags)
{
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
diff --git a/libmpdemux/demux_ty.c b/libmpdemux/demux_ty.c
index 385ccbb909..d5a07386ba 100644
--- a/libmpdemux/demux_ty.c
+++ b/libmpdemux/demux_ty.c
@@ -1237,7 +1237,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
return( 1 );
}
-static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, int flags )
+static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags )
{
demux_stream_t *d_audio = demuxer->audio;
demux_stream_t *d_video = demuxer->video;
diff --git a/libmpdemux/demux_vqf.c b/libmpdemux/demux_vqf.c
index 092b0d6cd9..6ce7082a24 100644
--- a/libmpdemux/demux_vqf.c
+++ b/libmpdemux/demux_vqf.c
@@ -179,7 +179,7 @@ static int demux_vqf_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) {
return 1;
}
-static void demux_seek_vqf(demuxer_t *demuxer,float rel_seek_secs,int flags){
+static void demux_seek_vqf(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
#if 0
stream_t* s = demuxer->stream;
sh_audio_t* sh_audio = demuxer->audio->sh;
diff --git a/libmpdemux/demux_y4m.c b/libmpdemux/demux_y4m.c
index 2fe784b4a7..58a8afcb9a 100644
--- a/libmpdemux/demux_y4m.c
+++ b/libmpdemux/demux_y4m.c
@@ -231,7 +231,7 @@ static demuxer_t* demux_open_y4m(demuxer_t* demuxer){
return demuxer;
}
-static void demux_seek_y4m(demuxer_t *demuxer, float rel_seek_secs, int flags) {
+static void demux_seek_y4m(demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags) {
sh_video_t* sh = demuxer->video->sh;
y4m_priv_t* priv = demuxer->priv;
int rel_seek_frames = sh->fps*rel_seek_secs;
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index 8ff2fc747f..181a16d3a6 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -859,7 +859,7 @@ demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int
}
-int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
+int demux_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
demux_stream_t *d_audio=demuxer->audio;
demux_stream_t *d_video=demuxer->video;
sh_audio_t *sh_audio=d_audio->sh;
diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h
index e184280b40..51f0b4c45f 100644
--- a/libmpdemux/demuxer.h
+++ b/libmpdemux/demuxer.h
@@ -300,7 +300,7 @@ static inline int avi_stream_id(unsigned int id){
}
demuxer_t* demux_open(stream_t *stream,int file_format,int aid,int vid,int sid,char* filename);
-int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags);
+int demux_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags);
demuxer_t* new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd);
// AVI demuxer params: