diff options
Diffstat (limited to 'src/audio_dec')
-rw-r--r-- | src/audio_dec/ff_dvaudio_decoder.c | 48 | ||||
-rw-r--r-- | src/audio_dec/fooaudio.c | 18 | ||||
-rw-r--r-- | src/audio_dec/gsm610.c | 10 | ||||
-rw-r--r-- | src/audio_dec/xine_a52_decoder.c | 24 | ||||
-rw-r--r-- | src/audio_dec/xine_dts_decoder.c | 68 | ||||
-rw-r--r-- | src/audio_dec/xine_faad_decoder.c | 118 | ||||
-rw-r--r-- | src/audio_dec/xine_lpcm_decoder.c | 64 | ||||
-rw-r--r-- | src/audio_dec/xine_mad_decoder.c | 62 | ||||
-rw-r--r-- | src/audio_dec/xine_musepack_decoder.c | 122 |
9 files changed, 267 insertions, 267 deletions
diff --git a/src/audio_dec/ff_dvaudio_decoder.c b/src/audio_dec/ff_dvaudio_decoder.c index eba6dee4a..f38167cf8 100644 --- a/src/audio_dec/ff_dvaudio_decoder.c +++ b/src/audio_dec/ff_dvaudio_decoder.c @@ -1,25 +1,25 @@ /* * Copyright (C) 2005 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 * * dv audio decoder based on patch by Dan Dennedy <dan@dennedy.org> */ - + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -219,29 +219,29 @@ static void dvaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) int out; audio_buffer_t *audio_buffer; int bytes_to_send; - + if (buf->decoder_flags & BUF_FLAG_PREVIEW) return; - + if (buf->decoder_flags & BUF_FLAG_STDHEADER) { this->buf = calloc(1, AUDIOBUFSIZE); this->bufsize = AUDIOBUFSIZE; this->size = 0; this->decode_buffer = calloc(1, MAXFRAMESIZE); - + this->audio_sample_rate = buf->decoder_info[1]; this->audio_bits = buf->decoder_info[2]; this->audio_channels = buf->decoder_info[3]; - + _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DV Audio"); - + this->decoder_ok = 1; - + return; } - + if (this->decoder_ok && !(buf->decoder_flags & (BUF_FLAG_HEADER|BUF_FLAG_SPECIAL))) { - + if (!this->output_open) { this->output_open = (this->stream->audio_out->open) (this->stream->audio_out, this->stream, this->audio_bits, this->audio_sample_rate, @@ -251,11 +251,11 @@ static void dvaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) /* if the audio still isn't open, bail */ if (!this->output_open) return; - + if( this->size + buf->size > this->bufsize ) { this->bufsize = this->size + 2 * buf->size; xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - _("dvaudio: increasing buffer to %d to avoid overflow.\n"), + _("dvaudio: increasing buffer to %d to avoid overflow.\n"), this->bufsize); this->buf = realloc( this->buf, this->bufsize ); } @@ -273,14 +273,14 @@ static void dvaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) bytes_consumed = dv_frame_profile(&this->buf[offset])->frame_size; else bytes_consumed = decode_buffer_size; - + /* dispatch the decoded audio */ out = 0; while (out < decode_buffer_size) { - audio_buffer = + audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); if (audio_buffer->mem_size == 0) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "dvaudio: Help! Allocated audio buffer with nothing in it!\n"); return; } @@ -316,7 +316,7 @@ static void dvaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) static void dvaudio_reset (audio_decoder_t *this_gen) { dvaudio_decoder_t *this = (dvaudio_decoder_t *) this_gen; - + this->size = 0; } @@ -326,7 +326,7 @@ static void dvaudio_discontinuity (audio_decoder_t *this_gen) { static void dvaudio_dispose (audio_decoder_t *this_gen) { dvaudio_decoder_t *this = (dvaudio_decoder_t *) this_gen; - + if (this->output_open) this->stream->audio_out->close (this->stream->audio_out, this->stream); this->output_open = 0; @@ -354,7 +354,7 @@ static audio_decoder_t *dvaudio_open_plugin (audio_decoder_class_t *class_gen, x this->buf = NULL; this->size = 0; this->decoder_ok = 0; - + return &this->audio_decoder; } @@ -372,7 +372,7 @@ static void *init_dvaudio_plugin (xine_t *xine, void *data) { return this; } -static uint32_t supported_audio_types[] = { +static uint32_t supported_audio_types[] = { BUF_AUDIO_DV, 0 }; @@ -381,13 +381,13 @@ static const decoder_info_t dec_info_dvaudio = { supported_audio_types, /* supported types */ 5 /* priority */ }; - + /* * exported plugin catalog entry */ 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, 16, "dvaudio", XINE_VERSION_CODE, &dec_info_dvaudio, init_dvaudio_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/audio_dec/fooaudio.c b/src/audio_dec/fooaudio.c index 7e202d627..d2f1f74a4 100644 --- a/src/audio_dec/fooaudio.c +++ b/src/audio_dec/fooaudio.c @@ -130,7 +130,7 @@ static void fooaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) * the accumulator buffer size as necessary */ if( this->size + buf->size > this->bufsize ) { this->bufsize = this->size + 2 * buf->size; - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "fooaudio: increasing source buffer to %d to avoid overflow.\n", this->bufsize); this->buf = realloc( this->buf, this->bufsize ); } @@ -151,8 +151,8 @@ static void fooaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) * This decoder generates a continuous sine pattern based on the pts * values sent by the xine engine. Two pts values are needed to know * how long to make the audio. Thus, If this is the first frame or - * a seek has occurred (indicated by this->last_pts = -1), - * log the pts but do not create any audio. + * a seek has occurred (indicated by this->last_pts = -1), + * log the pts but do not create any audio. * * When a valid pts delta is generated, create n audio samples, where * n is given as: @@ -181,7 +181,7 @@ static void fooaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) /* get an audio buffer */ audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); if (audio_buffer->mem_size == 0) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "fooaudio: Help! Allocated audio buffer with nothing in it!\n"); return; } @@ -196,7 +196,7 @@ static void fooaudio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) #define WAVE_HZ 300 /* fill up the samples in the buffer */ for (i = 0; i < samples_to_send; i++) - audio_buffer->mem[i] = + audio_buffer->mem[i] = (short)(sin(2 * M_PI * this->iteration++ / WAVE_HZ) * 32767); /* final prep for audio buffer dispatch */ @@ -296,7 +296,7 @@ static void dispose_class (audio_decoder_class_t *this_gen) { free (this); } -/* This function allocates a private audio decoder class and initializes +/* This function allocates a private audio decoder class and initializes * the class's member functions. */ static void *init_plugin (xine_t *xine, void *data) { @@ -312,18 +312,18 @@ static void *init_plugin (xine_t *xine, void *data) { return this; } -/* This is a list of all of the internal xine audio buffer types that +/* This is a list of all of the internal xine audio buffer types that * this decoder is able to handle. Check src/xine-engine/buffer.h for a * list of valid buffer types (and add a new one if the one you need does * not exist). Terminate the list with a 0. */ -static const uint32_t audio_types[] = { +static const uint32_t audio_types[] = { /* BUF_AUDIO_FOO, */ 0 }; /* This data structure combines the list of supported xine buffer types and * the priority that the plugin should be given with respect to other - * plugins that handle the same buffer type. A plugin with priority (n+1) + * plugins that handle the same buffer type. A plugin with priority (n+1) * will be used instead of a plugin with priority (n). */ static const decoder_info_t dec_info_audio = { audio_types, /* supported types */ diff --git a/src/audio_dec/gsm610.c b/src/audio_dec/gsm610.c index 25f54d310..be98da798 100644 --- a/src/audio_dec/gsm610.c +++ b/src/audio_dec/gsm610.c @@ -34,7 +34,7 @@ * are deemed to have made any representations as to the suitability of this * software for any purpose nor are held responsible for any defects of * this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. - * + * * As a matter of courtesy, the authors request to be informed about uses * this software has found, about bugs in this software, and about any * improvements that may be of general interest. @@ -125,7 +125,7 @@ static void gsm610_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if( this->size + buf->size > this->bufsize ) { this->bufsize = this->size + 2 * buf->size; - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "gsm610: increasing source buffer to %d to avoid overflow.\n", this->bufsize); this->buf = realloc( this->buf, this->bufsize ); } @@ -143,7 +143,7 @@ static void gsm610_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { /* the data should line up on a 65-byte boundary */ if ((buf->size % 65) != 0) { - xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "gsm610: received MS GSM block that does not line up\n"); this->size = 0; return; @@ -263,7 +263,7 @@ static void *init_plugin (xine_t *xine, void *data) { return this; } -static const uint32_t audio_types[] = { +static const uint32_t audio_types[] = { BUF_AUDIO_MSGSM, BUF_AUDIO_GSM610, 0 @@ -275,7 +275,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, 16, "gsm610", XINE_VERSION_CODE, &dec_info_audio, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/audio_dec/xine_a52_decoder.c b/src/audio_dec/xine_a52_decoder.c index 02ed2b622..bb0169a21 100644 --- a/src/audio_dec/xine_a52_decoder.c +++ b/src/audio_dec/xine_a52_decoder.c @@ -76,11 +76,11 @@ int a52file; typedef struct { audio_decoder_class_t decoder_class; config_values_t *config; - + float a52_level; int disable_dynrng_compress; int enable_surround_downmix; - + const AVCRC *av_crc; } a52dec_class_t; @@ -226,7 +226,7 @@ static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts, int previe */ #ifdef LOG_PTS printf("a52dec:decode_frame:pts=%lld\n",pts); -#endif +#endif if (!this->bypass_mode) { int a52_output_flags, i; @@ -278,7 +278,7 @@ static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts, int previe this->stream->audio_out->close (this->stream->audio_out, this->stream); - this->output_open = (this->stream->audio_out->open) (this->stream->audio_out, + this->output_open = (this->stream->audio_out->open) (this->stream->audio_out, this->stream, 16, this->a52_sample_rate, output_mode) ; @@ -302,13 +302,13 @@ static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts, int previe for (i = 0; i < 6; i++) { if (a52_block (this->a52_state)) { xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "liba52: a52_block error on audio channel %d\n", i); -#if 0 +#if 0 for(n=0;n<2000;n++) { printf("%02x ",this->frame_buffer[n]); if ((n % 32) == 0) printf("\n"); } printf("\n"); -#endif +#endif buf->num_frames = 0; break; } @@ -460,7 +460,7 @@ static void a52dec_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { * We call the start of an A52 frame a frame header. * So, if a A52 pack has 2 "Number of frame headers" is means that the A52 pack contains 2 A52 frame headers. * The "First access unit" then tells us which A52 frame the PTS value applies to. - * + * * Take the following example: - * PACK1: PTS = 10. Contains the entire A52 frame1, followed by the beginning of the frame2. PTS applies to frame1. * PACK2: PTS = 1000, Contains the rest of frame2, and the whole of frame3. and the start of frame4. PTS applies to frame4. @@ -582,14 +582,14 @@ static void a52dec_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } } break; - + case 2: /* Filling frame_buffer with sync_info bytes */ *this->frame_ptr++ = *current++; this->frame_todo--; if (this->frame_todo < 1) { this->sync_state = 3; } else break; - + case 3: { /* Ready for decode */ if (av_crc(this->class->av_crc, 0, &this->frame_buffer[2], this->frame_length - 2) != 0) { /* CRC16 failed */ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "liba52:a52 frame failed crc16 checksum.\n"); @@ -622,7 +622,7 @@ static void a52dec_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->syncword = 0; this->sync_state = 0; break; - default: /* No come here */ + default: /* No come here */ break; } } @@ -676,14 +676,14 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre this->pts_list_position = 0; if( !this->a52_state ) { - this->a52_state = + this->a52_state = #ifdef HAVE_A52DEC_A52_H /* External liba52 */ /* When using external liba52, enable _all_ capabilities, even if that might break stuff if they add some new capability that depends on CPU's caps. At the moment the only capability is DJBFFT, which is tested only if djbfft is being used at compile time. - + The actual question would be: why don't they check for capabilities themselves? */ diff --git a/src/audio_dec/xine_dts_decoder.c b/src/audio_dec/xine_dts_decoder.c index 345d821fd..2f4039696 100644 --- a/src/audio_dec/xine_dts_decoder.c +++ b/src/audio_dec/xine_dts_decoder.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2007 the xine project - * + * * This file is part of xine, a unix 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 @@ -75,7 +75,7 @@ typedef struct { dts_state_t *dts_state; int64_t pts; - int audio_caps; + int audio_caps; int sync_state; int ac5_length, ac5_pcm_length, frame_todo; uint32_t syncdword; @@ -83,7 +83,7 @@ typedef struct { uint8_t *frame_ptr; int output_open; - + int bypass_mode; int dts_flags; int dts_sample_rate; @@ -91,8 +91,8 @@ typedef struct { int dts_flags_map[11]; /* Convert from stream dts_flags to the dts_flags we want from the dts downmixer */ int ao_flags_map[11]; /* Convert from the xine AO_CAP's to dts_flags. */ int have_lfe; - - + + } dts_decoder_t; static void dts_reset (audio_decoder_t *const this_gen) { @@ -143,7 +143,7 @@ static void dts_decode_frame (dts_decoder_t *this, const int64_t pts, const int int output_mode = AO_CAP_MODE_STEREO; uint8_t *data_out; uint8_t *const data_in = this->frame_buffer; - + lprintf("decode_frame\n"); audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); audio_buffer->vpts = pts; @@ -152,13 +152,13 @@ static void dts_decode_frame (dts_decoder_t *this, const int64_t pts, const int /* SPDIF digital output */ if (!this->output_open) { this->output_open = ((this->stream->audio_out->open) (this->stream->audio_out, this->stream, - 16, this->dts_sample_rate, + 16, this->dts_sample_rate, AO_CAP_MODE_AC5)); } - - if (!this->output_open) + + if (!this->output_open) return; - + data_out=(uint8_t *) audio_buffer->mem; if (this->ac5_length > 8191) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "libdts: ac5_length too long\n"); @@ -176,7 +176,7 @@ static void dts_decode_frame (dts_decoder_t *this, const int64_t pts, const int ac5_spdif_type = 0x0d; /* DTS-1 (2048-sample bursts) */ break; default: - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "libdts: DTS %i-sample bursts not supported\n", this->ac5_pcm_length); return; } @@ -256,17 +256,17 @@ static void dts_decode_frame (dts_decoder_t *this, const int64_t pts, const int if (!this->output_open) { this->output_open = (this->stream->audio_out->open) (this->stream->audio_out, this->stream, - 16, this->dts_sample_rate, + 16, this->dts_sample_rate, output_mode); } - - if (!this->output_open) + + if (!this->output_open) return; - number_of_dts_blocks = dts_blocks_num (this->dts_state); + number_of_dts_blocks = dts_blocks_num (this->dts_state); audio_buffer->num_frames = 256*number_of_dts_blocks; for(i = 0; i < number_of_dts_blocks; i++) { if(dts_block(this->dts_state)) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "libdts: dts_block error on audio channel %d\n", i); audio_buffer->num_frames = 0; break; @@ -320,10 +320,10 @@ static void dts_decode_frame (dts_decoder_t *this, const int64_t pts, const int } } } - + this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream); - - + + } static void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { @@ -332,7 +332,7 @@ static void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { uint8_t *current = (uint8_t *)buf->content; uint8_t *sync_start=current + 1; uint8_t *const end = buf->content + buf->size; - + lprintf("decode_data\n"); if (buf->decoder_flags & BUF_FLAG_PREVIEW) @@ -431,14 +431,14 @@ static void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } } break; - + case 2: /* Filling frame_buffer with sync_info bytes */ *this->frame_ptr++ = *current++; this->frame_todo--; if (this->frame_todo < 1) { this->sync_state = 3; } else break; - + case 3: /* Ready for decode */ #if 0 dtsdec_decode_frame (this, this->pts_list[0], buf->decoder_flags & BUF_FLAG_PREVIEW); @@ -450,18 +450,18 @@ static void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->syncdword = 0; this->sync_state = 0; break; - default: /* No come here */ + default: /* No come here */ break; } } } static void dts_dispose (audio_decoder_t *this_gen) { - dts_decoder_t *const this = (dts_decoder_t *) this_gen; - - if (this->output_open) + dts_decoder_t *const this = (dts_decoder_t *) this_gen; + + if (this->output_open) this->stream->audio_out->close (this->stream->audio_out, this->stream); - + free (this); } @@ -507,7 +507,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre this->dts_flags_map[DTS_3F2R] = DTS_3F2R | DTS_LFE; this->ao_flags_map[DTS_2F2R] = AO_CAP_MODE_4CHANNEL; this->ao_flags_map[DTS_3F2R] = AO_CAP_MODE_5CHANNEL; - + } else if (this->audio_caps & AO_CAP_MODE_5CHANNEL) { this->dts_flags_map[DTS_2F2R] = DTS_2F2R; @@ -574,7 +574,7 @@ static void *init_plugin (xine_t *xine, void *data) { return this; } -static const uint32_t audio_types[] = { +static const uint32_t audio_types[] = { BUF_AUDIO_DTS, 0 }; @@ -584,7 +584,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, 16, "dts", XINE_VERSION_CODE, &dec_info_audio, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/audio_dec/xine_faad_decoder.c b/src/audio_dec/xine_faad_decoder.c index 9646c0744..cd58771e7 100644 --- a/src/audio_dec/xine_faad_decoder.c +++ b/src/audio_dec/xine_faad_decoder.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2005 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,29 +58,29 @@ typedef struct faad_decoder_s { audio_decoder_t audio_decoder; xine_stream_t *stream; - + /* faad2 stuff */ NeAACDecHandle faac_dec; NeAACDecConfigurationPtr faac_cfg; NeAACDecFrameInfo faac_finfo; int faac_failed; - + int raw_mode; - + unsigned char *buf; int size; int rec_audio_src_size; int max_audio_src_size; int pts; - + unsigned char *dec_config; int dec_config_size; - + unsigned long rate; - int bits_per_sample; - unsigned char num_channels; + int bits_per_sample; + unsigned char num_channels; int sbr; - + int output_open; unsigned long total_time; @@ -138,7 +138,7 @@ static int faad_open_dec( faad_decoder_t *this ) { if( this->dec_config ) { used = NeAACDecInit2(this->faac_dec, this->dec_config, this->dec_config_size, &this->rate, &this->num_channels); - + if( used < 0 ) { xprintf( this->stream->xine, XINE_VERBOSITY_LOG, _("libfaad: libfaad NeAACDecInit2 failed.\n")); @@ -149,7 +149,7 @@ static int faad_open_dec( faad_decoder_t *this ) { } else { used = NeAACDecInit(this->faac_dec, this->buf, this->size, &this->rate, &this->num_channels); - + if( used < 0 ) { xprintf ( this->stream->xine, XINE_VERBOSITY_LOG, _("libfaad: libfaad NeAACDecInit failed.\n")); @@ -157,16 +157,16 @@ static int faad_open_dec( faad_decoder_t *this ) { } else { lprintf( "NeAACDecInit() returned rate=%"PRId32" channels=%d (used=%d)\n", this->rate, this->num_channels, used); - + this->size -= used; memmove( this->buf, &this->buf[used], this->size ); } } } - + if( !this->bits_per_sample ) this->bits_per_sample = 16; - + if( this->faac_failed ) { if( this->faac_dec ) { NeAACDecClose( this->faac_dec ); @@ -176,7 +176,7 @@ static int faad_open_dec( faad_decoder_t *this ) { } else { faad_meta_info_set(this); } - + return this->faac_failed; } @@ -184,10 +184,10 @@ static int faad_open_output( faad_decoder_t *this ) { int ao_cap_mode; this->rec_audio_src_size = this->num_channels * FAAD_MIN_STREAMSIZE; - + switch( this->num_channels ) { case 1: - ao_cap_mode=AO_CAP_MODE_MONO; + ao_cap_mode=AO_CAP_MODE_MONO; break; case 6: if(this->stream->audio_out->get_capabilities(this->stream->audio_out) & @@ -202,11 +202,11 @@ static int faad_open_output( faad_decoder_t *this ) { } case 2: ao_cap_mode=AO_CAP_MODE_STEREO; - break; + break; default: return 0; } - + this->output_open = (this->stream->audio_out->open) (this->stream->audio_out, this->stream, this->bits_per_sample, @@ -221,48 +221,48 @@ static void faad_decode_audio ( faad_decoder_t *this, int end_frame ) { uint8_t *inbuf; audio_buffer_t *audio_buffer; int sample_size = this->size; - + if( !this->faac_dec ) return; inbuf = this->buf; while( (!this->raw_mode && end_frame && this->size >= 10) || (this->raw_mode && this->size >= this->rec_audio_src_size) ) { - - sample_buffer = NeAACDecDecode(this->faac_dec, + + sample_buffer = NeAACDecDecode(this->faac_dec, &this->faac_finfo, inbuf, sample_size); - + if( !sample_buffer ) { xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "libfaad: %s\n", NeAACDecGetErrorMessage(this->faac_finfo.error)); - used = 1; + used = 1; } else { used = this->faac_finfo.bytesconsumed; - + /* raw AAC parameters might only be known after decoding the first frame */ if( !this->dec_config && (this->num_channels != this->faac_finfo.channels || this->rate != this->faac_finfo.samplerate) ) { - + this->num_channels = this->faac_finfo.channels; this->rate = this->faac_finfo.samplerate; - + lprintf("NeAACDecDecode() returned rate=%"PRId32" channels=%d used=%d\n", this->rate, this->num_channels, used); - + this->stream->audio_out->close (this->stream->audio_out, this->stream); this->output_open = 0; faad_open_output( this ); faad_meta_info_set( this ); } - + /* faad doesn't tell us about sbr until after the first frame */ if (this->sbr != this->faac_finfo.sbr) { this->sbr = this->faac_finfo.sbr; faad_meta_info_set( this ); } - + /* estimate bitrate */ this->total_time += (1000*this->faac_finfo.samples/(this->rate*this->num_channels)); this->total_data += 8*used; @@ -308,25 +308,25 @@ static void faad_decode_audio ( faad_decoder_t *this, int end_frame ) { while( decoded ) { audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); - + if( decoded < audio_buffer->mem_size ) - outsize = decoded; + outsize = decoded; else outsize = audio_buffer->mem_size; - + xine_fast_memcpy( audio_buffer->mem, sample_buffer, outsize ); audio_buffer->num_frames = outsize / (this->num_channels*2); audio_buffer->vpts = this->pts; this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream); - + this->pts = 0; decoded -= outsize; sample_buffer += outsize; } } - + if(used >= this->size){ this->size = 0; } else { @@ -335,7 +335,7 @@ static void faad_decode_audio ( faad_decoder_t *this, int end_frame ) { } if( !this->raw_mode ) - this->size = 0; + this->size = 0; } if( this->size ) @@ -346,31 +346,31 @@ static void faad_decode_audio ( faad_decoder_t *this, int end_frame ) { static void faad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { faad_decoder_t *this = (faad_decoder_t *) this_gen; - + if (buf->decoder_flags & BUF_FLAG_PREVIEW) return; /* store config information from ESDS mp4/qt atom */ if( !this->faac_dec && (buf->decoder_flags & BUF_FLAG_SPECIAL) && buf->decoder_info[1] == BUF_SPECIAL_DECODER_CONFIG ) { - + this->dec_config = malloc(buf->decoder_info[2]); this->dec_config_size = buf->decoder_info[2]; memcpy(this->dec_config, buf->decoder_info_ptr[2], buf->decoder_info[2]); - + if( faad_open_dec(this) ) return; this->raw_mode = 0; } - /* get audio parameters from file header - (may be overwritten by libfaad returned parameters) */ + /* get audio parameters from file header + (may be overwritten by libfaad returned parameters) */ if (buf->decoder_flags & BUF_FLAG_STDHEADER) { this->rate=buf->decoder_info[1]; - this->bits_per_sample=buf->decoder_info[2] ; - this->num_channels=buf->decoder_info[3] ; - + this->bits_per_sample=buf->decoder_info[2] ; + this->num_channels=buf->decoder_info[3] ; + if( buf->size > sizeof(xine_waveformatex) ) { xine_waveformatex *wavex = (xine_waveformatex *) buf->content; @@ -379,7 +379,7 @@ static void faad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->dec_config_size = wavex->cbSize; memcpy(this->dec_config, buf->content + sizeof(xine_waveformatex), wavex->cbSize); - + if( faad_open_dec(this) ) return; @@ -395,15 +395,15 @@ static void faad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if( !this->size ) this->pts = buf->pts; - + if( this->size + buf->size > this->max_audio_src_size ) { this->max_audio_src_size = this->size + 2 * buf->size; this->buf = realloc( this->buf, this->max_audio_src_size ); } - + memcpy (&this->buf[this->size], buf->content, buf->size); this->size += buf->size; - + if( !this->faac_dec && faad_open_dec(this) ) return; @@ -421,23 +421,23 @@ static void faad_discontinuity (audio_decoder_t *this_gen) { static void faad_dispose (audio_decoder_t *this_gen) { - faad_decoder_t *this = (faad_decoder_t *) this_gen; + faad_decoder_t *this = (faad_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; - + if( this->buf ) free(this->buf); this->buf = NULL; this->size = 0; this->max_audio_src_size = 0; - + if( this->dec_config ) free(this->dec_config); this->dec_config = NULL; this->dec_config_size = 0; - + if( this->faac_dec ) NeAACDecClose(this->faac_dec); this->faac_dec = NULL; @@ -461,7 +461,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre this->stream = stream; this->output_open = 0; this->raw_mode = 1; - this->faac_dec = NULL; + this->faac_dec = NULL; this->faac_failed = 0; this->buf = NULL; this->size = 0; @@ -490,7 +490,7 @@ static void *init_plugin (xine_t *xine, void *data) { return this; } -static const uint32_t audio_types[] = { +static const uint32_t audio_types[] = { BUF_AUDIO_AAC, 0 }; diff --git a/src/audio_dec/xine_lpcm_decoder.c b/src/audio_dec/xine_lpcm_decoder.c index ebaceee8d..f5e2aeb6d 100644 --- a/src/audio_dec/xine_lpcm_decoder.c +++ b/src/audio_dec/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 @@ -62,10 +62,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; @@ -86,7 +86,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; @@ -97,7 +97,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; @@ -110,7 +110,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 || @@ -119,16 +119,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 */ @@ -152,11 +152,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); @@ -164,7 +164,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); @@ -175,20 +175,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 ) { @@ -227,7 +227,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); @@ -236,9 +236,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; @@ -258,11 +258,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; @@ -282,7 +282,7 @@ static void *init_plugin (xine_t *xine, void *data) { return this; } -static const uint32_t audio_types[] = { +static const uint32_t audio_types[] = { BUF_AUDIO_LPCM_BE, BUF_AUDIO_LPCM_LE, 0 }; @@ -292,7 +292,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, 16, "pcm", XINE_VERSION_CODE, &dec_info_audio, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/audio_dec/xine_mad_decoder.c b/src/audio_dec/xine_mad_decoder.c index 9d66d4f5b..3338028dd 100644 --- a/src/audio_dec/xine_mad_decoder.c +++ b/src/audio_dec/xine_mad_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 @@ -73,7 +73,7 @@ typedef struct mad_decoder_s { int64_t pts; - struct mad_synth synth; + struct mad_synth synth; struct mad_stream stream; struct mad_frame frame; @@ -115,7 +115,7 @@ static void mad_reset (audio_decoder_t *this_gen) { static void mad_discontinuity (audio_decoder_t *this_gen) { mad_decoder_t *this = (mad_decoder_t *) this_gen; - + this->pts = 0; } @@ -165,7 +165,7 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { buf->size, INPUT_BUF_SIZE-this->bytes_in_buffer); buf->size = INPUT_BUF_SIZE-this->bytes_in_buffer; } - + if ((buf->decoder_flags & BUF_FLAG_HEADER) == 0) { /* reset decoder on leaving preview mode */ @@ -179,15 +179,15 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { bytes_in_buffer_at_pts = this->bytes_in_buffer; - xine_fast_memcpy (&this->buffer[this->bytes_in_buffer], + xine_fast_memcpy (&this->buffer[this->bytes_in_buffer], buf->content, buf->size); this->bytes_in_buffer += buf->size; - + /* printf ("libmad: decode data - doing it\n"); */ - mad_stream_buffer (&this->stream, this->buffer, + mad_stream_buffer (&this->stream, this->buffer, this->bytes_in_buffer); if (this->bytes_in_buffer < MAD_MIN_SIZE) @@ -211,7 +211,7 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if (this->stream.next_frame) { int num_bytes = this->buffer + this->bytes_in_buffer - this->stream.next_frame; - + /* printf("libmad: MAD_ERROR_BUFLEN\n"); */ memmove(this->buffer, this->stream.next_frame, num_bytes); @@ -225,16 +225,16 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->needs_more_data = 1; return; - default: + default: lprintf ("error 0x%04X, mad_stream_buffer %d bytes\n", this->stream.error, this->bytes_in_buffer); - mad_stream_buffer (&this->stream, this->buffer, + mad_stream_buffer (&this->stream, this->buffer, this->bytes_in_buffer); } } else { int mode = (this->frame.header.mode == MAD_MODE_SINGLE_CHANNEL) ? AO_CAP_MODE_MONO : AO_CAP_MODE_STEREO; - if (!this->output_open + if (!this->output_open || (this->output_sampling_rate != this->frame.header.samplerate) || (this->output_mode != mode)) { @@ -250,23 +250,23 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if (! _x_meta_info_get(this->xstream, XINE_META_INFO_AUDIOCODEC)) { switch (this->frame.header.layer) { case MAD_LAYER_I: - _x_meta_info_set_utf8(this->xstream, XINE_META_INFO_AUDIOCODEC, + _x_meta_info_set_utf8(this->xstream, XINE_META_INFO_AUDIOCODEC, "MPEG audio layer 1 (lib: MAD)"); break; case MAD_LAYER_II: - _x_meta_info_set_utf8(this->xstream, XINE_META_INFO_AUDIOCODEC, + _x_meta_info_set_utf8(this->xstream, XINE_META_INFO_AUDIOCODEC, "MPEG audio layer 2 (lib: MAD)"); break; case MAD_LAYER_III: - _x_meta_info_set_utf8(this->xstream, XINE_META_INFO_AUDIOCODEC, + _x_meta_info_set_utf8(this->xstream, XINE_META_INFO_AUDIOCODEC, "MPEG audio layer 3 (lib: MAD)"); break; default: - _x_meta_info_set_utf8(this->xstream, XINE_META_INFO_AUDIOCODEC, + _x_meta_info_set_utf8(this->xstream, XINE_META_INFO_AUDIOCODEC, "MPEG audio (lib: MAD)"); } } - + if (this->output_open) { this->xstream->audio_out->close (this->xstream->audio_out, this->xstream); this->output_open = 0; @@ -274,7 +274,7 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if (!this->output_open) { this->output_open = (this->xstream->audio_out->open) (this->xstream->audio_out, this->xstream, 16, - this->frame.header.samplerate, + this->frame.header.samplerate, mode) ; } if (!this->output_open) { @@ -287,7 +287,7 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { mad_synth_frame (&this->synth, &this->frame); if ( (buf->decoder_flags & BUF_FLAG_PREVIEW) == 0 ) { - + unsigned int nchannels, nsamples; mad_fixed_t const *left_ch, *right_ch; struct mad_pcm *pcm = &this->synth.pcm; @@ -323,10 +323,10 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { while (nsamples--) { /* output sample(s) in 16-bit signed little-endian PCM */ - + *output++ = scale(*left_ch++); - - if (nchannels == 2) + + if (nchannels == 2) *output++ = scale(*right_ch++); } @@ -371,13 +371,13 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { static void mad_dispose (audio_decoder_t *this_gen) { - mad_decoder_t *this = (mad_decoder_t *) this_gen; + mad_decoder_t *this = (mad_decoder_t *) this_gen; mad_synth_finish (&this->synth); mad_frame_finish (&this->frame); mad_stream_finish(&this->stream); - if (this->output_open) { + if (this->output_open) { this->xstream->audio_out->close (this->xstream->audio_out, this->xstream); this->output_open = 0; } @@ -408,7 +408,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre this->stream.options = MAD_OPTION_IGNORECRC; - lprintf ("init\n"); + lprintf ("init\n"); return &this->audio_decoder; } @@ -419,7 +419,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre static void *init_plugin (xine_t *xine, void *data) { mad_class_t *this; - + this = (mad_class_t *) calloc(1, sizeof(mad_class_t)); this->decoder_class.open_plugin = open_plugin; @@ -430,7 +430,7 @@ static void *init_plugin (xine_t *xine, void *data) { return this; } -static const uint32_t audio_types[] = { +static const uint32_t audio_types[] = { BUF_AUDIO_MPEG, 0 }; @@ -440,7 +440,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, 16, "mad", XINE_VERSION_CODE, &dec_info_audio, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/audio_dec/xine_musepack_decoder.c b/src/audio_dec/xine_musepack_decoder.c index 42ba64108..93991832a 100644 --- a/src/audio_dec/xine_musepack_decoder.c +++ b/src/audio_dec/xine_musepack_decoder.c @@ -88,10 +88,10 @@ typedef struct mpc_decoder_s { #else mpc_demux *decoder; #endif - + int decoder_ok; unsigned int current_frame; - + int32_t file_size; } mpc_decoder_t; @@ -100,26 +100,26 @@ typedef struct mpc_decoder_s { /************************************************************************** * musepack specific functions *************************************************************************/ - + /* Reads size bytes of data into buffer at ptr. */ static int32_t mpc_reader_read(void *const data, void *const ptr, int size) { mpc_decoder_t *const this = (mpc_decoder_t *) data; - + lprintf("mpc_reader_read: size=%d\n", size); - + /* Don't try to read more data than we have */ if (size > (this->size - this->read)) size = this->size - this->read; /* Copy the data */ xine_fast_memcpy(ptr, &this->buf[this->read], size); - + /* Update our position in the data buffer */ this->read += size; - + return size; } - + /* Seeks to byte position offset. */ #ifndef HAVE_MPC_MPCDEC_H static mpc_bool_t mpc_reader_seek(void *const data, const int32_t offset) { @@ -128,13 +128,13 @@ static mpc_bool_t mpc_reader_seek(void *const data, const int32_t offset) { static mpc_bool_t mpc_reader_seek(mpc_reader *data, int32_t offset) { mpc_decoder_t *const this = (mpc_decoder_t *) data->data; #endif - + lprintf("mpc_reader_seek: offset=%d\n", offset); - + /* seek is only called when reading the header so we can assume * that the buffer starts at the start of the file */ this->read = offset; - + #ifndef HAVE_MPC_MPCDEC_H return TRUE; #else @@ -149,7 +149,7 @@ static int32_t mpc_reader_tell(void *const data) { static int32_t mpc_reader_tell(mpc_reader *const data) { #endif lprintf("mpc_reader_tell\n"); - + /* Tell isn't used so just return 0 */ return 0; } @@ -162,9 +162,9 @@ static int32_t mpc_reader_get_size(void *const data) { static int32_t mpc_reader_get_size(mpc_reader *const data) { mpc_decoder_t *const this = (mpc_decoder_t *) data->data; #endif - + lprintf("mpc_reader_get_size\n"); - + return this->file_size; } @@ -172,7 +172,7 @@ static int32_t mpc_reader_get_size(mpc_reader *const data) { #ifndef HAVE_MPC_MPCDEC_H static mpc_bool_t mpc_reader_canseek(void *data) { lprintf("mpc_reader_canseek\n"); - + return TRUE; #else static mpc_bool_t mpc_reader_canseek(mpc_reader *data) { @@ -213,9 +213,9 @@ static int mpc_decode_frame (mpc_decoder_t *this) { #ifdef HAVE_MPC_MPCDEC_H mpc_frame_info frame; #endif - + lprintf("mpd_decode_frame\n"); - + #ifndef HAVE_MPC_MPCDEC_H frames = mpc_decoder_decode(&this->decoder, buffer, 0, 0); #else @@ -223,26 +223,26 @@ static int mpc_decode_frame (mpc_decoder_t *this) { mpc_demux_decode(this->decoder, &frame); frames = frame.samples; #endif - + if (frames > 0) { - audio_buffer_t *audio_buffer; + audio_buffer_t *audio_buffer; int16_t *int_samples; - + lprintf("got %d samples\n", frames); - + /* Get audio buffer */ audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); audio_buffer->vpts = 0; audio_buffer->num_frames = frames; - + /* Convert samples */ int_samples = (int16_t *) audio_buffer->mem; float_to_int(buffer, int_samples, frames*this->channels); - + /* Output converted samples */ this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream); } - + return frames; } @@ -255,28 +255,28 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { int err; lprintf("mpc_decode_data\n"); - + if (!_x_stream_info_get(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED)) return; - + /* We don't handle special buffers */ if (buf->decoder_flags & BUF_FLAG_SPECIAL) return; - + /* Read header */ if (buf->decoder_flags & BUF_FLAG_HEADER) { - + lprintf("header\n"); - + /* File size is in decoder_info[0] */ this->file_size = buf->decoder_info[0]; - + /* Initialise the data accumulation buffer */ this->buf = calloc(1, INIT_BUFSIZE); this->buf_max = INIT_BUFSIZE; this->read = 0; this->size = 0; - + /* Initialise the reader */ this->reader.read = mpc_reader_read; this->reader.seek = mpc_reader_seek; @@ -284,11 +284,11 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->reader.get_size = mpc_reader_get_size; this->reader.canseek = mpc_reader_canseek; this->reader.data = this; - + /* Copy header to buffer */ xine_fast_memcpy(this->buf, buf->content, buf->size); this->size = buf->size; - + #ifdef HAVE_MPC_MPCDEC_H this->decoder = mpc_demux_init(&this->reader); if (!this->decoder) { @@ -301,28 +301,28 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { #else /* Initialise and read stream info */ mpc_streaminfo_init(&this->streaminfo); - + if ((err = mpc_streaminfo_read(&this->streaminfo, &this->reader))) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("libmusepack: mpc_streaminfo_read failed: %d\n"), err); - + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0); return; } #endif - + this->sample_rate = this->streaminfo.sample_freq; this->channels = this->streaminfo.channels; this->bits_per_sample = 16; - + /* After the header the demuxer starts sending data from an offset * of 28 bytes */ this->size = 28; - + /* We need to keep track of the current frame so we now when we've * reached the end of the stream */ this->current_frame = 0; - + /* Setup the decoder */ #ifndef HAVE_MPC_MPCDEC_H mpc_decoder_setup(&this->decoder, &this->reader); @@ -330,16 +330,16 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->decoder_ok = 0; /* Take this opportunity to initialize stream/meta information */ - _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, + _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Musepack (libmusepack)"); - _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, (int) this->streaminfo.average_bitrate); return; } lprintf("data: %u size=%u read=%u\n", buf->size, this->size, this->read); - + /* if the audio output is not open yet, open the audio output */ if (!this->output_open) { this->output_open = (this->stream->audio_out->open) ( @@ -353,7 +353,7 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { /* if the audio still isn't open, do not go any further with the decode */ if (!this->output_open) return; - + /* If we run out of space in our internal buffer we discard what's * already been read */ if (((this->size + buf->size) > this->buf_max) && this->read) { @@ -362,7 +362,7 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { memmove(this->buf, &this->buf[this->read], this->size); this->read = 0; } - + /* If there still isn't space we have to increase the size of the * internal buffer */ if ((this->size + buf->size) > this->buf_max) { @@ -371,11 +371,11 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { this->buf_max += 2*buf->size; this->buf = realloc(this->buf, this->buf_max); } - + /* Copy data */ xine_fast_memcpy(&this->buf[this->size], buf->content, buf->size); this->size += buf->size; - + /* Time to decode */ if (buf->decoder_flags & BUF_FLAG_FRAME_END) { /* Increment frame count */ @@ -388,45 +388,45 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { _("libmusepack: data after last frame ignored\n")); return; } - + if (!this->decoder_ok) { /* We require MPC_DECODER_MEMSIZE bytes to initialise the decoder */ if ((this->size - this->read) >= MPC_DECODER_MEMSIZE) { lprintf("initialise"); - + #ifndef HAVE_MPC_MPCDEC_H if (!mpc_decoder_initialize(&this->decoder, &this->streaminfo)) { #else if (!this->decoder) { #endif xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - _("libmusepack: mpc_decoder_initialise failed\n")); - + _("libmusepack: mpc_decoder_initialise failed\n")); + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0); return; } - + this->decoder_ok = 1; } else { /* Not enough data yet */ return; } } - + /* mpc_decoder_decode may cause a read of MPC_DECODER_MEMSIZE/2 bytes so * make sure we have enough data available */ if ((this->size - this->read) >= MPC_DECODER_MEMSIZE2) { lprintf("decoding\n"); - + if ((err = mpc_decode_frame(this)) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - _("libmusepack: mpc_decoder_decode failed: %d\n"), err); - + _("libmusepack: mpc_decoder_decode failed: %d\n"), err); + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0); return; } } - + /* If we are at the end of the stream we decode the remaining frames as we * know we'll have enough data */ #ifndef HAVE_MPC_MPCDEC_H @@ -435,14 +435,14 @@ static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { if (this->current_frame == this->streaminfo.samples) { #endif lprintf("flushing buffers\n"); - + do { if ((err = mpc_decode_frame(this)) < 0) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("libmusepack: mpc_decoder_decode failed: %d\n"), err); } } while (err > 0); - + lprintf("buffers flushed\n"); } } @@ -474,7 +474,7 @@ static void mpc_dispose (audio_decoder_t *this_gen) { if (this->decoder) mpc_demux_exit(this->decoder); #endif - + free(this); } @@ -495,7 +495,7 @@ static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stre /* audio output is not open at the start */ this->output_open = 0; - + /* no buffer yet */ this->buf = NULL; @@ -522,7 +522,7 @@ static void *init_plugin (xine_t *xine, void *data) { return this; } -static const uint32_t audio_types[] = { +static const uint32_t audio_types[] = { BUF_AUDIO_MPC, 0 }; |