ref: c38dc859dcc4de8501f4149b7aea7b95b679eb56
parent: b4eb5ce53e52f886455fbb2f8d3230a59da10250
author: Erik de Castro Lopo <erikd@miles>
date: Sat Nov 6 06:46:06 EST 2004
Hook in skeleton FIR/IIR/Polynomial converter.
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,7 +11,8 @@
noinst_HEADERS = common.h float_cast.h $(COEFF_HDRS)
-SRC_SOURCES = samplerate.c src_sinc.c $(COEFF_HDRS) src_zoh.c src_linear.c
+SRC_SOURCES = samplerate.c src_sinc.c $(COEFF_HDRS) src_zoh.c src_linear.c \
+ src_fir_iir_poly.c
# MinGW requires -no-undefined if a DLL is to be built.
libsamplerate_la_LDFLAGS = -no-undefined version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@
--- a/src/common.h
+++ b/src/common.h
@@ -114,6 +114,12 @@
int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
+/* In src_fir_iir_poly.c */
+const char* fip_get_name (int src_enum) ;
+const char* fip_get_description (int src_enum) ;
+
+int fip_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
+
#endif /* COMMON_H_INCLUDED */
/*
--- a/src/samplerate.c
+++ b/src/samplerate.c
@@ -313,6 +313,9 @@
if ((desc = linear_get_name (converter_type)) != NULL)
return desc ;
+ if ((desc = fip_get_name (converter_type)) != NULL)
+ return desc ;
+
return NULL ;
} /* src_get_name */
@@ -329,6 +332,9 @@
if ((desc = linear_get_description (converter_type)) != NULL)
return desc ;
+ if ((desc = fip_get_description (converter_type)) != NULL)
+ return desc ;
+
return NULL ;
} /* src_get_description */
@@ -480,6 +486,9 @@
return SRC_ERR_NO_ERROR ;
if (linear_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
+ return SRC_ERR_NO_ERROR ;
+
+ if (fip_set_converter (psrc, converter_type) == SRC_ERR_NO_ERROR)
return SRC_ERR_NO_ERROR ;
return SRC_ERR_BAD_CONVERTER ;
--- a/src/samplerate.h
+++ b/src/samplerate.h
@@ -168,7 +168,10 @@
SRC_SINC_MEDIUM_QUALITY = 1,
SRC_SINC_FASTEST = 2,
SRC_ZERO_ORDER_HOLD = 3,
- SRC_LINEAR = 4
+ SRC_LINEAR = 4,
+ SRC_FIR_IIR_POLY_BEST = 5,
+ SRC_FIR_IIR_POLY_MEDIUM = 6,
+ SRC_FIR_IIR_POLY_FASTEST = 7
} ;
/*
--- /dev/null
+++ b/src/src_fir_iir_poly.c
@@ -1,0 +1,155 @@
+/*
+** Copyright (C) 2002-2004 Erik de Castro Lopo <[email protected]>
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "config.h"
+#include "float_cast.h"
+#include "common.h"
+
+#define FIP_MAGIC_MARKER MAKE_MAGIC ('f', 'i', 'r', 'p', 'l', 'y')
+
+typedef struct
+{ int fip_magic_marker ;
+
+ int channels ;
+ long in_count, in_used ;
+ long out_count, out_gen ;
+
+ double src_ratio, input_index ;
+
+ float *input_buffer ;
+ int in_buf_len ;
+
+ float *fir_out ;
+ int fir_out_len ;
+
+ float *iir_out ;
+ int iir_out_len ;
+
+ float buffer [1] ;
+} FIR_IIR_POLY ;
+
+static void fip_reset (SRC_PRIVATE *psrc) ;
+static int fip_process (SRC_PRIVATE *psrc, SRC_DATA *data) ;
+
+const char*
+fip_get_name (int src_enum)
+{
+ switch (src_enum)
+ { case SRC_FIR_IIR_POLY_BEST :
+ return "Best FIR/IIR/Polynomial Interpolator" ;
+
+ case SRC_FIR_IIR_POLY_MEDIUM :
+ return "Medium FIR/IIR/Polynomial Interpolator" ;
+
+ case SRC_FIR_IIR_POLY_FASTEST :
+ return "Fastest FIR/IIR/Polynomial Interpolator" ;
+ } ;
+
+ return NULL ;
+} /* fip_get_descrition */
+
+const char*
+fip_get_description (int src_enum)
+{
+ switch (src_enum)
+ { case SRC_FIR_IIR_POLY_BEST :
+ return "Three stage FIR/IIR/Polynomial Interpolator, best quality, XXdb SNR, XX% BW." ;
+
+ case SRC_FIR_IIR_POLY_MEDIUM :
+ return "Three stage FIR/IIR/Polynomial Interpolator, medium quality, XXdb SNR, XX% BW." ;
+
+ case SRC_FIR_IIR_POLY_FASTEST :
+ return "Three stage FIR/IIR/Polynomial Interpolator, fastest, XXdb SNR, XX% BW." ;
+ } ;
+
+ return NULL ;
+} /* fip_get_descrition */
+
+int
+fip_set_converter (SRC_PRIVATE *psrc, int src_enum)
+{ FIR_IIR_POLY *fip ;
+
+ fip = (FIR_IIR_POLY *) psrc->private_data ;
+
+ switch (src_enum)
+ { case SRC_FIR_IIR_POLY_BEST :
+ break ;
+
+ case SRC_FIR_IIR_POLY_MEDIUM :
+ break ;
+
+ case SRC_FIR_IIR_POLY_FASTEST :
+ break ;
+
+ default :
+ return SRC_ERR_BAD_CONVERTER ;
+ } ;
+
+ psrc->reset = fip_reset ;
+ psrc->process = fip_process ;
+
+ return SRC_ERR_NO_ERROR ;
+} /* fip_set_converter */
+
+static void
+fip_reset (SRC_PRIVATE *psrc)
+{ FIR_IIR_POLY *fip ;
+
+ fip = (FIR_IIR_POLY *) psrc->private_data ;
+
+} /* fip_reset */
+
+/*========================================================================================
+** Beware all ye who dare pass this point. There be dragons here.
+*/
+
+static int
+fip_process (SRC_PRIVATE *psrc, SRC_DATA *data)
+{ FIR_IIR_POLY *fip ;
+
+ if (psrc->private_data == NULL)
+ return SRC_ERR_NO_PRIVATE ;
+
+ fip = (FIR_IIR_POLY*) psrc->private_data ;
+
+ /* If there is not a problem, this will be optimised out. */
+ if (sizeof (fip->buffer [0]) != sizeof (data->data_in [0]))
+ return SRC_ERR_SIZE_INCOMPATIBILITY ;
+
+
+ return SRC_ERR_NO_ERROR ;
+} /* fip_process */
+
+/*----------------------------------------------------------------------------------------
+*/
+
+
+
+
+/*
+** Do not edit or modify anything in this comment block.
+** The arch-tag line is a file identity tag for the GNU Arch
+** revision control system.
+**
+** arch-tag: a6c8bad4-740c-4e4f-99f1-e274174ab540
+*/
+