diff options
author | Thom Johansen <thomj@rockbox.org> | 2007-11-14 14:43:32 +0000 |
---|---|---|
committer | Thom Johansen <thomj@rockbox.org> | 2007-11-14 14:43:32 +0000 |
commit | 2bb48eb8edc62072e3ac026e0c26f7dd38a91a9a (patch) | |
tree | dd7954e6f5a26664d19494a32f0e6c5e8d468d0d /apps/codecs/speex.c | |
parent | 80821482006f0730ba70d3e0af63f77cb976285a (diff) | |
download | rockbox-2bb48eb8edc62072e3ac026e0c26f7dd38a91a9a.tar.gz rockbox-2bb48eb8edc62072e3ac026e0c26f7dd38a91a9a.zip |
Throw away the first samples to come out of the decoder to account for encoder latency.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15618 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/speex.c')
-rw-r--r-- | apps/codecs/speex.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/codecs/speex.c b/apps/codecs/speex.c index c3f1fc8408..6fbc8adf64 100644 --- a/apps/codecs/speex.c +++ b/apps/codecs/speex.c @@ -385,6 +385,7 @@ enum codec_status codec_main(void) int extra_headers = 0; int stream_init = 0; int page_nb_packets, frame_size, packet_count = 0; + int lookahead; int headerssize = -1; unsigned long strtoffset = 0; void *st = NULL; @@ -464,6 +465,7 @@ next_page: &samplerate, &nframes, &channels, stereo, &extra_headers); + speex_decoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); if (!nframes) nframes=1; @@ -527,8 +529,13 @@ next_page: speex_decode_stereo_int(output, frame_size, stereo); if (frame_size > 0) { - ci->pcmbuf_insert(output, NULL, frame_size); + spx_int16_t *frame_start = output + lookahead; + if (channels == 2) + frame_start += lookahead; + ci->pcmbuf_insert(frame_start, NULL, + frame_size - lookahead); + lookahead = 0; /* 2 bytes/sample */ cur_granule += frame_size / 2; |