summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-02-16 12:01:35 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-02-16 12:01:35 +0000
commit09186e31ae4409f50c1437911a413c36b381f3a4 (patch)
treecec1d61ef397682a6dadf9ff6aaca29ccea4aae0
parent6ffd8043cbdbf6c092ac7eb689863a02dc9840ff (diff)
downloadrockbox-09186e31ae4409f50c1437911a413c36b381f3a4.tar.gz
rockbox-09186e31ae4409f50c1437911a413c36b381f3a4.zip
SWCODEC: Remove the last quirks when upsampling.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12336 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/dsp.c13
-rw-r--r--apps/playback.c26
2 files changed, 21 insertions, 18 deletions
diff --git a/apps/dsp.c b/apps/dsp.c
index e0fb4475da..02e231d800 100644
--- a/apps/dsp.c
+++ b/apps/dsp.c
@@ -253,9 +253,15 @@ static int downsample(int32_t **dst, int32_t **src, int count,
253 if (pos < count) 253 if (pos < count)
254 *d[j]++ = last_sample + FRACMUL((phase & 0xffff) << 15, 254 *d[j]++ = last_sample + FRACMUL((phase & 0xffff) << 15,
255 src[j][pos] - last_sample); 255 src[j][pos] - last_sample);
256 else /* This is kinda nasty but works somewhat well for now */ 256 else
257 *d[j]++ = src[j][count - 1]; 257 {
258 /* No samples can be output here since were already passed the
259 end. Keep phase, save the last sample and return nothing. */
260 i = 0;
261 goto done;
262 }
258 } 263 }
264
259 phase += delta; 265 phase += delta;
260 266
261 while ((pos = phase >> 16) < count) 267 while ((pos = phase >> 16) < count)
@@ -268,6 +274,7 @@ static int downsample(int32_t **dst, int32_t **src, int count,
268 } 274 }
269 275
270 /* Wrap phase accumulator back to start of next frame. */ 276 /* Wrap phase accumulator back to start of next frame. */
277done:
271 r->phase = phase - (count << 16); 278 r->phase = phase - (count << 16);
272 r->last_sample[0] = src[0][count - 1]; 279 r->last_sample[0] = src[0][count - 1];
273 r->last_sample[1] = src[1][count - 1]; 280 r->last_sample[1] = src[1][count - 1];
@@ -768,6 +775,8 @@ int dsp_process(char *dst, const char *src[], int count)
768 count -= samples; 775 count -= samples;
769 apply_gain(tmp, samples); 776 apply_gain(tmp, samples);
770 samples = resample(tmp, samples); 777 samples = resample(tmp, samples);
778 if (samples <= 0)
779 break; /* I'm pretty sure we're downsampling here */
771 if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO) 780 if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO)
772 apply_crossfeed(tmp, samples); 781 apply_crossfeed(tmp, samples);
773 if (dsp->eq_enabled) 782 if (dsp->eq_enabled)
diff --git a/apps/playback.c b/apps/playback.c
index caaaddec6e..aa21ccc39b 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1047,14 +1047,8 @@ static bool voice_pcmbuf_insert_callback(
1047 * against resampling buffer overflows. */ 1047 * against resampling buffer overflows. */
1048 inp_count = dsp_input_count(out_count); 1048 inp_count = dsp_input_count(out_count);
1049 1049
1050 if (inp_count <= 0) 1050 if (inp_count <= 0)
1051 { 1051 return true;
1052 DEBUGF("Error: dsp_input_count(%ld=dsp_output_count(%ld))=%ld<=0\n",
1053 out_count, count, inp_count);
1054 /* If this happens, there are samples of codec data that don't
1055 * become a number of pcm samples, and something is broken */
1056 return false;
1057 }
1058 1052
1059 /* Input size has grown, no error, just don't write more than length */ 1053 /* Input size has grown, no error, just don't write more than length */
1060 if (inp_count > count) 1054 if (inp_count > count)
@@ -1062,6 +1056,9 @@ static bool voice_pcmbuf_insert_callback(
1062 1056
1063 out_count = dsp_process(dest, src, inp_count); 1057 out_count = dsp_process(dest, src, inp_count);
1064 1058
1059 if (out_count <= 0)
1060 return true;
1061
1065 if (playing) 1062 if (playing)
1066 { 1063 {
1067 pcmbuf_mix_voice(out_count); 1064 pcmbuf_mix_voice(out_count);
@@ -1329,14 +1326,8 @@ static bool codec_pcmbuf_insert_callback(
1329 * against resampling buffer overflows. */ 1326 * against resampling buffer overflows. */
1330 inp_count = dsp_input_count(out_count); 1327 inp_count = dsp_input_count(out_count);
1331 1328
1332 if (inp_count <= 0) 1329 if (inp_count <= 0)
1333 { 1330 return true;
1334 DEBUGF("Error: dsp_input_count(%ld=dsp_output_count(%ld))=%ld<=0\n",
1335 out_count, count, inp_count);
1336 /* If this happens, there are samples of codec data that don't
1337 * become a number of pcm samples, and something is broken */
1338 return false;
1339 }
1340 1331
1341 /* Input size has grown, no error, just don't write more than length */ 1332 /* Input size has grown, no error, just don't write more than length */
1342 if (inp_count > count) 1333 if (inp_count > count)
@@ -1344,6 +1335,9 @@ static bool codec_pcmbuf_insert_callback(
1344 1335
1345 out_count = dsp_process(dest, src, inp_count); 1336 out_count = dsp_process(dest, src, inp_count);
1346 1337
1338 if (out_count <= 0)
1339 return true;
1340
1347 pcmbuf_write_complete(out_count); 1341 pcmbuf_write_complete(out_count);
1348 1342
1349#ifdef PLAYBACK_VOICE 1343#ifdef PLAYBACK_VOICE