[Mplayer-cvslog] CVS: main cfg-mplayer.h,1.167,1.168 mplayer.c,1.583,1.584
Arpi of Ize
arpi at mplayerhq.hu
Wed Oct 2 00:29:07 CEST 2002
Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv25335
Modified Files:
cfg-mplayer.h mplayer.c
Log Message:
new opt: -autosync, controls ao->get_delay() smoothing (default: disabled)
patch by Sidik Isani <lksi at cfht.hawaii.edu>
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -r1.167 -r1.168
--- cfg-mplayer.h 29 Sep 2002 21:53:04 -0000 1.167
+++ cfg-mplayer.h 1 Oct 2002 22:29:03 -0000 1.168
@@ -349,6 +349,8 @@
{"playlist", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL},
// a-v sync stuff:
+ {"noautosync", &autosync, CONF_TYPE_FLAG, 0, 0, -1, NULL},
+ {"autosync", &autosync, CONF_TYPE_INT, CONF_RANGE, 0, 10000, NULL},
// {"dapsync", &dapsync, CONF_TYPE_FLAG, 0, 0, 1, NULL},
// {"nodapsync", &dapsync, CONF_TYPE_FLAG, 0, 1, 0, NULL},
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.583
retrieving revision 1.584
diff -u -r1.583 -r1.584
--- mplayer.c 29 Sep 2002 22:57:42 -0000 1.583
+++ mplayer.c 1 Oct 2002 22:29:03 -0000 1.584
@@ -164,6 +164,9 @@
static off_t step_sec=0;
static int loop_times=-1;
+// A/V sync:
+static int autosync=0; // 30 might be a good default value.
+
// may be changed by GUI: (FIXME!)
float rel_seek_secs=0;
int abs_seek_pos=0;
@@ -1446,7 +1449,16 @@
}
#endif
- if(drop_frame && !frame_time_remaining){
+ if(drop_frame && !frame_time_remaining && !autosync){
+ /*
+ * Note: time_frame should not be forced to 0 in autosync mode.
+ * It is used as a cumulative counter to predict and correct the
+ * delay measurements from the audio driver. time_frame is already
+ * < 0, so the "time to sleep" code does not actually sleep. Also,
+ * blit_frame is already 0 because drop_frame was true when
+ * decode_video was called (which causes it to set blit_frame to 0.)
+ * When autosync==0, the default behavior is still completely unchanged.
+ */
time_frame=0; // don't sleep!
blit_frame=0; // don't display!
@@ -1462,6 +1474,21 @@
float delay=audio_out->get_delay();
mp_dbg(MSGT_AVSYNC,MSGL_DBG2,"delay=%f\n",delay);
+ if (autosync){
+ /*
+ * Adjust this raw delay value by calculating the expected
+ * delay for this frame and generating a new value which is
+ * weighted between the two. The higher autosync is, the
+ * closer to the delay value gets to that which "-nosound"
+ * would have used, and the longer it will take for A/V
+ * sync to settle at the right value (but it eventually will.)
+ * This settling time is very short for values below 100.
+ */
+ float predicted = sh_audio->timer-sh_video->timer+time_frame;
+ float difference = delay - predicted;
+ delay = predicted + difference / (float)autosync;
+ }
+
time_frame=sh_video->timer;
time_frame-=sh_audio->timer-delay;
@@ -1564,6 +1591,22 @@
// unplayed bytes in our and soundcard/dma buffer:
float delay=audio_out->get_delay()+(float)sh_audio->a_buffer_len/(float)sh_audio->o_bps;
+
+ if (autosync){
+ /*
+ * If autosync is enabled, the value for delay must be calculated
+ * a bit differently. It is set only to the difference between
+ * the audio and video timers. Any attempt to include the real
+ * or corrected delay causes the pts_correction code below to
+ * try to correct for the changes in delay which autosync is
+ * trying to measure. This keeps the two from competing, but still
+ * allows the code to correct for PTS drift *only*. (Using a delay
+ * value here, even a "corrected" one, would be incompatible with
+ * autosync mode.)
+ */
+ delay=sh_audio->timer-sh_video->timer;
+ delay+=(float)sh_audio->a_buffer_len/(float)sh_audio->o_bps;
+ }
if(pts_from_bps){
// PTS = sample_no / samplerate
More information about the MPlayer-cvslog
mailing list