diff options
| author | Thom Johansen <thomj@rockbox.org> | 2007-10-29 23:58:00 +0000 |
|---|---|---|
| committer | Thom Johansen <thomj@rockbox.org> | 2007-10-29 23:58:00 +0000 |
| commit | daf937422c17ea571b67e3ef7dae570369daa8a1 (patch) | |
| tree | 27176aa4e280a2055ee6ba35943aa8006084b1ed /apps | |
| parent | 781c82c0d68e007582e98173ff9b767c6bc22df8 (diff) | |
| download | rockbox-daf937422c17ea571b67e3ef7dae570369daa8a1.zip rockbox-daf937422c17ea571b67e3ef7dae570369daa8a1.tar.gz rockbox-daf937422c17ea571b67e3ef7dae570369daa8a1.tar.bz2 rockbox-daf937422c17ea571b67e3ef7dae570369daa8a1.tar.xz | |
Fix faulty clipping when dithering is enabled (thanks to Jens Arnold). This bug would only affect people using WMA. Also, add a small comment in an unrelated place.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15369 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/dsp.c | 32 |
1 files changed, 13 insertions, 19 deletions
@@ -236,14 +236,13 @@ static inline struct dsp_config * switch_dsp(struct dsp_config *_dsp) /* Clip sample to arbitrary limits where range > 0 and min + range = max */ static inline long clip_sample(int32_t sample, int32_t min, int32_t range) { - int32_t c = sample - min; - if ((uint32_t)c > (uint32_t)range) + if ((uint32_t)(sample - min) > (uint32_t)range) { - sample -= c; - if (c > 0) - sample += range; + int32_t c = min; + if (sample > min) + c += range; + sample = c } - return sample; } #endif @@ -488,20 +487,12 @@ static void sample_output_dithered(int count, struct dsp_data *data, dither->random = random; /* Clip */ - int32_t c = output - min; - if ((uint32_t)c > (uint32_t)range) + if ((uint32_t)(output - min) > (uint32_t)range) { - output -= c; - if (c > 0) - { - output += range; - if (sample > max) - sample = max; - } - else if (sample < min) - { - sample = min; - } + int32_t c = min; + if (output > min) + c += range; + output = c; } output &= ~mask; @@ -986,6 +977,9 @@ static void set_tone_controls(void) } #endif +/* Hook back from firmware/ part of audio, which can't/shouldn't call apps/ + * code directly. + */ int dsp_callback(int msg, intptr_t param) { switch (msg) { |