From 9300f16316eb33715193a0f9a916991a2b24ba9d Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Wed, 16 Jun 2010 21:15:37 +0200 Subject: musepack plugin compile fix --- plugins/musepack/mpc/minimax.h | 57 +++++++++++++++ plugins/musepack/mpc/mpc_types.h | 138 +++++++++++++++++++++++++++++++++++ plugins/musepack/mpc/mpcdec.h | 148 ++++++++++++++++++++++++++++++++++++++ plugins/musepack/mpc/reader.h | 98 +++++++++++++++++++++++++ plugins/musepack/mpc/streaminfo.h | 109 ++++++++++++++++++++++++++++ plugins/musepack/mpcdec.h | 148 -------------------------------------- plugins/musepack/musepack.c | 2 +- plugins/musepack/reader.h | 98 ------------------------- plugins/musepack/streaminfo.h | 109 ---------------------------- 9 files changed, 551 insertions(+), 356 deletions(-) create mode 100644 plugins/musepack/mpc/minimax.h create mode 100644 plugins/musepack/mpc/mpc_types.h create mode 100644 plugins/musepack/mpc/mpcdec.h create mode 100644 plugins/musepack/mpc/reader.h create mode 100644 plugins/musepack/mpc/streaminfo.h delete mode 100644 plugins/musepack/mpcdec.h delete mode 100644 plugins/musepack/reader.h delete mode 100644 plugins/musepack/streaminfo.h (limited to 'plugins/musepack') diff --git a/plugins/musepack/mpc/minimax.h b/plugins/musepack/mpc/minimax.h new file mode 100644 index 00000000..11926265 --- /dev/null +++ b/plugins/musepack/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 mind(A,B) ( (A) ? (B) ) +# define minf(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/plugins/musepack/mpc/mpc_types.h b/plugins/musepack/mpc/mpc_types.h new file mode 100644 index 00000000..bd51f06a --- /dev/null +++ b/plugins/musepack/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 +#include + +#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 +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/plugins/musepack/mpc/mpcdec.h b/plugins/musepack/mpc/mpcdec.h new file mode 100644 index 00000000..c7235951 --- /dev/null +++ b/plugins/musepack/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/plugins/musepack/mpc/reader.h b/plugins/musepack/mpc/reader.h new file mode 100644 index 00000000..1a93e067 --- /dev/null +++ b/plugins/musepack/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 +#include + +#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/plugins/musepack/mpc/streaminfo.h b/plugins/musepack/mpc/streaminfo.h new file mode 100644 index 00000000..a0a9470b --- /dev/null +++ b/plugins/musepack/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 + +#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 diff --git a/plugins/musepack/mpcdec.h b/plugins/musepack/mpcdec.h deleted file mode 100644 index c7235951..00000000 --- a/plugins/musepack/mpcdec.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - 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/plugins/musepack/musepack.c b/plugins/musepack/musepack.c index 44e364f4..595eb571 100644 --- a/plugins/musepack/musepack.c +++ b/plugins/musepack/musepack.c @@ -20,7 +20,7 @@ #include #include #include -#include "mpcdec.h" +#include "mpc/mpcdec.h" #ifdef HAVE_CONFIG_H # include #endif diff --git a/plugins/musepack/reader.h b/plugins/musepack/reader.h deleted file mode 100644 index 1a93e067..00000000 --- a/plugins/musepack/reader.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - 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 -#include - -#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/plugins/musepack/streaminfo.h b/plugins/musepack/streaminfo.h deleted file mode 100644 index a0a9470b..00000000 --- a/plugins/musepack/streaminfo.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - 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 - -#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 -- cgit v1.2.3