summaryrefslogtreecommitdiffstats
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,
if (pos < count)
*d[j]++ = last_sample + FRACMUL((phase & 0xffff) << 15,
src[j][pos] - last_sample);
- else /* This is kinda nasty but works somewhat well for now */
- *d[j]++ = src[j][count - 1];
+ else
+ {
+ /* No samples can be output here since were already passed the
+ end. Keep phase, save the last sample and return nothing. */
+ i = 0;
+ goto done;
+ }
}
+
phase += delta;
while ((pos = phase >> 16) < count)
@@ -268,6 +274,7 @@ static int downsample(int32_t **dst, int32_t **src, int count,
}
/* Wrap phase accumulator back to start of next frame. */
+done:
r->phase = phase - (count << 16);
r->last_sample[0] = src[0][count - 1];
r->last_sample[1] = src[1][count - 1];
@@ -768,6 +775,8 @@ int dsp_process(char *dst, const char *src[], int count)
count -= samples;
apply_gain(tmp, samples);
samples = resample(tmp, samples);
+ if (samples <= 0)
+ break; /* I'm pretty sure we're downsampling here */
if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO)
apply_crossfeed(tmp, samples);
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(
* against resampling buffer overflows. */
inp_count = dsp_input_count(out_count);
- if (inp_count <= 0)
- {
- DEBUGF("Error: dsp_input_count(%ld=dsp_output_count(%ld))=%ld<=0\n",
- out_count, count, inp_count);
- /* If this happens, there are samples of codec data that don't
- * become a number of pcm samples, and something is broken */
- return false;
- }
+ if (inp_count <= 0)
+ return true;
/* Input size has grown, no error, just don't write more than length */
if (inp_count > count)
@@ -1062,6 +1056,9 @@ static bool voice_pcmbuf_insert_callback(
out_count = dsp_process(dest, src, inp_count);
+ if (out_count <= 0)
+ return true;
+
if (playing)
{
pcmbuf_mix_voice(out_count);
@@ -1329,14 +1326,8 @@ static bool codec_pcmbuf_insert_callback(
* against resampling buffer overflows. */
inp_count = dsp_input_count(out_count);
- if (inp_count <= 0)
- {
- DEBUGF("Error: dsp_input_count(%ld=dsp_output_count(%ld))=%ld<=0\n",
- out_count, count, inp_count);
- /* If this happens, there are samples of codec data that don't
- * become a number of pcm samples, and something is broken */
- return false;
- }
+ if (inp_count <= 0)
+ return true;
/* Input size has grown, no error, just don't write more than length */
if (inp_count > count)
@@ -1344,6 +1335,9 @@ static bool codec_pcmbuf_insert_callback(
out_count = dsp_process(dest, src, inp_count);
+ if (out_count <= 0)
+ return true;
+
pcmbuf_write_complete(out_count);
#ifdef PLAYBACK_VOICE