diff options
Diffstat (limited to 'src/libxineadec/xine_lpcm_decoder.c')
-rw-r--r-- | src/libxineadec/xine_lpcm_decoder.c | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/src/libxineadec/xine_lpcm_decoder.c b/src/libxineadec/xine_lpcm_decoder.c index 435545d56..b7c0f8d1a 100644 --- a/src/libxineadec/xine_lpcm_decoder.c +++ b/src/libxineadec/xine_lpcm_decoder.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA @@ -58,10 +58,10 @@ typedef struct lpcm_decoder_s { xine_stream_t *stream; uint32_t rate; - uint32_t bits_per_sample; - uint32_t number_of_channels; - uint32_t ao_cap_mode; - + uint32_t bits_per_sample; + uint32_t number_of_channels; + uint32_t ao_cap_mode; + int output_open; int cpu_be; /* TRUE, if we're a Big endian CPU */ } lpcm_decoder_t; @@ -82,7 +82,7 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { int stream_be; audio_buffer_t *audio_buffer; int format_changed = 0; - + /* Drop preview data */ if (buf->decoder_flags & BUF_FLAG_PREVIEW) return; @@ -93,7 +93,7 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { unsigned int bits_per_sample = 16; unsigned int sample_rate = 0; unsigned int num_channels; - + num_channels = (buf->decoder_info[2] & 0x7) + 1; switch ((buf->decoder_info[2]>>4) & 3) { case 0: sample_rate = 48000; break; @@ -106,7 +106,7 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { case 1: bits_per_sample = 20; break; case 2: bits_per_sample = 24; break; } - + if( this->bits_per_sample != bits_per_sample || this->number_of_channels != num_channels || this->rate != sample_rate || @@ -115,16 +115,16 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->number_of_channels = num_channels; this->rate = sample_rate; format_changed++; - } + } } - + if( buf->decoder_flags & BUF_FLAG_STDHEADER ) { this->rate=buf->decoder_info[1]; - this->bits_per_sample=buf->decoder_info[2] ; - this->number_of_channels=buf->decoder_info[3] ; + this->bits_per_sample=buf->decoder_info[2] ; + this->number_of_channels=buf->decoder_info[3] ; format_changed++; } - + /* * (re-)open output device */ @@ -148,11 +148,11 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { /* stream/meta info */ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Linear PCM"); - _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, this->bits_per_sample * this->rate * this->number_of_channels); } - if (!this->output_open || (buf->decoder_flags & BUF_FLAG_HEADER) ) + if (!this->output_open || (buf->decoder_flags & BUF_FLAG_HEADER) ) return; audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); @@ -160,7 +160,7 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { /* Swap LPCM samples into native byte order, if necessary */ buf->type &= 0xffff0000; stream_be = ( buf->type == BUF_AUDIO_LPCM_BE ); - + if( this->bits_per_sample == 16 ){ if (stream_be != this->cpu_be) swab (sample_buffer, audio_buffer->mem, buf->size); @@ -171,20 +171,20 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { uint8_t *s = (uint8_t *)sample_buffer; uint8_t *d = (uint8_t *)audio_buffer->mem; int n = buf->size; - + if (stream_be != this->cpu_be) { while( n >= 0 ) { swab( s, d, 8 ); s += 10; d += 8; - n -= 10; + n -= 10; } } else { while( n >= 0 ) { memcpy( d, s, 8 ); s += 10; d += 8; - n -= 10; + n -= 10; } } } else if( this->bits_per_sample == 24 ) { @@ -223,7 +223,7 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } else { memcpy (audio_buffer->mem, sample_buffer, buf->size); } - + audio_buffer->vpts = buf->pts; audio_buffer->num_frames = (((buf->size*8)/this->number_of_channels)/this->bits_per_sample); @@ -232,9 +232,9 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } static void lpcm_dispose (audio_decoder_t *this_gen) { - lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; + lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; - if (this->output_open) + if (this->output_open) this->stream->audio_out->close (this->stream->audio_out, this->stream); this->output_open = 0; @@ -254,11 +254,11 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre this->output_open = 0; this->rate = 0; - this->bits_per_sample=0; - this->number_of_channels=0; - this->ao_cap_mode=0; + this->bits_per_sample=0; + this->number_of_channels=0; + this->ao_cap_mode=0; this->stream = stream; - + this->cpu_be = ( htons(1) == 1 ); return &this->audio_decoder; @@ -290,7 +290,7 @@ static void *init_plugin (xine_t *xine, void *data) { return this; } -static uint32_t audio_types[] = { +static uint32_t audio_types[] = { BUF_AUDIO_LPCM_BE, BUF_AUDIO_LPCM_LE, 0 }; @@ -300,7 +300,7 @@ static const decoder_info_t dec_info_audio = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_AUDIO_DECODER, 15, "pcm", XINE_VERSION_CODE, &dec_info_audio, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |