Mercurial > mplayer.hg
diff libaf/af_channels.c @ 24888:b2402b4f0afa
libaf: change filter input/output ratio calculations
Change the audio filters to use a double instead of rationals for the
ratio of output to input size. The rationals could overflow when
calculating the overall ratio of a filter chain and gave no real
advantage compared to doubles.
author | uau |
---|---|
date | Thu, 01 Nov 2007 06:52:01 +0000 |
parents | 904e3f3f8bee |
children | 72d0b1444141 |
line wrap: on
line diff
--- a/libaf/af_channels.c Thu Nov 01 06:51:57 2007 +0000 +++ b/libaf/af_channels.c Thu Nov 01 06:52:01 2007 +0000 @@ -148,9 +148,7 @@ af->data->rate = ((af_data_t*)arg)->rate; af->data->format = ((af_data_t*)arg)->format; af->data->bps = ((af_data_t*)arg)->bps; - af->mul.n = af->data->nch; - af->mul.d = ((af_data_t*)arg)->nch; - af_frac_cancel(&af->mul); + af->mul = (double)af->data->nch / ((af_data_t*)arg)->nch; return check_routes(s,((af_data_t*)arg)->nch,af->data->nch); case AF_CONTROL_COMMAND_LINE:{ int nch = 0; @@ -251,7 +249,7 @@ return NULL; // Reset unused channels - memset(l->audio,0,(c->len*af->mul.n)/af->mul.d); + memset(l->audio,0,c->len / c->nch * l->nch); if(AF_OK == check_routes(s,c->nch,l->nch)) for(i=0;i<s->nr;i++) @@ -260,7 +258,7 @@ // Set output data c->audio = l->audio; - c->len = (c->len*af->mul.n)/af->mul.d; + c->len = c->len / c->nch * l->nch; c->nch = l->nch; return c; @@ -271,8 +269,7 @@ af->control=control; af->uninit=uninit; af->play=play; - af->mul.n=1; - af->mul.d=1; + af->mul=1; af->data=calloc(1,sizeof(af_data_t)); af->setup=calloc(1,sizeof(af_channels_t)); if((af->data == NULL) || (af->setup == NULL))