summaryrefslogtreecommitdiff
path: root/src/libmpg123
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmpg123')
-rw-r--r--src/libmpg123/Makefile.am37
-rw-r--r--src/libmpg123/interface.c30
-rw-r--r--src/libmpg123/layer1.c8
-rw-r--r--src/libmpg123/layer2.c10
-rw-r--r--src/libmpg123/layer3.c10
-rw-r--r--src/libmpg123/mpg123.h6
-rw-r--r--src/libmpg123/mpglib.h10
-rw-r--r--src/libmpg123/xine_decoder.c106
8 files changed, 174 insertions, 43 deletions
diff --git a/src/libmpg123/Makefile.am b/src/libmpg123/Makefile.am
index 854b992b1..04238af92 100644
--- a/src/libmpg123/Makefile.am
+++ b/src/libmpg123/Makefile.am
@@ -1,16 +1,41 @@
-CFLAGS = @BUILD_LIB_STATIC@ @GLOBAL_CFLAGS@
+CFLAGS = @GLOBAL_CFLAGS@
-EXTRA_DIST = main.c
+LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic
-noinst_LTLIBRARIES = libmpg123.la
+libdir = $(XINE_PLUGINDIR)
-libmpg123_la_SOURCES = common.c decode_i386.c layer1.c layer3.c tabinit.c \
- dct64_i386.c interface.c layer2.c
-libmpg123_la_LIBADD = -lm
+lib_LTLIBRARIES = xineplug_decode_mpg123.la
+xineplug_decode_mpg123_la_SOURCES = common.c decode_i386.c layer1.c layer3.c tabinit.c \
+ dct64_i386.c interface.c layer2.c xine_decoder.c
+xineplug_decode_mpg123_la_LDFLAGS = -avoid-version -module
noinst_HEADERS = huffman.h mpg123.h mpglib.h l2tables.h
+
+##
+## Install header files (default=$includedir/xine)
+##
+install-includeHEADERS: $(include_HEADERS)
+ @$(NORMAL_INSTALL)
+ $(mkinstalldirs) $(DESTDIR)$(includedir)/xine
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
+ echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/xine/$$p"; \
+ $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/xine/$$p; \
+ done
+
+
+##
+## Remove them
+##
+uninstall-includeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ list='$(include_HEADERS)'; for p in $$list; do \
+ rm -f $(DESTDIR)$(includedir)/xine/$$p; \
+ done
+
+
debug:
$(MAKE) CFLAGS="$(DEBUG_CFLAGS)"
diff --git a/src/libmpg123/interface.c b/src/libmpg123/interface.c
index f02bca63b..199c89479 100644
--- a/src/libmpg123/interface.c
+++ b/src/libmpg123/interface.c
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: interface.c,v 1.3 2001/05/06 16:56:01 guenter Exp $
+ * $Id: interface.c,v 1.4 2001/05/27 23:48:12 guenter Exp $
*/
#include <stdlib.h>
@@ -53,9 +53,17 @@ mpgaudio_t *mpg_audio_init (ao_functions_t *ao_output)
mp->ao_output = ao_output;
+ mpg_audio_reset (mp);
+
return mp;
}
+void mpg_audio_close (mpgaudio_t *mpg) {
+
+ free (mpg);
+
+}
+
int head_check(struct mpstr *mp)
{
if( (mp->header & 0xffe00000) != 0xffe00000)
@@ -69,16 +77,10 @@ int head_check(struct mpstr *mp)
return 1;
}
-void mpg_audio_decode_data (metronom_t *metronom,
- mpgaudio_t *mp, uint8_t *data, uint8_t *data_end,
+void mpg_audio_decode_data (mpgaudio_t *mp, uint8_t *data, uint8_t *data_end,
uint32_t pts)
{
- /* printf ("mpg123: decoding package\n"); */
-
- uint32_t pts_for_package = 0;
- /* pts = 0; */
-
while (1) {
/* sync */
if(mp->framesize == 0) {
@@ -103,12 +105,10 @@ void mpg_audio_decode_data (metronom_t *metronom,
mpg123_wordpointer = mp->bsspace[mp->bsnum] + 512;
mp->bsnum = (mp->bsnum + 1) & 0x1;
mpg123_bitindex = 0;
- pts_for_package = pts;
+ mp->pts = pts;
pts = 0;
}
-
- /* printf ("mpg123: copying data\n"); */
/* copy data to bsspace */
while (mp->bsize<mp->framesize) {
@@ -123,23 +123,21 @@ void mpg_audio_decode_data (metronom_t *metronom,
if(mp->fr.error_protection)
getbits(16);
- /* printf ("layer : %d\n",mp->fr.lay); */
switch(mp->fr.lay) {
case 1:
- do_layer1(metronom, mp, pts_for_package);
+ do_layer1(mp);
break;
case 2:
- do_layer2(metronom, mp, pts_for_package);
+ do_layer2(mp);
break;
case 3:
- do_layer3(metronom, mp, pts_for_package);
+ do_layer3(mp);
break;
}
mp->framesize_old = mp->framesize;
mp->framesize = 0;
mp->header = 0;
- pts_for_package = 0;
}
}
diff --git a/src/libmpg123/layer1.c b/src/libmpg123/layer1.c
index b10c938fd..4db905947 100644
--- a/src/libmpg123/layer1.c
+++ b/src/libmpg123/layer1.c
@@ -10,8 +10,6 @@
#include "mpg123.h"
-#include "metronom.h"
-
void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],struct frame *fr)
{
unsigned int *ba=balloc;
@@ -113,7 +111,7 @@ void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT],
}
}
-void do_layer1(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts)
+void do_layer1(mpgaudio_t *mp)
{
int clip=0;
struct frame *fr = &mp->fr;
@@ -159,7 +157,9 @@ void do_layer1(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts)
printf ("layer1\n");
}
- mp->ao_output->write_audio_data (mp->ao_output, (int16_t*)mp->osspace, num_bytes/(stereo-1 ? 4:2), pts);
+ mp->ao_output->write_audio_data (mp->ao_output, (int16_t*)mp->osspace, num_bytes/(stereo-1 ? 4:2),
+ mp->pts);
+ mp->pts = 0;
}
diff --git a/src/libmpg123/layer2.c b/src/libmpg123/layer2.c
index ee5a95cef..c4230ad5d 100644
--- a/src/libmpg123/layer2.c
+++ b/src/libmpg123/layer2.c
@@ -8,8 +8,6 @@
#include "mpg123.h"
#include "l2tables.h"
-#include "metronom.h"
-
static int grp_3tab[32 * 3] = { 0, }; /* used: 27 */
static int grp_5tab[128 * 3] = { 0, }; /* used: 125 */
static int grp_9tab[1024 * 3] = { 0, }; /* used: 729 */
@@ -249,7 +247,7 @@ static void II_select_table(struct frame *fr)
fr->II_sblimit = sblim;
}
-void do_layer2(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts)
+void do_layer2(mpgaudio_t *mp)
{
int clip=0;
int i,j;
@@ -295,11 +293,11 @@ void do_layer2(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts)
stereo-1 ? AO_CAP_MODE_STEREO: AO_CAP_MODE_MONO);
mp->is_output_initialized = 1;
mp->sample_rate_device = fr->sample_rate;
-
- printf ("layer2\n");
}
- mp->ao_output->write_audio_data (mp->ao_output, (int16_t*)mp->osspace, num_bytes/(stereo-1 ? 4:2), pts);
+ mp->ao_output->write_audio_data (mp->ao_output, (int16_t*)mp->osspace, num_bytes/(stereo-1 ? 4:2),
+ mp->pts);
+ mp->pts = 0;
}
diff --git a/src/libmpg123/layer3.c b/src/libmpg123/layer3.c
index 89b11776d..54eacdb01 100644
--- a/src/libmpg123/layer3.c
+++ b/src/libmpg123/layer3.c
@@ -10,8 +10,6 @@
#include "mpglib.h"
#include "huffman.h"
-#include "metronom.h"
-
#define MPEG1
@@ -1448,7 +1446,7 @@ static void III_hybrid(mpgaudio_t *mp,
/*
* main layer3 handler
*/
-void do_layer3(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts)
+void do_layer3(mpgaudio_t *mp)
{
int gr, ch, ss,clip=0;
struct frame *fr = &mp->fr;
@@ -1596,6 +1594,8 @@ void do_layer3(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts)
}
}
+ printf ("audio output...mp3\n");
+
if ((!mp->is_output_initialized) || (mp->sample_rate_device != fr->sample_rate)) {
if (mp->is_output_initialized)
@@ -1609,5 +1609,7 @@ void do_layer3(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts)
printf ("layer3\n");
}
- mp->ao_output->write_audio_data (mp->ao_output, (int16_t*)mp->osspace, num_bytes/(stereo-1 ? 4:2), pts);
+ mp->ao_output->write_audio_data (mp->ao_output, (int16_t*)mp->osspace, num_bytes/(stereo-1 ? 4:2),
+ mp->pts);
+ mp->pts = 0;
}
diff --git a/src/libmpg123/mpg123.h b/src/libmpg123/mpg123.h
index fc7709201..61166e85e 100644
--- a/src/libmpg123/mpg123.h
+++ b/src/libmpg123/mpg123.h
@@ -110,9 +110,9 @@ extern unsigned char *mpg123_wordpointer;
extern int mpg123_bitindex;
extern void make_decode_tables(long scaleval);
-extern void do_layer3(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts);
-extern void do_layer2(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts);
-extern void do_layer1(metronom_t *metronom, mpgaudio_t *mp, uint32_t pts);
+extern void do_layer3(mpgaudio_t *mp);
+extern void do_layer2(mpgaudio_t *mp);
+extern void do_layer1(mpgaudio_t *mp);
extern int decode_header(struct frame *fr,unsigned long newhead);
diff --git a/src/libmpg123/mpglib.h b/src/libmpg123/mpglib.h
index 961851235..94d412893 100644
--- a/src/libmpg123/mpglib.h
+++ b/src/libmpg123/mpglib.h
@@ -18,7 +18,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: mpglib.h,v 1.3 2001/05/06 16:56:01 guenter Exp $
+ * $Id: mpglib.h,v 1.4 2001/05/27 23:48:12 guenter Exp $
*/
#ifndef HAVE_MPGLIB_H
@@ -27,7 +27,6 @@
#include <inttypes.h>
#include "audio_out.h"
-#include "metronom.h"
typedef struct mpstr {
unsigned char bsspace[2][MAXFRAMESIZE+512]; /* MAXFRAMESIZE */
@@ -47,6 +46,8 @@ typedef struct mpstr {
int sample_rate_device;
ao_functions_t *ao_output;
unsigned char osspace[8192];
+
+ uint32_t pts;
} mpgaudio_t;
#ifndef BOOL
@@ -61,10 +62,11 @@ mpgaudio_t *mpg_audio_init (ao_functions_t *ao_output);
void mpg_audio_reset (mpgaudio_t *mp);
-void mpg_audio_decode_data (metronom_t *metronom,
- mpgaudio_t *mp, uint8_t *data, uint8_t *data_end,
+void mpg_audio_decode_data (mpgaudio_t *mp, uint8_t *data, uint8_t *data_end,
uint32_t pts);
+void mpg_audio_close (mpgaudio_t *mp);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/libmpg123/xine_decoder.c b/src/libmpg123/xine_decoder.c
new file mode 100644
index 000000000..8508dcd24
--- /dev/null
+++ b/src/libmpg123/xine_decoder.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2000-2001 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * $Id: xine_decoder.c,v 1.1 2001/05/27 23:48:12 guenter Exp $
+ *
+ * stuff needed to turn libmpg123 into a xine decoder plugin
+ */
+
+/*
+ * FIXME: libmpg123 uses global variables (that are written to)
+ */
+
+
+#include <stdlib.h>
+
+#include "audio_out.h"
+#include "mpg123.h"
+#include "mpglib.h"
+#include "buffer.h"
+#include "xine_internal.h"
+
+#define FRAME_SIZE 4096
+
+typedef struct mpgdec_decoder_s {
+ audio_decoder_t audio_decoder;
+
+ uint32_t pts;
+
+ mpgaudio_t *mpg;
+
+ ao_functions_t *audio_out;
+ int output_sampling_rate;
+ int output_open;
+
+} mpgdec_decoder_t;
+
+int mpgdec_can_handle (audio_decoder_t *this_gen, int buf_type) {
+ return ((buf_type & 0xFFFF0000) == BUF_AUDIO_MPEG) ;
+}
+
+
+void mpgdec_init (audio_decoder_t *this_gen, ao_functions_t *audio_out) {
+
+ mpgdec_decoder_t *this = (mpgdec_decoder_t *) this_gen;
+
+ this->audio_out = audio_out;
+ this->mpg = mpg_audio_init (audio_out);
+}
+
+void mpgdec_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
+
+ mpgdec_decoder_t *this = (mpgdec_decoder_t *) this_gen;
+
+ mpg_audio_decode_data (this->mpg, buf->content, buf->content + buf->size,
+ buf->PTS);
+}
+
+void mpgdec_close (audio_decoder_t *this_gen) {
+
+ mpgdec_decoder_t *this = (mpgdec_decoder_t *) this_gen;
+
+ mpg_audio_close (this->mpg);
+
+ if (this->output_open)
+ this->audio_out->close (this->audio_out);
+}
+
+static char *mpgdec_get_id(void) {
+ return "mpgdec";
+}
+
+audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *cfg) {
+
+ mpgdec_decoder_t *this ;
+
+ if (iface_version != 1)
+ return NULL;
+
+ this = (mpgdec_decoder_t *) malloc (sizeof (mpgdec_decoder_t));
+
+ this->audio_decoder.interface_version = 1;
+ this->audio_decoder.can_handle = mpgdec_can_handle;
+ this->audio_decoder.init = mpgdec_init;
+ this->audio_decoder.decode_data = mpgdec_decode_data;
+ this->audio_decoder.close = mpgdec_close;
+ this->audio_decoder.get_identifier = mpgdec_get_id;
+
+ return (audio_decoder_t *) this;
+}
+