From d75a5486e60d10a74049712d8bdf1fa2816038f8 Mon Sep 17 00:00:00 2001 From: Thom Johansen Date: Wed, 14 Nov 2007 00:46:49 +0000 Subject: New Speex stereo code in libspeex and speex.c, stereo should be more robust now. Remove last floating point code in speex.c and remove some unused stuff. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15611 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/speex.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'apps/codecs/speex.c') diff --git a/apps/codecs/speex.c b/apps/codecs/speex.c index 724160b152..c3f1fc8408 100644 --- a/apps/codecs/speex.c +++ b/apps/codecs/speex.c @@ -206,9 +206,7 @@ int speex_seek_page_granule(spx_int64_t pos, spx_int64_t curpos, the bitrate is relativly constant. */ - curoffset = (int)((((float)(*curbyteoffset-(headerssize)) * - (float)pos)/(float)curpos)*0.98); - + curoffset = (((*curbyteoffset-headerssize) * pos)/curpos)*98/100; if (curoffset < 0) curoffset=0; @@ -347,12 +345,14 @@ static void *process_header(spx_ogg_packet *op, speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled); speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size); - if (*channels!=1){ + if (header->nb_channels!=1){ callback.callback_id = SPEEX_INBAND_STEREO; callback.func = speex_std_stereo_request_handler; callback.data = stereo; speex_decoder_ctl(st, SPEEX_SET_HANDLER, &callback); } + *channels = header->nb_channels; + if (!*rate) *rate = header->rate; @@ -360,9 +360,6 @@ static void *process_header(spx_ogg_packet *op, *nframes = header->frames_per_packet; - if (*channels == -1) - *channels = header->nb_channels; - *extra_headers = header->extra_headers; return st; @@ -382,27 +379,25 @@ enum codec_status codec_main(void) int enh_enabled = 1; int nframes = 2; int eos = 0; - static const SpeexStereoState stereo_init = SPEEX_STEREO_STATE_INIT; - SpeexStereoState stereo = stereo_init; + SpeexStereoState *stereo; int channels = -1; int rate = 0, samplerate = 0; int extra_headers = 0; int stream_init = 0; int page_nb_packets, frame_size, packet_count = 0; - int lookahead = 0; int headerssize = -1; unsigned long strtoffset = 0; void *st = NULL; int j = 0; - /* We need to flush reserver memory every track load. */ + /* Ogg handling still uses mallocs, so reset the malloc buffer per track */ next_track: if (codec_init()) { error = CODEC_ERROR; goto exit; } - + stereo = speex_stereo_state_init(); strtoffset = ci->id3->offset; while (!*ci->taginfo_ready && !ci->stop_codec) @@ -467,9 +462,7 @@ next_page: if (packet_count==0){ st = process_header(&op, enh_enabled, &frame_size, &samplerate, &nframes, &channels, - &stereo, &extra_headers); - - speex_decoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); + stereo, &extra_headers); if (!nframes) nframes=1; @@ -531,7 +524,7 @@ next_page: break; if (channels == 2) - speex_decode_stereo_int(output, frame_size, &stereo); + speex_decode_stereo_int(output, frame_size, stereo); if (frame_size > 0) { ci->pcmbuf_insert(output, NULL, frame_size); @@ -566,8 +559,6 @@ done: cur_granule = stream_init = rate = samplerate = headerssize = packet_count = eos = 0; - stereo = stereo_init; - goto next_track; } -- cgit v1.2.3