From 54999f68a60f0f814566babb2df0f9a18089d149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 4 Apr 2007 22:00:36 +0200 Subject: Move the linear pcm decoder from liblpcm to libxineadec, as it's a single file. --HG-- rename : src/liblpcm/xine_decoder.c => src/libxineadec/xine_lpcm_decoder.c --- configure.ac | 1 - src/Makefile.am | 1 - src/liblpcm/Makefile.am | 10 -- src/liblpcm/xine_decoder.c | 288 ------------------------------------ src/libxineadec/Makefile.am | 19 ++- src/libxineadec/xine_lpcm_decoder.c | 288 ++++++++++++++++++++++++++++++++++++ 6 files changed, 297 insertions(+), 310 deletions(-) delete mode 100644 src/liblpcm/Makefile.am delete mode 100644 src/liblpcm/xine_decoder.c create mode 100644 src/libxineadec/xine_lpcm_decoder.c diff --git a/configure.ac b/configure.ac index 17d477d5d..724b87ff4 100644 --- a/configure.ac +++ b/configure.ac @@ -2638,7 +2638,6 @@ src/libffmpeg/libavcodec/ppc/Makefile src/libffmpeg/libavcodec/sparc/Makefile src/libffmpeg/libavcodec/libpostproc/Makefile src/libffmpeg/libavutil/Makefile -src/liblpcm/Makefile src/libmad/Makefile src/libmpeg2/Makefile src/libmusepack/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index df8e2d462..90f51ee50 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,6 @@ SUBDIRS = \ libdts \ libmad \ libw32dll \ - liblpcm \ libxinevdec \ libxineadec \ libvorbis \ diff --git a/src/liblpcm/Makefile.am b/src/liblpcm/Makefile.am deleted file mode 100644 index e8527ee5c..000000000 --- a/src/liblpcm/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include $(top_srcdir)/misc/Makefile.common - -libdir = $(XINE_PLUGINDIR) - -lib_LTLIBRARIES = xineplug_decode_lpcm.la - -xineplug_decode_lpcm_la_SOURCES = xine_decoder.c -xineplug_decode_lpcm_la_LIBADD = $(XINE_LIB) -xineplug_decode_lpcm_la_CFLAGS = $(VISIBILITY_FLAG) -xineplug_decode_lpcm_la_LDFLAGS = -avoid-version -module diff --git a/src/liblpcm/xine_decoder.c b/src/liblpcm/xine_decoder.c deleted file mode 100644 index 43bea4cbf..000000000 --- a/src/liblpcm/xine_decoder.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * $Id: xine_decoder.c,v 1.62 2007/03/17 20:59:36 dgp85 Exp $ - * - * 31-8-2001 Added LPCM rate sensing. - * (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk - * - */ -#ifndef __sun -#define _XOPEN_SOURCE 500 -#endif -/* avoid compiler warnings */ -#define _BSD_SOURCE 1 - -#include -#include -#include -#include -#include -#include -#include /* ntohs */ - -#include "xine_internal.h" -#include "audio_out.h" -#include "buffer.h" - -#ifdef WIN32 -#include -/*#include */ /* htons */ -#endif - -typedef struct { - audio_decoder_class_t decoder_class; -} lpcm_class_t; - -typedef struct lpcm_decoder_s { - audio_decoder_t audio_decoder; - - xine_stream_t *stream; - - uint32_t rate; - 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; - -static void lpcm_reset (audio_decoder_t *this_gen) { - - /* lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; */ - -} - -static void lpcm_discontinuity (audio_decoder_t *this_gen) { -} - -static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { - - lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; - int16_t *sample_buffer=(int16_t *)buf->content; - int stream_be; - audio_buffer_t *audio_buffer; - int format_changed = 0; - - /* Drop preview data */ - if (buf->decoder_flags & BUF_FLAG_PREVIEW) - return; - - /* get config byte from mpeg2 stream */ - if ( (buf->decoder_flags & BUF_FLAG_SPECIAL) && - buf->decoder_info[1] == BUF_SPECIAL_LPCM_CONFIG ) { - 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; - case 1: sample_rate = 96000; break; - case 2: sample_rate = 44100; break; - case 3: sample_rate = 32000; break; - } - switch ((buf->decoder_info[2]>>6) & 3) { - case 0: bits_per_sample = 16; break; - 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 || - !this->output_open ) { - this->bits_per_sample = bits_per_sample; - 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] ; - format_changed++; - } - - /* - * (re-)open output device - */ - if ( format_changed ) { - if (this->output_open) - this->stream->audio_out->close (this->stream->audio_out, this->stream); - - this->ao_cap_mode=_x_ao_channels2mode(this->number_of_channels); - - /* force 24-bit samples into 16 bits for now */ - if (this->bits_per_sample == 24) - this->output_open = this->stream->audio_out->open (this->stream->audio_out, this->stream, - 16, - this->rate, - this->ao_cap_mode) ; - else - this->output_open = this->stream->audio_out->open (this->stream->audio_out, this->stream, - this->bits_per_sample, - this->rate, - this->ao_cap_mode) ; - - /* 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, - this->bits_per_sample * this->rate * this->number_of_channels); - } - - if (!this->output_open || (buf->decoder_flags & BUF_FLAG_HEADER) ) - return; - - audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); - - /* 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); - else - memcpy (audio_buffer->mem, sample_buffer, buf->size); - } - else if( this->bits_per_sample == 20 ) { - 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; - } - } else { - while( n >= 0 ) { - memcpy( d, s, 8 ); - s += 10; - d += 8; - n -= 10; - } - } - } else if( this->bits_per_sample == 24 ) { - uint8_t *s = (uint8_t *)sample_buffer; - uint8_t *d = (uint8_t *)audio_buffer->mem; - int n = buf->size; - - while (n >= 0) { - if ( stream_be ) { - *d++ = s[0]; - *d++ = s[1]; - } else { - *d++ = s[1]; - *d++ = s[2]; - } - - s += 3; - n -= 3; - } - } 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); - - this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream); - -} - -static void lpcm_dispose (audio_decoder_t *this_gen) { - lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; - - if (this->output_open) - this->stream->audio_out->close (this->stream->audio_out, this->stream); - this->output_open = 0; - - free (this_gen); -} - -static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) { - - lpcm_decoder_t *this ; - - this = (lpcm_decoder_t *) xine_xmalloc (sizeof (lpcm_decoder_t)); - - this->audio_decoder.decode_data = lpcm_decode_data; - this->audio_decoder.reset = lpcm_reset; - this->audio_decoder.discontinuity = lpcm_discontinuity; - this->audio_decoder.dispose = lpcm_dispose; - - this->output_open = 0; - this->rate = 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; -} - -static char *get_identifier (audio_decoder_class_t *this) { - return "Linear PCM"; -} - -static char *get_description (audio_decoder_class_t *this) { - return "Linear PCM audio decoder plugin"; -} - -static void dispose_class (audio_decoder_class_t *this) { - free (this); -} - -static void *init_plugin (xine_t *xine, void *data) { - - lpcm_class_t *this ; - - this = (lpcm_class_t *) xine_xmalloc (sizeof (lpcm_class_t)); - - this->decoder_class.open_plugin = open_plugin; - this->decoder_class.get_identifier = get_identifier; - this->decoder_class.get_description = get_description; - this->decoder_class.dispose = dispose_class; - - return this; -} - -static uint32_t audio_types[] = { - BUF_AUDIO_LPCM_BE, BUF_AUDIO_LPCM_LE, 0 -}; - -static const decoder_info_t dec_info_audio = { - audio_types, /* supported types */ - 1 /* priority */ -}; - -const plugin_info_t xine_plugin_info[] EXPORTED = { - /* 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 } -}; diff --git a/src/libxineadec/Makefile.am b/src/libxineadec/Makefile.am index 82011dfd0..373347aaa 100644 --- a/src/libxineadec/Makefile.am +++ b/src/libxineadec/Makefile.am @@ -4,22 +4,21 @@ EXTRA_DIST = fooaudio.c SUBDIRS = gsm610 nosefart +AM_LDFLAGS = $(xineplug_ldflags) + xineplug_LTLIBRARIES = \ xineplug_decode_gsm610.la \ - xineplug_decode_nsf.la + xineplug_decode_nsf.la \ + xineplug_decode_lpcm.la xineplug_decode_gsm610_la_SOURCES = gsm610.c xineplug_decode_gsm610_la_CFLAGS = $(VISIBILITY_FLAG) -xineplug_decode_gsm610_la_LDFLAGS = $(xineplug_ldflags) -xineplug_decode_gsm610_la_LIBADD = \ - $(XINE_LIB) \ - $(top_builddir)/src/libxineadec/gsm610/libgsm610.la +xineplug_decode_gsm610_la_LIBADD = $(XINE_LIB) gsm610/libgsm610.la xineplug_decode_nsf_la_SOURCES = nsf.c xineplug_decode_nsf_la_CFLAGS = $(VISIBILITY_FLAG) -DNSF_PLAYER -fno-strict-aliasing -xineplug_decode_nsf_la_LDFLAGS = $(xineplug_ldflags) -xineplug_decode_nsf_la_LIBADD = -lm \ - $(XINE_LIB) \ - $(top_builddir)/src/libxineadec/nosefart/libnosefart.la +xineplug_decode_nsf_la_LIBADD = $(XINE_LIB) -lm nosefart/libnosefart.la -# noinst_HEADERS = +xineplug_decode_lpcm_la_SOURCES = xine_lpcm_decoder.c +xineplug_decode_lpcm_la_CFLAGS = $(VISIBILITY_FLAG) +xineplug_decode_lpcm_la_LIBADD = $(XINE_LIB) diff --git a/src/libxineadec/xine_lpcm_decoder.c b/src/libxineadec/xine_lpcm_decoder.c new file mode 100644 index 000000000..43bea4cbf --- /dev/null +++ b/src/libxineadec/xine_lpcm_decoder.c @@ -0,0 +1,288 @@ +/* + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xine_decoder.c,v 1.62 2007/03/17 20:59:36 dgp85 Exp $ + * + * 31-8-2001 Added LPCM rate sensing. + * (c) 2001 James Courtier-Dutton James@superbug.demon.co.uk + * + */ +#ifndef __sun +#define _XOPEN_SOURCE 500 +#endif +/* avoid compiler warnings */ +#define _BSD_SOURCE 1 + +#include +#include +#include +#include +#include +#include +#include /* ntohs */ + +#include "xine_internal.h" +#include "audio_out.h" +#include "buffer.h" + +#ifdef WIN32 +#include +/*#include */ /* htons */ +#endif + +typedef struct { + audio_decoder_class_t decoder_class; +} lpcm_class_t; + +typedef struct lpcm_decoder_s { + audio_decoder_t audio_decoder; + + xine_stream_t *stream; + + uint32_t rate; + 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; + +static void lpcm_reset (audio_decoder_t *this_gen) { + + /* lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; */ + +} + +static void lpcm_discontinuity (audio_decoder_t *this_gen) { +} + +static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { + + lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; + int16_t *sample_buffer=(int16_t *)buf->content; + int stream_be; + audio_buffer_t *audio_buffer; + int format_changed = 0; + + /* Drop preview data */ + if (buf->decoder_flags & BUF_FLAG_PREVIEW) + return; + + /* get config byte from mpeg2 stream */ + if ( (buf->decoder_flags & BUF_FLAG_SPECIAL) && + buf->decoder_info[1] == BUF_SPECIAL_LPCM_CONFIG ) { + 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; + case 1: sample_rate = 96000; break; + case 2: sample_rate = 44100; break; + case 3: sample_rate = 32000; break; + } + switch ((buf->decoder_info[2]>>6) & 3) { + case 0: bits_per_sample = 16; break; + 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 || + !this->output_open ) { + this->bits_per_sample = bits_per_sample; + 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] ; + format_changed++; + } + + /* + * (re-)open output device + */ + if ( format_changed ) { + if (this->output_open) + this->stream->audio_out->close (this->stream->audio_out, this->stream); + + this->ao_cap_mode=_x_ao_channels2mode(this->number_of_channels); + + /* force 24-bit samples into 16 bits for now */ + if (this->bits_per_sample == 24) + this->output_open = this->stream->audio_out->open (this->stream->audio_out, this->stream, + 16, + this->rate, + this->ao_cap_mode) ; + else + this->output_open = this->stream->audio_out->open (this->stream->audio_out, this->stream, + this->bits_per_sample, + this->rate, + this->ao_cap_mode) ; + + /* 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, + this->bits_per_sample * this->rate * this->number_of_channels); + } + + if (!this->output_open || (buf->decoder_flags & BUF_FLAG_HEADER) ) + return; + + audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out); + + /* 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); + else + memcpy (audio_buffer->mem, sample_buffer, buf->size); + } + else if( this->bits_per_sample == 20 ) { + 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; + } + } else { + while( n >= 0 ) { + memcpy( d, s, 8 ); + s += 10; + d += 8; + n -= 10; + } + } + } else if( this->bits_per_sample == 24 ) { + uint8_t *s = (uint8_t *)sample_buffer; + uint8_t *d = (uint8_t *)audio_buffer->mem; + int n = buf->size; + + while (n >= 0) { + if ( stream_be ) { + *d++ = s[0]; + *d++ = s[1]; + } else { + *d++ = s[1]; + *d++ = s[2]; + } + + s += 3; + n -= 3; + } + } 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); + + this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream); + +} + +static void lpcm_dispose (audio_decoder_t *this_gen) { + lpcm_decoder_t *this = (lpcm_decoder_t *) this_gen; + + if (this->output_open) + this->stream->audio_out->close (this->stream->audio_out, this->stream); + this->output_open = 0; + + free (this_gen); +} + +static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) { + + lpcm_decoder_t *this ; + + this = (lpcm_decoder_t *) xine_xmalloc (sizeof (lpcm_decoder_t)); + + this->audio_decoder.decode_data = lpcm_decode_data; + this->audio_decoder.reset = lpcm_reset; + this->audio_decoder.discontinuity = lpcm_discontinuity; + this->audio_decoder.dispose = lpcm_dispose; + + this->output_open = 0; + this->rate = 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; +} + +static char *get_identifier (audio_decoder_class_t *this) { + return "Linear PCM"; +} + +static char *get_description (audio_decoder_class_t *this) { + return "Linear PCM audio decoder plugin"; +} + +static void dispose_class (audio_decoder_class_t *this) { + free (this); +} + +static void *init_plugin (xine_t *xine, void *data) { + + lpcm_class_t *this ; + + this = (lpcm_class_t *) xine_xmalloc (sizeof (lpcm_class_t)); + + this->decoder_class.open_plugin = open_plugin; + this->decoder_class.get_identifier = get_identifier; + this->decoder_class.get_description = get_description; + this->decoder_class.dispose = dispose_class; + + return this; +} + +static uint32_t audio_types[] = { + BUF_AUDIO_LPCM_BE, BUF_AUDIO_LPCM_LE, 0 +}; + +static const decoder_info_t dec_info_audio = { + audio_types, /* supported types */ + 1 /* priority */ +}; + +const plugin_info_t xine_plugin_info[] EXPORTED = { + /* 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 } +}; -- cgit v1.2.3