From eec12427d706063ed58c5580e54a78647c4878ca Mon Sep 17 00:00:00 2001 From: diego Date: Fri, 2 Jan 2009 16:13:22 +0000 Subject: Rename libaf/af_resample.h to libaf/af_resample_template.c, it is used as a macro, not as a header file. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28236 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/af_resample.c | 10 +-- libaf/af_resample.h | 165 ------------------------------------------- libaf/af_resample_template.c | 165 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+), 170 deletions(-) delete mode 100644 libaf/af_resample.h create mode 100644 libaf/af_resample_template.c (limited to 'libaf') diff --git a/libaf/af_resample.c b/libaf/af_resample.c index 57e2d39321..fa2588976b 100644 --- a/libaf/af_resample.c +++ b/libaf/af_resample.c @@ -31,7 +31,7 @@ #define L16 #endif -#include "af_resample.h" +#include "af_resample_template.c" // Filtering types #define RSMP_LIN (0<<0) // Linear interpolation @@ -316,12 +316,12 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) # define FORMAT_I 1 if(s->up>s->dn){ # define UP -# include "af_resample.h" +# include "af_resample_template.c" # undef UP } else{ # define DN -# include "af_resample.h" +# include "af_resample_template.c" # undef DN } break; @@ -330,12 +330,12 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) # define FORMAT_F 1 if(s->up>s->dn){ # define UP -# include "af_resample.h" +# include "af_resample_template.c" # undef UP } else{ # define DN -# include "af_resample.h" +# include "af_resample_template.c" # undef DN } break; diff --git a/libaf/af_resample.h b/libaf/af_resample.h deleted file mode 100644 index d0aae0bceb..0000000000 --- a/libaf/af_resample.h +++ /dev/null @@ -1,165 +0,0 @@ -/*============================================================================= -// -// This software has been released under the terms of the GNU General Public -// license. See http://www.gnu.org/copyleft/gpl.html for details. -// -// Copyright 2002 Anders Johansson ajh@atri.curtin.edu.au -// -//============================================================================= -*/ - -/* This file contains the resampling engine, the sample format is - controlled by the FORMAT parameter, the filter length by the L - parameter and the resampling type by UP and DN. This file should - only be included by af_resample.c -*/ - -/* This header intentionally has no multiple inclusion guards. It is meant to - * be included multiple times and generates different code depending on the - * value of certain #defines. */ - -#undef L -#undef SHIFT -#undef FORMAT -#undef FIR -#undef ADDQUE - -/* The length Lxx definition selects the length of each poly phase - component. Valid definitions are L8 and L16 where the number - defines the nuber of taps. This definition affects the - computational complexity, the performance and the memory usage. -*/ - -/* The FORMAT_x parameter selects the sample format type currently - float and int16 are supported. Thes two formats are selected by - defining eiter FORMAT_F or FORMAT_I. The advantage of using float - is that the amplitude and therefore the SNR isn't affected by the - filtering, the disadvantage is that it is a lot slower. -*/ - -#if defined(FORMAT_I) -#define SHIFT >>16 -#define FORMAT int16_t -#else -#define SHIFT -#define FORMAT float -#endif - -// Short filter -#if defined(L8) - -#define L 8 // Filter length -// Unrolled loop to speed up execution -#define FIR(x,w,y) \ - (y[0]) = ( w[0]*x[0]+w[1]*x[1]+w[2]*x[2]+w[3]*x[3] \ - + w[4]*x[4]+w[5]*x[5]+w[6]*x[6]+w[7]*x[7] ) SHIFT - - - -#else /* L8/L16 */ - -#define L 16 -// Unrolled loop to speed up execution -#define FIR(x,w,y) \ - y[0] = ( w[0] *x[0] +w[1] *x[1] +w[2] *x[2] +w[3] *x[3] \ - + w[4] *x[4] +w[5] *x[5] +w[6] *x[6] +w[7] *x[7] \ - + w[8] *x[8] +w[9] *x[9] +w[10]*x[10]+w[11]*x[11] \ - + w[12]*x[12]+w[13]*x[13]+w[14]*x[14]+w[15]*x[15] ) SHIFT - -#endif /* L8/L16 */ - -// Macro to add data to circular que -#define ADDQUE(xi,xq,in)\ - xq[xi]=xq[(xi)+L]=*(in);\ - xi=((xi)-1)&(L-1); - -#if defined(UP) - - uint32_t ci = l->nch; // Index for channels - uint32_t nch = l->nch; // Number of channels - uint32_t inc = s->up/s->dn; - uint32_t level = s->up%s->dn; - uint32_t up = s->up; - uint32_t dn = s->dn; - uint32_t ns = c->len/l->bps; - register FORMAT* w = s->w; - - register uint32_t wi = 0; - register uint32_t xi = 0; - - // Index current channel - while(ci--){ - // Temporary pointers - register FORMAT* x = s->xq[ci]; - register FORMAT* in = ((FORMAT*)c->audio)+ci; - register FORMAT* out = ((FORMAT*)l->audio)+ci; - FORMAT* end = in+ns; // Block loop end - wi = s->wi; xi = s->xi; - - while(in < end){ - register uint32_t i = inc; - if(wiwi = wi; - s->xi = xi; -#endif /* UP */ - -#if defined(DN) /* DN */ - uint32_t ci = l->nch; // Index for channels - uint32_t nch = l->nch; // Number of channels - uint32_t inc = s->dn/s->up; - uint32_t level = s->dn%s->up; - uint32_t up = s->up; - uint32_t dn = s->dn; - uint32_t ns = c->len/l->bps; - FORMAT* w = s->w; - - register int32_t i = 0; - register uint32_t wi = 0; - register uint32_t xi = 0; - - // Index current channel - while(ci--){ - // Temporary pointers - register FORMAT* x = s->xq[ci]; - register FORMAT* in = ((FORMAT*)c->audio)+ci; - register FORMAT* out = ((FORMAT*)l->audio)+ci; - register FORMAT* end = in+ns; // Block loop end - i = s->i; wi = s->wi; xi = s->xi; - - while(in < end){ - - ADDQUE(xi,x,in); - in+=nch; - if((--i)<=0){ - // Run the FIR filter - FIR((&x[xi]),(&w[wi*L]),out); - len++; out+=nch; - - // Update wi to point at the correct polyphase component - wi=(wi+dn)%up; - - // Insert i number of new samples in queue - i = inc; - if(wiwi = wi; - s->xi = xi; - s->i = i; -#endif /* DN */ diff --git a/libaf/af_resample_template.c b/libaf/af_resample_template.c new file mode 100644 index 0000000000..d0aae0bceb --- /dev/null +++ b/libaf/af_resample_template.c @@ -0,0 +1,165 @@ +/*============================================================================= +// +// This software has been released under the terms of the GNU General Public +// license. See http://www.gnu.org/copyleft/gpl.html for details. +// +// Copyright 2002 Anders Johansson ajh@atri.curtin.edu.au +// +//============================================================================= +*/ + +/* This file contains the resampling engine, the sample format is + controlled by the FORMAT parameter, the filter length by the L + parameter and the resampling type by UP and DN. This file should + only be included by af_resample.c +*/ + +/* This header intentionally has no multiple inclusion guards. It is meant to + * be included multiple times and generates different code depending on the + * value of certain #defines. */ + +#undef L +#undef SHIFT +#undef FORMAT +#undef FIR +#undef ADDQUE + +/* The length Lxx definition selects the length of each poly phase + component. Valid definitions are L8 and L16 where the number + defines the nuber of taps. This definition affects the + computational complexity, the performance and the memory usage. +*/ + +/* The FORMAT_x parameter selects the sample format type currently + float and int16 are supported. Thes two formats are selected by + defining eiter FORMAT_F or FORMAT_I. The advantage of using float + is that the amplitude and therefore the SNR isn't affected by the + filtering, the disadvantage is that it is a lot slower. +*/ + +#if defined(FORMAT_I) +#define SHIFT >>16 +#define FORMAT int16_t +#else +#define SHIFT +#define FORMAT float +#endif + +// Short filter +#if defined(L8) + +#define L 8 // Filter length +// Unrolled loop to speed up execution +#define FIR(x,w,y) \ + (y[0]) = ( w[0]*x[0]+w[1]*x[1]+w[2]*x[2]+w[3]*x[3] \ + + w[4]*x[4]+w[5]*x[5]+w[6]*x[6]+w[7]*x[7] ) SHIFT + + + +#else /* L8/L16 */ + +#define L 16 +// Unrolled loop to speed up execution +#define FIR(x,w,y) \ + y[0] = ( w[0] *x[0] +w[1] *x[1] +w[2] *x[2] +w[3] *x[3] \ + + w[4] *x[4] +w[5] *x[5] +w[6] *x[6] +w[7] *x[7] \ + + w[8] *x[8] +w[9] *x[9] +w[10]*x[10]+w[11]*x[11] \ + + w[12]*x[12]+w[13]*x[13]+w[14]*x[14]+w[15]*x[15] ) SHIFT + +#endif /* L8/L16 */ + +// Macro to add data to circular que +#define ADDQUE(xi,xq,in)\ + xq[xi]=xq[(xi)+L]=*(in);\ + xi=((xi)-1)&(L-1); + +#if defined(UP) + + uint32_t ci = l->nch; // Index for channels + uint32_t nch = l->nch; // Number of channels + uint32_t inc = s->up/s->dn; + uint32_t level = s->up%s->dn; + uint32_t up = s->up; + uint32_t dn = s->dn; + uint32_t ns = c->len/l->bps; + register FORMAT* w = s->w; + + register uint32_t wi = 0; + register uint32_t xi = 0; + + // Index current channel + while(ci--){ + // Temporary pointers + register FORMAT* x = s->xq[ci]; + register FORMAT* in = ((FORMAT*)c->audio)+ci; + register FORMAT* out = ((FORMAT*)l->audio)+ci; + FORMAT* end = in+ns; // Block loop end + wi = s->wi; xi = s->xi; + + while(in < end){ + register uint32_t i = inc; + if(wiwi = wi; + s->xi = xi; +#endif /* UP */ + +#if defined(DN) /* DN */ + uint32_t ci = l->nch; // Index for channels + uint32_t nch = l->nch; // Number of channels + uint32_t inc = s->dn/s->up; + uint32_t level = s->dn%s->up; + uint32_t up = s->up; + uint32_t dn = s->dn; + uint32_t ns = c->len/l->bps; + FORMAT* w = s->w; + + register int32_t i = 0; + register uint32_t wi = 0; + register uint32_t xi = 0; + + // Index current channel + while(ci--){ + // Temporary pointers + register FORMAT* x = s->xq[ci]; + register FORMAT* in = ((FORMAT*)c->audio)+ci; + register FORMAT* out = ((FORMAT*)l->audio)+ci; + register FORMAT* end = in+ns; // Block loop end + i = s->i; wi = s->wi; xi = s->xi; + + while(in < end){ + + ADDQUE(xi,x,in); + in+=nch; + if((--i)<=0){ + // Run the FIR filter + FIR((&x[xi]),(&w[wi*L]),out); + len++; out+=nch; + + // Update wi to point at the correct polyphase component + wi=(wi+dn)%up; + + // Insert i number of new samples in queue + i = inc; + if(wiwi = wi; + s->xi = xi; + s->i = i; +#endif /* DN */ -- cgit v1.2.3