summaryrefslogtreecommitdiff
path: root/src/libxineadec
diff options
context:
space:
mode:
Diffstat (limited to 'src/libxineadec')
-rw-r--r--src/libxineadec/Makefile.am28
-rw-r--r--src/libxineadec/gsm610.c10
-rw-r--r--src/libxineadec/nosefart/diff_to_nosefart_cvs.patch42
-rw-r--r--src/libxineadec/nosefart/nsf.h4
-rw-r--r--src/libxineadec/nosefart/osd.h4
-rw-r--r--src/libxineadec/xine_dts_decoder.c592
-rw-r--r--src/libxineadec/xine_lpcm_decoder.c14
-rw-r--r--src/libxineadec/xine_musepack_decoder.c477
-rw-r--r--src/libxineadec/xine_vorbis_decoder.c4
9 files changed, 1156 insertions, 19 deletions
diff --git a/src/libxineadec/Makefile.am b/src/libxineadec/Makefile.am
index b2ffcf078..08d1df3dc 100644
--- a/src/libxineadec/Makefile.am
+++ b/src/libxineadec/Makefile.am
@@ -14,12 +14,28 @@ if HAVE_SPEEX
speex_module = xineplug_decode_speex.la
endif
+if MUSEPACK
+musepack_module = xineplug_decode_mpc.la
+endif
+
+if DTS
+dts_module = xineplug_decode_dts.la
+endif
+
+$(top_builddir)/contrib/libmpcdec/libmpcdec.la:
+ $(MAKE) -C $(top_builddir)/contrib/libmpcdec
+
+$(top_builddir)/contrib/libdca/libdca.la:
+ $(MAKE) -C $(top_builddir)/contrib/libdca
+
xineplug_LTLIBRARIES = \
xineplug_decode_gsm610.la \
xineplug_decode_nsf.la \
xineplug_decode_lpcm.la \
$(vorbis_module) \
- $(speex_module)
+ $(speex_module) \
+ $(musepack_module) \
+ $(dts_module)
xineplug_decode_gsm610_la_SOURCES = gsm610.c
xineplug_decode_gsm610_la_CFLAGS = $(VISIBILITY_FLAG)
@@ -40,3 +56,13 @@ xineplug_decode_vorbis_la_CFLAGS = $(VISIBILITY_FLAG) $(VORBIS_CFLAGS)
xineplug_decode_speex_la_SOURCES = xine_speex_decoder.c
xineplug_decode_speex_la_LIBADD = $(XINE_LIB) $(SPEEX_LIBS)
xineplug_decode_speex_la_CFLAGS = $(VISIBILITY_FLAGS) $(SPEEX_CFLAGS)
+
+xineplug_decode_mpc_la_SOURCES = xine_musepack_decoder.c
+xineplug_decode_mpc_la_CFLAGS = $(VISIBILITY_FLAG) $(MPCDEC_CFLAGS)
+xineplug_decode_mpc_la_DEPENDENCIES = $(MPCDEC_DEPS)
+xineplug_decode_mpc_la_LIBADD = $(XINE_LIB) $(MPCDEC_LIBS)
+
+xineplug_decode_dts_la_SOURCES = xine_dts_decoder.c
+xineplug_decode_dts_la_CFLAGS = $(LIBDTS_CFLAGS) $(VISIBILITY_FLAG)
+xineplug_decode_dts_la_DEPENDENCIES = $(LIBDTS_DEPS)
+xineplug_decode_dts_la_LIBADD = $(XINE_LIB) $(LIBDTS_LIBS)
diff --git a/src/libxineadec/gsm610.c b/src/libxineadec/gsm610.c
index 4f54714c9..9c96145e3 100644
--- a/src/libxineadec/gsm610.c
+++ b/src/libxineadec/gsm610.c
@@ -86,7 +86,6 @@ typedef struct gsm610_decoder_s {
int bufsize;
int size;
- unsigned short decode_buffer[GSM610_BLOCK_SIZE];
gsm gsm_state;
} gsm610_decoder_t;
@@ -138,6 +137,7 @@ static void gsm610_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
this->size += buf->size;
if (buf->decoder_flags & BUF_FLAG_FRAME_END) { /* time to decode a frame */
+ int16_t decode_buffer[GSM610_BLOCK_SIZE];
/* handle the Microsoft variant of GSM data */
if (this->buf_type == BUF_AUDIO_MSGSM) {
@@ -154,7 +154,7 @@ static void gsm610_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
in_ptr = 0;
while (this->size) {
- gsm_decode(this->gsm_state, &this->buf[in_ptr], this->decode_buffer);
+ gsm_decode(this->gsm_state, &this->buf[in_ptr], decode_buffer);
if ((in_ptr % 65) == 0) {
in_ptr += 33;
this->size -= 33;
@@ -167,7 +167,7 @@ static void gsm610_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
* always contain at least 160 samples */
audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- xine_fast_memcpy(audio_buffer->mem, this->decode_buffer,
+ xine_fast_memcpy(audio_buffer->mem, decode_buffer,
GSM610_BLOCK_SIZE * 2);
audio_buffer->num_frames = GSM610_BLOCK_SIZE;
@@ -189,7 +189,7 @@ static void gsm610_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
in_ptr = 0;
while (this->size) {
- gsm_decode(this->gsm_state, &this->buf[in_ptr], this->decode_buffer);
+ gsm_decode(this->gsm_state, &this->buf[in_ptr], decode_buffer);
in_ptr += 33;
this->size -= 33;
@@ -197,7 +197,7 @@ static void gsm610_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
* always contain at least 160 samples */
audio_buffer = this->stream->audio_out->get_buffer (this->stream->audio_out);
- xine_fast_memcpy(audio_buffer->mem, this->decode_buffer,
+ xine_fast_memcpy(audio_buffer->mem, decode_buffer,
GSM610_BLOCK_SIZE * 2);
audio_buffer->num_frames = GSM610_BLOCK_SIZE;
diff --git a/src/libxineadec/nosefart/diff_to_nosefart_cvs.patch b/src/libxineadec/nosefart/diff_to_nosefart_cvs.patch
index 280cd89cb..2b6202fb8 100644
--- a/src/libxineadec/nosefart/diff_to_nosefart_cvs.patch
+++ b/src/libxineadec/nosefart/diff_to_nosefart_cvs.patch
@@ -73,3 +73,45 @@ diff -u -p -r1.1.1.1 nes_apu.c
}
/* resync cycle counter */
+--- a/src/libxineadec/nosefart/nsf.h Tue Apr 10 13:42:00 2007 +0200
++++ b/src/libxineadec/nosefart/nsf.h Tue Apr 10 13:48:50 2007 +0200
+@@ -29,6 +29,8 @@
+ #include "osd.h"
+ #include "nes6502.h"
+ #include "nes_apu.h"
++
++#include "config.h"
+
+ #define NSF_MAGIC "NESM\x1A"
+
+@@ -96,7 +98,7 @@ typedef struct nsf_s
+
+ /* our main processing routine, calls all external mixing routines */
+ void (*process)(void *buffer, int num_samples);
+-} __PACKED__ nsf_t;
++} XINE_PACKED nsf_t;
+
+ /* Function prototypes */
+ extern void nsf_init(void);
+--- a/src/libxineadec/nosefart/osd.h Tue Apr 10 13:42:00 2007 +0200
++++ b/src/libxineadec/nosefart/osd.h Tue Apr 10 13:19:34 2007 +0200
+@@ -26,19 +26,15 @@
+ #ifndef _OSD_H_
+ #define _OSD_H_
+
+-
+ #if defined(__GNUC__) || defined(__ICC)
+-#define __PACKED__ __attribute__ ((packed))
+ #define PATH_SEP '/'
+ #ifdef __DJGPP__
+ #include <dpmi.h>
+ #include "dos_ints.h"
+ #endif
+ #elif defined(WIN32)
+-#define __PACKED__
+ #define PATH_SEP '\\'
+ #else /* crapintosh? */
+-#define __PACKED__
+ #define PATH_SEP ':'
+ #endif
+
diff --git a/src/libxineadec/nosefart/nsf.h b/src/libxineadec/nosefart/nsf.h
index 163e2f62f..79ec1dbb6 100644
--- a/src/libxineadec/nosefart/nsf.h
+++ b/src/libxineadec/nosefart/nsf.h
@@ -30,6 +30,8 @@
#include "nes6502.h"
#include "nes_apu.h"
+#include "config.h"
+
#define NSF_MAGIC "NESM\x1A"
#define NSF_DEDICATED_PAL 0x01
@@ -96,7 +98,7 @@ typedef struct nsf_s
/* our main processing routine, calls all external mixing routines */
void (*process)(void *buffer, int num_samples);
-} __PACKED__ nsf_t;
+} XINE_PACKED nsf_t;
/* Function prototypes */
extern void nsf_init(void);
diff --git a/src/libxineadec/nosefart/osd.h b/src/libxineadec/nosefart/osd.h
index ee90aa972..38b9480c7 100644
--- a/src/libxineadec/nosefart/osd.h
+++ b/src/libxineadec/nosefart/osd.h
@@ -26,19 +26,15 @@
#ifndef _OSD_H_
#define _OSD_H_
-
#if defined(__GNUC__) || defined(__ICC)
-#define __PACKED__ __attribute__ ((packed))
#define PATH_SEP '/'
#ifdef __DJGPP__
#include <dpmi.h>
#include "dos_ints.h"
#endif
#elif defined(WIN32)
-#define __PACKED__
#define PATH_SEP '\\'
#else /* crapintosh? */
-#define __PACKED__
#define PATH_SEP ':'
#endif
diff --git a/src/libxineadec/xine_dts_decoder.c b/src/libxineadec/xine_dts_decoder.c
new file mode 100644
index 000000000..000adaa85
--- /dev/null
+++ b/src/libxineadec/xine_dts_decoder.c
@@ -0,0 +1,592 @@
+/*
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/**
+ * @file
+ * @brief DTS decoder for xine
+ *
+ * @author Joachim Koenig (2001-09-04)
+ * @author James Courtier-Dutton (2001-12-09)
+ */
+
+#ifndef __sun
+/* required for swab() */
+#define _XOPEN_SOURCE 500
+#endif
+/* avoid compiler warnings */
+#define _BSD_SOURCE 1
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <assert.h>
+
+#define LOG_MODULE "libdts"
+#define LOG_VERBOSE
+/*
+#define LOG
+*/
+
+#include "xine_internal.h"
+#include "xineutils.h"
+#include "audio_out.h"
+#include "buffer.h"
+
+#include "bswap.h"
+
+#include <dts.h>
+
+#define MAX_AC5_FRAME 4096
+
+typedef struct {
+ audio_decoder_class_t decoder_class;
+} dts_class_t;
+
+typedef struct {
+ audio_decoder_t audio_decoder;
+
+ xine_stream_t *stream;
+ audio_decoder_class_t *class;
+
+ dts_state_t *dts_state;
+ int64_t pts;
+
+ int audio_caps;
+ int sync_state;
+ int ac5_length, ac5_pcm_length, frame_todo;
+ uint32_t syncdword;
+ uint8_t frame_buffer[MAX_AC5_FRAME];
+ uint8_t *frame_ptr;
+
+ int output_open;
+
+ int bypass_mode;
+ int dts_flags;
+ int dts_sample_rate;
+ int dts_bit_rate;
+ 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) {
+}
+
+static void dts_discontinuity (audio_decoder_t *const this_gen) {
+}
+
+/**
+ * @brief Convert a array of floating point samples into 16-bit signed integer samples
+ * @param f Floating point samples array (origin)
+ * @param s16 16-bit signed integer samples array (destination)
+ * @param num_channels Number of channels present in the stream
+ *
+ * @todo This same work is being done in many decoders to adapt the output of
+ * the decoder to what the audio output can actually use, this should be
+ * done by the audio_output loop, not by the decoders.
+ * @note This is subtly different from the function with the same name in xine_musepack_decoder.c
+ */
+static inline void float_to_int (const float *const _f, int16_t *const s16, const int num_channels) {
+ const int endidx = 256 * num_channels;
+ int i, j;
+
+ for (i = 0, j = 0; j < endidx; i++, j += num_channels) {
+ const float f = _f[i] * 32767;
+ if (f > INT16_MAX)
+ s16[j] = INT16_MAX;
+ else if (f < INT16_MIN)
+ s16[j] = INT16_MIN;
+ else
+ s16[j] = f;
+ /* printf("samples[%d] = %f, %d\n", i, _f[i], s16[num_channels*i]); */
+ }
+}
+
+static inline void mute_channel (int16_t *const s16, const int num_channels) {
+ const int endidx = 256 * num_channels;
+ int i;
+
+ for (i = 0; i < endidx; i += num_channels)
+ s16[i] = 0;
+}
+
+static void dts_decode_frame (dts_decoder_t *this, const int64_t pts, const int preview_mode) {
+
+ audio_buffer_t *audio_buffer;
+ uint32_t ac5_spdif_type=0;
+ 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;
+
+ if(this->bypass_mode) {
+ /* 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,
+ AO_CAP_MODE_AC5));
+ }
+
+ 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");
+ this->ac5_pcm_length = 0;
+ }
+
+ switch (this->ac5_pcm_length) {
+ case 512:
+ ac5_spdif_type = 0x0b; /* DTS-1 (512-sample bursts) */
+ break;
+ case 1024:
+ ac5_spdif_type = 0x0c; /* DTS-1 (1024-sample bursts) */
+ break;
+ case 2048:
+ ac5_spdif_type = 0x0d; /* DTS-1 (2048-sample bursts) */
+ break;
+ default:
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "libdts: DTS %i-sample bursts not supported\n", this->ac5_pcm_length);
+ return;
+ }
+
+#ifdef LOG_DEBUG
+ {
+ int i;
+ printf("libdts: DTS frame type=%d\n",data_in[4] >> 7);
+ printf("libdts: DTS deficit frame count=%d\n",(data_in[4] & 0x7f) >> 2);
+ printf("libdts: DTS AC5 PCM samples=%d\n",ac5_pcm_samples);
+ printf("libdts: DTS AC5 length=%d\n",this->ac5_length);
+ printf("libdts: DTS AC5 bitrate=%d\n",((data_in[8] & 0x03) << 4) | (data_in[8] >> 4));
+ printf("libdts: DTS AC5 spdif type=%d\n", ac5_spdif_type);
+
+ printf("libdts: ");
+ for(i=2000;i<2048;i++) {
+ printf("%02x ",data_in[i]);
+ }
+ printf("\n");
+ }
+#endif
+
+ lprintf("length=%d pts=%"PRId64"\n",this->ac5_pcm_length,audio_buffer->vpts);
+
+ audio_buffer->num_frames = this->ac5_pcm_length;
+
+ data_out[0] = 0x72; data_out[1] = 0xf8; /* spdif syncword */
+ data_out[2] = 0x1f; data_out[3] = 0x4e; /* .............. */
+ data_out[4] = ac5_spdif_type; /* DTS data */
+ data_out[5] = 0; /* Unknown */
+ data_out[6] = (this->ac5_length << 3) & 0xff; /* ac5_length * 8 */
+ data_out[7] = ((this->ac5_length ) >> 5) & 0xff;
+
+ if( this->ac5_pcm_length ) {
+ if( this->ac5_pcm_length % 2) {
+ swab(data_in, &data_out[8], this->ac5_length );
+ } else {
+ swab(data_in, &data_out[8], this->ac5_length + 1);
+ }
+ }
+ } else {
+ /* Software decode */
+ int i, dts_output_flags;
+ int16_t *const int_samples = audio_buffer->mem;
+ int number_of_dts_blocks;
+
+ level_t level = 1.0;
+ sample_t *samples;
+
+ dts_output_flags = this->dts_flags_map[this->dts_flags & DTS_CHANNEL_MASK];
+
+ if(dts_frame(this->dts_state, data_in, &dts_output_flags, &level, 0)) {
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "libdts: dts_frame error\n");
+ return;
+ }
+
+ this->have_lfe = dts_output_flags & DTS_LFE;
+ if (this->have_lfe)
+ if (this->audio_caps & AO_CAP_MODE_5_1CHANNEL) {
+ output_mode = AO_CAP_MODE_5_1CHANNEL;
+ } else if (this->audio_caps & AO_CAP_MODE_4_1CHANNEL) {
+ output_mode = AO_CAP_MODE_4_1CHANNEL;
+ } else {
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "libdts: WHAT DO I DO!!!\n");
+ output_mode = this->ao_flags_map[dts_output_flags & DTS_CHANNEL_MASK];
+ }
+ else
+ output_mode = this->ao_flags_map[dts_output_flags & DTS_CHANNEL_MASK];
+
+ if (!this->output_open) {
+ this->output_open = this->stream->audio_out->open (this->stream->audio_out, this->stream,
+ 16, this->dts_sample_rate,
+ output_mode);
+ }
+
+ if (!this->output_open)
+ return;
+ 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,
+ "libdts: dts_block error on audio channel %d\n", i);
+ audio_buffer->num_frames = 0;
+ break;
+ }
+
+ samples = dts_samples(this->dts_state);
+ switch (output_mode) {
+ case AO_CAP_MODE_MONO:
+ float_to_int (&samples[0], int_samples+(i*256), 1);
+ break;
+ case AO_CAP_MODE_STEREO:
+ /* Tested, working. */
+ float_to_int (&samples[0*256], int_samples+(i*256*2), 2); /* L */
+ float_to_int (&samples[1*256], int_samples+(i*256*2)+1, 2); /* R */
+ break;
+ case AO_CAP_MODE_4CHANNEL:
+ /* Tested, working */
+ float_to_int (&samples[0*256], int_samples+(i*256*4), 4); /* L */
+ float_to_int (&samples[1*256], int_samples+(i*256*4)+1, 4); /* R */
+ float_to_int (&samples[2*256], int_samples+(i*256*4)+2, 4); /* RL */
+ float_to_int (&samples[3*256], int_samples+(i*256*4)+3, 4); /* RR */
+ break;
+ case AO_CAP_MODE_4_1CHANNEL:
+ /* Tested, working */
+ float_to_int (&samples[0*256], int_samples+(i*256*6)+0, 6); /* L */
+ float_to_int (&samples[1*256], int_samples+(i*256*6)+1, 6); /* R */
+ float_to_int (&samples[2*256], int_samples+(i*256*6)+2, 6); /* RL */
+ float_to_int (&samples[3*256], int_samples+(i*256*6)+3, 6); /* RR */
+ float_to_int (&samples[4*256], int_samples+(i*256*6)+5, 6); /* LFE */
+ mute_channel ( int_samples+(i*256*6)+4, 6); /* C */
+ break;
+ case AO_CAP_MODE_5CHANNEL:
+ /* Tested, working */
+ float_to_int (&samples[0*256], int_samples+(i*256*6)+4, 6); /* C */
+ float_to_int (&samples[1*256], int_samples+(i*256*6)+0, 6); /* L */
+ float_to_int (&samples[2*256], int_samples+(i*256*6)+1, 6); /* R */
+ float_to_int (&samples[3*256], int_samples+(i*256*6)+2, 6); /* RL */
+ float_to_int (&samples[4*256], int_samples+(i*256*6)+3, 6); /* RR */
+ mute_channel ( int_samples+(i*256*6)+5, 6); /* LFE */
+ break;
+ case AO_CAP_MODE_5_1CHANNEL:
+ float_to_int (&samples[0*256], int_samples+(i*256*6)+4, 6); /* C */
+ float_to_int (&samples[1*256], int_samples+(i*256*6)+0, 6); /* L */
+ float_to_int (&samples[2*256], int_samples+(i*256*6)+1, 6); /* R */
+ float_to_int (&samples[3*256], int_samples+(i*256*6)+2, 6); /* RL */
+ float_to_int (&samples[4*256], int_samples+(i*256*6)+3, 6); /* RR */
+ float_to_int (&samples[5*256], int_samples+(i*256*6)+5, 6); /* LFE */ /* Not working yet */
+ break;
+ default:
+ xprintf (this->stream->xine, XINE_VERBOSITY_DEBUG, "libdts: help - unsupported mode %08x\n", output_mode);
+ }
+ }
+ }
+
+ 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) {
+
+ dts_decoder_t *const this = (dts_decoder_t *) this_gen;
+ 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)
+ return;
+ if (buf->decoder_flags & BUF_FLAG_STDHEADER)
+ return;
+
+ lprintf ("processing...state %d\n", this->sync_state);
+
+ while (current < end) {
+ switch (this->sync_state) {
+ case 0: /* Looking for sync header */
+ this->syncdword = (this->syncdword << 8) | *current++;
+/*
+ if ((this->syncdword == 0xff1f00e8) ||
+ (this->syncdword == 0x1fffe800) ||
+ (this->syncdword == 0xfe7f0180) ||
+ (this->syncdword == 0x7ffe8001) ) {
+*/
+
+ if ((this->syncdword == 0x7ffe8001) || (this->syncdword == 0xff1f00e8)) {
+ const uint32_t be_syncdword = be2me_32(this->syncdword);
+
+ lprintf ("sync found: syncdword=0x%x\n", this->syncdword);
+
+ memcpy(this->frame_buffer, &be_syncdword, sizeof(be_syncdword));
+
+ this->sync_state = 1;
+ this->frame_ptr = this->frame_buffer+4;
+ this->pts = buf->pts;
+ }
+ break;
+
+ case 1: /* Looking for enough bytes for sync_info. */
+ sync_start = current - 1;
+ *this->frame_ptr++ = *current++;
+ if ((this->frame_ptr - this->frame_buffer) > 19) {
+ const int old_dts_flags = this->dts_flags;
+ const int old_dts_sample_rate = this->dts_sample_rate;
+ const int old_dts_bit_rate = this->dts_bit_rate;
+
+ this->ac5_length = dts_syncinfo (this->dts_state, this->frame_buffer,
+ &this->dts_flags,
+ &this->dts_sample_rate,
+ &this->dts_bit_rate, &(this->ac5_pcm_length));
+ lprintf("ac5_length=%d\n",this->ac5_length);
+ lprintf("dts_sample_rate=%d\n",this->dts_sample_rate);
+
+ if ( (this->ac5_length < 80) || (this->ac5_length > MAX_AC5_FRAME) ) { /* Invalid dts ac5_pcm_length */
+ this->syncdword = 0;
+ current = sync_start;
+ this->sync_state = 0;
+ break;
+ }
+
+ lprintf("Frame length = %d\n",this->ac5_pcm_length);
+
+ this->frame_todo = this->ac5_length - 20;
+ this->sync_state = 2;
+ if (!_x_meta_info_get(this->stream, XINE_META_INFO_AUDIOCODEC) ||
+ old_dts_flags != this->dts_flags ||
+ old_dts_sample_rate != this->dts_sample_rate ||
+ old_dts_bit_rate != this->dts_bit_rate) {
+
+ switch (this->dts_flags & DTS_CHANNEL_MASK) {
+ case DTS_3F2R:
+ if (this->dts_flags & DTS_LFE)
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DTS 5.1");
+ else
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DTS 5.0");
+ break;
+ case DTS_3F1R:
+ case DTS_2F2R:
+ if (this->dts_flags & DTS_LFE)
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DTS 4.1");
+ else
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DTS 4.0");
+ break;
+ case DTS_2F1R:
+ case DTS_3F:
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DTS 3.0");
+ break;
+ case DTS_STEREO:
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DTS 2.0 (stereo)");
+ break;
+ case DTS_MONO:
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DTS 1.0");
+ break;
+ default:
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "DTS");
+ break;
+ }
+
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_BITRATE, this->dts_bit_rate);
+ _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_SAMPLERATE, this->dts_sample_rate);
+ }
+ }
+ 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);
+#else
+ dts_decode_frame (this, this->pts, buf->decoder_flags & BUF_FLAG_PREVIEW);
+#endif
+ case 4: /* Clear up ready for next frame */
+ this->pts = 0;
+ this->syncdword = 0;
+ this->sync_state = 0;
+ break;
+ 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)
+ this->stream->audio_out->close (this->stream->audio_out, this->stream);
+
+ free (this);
+}
+
+static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
+ dts_decoder_t *this ;
+
+ lprintf("open_plugin\n");
+
+ this = (dts_decoder_t *) xine_xmalloc (sizeof (dts_decoder_t));
+
+ this->audio_decoder.decode_data = dts_decode_data;
+ this->audio_decoder.reset = dts_reset;
+ this->audio_decoder.discontinuity = dts_discontinuity;
+ this->audio_decoder.dispose = dts_dispose;
+
+ this->dts_state = dts_init(0);
+ this->audio_caps = stream->audio_out->get_capabilities(stream->audio_out);
+ if(this->audio_caps & AO_CAP_MODE_AC5)
+ this->bypass_mode = 1;
+ else {
+ this->bypass_mode = 0;
+ /* FIXME: Leave "DOLBY pro logic" downmix out for now. */
+ this->dts_flags_map[DTS_MONO] = DTS_MONO;
+ this->dts_flags_map[DTS_STEREO] = DTS_STEREO;
+ this->dts_flags_map[DTS_3F] = DTS_STEREO;
+ this->dts_flags_map[DTS_2F1R] = DTS_STEREO;
+ this->dts_flags_map[DTS_3F1R] = DTS_STEREO;
+ this->dts_flags_map[DTS_2F2R] = DTS_STEREO;
+ this->dts_flags_map[DTS_3F2R] = DTS_STEREO;
+
+ this->ao_flags_map[DTS_MONO] = AO_CAP_MODE_MONO;
+ this->ao_flags_map[DTS_STEREO] = AO_CAP_MODE_STEREO;
+ this->ao_flags_map[DTS_3F] = AO_CAP_MODE_STEREO;
+ this->ao_flags_map[DTS_2F1R] = AO_CAP_MODE_STEREO;
+ this->ao_flags_map[DTS_3F1R] = AO_CAP_MODE_STEREO;
+ this->ao_flags_map[DTS_2F2R] = AO_CAP_MODE_STEREO;
+ this->ao_flags_map[DTS_3F2R] = AO_CAP_MODE_STEREO;
+
+ /* find best mode */
+ if (this->audio_caps & AO_CAP_MODE_5_1CHANNEL) {
+
+ this->dts_flags_map[DTS_2F2R] = DTS_2F2R;
+ 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;
+ this->dts_flags_map[DTS_3F2R] = DTS_3F2R;
+ 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_4_1CHANNEL) {
+
+ this->dts_flags_map[DTS_2F2R] = DTS_2F2R;
+ this->dts_flags_map[DTS_3F2R] = DTS_2F2R | DTS_LFE;
+ this->ao_flags_map[DTS_2F2R] = AO_CAP_MODE_4CHANNEL;
+ this->ao_flags_map[DTS_3F2R] = AO_CAP_MODE_4CHANNEL;
+
+ } else if (this->audio_caps & AO_CAP_MODE_4CHANNEL) {
+
+ this->dts_flags_map[DTS_2F2R] = DTS_2F2R;
+ this->dts_flags_map[DTS_3F2R] = DTS_2F2R;
+
+ this->ao_flags_map[DTS_2F2R] = AO_CAP_MODE_4CHANNEL;
+ this->ao_flags_map[DTS_3F2R] = AO_CAP_MODE_4CHANNEL;
+
+ /* else if (this->audio_caps & AO_CAP_MODE_STEREO)
+ defaults are ok */
+ } else if (!(this->audio_caps & AO_CAP_MODE_STEREO)) {
+ xprintf (this->stream->xine, XINE_VERBOSITY_LOG, _("HELP! a mono-only audio driver?!\n"));
+
+ this->dts_flags_map[DTS_MONO] = DTS_MONO;
+ this->dts_flags_map[DTS_STEREO] = DTS_MONO;
+ this->dts_flags_map[DTS_3F] = DTS_MONO;
+ this->dts_flags_map[DTS_2F1R] = DTS_MONO;
+ this->dts_flags_map[DTS_3F1R] = DTS_MONO;
+ this->dts_flags_map[DTS_2F2R] = DTS_MONO;
+ this->dts_flags_map[DTS_3F2R] = DTS_MONO;
+
+ this->ao_flags_map[DTS_MONO] = AO_CAP_MODE_MONO;
+ this->ao_flags_map[DTS_STEREO] = AO_CAP_MODE_MONO;
+ this->ao_flags_map[DTS_3F] = AO_CAP_MODE_MONO;
+ this->ao_flags_map[DTS_2F1R] = AO_CAP_MODE_MONO;
+ this->ao_flags_map[DTS_3F1R] = AO_CAP_MODE_MONO;
+ this->ao_flags_map[DTS_2F2R] = AO_CAP_MODE_MONO;
+ this->ao_flags_map[DTS_3F2R] = AO_CAP_MODE_MONO;
+ }
+ }
+ this->stream = stream;
+ this->class = class_gen;
+ this->output_open = 0;
+
+ return &this->audio_decoder;
+}
+
+static char *get_identifier (audio_decoder_class_t *this) {
+ return "DTS";
+}
+
+static char *get_description (audio_decoder_class_t *this) {
+ return "DTS passthru audio format decoder plugin";
+}
+
+static void dispose_class (audio_decoder_class_t *this) {
+ lprintf("dispose_class\n");
+
+ free (this);
+}
+
+static void *init_plugin (xine_t *xine, void *data) {
+ dts_class_t *this ;
+
+ lprintf("init_plugin\n");
+
+ this = (dts_class_t *) xine_xmalloc (sizeof (dts_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_DTS, 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, "dts", XINE_VERSION_CODE, &dec_info_audio, init_plugin },
+ { PLUGIN_NONE, 0, "", 0, NULL, NULL }
+};
diff --git a/src/libxineadec/xine_lpcm_decoder.c b/src/libxineadec/xine_lpcm_decoder.c
index 43bea4cbf..88256eb74 100644
--- a/src/libxineadec/xine_lpcm_decoder.c
+++ b/src/libxineadec/xine_lpcm_decoder.c
@@ -16,13 +16,15 @@
* 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
+ */
+
+/**
+ * @file
+ * @author James Courtier-Dutton <james@superbug.demon.co.uk>
*
- * $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
- *
+ * @date 2001-08-31 Added LPCM rate sensing
*/
+
#ifndef __sun
#define _XOPEN_SOURCE 500
#endif
@@ -61,7 +63,7 @@ typedef struct lpcm_decoder_s {
uint32_t ao_cap_mode;
int output_open;
- int cpu_be; /* TRUE, if we're a Big endian CPU */
+ int cpu_be; /**< TRUE, if we're a Big endian CPU */
} lpcm_decoder_t;
static void lpcm_reset (audio_decoder_t *this_gen) {
diff --git a/src/libxineadec/xine_musepack_decoder.c b/src/libxineadec/xine_musepack_decoder.c
new file mode 100644
index 000000000..51b2a9109
--- /dev/null
+++ b/src/libxineadec/xine_musepack_decoder.c
@@ -0,0 +1,477 @@
+/*
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/**
+ * @file
+ * @brief xine interface to libmusepack/libmpcdec
+ * @author James Stembridge <jstembridge@gmail.com>
+ *
+ * @todo Add support for 32-bit float samples.
+ * @todo Add support for seeking.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#define LOG_MODULE "mpc_decoder"
+#define LOG_VERBOSE
+/*
+#define LOG
+*/
+
+#include "xine_internal.h"
+#include "audio_out.h"
+#include "buffer.h"
+#include "xineutils.h"
+
+#include <mpcdec/mpcdec.h>
+
+#define MPC_DECODER_MEMSIZE 65536
+#define MPC_DECODER_MEMSIZE2 (MPC_DECODER_MEMSIZE/2)
+
+#define INIT_BUFSIZE (MPC_DECODER_MEMSIZE*2)
+
+typedef struct {
+ audio_decoder_class_t decoder_class;
+} mpc_class_t;
+
+typedef struct mpc_decoder_s {
+ audio_decoder_t audio_decoder;
+
+ xine_stream_t *stream;
+
+ int sample_rate; /* audio sample rate */
+ int bits_per_sample; /* bits/sample, usually 8 or 16 */
+ int channels; /* 1 or 2, usually */
+
+ int output_open; /* flag to indicate audio is ready */
+
+ unsigned char *buf; /* data accumulation buffer */
+ unsigned int buf_max; /* maximum size of buf */
+ unsigned int read; /* size of accum. data already read */
+ unsigned int size; /* size of accumulated data in buf */
+
+ mpc_reader reader;
+ mpc_streaminfo streaminfo;
+ mpc_decoder decoder;
+
+ int decoder_ok;
+ unsigned int current_frame;
+
+ int32_t file_size;
+
+} mpc_decoder_t;
+
+
+/**************************************************************************
+ * 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. */
+static mpc_bool_t mpc_reader_seek(void *const data, const int32_t offset) {
+ mpc_decoder_t *const this = (mpc_decoder_t *) data;
+
+ 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;
+
+ return TRUE;
+}
+
+/* Returns the current byte offset in the stream. */
+static int32_t mpc_reader_tell(void *const data) {
+ lprintf("mpc_reader_tell\n");
+
+ /* Tell isn't used so just return 0 */
+ return 0;
+}
+
+/* Returns the total length of the source stream, in bytes. */
+static int32_t mpc_reader_get_size(void *const data) {
+ mpc_decoder_t *const this = (const mpc_decoder_t *) data;
+
+ lprintf("mpc_reader_get_size\n");
+
+ return this->file_size;
+}
+
+/* True if the stream is a seekable stream. */
+static mpc_bool_t mpc_reader_canseek(void *data) {
+ lprintf("mpc_reader_canseek\n");
+
+ return TRUE;
+}
+
+/**
+ * @brief Convert a array of floating point samples into 16-bit signed integer samples
+ * @param f Floating point samples array (origin)
+ * @param s16 16-bit signed integer samples array (destination)
+ * @param samples Number of samples to convert
+ *
+ * @todo This same work is being done in many decoders to adapt the output of
+ * the decoder to what the audio output can actually use, this should be
+ * done by the audio_output loop, not by the decoders.
+ */
+static inline void float_to_int(const float *const _f, int16_t *const s16, const int samples) {
+ int i;
+ for (i = 0; i < samples; i++) {
+ const float f = _f[i] * 32767;
+ if (f > INT16_MAX)
+ s16[i] = INT16_MAX;
+ else if (f < INT16_MIN)
+ s16[i] = INT16_MIN;
+ else
+ s16[i] = f;
+ /* printf("samples[%d] = %f, %d\n", i, _f[i], s16[num_channels*i]); */
+ }
+}
+
+/* Decode a musepack frame */
+static int mpc_decode_frame (mpc_decoder_t *this) {
+ float buffer[MPC_DECODER_BUFFER_LENGTH];
+ uint32_t frames;
+
+ lprintf("mpd_decode_frame\n");
+
+ frames = mpc_decoder_decode(&this->decoder, buffer, 0, 0);
+
+ if (frames > 0) {
+ 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;
+}
+
+/**************************************************************************
+ * xine audio plugin functions
+ *************************************************************************/
+
+static void mpc_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
+ mpc_decoder_t *this = (mpc_decoder_t *) this_gen;
+ 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 = xine_xmalloc(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;
+ this->reader.tell = mpc_reader_tell;
+ 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;
+
+ /* 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;
+ }
+
+ 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 */
+ mpc_decoder_setup(&this->decoder, &this->reader);
+ this->decoder_ok = 0;
+
+ /* Take this opportunity to initialize stream/meta information */
+ _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC,
+ "Musepack (libmusepack)");
+ _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(
+ this->stream->audio_out,
+ this->stream,
+ this->bits_per_sample,
+ this->sample_rate,
+ _x_ao_channels2mode(this->channels));
+ }
+
+ /* 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) {
+ lprintf("discarding read data\n");
+ this->size -= this->read;
+ 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) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG,
+ "libmusepack: increasing internal buffer size\n");
+ 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 */
+ if (this->current_frame++ == this->streaminfo.frames) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ _("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");
+
+ if (!mpc_decoder_initialize(&this->decoder, &this->streaminfo)) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ _("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);
+
+ _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 */
+ if (this->current_frame == this->streaminfo.frames) {
+ 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");
+ }
+ }
+}
+
+static void mpc_reset (audio_decoder_t *this_gen) {
+ mpc_decoder_t *this = (mpc_decoder_t *) this_gen;
+
+ this->size = 0;
+ this->read = 0;
+}
+
+static void mpc_discontinuity (audio_decoder_t *this_gen) {
+ /* mpc_decoder_t *this = (mpc_decoder_t *) this_gen; */
+}
+
+static void mpc_dispose (audio_decoder_t *this_gen) {
+
+ mpc_decoder_t *this = (mpc_decoder_t *) this_gen;
+
+ /* close the audio output */
+ if (this->output_open)
+ this->stream->audio_out->close (this->stream->audio_out, this->stream);
+
+ /* free anything that was allocated during operation */
+ free(this->buf);
+
+ free(this);
+}
+
+static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) {
+
+ mpc_decoder_t *this ;
+
+ this = (mpc_decoder_t *) xine_xmalloc (sizeof (mpc_decoder_t));
+
+ /* connect the member functions */
+ this->audio_decoder.decode_data = mpc_decode_data;
+ this->audio_decoder.reset = mpc_reset;
+ this->audio_decoder.discontinuity = mpc_discontinuity;
+ this->audio_decoder.dispose = mpc_dispose;
+
+ /* connect the stream */
+ this->stream = stream;
+
+ /* audio output is not open at the start */
+ this->output_open = 0;
+
+ /* no buffer yet */
+ this->buf = NULL;
+
+ /* initialize the basic audio parameters */
+ this->channels = 0;
+ this->sample_rate = 0;
+ this->bits_per_sample = 0;
+
+ /* return the newly-initialized audio decoder */
+ return &this->audio_decoder;
+}
+
+static char *get_identifier (audio_decoder_class_t *this) {
+ return "mpc";
+}
+
+static char *get_description (audio_decoder_class_t *this) {
+ return "mpc: musepack audio decoder plugin";
+}
+
+static void dispose_class (audio_decoder_class_t *this_gen) {
+
+ mpc_class_t *this = (mpc_class_t *)this_gen;
+
+ free (this);
+}
+
+static void *init_plugin (xine_t *xine, void *data) {
+
+ mpc_class_t *this ;
+
+ this = (mpc_class_t *) xine_xmalloc (sizeof (mpc_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_MPC,
+ 0
+};
+
+static const decoder_info_t dec_info_audio = {
+ audio_types, /* supported types */
+ 5 /* priority */
+};
+
+const plugin_info_t xine_plugin_info[] EXPORTED = {
+ /* { type, API version, "name", version, special_info, init_function }, */
+ { PLUGIN_AUDIO_DECODER, 15, "mpc", XINE_VERSION_CODE, &dec_info_audio, &init_plugin },
+ { PLUGIN_NONE, 0, "", 0, NULL, NULL }
+};
+
diff --git a/src/libxineadec/xine_vorbis_decoder.c b/src/libxineadec/xine_vorbis_decoder.c
index ef8575949..7fc1b9197 100644
--- a/src/libxineadec/xine_vorbis_decoder.c
+++ b/src/libxineadec/xine_vorbis_decoder.c
@@ -91,8 +91,8 @@ static void vorbis_discontinuity (audio_decoder_t *this_gen) {
}
/* Known vorbis comment keys from ogg123 sources*/
-static struct {
- char *key; /* includes the '=' for programming convenience */
+static const struct {
+ const char *key; /* includes the '=' for programming convenience */
int xine_metainfo_index;
} vorbis_comment_keys[] = {
{"ARTIST=", XINE_META_INFO_ARTIST},