[Mplayer-cvslog] CVS: main/libaf af.c,1.12,1.13 af.h,1.7,1.8 af_resample.c,1.8,1.9 af_delay.c,1.2,1.3
Anders Johansson
anders at mplayerhq.hu
Tue Oct 8 12:20:52 CEST 2002
Update of /cvsroot/mplayer/main/libaf
In directory mail:/var/tmp.root/cvs-serv14281
Modified Files:
af.c af.h af_resample.c af_delay.c
Log Message:
Adding function for calculating the delay caused by the filters
Index: af.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- af.c 7 Oct 2002 10:46:01 -0000 1.12
+++ af.c 8 Oct 2002 10:20:36 -0000 1.13
@@ -487,6 +487,19 @@
return in;
}
+/* Calculate the total delay [ms] caused by the filters */
+double af_calc_delay(af_stream_t* s)
+{
+ af_instance_t* af=s->first;
+ register double delay = 0.0;
+ // Iterate through all filters
+ while(af){
+ delay += af->delay;
+ af=af->next;
+ }
+ return delay;
+}
+
/* Helper function called by the macro with the same name this
function should not be called directly */
inline int af_resize_local_buffer(af_instance_t* af, af_data_t* data)
Index: af.h
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- af.h 7 Oct 2002 10:46:01 -0000 1.7
+++ af.h 8 Oct 2002 10:20:36 -0000 1.8
@@ -48,6 +48,7 @@
af_data_t* data; // configuration for outgoing data stream
struct af_instance_s* next;
struct af_instance_s* prev;
+ double delay; // Delay caused by the filter [ms]
frac_t mul; /* length multiplier: how much does this instance change
the length of the buffer. */
}af_instance_t;
@@ -180,6 +181,8 @@
int af_calc_insize_constrained(af_stream_t* s, int len,
int max_outsize,int max_insize);
+/* Calculate the total delay caused by the filters */
+double af_calc_delay(af_stream_t* s);
// Helper functions and macros used inside the audio filters
Index: af_resample.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_resample.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- af_resample.c 6 Oct 2002 11:28:03 -0000 1.8
+++ af_resample.c 8 Oct 2002 10:20:36 -0000 1.9
@@ -258,7 +258,8 @@
mp_msg(MSGT_AFILTER,MSGL_V,"[resample] New filter designed up: %i down: %i\n", s->up, s->dn);
}
- // Set multiplier
+ // Set multiplier and delay
+ af->delay = (double)(1000*L/2)/((double)n->rate);
af->mul.n = s->up;
af->mul.d = s->dn;
return rv;
Index: af_delay.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_delay.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- af_delay.c 6 Oct 2002 11:26:14 -0000 1.2
+++ af_delay.c 8 Oct 2002 10:20:36 -0000 1.3
@@ -41,11 +41,13 @@
mp_msg(MSGT_AFILTER,MSGL_ERR,"Error setting delay length in af_delay. Delay must be between 0s and 30s\n");
s->len=0;
s->tlen=0.0;
+ af->delay=0.0;
return AF_ERROR;
}
// Set new len and allocate new buffer
s->tlen = *((float*)arg);
+ af->delay = s->tlen * 1000.0;
s->len = af->data->rate*af->data->bps*af->data->nch*(int)s->tlen;
s->buf = malloc(s->len);
mp_msg(MSGT_AFILTER,MSGL_DBG2,"[delay] Delaying audio output by %0.2fs\n",s->tlen);
More information about the MPlayer-cvslog
mailing list