Initial community commit

This commit is contained in:
Jef
2024-09-24 14:54:57 +02:00
parent 537bcbc862
commit 20d28e80a5
16810 changed files with 4640254 additions and 2 deletions

View File

@ -0,0 +1,69 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: bitsequence.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1997-12-23
* contents/description: HEADER - bitsequence object
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:01 $
* $Id: bitsequence.h,v 1.1 2010/11/17 20:46:01 audiodsp Exp $
*/
#ifndef __BITSEQUENCE_H__
#define __BITSEQUENCE_H__
/* ------------------------ includes --------------------------------------*/
#include "bitstream.h"
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*/
//
// Bitstream parser class.
//
// This helper class is basically a numerical value that can read itself from
// a CBitStream interface for convenience. The decoder almost completely
// does the bitstream parsing through CBitSequence rather than CBitStream
// directly.
//
class CBitSequence
{
public:
CBitSequence(int nBits = 0) { m_nBits = nBits; m_nValue = 0; }
virtual ~CBitSequence() {}
void SetNumberOfBits(int nBits) { m_nBits = nBits; }
int GetNumberOfBits() const { return m_nBits; }
bool ReadFrom(CBitStream &Bs) { m_nValue = Bs.GetBits(m_nBits); return true; }
bool ReadFrom_Bit(CBitStream &Bs) { m_nValue = Bs.Get1Bit(); return true; }
bool ReadFrom(CBitStream &Bs, int nBits) { SetNumberOfBits(nBits); return ReadFrom(Bs); }
bool Equals(int nValue) const { return (m_nValue == nValue); }
int ToInt() const { return m_nValue; }
void FromInt(int nValue) { m_nValue = nValue; }
protected:
private:
int m_nBits;
int m_nValue;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,103 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: bitstream.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1997-12-05
* contents/description: generic bitbuffer - HEADER
*
*
\***************************************************************************/
/*
* $Date: 2011/01/18 18:22:02 $
* $Id: bitstream.h,v 1.4 2011/01/18 18:22:02 audiodsp Exp $
*/
#ifndef __BITSTREAM_H__
#define __BITSTREAM_H__
/* ------------------------ includes --------------------------------------*/
/*-------------------------- defines --------------------------------------*/
class CGioBase;
/*-------------------------------------------------------------------------*/
//
// Bitstream input class.
//
// This class defines the interface that the mp3 decoder object will
// read all of its bitstream input data from.
//
class CBitStream
{
public:
CBitStream(int cbSize);
CBitStream(unsigned char *pBuf, int cbSize, bool fDataValid = false);
virtual ~CBitStream();
virtual void Reset();
bool ByteAligned() const { return !(m_BitNdx & 7); }
bool ResetOccurred() { return m_ResetOccurred; }
void SetResetState(bool state) { m_ResetOccurred = state; }
void Connect(CGioBase *pGB);
void ResetBitCnt() { m_BitCnt = 0; }
int GetBitCnt() const { return m_BitCnt; }
unsigned int GetBits(unsigned int nBits); // gets 16 bits or less
unsigned int GetBits8(unsigned int nBits); // gets 8 bits or less
unsigned int Get1Bit();
unsigned long Get32Bits();
bool Ff(int nBits) { return ( (nBits > 0) ? Seek(nBits) : false); }
bool Rewind(int nBits) { return ( (nBits > 0) ? Seek(-nBits) : false); }
bool Seek(int nBits)
{
m_BitCnt += nBits;
m_ValidBits -= nBits;
m_BitNdx = (m_BitNdx+nBits) & m_bitMask;
return true;
}
int GetValidBits() const { return m_ValidBits; }
int GetFree() const;
void SetEof();
int Fill(const unsigned char *pBuf, int cbSize);
int Fill(CBitStream &Bs, int cbSize);
protected:
int Refill();
bool IsEof() const;
bool IsConnected() const;
private:
CGioBase *m_pGB; // I/O object
int m_nBytes; // size of buffer in bytes
int m_mask;
int m_nBits; // size of buffer in bits
int m_bitMask;
int m_ValidBits; // valid bits in buffer
int m_ReadOffset; // where to write next
int m_BitCnt; // bit counter
int m_BitNdx; // position of next bit in byte
bool m_fEof; // indication of input eof
unsigned char *m_Buf; // the buffer
bool m_fBufferIntern; // did we allocate the buffer ourselves
bool m_ResetOccurred; // reset just occurred, only for dynamic buffer used
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,137 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: conceal.h
* project : ISO/MPEG-Decoder
* author : Stefan Gewinner
* date : 1998-05-26
* contents/description: error concealment class - HEADER
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:02 $
* $Id: conceal.h,v 1.1 2010/11/17 20:46:02 audiodsp Exp $
*/
#ifndef __CONCEAL_H__
#define __CONCEAL_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
/*-------------------------------------------------------------------------*/
//
// Error concealment class.
//
// This object is used to apply error concealment to a spectrum in case of
// CRC errors. CRC protection is optional for ISO/MPEG bitstreams.
//
class CErrorConcealment
{
public:
CErrorConcealment();
~CErrorConcealment() {}
void Init();
void Apply
(
bool fApply, // true: restore, false: store
const MPEG_INFO &Info,
MP3SI &Si,
float *lpSpec,
int gr,
int ch
);
enum { MAX_SPECTRUM_DATA = 4 };
protected :
//
// structure to hold information for one granule
//
typedef struct tagGRAN_DATA
{
MP3SI_GRCH gr; /* side info */
float Rs[SBLIMIT*SSLIMIT]; /* line amplitudes */
float nrg[23]; /* sf-band energies */
int nrgValid; /* valid-flag for sf-band energies */
#ifdef DEBUG_CONCEALMENT
long frameNumber;
#endif
} GRAN_DATA;
//
// structure for concealment data
//
typedef struct tagSPECTRUM_DATA
{
int writeOffset; /* place to store next valid granule */
GRAN_DATA gran[MAX_SPECTRUM_DATA]; /* ring buffer */
GRAN_DATA estGran;
} SPECTRUM_DATA;
SPECTRUM_DATA SpecDataBuffer[2]; /* one buffer for each channel */
void Store
(
const MPEG_INFO &Info,
const MP3SI &Si,
const float *lpSpec,
int gr,
int ch
);
void Restore
(
const MPEG_INFO &Info,
MP3SI &Si,
float *lpSpec,
int gr,
int ch
);
#ifdef USE_ENERGY_PREDICTION
float predict(const float *hist, const float *coff, int n);
void adaptPredictor(const float *hist, float pwr, float *coff, float d, int n);
#endif
void estimateBandEnergies(const MPEG_INFO &Info, GRAN_DATA *g);
void predictEnergies(const MPEG_INFO &Info, SPECTRUM_DATA *s);
//
// random seeds for the float and bit random generators
//
float ranHigh1(float a);
float ranHigh2(float a);
float ranLow(float a);
float ran3(long *idum);
int irbit2(unsigned long *iseed);
int inext;
int inextp;
long ma [56];
int iff ;
long f_seed, w_seed ;
unsigned long b_seed ;
#ifdef DEBUG_CONCEALMENT
long currentFrame ;
#endif
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,35 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: crc16.h
* project : ISO/MPEG decoder
* author : Martin Sieler
* date : 1998-05-26
* contents/description: functions to calculate a CRC-16
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:02 $
* $Id: crc16.h,v 1.1 2010/11/17 20:46:02 audiodsp Exp $
*/
#ifndef __CRC16_H__
#define __CRC16_H__
/* ------------------------ includes --------------------------------------*/
/* ------------------------------------------------------------------------*/
class CBitStream;
/* ------------------------------------------------------------------------*/
unsigned int CalcCrc(CBitStream &Bs, int len, unsigned int start);
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,46 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: giobase.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1998-02-11
* contents/description: HEADER - basic I/O class for MPEG Decoder
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:02 $
* $Id: giobase.h,v 1.1 2010/11/17 20:46:02 audiodsp Exp $
*/
#ifndef __GIOBASE_H__
#define __GIOBASE_H__
/* ------------------------ includes --------------------------------------*/
#include "mp3sscdef.h"
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*/
class CGioBase
{
public:
virtual SSC Read(void *pBuffer, int cbToRead, int *pcbRead) = 0;
virtual bool IsEof() const = 0;
protected:
~CGioBase() {}
private:
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,57 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: huffdec.h
* project : ISO/MPEG Decoder
* author : Martin Sieler
* date : 1998-05-26
* contents/description: main hufman decoding - HEADER
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:02 $
* $Id: huffdec.h,v 1.1 2010/11/17 20:46:02 audiodsp Exp $
*/
#ifndef __HUFFDEC_H__
#define __HUFFDEC_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
#include "huffmandecoder.h"
/* ------------------------------------------------------------------------*/
//
// MPEG Layer-3 huffman decoding class.
//
// This class is derived from a CHuffmanDecoder object. In addition to
// the CHuffmanDecoder object, this object calculates the number of
// spectral lines in the big value area, the number of spectral lines in the
// count-one area and the region boundaries within the big value area from
// an MPEG Layer-3 bitstream sideinfo.
//
class CMp3Huffman : protected CHuffmanDecoder
{
public:
CMp3Huffman() {}
~CMp3Huffman() {}
void Read
(
CBitStream &Bs, // where to read from
int *pISpectrum, // pointer to spectrum
MP3SI_GRCH &SiGrCh, // side info (granule/channel)
const MPEG_INFO &Info // mpeg info
);
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,54 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: huffmanbitobj.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1997-12-29
* contents/description: HEADER - Huffman Bit Object
*
*
\***************************************************************************/
/*
* $Date: 2011/01/18 23:00:53 $
* $Id: huffmanbitobj.h,v 1.3 2011/01/18 23:00:53 audiodsp Exp $
*/
#ifndef __HUFFMANBITOBJ_H__
#define __HUFFMANBITOBJ_H__
/* ------------------------ includes --------------------------------------*/
/*-------------------------- defines --------------------------------------*/
class CBitStream;
class CHuffmanTable;
/*-------------------------------------------------------------------------*/
//
// Class holding one huffman value.
//
// This object reads and decodes one huffman value from a CBitStream
// object. One huffman value represents either two (big value part) or four
// spectral lines (count-one part).
//
class CHuffmanBitObj
{
public:
CHuffmanBitObj(const CHuffmanTable &HT);
virtual ~CHuffmanBitObj();
int ReadFrom(CBitStream &BS) const;
private:
const CHuffmanTable& m_HuffmanTable;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,85 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: huffmandecoder.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1998-02-08
* contents/description: HEADER - huffman decoder
*
*
\***************************************************************************/
/*
* $Date: 2011/01/21 22:25:58 $
* $Id: huffmandecoder.h,v 1.4 2011/01/21 22:25:58 audiodsp Exp $
*/
#ifndef __HUFFMANDECODER_H__
#define __HUFFMANDECODER_H__
/* ------------------------ includes --------------------------------------*/
#include "bitsequence.h"
#include "huffmanbitobj.h"
#include "huffmantable.h"
/*-------------------------- defines --------------------------------------*/
class CBitStream;
/*-------------------------------------------------------------------------*/
//
// Huffman decoder (helper) class.
//
// This object reads and decodes MPEG Layer-3 huffman data.
//
class CHuffmanDecoder
{
public:
CHuffmanDecoder();
virtual ~CHuffmanDecoder();
int ReadHuffmanCode(CBitStream &Bs,
int *pIsp,
const int *pTableSelect,
const int *pRegionEnd,
int Count1TableSelect,
int Part2_3Length);
protected:
private:
int ReadBigValues(CBitStream &Bs,
int *pIsp,
const int *pTableSelect,
const int *pRegionEnd);
int ReadCount1Area(CBitStream &Bs,
int *pIsp,
int Count1TableSelect,
int Count1Start,
int Part2_3Length);
#ifdef _MSC_VER
// these only have one caller and inlining shows notable improvements in the profiler
__forceinline void ReadHuffmanDual (CBitStream &Bs, int *pIsp);
__forceinline void ReadHuffmanDualLin(CBitStream &Bs, int *pIsp);
__forceinline bool ReadHuffmanQuad (CBitStream &Bs, int *pIsp);
#else
void ReadHuffmanDual (CBitStream &Bs, int *pIsp);
void ReadHuffmanDualLin(CBitStream &Bs, int *pIsp);
bool ReadHuffmanQuad (CBitStream &Bs, int *pIsp);
#endif
CHuffmanTable m_HuffmanTable;
CHuffmanBitObj m_HuffmanBitObj;
CBitSequence m_LinBits;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,102 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: huffmantable.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1998-01-05
* contents/description: HEADER - huffman table object
*
*
\***************************************************************************/
/*
* $Date: 2011/01/18 23:00:53 $
* $Id: huffmantable.h,v 1.3 2011/01/18 23:00:53 audiodsp Exp $
*/
#ifndef __HUFFMANTABLE_H__
#define __HUFFMANTABLE_H__
/* ------------------------ includes --------------------------------------*/
/*-------------------------- defines --------------------------------------*/
#define HUFFMAN_BITS_4
/*-------------------------------------------------------------------------*/
// Huffman tables.
//
// This object holds the huffman table for ISO/MPEG Layer-3.
//
typedef struct
{
const unsigned char length;
const unsigned char value;
} huffman_entry_t;
class CHuffmanTable
{
public:
/*unsigned int nTableIndex; */
CHuffmanTable();
virtual ~CHuffmanTable();
void SetTableIndex(unsigned int _nTableIndex)
{ nTableIndex = _nTableIndex; }
unsigned int GetBitsPerLevel() const
{ return BITS_PER_LEVEL; }
unsigned int GetLinBits() const
{ return ht[nTableIndex].linbits; }
unsigned char GetCode (unsigned int nIndex, unsigned int nValue) const
{ return (ht[nTableIndex].table[nIndex][nValue] & 0xff); }
unsigned char GetLength(unsigned int nIndex, unsigned int nValue) const
{ return ((ht[nTableIndex].table[nIndex][nValue] >> 8) & 0xff); }
bool IsTableValid() const
{ return (ht[nTableIndex].table ? true:false); }
bool IsLengthZero(unsigned int nIndex, unsigned int nValue) const
{ return ((ht[nTableIndex].table[nIndex][nValue] & 0xff00) == 0); }
enum
{
#if defined HUFFMAN_BITS_2 /* HuffmanBits parallel huffman tables */
BITS_PER_LEVEL = 2,
ENTRIES_PER_LEVEL = 4
#elif defined HUFFMAN_BITS_3
BITS_PER_LEVEL = 3,
ENTRIES_PER_LEVEL = 8
#elif defined HUFFMAN_BITS_4 /* HuffmanBits parallel huffman tables */
BITS_PER_LEVEL = 4,
ENTRIES_PER_LEVEL = 16
#endif
};
protected:
private:
typedef struct
{
unsigned int linbits;
const unsigned short(*table)[ENTRIES_PER_LEVEL];
} huffmantab;
static const huffmantab ht[];
unsigned int nTableIndex;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,112 @@
/***************************************************************************\
*
* (C) copyright Fraunhofer - IIS (1996)
* All Rights Reserved
*
* filename: l3reg.h
* project : <none>
* author : Martin Sieler
* date : 1996-11-05
* contents/description: HEADER - registered types for MPEG Layer-3
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:02 $
* $Header: /cvs/root/nullsoft/Replicant/jni/nsmp3/l3reg.h,v 1.1 2010/11/17 20:46:02 audiodsp Exp $
*/
#ifndef __L3REG_H__
#define __L3REG_H__
/* ------------------------ includes --------------------------------------*/
/*-------------------------- defines --------------------------------------*/
#ifdef _MSC_VER
#pragma pack(push, 1) /* assume byte packing throughout */
#endif
/*-------------------------------------------------------------------------*/
//==========================================================================;
//
// ISO/MPEG Layer3 Format Tag
//
#define WAVE_FORMAT_MPEGLAYER3 0x0055
//==========================================================================;
//
// Manufacturer ID and Product ID
//
#define MM_FRAUNHOFER_IIS 172
#define MM_FHGIIS_MPEGLAYER3 10
#define MM_FHGIIS_MPEGLAYER3_DECODE 9
#define MM_FHGIIS_MPEGLAYER3_LITE 10
#define MM_FHGIIS_MPEGLAYER3_BASIC 11
#define MM_FHGIIS_MPEGLAYER3_ADVANCED 12
#define MM_FHGIIS_MPEGLAYER3_PROFESSIONAL 13
#define MM_FHGIIS_MPEGLAYER3_ADVANCEDPLUS 14
//==========================================================================;
//
//
//
//==========================================================================;
#ifdef MPEGLAYER3_WFX_EXTRA_BYTES
//
// seems like the structure below is already defined
//
#else
//==========================================================================;
//
// MPEG Layer3 WAVEFORMATEX structure
//
#define MPEGLAYER3_WFX_EXTRA_BYTES 12
// WAVE_FORMAT_MPEGLAYER3 format structure
//
typedef struct tagMPEGLAYER3WAVEFORMAT
{
WAVEFORMATEX wfx;
WORD wID;
DWORD fdwFlags;
WORD nBlockSize;
WORD nFramesPerBlock;
WORD nCodecDelay;
} MPEGLAYER3WAVEFORMAT;
typedef MPEGLAYER3WAVEFORMAT * PMPEGLAYER3WAVEFORMAT;
typedef MPEGLAYER3WAVEFORMAT NEAR *NPMPEGLAYER3WAVEFORMAT;
typedef MPEGLAYER3WAVEFORMAT FAR *LPMPEGLAYER3WAVEFORMAT;
#endif
//==========================================================================;
#define MPEGLAYER3_ID_UNKNOWN 0
#define MPEGLAYER3_ID_MPEG 1
#define MPEGLAYER3_ID_CONSTANTFRAMESIZE 2
#define MPEGLAYER3_FLAG_PADDING_ISO 0x00000000
#define MPEGLAYER3_FLAG_PADDING_ON 0x00000001
#define MPEGLAYER3_FLAG_PADDING_OFF 0x00000002
#define MPEGLAYER3_FLAG_CRC_ON 0x00000010
#define MPEGLAYER3_FLAG_CRC_OFF 0x00000020
#define MPEGLAYER3_FLAG_VBR 0x00000100
/*-------------------------------------------------------------------------*/
#ifdef _MSC_VER
#pragma pack(pop) /* revert to previous packing */
#endif
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,47 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: l3table.h
* project : ISO/MPEG-Decoder
* author : Martin Sieler
* date : 1998-05-26
* contents/description: HEADER - tables for iso/mpeg-decoding (layer3)
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:02 $
* $Id: l3table.h,v 1.1 2010/11/17 20:46:02 audiodsp Exp $
*/
/*-------------------------------------------------------------------------*/
#ifndef __L3TABLE_H__
#define __L3TABLE_H__
#ifdef __cplusplus
extern "C" {
#endif
/* ------------------------ includes --------------------------------------*/
/* ------------------------------------------------------------------------*/
struct SF_BAND_INDEX
{
int l[23];
int s[14];
};
/* ------------------------------------------------------------------------*/
extern const SF_BAND_INDEX sfBandIndex[3][3];
/*-------------------------------------------------------------------------*/
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,61 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mdct.h
* project : ISO/MPEG-Decoder
* author : Stefan Gewinner
* date : 1998-05-26
* contents/description: mdct class - HEADER
*
*
\***************************************************************************/
/*
* $Date: 2011/01/18 18:22:03 $
* $Id: mdct.h,v 1.4 2011/01/18 18:22:03 audiodsp Exp $
*/
#ifndef __MDCT_H__
#define __MDCT_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
#include "foundation/align.h"
/*-------------------------------------------------------------------------*/
//
// MDCT class.
//
// This object performs the frequency-to-time mapping.
//
class CMdct
{
public :
CMdct(const MPEG_INFO &_info);
~CMdct() {}
void Init();
void Apply(int ch, const MP3SI_GRCH &SiGrCH, SPECTRUM &rs);
protected :
void cos_t_h_long (float *prev,float *dest,const float *win);
void cos_t_h_short(float *prev,float *dest,const float *win);
float hybrid_res[36];
NALIGN(16) float cost36_rese[9];
NALIGN(16) float cost36_reso[9];
const MPEG_INFO &info;
SPECTRUM prevblck;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,61 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: meanvalue.h
* project : ---
* author : Martin Sieler
* date : 1998-02-14
* contents/description: HEADER - calc mean value
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:03 $
* $Id: meanvalue.h,v 1.1 2010/11/17 20:46:03 audiodsp Exp $
*/
#ifndef __MEANVALUE_H__
#define __MEANVALUE_H__
/* ------------------------ includes --------------------------------------*/
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*/
class CMeanValue
{
public:
CMeanValue() { Reset(); }
void Reset();
CMeanValue& operator+= (int nValue);
operator int() const { return m_Count ? m_Sum/m_Count : 0; }
operator float() const { return m_Count ? float(m_Sum)/float(m_Count) : 0.0f; }
int GetSum() const { return m_Sum; }
int GetCount() const { return m_Count; }
int GetMin() const { return m_Min; }
int GetMax() const { return m_Max; }
bool IsFixed() const { return m_bFixed; }
protected:
private:
int m_Count;
int m_Sum;
int m_FirstValue;
int m_Min;
int m_Max;
bool m_bFixed;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,50 @@
#ifndef __MP2DECODE_H__
#define __MP2DECODE_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
#include "mpegbitstream.h"
#include "polyphase.h"
/*-------------------------------------------------------------------------*/
//
// MPEG Layer-2 decoding class.
//
// This is the main MPEG Layer-2 decoder object.
//
class CMp2Decode
{
public:
CMp2Decode(CMpegBitStream &_Bs, DecoderHooks *_hooks=0);
~CMp2Decode();
void Init(bool fFullReset = true);
SSC Decode(void *pPcm, size_t cbPcm, size_t *pcbUsed);
private:
SSC Decode2(void *pPcm);
SSC Decode1(void *pPcm);
void ZeroPolySpectrum();
void SetInfo();
CPolyphase m_Polyphase; // polyphase
MPEG_INFO m_Info; // info structure
CMpegBitStream &m_Bs; // bitstream
POLYSPECTRUM m_PolySpectrum; // spectrum (post-mdct)
char m_tab_3[32 * 3];
char m_tab_5[128 * 3];
char m_tab_9[1024 * 3];
float m_scales[27][64];
DecoderHooks *hooks;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,86 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp3ancofl.h
* project : MPEG Decoder
* author : Dieter Weninger
* date : 2003-05-14
* contents: ancillary data and original file length - HEADER
*
\***************************************************************************/
#ifndef __MP3ANCOFL_H__
#define __MP3ANCOFL_H__
#include "mpegbitstream.h"
#define ID_OFL 0xB
#define VERSION_0_LEN 8 /* bytes */
#define VERSION_1_LEN 10 /* bytes */
class CMp3AncOfl
{
public:
CMp3AncOfl(CBitStream &__Db);
~CMp3AncOfl();
void Reset(void);
int getVersion(void);
unsigned int getTotalLength(void);
unsigned int getCodecDelay(void);
unsigned int getAddDelay(void);
bool validOfl(void);
void fetchOfl(int oflOn,
CBitStream &Db,
int beforeScf,
unsigned int* startDelay,
unsigned int* totalLength);
int readAnc(unsigned char *ancBytes,
CBitStream &Db,
const int numAncBits);
int doReadBytes(){return m_readBytes;}
private:
void crcOfl(unsigned short crcPoly,
unsigned short crcMask,
unsigned long *crc,
unsigned char byte);
void cleanUp(void);
bool isFhGAnc( int size);
bool readOfl(CBitStream &Db, int beforeScaleFactors);
bool isOfl(void);
bool justSearched(void);
int toSkip(void);
void getOfl(CBitStream &Db, const int len);
CBitStream &m_Db; // dynamic buffer
unsigned char oflArray[10];
bool m_valid;
bool m_searched;
bool m_semaphor;
bool m_FhGAncChecked;
bool m_collecting;
bool m_mp3pro;
unsigned char* m_FhGAncBuf;
unsigned char* m_tmpAncBuf;
int m_pFhGAncBuf;
int m_FhGAncBufSize;
// flag signalling byte- or bit-wise reading
int m_readBytes;
};
#endif /* __MP3ANCOFL_H__ */

View File

@ -0,0 +1,113 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp3decode.h
* project : ISO/MPEG-Decoder
* author : Martin Sieler
* date : 1998-05-26
* contents/description: MPEG Layer-3 decoder
*
*
\***************************************************************************/
/*
* $Date: 2011/01/28 21:45:29 $
* $Id: mp3decode.h,v 1.5 2011/01/28 21:45:29 audiodsp Exp $
*/
#ifndef __MP3DECODE_H__
#define __MP3DECODE_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
#include "mpegbitstream.h"
#include "huffdec.h"
#include "mdct.h"
#include "polyphase.h"
#include "mp3ancofl.h"
#ifdef ERROR_CONCEALMENT
#include "conceal.h"
#endif
/*-------------------------------------------------------------------------*/
//
// MPEG Layer-3 decoding class.
//
// This is the main MPEG Layer-3 decoder object.
//
class NALIGN(16) CMp3Decode
{
public:
CMp3Decode(CMpegBitStream &_Bs, int _crc_check, DecoderHooks *_hooks=0);
~CMp3Decode();
void Init(bool fFullReset = true);
// PcmFormat: 0: integer, 1: 32 bit float (IEEE)
SSC Decode(float *pPcm,
size_t cbPcm,
size_t *pcbUsed,
unsigned char *ancData,
size_t *numAncBytes = 0,
int oflOn = 0,
unsigned int *startDelay = 0,
unsigned int *totalLength = 0);
SSC GetLastAncData(unsigned char* ancData, size_t *numAncBytes);
SSC GetOflVersion(int* oflVersion);
protected:
SSC DecodeOnNoMainData(float *pPcm);
SSC DecodeNormal (float *pPcm, bool fCrcOk);
void PolyphaseReorder();
void ZeroISpectrum();
void ZeroSpectrum();
void ZeroPolySpectrum();
void SetInfo();
CMp3Huffman m_Mp3Huffman; // huffman decoder
CMdct m_Mdct; // mdct
CPolyphase m_Polyphase; // polyphase
CMp3AncOfl m_AncOfl; // ancillary data and ofl
#ifdef ERROR_CONCEALMENT
CErrorConcealment m_Conceal; // error concealment
#endif
MPEG_INFO m_Info; // info structure
CMpegBitStream &m_Bs; // bitstream
CBitStream m_Db; // dynamic buffer
MP3SI m_Si; // side info
MP3SCF m_ScaleFac[2]; // scalefactors
int m_ISpectrum[2][SSLIMIT*SBLIMIT]; // spectrum (integer)
NALIGN(16) SPECTRUM m_Spectrum; // spectrum (float)
NALIGN(16) POLYSPECTRUM m_PolySpectrum; // spectrum (post-mdct)
int m_crc_check; // 0: no CRC check, 1: fail on CRC errors
protected:
enum { dynBufSize = 2048 } ;
unsigned char m_dynBufMemory [dynBufSize] ;
private:
DecoderHooks *hooks;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,25 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp3drmifc.h
* project : MPEG Decoder
* author :
* date : 2004-12-06
* contents/description: DRM Interface
*
*
\***************************************************************************/
#ifndef __MP3DRMIFC_H__
#define __MP3DRMIFC_H__
#include "mp3sscdef.h"
SSC MP3DECAPI mp3decGetScfBuffer(MP3DEC_HANDLE handle,
const unsigned char** ppBuffer,
unsigned int* pBufSize);
#endif /* __MP3DRMIFC_H__ */

View File

@ -0,0 +1,43 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp_quant.h
* project : ISO/MPEG-Decoder
* author : Markus Werner, addings: Martin Sieler
* date : 1995-07-07
* contents/description: HEADER - sample-dequantization
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:04 $
* $Id: mp3quant.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
*/
/*-------------------------------------------------------------------------*/
#ifndef __MP3QUANT_H__
#define __MP3QUANT_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
/* ------------------------------------------------------------------------*/
void mp3DequantizeSpectrum
(
int *pIData,
float *pFData,
const MP3SI_GRCH &SiGrCh,
const MP3SCF &ScaleFac,
const MPEG_INFO &Info
);
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,60 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp3read.h
* project : ISO/MPEG-Decoder
* author : Martin Sieler
* date : 1998-05-26
* contents/description: mp3 read-functions: sideinfo, main data,
* scalefactors
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:04 $
* $Id: mp3read.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
*/
/*-------------------------------------------------------------------------*/
#ifndef __MP3READ_H__
#define __MP3READ_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
/* ------------------------------------------------------------------------*/
class CBitStream;
/* ------------------------------------------------------------------------*/
bool mp3SideInfoRead(CBitStream &Bs, MP3SI &Si, const MPEG_INFO &Info, int crc_check);
bool mp3MainDataRead
(
CBitStream &Bs, // bitstream
CBitStream &Db, // dynamic buffer
const MP3SI &Si,
const MPEG_INFO &Info
);
void mp3ScaleFactorRead
(
CBitStream &Bs,
MP3SI_GRCH &SiGrCh,
MP3SCF &ScaleFac,
const MPEG_INFO &Info,
const int *pScfsi,
int gr,
int ch
);
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,57 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp3ssc.h
* project : ---
* author : Martin Sieler
* date : 1999-02-15
* contents/description: ssc helper class (Structured Status Code)
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:04 $
* $Id: mp3ssc.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
*/
#ifndef __MP3SSC_H__
#define __MP3SSC_H__
/* ------------------------ includes --------------------------------------*/
#include "mp3sscdef.h"
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*/
/** Helper class for more information about SSC codes.
*/
class CMp3Ssc
{
public:
/** Object constructor
@param An SSC staus code to initialize the object with.
*/
CMp3Ssc(SSC ssc);
~CMp3Ssc() {}
/** Operator for conversion to a text string.
@return Textual description.
*/
operator const char*();
private:
SSC m_ssc;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,154 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp3sscdef.h
* project : ---
* author : Martin Sieler
* date : 1998-02-16
* contents/description: ssc definitions (Structured Status Code)
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:04 $
* $Id: mp3sscdef.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
*/
#ifndef __MP3SSCDEF_H__
#define __MP3SSCDEF_H__
/*------------------------- includes --------------------------------------*/
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*\
*
* Standard error/return values are 32 bit values layed out as follows:
*
* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +---+-+-+-----------------------+-------------------------------+
* |Sev|C|R| Handler | Code |
* +---+-+-+-----------------------+-------------------------------+
*
* where
*
* Sev - is the severity code
*
* 00 - Success
* 01 - Informational
* 10 - Warning
* 11 - Error
*
* C - is the Customer code flag
*
* R - is a reserved bit
*
* Handler - is the handler code
*
* Code - is the facility's status code
*
\*-------------------------------------------------------------------------*/
/*
* define the Severity codes
*/
#define SSC_SEV_SUCCESS 0x00000000L
#define SSC_SEV_INFO 0x40000000L
#define SSC_SEV_WARNING 0x80000000L
#define SSC_SEV_ERROR 0xc0000000L
/*
* define masks to extract the fields
*/
#define SSC_MASK_SEVERITY 0xc0000000L
#define SSC_MASK_HANDLER 0x0fff0000L
#define SSC_MASK_CODE 0x0000ffffL
/*
* define MACROS to test an error/return code
*/
#define SSC_GETSEV(x) ( (x) & SSC_MASK_SEVERITY )
/* Check, if an SSC indicates success */
#define SSC_SUCCESS(x) (((SSC_GETSEV(x)==SSC_SEV_SUCCESS)||(SSC_GETSEV(x)==SSC_SEV_INFO))?1:0)
/* Check, if an SSC indicates an information */
#define SSC_INFO(x) ((SSC_GETSEV(x)==SSC_SEV_INFO)?1:0)
/* Check, if an SSC indicates a warning */
#define SSC_WARNING(x) ((SSC_GETSEV(x)==SSC_SEV_WARNING)?1:0)
/* Check, if an SSC indicates an error */
#define SSC_ERROR(x) ((SSC_GETSEV(x)==SSC_SEV_ERROR)?1:0)
/*-------------------------------------------------------------------------*\
*
* SSC classes (handler)
*
\*-------------------------------------------------------------------------*/
#define SSC_HANDLER_GEN 0x00000000L
#define SSC_I_GEN (SSC_SEV_INFO | SSC_HANDLER_GEN)
#define SSC_W_GEN (SSC_SEV_WARNING | SSC_HANDLER_GEN)
#define SSC_E_GEN (SSC_SEV_ERROR | SSC_HANDLER_GEN)
/*-------------------------------------------------------------------------*/
#define SSC_HANDLER_IO 0x00010000L
#define SSC_I_IO (SSC_SEV_INFO | SSC_HANDLER_IO)
#define SSC_W_IO (SSC_SEV_WARNING | SSC_HANDLER_IO)
#define SSC_E_IO (SSC_SEV_ERROR | SSC_HANDLER_IO)
/*-------------------------------------------------------------------------*/
#define SSC_HANDLER_MPGA 0x01010000L
#define SSC_I_MPGA (SSC_SEV_INFO | SSC_HANDLER_MPGA)
#define SSC_W_MPGA (SSC_SEV_WARNING | SSC_HANDLER_MPGA)
#define SSC_E_MPGA (SSC_SEV_ERROR | SSC_HANDLER_MPGA)
/*-------------------------------------------------------------------------*\
*
* SSC codes
*
\*-------------------------------------------------------------------------*/
typedef enum
{
SSC_OK = 0x00000000L,
SSC_E_WRONGPARAMETER = (SSC_E_GEN | 1),
SSC_E_OUTOFMEMORY = (SSC_E_GEN | 2),
SSC_E_INVALIDHANDLE = (SSC_E_GEN | 3),
SSC_E_IO_GENERIC = (SSC_W_IO | 1),
SSC_E_IO_OPENFAILED = (SSC_W_IO | 2),
SSC_E_IO_CLOSEFAILED = (SSC_W_IO | 3),
SSC_E_IO_READFAILED = (SSC_W_IO | 4),
SSC_I_MPGA_CRCERROR = (SSC_I_MPGA | 1),
SSC_I_MPGA_NOMAINDATA = (SSC_I_MPGA | 2),
SSC_E_MPGA_GENERIC = (SSC_E_MPGA | 1),
SSC_E_MPGA_WRONGLAYER = (SSC_E_MPGA | 2),
SSC_E_MPGA_BUFFERTOOSMALL = (SSC_E_MPGA | 3),
SSC_W_MPGA_SYNCSEARCHED = (SSC_W_MPGA | 1),
SSC_W_MPGA_SYNCLOST = (SSC_W_MPGA | 2),
SSC_W_MPGA_SYNCNEEDDATA = (SSC_W_MPGA | 3),
SSC_W_MPGA_SYNCEOF = (SSC_W_MPGA | 4)
} SSC;
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,117 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp3streaminfo.h
* project : MPEG Layer-3 Decoder
* author : Martin Sieler
* date : 1998-05-27
* contents/description: current bitstream parameters
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:04 $
* $Id: mp3streaminfo.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
*/
#ifndef __MP3STREAMINFO_H__
#define __MP3STREAMINFO_H__
/* ------------------------ structure alignment ---------------------------*/
#ifdef WIN32
#pragma pack(push, 8)
#endif
/*-------------------------------------------------------------------------*/
typedef struct
{
int m_Layer; /* ISO/MPEG Layer */
int m_MpegVersion; /* ISO/MPEG Version */
int m_Bitrate; /* Bitrate (Bit/s) */
int m_BitrateIndex; /* ISO/MPEG Bitrate index of frame */
int m_Channels; /* Number of Channels (as indicated) */
int m_SFreq; /* Sampling Frequency (as indicated) */
int m_EffectiveChannels; /* Number of effective output channels */
int m_EffectiveSFreq; /* Effective Sampling Frequency */
int m_BitsPerFrame; /* Number of bits in frame */
float m_Duration; /* Duration of frame in milli seconds */
int m_CrcError; /* Indication of CRC Errors */
int m_NoMainData; /* Indication of missing main data */
int m_SamplesPerFrame;
} MP3STREAMINFO;
/*-------------------------------------------------------------------------*/
#ifdef __cplusplus
//
// Mp3 Streaminfo object.
//
// Object holding information on the last successfully decode frame.
//
class CMp3StreamInfo : protected MP3STREAMINFO
{
public:
CMp3StreamInfo() { Reset(); }
int GetLayer() const { return m_Layer; }
int GetMpegVersion() const { return m_MpegVersion; }
int GetBitrate() const { return m_Bitrate; }
int GetBitrateIndex() const { return m_BitrateIndex; }
int GetChannels() const { return m_Channels; }
int GetSFreq() const { return m_SFreq; }
int GetBitsPerFrame() const { return m_BitsPerFrame; }
float GetDuration() const { return m_Duration; }
int GetCrcError() const { return m_CrcError; }
int GetNoMainData() const { return m_NoMainData; }
int GetSamplesPerFrame() const { return m_SamplesPerFrame; }
protected:
friend class CMpgaDecoder;
void SetLayer(int nValue) { m_Layer = nValue; }
void SetMpegVersion(int nValue) { m_MpegVersion = nValue; }
void SetBitrate(int nValue) { m_Bitrate = nValue; }
void SetBitrateIndex(int nValue) { m_BitrateIndex = nValue; }
void SetChannels(int nValue) { m_Channels = nValue; }
void SetSFreq(int nValue) { m_SFreq = nValue; }
void SetBitsPerFrame(int nValue) { m_BitsPerFrame = nValue; }
void SetDuration(float fValue) { m_Duration = fValue; }
void SetCrcError(int nValue) { m_CrcError = nValue; }
void SetNoMainData(int nValue) { m_NoMainData = nValue; }
void SetSamplesPerFrame(int nValue) { m_SamplesPerFrame = nValue; }
void Reset()
{
m_Layer = 0;
m_MpegVersion = 0;
m_Bitrate = 0;
m_BitrateIndex = 0;
m_Channels = 0;
m_SFreq = 0;
m_BitsPerFrame = 0;
m_Duration = 0.0f;
m_CrcError = 0;
m_NoMainData = 0;
m_SamplesPerFrame=0;
}
};
#endif /* __cplusplus */
/*-------------------------------------------------------------------------*/
#ifdef WIN32
#pragma pack(pop)
#endif
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,66 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mp3tools.h
* project : ISO/MPEG-Decoder
* author : Martin Sieler
* date : 1998-05-26
* contents/description: HEADER - layer III processing
*
*
\***************************************************************************/
/*
* $Date: 2011/01/13 22:43:21 $
* $Id: mp3tools.h,v 1.2 2011/01/13 22:43:21 audiodsp Exp $
*/
/*-------------------------------------------------------------------------*/
#ifndef __MP3TOOLS_H__
#define __MP3TOOLS_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
/* ------------------------------------------------------------------------*/
void mp3ScaleFactorUpdate
(
const MP3SI_GRCH &SiL,
const MP3SI_GRCH &SiR,
const MPEG_INFO &Info,
MP3SCF &ScaleFac
);
void mp3StereoProcessing
(
float *pLeft,
float *pRight,
MP3SI_GRCH &SiL,
MP3SI_GRCH &SiR,
const MP3SCF &ScaleFac, /* right channel!! */
const MPEG_INFO &Info
);
void mp3Reorder
(
float *pData,
const MP3SI_GRCH &Si,
const MPEG_INFO &Info
);
void mp3Antialias
(
float *pData,
MP3SI_GRCH &Si,
const MPEG_INFO &Info
);
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,174 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mpeg.h
* project : ISO/MPEG-Decoder
* author : Markus Werner, addings: Martin Sieler
* date : 1995-07-07
* contents/description: HEADER - iso/mpeg-definitions
*
*
\***************************************************************************/
/*
* $Date: 2011/01/20 22:14:40 $
* $Id: mpeg.h,v 1.3 2011/01/20 22:14:40 audiodsp Exp $
*/
/*-------------------------------------------------------------------------*/
#ifndef __MPEG_H__
#define __MPEG_H__
#include "foundation/align.h"
/* ------------------------ includes --------------------------------------*/
/* ------------------------------------------------------------------------*/
//
// MPEG ID (fhgVersion)
//
#define MPG_MPEG1 1
#define MPG_MPEG2 0
#define MPG_MPEG25 2
/* ------------------------------------------------------------------------*/
//
// sample rate
//
#define MPG_SF_LOW 2
/* ------------------------------------------------------------------------*/
//
// header-mode field
//
#define MPG_MD_STEREO 0
#define MPG_MD_JOINT_STEREO 1
#define MPG_MD_DUAL_CHANNEL 2
#define MPG_MD_MONO 3
/*-------------------------------------------------------------------------*/
//
// channels
//
#define MONO 1
#define STEREO 2
/* ------------------------------------------------------------------------*/
//
// subbands, samples/subband
//
#define SBLIMIT 32
#define SSLIMIT 18
/* ------------------------------------------------------------------------*/
//
// info structure
//
typedef struct
{
int stereo;
int sample_rate_ndx;
int frame_bits;
int mode;
int mode_ext;
int header_size;
int fhgVersion;
int protection;
bool IsMpeg1;
} MPEG_INFO;
/* ------------------------------------------------------------------------*/
//
// MPEG Layer-3 sideinfo (per channel/granule)
//
typedef struct
{
int part2_3_length;
int big_values;
int global_gain;
int scalefac_compress;
int window_switching_flag;
int block_type;
int mixed_block_flag;
int table_select[3];
int subblock_gain[3];
int region0_count;
int region1_count;
int preflag;
int scalefac_scale;
int count1table_select;
// additional calced values
int intensity_scale; // MPEG 2, MPEG 2.5 only
int zeroStartNdx;
int zeroSfbStartNdxIsLong;
int zeroSfbStartNdxL;
int zeroSfbStartNdxSMax;
int zeroSfbStartNdxS[3];
int zeroSbStartNdx;
} MP3SI_GRCH;
/* ------------------------------------------------------------------------*/
//
// MPEG Layer-3 sideinfo
//
typedef struct
{
int main_data_begin;
int private_bits;
struct
{
int scfsi[4];
MP3SI_GRCH gr[2];
} ch[2];
} MP3SI;
/* ------------------------------------------------------------------------*/
//
// MPEG Layer-3 scalefactors
//
typedef struct
{
// scalefactors
int l[23];
int s[3][13];
// illegal intensity position
int l_iip[23];
int s_iip[13];
} MP3SCF;
/* ------------------------------------------------------------------------*/
//
// spectrum (as transmitted)
//
typedef NALIGN(16) float SPECTRUM[2][SBLIMIT][SSLIMIT];
//
// spectrum (after mdct)
//
typedef NALIGN(16) float POLYSPECTRUM[2][SSLIMIT][SBLIMIT];
/* Nullsoft added 25 Oct 2007 */
struct DecoderHooks
{
void (*layer3_vis)(SPECTRUM vistable,int gr, int nch);
void (*layer2_eq)(float *xr, int nch, int srate, int nparts);
void (*layer3_eq)(float *xr, int nch, int srate);
};
/* ------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,71 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mpegbitstream.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1997-12-05
* contents/description: MPEG bitstream - HEADER
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:04 $
* $Id: mpegbitstream.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
*/
#ifndef __MPEGBITSTREAM_H__
#define __MPEGBITSTREAM_H__
/* ------------------------ includes --------------------------------------*/
#include "bitstream.h"
#include "mpegheader.h"
#include "mp3sscdef.h"
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*/
//
// MPEG bitstream class.
//
// This object is derived from CBitStream. In addition to CBitStream
// this object is able to sync to the next ISO/MPEG header position.
//
class CMpegBitStream : public CBitStream
{
public:
CMpegBitStream(int cbSize);
CMpegBitStream(unsigned char *pBuf, int cbSize, bool fDataValid = false);
virtual ~CMpegBitStream();
virtual void Reset();
SSC DoSync();
int GetSyncPosition() const { return m_SyncPosition; }
const CMpegHeader *GetHdr() const { return &m_Hdr; }
protected:
private:
SSC DoSyncInitial();
SSC DoSyncContinue();
enum { FRAMES_TO_CHECK = 10 };
CMpegHeader m_Hdr; // mpeg header
unsigned long m_FirstHdr; // "relevant" bits of first good header
unsigned long m_nFramesToCheck; // # frames to be checked for next mpeg header
int m_SyncPosition; // offset of first sync in bits
SSC m_SyncState; // last sync state
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,105 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mpegheader.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1997-12-05
* contents/description: ISO/MPEG Header
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:04 $
* $Id: mpegheader.h,v 1.1 2010/11/17 20:46:04 audiodsp Exp $
*/
#ifndef __MPEGHEADER_H__
#define __MPEGHEADER_H__
/* ------------------------ includes --------------------------------------*/
/*-------------------------- defines --------------------------------------*/
class CBitStream;
/*-------------------------------------------------------------------------*/
//
// MPEG header class.
//
// This object reads and decodes an ISO/MPEG header.
//
class CMpegHeader
{
public:
CMpegHeader();
virtual ~CMpegHeader();
int ReadFrom(CBitStream &sBS);
int FromInt(unsigned long dwHdrBits);
int GetMpegVersion() const { return m_MpegVersion;}
int GetLayer() const { return m_Layer;}
int GetChannels() const { return m_Channels;}
int GetSampleRate() const { return m_SampleRate;}
int GetSampleRateNdx() const { return m_SampleRateNdx;}
int GetBitrate() const { return m_Bitrate;}
int GetBitrateNdx() const { return m_BitrateNdx;}
int GetMode() const { return m_Mode;}
int GetModeExt() const { return m_ModeExt;}
int GetPadding() const { return m_Padding; }
int GetCrcCheck() const { return m_CrcCheck;}
int GetCopyright() const { return m_Copyright;}
int GetOriginal() const { return m_Original;}
int GetEmphasis() const { return m_Emphasis;}
int GetHeaderLen() const
{ return MPEG_HDRLEN+(m_CrcCheck?MPEG_CRCLEN:0); }
int GetFrameLen() const { return m_FrameLen;}
float GetDuration() const { return m_Duration;}
int GetSamplesPerFrame() const;
protected:
private:
enum { MPEG_HDRLEN = 32, MPEG_CRCLEN = 16 };
int CalcFrameLen();
void ResetMembers();
void SetMembers();
// header fields
int m_Syncword;
int m_Idex;
int m_Id;
int m_Layer;
int m_CrcCheck;
int m_BitrateNdx;
int m_SampleRateNdx;
int m_Padding;
int m_Private;
int m_Mode;
int m_ModeExt;
int m_Copyright;
int m_Original;
int m_Emphasis;
// calculated data
int m_HeaderValid;
int m_MpegVersion;
int m_Channels;
int m_SampleRate;
int m_Bitrate;
int m_FrameLen;
float m_Duration;
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,100 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: mpgadecoder.h
* project : MPEG Decoder
* author : Martin Sieler
* date : 1998-05-26
* contents/description: MPEG Decoder class - HEADER
*
*
\***************************************************************************/
/*
* $Date: 2011/01/25 18:24:17 $
* $Id: mpgadecoder.h,v 1.4 2011/01/25 18:24:17 audiodsp Exp $
*/
#ifndef __MPGADECODER_H__
#define __MPGADECODER_H__
/* ------------------------ includes --------------------------------------*/
#include "mp3sscdef.h"
#include "mp3streaminfo.h"
#include "mpegbitstream.h"
#include "mp3decode.h"
#include "mp2decode.h"
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*/
//
// Mp3 Decoder Top Level Object.
//
// This is the main ISO/MPEG decoder object that interfaces with the
// application code.
//
// It is however recommended to use IMpgaDecoder (see mp3decifc.h) instead.
// Define USE_MP3DECIFC when planning to use IMpgaDecoder.
//
enum
{
MPEGAUDIO_CRCCHECK_OFF = 0,
MPEGAUDIO_CRCCHECK_ON = 1,
};
class CMpgaDecoder
{
public:
CMpgaDecoder(int crcCheck = MPEGAUDIO_CRCCHECK_OFF);
CMpgaDecoder(DecoderHooks *hooks, int crcCheck = MPEGAUDIO_CRCCHECK_OFF);
CMpgaDecoder(unsigned char *pBuf, int cbSize, int crcCheck = MPEGAUDIO_CRCCHECK_OFF);
~CMpgaDecoder();
void *operator new(size_t stAllocateBlock);
void operator delete(void *);
void Reset();
SSC DecodeFrame(float *pPcm, size_t cbPcm, size_t *pcbUsed = 0, unsigned char *ancData = 0, size_t *numAncBytes = 0, int oflOn = 0, unsigned int *startDelay = 0, unsigned int *totalLength = 0);
const CMp3StreamInfo *GetStreamInfo() const;
void Connect(CGioBase *gf);
int Fill(const unsigned char *pBuffer, int cbBuffer);
int GetInputFree() const;
int GetInputLeft() const;
void SetInputEof();
bool IsEof() const;
#ifdef KSA_DRM
int GetScfBuffer(const unsigned char** ppBuffer, unsigned int* pBufSize) const;
#endif
SSC GetLastAncData(unsigned char* ancData = 0, size_t *numAncBytes = 0);
SSC GetOflVersion(int* oflVersion = 0);
//protected:
void SetStreamInfo(SSC dwReturn);
CMp3StreamInfo m_Info;
CMpegBitStream m_Mbs;
NALIGN(16) CMp3Decode m_Mp3Decode;
NALIGN(16) CMp2Decode m_Mp2Decode;
bool m_IsEof;
int m_Layer;
private:
};
/*-------------------------------------------------------------------------*/
#endif

View File

@ -0,0 +1,61 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: polyphase.h
* project : ISO/MPEG-Decoder
* author : Stefan Gewinner
* date : 1998-05-26
* contents/description: polyphase class - HEADER
*
*
\***************************************************************************/
/*
* $Date: 2011/02/14 14:48:56 $
* $Id: polyphase.h,v 1.6 2011/02/14 14:48:56 bigg Exp $
*/
#pragma once
//#ifndef __POLYPHASE_H__
//#define __POLYPHASE_H__
/* ------------------------ includes --------------------------------------*/
#include "mpeg.h"
#include "foundation/align.h"
/*-------------------------------------------------------------------------*/
#define HAN_SIZE 512
/*-------------------------------------------------------------------------*/
// Class for (inverse) Polyphase calculation.
class CPolyphase
{
public:
CPolyphase(const MPEG_INFO &_info);
~CPolyphase() {}
void Init();
float *Apply(POLYSPECTRUM &sample, float *pPcm, int frms=18);
static void Reorder(int channels, POLYSPECTRUM &output, const SPECTRUM &input);
protected:
int bufOffset;
NALIGN(16) float syn_buf[2][HAN_SIZE];
const MPEG_INFO &info ; // info-structure
void window_band_m(int bufOffset, float *out_samples) const;
void window_band_s(int bufOffset, float *out_samples) const;
};
/*-------------------------------------------------------------------------*/
//#endif

View File

@ -0,0 +1,19 @@
//
// precomp.h
// nsmp3
//
#include <assert.h>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "foundation/align.h"
#include "bitstream.h"
#include "mpeg.h"
#include "mp3ssc.h"
#include "mp3sscdef.h"

View File

@ -0,0 +1,66 @@
/***************************************************************************\
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: regtypes.h
* project : -
* author : Stefan Gewinner gew@iis.fhg.de
* date : 1998-06-08
* contents/description: absolute minimum to make l3reg.h compile without windef.h
*
* $Header: /cvs/root/nullsoft/Replicant/jni/nsmp3/regtypes.h,v 1.1 2010/11/17 20:46:05 audiodsp Exp $
*
\***************************************************************************/
/* the typedefs should be in place if we already got windows.h included */
#ifndef _INC_WINDOWS
#ifndef __REGTYPES_H__
#define __REGTYPES_H__
/*-------------------------------------------------------------------------*/
#ifdef _MSC_VER
#pragma warning(disable:4103)
#pragma pack(push, 1) /* assume byte packing throughout */
#endif
/*-------------------------------------------------------------------------*/
#define FAR
#define NEAR
typedef unsigned long DWORD ;
typedef unsigned short WORD ;
/*
* extended waveform format structure used for all non-PCM formats. this
* structure is common to all non-PCM formats.
*/
typedef struct tagWAVEFORMATEX
{
WORD wFormatTag; /* format type */
WORD nChannels; /* number of channels (i.e. mono, stereo...) */
DWORD nSamplesPerSec; /* sample rate */
DWORD nAvgBytesPerSec; /* for buffer estimation */
WORD nBlockAlign; /* block size of data */
WORD wBitsPerSample; /* number of bits per sample of mono data */
WORD cbSize; /* the count in bytes of the size of */
/* extra information (after cbSize) */
} WAVEFORMATEX, *PWAVEFORMATEX, NEAR *NPWAVEFORMATEX, FAR *LPWAVEFORMATEX ;
typedef const WAVEFORMATEX FAR *LPCWAVEFORMATEX ;
/*-------------------------------------------------------------------------*/
#ifdef _MSC_VER
#pragma pack(pop) /* revert to previous packing */
#endif
/*-------------------------------------------------------------------------*/
#endif
#endif

View File

@ -0,0 +1,53 @@
/***************************************************************************\
*
* MPEG Layer3-Audio Decoder
* <20> 1997-2006 by Fraunhofer IIS
* All Rights Reserved
*
* filename: sequencedetector.h
* project : ---
* author : Martin Sieler
* date : 1998-02-14
* contents/description: HEADER - sequence detector
*
*
\***************************************************************************/
/*
* $Date: 2010/11/17 20:46:05 $
* $Id: sequencedetector.h,v 1.1 2010/11/17 20:46:05 audiodsp Exp $
*/
#ifndef __SEQUENCEDETECTOR_H__
#define __SEQUENCEDETECTOR_H__
/* ------------------------ includes --------------------------------------*/
/*-------------------------- defines --------------------------------------*/
/*-------------------------------------------------------------------------*/
class CSequenceDetector
{
public:
CSequenceDetector(int nLimit);
~CSequenceDetector();
void Reset();
CSequenceDetector& operator+= (int nValue);
int GetLength() const;
int GetValue(int nIndex) const;
int GetSum() const;
protected:
private:
int m_Limit;
int m_Count;
bool *m_pDisabled;
int *m_pArray;
};
/*-------------------------------------------------------------------------*/
#endif