diff options
| -rw-r--r-- | firmware/export/pcm_mixer.h | 3 | ||||
| -rw-r--r-- | lib/rbcodec/dsp/dsp_sample_input.c | 31 | ||||
| -rw-r--r-- | lib/rbcodec/dsp/dsp_sample_io.h | 4 | ||||
| -rw-r--r-- | lib/rbcodec/dsp/lin_resample.c | 43 |
4 files changed, 67 insertions, 14 deletions
diff --git a/firmware/export/pcm_mixer.h b/firmware/export/pcm_mixer.h index f6d212d..69d2b89 100644 --- a/firmware/export/pcm_mixer.h +++ b/firmware/export/pcm_mixer.h @@ -40,8 +40,7 @@ #define MIX_FRAME_SAMPLES 256 #endif -/* IAUDIO_M5 is very tight on IRAM */ -#if (defined(CPU_COLDFIRE) && !defined(IAUDIO_M5)) || defined(CPU_PP) +#if defined(CPU_COLDFIRE) || defined(CPU_PP) /* For Coldfire, it's just faster For PortalPlayer, this also avoids more expensive cache coherency */ #define DOWNMIX_BUF_IBSS IBSS_ATTR diff --git a/lib/rbcodec/dsp/dsp_sample_input.c b/lib/rbcodec/dsp/dsp_sample_input.c index 97b4ec2..df0b01f 100644 --- a/lib/rbcodec/dsp/dsp_sample_input.c +++ b/lib/rbcodec/dsp/dsp_sample_input.c @@ -51,6 +51,10 @@ extern void dsp_sample_output_init(struct sample_io_data *this); extern void dsp_sample_output_flush(struct sample_io_data *this); +#define SAMPLE_BUF_COUNT 128 /* Per channel, per DSP */ +/* CODEC_IDX_AUDIO = left and right, CODEC_IDX_VOICE = mono */ +static int32_t sample_bufs[3][SAMPLE_BUF_COUNT] IBSS_ATTR; + /* convert count 16-bit mono to 32-bit mono */ static void sample_input_mono16(struct sample_io_data *this, struct dsp_buffer **buf_p) @@ -269,8 +273,31 @@ static void dsp_sample_input_format_change(struct sample_io_data *this, format_change_ack(&src->format); } -static void dsp_sample_input_init(struct sample_io_data *this) +static void dsp_sample_input_init(struct sample_io_data *this, + enum dsp_ids dsp_id) { + int32_t *lbuf, *rbuf; + + switch (dsp_id) + { + case CODEC_IDX_AUDIO: + lbuf = sample_bufs[0]; + rbuf = sample_bufs[1]; + break; + + case CODEC_IDX_VOICE: + lbuf = rbuf = sample_bufs[2]; /* Always mono */ + break; + + default: + /* orly */ + DEBUGF("DSP Input- unknown dsp %d\n", (int)dsp_id); + return; + } + + this->sample_buf_arr[0] = lbuf; + this->sample_buf_arr[1] = rbuf; + this->input_samples[0] = sample_input_ni_stereo32; this->input_samples[1] = dsp_sample_input_format_change; } @@ -288,7 +315,7 @@ void dsp_sample_io_configure(struct sample_io_data *this, switch (setting) { case DSP_INIT: - dsp_sample_input_init(this); + dsp_sample_input_init(this, (enum dsp_ids)value); dsp_sample_output_init(this); break; diff --git a/lib/rbcodec/dsp/dsp_sample_io.h b/lib/rbcodec/dsp/dsp_sample_io.h index 4430389..0afe75c 100644 --- a/lib/rbcodec/dsp/dsp_sample_io.h +++ b/lib/rbcodec/dsp/dsp_sample_io.h @@ -28,8 +28,6 @@ #define WORD_FRACBITS 27 #define NATIVE_DEPTH 16 -#define SAMPLE_BUF_COUNT 128 /* Per channel, per DSP */ - struct sample_io_data; /* DSP initial buffer input function call prototype */ @@ -50,7 +48,7 @@ struct sample_io_data int stereo_mode; /* Codec-specified input format */ sample_input_fn_type input_samples[2]; /* input functions */ struct dsp_buffer sample_buf; /* Buffer descriptor for converted samples */ - int32_t sample_buf_arr[2][SAMPLE_BUF_COUNT]; /* Internal format */ + int32_t *sample_buf_arr[2]; /* Internal format buffer pointers */ sample_output_fn_type output_samples[2]; /* Final output functions */ }; diff --git a/lib/rbcodec/dsp/lin_resample.c b/lib/rbcodec/dsp/lin_resample.c index b3855ec..5a6f55a 100644 --- a/lib/rbcodec/dsp/lin_resample.c +++ b/lib/rbcodec/dsp/lin_resample.c @@ -40,6 +40,9 @@ #define RESAMPLE_BUF_COUNT 192 /* Per channel, per DSP */ +/* CODEC_IDX_AUDIO = left and right, CODEC_IDX_VOICE = mono */ +static int32_t resample_out_bufs[3][RESAMPLE_BUF_COUNT] IBSS_ATTR; + /* Data for each resampler on each DSP */ static struct resample_data { @@ -50,7 +53,7 @@ static struct resample_data /* 14h */ struct dsp_config *dsp; /* The DSP for this resampler */ struct dsp_buffer resample_buf; /* Buffer descriptor for resampled data */ - int32_t resample_buf_arr[2][RESAMPLE_BUF_COUNT]; /* Actual output data */ + int32_t *resample_buf_arr[2]; /* Actual output data pointers */ } resample_data[DSP_COUNT] IBSS_ATTR; /* Actual worker function. Implemented here or in target assembly code. */ @@ -165,11 +168,9 @@ static void lin_resample_process(struct dsp_proc_entry *this, if (dst->remcount > 0) return; /* data still remains */ - int channels = src->format.num_channels; - dst->remcount = 0; dst->p32[0] = data->resample_buf_arr[0]; - dst->p32[1] = data->resample_buf_arr[channels - 1]; + dst->p32[1] = data->resample_buf_arr[1]; if (src->remcount > 0) { @@ -238,6 +239,36 @@ static void lin_resample_new_format(struct dsp_proc_entry *this, dsp_proc_call(this, buf_p, 0); } +static void lin_resample_init(struct dsp_config *dsp, + enum dsp_ids dsp_id) +{ + /* Always enable resampler so that format changes may be monitored and + * it self-activated when required */ + dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true); + + int32_t *lbuf, *rbuf; + + switch (dsp_id) + { + case CODEC_IDX_AUDIO: + lbuf = resample_out_bufs[0]; + rbuf = resample_out_bufs[1]; + break; + + case CODEC_IDX_VOICE: + lbuf = rbuf = resample_out_bufs[2]; /* Always mono */ + break; + + default: + /* huh? */ + DEBUGF("DSP_PROC_RESAMPLE- unknown DSP %d\n", (int)dsp_id); + return; + } + + resample_data[dsp_id].resample_buf_arr[0] = lbuf; + resample_data[dsp_id].resample_buf_arr[1] = rbuf; +} + /* DSP message hook */ static intptr_t lin_resample_configure(struct dsp_proc_entry *this, struct dsp_config *dsp, @@ -247,9 +278,7 @@ static intptr_t lin_resample_configure(struct dsp_proc_entry *this, switch (setting) { case DSP_INIT: - /* Always enable resampler so that format changes may be monitored and - * it self-activated when required */ - dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true); + lin_resample_init(dsp, (enum dsp_ids)value); break; case DSP_FLUSH: |