summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Bavin <pondlife@pondlife.me>2009-06-15 15:46:09 +0000
committerSteve Bavin <pondlife@pondlife.me>2009-06-15 15:46:09 +0000
commit77f6f4caadfab255eed4d4cfbd471cb981ccb073 (patch)
tree9f4893b5e5b21763e9dbe9c449c34ca06ae3e7b4
parent3391bf3543876205c253544aa5ba42140b7d8ad0 (diff)
downloadrockbox-77f6f4caadfab255eed4d4cfbd471cb981ccb073.tar.gz
rockbox-77f6f4caadfab255eed4d4cfbd471cb981ccb073.zip
Fix FS#10331 and get mpegplayer working again.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21293 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/dsp.c47
-rw-r--r--apps/main.c6
-rw-r--r--apps/tdspeed.c18
-rw-r--r--apps/tdspeed.h3
4 files changed, 39 insertions, 35 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index b32b641693..496e333bc5 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -245,20 +245,6 @@ static int32_t *resample_buf;
245#define RESAMPLE_BUF_LEFT_CHANNEL 0 245#define RESAMPLE_BUF_LEFT_CHANNEL 0
246#define RESAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2 * RESAMPLE_RATIO) 246#define RESAMPLE_BUF_RIGHT_CHANNEL (sample_buf_count/2 * RESAMPLE_RATIO)
247 247
248#if 0
249/* Clip sample to arbitrary limits where range > 0 and min + range = max */
250static inline long clip_sample(int32_t sample, int32_t min, int32_t range)
251{
252 if ((uint32_t)(sample - min) > (uint32_t)range)
253 {
254 int32_t c = min;
255 if (sample > min)
256 c += range;
257 sample = c;
258 }
259 return sample;
260}
261#endif
262 248
263/* Clip sample to signed 16 bit range */ 249/* Clip sample to signed 16 bit range */
264static inline int32_t clip_sample_16(int32_t sample) 250static inline int32_t clip_sample_16(int32_t sample)
@@ -282,14 +268,14 @@ void sound_set_pitch(int permille)
282 268
283void tdspeed_setup(struct dsp_config *dspc) 269void tdspeed_setup(struct dsp_config *dspc)
284{ 270{
271 dspc->tdspeed_active = false;
285 if (dspc == &AUDIO_DSP) 272 if (dspc == &AUDIO_DSP)
286 { 273 {
287 dspc->tdspeed_active = false;
288 if (!dspc->tdspeed_enabled) 274 if (!dspc->tdspeed_enabled)
289 return; 275 return;
290 if (dspc->tdspeed_percent == 0) 276 if (dspc->tdspeed_percent == 0)
291 dspc->tdspeed_percent = 100; 277 dspc->tdspeed_percent = 100;
292 if (!tdspeed_init( 278 if (!tdspeed_config(
293 dspc->codec_frequency == 0 ? NATIVE_FREQUENCY : dspc->codec_frequency, 279 dspc->codec_frequency == 0 ? NATIVE_FREQUENCY : dspc->codec_frequency,
294 dspc->stereo_mode != STEREO_MONO, 280 dspc->stereo_mode != STEREO_MONO,
295 dspc->tdspeed_percent)) 281 dspc->tdspeed_percent))
@@ -1277,19 +1263,7 @@ int dsp_process(struct dsp_config *dsp, char *dst, const char *src[], int count)
1277/* dsp_input_size MUST be called afterwards */ 1263/* dsp_input_size MUST be called afterwards */
1278int dsp_output_count(struct dsp_config *dsp, int count) 1264int dsp_output_count(struct dsp_config *dsp, int count)
1279{ 1265{
1280 if(!dsp->tdspeed_active) 1266 if (dsp->tdspeed_active)
1281 {
1282 sample_buf = small_sample_buf;
1283 resample_buf = small_resample_buf;
1284 sample_buf_count = SMALL_SAMPLE_BUF_COUNT;
1285 }
1286 else
1287 {
1288 sample_buf = big_sample_buf;
1289 sample_buf_count = big_sample_buf_count;
1290 resample_buf = big_resample_buf;
1291 }
1292 if(dsp->tdspeed_active)
1293 count = tdspeed_est_output_size(); 1267 count = tdspeed_est_output_size();
1294 if (dsp->resample) 1268 if (dsp->resample)
1295 { 1269 {
@@ -1324,7 +1298,7 @@ int dsp_input_count(struct dsp_config *dsp, int count)
1324 dsp->data.resample_data.delta) >> 16); 1298 dsp->data.resample_data.delta) >> 16);
1325 } 1299 }
1326 1300
1327 if(dsp->tdspeed_active) 1301 if (dsp->tdspeed_active)
1328 count = tdspeed_est_input_size(count); 1302 count = tdspeed_est_input_size(count);
1329 1303
1330 return count; 1304 return count;
@@ -1464,6 +1438,19 @@ intptr_t dsp_configure(struct dsp_config *dsp, int setting, intptr_t value)
1464 return 0; 1438 return 0;
1465 } 1439 }
1466 1440
1441 if (!dsp->tdspeed_active)
1442 {
1443 sample_buf = small_sample_buf;
1444 resample_buf = small_resample_buf;
1445 sample_buf_count = SMALL_SAMPLE_BUF_COUNT;
1446 }
1447 else
1448 {
1449 sample_buf = big_sample_buf;
1450 sample_buf_count = big_sample_buf_count;
1451 resample_buf = big_resample_buf;
1452 }
1453
1467 return 1; 1454 return 1;
1468} 1455}
1469 1456
diff --git a/apps/main.c b/apps/main.c
index 642ec5be08..c899912e22 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -336,6 +336,9 @@ static void init(void)
336 336
337 scrobbler_init(); 337 scrobbler_init();
338 cuesheet_init(); 338 cuesheet_init();
339#if CONFIG_CODEC == SWCODEC
340 tdspeed_init();
341#endif /* CONFIG_CODEC == SWCODEC */
339 342
340 audio_init(); 343 audio_init();
341 button_clear_queue(); /* Empty the keyboard buffer */ 344 button_clear_queue(); /* Empty the keyboard buffer */
@@ -549,6 +552,9 @@ static void init(void)
549 filetype_init(); 552 filetype_init();
550 scrobbler_init(); 553 scrobbler_init();
551 cuesheet_init(); 554 cuesheet_init();
555#if CONFIG_CODEC == SWCODEC
556 tdspeed_init();
557#endif /* CONFIG_CODEC == SWCODEC */
552 558
553#if CONFIG_CODEC != SWCODEC 559#if CONFIG_CODEC != SWCODEC
554 /* No buffer allocation (see buffer.c) may take place after the call to 560 /* No buffer allocation (see buffer.c) may take place after the call to
diff --git a/apps/tdspeed.c b/apps/tdspeed.c
index 67f749f6c3..f365e95e03 100644
--- a/apps/tdspeed.c
+++ b/apps/tdspeed.c
@@ -54,11 +54,8 @@ static struct tdspeed_state_s tdspeed_state;
54static int32_t *overlap_buffer[2] = { NULL, NULL }; 54static int32_t *overlap_buffer[2] = { NULL, NULL };
55static int32_t *outbuf[2] = { NULL, NULL }; 55static int32_t *outbuf[2] = { NULL, NULL };
56 56
57bool tdspeed_init(int samplerate, bool stereo, int factor) 57void tdspeed_init()
58{ 58{
59 struct tdspeed_state_s *st = &tdspeed_state;
60 int src_frame_sz;
61
62 /* Allocate buffers */ 59 /* Allocate buffers */
63 if (overlap_buffer[0] == NULL) 60 if (overlap_buffer[0] == NULL)
64 overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t)); 61 overlap_buffer[0] = (int32_t *) buffer_alloc(FIXED_BUFSIZE * sizeof(int32_t));
@@ -68,6 +65,19 @@ bool tdspeed_init(int samplerate, bool stereo, int factor)
68 outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); 65 outbuf[0] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t));
69 if (outbuf[1] == NULL) 66 if (outbuf[1] == NULL)
70 outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t)); 67 outbuf[1] = (int32_t *) buffer_alloc(TDSPEED_OUTBUFSIZE * sizeof(int32_t));
68}
69
70
71bool tdspeed_config(int samplerate, bool stereo, int factor)
72{
73 struct tdspeed_state_s *st = &tdspeed_state;
74 int src_frame_sz;
75
76 /* Check buffers were allocated ok */
77 if (overlap_buffer[0] == NULL || overlap_buffer[1] == NULL)
78 return false;
79 if (outbuf[0] == NULL || outbuf[1] == NULL)
80 return false;
71 81
72 /* Check parameters */ 82 /* Check parameters */
73 if (factor == 100) 83 if (factor == 100)
diff --git a/apps/tdspeed.h b/apps/tdspeed.h
index 6d7cecdcdf..72acebebf8 100644
--- a/apps/tdspeed.h
+++ b/apps/tdspeed.h
@@ -25,7 +25,8 @@
25 25
26#define TDSPEED_OUTBUFSIZE 4096 26#define TDSPEED_OUTBUFSIZE 4096
27 27
28bool tdspeed_init(int samplerate, bool stereo, int factor); 28void tdspeed_init();
29bool tdspeed_config(int samplerate, bool stereo, int factor);
29long tdspeed_est_output_size(void); 30long tdspeed_est_output_size(void);
30long tdspeed_est_input_size(long size); 31long tdspeed_est_input_size(long size);
31int tdspeed_doit(int32_t *src[], int count); 32int tdspeed_doit(int32_t *src[], int count);