diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2007-02-09 18:11:11 +0000 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2007-02-09 18:11:11 +0000 |
| commit | d52f2e4bcaac8a70f306d3022a16ea6360108559 (patch) | |
| tree | 134ae84bc188ee44f4e6cfc7706616618cedd67b /apps/codecs/wavpack_enc.c | |
| parent | 0abfe9f8ea5cc52a17ae3ac0b4ebe9df0b27ce14 (diff) | |
| download | rockbox-d52f2e4bcaac8a70f306d3022a16ea6360108559.zip rockbox-d52f2e4bcaac8a70f306d3022a16ea6360108559.tar.gz rockbox-d52f2e4bcaac8a70f306d3022a16ea6360108559.tar.bz2 rockbox-d52f2e4bcaac8a70f306d3022a16ea6360108559.tar.xz | |
Encoders: Add a little dithering with the fractional bit for mono mixdowns so faster shifts can be used again instead of division without introducing their own DC offset into the mixed channels.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12246 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/wavpack_enc.c')
| -rw-r--r-- | apps/codecs/wavpack_enc.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/apps/codecs/wavpack_enc.c b/apps/codecs/wavpack_enc.c index 208cd3b..7122259 100644 --- a/apps/codecs/wavpack_enc.c +++ b/apps/codecs/wavpack_enc.c @@ -69,6 +69,7 @@ static int8_t input_buffer[PCM_CHUNK_SIZE*2] IBSS_ATTR; static WavpackConfig config IBSS_ATTR; static WavpackContext *wpc; static int32_t data_size, input_size, input_step IBSS_ATTR; +static int32_t err IBSS_ATTR; static const WavpackMetadataHeader wvpk_mdh = { @@ -126,7 +127,9 @@ static void chunk_to_int32(int32_t *src) { int32_t t = *(*src)++; /* endianness irrelevant */ - *(*dst)++ = ((int16_t)t + (t >> 16)) / 2; + t = (int16_t)t + (t >> 16) + err; + err = t & 1; + *(*dst)++ = t >> 1; } /* to_int32 */ do @@ -364,6 +367,8 @@ static bool init_encoder(void) if (!WavpackSetConfiguration(wpc, &config, -1)) return false; + err = 0; + /* configure the buffer system */ params.afmt = AFMT_WAVPACK; input_size = PCM_CHUNK_SIZE*inputs.num_channels / 2; |