From dcd3bdb0ea6df1a110f317ad4d8995653d9ba5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 29 May 2007 19:00:05 +0200 Subject: Use the integer versions of Speex decoding functions, this avoids an iteration over the decoded frames to transform them to integer, and also avoids an improper saturation. --- ChangeLog | 3 +++ src/libxineadec/xine_speex_decoder.c | 21 ++------------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 915f623e1..1f439b880 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,9 @@ xine-lib (1.1.7) (unreleased) * Document dvba: MRLs (ATSC with full tuning info). * Fix VCD playback (broken since 1.1.4). * Fix demuxing of FLAC files with ID3v2 tags. + * Use the integer versions of Speex decoding functions, this avoids an + iteration over the decoded frames to transform them to integers, and + also avoids an improper saturation. xine-lib (1.1.6) * Split the DirectFB plugin into X11 and non-X versions. diff --git a/src/libxineadec/xine_speex_decoder.c b/src/libxineadec/xine_speex_decoder.c index b729dc3bb..034e726a6 100644 --- a/src/libxineadec/xine_speex_decoder.c +++ b/src/libxineadec/xine_speex_decoder.c @@ -72,8 +72,6 @@ typedef struct speex_decoder_s { SpeexStereoState stereo; int expect_metadata; - float output[MAX_FRAME_SIZE]; - int header_count; xine_stream_t *stream; @@ -296,9 +294,8 @@ static void speex_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { for (j = 0; j < this->nframes; j++) { int ret; int bitrate; - ogg_int16_t * ptr = audio_buffer->mem; - ret = speex_decode (this->st, &this->bits, this->output); + ret = speex_decode_int (this->st, &this->bits, audio_buffer->mem); if (ret==-1) break; @@ -312,27 +309,13 @@ static void speex_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } if (this->channels == 2) { - speex_decode_stereo (this->output, this->frame_size, &this->stereo); + speex_decode_stereo_int (audio_buffer->mem, this->frame_size, &this->stereo); } speex_decoder_ctl (this->st, SPEEX_GET_BITRATE, &bitrate); if (bitrate <= 1) bitrate = 16000; /* assume 16 kbit */ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, bitrate); - /*PCM saturation (just in case)*/ - for (i=0; i < this->frame_size * this->channels; i++) - { - if (this->output[i]>32000.0) - this->output[i]=32000.0; - else if (this->output[i]<-32000.0) - this->output[i]=-32000.0; - } - - /*Convert to short and play */ - for (i=0; i< this->frame_size * this->channels; i++) { - *ptr++ = (ogg_int16_t)this->output[i]; - } - audio_buffer->vpts = this->pts; this->pts=0; audio_buffer->num_frames = this->frame_size; -- cgit v1.2.3