From 09186e31ae4409f50c1437911a413c36b381f3a4 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Fri, 16 Feb 2007 12:01:35 +0000 Subject: SWCODEC: Remove the last quirks when upsampling. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12336 a1c6a512-1295-4272-9138-f99709370657 --- apps/dsp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'apps/dsp.c') 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) -- cgit v1.2.3