[MPlayer-dev-eng] [PATCH] Preliminary musepack support
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Jul 3 15:43:44 CEST 2005
Hi,
the last version, it works nice for me...
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.325
diff -u -r1.325 Makefile
--- Makefile 27 Jun 2005 20:08:38 -0000 1.325
+++ Makefile 3 Jul 2005 13:24:40 -0000
@@ -94,6 +94,7 @@
$(ALSA_LIB) \
$(XMMS_LIB) \
$(X264_LIB) \
+ $(MUSEPACK_LIB) \
COMMON_LIBS = libmpcodecs/libmpcodecs.a \
$(W32_LIB) \
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.1026
diff -u -r1.1026 configure
--- configure 26 Jun 2005 17:32:59 -0000 1.1026
+++ configure 3 Jul 2005 13:25:03 -0000
@@ -233,6 +233,7 @@
--disable-liba52 disable builtin liba52 [enabled]
--enable-libdts enable libdts support [autodetect]
--disable-libmpeg2 disable builtin libmpeg2 [enabled]
+ --disable-musepack disable musepack support [autodetect]
--disable-amr_nb disable amr narrowband, floating point [autodetect]
--disable-amr_nb-fixed disable amr narrowband, fixed point [autodetect]
--disable-amr_wb disable amr wideband, floating point [autodetect]
@@ -1476,6 +1477,7 @@
_inet6=auto
_gethostbyname2=auto
_ftp=yes
+_musepack=auto
_vstream=auto
_pthreads=yes
for ac_option do
@@ -1595,6 +1597,8 @@
--disable-libdts) _libdts=no ;;
--enable-libmpeg2) _libmpeg2=yes ;;
--disable-libmpeg2) _libmpeg2=no ;;
+ --enable-musepack) _musepack=yes ;;
+ --disable-musepack) _musepack=no ;;
--enable-internal-matroska) _matroska_internal=yes ;;
--disable-internal-matroska) _matroska_internal=no ;;
--enable-internal-faad) _faad_internal=yes _faad_external=no ;;
@@ -5446,6 +5450,30 @@
fi
echores "$_libmpeg2"
+echocheck "patched libmpcdec"
+if test "$_musepack" = auto ; then
+ _musepack=no
+ cat > $TMPC << EOF
+#include <mpcdec/mpcdec.h>
+int main(void) {
+ mpc_streaminfo info;
+ mpc_decoder decoder;
+ mpc_decoder_set_streaminfo(&decoder, &info);
+ mpc_decoder_decode_frame(&decoder, NULL, 0, NULL);
+}
+EOF
+ cc_check -lmpcdec $_ld_lm && _musepack=yes
+fi
+if test "$_musepack" = yes ; then
+ _def_musepack='#define HAVE_MUSEPACK 1'
+ _ld_musepack='-lmpcdec'
+ _codecmodules="musepack $_codecmodules"
+else
+ _def_musepack='#undef HAVE_MUSEPACK'
+ _nocodecmodules="musepack $_nocodecmodules"
+fi
+echores "$_musepack"
+
echocheck "Matroska support"
if test "$_matroska_internal" = yes ; then
@@ -6908,6 +6936,8 @@
TREMOR = $_tremor_internal
TREMOR_FLAGS = $_tremor_flags
+MUSEPACK = $_musepack
+
UNRARLIB = $_unrarlib
HAVE_FFPOSTPROCESS = $_def_haveffpostprocess
PNG = $_mkf_png
@@ -7028,6 +7058,7 @@
TOOLAME_LIB=$_toolame_lib
TWOLAME=$_twolame
TWOLAME_LIB=$_twolame_lib
+MUSEPACK_LIB = $_ld_musepack
FAAC=$_faac
FAAC_LIB=$_ld_faac
AMR_NB=$_amr_nb
@@ -7568,6 +7599,9 @@
/* enable Tremor as vorbis decoder */
$_def_tremor
+/* enable musepack support */
+$_def_musepack
+
/* enable OggTheora support */
$_def_theora
Index: etc/codecs.conf
===================================================================
RCS file: /cvsroot/mplayer/main/etc/codecs.conf,v
retrieving revision 1.418
diff -u -r1.418 codecs.conf
--- etc/codecs.conf 30 Jun 2005 17:37:10 -0000 1.418
+++ etc/codecs.conf 3 Jul 2005 13:25:10 -0000
@@ -2464,6 +2494,13 @@
driver ffmpeg
dll "dts"
+audiocodec musepack
+ info "MPC/MpegPlus audio codec"
+ status working
+ fourcc "MPC "
+ format 0x60
+ driver libmusepack
+
audiocodec ffamrnb
info "AMR Narrowband"
status working
Index: libmpcodecs/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/Makefile,v
retrieving revision 1.144
diff -u -r1.144 Makefile
--- libmpcodecs/Makefile 19 Jun 2005 22:52:55 -0000 1.144
+++ libmpcodecs/Makefile 3 Jul 2005 13:25:43 -0000
@@ -186,6 +186,10 @@
ENCODER_SRCS += ae_lavc.c
endif
+ifeq ($(MUSEPACK),yes)
+AUDIO_SRCS += ad_mpc.c
+endif
+
ifeq ($(FAAC),yes)
ENCODER_SRCS += ae_faac.c
endif
Index: libmpcodecs/ad.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad.c,v
retrieving revision 1.20
diff -u -r1.20 ad.c
--- libmpcodecs/ad.c 29 Dec 2004 19:51:56 -0000 1.20
+++ libmpcodecs/ad.c 3 Jul 2005 13:25:43 -0000
@@ -39,6 +39,7 @@
extern ad_functions_t mpcodecs_ad_qtaudio;
extern ad_functions_t mpcodecs_ad_ra1428;
extern ad_functions_t mpcodecs_ad_twin;
+extern ad_functions_t mpcodecs_ad_libmusepack;
ad_functions_t* mpcodecs_ad_drivers[] =
{
@@ -87,5 +88,8 @@
&mpcodecs_ad_libdv,
#endif
&mpcodecs_ad_ra1428,
+#ifdef HAVE_MUSEPACK
+ &mpcodecs_ad_libmusepack,
+#endif
NULL
};
Index: libmpcodecs/ad_mpc.c
===================================================================
RCS file: libmpcodecs/ad_mpc.c
diff -N libmpcodecs/ad_mpc.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libmpcodecs/ad_mpc.c 3 Jul 2005 13:25:44 -0000
@@ -0,0 +1,178 @@
+/**
+ * Musepack audio files decoder for MPlayer
+ * by Reza Jelveh <reza.jelveh at tuhh.de> and
+ * Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>
+ * License: GPL
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "ad_internal.h"
+#include "../libaf/af_format.h"
+#include "../libvo/fastmemcpy.h"
+
+static ad_info_t info =
+{
+ "MPC/MPEGPlus audio decoder",
+ "libmusepack",
+ "Reza Jelveh and Reimar Döffinger",
+ "",
+ ""
+};
+
+LIBAD_EXTERN(libmusepack)
+
+#include <mpcdec/mpcdec.h>
+
+#define MAX_FRAMESIZE MPC_DECODER_BUFFER_LENGTH
+
+typedef struct context_s {
+ char *header;
+ int header_len;
+ sh_audio_t *sh;
+ uint32_t pos;
+ mpc_decoder decoder;
+} context_t;
+
+/**
+ * \brief mpc_reader callback function for reading the header
+ */
+static mpc_int32_t cb_read(void *data, void *buf, mpc_int32_t size) {
+ context_t *d = (context_t *)data;
+ char *p = (char *)buf;
+ int s = size;
+ if (d->pos < d->header_len) {
+ if (s > d->header_len - d->pos)
+ s = d->header_len - d->pos;
+ memcpy(p, &d->header[d->pos], s);
+ } else
+ s = 0;
+ memset(&p[s], 0, size - s);
+ d->pos += size;
+ return size;
+}
+
+/**
+ * \brief dummy mpc_reader callback function for seeking
+ */
+static mpc_bool_t cb_seek(void *data, mpc_int32_t offset ) {
+ context_t *d = (context_t *)data;
+ d->pos = offset;
+ return 1;
+}
+
+/**
+ * \brief dummy mpc_reader callback function for getting stream position
+ */
+static mpc_int32_t cb_tell(void *data) {
+ context_t *d = (context_t *)data;
+ return d->pos;
+}
+
+/**
+ * \brief dummy mpc_reader callback function for getting stream length
+ */
+static mpc_int32_t cb_get_size(void *data) {
+ return 1 << 30;
+}
+
+/**
+ * \brief mpc_reader callback function, we cannot seek.
+ */
+static mpc_bool_t cb_canseek(void *data) {
+ return 0;
+}
+
+
+mpc_reader header_reader = {
+ .read = cb_read, .seek = cb_seek, .tell = cb_tell,
+ .get_size = cb_get_size, .canseek = cb_canseek
+};
+
+static int preinit(sh_audio_t *sh) {
+// sh->audio_out_minsize = 2 * MPC_DECODER_BUFFER_LENGTH;
+ return 1;
+}
+
+static void uninit(sh_audio_t *sh) {
+ if (sh->context)
+ free(sh->context);
+}
+
+static int init(sh_audio_t *sh) {
+ mpc_streaminfo info;
+ context_t *cd = malloc(sizeof(context_t));
+
+ if (!sh->wf || (sh->wf->cbSize < 6 * 4)) {
+ mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Missing extradata!\n");
+ return 0;
+ }
+ cd->header = (char *)sh->wf;
+ cd->header = &cd->header[sizeof(WAVEFORMATEX)];
+ cd->header_len = sh->wf->cbSize;
+ cd->sh = sh;
+ cd->pos = 0;
+ sh->context = (char *)cd;
+
+ /* read file's streaminfo data */
+ mpc_streaminfo_init(&info);
+ header_reader.data = cd;
+ if (mpc_streaminfo_read(&info, &header_reader) != ERROR_CODE_OK) {
+ mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Not a valid musepack file.\n");
+ return 0;
+ }
+ sh->i_bps = info.average_bitrate / 8;
+ sh->channels = info.channels;
+ sh->samplerate = info.sample_freq;
+ sh->samplesize = 4;
+ sh->sample_format =
+#if MPC_SAMPLE_FORMAT == float
+ AF_FORMAT_FLOAT_NE;
+#elif MPC_SAMPLE_FORMAT == mpc_int32_t
+ AF_FORMAT_S32_NE;
+#else
+ #error musepack lib must use either float or mpc_int32_t sample format
+#endif
+
+ mpc_decoder_setup(&cd->decoder, NULL);
+ mpc_decoder_set_streaminfo(&cd->decoder, &info);
+ return 1;
+}
+
+// FIXME: minlen is currently ignored
+static int decode_audio(sh_audio_t *sh, unsigned char *buf,
+ int minlen, int maxlen) {
+ int status, len;
+ MPC_SAMPLE_FORMAT *sample_buffer = (MPC_SAMPLE_FORMAT *)buf;
+ mpc_uint32_t *packet = NULL;
+
+ context_t *cd = (context_t *) sh->context;
+ if (maxlen < MPC_DECODER_BUFFER_LENGTH) {
+ mp_msg(MSGT_DECAUDIO, MSGL_ERR, "maxlen too small in decode_audio\n");
+ return -1;
+ }
+ len = ds_get_packet(sh->ds, (unsigned char **)&packet);
+ if (len <= 0) return -1;
+ status = mpc_decoder_decode_frame(&cd->decoder, packet, len, sample_buffer);
+ if (status == -1) // decode error
+ mp_msg(MSGT_DECAUDIO, MSGL_FATAL, "Error decoding file.\n");
+ if (status <= 0) // error or EOF
+ return -1;
+
+ status = MPC_FRAME_LENGTH * sh->channels; // one sample per channel
+#if MPC_SAMPLE_FORMAT == float || MPC_SAMPLE_FORMAT == mpc_int32_t
+ status *= 4;
+#else
+ // should not happen
+ status *= 2;
+#endif
+ return status;
+}
+
+static int control(sh_audio_t *sh, int cmd, void* arg, ...) {
+ return CONTROL_UNKNOWN;
+}
+
Index: libmpdemux/Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.94
diff -u -r1.94 Makefile
--- libmpdemux/Makefile 19 Jun 2005 22:52:55 -0000 1.94
+++ libmpdemux/Makefile 3 Jul 2005 13:25:45 -0000
@@ -69,6 +69,7 @@
demux_lmlm4.c \
demux_mf.c \
demux_mov.c \
+ demux_mpc.c \
demux_mpg.c \
demux_nsv.c \
demux_nuv.c \
Index: libmpdemux/demux_mpc.c
===================================================================
RCS file: libmpdemux/demux_mpc.c
diff -N libmpdemux/demux_mpc.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libmpdemux/demux_mpc.c 3 Jul 2005 13:25:46 -0000
@@ -0,0 +1,145 @@
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "mp_msg.h"
+#include "bswap.h"
+#include "stream.h"
+#include "demuxer.h"
+#include "stheader.h"
+
+
+#define HDR_SIZE (6 * 4)
+
+typedef struct da_priv {
+ float last_pts;
+ uint32_t dword;
+ int pos;
+} da_priv_t;
+
+extern void free_sh_audio(sh_audio_t* sh);
+
+static uint32_t get_bits(da_priv_t* priv, stream_t* s, int bits) {
+ uint32_t out = priv->dword;
+ uint32_t mask = (1 << bits) - 1;
+ priv->pos += bits;
+ if (priv->pos < 32) {
+ out >>= (32 - priv->pos);
+ }
+ else {
+ stream_read(s, (void *)&priv->dword, 4);
+ le2me_32(priv->dword);
+ priv->pos -= 32;
+ if (priv->pos) {
+ out <<= priv->pos;
+ out |= priv->dword >> (32 - priv->pos);
+ }
+ }
+ return out & mask;
+}
+
+int demux_mpc_open(demuxer_t* demuxer) {
+ stream_t *s = demuxer->stream;
+ sh_audio_t* sh_audio;
+ uint8_t hdr[HDR_SIZE];
+ da_priv_t* priv;
+ int i;
+
+ if (stream_read(s, hdr, HDR_SIZE) != HDR_SIZE)
+ return 0;
+ for (i = 0; i < 30000 && !s->eof; i++) {
+ if (hdr[0] == 'M' && hdr[1] == 'P' && hdr[2] == '+')
+ break;
+ memmove(hdr, &hdr[1], HDR_SIZE - 1);
+ stream_read(s, &hdr[HDR_SIZE - 1], 1);
+ }
+
+ if (hdr[0] != 'M' || hdr[1] != 'P' || hdr[2] != '+')
+ return 0;
+
+ sh_audio = new_sh_audio(demuxer,0);
+
+ {
+ char *wf = (char *)calloc(1, sizeof(WAVEFORMATEX) + HDR_SIZE);
+ char *header = &wf[sizeof(WAVEFORMATEX)];
+ const int freqs[4] = {44100, 48000, 37800, 32000};
+ sh_audio->format = mmioFOURCC('M', 'P', 'C', ' ');
+ memcpy(header, hdr, HDR_SIZE);
+ sh_audio->wf = (WAVEFORMATEX *)wf;
+ sh_audio->wf->wFormatTag = sh_audio->format;
+ sh_audio->wf->nChannels = 2;
+ sh_audio->wf->nSamplesPerSec = freqs[header[10] & 3];
+ sh_audio->wf->nBlockAlign = 32 * 36;
+ sh_audio->wf->wBitsPerSample = 16;
+ sh_audio->wf->nAvgBytesPerSec = 128 * 1024; // dummy to make mencoder not hang
+ sh_audio->wf->cbSize = HDR_SIZE;
+ demuxer->movi_start = stream_tell(s);
+ demuxer->movi_end = s->end_pos;
+ }
+
+ priv = (da_priv_t *)malloc(sizeof(da_priv_t));
+ priv->last_pts = -1;
+ priv->dword = 0;
+ priv->pos = 0;
+ stream_read(s, (void *)&priv->dword, 4);
+ priv->pos = 8;
+ demuxer->priv = priv;
+ demuxer->audio->id = 0;
+ demuxer->audio->sh = sh_audio;
+ sh_audio->ds = demuxer->audio;
+ sh_audio->samplerate = sh_audio->wf->nSamplesPerSec;
+ sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec;
+ sh_audio->audio.dwSampleSize = 0;
+ sh_audio->audio.dwScale = 32 * 36;
+ sh_audio->audio.dwRate = sh_audio->samplerate;
+
+ return 1;
+}
+
+int demux_mpc_fill_buffer(demux_stream_t *ds) {
+ int l;
+ int bit_len;
+ demux_packet_t* dp;
+ sh_audio_t* sh_audio = ds->sh;
+ demuxer_t* demux = ds->demuxer;
+ da_priv_t* priv = demux->priv;
+ stream_t* s = demux->stream;
+ sh_audio = ds->sh;
+
+ if (s->eof)
+ return 0;
+
+ bit_len = get_bits(priv, s, 20);
+ dp = new_demux_packet((bit_len + 7) / 8);
+ for (l = 0; l < (bit_len / 8); l++)
+ dp->buffer[l] = get_bits(priv, s, 8);
+ bit_len %= 8;
+ if (bit_len)
+ dp->buffer[l] = get_bits(priv, s, bit_len) << (8 - bit_len);
+ if (priv->last_pts < 0)
+ priv->last_pts = 0;
+ else
+ priv->last_pts += (36 * 32) / (float)sh_audio->samplerate;
+ ds->pts = priv->last_pts - (ds_tell_pts(demux->audio) -
+ sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
+ ds_add_packet(ds, dp);
+ return 1;
+}
+
+void demux_mpc_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){
+// TODO
+}
+
+void demux_close_mpc(demuxer_t* demuxer) {
+ da_priv_t* priv = demuxer->priv;
+
+ if(!priv)
+ return;
+ free(priv);
+}
+
+int demux_mpc_control(demuxer_t *demuxer,int cmd, void *arg){
+ return DEMUXER_CTRL_NOTIMPL;
+}
Index: libmpdemux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.192
diff -u -r1.192 demuxer.c
--- libmpdemux/demuxer.c 20 Jun 2005 23:07:35 -0000 1.192
+++ libmpdemux/demuxer.c 3 Jul 2005 13:25:50 -0000
@@ -211,6 +211,8 @@
#endif
case DEMUXER_TYPE_AUDIO:
demux_close_audio(demuxer); break;
+ case DEMUXER_TYPE_MPC:
+ demux_close_mpc(demuxer); break;
#ifdef HAVE_OGGVORBIS
case DEMUXER_TYPE_OGG:
demux_close_ogg(demuxer); break;
@@ -388,6 +390,7 @@
#endif
case DEMUXER_TYPE_Y4M: return demux_y4m_fill_buffer(demux);
case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds);
+ case DEMUXER_TYPE_MPC: return demux_mpc_fill_buffer(ds);
#ifdef HAVE_XMMS
case DEMUXER_TYPE_XMMS: return demux_xmms_fill_buffer(demux,ds);
#endif
@@ -1063,6 +1066,17 @@
demuxer = NULL;
}
}
+//=============== Try to open as musepack file: =================
+if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_MPC){
+ demuxer=new_demuxer(stream,DEMUXER_TYPE_MPC,audio_id,video_id,dvdsub_id);
+ if(demux_mpc_open(demuxer)){
+ mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_Detected_XXX_FileFormat, "MPC");
+ file_format=DEMUXER_TYPE_MPC;
+ } else {
+ free_demuxer(demuxer);
+ demuxer = NULL;
+ }
+}
#ifdef HAVE_XMMS
//=============== Try to open as XMMS file: =================
if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_XMMS){
@@ -1532,6 +1546,8 @@
demux_seek_nuv(demuxer,rel_seek_secs,flags); break;
case DEMUXER_TYPE_AUDIO:
demux_audio_seek(demuxer,rel_seek_secs,flags); break;
+ case DEMUXER_TYPE_MPC:
+ demux_mpc_seek(demuxer,rel_seek_secs,flags); break;
case DEMUXER_TYPE_DEMUXERS:
demux_demuxers_seek(demuxer,rel_seek_secs,flags); break;
#ifdef HAVE_OGGVORBIS
@@ -1659,6 +1675,8 @@
return demux_avi_control(demuxer,cmd,arg);
case DEMUXER_TYPE_AUDIO:
return demux_audio_control(demuxer,cmd,arg);
+ case DEMUXER_TYPE_MPC:
+ return demux_mpc_control(demuxer,cmd,arg);
#ifdef HAVE_OGGVORBIS
case DEMUXER_TYPE_OGG:
return demux_ogg_control(demuxer,cmd,arg);
Index: libmpdemux/demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.77
diff -u -r1.77 demuxer.h
--- libmpdemux/demuxer.h 13 Jun 2005 20:39:18 -0000 1.77
+++ libmpdemux/demuxer.h 3 Jul 2005 13:25:51 -0000
@@ -47,11 +47,12 @@
#define DEMUXER_TYPE_VQF 37
#define DEMUXER_TYPE_AVS 38
#define DEMUXER_TYPE_AAC 39
+#define DEMUXER_TYPE_MPC 40
// This should always match the higest demuxer type number.
// Unless you want to disallow users to force the demuxer to some types
#define DEMUXER_TYPE_MIN 0
-#define DEMUXER_TYPE_MAX 39
+#define DEMUXER_TYPE_MAX 40
#define DEMUXER_TYPE_DEMUXERS (1<<16)
// A virtual demuxer type for the network code
-------------- next part --------------
diff -ur libmpcdec-1.2/include/mpcdec/internal.h libmpcdec-1.2.mine/include/mpcdec/internal.h
--- libmpcdec-1.2/include/mpcdec/internal.h 2005-05-05 23:43:34.000000000 +0200
+++ libmpcdec-1.2.mine/include/mpcdec/internal.h 2005-07-03 15:10:05.000000000 +0200
@@ -46,10 +46,8 @@
/// Big/little endian 32 bit byte swapping routine.
static __inline
mpc_uint32_t swap32(mpc_uint32_t val) {
- const unsigned char* src = (const unsigned char*)&val;
- return
- (mpc_uint32_t)src[0] |
- ((mpc_uint32_t)src[1] << 8) | ((mpc_uint32_t)src[2] << 16) | ((mpc_uint32_t)src[3] << 24);
+ return (((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) |
+ ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24));
}
/// Searches for a ID3v2-tag and reads the length (in bytes) of it.
diff -ur libmpcdec-1.2/include/mpcdec/mpcdec.h libmpcdec-1.2.mine/include/mpcdec/mpcdec.h
--- libmpcdec-1.2/include/mpcdec/mpcdec.h 2005-05-05 23:24:17.000000000 +0200
+++ libmpcdec-1.2.mine/include/mpcdec/mpcdec.h 2005-07-03 15:10:58.000000000 +0200
@@ -100,6 +100,8 @@
/// \return TRUE if decoder was initalized successfully, FALSE otherwise
mpc_bool_t mpc_decoder_initialize(mpc_decoder *d, mpc_streaminfo *si);
+void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si);
+
/// Sets decoder sample scaling factor. All decoded samples will be multiplied
/// by this factor.
/// \param scale_factor multiplicative scaling factor
@@ -119,6 +121,12 @@
mpc_uint32_t *vbr_update_acc,
mpc_uint32_t *vbr_update_bits);
+mpc_uint32_t mpc_decoder_decode_frame(
+ mpc_decoder *d,
+ mpc_uint32_t *in_buffer,
+ mpc_uint32_t in_len,
+ MPC_SAMPLE_FORMAT *out_buffer);
+
/// Seeks to the specified sample in the source stream.
mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample);
diff -ur libmpcdec-1.2/src/mpc_decoder.c libmpcdec-1.2.mine/src/mpc_decoder.c
--- libmpcdec-1.2/src/mpc_decoder.c 2005-05-05 23:24:24.000000000 +0200
+++ libmpcdec-1.2.mine/src/mpc_decoder.c 2005-07-03 15:10:18.000000000 +0200
@@ -313,6 +313,37 @@
memset(d->MS_Flag , 0, sizeof d->MS_Flag );
}
+mpc_uint32_t
+mpc_decoder_decode_frame(mpc_decoder *d, mpc_uint32_t *in_buffer,
+ mpc_uint32_t in_len, MPC_SAMPLE_FORMAT *out_buffer)
+{
+ int i;
+ mpc_decoder_reset_bitstream_decode(d);
+ if (in_len > sizeof(d->Speicher)) in_len = sizeof(d->Speicher);
+ memcpy(d->Speicher, in_buffer, in_len);
+#ifdef MPC_LITTLE_ENDIAN
+ for (i = 0; i < (in_len + 3) / 4; i++)
+ d->Speicher[i] = swap32(d->Speicher[i]);
+#endif
+ d->dword = d->Speicher[0];
+ switch (d->StreamVersion) {
+ case 0x04:
+ case 0x05:
+ case 0x06:
+ mpc_decoder_read_bitstream_sv6(d);
+ break;
+ case 0x07:
+ case 0x17:
+ mpc_decoder_read_bitstream_sv7(d);
+ break;
+ default:
+ return (mpc_uint32_t)(-1);
+ }
+ mpc_decoder_requantisierung(d, d->Max_Band);
+ mpc_decoder_synthese_filter_float(d, out_buffer);
+ return mpc_decoder_bits_read(d);
+}
+
static mpc_uint32_t
mpc_decoder_decode_internal(mpc_decoder *d, MPC_SAMPLE_FORMAT *buffer)
{
@@ -1174,7 +1205,7 @@
mpc_decoder_init_huffman_sv7(d);
}
-static void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si)
+void mpc_decoder_set_streaminfo(mpc_decoder *d, mpc_streaminfo *si)
{
mpc_decoder_reset_synthesis(d);
mpc_decoder_reset_globals(d);
More information about the MPlayer-dev-eng
mailing list