summaryrefslogtreecommitdiff
path: root/thirdparty/libmpcdec/mpc
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/libmpcdec/mpc')
-rw-r--r--thirdparty/libmpcdec/mpc/datatypes.h38
-rw-r--r--thirdparty/libmpcdec/mpc/minimax.h57
-rw-r--r--thirdparty/libmpcdec/mpc/mpc_types.h138
-rw-r--r--thirdparty/libmpcdec/mpc/mpcdec.h148
-rw-r--r--thirdparty/libmpcdec/mpc/mpcmath.h153
-rw-r--r--thirdparty/libmpcdec/mpc/reader.h98
-rw-r--r--thirdparty/libmpcdec/mpc/streaminfo.h109
7 files changed, 741 insertions, 0 deletions
diff --git a/thirdparty/libmpcdec/mpc/datatypes.h b/thirdparty/libmpcdec/mpc/datatypes.h
new file mode 100644
index 0000000000..608ecfa2f2
--- /dev/null
+++ b/thirdparty/libmpcdec/mpc/datatypes.h
@@ -0,0 +1,38 @@
+/*
+ * Musepack audio compression
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#pragma once
+
+// mpcenc.h
+#define CENTER 448 // offset for centering current data in Main-array
+#define BLOCK 1152 // blocksize
+#define ANABUFFER (BLOCK + CENTER) // size of PCM-data array for analysis
+
+
+typedef struct {
+ float L [36];
+ float R [36];
+} SubbandFloatTyp;
+
+typedef struct {
+ float L [ANABUFFER];
+ float R [ANABUFFER];
+ float M [ANABUFFER];
+ float S [ANABUFFER];
+} PCMDataTyp;
+
diff --git a/thirdparty/libmpcdec/mpc/minimax.h b/thirdparty/libmpcdec/mpc/minimax.h
new file mode 100644
index 0000000000..1192626567
--- /dev/null
+++ b/thirdparty/libmpcdec/mpc/minimax.h
@@ -0,0 +1,57 @@
+/*
+ * Musepack audio compression
+ * Copyright (C) 1999-2004 Buschmann/Klemm/Piecha/Wolf
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#pragma once
+
+# define clip(x,min,max) ( (x) < (min) ? (min) : (x) > (max) ? (max) : (x) )
+
+#ifdef __cplusplus
+
+# define maxi(A,B) ( (A) >? (B) )
+# define mini(A,B) ( (A) <? (B) )
+# define maxd(A,B) ( (A) >? (B) )
+# define mind(A,B) ( (A) <? (B) )
+# define maxf(A,B) ( (A) >? (B) )
+# define minf(A,B) ( (A) <? (B) )
+
+#else
+
+# define maxi(A,B) ( (A) > (B) ? (A) : (B) )
+# define mini(A,B) ( (A) < (B) ? (A) : (B) )
+# define maxd(A,B) ( (A) > (B) ? (A) : (B) )
+# define mind(A,B) ( (A) < (B) ? (A) : (B) )
+# define maxf(A,B) ( (A) > (B) ? (A) : (B) )
+# define minf(A,B) ( (A) < (B) ? (A) : (B) )
+
+#endif
+
+#ifdef __GNUC__
+
+# define absi(A) abs (A)
+# define absf(A) fabsf (A)
+# define absd(A) fabs (A)
+
+#else
+
+# define absi(A) ( (A) >= 0 ? (A) : -(A) )
+# define absf(A) ( (A) >= 0.f ? (A) : -(A) )
+# define absd(A) ( (A) >= 0. ? (A) : -(A) )
+
+#endif
+
diff --git a/thirdparty/libmpcdec/mpc/mpc_types.h b/thirdparty/libmpcdec/mpc/mpc_types.h
new file mode 100644
index 0000000000..a827d15725
--- /dev/null
+++ b/thirdparty/libmpcdec/mpc/mpc_types.h
@@ -0,0 +1,138 @@
+/*
+ Copyright (c) 2005-2009, The Musepack Development Team
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of the The Musepack Development Team nor the
+ names of its contributors may be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef _MPC_TYPES_H_
+#define _MPC_TYPES_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include <stdlib.h>
+//#include <memory.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef _MSC_VER
+typedef __int8 mpc_int8_t;
+typedef unsigned __int8 mpc_uint8_t;
+typedef __int16 mpc_int16_t;
+typedef unsigned __int16 mpc_uint16_t;
+typedef __int32 mpc_int32_t;
+typedef unsigned __int32 mpc_uint32_t;
+typedef __int64 mpc_int64_t;
+typedef unsigned __int64 mpc_uint64_t;
+#define mpc_inline __inline
+#else
+#include <stdint.h>
+typedef int8_t mpc_int8_t;
+typedef uint8_t mpc_uint8_t;
+typedef int16_t mpc_int16_t;
+typedef uint16_t mpc_uint16_t;
+typedef int32_t mpc_int32_t;
+typedef uint32_t mpc_uint32_t;
+typedef int64_t mpc_int64_t;
+typedef uint64_t mpc_uint64_t;
+#define mpc_inline inline
+#endif
+
+typedef int mpc_int_t;
+typedef unsigned int mpc_uint_t;
+typedef size_t mpc_size_t;
+typedef mpc_uint8_t mpc_bool_t;
+
+// #define LONG_SEEK_TABLE
+#ifdef LONG_SEEK_TABLE // define as needed (mpc_uint32_t supports files up to 512 MB)
+typedef mpc_uint64_t mpc_seek_t;
+#else
+typedef mpc_uint32_t mpc_seek_t;
+#endif
+
+# define mpc_int64_min -9223372036854775808ll
+# define mpc_int64_max 9223372036854775807ll
+
+typedef struct mpc_quantizer {
+ mpc_int16_t L [36];
+ mpc_int16_t R [36];
+} mpc_quantizer;
+
+/// Libmpcdec error codes
+typedef enum mpc_status {
+ MPC_STATUS_OK = 0,
+ MPC_STATUS_FILE = -1,
+ MPC_STATUS_SV7BETA = -2,
+ MPC_STATUS_CBR = -3,
+ MPC_STATUS_IS = -4,
+ MPC_STATUS_BLOCKSIZE = -5,
+ MPC_STATUS_INVALIDSV = -6
+} mpc_status;
+
+
+#define MPC_FIXED_POINT_SHIFT 16
+
+#ifdef MPC_FIXED_POINT
+# define MPC_FIXED_POINT_FRACTPART 14
+# define MPC_FIXED_POINT_SCALE_SHIFT (MPC_FIXED_POINT_SHIFT + MPC_FIXED_POINT_FRACTPART)
+# define MPC_FIXED_POINT_SCALE (1 << (MPC_FIXED_POINT_SCALE_SHIFT - 1))
+typedef mpc_int32_t MPC_SAMPLE_FORMAT;
+#else
+typedef float MPC_SAMPLE_FORMAT;
+#endif
+
+enum {
+ MPC_FALSE = 0,
+ MPC_TRUE = !MPC_FALSE
+};
+
+//// 'Cdecl' forces the use of standard C/C++ calling convention ///////
+#if defined _WIN32
+# define mpc_cdecl __cdecl
+#elif defined __ZTC__
+# define mpc_cdecl _cdecl
+#elif defined __TURBOC__
+# define mpc_cdecl cdecl
+#else
+# define mpc_cdecl
+#endif
+
+#ifdef __GNUC__
+# define MPC_API __attribute__ ((visibility("default")))
+#else
+# define MPC_API
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/thirdparty/libmpcdec/mpc/mpcdec.h b/thirdparty/libmpcdec/mpc/mpcdec.h
new file mode 100644
index 0000000000..c72359516c
--- /dev/null
+++ b/thirdparty/libmpcdec/mpc/mpcdec.h
@@ -0,0 +1,148 @@
+/*
+ Copyright (c) 2005-2009, The Musepack Development Team
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of the The Musepack Development Team nor the
+ names of its contributors may be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file mpcdec.h
+/// Top level include file for libmpcdec.
+#ifndef _MPCDEC_H_
+#define _MPCDEC_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include "reader.h"
+#include "streaminfo.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ MPC_FRAME_LENGTH = (36 * 32), ///< Samples per mpc frame
+ MPC_DECODER_BUFFER_LENGTH = (MPC_FRAME_LENGTH * 4), ///< Required buffer size for decoder
+ MPC_DECODER_SYNTH_DELAY = 481
+};
+
+typedef struct mpc_decoder_t mpc_decoder;
+typedef struct mpc_demux_t mpc_demux;
+
+typedef struct mpc_bits_reader_t {
+ unsigned char * buff; /// pointer on current byte
+ unsigned int count; /// unread bits in current byte
+} mpc_bits_reader;
+
+typedef struct mpc_frame_info_t {
+ mpc_uint32_t samples; /// number of samples in the frame (counting once for multiple channels)
+ mpc_int32_t bits; /// number of bits consumed by this frame (-1) if end of stream
+ MPC_SAMPLE_FORMAT * buffer; /// frame samples buffer (size = samples * channels * sizeof(MPC_SAMPLE_FORMAT))
+ mpc_bool_t is_key_frame; /// 1 if this frame is a key frame (first in block) 0 else. Set by the demuxer.
+} mpc_frame_info;
+
+typedef struct mpc_chap_info_t {
+ mpc_uint64_t sample; /// sample where the chapter starts
+ mpc_uint16_t gain; /// replaygain chapter value
+ mpc_uint16_t peak; /// peak chapter loudness level
+ mpc_uint_t tag_size; /// size of the tag element (0 if no tag is present for this chapter)
+ char * tag; /// pointer to an APEv2 tag without the preamble
+} mpc_chap_info;
+
+/// Initializes mpc decoder with the supplied stream info parameters.
+/// \param si streaminfo structure indicating format of source stream
+/// \return pointer on the initialized decoder structure if successful, 0 if not
+MPC_API mpc_decoder * mpc_decoder_init(mpc_streaminfo *si);
+
+/// Releases input mpc decoder
+MPC_API void mpc_decoder_exit(mpc_decoder *p_dec);
+
+/**
+ * Sets decoder sample scaling factor. All decoded samples will be multiplied
+ * by this factor. Useful for applying replay gain.
+ * @param scale_factor multiplicative scaling factor
+ */
+MPC_API void mpc_decoder_scale_output(mpc_decoder *p_dec, double scale_factor);
+
+MPC_API void mpc_decoder_decode_frame(mpc_decoder * d, mpc_bits_reader * r, mpc_frame_info * i);
+
+// This is the gain reference used in old replaygain
+#define MPC_OLD_GAIN_REF 64.82
+
+/**
+ * init demuxer
+ * @param p_reader initialized mpc_reader pointer
+ * @return an initialized mpc_demux pointer
+ */
+MPC_API mpc_demux * mpc_demux_init(mpc_reader * p_reader);
+/// free demuxer
+MPC_API void mpc_demux_exit(mpc_demux * d);
+/**
+ * Calls mpc_decoder_scale_output to set the scaling factor according to the
+ * replay gain stream information and the supplied ouput level
+ * @param d pointer to a musepack demuxer
+ * @param level the desired ouput level (in db). Must be MPC_OLD_GAIN_REF (64.82 db) if you want to get the old replaygain behavior
+ * @param use_gain set it to MPC_TRUE if you want to set the scaling factor according to the stream gain
+ * @param use_title MPC_TRUE : uses the title gain, MPC_FALSE : uses the album gain
+ * @param clip_prevention MPC_TRUE : uses cliping prevention
+ */
+MPC_API void mpc_set_replay_level(mpc_demux * d, float level, mpc_bool_t use_gain,
+ mpc_bool_t use_title, mpc_bool_t clip_prevention);
+/// decode frame
+MPC_API mpc_status mpc_demux_decode(mpc_demux * d, mpc_frame_info * i);
+/// get streaminfo
+MPC_API void mpc_demux_get_info(mpc_demux * d, mpc_streaminfo * i);
+/// seeks to a given sample
+MPC_API mpc_status mpc_demux_seek_sample(mpc_demux * d, mpc_uint64_t destsample);
+/// seeks to a given second
+MPC_API mpc_status mpc_demux_seek_second(mpc_demux * d, double seconds);
+
+/// \return the current position in the stream (in bits) from the beginning of the file
+MPC_API mpc_seek_t mpc_demux_pos(mpc_demux * d);
+
+/// chapters : only for sv8 streams
+/**
+ * Gets the number of chapters in the stream
+ * @param d pointer to a musepack demuxer
+ * @return the number of chapters found in the stream
+ */
+MPC_API mpc_int_t mpc_demux_chap_nb(mpc_demux * d);
+/**
+ * Gets datas associated to a given chapter
+ * The chapter tag is an APEv2 tag without the preamble
+ * @param d pointer to a musepack demuxer
+ * @param chap_nb chapter number you want datas (from 0 to mpc_demux_chap_nb(d) - 1)
+ * @return the chapter information structure
+ */
+MPC_API mpc_chap_info const * mpc_demux_chap(mpc_demux * d, int chap_nb);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/thirdparty/libmpcdec/mpc/mpcmath.h b/thirdparty/libmpcdec/mpc/mpcmath.h
new file mode 100644
index 0000000000..fa83cf8374
--- /dev/null
+++ b/thirdparty/libmpcdec/mpc/mpcmath.h
@@ -0,0 +1,153 @@
+/*
+ * Musepack audio compression
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <mpc/mpc_types.h>
+
+typedef union mpc_floatint
+{
+ float f;
+ mpc_int32_t n;
+} mpc_floatint;
+
+typedef union mpc_doubleint
+{
+ double d;
+ mpc_int32_t n[2];
+} mpc_doubleint;
+
+static mpc_inline mpc_int32_t mpc_lrintf(float fVal)
+{
+ mpc_floatint tmp;
+ tmp.f = fVal + 0x00FF8000;
+ return tmp.n - 0x4B7F8000;
+}
+
+#define mpc_round32 mpc_lrintf
+#define mpc_nearbyintf mpc_lrintf
+
+
+#ifndef M_PI
+# define M_PI 3.1415926535897932384626433832795029 // 4*atan(1)
+# define M_PIl 3.1415926535897932384626433832795029L
+# define M_LN2 0.6931471805599453094172321214581766 // ln(2)
+# define M_LN2l 0.6931471805599453094172321214581766L
+# define M_LN10 2.3025850929940456840179914546843642 // ln 10 */
+# define M_LN10l 2.3025850929940456840179914546843642L
+#endif
+
+// fast but maybe more inaccurate, use if you need speed
+#if defined(__GNUC__) && !defined(__APPLE__)
+# define SIN(x) sinf ((float)(x))
+# define COS(x) cosf ((float)(x))
+# define ATAN2(x,y) atan2f ((float)(x), (float)(y))
+# define SQRT(x) sqrtf ((float)(x))
+# define LOG(x) logf ((float)(x))
+# define LOG10(x) log10f ((float)(x))
+# define POW(x,y) expf (logf(x) * (y))
+# define POW10(x) expf (M_LN10 * (x))
+# define FLOOR(x) floorf ((float)(x))
+# define IFLOOR(x) (int) floorf ((float)(x))
+# define FABS(x) fabsf ((float)(x))
+#else
+# define SIN(x) (float) sin (x)
+# define COS(x) (float) cos (x)
+# define ATAN2(x,y) (float) atan2 (x, y)
+# define SQRT(x) (float) sqrt (x)
+# define LOG(x) (float) log (x)
+# define LOG10(x) (float) log10 (x)
+# define POW(x,y) (float) pow (x,y)
+# define POW10(x) (float) pow (10., (x))
+# define FLOOR(x) (float) floor (x)
+# define IFLOOR(x) (int) floor (x)
+# define FABS(x) (float) fabs (x)
+#endif
+
+#define SQRTF(x) SQRT (x)
+#ifdef FAST_MATH
+# define TABSTEP 64
+# define COSF(x) my_cos ((float)(x))
+# define ATAN2F(x,y) my_atan2 ((float)(x), (float)(y))
+# define IFLOORF(x) my_ifloor ((float)(x))
+
+void Init_FastMath ( void );
+extern const float tabatan2 [] [2];
+extern const float tabcos [] [2];
+extern const float tabsqrt_ex [];
+extern const float tabsqrt_m [] [2];
+
+static mpc_inline float my_atan2 ( float x, float y )
+{
+ float t, ret; int i; mpc_floatint mx, my;
+
+ mx.f = x;
+ my.f = y;
+ if ( (mx.n & 0x7FFFFFFF) < (my.n & 0x7FFFFFFF) ) {
+ i = mpc_round32 (t = TABSTEP * (mx.f / my.f));
+ ret = tabatan2 [1*TABSTEP+i][0] + tabatan2 [1*TABSTEP+i][1] * (t-i);
+ if ( my.n < 0 )
+ ret = (float)(ret - M_PI);
+ }
+ else if ( mx.n < 0 ) {
+ i = mpc_round32 (t = TABSTEP * (my.f / mx.f));
+ ret = - M_PI/2 - tabatan2 [1*TABSTEP+i][0] + tabatan2 [1*TABSTEP+i][1] * (i-t);
+ }
+ else if ( mx.n > 0 ) {
+ i = mpc_round32 (t = TABSTEP * (my.f / mx.f));
+ ret = + M_PI/2 - tabatan2 [1*TABSTEP+i][0] + tabatan2 [1*TABSTEP+i][1] * (i-t);
+ }
+ else {
+ ret = 0.;
+ }
+ return ret;
+}
+
+
+static mpc_inline float my_cos ( float x )
+{
+ float t, ret; int i;
+ i = mpc_round32 (t = TABSTEP * x);
+ ret = tabcos [13*TABSTEP+i][0] + tabcos [13*TABSTEP+i][1] * (t-i);
+ return ret;
+}
+
+
+static mpc_inline int my_ifloor ( float x )
+{
+ mpc_floatint mx;
+ mx.f = (float) (x + (0x0C00000L + 0.500000001));
+ return mx.n - 1262485505;
+}
+
+
+static mpc_inline float my_sqrt ( float x )
+{
+ float ret; int i, ex; mpc_floatint mx;
+ mx.f = x;
+ ex = mx.n >> 23; // get the exponent
+ mx.n = (mx.n & 0x7FFFFF) | 0x42800000; // delete the exponent
+ i = mpc_round32 (mx.f); // Integer-part of the mantissa (round ????????????)
+ ret = tabsqrt_m [i-TABSTEP][0] + tabsqrt_m [i-TABSTEP][1] * (mx.f-i); // calculate value
+ ret *= tabsqrt_ex [ex];
+ return ret;
+}
+#else
+# define COSF(x) COS (x)
+# define ATAN2F(x,y) ATAN2 (x,y)
+# define IFLOORF(x) IFLOOR (x)
+#endif
+
diff --git a/thirdparty/libmpcdec/mpc/reader.h b/thirdparty/libmpcdec/mpc/reader.h
new file mode 100644
index 0000000000..1a93e06706
--- /dev/null
+++ b/thirdparty/libmpcdec/mpc/reader.h
@@ -0,0 +1,98 @@
+/*
+ Copyright (c) 2005-2009, The Musepack Development Team
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of the The Musepack Development Team nor the
+ names of its contributors may be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file reader.h
+#ifndef _MPCDEC_READER_H_
+#define _MPCDEC_READER_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include <mpc/mpc_types.h>
+#include <stdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/// \brief Stream reader interface structure.
+///
+/// This is the structure you must supply to the musepack decoding library
+/// to feed it with raw data. Implement the five member functions to provide
+/// a functional reader.
+typedef struct mpc_reader_t mpc_reader;
+struct mpc_reader_t {
+ /// Reads size bytes of data into buffer at ptr.
+ mpc_int32_t (*read)(mpc_reader *p_reader, void *ptr, mpc_int32_t size);
+
+ /// Seeks to byte position offset.
+ mpc_bool_t (*seek)(mpc_reader *p_reader, mpc_int32_t offset);
+
+ /// Returns the current byte offset in the stream.
+ mpc_int32_t (*tell)(mpc_reader *p_reader);
+
+ /// Returns the total length of the source stream, in bytes.
+ mpc_int32_t (*get_size)(mpc_reader *p_reader);
+
+ /// True if the stream is a seekable stream.
+ mpc_bool_t (*canseek)(mpc_reader *p_reader);
+
+ /// Field that can be used to identify a particular instance of
+ /// reader or carry along data associated with that reader.
+ void *data;
+};
+
+/// Initializes reader with default stdio file reader implementation. Use
+/// this if you're just reading from a plain file.
+///
+/// \param r p_reader handle to initialize
+/// \param filename input filename to attach to the reader
+MPC_API mpc_status mpc_reader_init_stdio(mpc_reader *p_reader, const char *filename);
+
+/// Initializes reader with default stdio file reader implementation. Use
+/// this if you prefer to open the file yourself.
+///
+/// \param r p_reader handle to initialize
+/// \param p_file input file handle (already open)
+MPC_API mpc_status mpc_reader_init_stdio_stream(mpc_reader * p_reader, FILE * p_file);
+
+/// Release reader with default stdio file reader implementation.
+///
+/// \param r reader handle to release
+MPC_API void mpc_reader_exit_stdio(mpc_reader *p_reader);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/thirdparty/libmpcdec/mpc/streaminfo.h b/thirdparty/libmpcdec/mpc/streaminfo.h
new file mode 100644
index 0000000000..a0a9470be1
--- /dev/null
+++ b/thirdparty/libmpcdec/mpc/streaminfo.h
@@ -0,0 +1,109 @@
+/*
+ Copyright (c) 2005-2009, The Musepack Development Team
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+ * Neither the name of the The Musepack Development Team nor the
+ names of its contributors may be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/// \file streaminfo.h
+#ifndef _MPCDEC_STREAMINFO_H_
+#define _MPCDEC_STREAMINFO_H_
+#ifdef WIN32
+#pragma once
+#endif
+
+#include <mpc/mpc_types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+typedef mpc_int32_t mpc_streaminfo_off_t;
+
+/// \brief mpc stream properties structure
+///
+/// Structure containing all the properties of an mpc stream. Populated
+/// by the streaminfo_read function.
+typedef struct mpc_streaminfo {
+ /// @name Core mpc stream properties
+ //@{
+ mpc_uint32_t sample_freq; ///< Sample frequency of stream
+ mpc_uint32_t channels; ///< Number of channels in stream
+ mpc_uint32_t stream_version; ///< Streamversion of stream
+ mpc_uint32_t bitrate; ///< Bitrate of stream file (in bps)
+ double average_bitrate; ///< Average bitrate of stream (in bits/sec)
+ mpc_uint32_t max_band; ///< Maximum band-index used in stream (0...31)
+ mpc_uint32_t ms; ///< Mid/side stereo (0: off, 1: on)
+ mpc_uint32_t fast_seek; ///< True if stream supports fast-seeking (sv7)
+ mpc_uint32_t block_pwr; ///< Number of frames in a block = 2^block_pwr (sv8)
+ //@}
+
+ /// @name Replaygain properties
+ //@{
+ mpc_uint16_t gain_title; ///< Replaygain title value
+ mpc_uint16_t gain_album; ///< Replaygain album value
+ mpc_uint16_t peak_album; ///< Peak album loudness level
+ mpc_uint16_t peak_title; ///< Peak title loudness level
+ //@}
+
+ /// @name True gapless properties
+ //@{
+ mpc_uint32_t is_true_gapless; ///< True gapless? (0: no, 1: yes)
+ mpc_uint64_t samples; ///< Number of samples in the stream
+ mpc_uint64_t beg_silence; ///< Number of samples that must not be played at the beginning of the stream
+ //@}
+
+ /// @name Encoder informations
+ //@{
+ mpc_uint32_t encoder_version; ///< Version of encoder used
+ char encoder[256]; ///< Encoder name
+ mpc_bool_t pns; ///< pns used
+ float profile; ///< Quality profile of stream
+ const char* profile_name; ///< Name of profile used by stream
+ //@}
+
+
+ mpc_streaminfo_off_t header_position; ///< Byte offset of position of header in stream
+ mpc_streaminfo_off_t tag_offset; ///< Offset to file tags
+ mpc_streaminfo_off_t total_file_length; ///< Total length of underlying file
+} mpc_streaminfo;
+
+/// Gets length of stream si, in seconds.
+/// \return length of stream in seconds
+MPC_API double mpc_streaminfo_get_length(mpc_streaminfo *si);
+
+/// Returns length of stream si, in samples.
+/// \return length of stream in samples
+MPC_API mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si);
+
+#ifdef __cplusplus
+}
+#endif
+#endif