diff options
Diffstat (limited to 'lib/rbcodec/dsp/lin_resample.c')
-rw-r--r-- | lib/rbcodec/dsp/lin_resample.c | 43 |
1 files changed, 36 insertions, 7 deletions
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 @@ | |||
40 | 40 | ||
41 | #define RESAMPLE_BUF_COUNT 192 /* Per channel, per DSP */ | 41 | #define RESAMPLE_BUF_COUNT 192 /* Per channel, per DSP */ |
42 | 42 | ||
43 | /* CODEC_IDX_AUDIO = left and right, CODEC_IDX_VOICE = mono */ | ||
44 | static int32_t resample_out_bufs[3][RESAMPLE_BUF_COUNT] IBSS_ATTR; | ||
45 | |||
43 | /* Data for each resampler on each DSP */ | 46 | /* Data for each resampler on each DSP */ |
44 | static struct resample_data | 47 | static struct resample_data |
45 | { | 48 | { |
@@ -50,7 +53,7 @@ static struct resample_data | |||
50 | /* 14h */ | 53 | /* 14h */ |
51 | struct dsp_config *dsp; /* The DSP for this resampler */ | 54 | struct dsp_config *dsp; /* The DSP for this resampler */ |
52 | struct dsp_buffer resample_buf; /* Buffer descriptor for resampled data */ | 55 | struct dsp_buffer resample_buf; /* Buffer descriptor for resampled data */ |
53 | int32_t resample_buf_arr[2][RESAMPLE_BUF_COUNT]; /* Actual output data */ | 56 | int32_t *resample_buf_arr[2]; /* Actual output data pointers */ |
54 | } resample_data[DSP_COUNT] IBSS_ATTR; | 57 | } resample_data[DSP_COUNT] IBSS_ATTR; |
55 | 58 | ||
56 | /* Actual worker function. Implemented here or in target assembly code. */ | 59 | /* Actual worker function. Implemented here or in target assembly code. */ |
@@ -165,11 +168,9 @@ static void lin_resample_process(struct dsp_proc_entry *this, | |||
165 | if (dst->remcount > 0) | 168 | if (dst->remcount > 0) |
166 | return; /* data still remains */ | 169 | return; /* data still remains */ |
167 | 170 | ||
168 | int channels = src->format.num_channels; | ||
169 | |||
170 | dst->remcount = 0; | 171 | dst->remcount = 0; |
171 | dst->p32[0] = data->resample_buf_arr[0]; | 172 | dst->p32[0] = data->resample_buf_arr[0]; |
172 | dst->p32[1] = data->resample_buf_arr[channels - 1]; | 173 | dst->p32[1] = data->resample_buf_arr[1]; |
173 | 174 | ||
174 | if (src->remcount > 0) | 175 | if (src->remcount > 0) |
175 | { | 176 | { |
@@ -238,6 +239,36 @@ static void lin_resample_new_format(struct dsp_proc_entry *this, | |||
238 | dsp_proc_call(this, buf_p, 0); | 239 | dsp_proc_call(this, buf_p, 0); |
239 | } | 240 | } |
240 | 241 | ||
242 | static void lin_resample_init(struct dsp_config *dsp, | ||
243 | enum dsp_ids dsp_id) | ||
244 | { | ||
245 | /* Always enable resampler so that format changes may be monitored and | ||
246 | * it self-activated when required */ | ||
247 | dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true); | ||
248 | |||
249 | int32_t *lbuf, *rbuf; | ||
250 | |||
251 | switch (dsp_id) | ||
252 | { | ||
253 | case CODEC_IDX_AUDIO: | ||
254 | lbuf = resample_out_bufs[0]; | ||
255 | rbuf = resample_out_bufs[1]; | ||
256 | break; | ||
257 | |||
258 | case CODEC_IDX_VOICE: | ||
259 | lbuf = rbuf = resample_out_bufs[2]; /* Always mono */ | ||
260 | break; | ||
261 | |||
262 | default: | ||
263 | /* huh? */ | ||
264 | DEBUGF("DSP_PROC_RESAMPLE- unknown DSP %d\n", (int)dsp_id); | ||
265 | return; | ||
266 | } | ||
267 | |||
268 | resample_data[dsp_id].resample_buf_arr[0] = lbuf; | ||
269 | resample_data[dsp_id].resample_buf_arr[1] = rbuf; | ||
270 | } | ||
271 | |||
241 | /* DSP message hook */ | 272 | /* DSP message hook */ |
242 | static intptr_t lin_resample_configure(struct dsp_proc_entry *this, | 273 | static intptr_t lin_resample_configure(struct dsp_proc_entry *this, |
243 | struct dsp_config *dsp, | 274 | struct dsp_config *dsp, |
@@ -247,9 +278,7 @@ static intptr_t lin_resample_configure(struct dsp_proc_entry *this, | |||
247 | switch (setting) | 278 | switch (setting) |
248 | { | 279 | { |
249 | case DSP_INIT: | 280 | case DSP_INIT: |
250 | /* Always enable resampler so that format changes may be monitored and | 281 | lin_resample_init(dsp, (enum dsp_ids)value); |
251 | * it self-activated when required */ | ||
252 | dsp_proc_enable(dsp, DSP_PROC_RESAMPLE, true); | ||
253 | break; | 282 | break; |
254 | 283 | ||
255 | case DSP_FLUSH: | 284 | case DSP_FLUSH: |