| @@ -0,0 +1,155 @@ |
| | 1 | /* |
| | 2 | ** Copyright (C) 2002-2004 Erik de Castro Lopo <erikd@mega-nerd.com> |
| | 3 | ** |
| | 4 | ** This program is free software; you can redistribute it and/or modify |
| | 5 | ** it under the terms of the GNU General Public License as published by |
| | 6 | ** the Free Software Foundation; either version 2 of the License, or |
| | 7 | ** (at your option) any later version. |
| | 8 | ** |
| | 9 | ** This program is distributed in the hope that it will be useful, |
| | 10 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| | 11 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| | 12 | ** GNU General Public License for more details. |
| | 13 | ** |
| | 14 | ** You should have received a copy of the GNU General Public License |
| | 15 | ** along with this program; if not, write to the Free Software |
| | 16 | ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
| | 17 | */ |
| | 18 | |
| | 19 | #include <stdio.h> |
| | 20 | #include <stdlib.h> |
| | 21 | #include <string.h> |
| | 22 | |
| | 23 | #include "config.h" |
| | 24 | #include "float_cast.h" |
| | 25 | #include "common.h" |
| | 26 | |
| | 27 | #define FIP_MAGIC_MARKER MAKE_MAGIC ('f', 'i', 'r', 'p', 'l', 'y') |
| | 28 | |
| | 29 | typedef struct |
| | 30 | { int fip_magic_marker ; |
| | 31 | |
| | 32 | int channels ; |
| | 33 | long in_count, in_used ; |
| | 34 | long out_count, out_gen ; |
| | 35 | |
| | 36 | double src_ratio, input_index ; |
| | 37 | |
| | 38 | float *input_buffer ; |
| | 39 | int in_buf_len ; |
| | 40 | |
| | 41 | float *fir_out ; |
| | 42 | int fir_out_len ; |
| | 43 | |
| | 44 | float *iir_out ; |
| | 45 | int iir_out_len ; |
| | 46 | |
| | 47 | float buffer [1] ; |
| | 48 | } FIR_IIR_POLY ; |
| | 49 | |
| | 50 | static void fip_reset (SRC_PRIVATE *psrc) ; |
| | 51 | static int fip_process (SRC_PRIVATE *psrc, SRC_DATA *data) ; |
| | 52 | |
| | 53 | const char* |
| | 54 | fip_get_name (int src_enum) |
| | 55 | { |
| | 56 | switch (src_enum) |
| | 57 | { case SRC_FIR_IIR_POLY_BEST : |
| | 58 | return "Best FIR/IIR/Polynomial Interpolator" ; |
| | 59 | |
| | 60 | case SRC_FIR_IIR_POLY_MEDIUM : |
| | 61 | return "Medium FIR/IIR/Polynomial Interpolator" ; |
| | 62 | |
| | 63 | case SRC_FIR_IIR_POLY_FASTEST : |
| | 64 | return "Fastest FIR/IIR/Polynomial Interpolator" ; |
| | 65 | } ; |
| | 66 | |
| | 67 | return NULL ; |
| | 68 | } /* fip_get_descrition */ |
| | 69 | |
| | 70 | const char* |
| | 71 | fip_get_description (int src_enum) |
| | 72 | { |
| | 73 | switch (src_enum) |
| | 74 | { case SRC_FIR_IIR_POLY_BEST : |
| | 75 | return "Three stage FIR/IIR/Polynomial Interpolator, best quality, XXdb SNR, XX% BW." ; |
| | 76 | |
| | 77 | case SRC_FIR_IIR_POLY_MEDIUM : |
| | 78 | return "Three stage FIR/IIR/Polynomial Interpolator, medium quality, XXdb SNR, XX% BW." ; |
| | 79 | |
| | 80 | case SRC_FIR_IIR_POLY_FASTEST : |
| | 81 | return "Three stage FIR/IIR/Polynomial Interpolator, fastest, XXdb SNR, XX% BW." ; |
| | 82 | } ; |
| | 83 | |
| | 84 | return NULL ; |
| | 85 | } /* fip_get_descrition */ |
| | 86 | |
| | 87 | int |
| | 88 | fip_set_converter (SRC_PRIVATE *psrc, int src_enum) |
| | 89 | { FIR_IIR_POLY *fip ; |
| | 90 | |
| | 91 | fip = (FIR_IIR_POLY *) psrc->private_data ; |
| | 92 | |
| | 93 | switch (src_enum) |
| | 94 | { case SRC_FIR_IIR_POLY_BEST : |
| | 95 | break ; |
| | 96 | |
| | 97 | case SRC_FIR_IIR_POLY_MEDIUM : |
| | 98 | break ; |
| | 99 | |
| | 100 | case SRC_FIR_IIR_POLY_FASTEST : |
| | 101 | break ; |
| | 102 | |
| | 103 | default : |
| | 104 | return SRC_ERR_BAD_CONVERTER ; |
| | 105 | } ; |
| | 106 | |
| | 107 | psrc->reset = fip_reset ; |
| | 108 | psrc->process = fip_process ; |
| | 109 | |
| | 110 | return SRC_ERR_NO_ERROR ; |
| | 111 | } /* fip_set_converter */ |
| | 112 | |
| | 113 | static void |
| | 114 | fip_reset (SRC_PRIVATE *psrc) |
| | 115 | { FIR_IIR_POLY *fip ; |
| | 116 | |
| | 117 | fip = (FIR_IIR_POLY *) psrc->private_data ; |
| | 118 | |
| | 119 | } /* fip_reset */ |
| | 120 | |
| | 121 | /*======================================================================================== |
| | 122 | ** Beware all ye who dare pass this point. There be dragons here. |
| | 123 | */ |
| | 124 | |
| | 125 | static int |
| | 126 | fip_process (SRC_PRIVATE *psrc, SRC_DATA *data) |
| | 127 | { FIR_IIR_POLY *fip ; |
| | 128 | |
| | 129 | if (psrc->private_data == NULL) |
| | 130 | return SRC_ERR_NO_PRIVATE ; |
| | 131 | |
| | 132 | fip = (FIR_IIR_POLY*) psrc->private_data ; |
| | 133 | |
| | 134 | /* If there is not a problem, this will be optimised out. */ |
| | 135 | if (sizeof (fip->buffer [0]) != sizeof (data->data_in [0])) |
| | 136 | return SRC_ERR_SIZE_INCOMPATIBILITY ; |
| | 137 | |
| | 138 | |
| | 139 | return SRC_ERR_NO_ERROR ; |
| | 140 | } /* fip_process */ |
| | 141 | |
| | 142 | /*---------------------------------------------------------------------------------------- |
| | 143 | */ |
| | 144 | |
| | 145 | |
| | 146 | |
| | 147 | |
| | 148 | /* |
| | 149 | ** Do not edit or modify anything in this comment block. |
| | 150 | ** The arch-tag line is a file identity tag for the GNU Arch |
| | 151 | ** revision control system. |
| | 152 | ** |
| | 153 | ** arch-tag: a6c8bad4-740c-4e4f-99f1-e274174ab540 |
| | 154 | */ |
| | 155 | |