Index: apps/dsp_asm.h =================================================================== --- apps/dsp_asm.h (Revision 30373) +++ apps/dsp_asm.h (Arbeitskopie) @@ -27,7 +27,6 @@ /* Set the appropriate #defines based on CPU or whatever matters */ #if defined(CPU_ARM) #define DSP_HAVE_ASM_APPLY_GAIN -#define DSP_HAVE_ASM_RESAMPLING #define DSP_HAVE_ASM_CROSSFEED #define DSP_HAVE_ASM_SOUND_CHAN_MONO #define DSP_HAVE_ASM_SOUND_CHAN_CUSTOM @@ -36,7 +35,6 @@ #define DSP_HAVE_ASM_SAMPLE_OUTPUT_STEREO #elif defined (CPU_COLDFIRE) #define DSP_HAVE_ASM_APPLY_GAIN -#define DSP_HAVE_ASM_RESAMPLING #define DSP_HAVE_ASM_CROSSFEED #define DSP_HAVE_ASM_SOUND_CHAN_MONO #define DSP_HAVE_ASM_SOUND_CHAN_CUSTOM @@ -45,6 +43,10 @@ #define DSP_HAVE_ASM_SAMPLE_OUTPUT_STEREO #endif /* CPU_COLDFIRE */ +#if (defined(CPU_ARM) || defined(CPU_COLDFIRE)) && !defined(DSP_USE_SINC_RESAMPLING) +#define DSP_HAVE_ASM_RESAMPLING +#endif + /* Declare prototypes based upon what's #defined above */ #ifdef DSP_HAVE_ASM_CROSSFEED void apply_crossfeed(int count, int32_t *buf[]); Index: apps/dsp_arm.S =================================================================== --- apps/dsp_arm.S (Revision 30373) +++ apps/dsp_arm.S (Arbeitskopie) @@ -397,6 +397,8 @@ * int dsp_downsample(int count, struct dsp_data *data, * in32_t *src[], int32_t *dst[]) */ + +#ifndef DSP_USE_SINC_RESAMPLING .section .text .global dsp_downsample dsp_downsample: @@ -513,6 +515,8 @@ ldmpc regs=r4-r11 @ ... and we're out .size dsp_upsample, .-dsp_upsample +#endif + /**************************************************************************** * void dsp_apply_gain(int count, struct dsp_data *data, int32_t *buf[]) */ Index: apps/dsp.c =================================================================== --- apps/dsp.c (Revision 30373) +++ apps/dsp.c (Arbeitskopie) @@ -33,6 +33,9 @@ #include "buffer.h" #include "fixedpoint.h" #include "fracmul.h" +#ifdef DSP_USE_SINC_RESAMPLING +#include "sinc.h" +#endif /* Define LOGF_ENABLE to enable logf output in this file */ /*#define LOGF_ENABLE*/ @@ -73,13 +76,36 @@ * NOTE: Any assembly routines that use these structures must be updated * if current data members are moved or changed. */ + +#ifdef DSP_USE_SINC_RESAMPLING +#define FILTER_SIZE 15 +#define FILTER_DELAY 7 + +struct resample_buffer +{ + uint32_t buf_fill; + int32_t sample_buf[2][FILTER_SIZE]; + int32_t resample_buf[2][FILTER_SIZE*2]; +}; + struct resample_data { + uint32_t increment; /* 00h */ + uint32_t current; /* 04h */ + uint32_t reserved; /* 08h */ + int32_t (*sinc)[256][8]; /* 0ch */ + /* 10h */ +}; + +#else +struct resample_data +{ uint32_t delta; /* 00h */ uint32_t phase; /* 04h */ int32_t last_sample[2]; /* 08h */ /* 10h */ }; +#endif /* This is for passing needed data to assembly dsp routines. If another * dsp parameter needs to be passed, add to the end of the structure @@ -193,6 +219,9 @@ channels_process_fn_type eq_process; channels_process_fn_type channels_process; channels_process_fn_type compressor_process; +#ifdef DSP_USE_SINC_RESAMPLING + struct resample_buffer resample_buffer; +#endif }; /* General DSP config */ @@ -632,6 +661,253 @@ dsp->output_samples = sample_output_functions[out]; } +#ifdef DSP_USE_SINC_RESAMPLING + +/* Expand sinc coefficients from s.16 to s.28 */ +#define SINC_MUL(A,B) FRACMUL((A), ((B)<<12)) + +static inline int32_t sinc_resample(const int32_t *p_src, uint32_t current, + int32_t p_sinc[256][8]) +{ + int32_t samp; + uint32_t current_int = current >> 16; + uint32_t current_frac = (current >> 8) & 0xff; + uint32_t sinc_index; + const int32_t *sinc = &p_sinc[current_frac][7]; + const int32_t *src = &p_src[current_int-7]; + + // todo: linear interpolation between sinc values (doubles the amount of MULs) + samp = SINC_MUL(*src++, *sinc--); + samp += SINC_MUL(*src++, *sinc--); + samp += SINC_MUL(*src++, *sinc--); + samp += SINC_MUL(*src++, *sinc--); + samp += SINC_MUL(*src++, *sinc--); + samp += SINC_MUL(*src++, *sinc--); + samp += SINC_MUL(*src++, *sinc--); + samp += SINC_MUL(*src++, *sinc--); + + /* use the symmetry of sinc: */ + current_frac = 256 - current_frac; + /* if current_frac was 0, we get 1.0 as index */ + sinc_index = current_frac >> 8; + current_frac &= 0xff; + sinc = &p_sinc[current_frac][sinc_index]; + src = &p_src[current_int+1]; + + samp += SINC_MUL(*src++, *sinc++); + samp += SINC_MUL(*src++, *sinc++); + samp += SINC_MUL(*src++, *sinc++); + samp += SINC_MUL(*src++, *sinc++); + samp += SINC_MUL(*src++, *sinc++); + samp += SINC_MUL(*src++, *sinc++); + samp += SINC_MUL(*src++, *sinc++); + + return (samp << 3); +} + + +static int dsp_resample(int count, struct dsp_data *data, + const int32_t *src[], int32_t *dst[]) +{ + uint32_t inc = data->resample_data.increment; + uint32_t cur = data->resample_data.current; + int32_t *d = dst[0]; + int i; + + for(i = 0; inum_channels; i++) { + cur = data->resample_data.current; + d = dst[i]; + + while((cur>>16) < (unsigned)count - FILTER_DELAY) { + int32_t sample = sinc_resample(src[i], cur, *(data->resample_data.sinc)); + *d++ = sample; + cur += inc; + } + } + + data->resample_data.current = cur; + + return d - dst[data->num_channels-1]; +} + +static int resampler_init(struct dsp_config *dsp) +{ + if(dsp->data.resample_data.sinc == NULL) { +#if 0 + dsp->data.resample_data.sinc = buffer_alloc(sizeof(*(dsp->data.resample_data.sinc))); + if(sinc == NULL) { + return -1; + } +#else + /* cache-line align */ + char *sinc = buffer_alloc(sizeof(*(dsp->data.resample_data.sinc)) + CACHEALIGN_SIZE); + if(sinc == NULL) { + return -1; + } + dsp->data.resample_data.sinc = (void *)((long)(sinc + CACHEALIGN_SIZE - 1) & ~(CACHEALIGN_SIZE - 1)); +#endif + } + return 0; +} + +void dsp_resample_init(void) +{ + resampler_init(&AUDIO_DSP); + resampler_init(&VOICE_DSP); +} + +static void resampler_reset(struct dsp_config *dsp) +{ + memset(dsp->resample_buffer.resample_buf, 0, sizeof(dsp->resample_buffer.resample_buf)); + dsp->resample_buffer.buf_fill = 0; /* fixme: initialize to FILTER_DELAY on startup */ + dsp->data.resample_data.current = FILTER_SIZE<<16; /* fixme: initialize on startup */ +} + +static void resampler_new_delta(struct dsp_config *dsp) +{ + int i, k; + dsp->data.resample_data.increment = (uint32_t) + dsp->frequency * 65536LL / NATIVE_FREQUENCY; + + if(dsp->data.resample_data.sinc == NULL) { + dsp->resample = NULL; + dsp->data.resample_data.increment = 0x10000; + return; + } + + if (dsp->frequency == NATIVE_FREQUENCY) { + /* NOTE: If fully glitch-free transistions from no resampling to + resampling are desired, last_sample history should be maintained + even when not resampling. */ + dsp->resample = NULL; + resampler_reset(dsp); + } else if (dsp->frequency < NATIVE_FREQUENCY) { + dsp->resample = dsp_resample; + memcpy(*(dsp->data.resample_data.sinc), sinc, sizeof(sinc)); + } else { + uint32_t sinc_inc = (uint32_t) + NATIVE_FREQUENCY * 256LL / dsp->frequency; + uint32_t sinc_cur = 0; + dsp->resample = dsp_resample; + /* we have to scale the sinc's amplitude by downsampling rate, + * which is the same as the sinc_increment + * we also have to stretch (widen) the sinc by sinc_inc */ + for (i=0; i<8; i++) { + for(k=0; k<256; k++) { + uint32_t sinc_cur_int = sinc_cur >> 16; + uint32_t sinc_cur_frac = (sinc_cur >> 8) & 0xff; + int32_t sinc_val; + int32_t sinc_successor; + /* linear interpolation between sinc values */ + if(sinc_cur_frac == 255) sinc_successor = 0; /* sinc[0][x] is always 0, for x!= 0 */ + else sinc_successor = sinc[sinc_cur_frac+1][sinc_cur_int]; + + sinc_val = sinc_successor - sinc[sinc_cur_frac][sinc_cur_int]; + sinc_val = (sinc_val * (int32_t)(sinc_cur & 0xff)) >> 8; + sinc_val += sinc[sinc_cur_frac][sinc_cur_int]; + /* scaling of sinc */ + /* we need to use scale as 17.15, because sinc's max is 1.0 + * and it is signed */ + (*(dsp->data.resample_data.sinc))[k][i] = + (sinc_val * (int32_t)(NATIVE_FREQUENCY * 32768LL / dsp->frequency)) >> 15; + sinc_cur += sinc_inc; + } + } + } +} + +/* Resample count stereo samples. Returns number of stereo samples + * for further processing. + * count must be >= 15 + */ +static inline int resample_core(struct dsp_config *dsp, unsigned count, int32_t *src[], int32_t *dst[]) +{ + struct resample_data *rsdata = &dsp->data.resample_data; + struct resample_buffer *rsbuf = &dsp->resample_buffer; + int32_t *sb_src[2] = + { + &rsbuf->resample_buf[0][0], + &rsbuf->resample_buf[1][0], + }; + int cnt; + + memcpy(&rsbuf->resample_buf[0][FILTER_SIZE], src[0], FILTER_SIZE * sizeof(int32_t)); + if (dsp->data.num_channels > 1) + memcpy(&rsbuf->resample_buf[1][FILTER_SIZE], src[1], FILTER_SIZE * sizeof(int32_t)); + + cnt = dsp->resample(FILTER_SIZE*2, &dsp->data, (const int32_t **)sb_src, dst); + + rsdata->current -= (FILTER_SIZE << 16); + + if((rsdata->current >> 16) < count) { + int32_t *add_dst[2]; + add_dst[0] = dst[0] + cnt; + add_dst[1] = dst[1] + cnt; + cnt += dsp->resample((int)count, &dsp->data, (const int32_t **)src, add_dst); + } + + memcpy(rsbuf->resample_buf[0], &src[0][count - FILTER_SIZE], FILTER_SIZE * sizeof(int32_t)); + memcpy(rsbuf->resample_buf[1], &src[dsp->data.num_channels - 1][count - FILTER_SIZE], FILTER_SIZE * sizeof(int32_t)); + + rsdata->current -= ((count - FILTER_SIZE) << 16); + + return cnt; +} + +/* Resample count stereo samples. Updates the src array, if resampling is + * done, to refer to the resampled data. Returns number of stereo samples + * for further processing. + */ +static inline int resample(struct dsp_config *dsp, int count, int32_t *src[]) +{ + int32_t *dst[2] = + { + &resample_buf[RESAMPLE_BUF_LEFT_CHANNEL], + &resample_buf[RESAMPLE_BUF_RIGHT_CHANNEL], + }; + struct resample_buffer *rsbuf = &dsp->resample_buffer; + int res = 0; + + if(rsbuf->buf_fill || count < FILTER_SIZE) { + unsigned size = (count - rsbuf->buf_fill > FILTER_SIZE)? FILTER_SIZE - rsbuf->buf_fill : (unsigned)count; + memcpy(&rsbuf->sample_buf[0][rsbuf->buf_fill], src[0], size * sizeof(int32_t)); + memcpy(&rsbuf->sample_buf[1][rsbuf->buf_fill], src[dsp->data.num_channels - 1], size * sizeof(int32_t)); + rsbuf->buf_fill += size; + count -= size; + src[0] += size; + src[1] += size; + } + + if(rsbuf->buf_fill == FILTER_SIZE) { + int32_t *buf_src[2] = + { + rsbuf->sample_buf[0], + rsbuf->sample_buf[1], + }; + res = resample_core(dsp, FILTER_SIZE, buf_src, dst); + rsbuf->buf_fill = 0; + } + + if(count > FILTER_SIZE) { + int32_t *add_dst[2]; + add_dst[0] = dst[0] + res; + add_dst[1] = dst[1] + res; + res += resample_core(dsp, (unsigned)count, src, add_dst); + } else if(count) { + /* assert(rsdata->buf_fill == 0); */ + memcpy(rsbuf->sample_buf[0], src[0], count * sizeof(int32_t)); + memcpy(rsbuf->sample_buf[1], src[dsp->data.num_channels - 1], count * sizeof(int32_t)); + rsbuf->buf_fill = count; + } + + src[0] = dst[0]; + src[1] = dst[dsp->data.num_channels - 1]; + + return res; +} + +#else /* DSP_USE_SINC_RESAMPLING */ + /** * Linear interpolation resampling that introduces a one sample delay because * of our inability to look into the future at the end of a frame. @@ -762,6 +1038,8 @@ return count; } +#endif /* DSP_USE_SINC_RESAMPLING */ + static void dither_init(struct dsp_config *dsp) { memset(dither_data, 0, sizeof (dither_data)); @@ -1310,8 +1588,13 @@ #endif if (dsp->resample) { +#ifdef DSP_USE_SINC_RESAMPLING + count = (int)(((unsigned long)(count + FILTER_SIZE - 1) * NATIVE_FREQUENCY + + (dsp->frequency - 1)) / dsp->frequency); +#else count = (int)(((unsigned long)count * NATIVE_FREQUENCY + (dsp->frequency - 1)) / dsp->frequency); +#endif } /* Now we have the resampled sample count which must not exceed @@ -1337,8 +1620,15 @@ /* Use the real resampling delta = * dsp->frequency * 65536 / NATIVE_FREQUENCY, and * round towards zero to avoid buffer overflows. */ +#ifdef DSP_USE_SINC_RESAMPLING count = (int)(((unsigned long)count * + dsp->data.resample_data.increment) >> 16); + count -= dsp->resample_buffer.buf_fill; + if(count < 0) count = 0; +#else + count = (int)(((unsigned long)count * dsp->data.resample_data.delta) >> 16); +#endif } #ifdef HAVE_PITCHSCREEN @@ -1379,7 +1669,11 @@ } case DSP_SET_FREQUENCY: +#ifdef DSP_USE_SINC_RESAMPLING + resampler_reset(dsp); +#else memset(&dsp->data.resample_data, 0, sizeof (dsp->data.resample_data)); +#endif /* Fall through!!! */ case DSP_SWITCH_FREQUENCY: dsp->codec_frequency = (value == 0) ? NATIVE_FREQUENCY : value; @@ -1462,8 +1756,12 @@ break; case DSP_FLUSH: +#ifdef DSP_USE_SINC_RESAMPLING + resampler_reset(dsp); +#else memset(&dsp->data.resample_data, 0, sizeof (dsp->data.resample_data)); +#endif resampler_new_delta(dsp); dither_init(dsp); #ifdef HAVE_PITCHSCREEN Index: apps/dsp.h =================================================================== --- apps/dsp.h (Revision 30373) +++ apps/dsp.h (Arbeitskopie) @@ -84,5 +84,7 @@ int dsp_callback(int msg, intptr_t param); void dsp_set_compressor(int c_threshold, int c_gain, int c_ratio, int c_knee, int c_release); - +#ifdef DSP_USE_SINC_RESAMPLING +void dsp_resample_init(void) INIT_ATTR; #endif +#endif Index: apps/sinc.c =================================================================== --- apps/sinc.c (Revision 0) +++ apps/sinc.c (Revision 0) @@ -0,0 +1,260 @@ +#include + +int32_t sinc[256][8] = { + {65536, 0, 0, 0, 0, 0, 0, 0}, + {65534, -246, 111, -61, 35, -19, 9, -4}, + {65529, -490, 220, -122, 69, -37, 18, -8}, + {65521, -732, 330, -182, 103, -56, 27, -13}, + {65509, -972, 439, -242, 137, -74, 36, -17}, + {65494, -1209, 547, -302, 171, -92, 45, -21}, + {65476, -1445, 654, -362, 205, -110, 54, -25}, + {65454, -1678, 761, -421, 238, -128, 63, -29}, + {65429, -1909, 867, -480, 271, -146, 72, -33}, + {65400, -2138, 973, -538, 304, -164, 80, -37}, + {65368, -2365, 1078, -597, 337, -181, 89, -41}, + {65333, -2590, 1182, -654, 370, -199, 97, -45}, + {65295, -2812, 1285, -712, 402, -216, 106, -49}, + {65253, -3032, 1388, -769, 435, -234, 114, -53}, + {65208, -3250, 1490, -826, 467, -251, 123, -56}, + {65159, -3466, 1591, -882, 499, -268, 131, -60}, + {65107, -3680, 1692, -938, 530, -285, 139, -64}, + {65052, -3891, 1792, -994, 562, -301, 147, -68}, + {64994, -4100, 1891, -1049, 593, -318, 155, -71}, + {64932, -4307, 1989, -1104, 624, -335, 163, -75}, + {64867, -4511, 2087, -1158, 654, -351, 171, -79}, + {64798, -4713, 2183, -1212, 685, -367, 179, -82}, + {64727, -4913, 2279, -1266, 715, -383, 187, -86}, + {64652, -5111, 2374, -1319, 745, -399, 195, -90}, + {64573, -5306, 2468, -1372, 775, -415, 202, -93}, + {64492, -5499, 2562, -1424, 804, -430, 210, -97}, + {64407, -5690, 2654, -1476, 833, -446, 217, -100}, + {64319, -5878, 2746, -1527, 862, -461, 224, -103}, + {64228, -6064, 2836, -1578, 891, -476, 232, -107}, + {64133, -6247, 2926, -1628, 919, -491, 239, -110}, + {64035, -6429, 3015, -1678, 947, -506, 246, -113}, + {63934, -6607, 3103, -1728, 975, -521, 253, -117}, + {63830, -6784, 3190, -1777, 1002, -536, 260, -120}, + {63723, -6958, 3277, -1825, 1030, -550, 267, -123}, + {63612, -7130, 3362, -1873, 1057, -564, 274, -126}, + {63499, -7299, 3446, -1920, 1083, -578, 281, -130}, + {63382, -7466, 3530, -1967, 1110, -592, 287, -133}, + {63262, -7631, 3612, -2014, 1136, -606, 294, -136}, + {63138, -7793, 3694, -2060, 1162, -619, 300, -139}, + {63012, -7953, 3774, -2105, 1187, -633, 306, -142}, + {62883, -8110, 3854, -2150, 1212, -646, 313, -145}, + {62750, -8265, 3932, -2194, 1237, -659, 319, -148}, + {62614, -8417, 4010, -2238, 1262, -672, 325, -150}, + {62476, -8568, 4087, -2282, 1286, -685, 331, -153}, + {62334, -8715, 4162, -2324, 1310, -697, 337, -156}, + {62189, -8861, 4237, -2367, 1333, -710, 343, -159}, + {62041, -9004, 4311, -2408, 1357, -722, 349, -161}, + {61890, -9144, 4383, -2449, 1380, -734, 354, -164}, + {61736, -9282, 4455, -2490, 1402, -746, 360, -167}, + {61579, -9418, 4525, -2530, 1425, -757, 365, -169}, + {61419, -9551, 4595, -2569, 1447, -769, 371, -172}, + {61256, -9682, 4663, -2608, 1468, -780, 376, -174}, + {61090, -9810, 4730, -2646, 1490, -791, 381, -177}, + {60921, -9936, 4797, -2684, 1511, -802, 386, -179}, + {60749, -10060, 4862, -2721, 1531, -813, 391, -182}, + {60575, -10181, 4926, -2757, 1552, -823, 396, -184}, + {60397, -10299, 4989, -2793, 1572, -833, 401, -186}, + {60217, -10416, 5051, -2829, 1591, -844, 406, -189}, + {60033, -10530, 5112, -2863, 1611, -854, 410, -191}, + {59847, -10641, 5172, -2898, 1630, -863, 415, -193}, + {59658, -10750, 5231, -2931, 1648, -873, 419, -195}, + {59467, -10857, 5289, -2964, 1667, -882, 424, -197}, + {59272, -10961, 5346, -2996, 1685, -892, 428, -199}, + {59075, -11063, 5401, -3028, 1702, -901, 432, -201}, + {58875, -11162, 5456, -3059, 1720, -909, 436, -203}, + {58672, -11259, 5509, -3090, 1737, -918, 440, -205}, + {58466, -11353, 5561, -3119, 1753, -927, 444, -207}, + {58258, -11446, 5612, -3149, 1769, -935, 448, -209}, + {58047, -11535, 5662, -3177, 1785, -943, 452, -211}, + {57833, -11623, 5711, -3205, 1801, -951, 455, -213}, + {57617, -11708, 5759, -3233, 1816, -958, 459, -215}, + {57398, -11791, 5806, -3260, 1831, -966, 462, -216}, + {57177, -11871, 5851, -3286, 1845, -973, 465, -218}, + {56953, -11949, 5896, -3311, 1859, -980, 469, -220}, + {56726, -12024, 5939, -3336, 1873, -987, 472, -221}, + {56497, -12097, 5981, -3361, 1886, -994, 475, -223}, + {56266, -12168, 6023, -3384, 1899, -1000, 478, -224}, + {56032, -12237, 6063, -3407, 1912, -1007, 480, -226}, + {55795, -12303, 6101, -3430, 1924, -1013, 483, -227}, + {55556, -12367, 6139, -3451, 1936, -1019, 486, -228}, + {55315, -12428, 6176, -3473, 1948, -1024, 488, -230}, + {55071, -12487, 6211, -3493, 1959, -1030, 491, -231}, + {54825, -12544, 6246, -3513, 1970, -1035, 493, -232}, + {54576, -12599, 6279, -3532, 1980, -1041, 496, -233}, + {54325, -12651, 6311, -3551, 1990, -1045, 498, -235}, + {54072, -12701, 6342, -3569, 2000, -1050, 500, -236}, + {53817, -12749, 6372, -3586, 2009, -1055, 502, -237}, + {53559, -12794, 6400, -3603, 2019, -1059, 504, -238}, + {53299, -12837, 6428, -3619, 2027, -1063, 505, -239}, + {53037, -12878, 6455, -3634, 2036, -1067, 507, -240}, + {52772, -12917, 6480, -3649, 2044, -1071, 509, -241}, + {52506, -12953, 6504, -3663, 2051, -1075, 510, -242}, + {52237, -12988, 6527, -3677, 2058, -1078, 512, -243}, + {51966, -13020, 6549, -3690, 2065, -1082, 513, -243}, + {51693, -13049, 6570, -3702, 2072, -1085, 514, -244}, + {51418, -13077, 6590, -3714, 2078, -1087, 516, -245}, + {51141, -13102, 6609, -3725, 2084, -1090, 517, -246}, + {50862, -13125, 6626, -3735, 2089, -1093, 518, -246}, + {50581, -13147, 6643, -3745, 2094, -1095, 519, -247}, + {50298, -13165, 6658, -3754, 2099, -1097, 519, -247}, + {50013, -13182, 6672, -3763, 2104, -1099, 520, -248}, + {49726, -13197, 6686, -3770, 2108, -1101, 521, -248}, + {49437, -13209, 6698, -3778, 2111, -1102, 521, -249}, + {49147, -13220, 6709, -3784, 2115, -1104, 522, -249}, + {48854, -13228, 6719, -3790, 2118, -1105, 522, -250}, + {48560, -13234, 6727, -3796, 2121, -1106, 522, -250}, + {48264, -13238, 6735, -3801, 2123, -1107, 523, -250}, + {47966, -13240, 6742, -3805, 2125, -1107, 523, -250}, + {47667, -13240, 6747, -3809, 2126, -1108, 523, -251}, + {47365, -13238, 6752, -3812, 2128, -1108, 523, -251}, + {47063, -13234, 6755, -3814, 2129, -1108, 523, -251}, + {46758, -13228, 6758, -3816, 2129, -1108, 522, -251}, + {46452, -13220, 6759, -3817, 2130, -1108, 522, -251}, + {46144, -13210, 6759, -3817, 2130, -1107, 522, -251}, + {45835, -13198, 6759, -3817, 2129, -1107, 521, -251}, + {45524, -13184, 6757, -3817, 2129, -1106, 521, -251}, + {45211, -13169, 6754, -3816, 2127, -1105, 520, -251}, + {44898, -13151, 6750, -3814, 2126, -1104, 519, -251}, + {44582, -13131, 6745, -3812, 2124, -1103, 519, -251}, + {44266, -13110, 6739, -3809, 2122, -1101, 518, -251}, + {43947, -13086, 6733, -3805, 2120, -1100, 517, -250}, + {43628, -13061, 6725, -3801, 2117, -1098, 516, -250}, + {43307, -13033, 6716, -3796, 2114, -1096, 515, -250}, + {42985, -13004, 6706, -3791, 2111, -1094, 514, -250}, + {42662, -12974, 6695, -3785, 2107, -1091, 512, -249}, + {42337, -12941, 6683, -3779, 2103, -1089, 511, -249}, + {42011, -12906, 6670, -3772, 2099, -1086, 510, -248}, + {41684, -12870, 6656, -3764, 2095, -1084, 508, -248}, + {41356, -12832, 6642, -3756, 2090, -1081, 507, -247}, + {41026, -12793, 6626, -3748, 2085, -1078, 505, -247}, + {40696, -12751, 6609, -3739, 2079, -1074, 503, -246}, + {40364, -12708, 6592, -3729, 2073, -1071, 502, -246}, + {40032, -12663, 6573, -3719, 2067, -1067, 500, -245}, + {39698, -12617, 6553, -3708, 2061, -1064, 498, -244}, + {39364, -12568, 6533, -3697, 2054, -1060, 496, -244}, + {39028, -12518, 6512, -3685, 2047, -1056, 494, -243}, + {38691, -12467, 6489, -3673, 2040, -1052, 492, -242}, + {38354, -12414, 6466, -3660, 2033, -1048, 490, -242}, + {38016, -12359, 6442, -3646, 2025, -1043, 488, -241}, + {37677, -12303, 6417, -3633, 2017, -1039, 485, -240}, + {37337, -12245, 6391, -3618, 2008, -1034, 483, -239}, + {36996, -12186, 6365, -3603, 2000, -1029, 481, -238}, + {36655, -12125, 6337, -3588, 1991, -1024, 478, -237}, + {36313, -12063, 6309, -3572, 1981, -1019, 476, -236}, + {35970, -11999, 6280, -3556, 1972, -1014, 473, -235}, + {35626, -11933, 6250, -3539, 1962, -1008, 470, -234}, + {35282, -11867, 6219, -3522, 1952, -1003, 468, -233}, + {34937, -11798, 6187, -3504, 1942, -997, 465, -232}, + {34592, -11729, 6154, -3486, 1932, -991, 462, -231}, + {34246, -11658, 6121, -3467, 1921, -986, 459, -230}, + {33900, -11585, 6087, -3448, 1910, -980, 456, -228}, + {33553, -11512, 6052, -3428, 1899, -973, 453, -227}, + {33205, -11436, 6016, -3408, 1887, -967, 450, -226}, + {32858, -11360, 5980, -3388, 1875, -961, 447, -225}, + {32510, -11282, 5943, -3367, 1863, -954, 444, -223}, + {32161, -11203, 5905, -3346, 1851, -948, 441, -222}, + {31812, -11123, 5866, -3324, 1839, -941, 438, -221}, + {31463, -11041, 5827, -3302, 1826, -934, 434, -219}, + {31114, -10959, 5786, -3279, 1813, -927, 431, -218}, + {30764, -10875, 5746, -3256, 1800, -920, 428, -217}, + {30414, -10790, 5704, -3233, 1787, -913, 424, -215}, + {30064, -10703, 5662, -3209, 1773, -906, 421, -214}, + {29714, -10616, 5619, -3184, 1759, -898, 417, -212}, + {29364, -10527, 5575, -3160, 1745, -891, 413, -211}, + {29013, -10437, 5531, -3135, 1731, -883, 410, -209}, + {28663, -10347, 5486, -3110, 1717, -876, 406, -207}, + {28312, -10255, 5440, -3084, 1702, -868, 402, -206}, + {27962, -10162, 5394, -3058, 1688, -860, 399, -204}, + {27611, -10068, 5347, -3031, 1673, -852, 395, -203}, + {27261, -9973, 5300, -3004, 1657, -844, 391, -201}, + {26910, -9877, 5252, -2977, 1642, -836, 387, -199}, + {26560, -9780, 5203, -2950, 1626, -828, 383, -197}, + {26210, -9682, 5154, -2922, 1611, -819, 379, -196}, + {25860, -9583, 5104, -2894, 1595, -811, 375, -194}, + {25510, -9483, 5054, -2865, 1579, -802, 371, -192}, + {25161, -9382, 5003, -2836, 1563, -794, 367, -190}, + {24811, -9281, 4951, -2807, 1546, -785, 363, -188}, + {24462, -9178, 4899, -2778, 1530, -776, 359, -187}, + {24114, -9075, 4847, -2748, 1513, -768, 355, -185}, + {23765, -8971, 4794, -2718, 1496, -759, 351, -183}, + {23417, -8866, 4740, -2688, 1479, -750, 347, -181}, + {23070, -8760, 4686, -2657, 1462, -741, 342, -179}, + {22723, -8654, 4631, -2626, 1444, -732, 338, -177}, + {22376, -8546, 4576, -2595, 1427, -723, 334, -175}, + {22030, -8438, 4521, -2564, 1409, -714, 330, -173}, + {21684, -8330, 4465, -2532, 1392, -704, 325, -171}, + {21339, -8220, 4409, -2500, 1374, -695, 321, -169}, + {20994, -8110, 4352, -2468, 1356, -686, 316, -167}, + {20650, -8000, 4295, -2435, 1338, -676, 312, -165}, + {20307, -7889, 4237, -2403, 1319, -667, 308, -163}, + {19964, -7777, 4179, -2370, 1301, -657, 303, -161}, + {19622, -7664, 4121, -2337, 1283, -648, 299, -159}, + {19280, -7551, 4062, -2303, 1264, -638, 294, -157}, + {18940, -7438, 4003, -2270, 1245, -628, 290, -154}, + {18600, -7324, 3943, -2236, 1226, -618, 285, -152}, + {18261, -7209, 3883, -2202, 1208, -609, 281, -150}, + {17922, -7094, 3823, -2168, 1189, -599, 276, -148}, + {17585, -6978, 3763, -2134, 1169, -589, 271, -146}, + {17248, -6862, 3702, -2099, 1150, -579, 267, -144}, + {16912, -6746, 3641, -2065, 1131, -569, 262, -141}, + {16578, -6629, 3579, -2030, 1112, -559, 258, -139}, + {16244, -6512, 3518, -1995, 1092, -549, 253, -137}, + {15911, -6394, 3456, -1960, 1073, -539, 248, -135}, + {15579, -6276, 3394, -1924, 1053, -529, 244, -132}, + {15248, -6158, 3331, -1889, 1033, -519, 239, -130}, + {14918, -6039, 3269, -1853, 1014, -509, 234, -128}, + {14589, -5921, 3206, -1818, 994, -499, 230, -125}, + {14261, -5801, 3143, -1782, 974, -489, 225, -123}, + {13935, -5682, 3079, -1746, 954, -479, 220, -121}, + {13609, -5562, 3016, -1710, 934, -468, 215, -118}, + {13285, -5442, 2952, -1674, 914, -458, 211, -116}, + {12962, -5322, 2888, -1638, 894, -448, 206, -113}, + {12640, -5202, 2824, -1601, 874, -438, 201, -111}, + {12319, -5082, 2760, -1565, 854, -427, 197, -109}, + {12000, -4961, 2696, -1528, 834, -417, 192, -106}, + {11681, -4840, 2631, -1492, 814, -407, 187, -104}, + {11365, -4720, 2567, -1455, 794, -397, 182, -101}, + {11049, -4599, 2502, -1418, 773, -386, 178, -99}, + {10735, -4478, 2437, -1382, 753, -376, 173, -97}, + {10422, -4357, 2372, -1345, 733, -366, 168, -94}, + {10111, -4236, 2307, -1308, 713, -356, 163, -92}, + {9801, -4115, 2242, -1271, 692, -345, 159, -89}, + {9492, -3994, 2177, -1234, 672, -335, 154, -87}, + {9185, -3873, 2112, -1197, 652, -325, 149, -84}, + {8879, -3752, 2047, -1160, 631, -315, 145, -82}, + {8575, -3631, 1982, -1123, 611, -304, 140, -79}, + {8273, -3510, 1916, -1086, 591, -294, 135, -77}, + {7972, -3389, 1851, -1049, 571, -284, 130, -74}, + {7672, -3268, 1786, -1012, 550, -274, 126, -72}, + {7374, -3148, 1721, -975, 530, -264, 121, -69}, + {7078, -3027, 1655, -938, 510, -253, 116, -67}, + {6783, -2907, 1590, -901, 490, -243, 112, -64}, + {6490, -2787, 1525, -864, 469, -233, 107, -62}, + {6199, -2667, 1460, -827, 449, -223, 102, -59}, + {5909, -2547, 1395, -790, 429, -213, 98, -56}, + {5621, -2428, 1330, -754, 409, -203, 93, -54}, + {5335, -2309, 1265, -717, 389, -193, 89, -51}, + {5051, -2190, 1201, -680, 369, -183, 84, -49}, + {4768, -2071, 1136, -643, 349, -173, 79, -46}, + {4487, -1953, 1071, -607, 329, -163, 75, -44}, + {4208, -1835, 1007, -570, 309, -153, 70, -41}, + {3931, -1717, 943, -534, 289, -143, 66, -39}, + {3655, -1600, 879, -498, 269, -133, 61, -36}, + {3381, -1482, 815, -461, 250, -124, 57, -33}, + {3110, -1366, 751, -425, 230, -114, 52, -31}, + {2840, -1250, 687, -389, 211, -104, 48, -28}, + {2572, -1134, 624, -353, 191, -94, 43, -26}, + {2306, -1018, 560, -317, 172, -85, 39, -23}, + {2042, -903, 497, -281, 152, -75, 34, -21}, + {1779, -788, 434, -246, 133, -66, 30, -18}, + {1519, -674, 371, -210, 114, -56, 26, -15}, + {1261, -561, 309, -175, 94, -47, 21, -13}, + {1005, -448, 247, -140, 75, -37, 17, -10}, + {750, -335, 185, -104, 56, -28, 13, -8}, + {498, -223, 123, -69, 38, -18, 8, -5}, + {248, -111, 61, -35, 19, -9, 4, -3} +}; Index: apps/sinc.h =================================================================== --- apps/sinc.h (Revision 0) +++ apps/sinc.h (Revision 0) @@ -0,0 +1,6 @@ +#ifndef _SINC_H +#define _SINC_H + +extern int32_t sinc[256][8]; + +#endif Index: apps/SOURCES =================================================================== --- apps/SOURCES (Revision 30373) +++ apps/SOURCES (Arbeitskopie) @@ -170,6 +170,9 @@ playback.c codecs.c dsp.c +#ifdef DSP_USE_SINC_RESAMPLING +sinc.c +#endif #ifndef HAVE_HARDWARE_BEEP beep.c #endif Index: apps/main.c =================================================================== --- apps/main.c (Revision 30373) +++ apps/main.c (Arbeitskopie) @@ -87,6 +87,7 @@ #if (CONFIG_CODEC == SWCODEC) #include "playback.h" #include "tdspeed.h" +#include "dsp.h" #endif #if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR) #include "pcm_record.h" @@ -410,6 +411,10 @@ tdspeed_init(); #endif /* CONFIG_CODEC == SWCODEC */ +#if CONFIG_CODEC == SWCODEC && defined (DSP_USE_SINC_RESAMPLING) + dsp_resample_init(); +#endif /* CONFIG_CODEC == SWCODEC */ + audio_init(); settings_apply_skins(); @@ -665,6 +670,9 @@ #if CONFIG_CODEC == SWCODEC && defined (HAVE_PITCHSCREEN) tdspeed_init(); #endif /* CONFIG_CODEC == SWCODEC */ +#if CONFIG_CODEC == SWCODEC && defined (DSP_USE_SINC_RESAMPLING) + dsp_resample_init(); +#endif /* CONFIG_CODEC == SWCODEC */ theme_init_buffer(); #if CONFIG_CODEC != SWCODEC