summaryrefslogtreecommitdiff
path: root/lib/rbcodec
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-05-04 22:00:44 -0400
committerMichael Sevakis <jethead71@rockbox.org>2012-05-04 22:00:44 -0400
commit88aeef91275dd121f2e8663ec79729412aaa2fa2 (patch)
treeb8edc9365cfd8e73744f279724eede910adf53bb /lib/rbcodec
parentdbe5e5f2df24a0dbe650561c0b42ce982346534c (diff)
Remove pointless IRAM allocation from voice DSP.
It's always used in MONO mode and doesn't need the IRAM sample/ resample buffers and 1280 bytes can be freed. M5 can now have its PCM mixer downmix buffer in IRAM. Change-Id: I0af08be5b212b7dfe382bba588a6585eb328a038
Diffstat (limited to 'lib/rbcodec')
-rw-r--r--lib/rbcodec/dsp/dsp_sample_input.c31
-rw-r--r--lib/rbcodec/dsp/dsp_sample_io.h4
-rw-r--r--lib/rbcodec/dsp/lin_resample.c43
3 files changed, 66 insertions, 12 deletions
diff --git a/lib/rbcodec/dsp/dsp_sample_input.c b/lib/rbcodec/dsp/dsp_sample_input.c
index 97b4ec27ad..df0b01f8c6 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 443038919d..0afe75c6ca 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 b3855ec768..5a6f55ac48 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: