diff options
author | James Stembridge <jstembridge@users.sourceforge.net> | 2005-01-14 15:24:07 +0000 |
---|---|---|
committer | James Stembridge <jstembridge@users.sourceforge.net> | 2005-01-14 15:24:07 +0000 |
commit | 05f670cb8cb0e0594d85ee50e8d126557cf3f8fe (patch) | |
tree | 638bdc4737dab9c7c3724ab372459590a607e07b /src/libmusepack/musepack | |
parent | f03ebd99a8e85f09d1abcde8fcc4a6b3318d82ad (diff) | |
download | xine-lib-05f670cb8cb0e0594d85ee50e8d126557cf3f8fe.tar.gz xine-lib-05f670cb8cb0e0594d85ee50e8d126557cf3f8fe.tar.bz2 |
(Drum roll) Long awaited support for Musepack
CVS patchset: 7344
CVS date: 2005/01/14 15:24:07
Diffstat (limited to 'src/libmusepack/musepack')
-rw-r--r-- | src/libmusepack/musepack/Makefile.am | 5 | ||||
-rw-r--r-- | src/libmusepack/musepack/config_types.h | 23 | ||||
-rw-r--r-- | src/libmusepack/musepack/decoder.h | 114 | ||||
-rw-r--r-- | src/libmusepack/musepack/huffman.h | 41 | ||||
-rw-r--r-- | src/libmusepack/musepack/internal.h | 27 | ||||
-rw-r--r-- | src/libmusepack/musepack/math.h | 110 | ||||
-rw-r--r-- | src/libmusepack/musepack/musepack.h | 94 | ||||
-rw-r--r-- | src/libmusepack/musepack/reader.h | 46 | ||||
-rw-r--r-- | src/libmusepack/musepack/requant.h | 17 | ||||
-rw-r--r-- | src/libmusepack/musepack/streaminfo.h | 52 |
10 files changed, 529 insertions, 0 deletions
diff --git a/src/libmusepack/musepack/Makefile.am b/src/libmusepack/musepack/Makefile.am new file mode 100644 index 000000000..1d37e1d79 --- /dev/null +++ b/src/libmusepack/musepack/Makefile.am @@ -0,0 +1,5 @@ +include $(top_srcdir)/misc/Makefile.common + +noinst_HEADERS = config_types.h decoder.h huffman.h internal.h math.h \ + musepack.h reader.h requant.h streaminfo.h + diff --git a/src/libmusepack/musepack/config_types.h b/src/libmusepack/musepack/config_types.h new file mode 100644 index 000000000..4ea88272c --- /dev/null +++ b/src/libmusepack/musepack/config_types.h @@ -0,0 +1,23 @@ +#ifndef __CONFIG_TYPES_H__ +#define __CONFIG_TYPES_H__ + +#include <stdint.h> + +#ifdef WORDS_BIGENDIAN + #undef MPC_LITTLE_ENDIAN +#else + #define MPC_LITTLE_ENDIAN +#endif + +typedef unsigned char BOOL; +#define TRUE 1 +#define FALSE 0 + +/* these are filled in by configure */ +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; + +#endif diff --git a/src/libmusepack/musepack/decoder.h b/src/libmusepack/musepack/decoder.h new file mode 100644 index 000000000..08c316390 --- /dev/null +++ b/src/libmusepack/musepack/decoder.h @@ -0,0 +1,114 @@ +/// \file decoder.h + +#ifndef _musepack_decoder_h_ +#define _musepack_decoder_h_ + +#include "musepack/huffman.h" +#include "musepack/math.h" +#include "musepack/musepack.h" +#include "musepack/reader.h" +#include "musepack/streaminfo.h" + +enum { + MPC_V_MEM = 2304, + MPC_DECODER_MEMSIZE = 16384, // overall buffer size +}; + +typedef struct { + mpc_int32_t L [36]; + mpc_int32_t R [36]; +} QuantTyp; + +typedef struct mpc_decoder_t { + mpc_reader *r; + + /// @name internal state variables + //@{ + + mpc_uint32_t dword; /// actually decoded 32bit-word + mpc_uint32_t pos; /// bit-position within dword + mpc_uint32_t Speicher[MPC_DECODER_MEMSIZE]; /// read-buffer + mpc_uint32_t Zaehler; /// actual index within read-buffer + + mpc_uint32_t samples_to_skip; + + mpc_uint32_t FwdJumpInfo; + mpc_uint32_t ActDecodePos; + mpc_uint32_t FrameWasValid; + + mpc_uint32_t DecodedFrames; + mpc_uint32_t OverallFrames; + mpc_int32_t SampleRate; // Sample frequency + + mpc_uint32_t StreamVersion; // version of bitstream + mpc_uint32_t MS_used; // MS-coding used ? + mpc_int32_t Max_Band; + mpc_uint32_t MPCHeaderPos; // AB: needed to support ID3v2 + mpc_uint32_t LastValidSamples; + mpc_uint32_t TrueGaplessPresent; + + mpc_uint32_t EQ_activated; + + mpc_uint32_t WordsRead; // counts amount of decoded dwords + + // randomizer state variables + mpc_uint32_t __r1; + mpc_uint32_t __r2; + + mpc_uint32_t Q_bit [32]; + mpc_uint32_t Q_res [32][16]; + + // huffman table stuff + HuffmanTyp HuffHdr [10]; + HuffmanTyp HuffSCFI [ 4]; + HuffmanTyp HuffDSCF [16]; + HuffmanTyp* HuffQ [2] [8]; + + HuffmanTyp HuffQ1 [2] [3*3*3]; + HuffmanTyp HuffQ2 [2] [5*5]; + HuffmanTyp HuffQ3 [2] [ 7]; + HuffmanTyp HuffQ4 [2] [ 9]; + HuffmanTyp HuffQ5 [2] [15]; + HuffmanTyp HuffQ6 [2] [31]; + HuffmanTyp HuffQ7 [2] [63]; + const HuffmanTyp* SampleHuff [18]; + HuffmanTyp SCFI_Bundle [ 8]; + HuffmanTyp DSCF_Entropie [13]; + HuffmanTyp Region_A [16]; + HuffmanTyp Region_B [ 8]; + HuffmanTyp Region_C [ 4]; + + HuffmanTyp Entropie_1 [ 3]; + HuffmanTyp Entropie_2 [ 5]; + HuffmanTyp Entropie_3 [ 7]; + HuffmanTyp Entropie_4 [ 9]; + HuffmanTyp Entropie_5 [15]; + HuffmanTyp Entropie_6 [31]; + HuffmanTyp Entropie_7 [63]; + + mpc_int32_t SCF_Index_L [32] [3]; + mpc_int32_t SCF_Index_R [32] [3]; // holds scalefactor-indices + QuantTyp Q [32]; // holds quantized samples + mpc_int32_t Res_L [32]; + mpc_int32_t Res_R [32]; // holds the chosen quantizer for each subband + mpc_int32_t DSCF_Flag_L [32]; + mpc_int32_t DSCF_Flag_R [32]; // differential SCF used? + mpc_int32_t SCFI_L [32]; + mpc_int32_t SCFI_R [32]; // describes order of transmitted SCF + mpc_int32_t DSCF_Reference_L [32]; + mpc_int32_t DSCF_Reference_R [32]; // holds last frames SCF + mpc_int32_t MS_Flag[32]; // MS used? +#ifdef MPC_FIXED_POINT + unsigned char SCF_shift[256]; +#endif + + MPC_SAMPLE_FORMAT V_L[MPC_V_MEM + 960]; + MPC_SAMPLE_FORMAT V_R[MPC_V_MEM + 960]; + MPC_SAMPLE_FORMAT Y_L[36][32]; + MPC_SAMPLE_FORMAT Y_R[36][32]; + MPC_SAMPLE_FORMAT SCF[256]; ///< holds adapted scalefactors (for clipping prevention) + //@} + +} mpc_decoder; + +#endif // _mpc_decoder_h diff --git a/src/libmusepack/musepack/huffman.h b/src/libmusepack/musepack/huffman.h new file mode 100644 index 000000000..7f587771f --- /dev/null +++ b/src/libmusepack/musepack/huffman.h @@ -0,0 +1,41 @@ +/// \file huffman.h +/// Data structures and functions for huffman coding. + +#ifndef _musepack_huffman_h_ +#define _musepack_huffman_h_ + +#include "musepack/config_types.h" +#include "musepack/decoder.h" + +struct mpc_decoder_t; // forward declare to break circular dependencies + +/// Huffman table entry. +typedef struct huffman_type_t { + mpc_uint32_t Code; + mpc_uint32_t Length; + mpc_int32_t Value; +} HuffmanTyp; + +//! \brief Sorts huffman-tables by codeword. +//! +//! offset resulting value. +//! \param elements +//! \param Table table to sort +//! \param offset offset of resulting sort +void +mpc_decoder_resort_huff_tables( + const mpc_uint32_t elements, HuffmanTyp *Table, const mpc_int32_t offset); + +/// Initializes sv6 huffman decoding structures. +void mpc_decoder_init_huffman_sv6(struct mpc_decoder_t *d); + +/// Initializes sv6 huffman decoding tables. +void mpc_decoder_init_huffman_sv6_tables(struct mpc_decoder_t *d); + +/// Initializes sv7 huffman decoding structures. +void mpc_decoder_init_huffman_sv7(struct mpc_decoder_t *d); + +/// Initializes sv7 huffman decoding tables. +void mpc_decoder_init_huffman_sv7_tables(struct mpc_decoder_t *d); + +#endif // _musepack_huffman_h_ diff --git a/src/libmusepack/musepack/internal.h b/src/libmusepack/musepack/internal.h new file mode 100644 index 000000000..fce533434 --- /dev/null +++ b/src/libmusepack/musepack/internal.h @@ -0,0 +1,27 @@ +/// \file musepack_internal.h +/// Definitions and structures used only internally by the libmusepack. + +#ifndef _musepack_internal_h +#define _musepack_internal_h + +enum { + MPC_DECODER_SYNTH_DELAY = 481 +}; + +/// 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); +} + +/// Searches for a ID3v2-tag and reads the length (in bytes) of it. +/// \param reader supplying raw stream data +/// \return size of tag, in bytes +/// \return -1 on errors of any kind +mpc_int32_t JumpID3v2(mpc_reader* fp); + +#endif // _musepack_internal_h + diff --git a/src/libmusepack/musepack/math.h b/src/libmusepack/musepack/math.h new file mode 100644 index 000000000..f3d52c504 --- /dev/null +++ b/src/libmusepack/musepack/math.h @@ -0,0 +1,110 @@ +/// \file mpc_math.h +/// Libmusepack internal math routines. + +#ifndef _musepack_math_h_ +#define _musepack_math_h_ + +//#define MPC_FIXED_POINT + +#define MPC_FIXED_POINT_SHIFT 16 + +#ifdef MPC_FIXED_POINT + + +#ifdef _WIN32_WCE + +#include <cmnintrin.h> + +#define MPC_HAVE_MULHIGH + +#endif + + +#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)) + + +//in fixedpoint mode, results in decode output buffer are in -MPC_FIXED_POINT_SCALE ... MPC_FIXED_POINT_SCALE range + +#define MPC_FIXED_POINT_FRACTPART 14 +typedef mpc_int32_t MPC_SAMPLE_FORMAT; + +typedef mpc_int64_t MPC_SAMPLE_FORMAT_MULTIPLY; + +#define MAKE_MPC_SAMPLE(X) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((mpc_int64_t)1)<<MPC_FIXED_POINT_FRACTPART)) +#define MAKE_MPC_SAMPLE_EX(X,Y) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((mpc_int64_t)1)<<(Y))) + +#define MPC_MULTIPLY_NOTRUNCATE(X,Y) \ + (((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> MPC_FIXED_POINT_FRACTPART) + +#define MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z) \ + (((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> (Z)) + +#ifdef _DEBUG +static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2) +{ + MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_NOTRUNCATE(item1,item2); + assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp); + return (MPC_SAMPLE_FORMAT)temp; +} + +static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY_EX(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2,unsigned shift) +{ + MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_EX_NOTRUNCATE(item1,item2,shift); + assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp); + return (MPC_SAMPLE_FORMAT)temp; +} + +#else + +#define MPC_MULTIPLY(X,Y) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_NOTRUNCATE(X,Y)) +#define MPC_MULTIPLY_EX(X,Y,Z) ((MPC_SAMPLE_FORMAT)MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z)) + +#endif + +#ifdef MPC_HAVE_MULHIGH +#define MPC_MULTIPLY_FRACT(X,Y) _MulHigh(X,Y) +#else +#define MPC_MULTIPLY_FRACT(X,Y) MPC_MULTIPLY_EX(X,Y,32) +#endif + +#define MPC_MAKE_FRACT_CONST(X) (MPC_SAMPLE_FORMAT)((X) * (double)(((mpc_int64_t)1)<<32) ) +#define MPC_MULTIPLY_FRACT_CONST(X,Y) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST(Y)) +#define MPC_MULTIPLY_FRACT_CONST_FIX(X,Y,Z) ( MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y / (1<<(Z)) )) << (Z) ) +#define MPC_MULTIPLY_FRACT_CONST_SHR(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y / (1<<(Z)) )) + +#define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y)) +#define MPC_SCALE_CONST(X,Y,Z) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z)) +#define MPC_SCALE_CONST_SHL(X,Y,Z,S) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z)-(S)) +#define MPC_SCALE_CONST_SHR(X,Y,Z,S) MPC_MULTIPLY_EX(X,MAKE_MPC_SAMPLE_EX(Y,Z),(Z)+(S)) +#define MPC_SHR(X,Y) ((X)>>(Y)) +#define MPC_SHL(X,Y) ((X)<<(Y)) + +#else + +//in floating-point mode, decoded samples are in -1...1 range + +typedef float MPC_SAMPLE_FORMAT; + +#define MAKE_MPC_SAMPLE(X) ((MPC_SAMPLE_FORMAT)(X)) +#define MAKE_MPC_SAMPLE_EX(X,Y) ((MPC_SAMPLE_FORMAT)(X)) + +#define MPC_MULTIPLY_FRACT(X,Y) ((X)*(Y)) +#define MPC_MAKE_FRACT_CONST(X) (X) +#define MPC_MULTIPLY_FRACT_CONST(X,Y) MPC_MULTPLY_FRACT(X,MPC_MAKE_FRACT_CONST(Y)) +#define MPC_MULTIPLY_FRACT_CONST_SHR(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y )) +#define MPC_MULTIPLY_FRACT_CONST_FIX(X,Y,Z) MPC_MULTIPLY_FRACT(X,MPC_MAKE_FRACT_CONST( Y )) + +#define MPC_MULTIPLY_FLOAT_INT(X,Y) ((X)*(Y)) +#define MPC_MULTIPLY(X,Y) ((X)*(Y)) +#define MPC_MULTIPLY_EX(X,Y,Z) ((X)*(Y)) +#define MPC_SCALE_CONST(X,Y,Z) ((X)*(Y)) +#define MPC_SCALE_CONST_SHL(X,Y,Z,S) ((X)*(Y)) +#define MPC_SCALE_CONST_SHR(X,Y,Z,S) ((X)*(Y)) +#define MPC_SHR(X,Y) (X) +#define MPC_SHL(X,Y) (X) + +#endif + +#endif // _musepack_math_h_ + diff --git a/src/libmusepack/musepack/musepack.h b/src/libmusepack/musepack/musepack.h new file mode 100644 index 000000000..b84cf3513 --- /dev/null +++ b/src/libmusepack/musepack/musepack.h @@ -0,0 +1,94 @@ +/// \file musepack.h +/// Top level include file for libmusepack. + +#ifndef _musepack_h_ +#define _musepack_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include "musepack/config_types.h" +#include "musepack/decoder.h" +#include "musepack/math.h" +#include "musepack/reader.h" +#include "musepack/streaminfo.h" + +enum { + MPC_FRAME_LENGTH = (36 * 32), /// samples per mpc frame + MPC_DECODER_BUFFER_LENGTH = 4 * MPC_FRAME_LENGTH /// required buffer size for decoder +}; + +// error codes +#define ERROR_CODE_OK 0 +#define ERROR_CODE_FILE -1 +#define ERROR_CODE_SV7BETA 1 +#define ERROR_CODE_CBR 2 +#define ERROR_CODE_IS 3 +#define ERROR_CODE_BLOCKSIZE 4 +#define ERROR_CODE_INVALIDSV 5 + +/// Initializes a streaminfo structure. +/// \param si streaminfo structure to initialize +void mpc_streaminfo_init(mpc_streaminfo *si); + +/// Reads streaminfo header from the mpc stream supplied by r. +/// \param si streaminfo pointer to which info will be written +/// \param r stream reader to supply raw data +/// \return error code +mpc_int32_t mpc_streaminfo_read(mpc_streaminfo *si, mpc_reader *r); + +/// Gets length of stream si, in seconds. +/// \return length of stream in seconds +double mpc_streaminfo_get_length(mpc_streaminfo *si); + +/// Returns length of stream si, in samples. +/// \return length of stream in samples +mpc_int64_t mpc_streaminfo_get_length_samples(mpc_streaminfo *si); + +/// Sets up decoder library. +/// Call this first when preparing to decode an mpc stream. +/// \param r reader that will supply raw data to the decoder +void mpc_decoder_setup(mpc_decoder *d, mpc_reader *r); + +/// Initializes mpc decoder with the supplied stream info parameters. +/// Call this next after calling mpc_decoder_setup. +/// \param si streaminfo structure indicating format of source stream +/// \return TRUE if decoder was initalized successfully, FALSE otherwise +BOOL mpc_decoder_initialize(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 +void mpc_decoder_scale_output(mpc_decoder *d, double scale_factor); + +/// Actually reads data from previously initialized stream. Call +/// this iteratively to decode the mpc stream. +/// \param buffer destination buffer for decoded samples +/// \param vbr_update_acc \todo document me +/// \param vbr_update_bits \todo document me +/// \return -1 if an error is encountered +/// \return 0 if the stream has been completely decoded successfully and there are no more samples +/// \return > 0 to indicate the number of bytes that were actually read from the stream. +mpc_uint32_t mpc_decoder_decode( + mpc_decoder *d, + MPC_SAMPLE_FORMAT *buffer, + mpc_uint32_t *vbr_update_acc, + mpc_uint32_t *vbr_update_bits); + +/// Seeks to the specified sample in the source stream. +BOOL mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample); + +/// Seeks to specified position in seconds in the source stream. +BOOL mpc_decoder_seek_seconds(mpc_decoder *d, double seconds); + +#ifdef __cplusplus +} +#endif // __cplusplus + +#endif // _musepack_h_ diff --git a/src/libmusepack/musepack/reader.h b/src/libmusepack/musepack/reader.h new file mode 100644 index 000000000..00aae830d --- /dev/null +++ b/src/libmusepack/musepack/reader.h @@ -0,0 +1,46 @@ +/// \file reader.h + +#ifndef _musepack_reader_h_ +#define _musepack_reader_h_ + +/// \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 { + /// Reads size bytes of data into buffer at ptr. + mpc_int32_t (*read)(void *t, void *ptr, mpc_int32_t size); + + /// Seeks to byte position offset. + BOOL (*seek)(void *t, mpc_int32_t offset); + + /// Returns the current byte offset in the stream. + mpc_int32_t (*tell)(void *t); + + /// Returns the total length of the source stream, in bytes. + mpc_int32_t (*get_size)(void *t); + + /// True if the stream is a seekable stream. + BOOL (*canseek)(void *t); + + /// Optional field that can be used to identify a particular instance of + /// reader or carry along data associated with that reader. + void *data; + + // These are used by provided internal standard file-based reader implementation. + // You shouldn't touch them. They're included in the main struct to avoid + // malloc/free. + FILE *file; + long file_size; + BOOL is_seekable; +} mpc_reader; + +/// Initializes reader with default stdio file reader implementation. Use +/// this if you're just reading from a plain file. +/// +/// \param r reader struct to initalize +/// \param input input stream to attach to the reader +void mpc_reader_setup_file_reader(mpc_reader *r, FILE *input); + +#endif // _musepack_reader_h_ diff --git a/src/libmusepack/musepack/requant.h b/src/libmusepack/musepack/requant.h new file mode 100644 index 000000000..dc9a5c32f --- /dev/null +++ b/src/libmusepack/musepack/requant.h @@ -0,0 +1,17 @@ +/// \file requant.h +/// Requantization function definitions. + +#ifndef _musepack_requant_h +#define _musepack_requant_h_ + +#include "musepack/musepack.h" + +/* C O N S T A N T S */ +extern const mpc_uint32_t Res_bit [18]; // bits per sample for chosen quantizer +extern const MPC_SAMPLE_FORMAT __Cc [1 + 18]; // coefficients for requantization +extern const mpc_int32_t __Dc [1 + 18]; // offset for requantization + +#define Cc (__Cc + 1) +#define Dc (__Dc + 1) + +#endif // _musepack_requant_h_ diff --git a/src/libmusepack/musepack/streaminfo.h b/src/libmusepack/musepack/streaminfo.h new file mode 100644 index 000000000..dc8e77c22 --- /dev/null +++ b/src/libmusepack/musepack/streaminfo.h @@ -0,0 +1,52 @@ +/// \file streaminfo.h + +#ifndef _musepack_streaminfo_h_ +#define _musepack_streaminfo_h_ + +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_streaminfo_off_t header_position; ///< byte offset of position of header 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 frames; ///< number of frames in stream + mpc_int64_t pcm_samples; + mpc_uint32_t max_band; ///< maximum band-index used in stream (0...31) + mpc_uint32_t is; ///< intensity stereo (0: off, 1: on) + mpc_uint32_t ms; ///< mid/side stereo (0: off, 1: on) + mpc_uint32_t block_size; ///< only needed for SV4...SV6 -> not supported + mpc_uint32_t profile; ///< quality profile of stream + const char* profile_name; ///< name of profile used by stream + //@} + + /// @name replaygain related fields + //@{ + mpc_int16_t gain_title; ///< replaygain title value + mpc_int16_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 support data + //@{ + mpc_uint32_t is_true_gapless; ///< true gapless? (0: no, 1: yes) + mpc_uint32_t last_frame_samples; ///< number of valid samples within last frame + + mpc_uint32_t encoder_version; ///< version of encoder used + char encoder[256]; ///< encoder name + + mpc_streaminfo_off_t tag_offset; ///< offset to file tags + mpc_streaminfo_off_t total_file_length; ///< total length of underlying file + //@} +} mpc_streaminfo; + +#endif // _musepack_streaminfo_h_ |