mirror of
https://github.com/mpv-player/mpv
synced 2025-04-27 11:33:39 +02:00
Cleanup and comment
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4790 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
ee2ed8567e
commit
2eb3f24dc1
libao2
43
libao2/fir.h
43
libao2/fir.h
@ -11,14 +11,13 @@
|
|||||||
#ifndef __FIR_H__
|
#ifndef __FIR_H__
|
||||||
#define __FIR_H__
|
#define __FIR_H__
|
||||||
|
|
||||||
/* Fixpoint 16 bit fir filter FIR filter. The filter is implemented
|
/* Fixpoint 16 bit FIR filter. The filter is implemented both in C and
|
||||||
both in C and MMX assembly. The filter consists of one macro
|
MMX assembly. The filter consists of the two inline functions updateq
|
||||||
UPDATE_QUE and one inline function firn. The macro can be used for
|
and firn, update q is used for adding new data to the circular buffer
|
||||||
adding new data to the circular buffer used by the filter firn.
|
used by the filter firn. Limitations: max length of n = 16*4 and n
|
||||||
Limitations: max length of n = 16*4 and n must be multiple of 4 (pad
|
must be multiple of 4 (pad fiter with zeros for other lengths).
|
||||||
fiter with zeros for other lengths). Sometimes it works with filters
|
Sometimes it works with filters longer than 4*16 (the problem is
|
||||||
longer than 4*16 (the problem is overshoot and the acumulated energy
|
overshoot and the acumulated energy in the filter taps). */
|
||||||
in the filter taps). */
|
|
||||||
|
|
||||||
#ifdef HAVE_MMX
|
#ifdef HAVE_MMX
|
||||||
inline int32_t firn(int16_t* x, int16_t* w, int16_t n)
|
inline int32_t firn(int16_t* x, int16_t* w, int16_t n)
|
||||||
@ -60,26 +59,14 @@ inline int32_t firn(int16_t* x, int16_t* w, int16_t n)
|
|||||||
|
|
||||||
#endif /* HAVE_MMX */
|
#endif /* HAVE_MMX */
|
||||||
|
|
||||||
// Macro to add new data to circular queue
|
/* Add new data to circular queue designed to be used with a FIR
|
||||||
#define UPDATE_QUE(ind,xq,xid) \
|
filter. xq is the circular queue, in pointing at the new sample, xi
|
||||||
xid=(--xid)&(L-1); \
|
current index for in xq and l the lenght of the filter */
|
||||||
xq[xid]=xq[xid+L]=*(ind);
|
inline uint16_t updateq(int16_t* xq, int16_t* in, uint16_t xi, uint16_t l)
|
||||||
|
{
|
||||||
#ifdef L8
|
xq[xi]=xq[xi+l]=*in;
|
||||||
#ifdef HAVE_MMX
|
return (--xi)&(l-1); \
|
||||||
#define FIR(x,w,y) *y=(int16_t)firn(x,w,8);
|
|
||||||
#else /* HAVE_MMX */
|
|
||||||
// Unrolled loop to speed up execution
|
|
||||||
#define FIR(x,w,y){ \
|
|
||||||
int16_t a = (w[0]*x[0]+w[1]*x[1]+w[2]*x[2]+w[3]*x[3]) >> 16; \
|
|
||||||
int16_t b = (w[4]*x[4]+w[5]*x[5]+w[6]*x[6]+w[7]*x[7]) >> 16; \
|
|
||||||
y[0] = a+b; \
|
|
||||||
}
|
}
|
||||||
#endif /* HAVE_MMX */
|
|
||||||
#endif /* L8 */
|
|
||||||
|
|
||||||
#ifdef L16
|
|
||||||
#define FIR(x,w,y) *y=(int16_t)firn(x,w,16);
|
|
||||||
#endif /* L16 */
|
|
||||||
|
|
||||||
#endif /* __FIR_H__ */
|
#endif /* __FIR_H__ */
|
||||||
|
|
||||||
|
@ -48,13 +48,26 @@ LIBAO_PLUGIN_EXTERN(resample)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(HAVE_SSE) && !defined(HAVE_3DNOW) //This machine is slow
|
#if !defined(HAVE_SSE) && !defined(HAVE_3DNOW) //This machine is slow
|
||||||
#define L8 1 // Filter bank type
|
|
||||||
#define W W8 // Filter bank parameters
|
#define W W8 // Filter bank parameters
|
||||||
#define L 8 // Filter length
|
#define L 8 // Filter length
|
||||||
#else // Fat machine
|
#ifdef HAVE_MMX
|
||||||
#define L16 1
|
#define FIR(x,w,y) *y=(int16_t)firn(x,w,8);
|
||||||
|
#else /* HAVE_MMX */
|
||||||
|
// Unrolled loop to speed up execution
|
||||||
|
#define FIR(x,w,y){ \
|
||||||
|
int16_t a = (w[0]*x[0]+w[1]*x[1]+w[2]*x[2]+w[3]*x[3]) >> 16; \
|
||||||
|
int16_t b = (w[4]*x[4]+w[5]*x[5]+w[6]*x[6]+w[7]*x[7]) >> 16; \
|
||||||
|
y[0] = a+b; \
|
||||||
|
}
|
||||||
|
#endif /* HAVE_MMX */
|
||||||
|
|
||||||
|
#else /* Fast machine */
|
||||||
|
|
||||||
#define W W16
|
#define W W16
|
||||||
#define L 16
|
#define L 16
|
||||||
|
#define FIR(x,w,y) *y=(int16_t)firn(x,w,16);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CH 6 // Max number of channels
|
#define CH 6 // Max number of channels
|
||||||
@ -192,7 +205,7 @@ int upsample(){
|
|||||||
register uint16_t i = inc;
|
register uint16_t i = inc;
|
||||||
if(wi<level) i++;
|
if(wi<level) i++;
|
||||||
|
|
||||||
UPDATE_QUE(in,x,xi);
|
xi=updateq(x,in,xi,L);
|
||||||
in+=nch;
|
in+=nch;
|
||||||
while(i--){
|
while(i--){
|
||||||
// Run the FIR filter
|
// Run the FIR filter
|
||||||
@ -242,9 +255,8 @@ int downsample(){
|
|||||||
|
|
||||||
while(in < end){
|
while(in < end){
|
||||||
|
|
||||||
UPDATE_QUE(in,x,xi);
|
xi=updateq(x,in,xi,L);
|
||||||
in+=nch;
|
in+=nch;
|
||||||
|
|
||||||
if(!--i){
|
if(!--i){
|
||||||
// Run the FIR filter
|
// Run the FIR filter
|
||||||
FIR((&x[xi]),(&pl_resample.w[wi*L]),out);
|
FIR((&x[xi]),(&pl_resample.w[wi*L]),out);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user