Mercurial > mplayer.hg
changeset 7665:fbd5445cc853
Adding function for calculating the delay caused by the filters
author | anders |
---|---|
date | Tue, 08 Oct 2002 10:20:36 +0000 |
parents | b10d6345f2a6 |
children | 407031aeedcf |
files | libaf/af.c libaf/af.h libaf/af_delay.c libaf/af_resample.c |
diffstat | 4 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libaf/af.c Tue Oct 08 05:46:23 2002 +0000 +++ b/libaf/af.c Tue Oct 08 10:20:36 2002 +0000 @@ -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)
--- a/libaf/af.h Tue Oct 08 05:46:23 2002 +0000 +++ b/libaf/af.h Tue Oct 08 10:20:36 2002 +0000 @@ -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
--- a/libaf/af_delay.c Tue Oct 08 05:46:23 2002 +0000 +++ b/libaf/af_delay.c Tue Oct 08 10:20:36 2002 +0000 @@ -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);
--- a/libaf/af_resample.c Tue Oct 08 05:46:23 2002 +0000 +++ b/libaf/af_resample.c Tue Oct 08 10:20:36 2002 +0000 @@ -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;