summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-06-03 12:16:44 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-06-03 12:16:44 +0000
commitf4995ecac75dbaa2089aaf29db54cd1f83a2a836 (patch)
treeb3b70d822f24715483203d5d1923e57d2908b873
parent22d3c2d38b8d31826f0166b17bc2c631a369c9e4 (diff)
downloadxine-lib-f4995ecac75dbaa2089aaf29db54cd1f83a2a836.tar.gz
xine-lib-f4995ecac75dbaa2089aaf29db54cd1f83a2a836.tar.bz2
fixed mp3 playback
CVS patchset: 115 CVS date: 2001/06/03 12:16:44
-rw-r--r--src/demuxers/demux_mpgaudio.c206
-rw-r--r--src/libmpg123/layer3.c4
2 files changed, 7 insertions, 203 deletions
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index 9ddaa8d11..11f7eb6eb 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -17,7 +17,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: demux_mpgaudio.c,v 1.8 2001/05/30 02:09:24 f1rmb Exp $
+ * $Id: demux_mpgaudio.c,v 1.9 2001/06/03 12:16:44 guenter Exp $
*
* demultiplexer for mpeg audio (i.e. mp3) streams
*
@@ -38,9 +38,6 @@
#include "monitor.h"
#include "demux.h"
-#include "libmpg123/mpg123.h"
-#include "libmpg123/mpglib.h"
-
#define DEMUX_MPGAUDIO_IFACE_VERSION 1
typedef struct {
@@ -59,147 +56,6 @@ typedef struct {
static uint32_t xine_debug;
-/*
- * ***********************************************************************
- * Adds some (very slightly hacked) parts of libmpg123 here:
- * I don't want to link the lib to this demuxer.
- */
-static int ssize;
-static int grp_3tab[32 * 3] = {0,};
-static int grp_5tab[128 * 3] = {0,};
-static int grp_9tab[1024 * 3] = {0,};
-static real mpg123_muls[27][64];
-static int tabsel_123[2][3][16] = {
- {
- {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,},
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,},
- {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}},
-
- {
- {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,},
- {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}}
-};
-static long mpg123_freqs[9] = {
- 44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000
-};
-/*
- *
- */
-static void mpg123_init_layer2(void) {
- static double mulmul[27] = {
- 0.0, -2.0 / 3.0, 2.0 / 3.0,
- 2.0 / 7.0, 2.0 / 15.0, 2.0 / 31.0, 2.0 / 63.0, 2.0 / 127.0, 2.0 / 255.0,
- 2.0 / 511.0, 2.0 / 1023.0, 2.0 / 2047.0, 2.0 / 4095.0, 2.0 / 8191.0,
- 2.0 / 16383.0, 2.0 / 32767.0, 2.0 / 65535.0,
- -4.0 / 5.0, -2.0 / 5.0, 2.0 / 5.0, 4.0 / 5.0,
- -8.0 / 9.0, -4.0 / 9.0, -2.0 / 9.0, 2.0 / 9.0, 4.0 / 9.0, 8.0 / 9.0
- };
- static int base[3][9] = {
- {1, 0, 2,},
- {17, 18, 0, 19, 20,},
- {21, 1, 22, 23, 0, 24, 25, 2, 26}
- };
- int i, j, k, l, len;
- real *table;
- static int tablen[3] = { 3, 5, 9 };
- static int *itable, *tables[3] = { grp_3tab, grp_5tab, grp_9tab };
-
- for (i = 0; i < 3; i++) {
- itable = tables[i];
- len = tablen[i];
- for (j = 0; j < len; j++)
- for (k = 0; k < len; k++)
- for (l = 0; l < len; l++) {
- *itable++ = base[i][l];
- *itable++ = base[i][k];
- *itable++ = base[i][j];
- }
- }
-
- for (k = 0; k < 27; k++) {
- double m = mulmul[k];
-
- table = mpg123_muls[k];
- for (j = 3, i = 0; i < 63; i++, j--)
- *table++ = m * pow(2.0, (double) j / 3.0);
- *table++ = 0.0;
- }
-}
-/*
- *
- */
-static int mpg123_decode_header(struct frame *fr, unsigned long newhead) {
- if (newhead & (1 << 20)) {
- fr->lsf = (newhead & (1 << 19)) ? 0x0 : 0x1;
- fr->mpeg25 = 0;
- }
- else {
- fr->lsf = 1;
- fr->mpeg25 = 1;
- }
- fr->lay = 4 - ((newhead >> 17) & 3);
- if (fr->mpeg25) {
- fr->sampling_frequency = 6 + ((newhead >> 10) & 0x3);
- }
- else
- fr->sampling_frequency = ((newhead >> 10) & 0x3) + (fr->lsf * 3);
-
- fr->error_protection = ((newhead >> 16) & 0x1) ^ 0x1;
-
- if (fr->mpeg25)
- fr->bitrate_index = ((newhead >> 12) & 0xf);
-
- fr->bitrate_index = ((newhead >> 12) & 0xf);
- fr->padding = ((newhead >> 9) & 0x1);
- fr->extension = ((newhead >> 8) & 0x1);
- fr->mode = ((newhead >> 6) & 0x3);
- fr->mode_ext = ((newhead >> 4) & 0x3);
- fr->copyright = ((newhead >> 3) & 0x1);
- fr->original = ((newhead >> 2) & 0x1);
- fr->emphasis = newhead & 0x3;
-
- fr->stereo = (fr->mode == MPG_MD_MONO) ? 1 : 2;
-
- ssize = 0;
-
- if (!fr->bitrate_index)
- return (0);
-
- switch (fr->lay) {
- case 1:
- mpg123_init_layer2();
- fr->framesize = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
- fr->framesize /= mpg123_freqs[fr->sampling_frequency];
- fr->framesize = ((fr->framesize + fr->padding) << 2) - 4;
- break;
- case 2:
- mpg123_init_layer2();
- fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
- fr->framesize /= mpg123_freqs[fr->sampling_frequency];
- fr->framesize += fr->padding - 4;
- break;
- case 3:
- if (fr->lsf)
- ssize = (fr->stereo == 1) ? 9 : 17;
- else
- ssize = (fr->stereo == 1) ? 17 : 32;
- if (fr->error_protection)
- ssize += 2;
- fr->framesize = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
- fr->framesize /= mpg123_freqs[fr->sampling_frequency] << (fr->lsf);
- fr->framesize = fr->framesize + fr->padding - 4;
- break;
- default:
- return (0);
- }
- if(fr->framesize > MAXFRAMESIZE)
- return 0;
- return 1;
-}
-/*
- *
- */
static int mpg123_head_check(unsigned long head) {
if ((head & 0xffe00000) != 0xffe00000)
return 0;
@@ -220,10 +76,6 @@ static int mpg123_head_check(unsigned long head) {
return 1;
}
-/*
- * End of libmpg123 adds.
- ************************************************************************
- */
static int demux_mpgaudio_next (demux_mpgaudio_t *this) {
@@ -241,7 +93,7 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this) {
buf->DTS = 0;
buf->PTS = 0;
buf->input_pos = this->input->get_current_pos(this->input);
- buf->type = BUF_AUDIO_AVI;
+ buf->type = BUF_AUDIO_MPEG;
if(this->audio_fifo)
this->audio_fifo->put(this->audio_fifo, buf);
@@ -335,10 +187,7 @@ static int demux_mpgaudio_open(demux_plugin_t *this_gen,
case STAGE_BY_CONTENT: {
uint8_t buf[4096];
- uint8_t *pbuf;
- struct frame fr;
uint32_t head;
- int in_buf, i;
int bs = 0;
if(!input)
@@ -347,60 +196,19 @@ static int demux_mpgaudio_open(demux_plugin_t *this_gen,
if((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0) {
input->seek(input, 0, SEEK_SET);
- if(input->get_blocksize)
+ if (input->get_capabilities (input) & INPUT_CAP_BLOCK)
bs = input->get_blocksize(input);
- if(bs > 4)
- return DEMUX_CANNOT_HANDLE;
-
if(!bs)
bs = 4;
if(input->read(input, buf, bs)) {
- /* Not an AVI ?? */
- if(buf[0] || buf[1] || (buf[2] != 0x01) || (buf[3] != 0x46)) {
-
- pbuf = (uint8_t *) malloc(1024);
- head = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
-
- while(!mpg123_head_check(head)) {
-
- in_buf = input->read(input, pbuf, 1024);
-
- if(in_buf == 0) {
- free(pbuf);
- return DEMUX_CANNOT_HANDLE;
- }
-
- for(i = 0; i < in_buf; i++) {
- head <<= 8;
- head |= pbuf[i];
-
- if(mpg123_head_check(head)) {
- input->seek(input, i+1-in_buf, SEEK_CUR);
- break;
- }
- }
- }
- free(pbuf);
-
- if(mpg123_decode_header(&fr, head)) {
-
- if((input->seek(input, fr.framesize, SEEK_CUR)) <= 0)
- return DEMUX_CANNOT_HANDLE;
-
- if((input->read(input, buf, 4)) != 4)
- return DEMUX_CANNOT_HANDLE;
- }
-
- head = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
+ head = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3];
- if(mpg123_head_check(head) &&
- (((head >> 8) & 0x1) == 0x0) && (((head >> 6) & 0x3) == 0x1)) {
- this->input = input;
- return DEMUX_CAN_HANDLE;
- }
+ if (mpg123_head_check(head)) {
+ this->input = input;
+ return DEMUX_CAN_HANDLE;
}
}
}
diff --git a/src/libmpg123/layer3.c b/src/libmpg123/layer3.c
index 54eacdb01..d3673b57d 100644
--- a/src/libmpg123/layer3.c
+++ b/src/libmpg123/layer3.c
@@ -1594,8 +1594,6 @@ void do_layer3(mpgaudio_t *mp)
}
}
- printf ("audio output...mp3\n");
-
if ((!mp->is_output_initialized) || (mp->sample_rate_device != fr->sample_rate)) {
if (mp->is_output_initialized)
@@ -1605,8 +1603,6 @@ void do_layer3(mpgaudio_t *mp)
stereo-1 ? AO_CAP_MODE_STEREO: AO_CAP_MODE_MONO);
mp->is_output_initialized = 1;
mp->sample_rate_device = fr->sample_rate;
-
- printf ("layer3\n");
}
mp->ao_output->write_audio_data (mp->ao_output, (int16_t*)mp->osspace, num_bytes/(stereo-1 ? 4:2),