diff options
author | Thom Johansen <thomj@rockbox.org> | 2007-11-14 00:46:49 +0000 |
---|---|---|
committer | Thom Johansen <thomj@rockbox.org> | 2007-11-14 00:46:49 +0000 |
commit | d75a5486e60d10a74049712d8bdf1fa2816038f8 (patch) | |
tree | 85734ec703eb600faa001859a67138e215566bd7 /apps/codecs/speex.c | |
parent | f554e00b61a2ecfdbf72314414947de57912fe02 (diff) | |
download | rockbox-d75a5486e60d10a74049712d8bdf1fa2816038f8.tar.gz rockbox-d75a5486e60d10a74049712d8bdf1fa2816038f8.zip |
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
Diffstat (limited to 'apps/codecs/speex.c')
-rw-r--r-- | apps/codecs/speex.c | 27 |
1 files changed, 9 insertions, 18 deletions
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, | |||
206 | the bitrate is relativly constant. | 206 | the bitrate is relativly constant. |
207 | */ | 207 | */ |
208 | 208 | ||
209 | curoffset = (int)((((float)(*curbyteoffset-(headerssize)) * | 209 | curoffset = (((*curbyteoffset-headerssize) * pos)/curpos)*98/100; |
210 | (float)pos)/(float)curpos)*0.98); | ||
211 | |||
212 | if (curoffset < 0) | 210 | if (curoffset < 0) |
213 | curoffset=0; | 211 | curoffset=0; |
214 | 212 | ||
@@ -347,12 +345,14 @@ static void *process_header(spx_ogg_packet *op, | |||
347 | speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled); | 345 | speex_decoder_ctl(st, SPEEX_SET_ENH, &enh_enabled); |
348 | speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size); | 346 | speex_decoder_ctl(st, SPEEX_GET_FRAME_SIZE, frame_size); |
349 | 347 | ||
350 | if (*channels!=1){ | 348 | if (header->nb_channels!=1){ |
351 | callback.callback_id = SPEEX_INBAND_STEREO; | 349 | callback.callback_id = SPEEX_INBAND_STEREO; |
352 | callback.func = speex_std_stereo_request_handler; | 350 | callback.func = speex_std_stereo_request_handler; |
353 | callback.data = stereo; | 351 | callback.data = stereo; |
354 | speex_decoder_ctl(st, SPEEX_SET_HANDLER, &callback); | 352 | speex_decoder_ctl(st, SPEEX_SET_HANDLER, &callback); |
355 | } | 353 | } |
354 | *channels = header->nb_channels; | ||
355 | |||
356 | if (!*rate) | 356 | if (!*rate) |
357 | *rate = header->rate; | 357 | *rate = header->rate; |
358 | 358 | ||
@@ -360,9 +360,6 @@ static void *process_header(spx_ogg_packet *op, | |||
360 | 360 | ||
361 | *nframes = header->frames_per_packet; | 361 | *nframes = header->frames_per_packet; |
362 | 362 | ||
363 | if (*channels == -1) | ||
364 | *channels = header->nb_channels; | ||
365 | |||
366 | *extra_headers = header->extra_headers; | 363 | *extra_headers = header->extra_headers; |
367 | 364 | ||
368 | return st; | 365 | return st; |
@@ -382,27 +379,25 @@ enum codec_status codec_main(void) | |||
382 | int enh_enabled = 1; | 379 | int enh_enabled = 1; |
383 | int nframes = 2; | 380 | int nframes = 2; |
384 | int eos = 0; | 381 | int eos = 0; |
385 | static const SpeexStereoState stereo_init = SPEEX_STEREO_STATE_INIT; | 382 | SpeexStereoState *stereo; |
386 | SpeexStereoState stereo = stereo_init; | ||
387 | int channels = -1; | 383 | int channels = -1; |
388 | int rate = 0, samplerate = 0; | 384 | int rate = 0, samplerate = 0; |
389 | int extra_headers = 0; | 385 | int extra_headers = 0; |
390 | int stream_init = 0; | 386 | int stream_init = 0; |
391 | int page_nb_packets, frame_size, packet_count = 0; | 387 | int page_nb_packets, frame_size, packet_count = 0; |
392 | int lookahead = 0; | ||
393 | int headerssize = -1; | 388 | int headerssize = -1; |
394 | unsigned long strtoffset = 0; | 389 | unsigned long strtoffset = 0; |
395 | void *st = NULL; | 390 | void *st = NULL; |
396 | int j = 0; | 391 | int j = 0; |
397 | 392 | ||
398 | /* We need to flush reserver memory every track load. */ | 393 | /* Ogg handling still uses mallocs, so reset the malloc buffer per track */ |
399 | next_track: | 394 | next_track: |
400 | 395 | ||
401 | if (codec_init()) { | 396 | if (codec_init()) { |
402 | error = CODEC_ERROR; | 397 | error = CODEC_ERROR; |
403 | goto exit; | 398 | goto exit; |
404 | } | 399 | } |
405 | 400 | stereo = speex_stereo_state_init(); | |
406 | strtoffset = ci->id3->offset; | 401 | strtoffset = ci->id3->offset; |
407 | 402 | ||
408 | while (!*ci->taginfo_ready && !ci->stop_codec) | 403 | while (!*ci->taginfo_ready && !ci->stop_codec) |
@@ -467,9 +462,7 @@ next_page: | |||
467 | if (packet_count==0){ | 462 | if (packet_count==0){ |
468 | st = process_header(&op, enh_enabled, &frame_size, | 463 | st = process_header(&op, enh_enabled, &frame_size, |
469 | &samplerate, &nframes, &channels, | 464 | &samplerate, &nframes, &channels, |
470 | &stereo, &extra_headers); | 465 | stereo, &extra_headers); |
471 | |||
472 | speex_decoder_ctl(st, SPEEX_GET_LOOKAHEAD, &lookahead); | ||
473 | 466 | ||
474 | if (!nframes) | 467 | if (!nframes) |
475 | nframes=1; | 468 | nframes=1; |
@@ -531,7 +524,7 @@ next_page: | |||
531 | break; | 524 | break; |
532 | 525 | ||
533 | if (channels == 2) | 526 | if (channels == 2) |
534 | speex_decode_stereo_int(output, frame_size, &stereo); | 527 | speex_decode_stereo_int(output, frame_size, stereo); |
535 | 528 | ||
536 | if (frame_size > 0) { | 529 | if (frame_size > 0) { |
537 | ci->pcmbuf_insert(output, NULL, frame_size); | 530 | ci->pcmbuf_insert(output, NULL, frame_size); |
@@ -566,8 +559,6 @@ done: | |||
566 | cur_granule = stream_init = rate = samplerate = headerssize | 559 | cur_granule = stream_init = rate = samplerate = headerssize |
567 | = packet_count = eos = 0; | 560 | = packet_count = eos = 0; |
568 | 561 | ||
569 | stereo = stereo_init; | ||
570 | |||
571 | goto next_track; | 562 | goto next_track; |
572 | } | 563 | } |
573 | 564 | ||