diff options
Diffstat (limited to 'apps/dsp.c')
-rw-r--r-- | apps/dsp.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/apps/dsp.c b/apps/dsp.c index 5aa93ccc7c..5f9749c02c 100644 --- a/apps/dsp.c +++ b/apps/dsp.c | |||
@@ -227,7 +227,37 @@ static long album_peak; | |||
227 | static long replaygain; | 227 | static long replaygain; |
228 | static bool crossfeed_enabled; | 228 | static bool crossfeed_enabled; |
229 | 229 | ||
230 | #define AUDIO_DSP (dsp_conf[CODEC_IDX_AUDIO]) | ||
231 | #define VOICE_DSP (dsp_conf[CODEC_IDX_VOICE]) | ||
232 | |||
233 | /* The internal format is 32-bit samples, non-interleaved, stereo. This | ||
234 | * format is similar to the raw output from several codecs, so the amount | ||
235 | * of copying needed is minimized for that case. | ||
236 | */ | ||
237 | |||
238 | #define RESAMPLE_RATIO 4 /* Enough for 11,025 Hz -> 44,100 Hz */ | ||
239 | |||
240 | static int32_t small_sample_buf[SMALL_SAMPLE_BUF_COUNT] IBSS_ATTR; | ||
241 | static int32_t small_resample_buf[SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO] IBSS_ATTR; | ||
242 | |||
243 | static int32_t *big_sample_buf = NULL; | ||
244 | static int32_t *big_resample_buf = NULL; | ||
245 | static int big_sample_buf_count = -1; /* -1=unknown, 0=not available */ | ||
246 | |||
247 | static int sample_buf_count; | ||
248 | static int32_t *sample_buf; | ||
249 | static int32_t *resample_buf; | ||
250 | |||
251 | #define SAMPLE_BUF_LEFT_CHANNEL 0 | ||
252 | #define SAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2) | ||
253 | #define RESAMPLE_BUF_LEFT_CHANNEL 0 | ||
254 | #define RESAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2 * RESAMPLE_RATIO) | ||
255 | |||
230 | /* limiter */ | 256 | /* limiter */ |
257 | /* MAX_COUNT is largest possible sample count in limiter_process. This is | ||
258 | needed in case time stretch makes the count in dsp_process larger than | ||
259 | the limiter buffer. */ | ||
260 | #define MAX_COUNT MAX(SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO / 2, LIMITER_BUFFER_SIZE) | ||
231 | static int count_adjust; | 261 | static int count_adjust; |
232 | static bool limiter_buffer_active; | 262 | static bool limiter_buffer_active; |
233 | static bool limiter_buffer_full; | 263 | static bool limiter_buffer_full; |
@@ -238,7 +268,7 @@ static int32_t *start_lim_buf[2] IBSS_ATTR, | |||
238 | static uint16_t lim_buf_peak[LIMITER_BUFFER_SIZE] IBSS_ATTR; | 268 | static uint16_t lim_buf_peak[LIMITER_BUFFER_SIZE] IBSS_ATTR; |
239 | static uint16_t *start_peak IBSS_ATTR, | 269 | static uint16_t *start_peak IBSS_ATTR, |
240 | *end_peak IBSS_ATTR; | 270 | *end_peak IBSS_ATTR; |
241 | static uint16_t out_buf_peak[LIMITER_BUFFER_SIZE] IBSS_ATTR; | 271 | static uint16_t out_buf_peak[MAX_COUNT] IBSS_ATTR; |
242 | static uint16_t *out_buf_peak_index IBSS_ATTR; | 272 | static uint16_t *out_buf_peak_index IBSS_ATTR; |
243 | static uint16_t release_peak IBSS_ATTR; | 273 | static uint16_t release_peak IBSS_ATTR; |
244 | static int32_t in_samp IBSS_ATTR, | 274 | static int32_t in_samp IBSS_ATTR, |
@@ -276,32 +306,6 @@ const long gain_steps[49] ICONST_ATTR = { 0x10000000, | |||
276 | 0x4EA84FE, 0x4C6D00E, 0x4A41E78, 0x48268DF, 0x461A81C, | 306 | 0x4EA84FE, 0x4C6D00E, 0x4A41E78, 0x48268DF, 0x461A81C, |
277 | 0x441D53E, 0x422E985, 0x404DE62}; | 307 | 0x441D53E, 0x422E985, 0x404DE62}; |
278 | 308 | ||
279 | #define AUDIO_DSP (dsp_conf[CODEC_IDX_AUDIO]) | ||
280 | #define VOICE_DSP (dsp_conf[CODEC_IDX_VOICE]) | ||
281 | |||
282 | /* The internal format is 32-bit samples, non-interleaved, stereo. This | ||
283 | * format is similar to the raw output from several codecs, so the amount | ||
284 | * of copying needed is minimized for that case. | ||
285 | */ | ||
286 | |||
287 | #define RESAMPLE_RATIO 4 /* Enough for 11,025 Hz -> 44,100 Hz */ | ||
288 | |||
289 | static int32_t small_sample_buf[SMALL_SAMPLE_BUF_COUNT] IBSS_ATTR; | ||
290 | static int32_t small_resample_buf[SMALL_SAMPLE_BUF_COUNT * RESAMPLE_RATIO] IBSS_ATTR; | ||
291 | |||
292 | static int32_t *big_sample_buf = NULL; | ||
293 | static int32_t *big_resample_buf = NULL; | ||
294 | static int big_sample_buf_count = -1; /* -1=unknown, 0=not available */ | ||
295 | |||
296 | static int sample_buf_count; | ||
297 | static int32_t *sample_buf; | ||
298 | static int32_t *resample_buf; | ||
299 | |||
300 | #define SAMPLE_BUF_LEFT_CHANNEL 0 | ||
301 | #define SAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2) | ||
302 | #define RESAMPLE_BUF_LEFT_CHANNEL 0 | ||
303 | #define RESAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2 * RESAMPLE_RATIO) | ||
304 | |||
305 | 309 | ||
306 | /* Clip sample to signed 16 bit range */ | 310 | /* Clip sample to signed 16 bit range */ |
307 | static inline int32_t clip_sample_16(int32_t sample) | 311 | static inline int32_t clip_sample_16(int32_t sample) |