Remove potential unlicensed code

This commit is contained in:
Jef 2024-09-24 21:52:26 +02:00
parent c0ffc1d59e
commit 0003d3d743
74 changed files with 0 additions and 18623 deletions

View File

@ -1,40 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/DataIO.h,v 1.1 2009/04/28 20:21:06 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* filename: DataIO.h
* project : MPEG-2 AAC Decoder
* contents/description: Data I/O include header
*
* $Header: /cvs/root/winamp/vlb/DataIO.h,v 1.1 2009/04/28 20:21:06 audiodsp Exp $
*
\***************************************************************************/
#ifndef DATAIOCONTROL
#define DATAIOCONTROL
#define DATA_IO_READ 0
#define DATA_IO_WRITE 1
#define DATA_IO_ERROR_NONE 0
#define DATA_IO_ERROR_INVALID -1
class DataIOControl{
public:
virtual int IO( void*pvBuffer,
int iSize,
int iCount)=0;
virtual int Seek(long lOffset, int iOrigin)=0;
// virtual int Close()=0;
virtual int EndOf()=0;
virtual int DICGetLastError()=0;
virtual int DICGetDirection()=0;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,193 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/DolbyPayload.h,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* filename: DolbyPayload.h
* project : MPEG-2 AAC Decoder
* contents/description: Dolby SE bitstream parser include file
*
\***************************************************************************/
#ifndef _DolbyPayload_h_
#define _DolbyPayload_h_
//This is the quickest way to get all the Dolby Payload into the AAC Decoder but not the best!
#include<math.h>
#include<stdlib.h>
#include<stdio.h>
#include"bitstream.h"
#define DSPmax(a,b) (((a) > (b)) ? (a) : (b));
#define DSPmin(a,b) (((a) < (b)) ? (a) : (b));
#define DNS
#define SIGNAL_SUB
#define DOLBY_MAX_NUM_SFB 64
#define DOLBY_BLOCK_LEN_LONG 1024
#define SS_BUF_LEN_LONG 150
#define SS_BUF_LEN_SHORT 18
#define SS_COPYSTART 50
#define SS_STEP_LONG 10 /* note that SS_STEP_LONG must divide into SS_BUF_LEN_LONG without remainder,
to assure that all values in normCopy array are power normalized.*/
#define SS_STEP_SHORT 3 /* note that SS_STEP_SHORT must divide into SS_BUF_LEN_SHORT without remainder,
to assure that all values in normCopy array are power normalized.*/
#define GLOBAL_ATTEN 0.08f
#define NS_ATTEN1_LONG 0.975f
#define NS_ATTEN2_LONG 0.90f
#define NS_ATTEN1_SHORT 0.90f /* 0.816 would be attenuation factor to apply same per octave attenuation as
short block, but it is desireable to allow gentler rolloff for short blocks.
Thus set to 0.90. */
#define NS_ATTEN2_SHORT 0.7f /* To apply the same per octave attenuation as long block, the slope would
be too sharp (greater than 6dB from bin to bin), thus allow a gentler slope
for short blocks due to flat nature of short block spectra. */
#define NSFILT_COEF 0.3f
#define BACKWARD_MASK_COMP 0.95f
#define START_BIN_LONG 50
#define START_BIN_SHORT (START_BIN_LONG / 8)
#define SE_MAX_NUM_BANDS 80
#define MAX_NUM_POWER_VALUES SE_MAX_NUM_BANDS
#define SE_BAND_IGNORE_BITS 3
#define SE_NSHAPE_ORDER 2
#define NOISE_LENGTH 10000
#define NUM_BANDRES_OPTIONS 2
#define SE_BANDRES_2_67_DB 0
#define SE_BANDRES_1_33_DB 1
#define NUM_BLOCKTYPES 4
#define MAX_NUM_WINDOW_GROUPS 8
#define SE_DNS_PWR_BITS_SHORT 3
#define SE_DNS_PWR_BITS_LONG 4
#define SE_SPECT_FLAT_BITS_LONG 8
#define SE_SPECT_FLAT_BITS_SHORT 4
#define SE_REF_ENERG_BITS_LONG 8
#define SE_REF_ENERG_BITS_SHORT 7
// buffer model control variables
#define NEW_BUFFER_MODEL /* if #defined, uses the new buffer model which accounts for */
/* frequency alignment between non-short and short frames */
//#define DEBUG_PRINT_BUFFER_MODEL /* if #defined, prints out buffer model. Check the exact if statement */
/* in the code to see whether or not the long or short buffer model is being printed out */
#define USE_XFORM_HYSTERESIS
#define XFORM_HYSTERESIS_LENGTH 2 /* Hysteresis for switching SE transform lengths. Relevant
* only if USE_XFORM_HYSTERESIS is #define'd.
* NOTE: Should be between 2 and (2 * NRDB per SE frame) inclusive or
* even a clean switch (from single to double or vice-versa) will
* elicit an unnecessary sound card close/re-open/glitch (twice).
*/
struct SECTION_INFORMATION_STRUCT{
int aiSectionCount[MAX_NUM_WINDOW_GROUPS];
int aaiSectionCodebooks[MAX_NUM_WINDOW_GROUPS][DOLBY_MAX_NUM_SFB];
int aaiSectionStart[MAX_NUM_WINDOW_GROUPS][DOLBY_MAX_NUM_SFB];
int aaiSectionEnd[MAX_NUM_WINDOW_GROUPS][DOLBY_MAX_NUM_SFB];
};
struct DNS_INFORMATION_STRUCT{
int iWindowSequence;
int iGroupCount;
int iGroupLength[MAX_NUM_WINDOW_GROUPS];
int iMaxSFB;
int iLastBin;
const int *piBandOffsets;
const SECTION_INFORMATION_STRUCT *psSectionInfoStruct;
float aafDNSRatio[MAX_NUM_WINDOW_GROUPS][DOLBY_MAX_NUM_SFB];
};
struct DOLBY_PAYLOAD_STRUCT{
int iDolbyBitStreamWarning;
int iUsesDoubleLengthXForm;
int iSEPowerResolution;
int iChannels;
int iSampleRateIndex;
int iSampleRate;
int num_se_bands[2];
int seBands[2][MAX_NUM_WINDOW_GROUPS][SE_MAX_NUM_BANDS];
int sfm[2][MAX_NUM_WINDOW_GROUPS];
int delta_power_values[2][MAX_NUM_WINDOW_GROUPS][MAX_NUM_POWER_VALUES];
float fdamp[2][MAX_NUM_WINDOW_GROUPS];
int SE_num_ignored_upper_bands[2];
int aiMaxSFB[2];
int aiTotalSFB[2];
int aiCopyStop[2];
int iGroupLength[2][MAX_NUM_WINDOW_GROUPS];
int iGroupCount[2];
DNS_INFORMATION_STRUCT asDNSInfoStruct[2];
};
struct Huffman
{
int index;
int len;
unsigned long cw;
} ;
struct Huffman_lookup
{
int index;
int len;
int cw;
};
typedef struct {
unsigned int sr;
unsigned int* SE_bands_bw;
unsigned char SE_max_num_se_bands;
unsigned char SE_num_ignored_upper_bands;
} SE_Band_Info_struct;
typedef struct {
int powerResolution;
Huffman* cwLengthLookupTable;
Huffman_lookup* cwValueLookupTable;
int num_codewords;
} SE_power_resolution_table_struct;
void applyDNS( float *pfSpectralData,
DNS_INFORMATION_STRUCT*psDNSInfoStruct,
int iPrevWnd);
unsigned char computeSeBandInfo (unsigned int SRate, /* input: Sample Rate */
unsigned int first_SE_bin, /* input: bin number of the first bin of the extension range */
SE_Band_Info_struct* pSE_Band_Info_struct, /* input: SE band info struct ptr */
int* SE_bands_bw, /* output: SE bandwidths, in bins (array; memory assumed to be already allocated) */
int* num_SE_bands);
int spectralExtInfo( int cnt,
DOLBY_PAYLOAD_STRUCT *seData,
CDolbyBitStream*poBitStream);
void spectralExtend(float* pfData,
int iCopyStart,
int iCopyStop,
int iSfm,
int iBandCount,
int* piBands,
int* delta_power_values,
float fDamp,
int iHBlockSize,
int wnd,
int SEPowerResolution,
int iPreviousWnd,
float* avgCopyEnergies);
void computeAvgCopyEnergies(float* pfData,
int iCopyStart,
int iCopyStop,
int num_se_bands,
int* piBands,
int halfWindowLength,
int iWindowSequence,
float* avgCopyEnergies);
#endif

View File

@ -1,27 +0,0 @@
#include "NSVFactory.h"
#include "nsv_vlb.h"
#include "api__vlb.h"
#include "../nsv/nsvlib.h"
IAudioDecoder *NSVFactory::CreateAudioDecoder(FOURCC format, IAudioOutput **output)
{
switch (format)
{
case NSV_MAKETYPE('V', 'L', 'B', ' '):
{
VLB_Decoder *dec;
WASABI_API_MEMMGR->New(&dec);
return dec;
}
default:
return 0;
}
}
#define CBCLASS NSVFactory
START_DISPATCH;
CB(SVC_NSVFACTORY_CREATEAUDIODECODER, CreateAudioDecoder)
END_DISPATCH;
#undef CBCLASS

View File

@ -1,15 +0,0 @@
#ifndef NULLSOFT_VLB_NSVFACTORY_H
#define NULLSOFT_VLB_NSVFACTORY_H
#include "../nsv/svc_nsvFactory.h"
class NSVFactory : public svc_nsvFactory
{
public:
IAudioDecoder *CreateAudioDecoder(FOURCC format, IAudioOutput **output) override;
protected:
RECVS_DISPATCH;
};
#endif

View File

@ -1,116 +0,0 @@
#include "VLBIO.h"
#include "vlbout.h"
#include "api__vlb.h"
///////////////////////////////////////////////////////////////////////
//
// VLB Data Input Class
//
///////////////////////////////////////////////////////////////////////
void VLBIn::Fill( unsigned char *buf, int nbytes )
{
int writepos = pos + size;
if (writepos >= BUFSIZE) writepos -= BUFSIZE;
if (writepos + nbytes > BUFSIZE)
{
int l = BUFSIZE - writepos;
memcpy(data + writepos, buf, l);
buf += l;
writepos += l;
size += l;
nbytes -= l;
if (writepos >= BUFSIZE) writepos -= BUFSIZE;
}
memcpy( data + writepos, buf, nbytes );
size += nbytes;
}
int VLBIn::IO( void *buf, int s, int n )
{
int nbytes = s * n;
void *obuf = buf;
if ( nbytes > size )
{
nbytes = size - nbytes % s;
}
if (!nbytes) return 0;
int bleft = nbytes;
if (pos + nbytes > BUFSIZE)
{
int l = BUFSIZE - pos;
memcpy(buf, data + pos, l);
bleft -= l;
pos = 0;
buf = (char *)buf + l;
}
memcpy(buf, data + pos, bleft);
size -= nbytes;
pos += bleft;
if (pos >= BUFSIZE) pos = 0;
return nbytes / s;
}
///////////////////////////////////////////////////////////////////////
//
// VLB Data Output Class
//
///////////////////////////////////////////////////////////////////////
#define ADD_SAMPLE(T,S) { *(T *)(data + ((size + pos) & (OBUFSIZE-1))) = S; size += sizeof(T); }
#if !defined(__alpha) && !defined(_WIN64)
static __inline long float_to_long(double t)
{
long r;
__asm fld t
__asm fistp r
return r;
}
#else
#define float_to_long(x) ((long)( x ))
#endif
int VLBOut::IO( float **buf, int samples )
{
if ( iError ) return iError;
long l;
for ( int i = 0; i < samples; i++ )
for ( int j = 0; j < format.ucNChannels; j++ )
{
l = float_to_long( buf[j][i] );
if ( l > 32767 ) l = 32767;
if ( l < -32768 ) l = -32768;
ADD_SAMPLE(short, (short)l)
}
return iError;
}
void VLBOut::PullBytes( unsigned char *buf, int nbytes )
{
if (pos + nbytes >= OBUFSIZE)
{
int l = OBUFSIZE - pos;
memcpy(buf, data + pos, l);
pos = 0;
buf += l;
nbytes -= l;
size -= l;
}
memcpy( buf, data + pos, nbytes );
size -= nbytes;
pos += nbytes;
if (pos >= OBUFSIZE) pos = 0;
}

View File

@ -1,24 +0,0 @@
#pragma once
#include "dataio.h"
#include "vlbout.h"
class VLBIn : public DataIOControl
{
public:
VLBIn() { pos = size = 0; }
virtual int IO( void *buf, int size, int count );
virtual int Seek( long offset, int origin )
{
return 0;
}
virtual int Close() { return 0; }
virtual int EndOf( void ) { return 0; }
virtual int DICGetLastError() { return DATA_IO_ERROR_NONE; }
virtual int DICGetDirection() { return DATA_IO_READ; }
int GetInputFree() { return BUFSIZE - size; }
int GetSize() { return size; }
void Fill( unsigned char *buf, int nbytes );
void Empty() { pos = size = 0; }
private:
unsigned char data[BUFSIZE];
int size, pos;
};

View File

@ -1,79 +0,0 @@
#include "VLBDecoder.h"
VLBDecoder::VLBDecoder()
{
decoder = 0;
}
VLBDecoder::~VLBDecoder()
{
delete decoder;
}
int VLBDecoder::Open(DataIOControl *paacInput)
{
if (decoder)
return 1;
decoder = new CAacDecoderApi(paacInput);
return 0;
}
void VLBDecoder::Close()
{
delete decoder;
decoder=0;
}
long VLBDecoder::Synchronize(AACStreamParameters *paacStreamParameters)
{
if (decoder)
{
long status = decoder->Synchronize(paacStreamParameters);
if (status == 0)
{
info.ucNChannels = (unsigned char) paacStreamParameters->num_channels;
info.uiSampleRate = paacStreamParameters->sampling_frequency;
dataout.SetFormatInfo(&info);
}
return status;
}
else
return ERR_SYNC_ERROR;
}
long VLBDecoder::DecodeFrame(AACStreamParameters *paacStreamParameters)
{
if (decoder)
return decoder->DecodeFrame(&dataout, paacStreamParameters);
else
return ERR_INVALID_BITSTREAM;
}
void VLBDecoder::Flush()
{
dataout.Empty();
}
size_t VLBDecoder::Read(void *buffer, size_t bufferlen)
{
if (dataout.BytesAvail() > 0)
{
size_t l = dataout.BytesAvail();
if (l > bufferlen)
l = bufferlen;
dataout.PullBytes((unsigned char *)buffer, (int)l);
return l;
}
return 0;
}
#define CBCLASS VLBDecoder
START_DISPATCH;
CB(OBJ_VLBDECODER_OPEN, Open)
VCB(OBJ_VLBDECODER_CLOSE, Close)
CB(OBJ_VLBDECODER_SYNCHRONIZE, Synchronize)
CB(OBJ_VLBDECODER_DECODEFRAME, DecodeFrame)
VCB(OBJ_VLBDECODER_FLUSH, Flush)
CB(OBJ_VLBDECODER_READ, Read)
END_DISPATCH;

View File

@ -1,21 +0,0 @@
#pragma once
#include "obj_vlbDecoder.h"
#include "vlbout.h"
class VLBDecoder : public obj_vlbDecoder
{
public:
VLBDecoder();
~VLBDecoder();
int Open(DataIOControl *paacInput);
void Close();
long Synchronize(AACStreamParameters *paacStreamParameters);
long DecodeFrame(AACStreamParameters *paacStreamParameters);
void Flush();
size_t Read(void *buffer, size_t bufferlen);
protected:
RECVS_DISPATCH;
private:
CAacDecoderApi *decoder;
VLBOut dataout;
AUDIO_FORMATINFO info;
};

View File

@ -1,434 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/aacdecoder.cpp,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: aacdecoder.cpp
* project : MPEG-2 AAC Decoder
* contents/description: decoder main object
*
\***************************************************************************/
#include "aacdecoder.h"
#include "bitstream.h"
#include "bitsequence.h"
#include "channelinfo.h"
#include<stdio.h>
// // //
CAacDecoder::CAacDecoder (CDolbyBitStream& bs)
: m_bs (bs), sce (bs), cpe (bs), lfe (bs), dse (bs),bIgnoreDolbyStream(false), bLookForDSEInfoStream(true),
bHasDSEInfoStream(false)
{
m_BlockNumber = 0 ;
m_SelectedProgram = 0 ;
}
CAacDecoder::~CAacDecoder ()
{
}
void CAacDecoder::SetEqualization (bool wantEQ, float Mask [])
{
sce.SetEqualization (wantEQ, Mask) ;
cpe.SetEqualization (wantEQ, Mask) ;
lfe.SetEqualization (wantEQ, Mask) ;
}
void CAacDecoder::ReadFillElement (void)
{
CVLBBitSequence count (4) ;
if (count.Read (m_bs) == 15)
{
CVLBBitSequence esc_count (8) ;
esc_count.Read (m_bs) ;
count = esc_count + 14 ;
}
CVLBBitSequence fill_byte (8) ;
for (int i = 0 ; i < count ; i++)
{
fill_byte.Read (m_bs) ;
}
}
void CAacDecoder::ReadDolbyFillElement (void)
{
CVLBBitSequence count (4) ;
int iCountInBytes;
int iCountInBits;
if (count.Read (m_bs) == 15)
{
CVLBBitSequence esc_count (8) ;
esc_count.Read (m_bs) ;
count = esc_count + 14 ;
}
iCountInBytes=(int)count;
iCountInBits = iCountInBytes * 8;
CVLBBitSequence fill_byte (8) ;
CVLBBitSequence fill_nibble(4);
if(iCountInBytes){
fill_nibble.Read(m_bs);
if(bLookForDSEInfoStream && ((int)fill_nibble)==15){
iCountInBits=spectralExtInfo(iCountInBytes,&sDSEInfo,&m_bs);
// Debug: simulate a bitstream error. This will cause the
// MDCT record to be zeroed-out at higher frequencies prior to
// the inverse transform.
// iCountInBits = iCountInBytes*8 - 4;
// sDSEInfo.iDolbyBitStreamWarning = 942;
bHasDSEInfoStream=true;
}
else{
// read out the rest of the byte; adjust bits read counter
fill_nibble.Read(m_bs);
iCountInBits -= 8;
}
}
// If there was an error in reading the SE bitstream, or if there are fill
// bits left in the same fill element, then read out the rest of the Fill Element.
while(iCountInBits > 8)
{
fill_byte.Read (m_bs);
iCountInBits -= 8;
}
if (iCountInBits > 0 && iCountInBits <= 8)
{
m_bs.Get(iCountInBits);
iCountInBits -= iCountInBits;
}
}
void CAacDecoder::FrameInit(CStreamInfo &info)
{
if (m_bs.IsAdifHeaderPresent ())
{
m_AdifHeader.Read (m_bs) ;
info.SetBitRate (m_AdifHeader.GetBitRate ()) ;
info.SetOriginalCopy(m_AdifHeader.GetOriginalCopy());
info.SetHome(m_AdifHeader.GetHome());
info.SetSamplingRateIndex(m_AdifHeader.GetProgramConfig(0).GetSamplingFrequencyIndex());
info.SetSamplingRate(CChannelInfo::SamplingRateFromIndex(info.GetSamplingRateIndex ()));
info.SetChannels(m_AdifHeader.GetProgramConfig(0).GetNumChannels());
info.SetProfile(m_AdifHeader.GetProgramConfig(0).GetProfile());
}
}
//MSV:
void CAacDecoder::InitDSEInfo( CDolbyBitStream*poBS,
CChannelElement *poChannelElement)
{
// note that poChannelElement can be either poSingleChannel or poChannelPair.
// depending on a mono or stereo vlb bitstream. We will deal with poChannelElement
// (base class) calls in this function for either type of Channel Element, with the
// exception of calling Get[Left|Right]Block() for ChannelPair Elements.
int numChannels = poChannelElement->GetNumberOfChannels();
int channelIndex;
if (numChannels == 1 || numChannels == 2)
{
CBlock *poCBlock[2];
CChannelInfo *poCChannelInfo;
// This is garaunteed to set poCLongBlock to valid values,
// since we've already checked the number of channels!
// GetChannelInfo could be made a virtual function of the base class, thus
// avoiding the need to specifically call different versions of GetChannelInfo()
// below, but this would require moving more code to the Base Class, which is
// unnecessarily complex. Note, however, that for CPE's, there poChannelInfo returns
// a pointer to an array of 2 ChannelInfo objects.
if (numChannels == 1)
{
poCBlock[0]=(CBlock*)( ((CSingleChannel*)poChannelElement)->GetBlock() );
poCChannelInfo = ((CSingleChannel*)poChannelElement)->GetChannelInfo();
} else { // num_channels == 2
poCBlock[0]=(CBlock*)( ((CChannelPair*)poChannelElement)->GetLeftBlock() );
poCBlock[1]=(CBlock*)( ((CChannelPair*)poChannelElement)->GetRightBlock() );
poCChannelInfo = ((CChannelPair*)poChannelElement)->GetChannelInfo();
}
//Fill Out Dolby Payload Structure:
sDSEInfo.iChannels=numChannels;
// sampling rate is same for both channels; just use sr info from the left (0th) channel
sDSEInfo.iSampleRateIndex=poCChannelInfo[0].GetSamplingIndex();
sDSEInfo.iSampleRate=poCChannelInfo[0].GetSamplingFrequency();
// all other information must be read for left and right channels
for (channelIndex=0;channelIndex<numChannels;channelIndex++)
{
sDSEInfo.aiMaxSFB[channelIndex]=poCChannelInfo[channelIndex].GetScaleFactorBandsTransmitted();
sDSEInfo.aiTotalSFB[channelIndex]=poCChannelInfo[channelIndex].GetScaleFactorBandsTotal();
sDSEInfo.asDNSInfoStruct[channelIndex].psSectionInfoStruct=poCBlock[channelIndex]->GetSectionInfo();
sDSEInfo.asDNSInfoStruct[channelIndex].iWindowSequence=poCChannelInfo[channelIndex].GetWindowSequence();
sDSEInfo.asDNSInfoStruct[channelIndex].iGroupCount=poCChannelInfo[channelIndex].GetWindowGroups();
sDSEInfo.asDNSInfoStruct[channelIndex].iLastBin=poCChannelInfo[channelIndex].GetLastBin();
sDSEInfo.asDNSInfoStruct[channelIndex].iMaxSFB=poCChannelInfo[channelIndex].GetScaleFactorBandsTransmitted();
sDSEInfo.asDNSInfoStruct[channelIndex].piBandOffsets=poCChannelInfo[channelIndex].GetScaleFactorBandOffsets();
sDSEInfo.aiCopyStop[channelIndex]=poCChannelInfo[channelIndex].GetLastBin();
sDSEInfo.iGroupCount[channelIndex]=poCChannelInfo[channelIndex].GetWindowGroups();
for (int i=0;i<sDSEInfo.asDNSInfoStruct[channelIndex].iGroupCount;i++)
{
sDSEInfo.iGroupLength[channelIndex][i] = poCChannelInfo[channelIndex].GetWindowGroupLength(i);
sDSEInfo.asDNSInfoStruct[channelIndex].iGroupLength[i] = poCChannelInfo[channelIndex].GetWindowGroupLength(i);
}
}
}
else{
bLookForDSEInfoStream=false;
}
if(bIgnoreDolbyStream) bLookForDSEInfoStream=false;
}
#define ELEMENT_TYPE_SCE 0
#define ELEMENT_TYPE_CPE 1
#define ELEMENT_TYPE_IGNORE 3
void CAacDecoder::DecodeFrame (AudioIOControl *poAudioIO, CStreamInfo &info)
{
int iRepeatCount = m_bs.GetNRDB() + 1;
for(int n = 0; n < iRepeatCount; n++)
{
bool bHasElement;
int iElementType;
m_SelectedProgram = 0;
bLookForDSEInfoStream = true;
bHasDSEInfoStream = false;
bHasElement = false;
iElementType = ELEMENT_TYPE_IGNORE;
// support Audio_Data_Interchange_Format header, if present
CProgramConfig &pce = m_AdifHeader.GetProgramConfig(m_SelectedProgram);
if ((m_BlockNumber == 0) && m_bs.IsAdifHeaderPresent())
{
info.SetSamplingRateIndex (pce.GetSamplingFrequencyIndex());
info.SetProfile (pce.GetProfile());
}
info.SetChannels(0);
info.SetSamplingRate (CChannelInfo::SamplingRateFromIndex(info.GetSamplingRateIndex ()));
// // //
CVLBBitSequence type (3), tag (4);
m_bs.ByteAlign();
while (type != CAacDecoder::ID_END)
{
type.Read(m_bs);
switch (type)
{
case CAacDecoder::ID_SCE:
if(bHasElement)
{
throw EUnimplemented();
}
m_bs.SetPositionMarker(CDolbyBitStream::ChannelElementStart);
tag.Read (m_bs);
sce.Read (info);
m_bs.SetPositionMarker(CDolbyBitStream::ChannelElementStop);
if(!bHasElement)
{
iElementType = ELEMENT_TYPE_SCE;
}
else
{
throw EUnimplemented();
iElementType = ELEMENT_TYPE_IGNORE;
}
info.IncChannels(1);
bHasElement = true;
break ;
case CAacDecoder::ID_CPE:
if(bHasElement)
{
throw EUnimplemented();
}
m_bs.SetPositionMarker(CDolbyBitStream::ChannelElementStart);
tag.Read(m_bs);
cpe.Read(info);
m_bs.SetPositionMarker(CDolbyBitStream::ChannelElementStop);
if(!bHasElement)
{
iElementType = ELEMENT_TYPE_CPE;
}
else
{
throw EUnimplemented();
iElementType = ELEMENT_TYPE_IGNORE;
}
info.IncChannels (2);
bHasElement = true;
break;
case CAacDecoder::ID_CCE:
throw EUnimplemented();
break;
case CAacDecoder::ID_LFE:
m_bs.SetPositionMarker(CDolbyBitStream::ChannelElementStart);
tag.Read(m_bs);
lfe.Read(info);
m_bs.SetPositionMarker(CDolbyBitStream::ChannelElementStop);
if (pce.AddChannel(tag,false))
{
throw EUnimplemented();
info.IncChannels(1);
}
iElementType = ELEMENT_TYPE_IGNORE;
bHasElement = true;
break;
case CAacDecoder::ID_DSE:
tag.Read(m_bs);
dse.Read();
break;
case CAacDecoder::ID_PCE:
m_AdifHeader.GetProgramConfig(tag.Read(m_bs)).Read(m_bs);
break;
case CAacDecoder::ID_FIL:
switch(iElementType)
{
case ELEMENT_TYPE_SCE:
InitDSEInfo(&m_bs,&sce);
break;
case ELEMENT_TYPE_CPE:
InitDSEInfo(&m_bs,&cpe);
break;
}
ReadDolbyFillElement();
break;
case CAacDecoder::ID_END:
break;
}
}
// Check for main profile. abort is bitstream is main profile
#ifndef MAIN_PROFILE
if (info.GetProfile() == 0)
{
throw EIllegalProfile();
}
#endif
if(poAudioIO) //Only perform actual decode if we have a valid output buffer object pointer
{
switch(iElementType)
{
case ELEMENT_TYPE_SCE:
if (pce.AddChannel(tag,false))
{
if(bHasDSEInfoStream)
{
sce.DecodeDolby(poAudioIO,&sDSEInfo,info);
}
else
{
sce.Decode(poAudioIO,info);
}
}
break;
case ELEMENT_TYPE_CPE:
if (pce.AddChannel (tag,true))
{
if(bHasDSEInfoStream)
{
cpe.DecodeDolby(poAudioIO,&sDSEInfo,info);
}
else
{
cpe.Decode(poAudioIO,info,2);
}
}
break;
}
}
info.SetNumberOfFrontChannels (info.GetChannels ());
info.SetChannelMask (Speaker_FrontLeft + Speaker_FrontRight);
m_BlockNumber++;
if(n && poAudioIO) m_bs.DecrementBlocks();//NRDB == N-1!
m_bs.ByteAlign();
}
if (poAudioIO == NULL)
{
m_bs.SetFrameReadButNotDecoded();
}
else
{
m_bs.ClearFrameReadButNotDecoded();
}
}

View File

@ -1,215 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/aacdecoder.h,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: aacdecoder.h
* project : MPEG-2 AAC Decoder
* contents/description: decoder main object
*
\***************************************************************************/
#ifndef __AACDECODER_H__
#define __AACDECODER_H__
#include "channel.h"
#include "programcfg.h"
#include "datastream.h"
#include "exception.h"
#include "adif.h"
#include "streaminfo.h"
#include "aacdecoderapi.h"
#include "bitbuffer.h"
#include "DolbyPayload.h"
#include "audio_io.h"
//typedef struct {
// short file_format;
// long bitrate;
//} AACStreamParameters;
typedef struct {
long frame_length;
short protection_absent;
short copyright;
short original_copy;
char copyright_id[9];
} AACFrameParameters;
typedef struct {
short pce_instance_tag;
short profile;
long sampling_frequency;
short num_channels;
short num_front_channels;
short num_side_channels;
short num_back_channels;
short num_lfe_channels;
short num_coupling_channels;
short *pcoupling_channel_tags;
short mono_mixdown_present;
short stereo_mixdown_present;
short matrix_mixdown_present;
short pseudo_surround_present;
short drc_present;
unsigned int prog_ref_level;
char *comment_field_data;
} AACProgramParameters;
typedef struct{
short pce_instance_tag;
short channel_config;
unsigned int *pcoupling_channel_tags;
short drc_factor_high;
short drc_factor_low;
unsigned int target_level;
} AACDecodeParameters;
class CDolbyBitStream ;
/** MPEG-2 AAC Decoder Top Level Object.
This is the main decoder object that interfaces with the application code.
It wraps the bitstream element objects and calls their individual decoding methods.
To indicate unexpected events and error conditions that prevent correct operation,
an exception derived from \Ref{CAacException} will be thrown that should be caught
by the calling application's decoding loop.
\URL[High Level Objects - Overview Diagram]{overview.html}
\URL[MPEG-2 AAC Decoder Block Diagram]{scheme.html}
*/
class CAacDecoder
{
public :
/** Former API parameter structures */
AACStreamParameters *pAACStreamParameters;
AACFrameParameters *pAACFrameParameters;
AACProgramParameters *pAACProgramParameters[AAC_MAX_PROGRAMS];
AACDecodeParameters *pAACDecodeParameters;
/** Object Constructor.
Instantiates a decoder object capable of decoding one stream of
MPEG-2 AAC Audio Data.
@param bs The \Ref{CDolbyBitStream} object that the decoder will read from.
*/
CAacDecoder (CDolbyBitStream &bs) ;
~CAacDecoder () ;
/** Frame Initialization Method.
This method initializes the frame and encodes the ADIF header.
@param info The configuration information.
*/
void FrameInit(CStreamInfo &info);
/** Main Decoding Method.
This method delivers one frame of decoded pcm audio data.
@param pcmbuf The decoded data will be written to the buffer provided by the application.
This buffer must be allocated large enough to hold one frame.
@param info The configuration information.
*/
void DecodeFrame (AudioIOControl *poAudioIO, CStreamInfo &info) ;
/** Equalizer Configuration Method.
This method configures the built-in spectral equalizer.
@param wantEQ Turn the Equalizer on/off.
@param Mask An array of 16 coefficients that will be applied to the spectral data
of all active channel elements in ascending order.
*/
void SetEqualization (bool wantEQ, float Mask []) ;
/** Status Information Method.
This method returns the number of raw_data_blocks decoded until now.
*/
int GetNumberOfBlocksDecoded (void)
{
return m_BlockNumber ;
}
int GetDolbyBitstreamWarning(void)
{
return sDSEInfo.iDolbyBitStreamWarning;
}
bool HasDolbySpectralExtension(){return bHasDSEInfoStream;}
bool HasDoubleLengthXForm(){return (sDSEInfo.iUsesDoubleLengthXForm ? true : false);}
void IgnoreDolbyStream(bool bIgnore){bIgnoreDolbyStream=bIgnore;}
CAdifHeader* GetAdifHeader(void) { return &m_AdifHeader; }
/*Default Not Ignore*/
private:
//MSV:
void InitDSEInfo(CDolbyBitStream*poBS,CChannelElement*poChannelElement);
private:
bool bLookForDSEInfoStream;
bool bHasDSEInfoStream;
bool bIgnoreDolbyStream;
DOLBY_PAYLOAD_STRUCT sDSEInfo;
protected :
void ReadFillElement (void) ;
void ReadDolbyFillElement (void) ;
enum
{
ID_SCE = 0,
ID_CPE,
ID_CCE,
ID_LFE,
ID_DSE,
ID_PCE,
ID_FIL,
ID_END
} ;
CDolbyBitStream &m_bs ;
CSingleChannel sce ;
CChannelPair cpe ;
CSingleChannel lfe ;
CDataStream dse ;
CAdifHeader m_AdifHeader ;
int m_BlockNumber ;
int m_SelectedProgram ;
DECLARE_EXCEPTION(EUnimplemented, AAC_UNIMPLEMENTED, "Unimplemented Feature Used") ;
DECLARE_EXCEPTION(EDolbyNotSupported, AAC_DOLBY_NOT_SUPPORTED, "Not Supported") ;
DECLARE_EXCEPTION(EIllegalProfile, AAC_ILLEGAL_PROFILE, "Illegal Profile") ;
} ;
#endif

View File

@ -1,441 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/aacdecoderapi.cpp,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: aacdecode.cpp
* project : MPEG-2 AAC Decoder
* contents/description: AAC decoder API
*
\***************************************************************************/
#include "aacdecoderapi.h"
#include "aacdecoder.h"
#include "plainfile.h"
#include "bitbuffer.h"
#include "streaminfo.h"
#include "DataIO.h"
// sample frequency table
// converts sample frequency index to actual sample frequency
const unsigned int CAacDecoderApi::sfTab[16] =
{
96000,
88200,
64000,
48000,
44100,
32000,
24000,
22050,
16000,
12000,
11025,
8000,
0, // reserved
0, // reserved
0, // reserved
0 // reserved
};
DECLARE_EXCEPTION(ESyncError, AAC_SYNCERROR, "Synchronization Error!") ;
CAacDecoderApi::CAacDecoderApi (DataIOControl *paacInput) :
cbValid(0),
cbActual(0),
decoder(NULL),
input(NULL),
buffer(NULL),
info(NULL)
{
info = new CStreamInfo;
input = new CPlainFile(paacInput);
buffer = new CDolbyBitBuffer;
decoder = input->IsAdifHeaderPresent () ? new CAacDecoder (*input) : new CAacDecoder (*buffer);
decoder->FrameInit(*info);
}
CAacDecoderApi::~CAacDecoderApi ()
{
delete decoder;
delete input;
delete buffer;
delete info;
}
long CAacDecoderApi::Synchronize(AACStreamParameters *pAACStreamParameters)
{
long lReturn = ERR_SYNC_ERROR;
int iResyncCount = 5;
if (input->IsAdifHeaderPresent ())
{
/* Cannot resync to an ADIF stream! */
lReturn = ERR_NO_ERROR;
}
else
{
#if defined (_DEBUG)
// cout << "Resynchronizing" << endl;
#endif
buffer->ClearBytesSkipped();
while(lReturn != ERR_NO_ERROR && lReturn != ERR_END_OF_FILE && iResyncCount)
{
//Reset the block count:
buffer->ResetBlocks();
try
{
if (!cbValid)
{
cbValid = input->Read (readbuf, cbSize);
if (!cbValid)
buffer->SetEOF();
else
cbActual = cbValid;
}
buffer->Feed(readbuf, cbActual, cbValid);
if (buffer->IsDecodableFrame(*info))
{
lReturn = ERR_NO_ERROR;
}
else
{
throw ESyncError();
}
//Try to decode the first Raw Data Block to Get Dolby Info:
unsigned int uiValidBits1;
unsigned int uiValidBits2;
unsigned int uiBitsUsed;
uiValidBits1 = buffer->GetBitState();
decoder->DecodeFrame(NULL, *info); //this is only for ADTS!
uiValidBits2 = buffer->GetBitState();
uiBitsUsed = uiValidBits1 - uiValidBits2;
buffer->PushBack((int)uiBitsUsed);
if (!info->GetProtectionAbsent())
{
unsigned int CRCsyndrome;
buffer->IsCrcConsistent(&CRCsyndrome);
}
}
catch(CAacException& e)
{
/* If an exception was thrown, we have to clear this flag so that the next
* call to IsDecodableFrame() will not simply return 'true' without actually
* sync'ing and parsing the header.
*/
buffer->ClearFrameReadButNotDecoded();
lReturn = TranslateException(e);
iResyncCount--;
}
catch (...)
{
/* All exceptions thrown should be derived from CAacException and therefore
* should be caught above. Just in case, though we'll add this catch() statement
* to catch things like access violations, etc.
*/
lReturn = ERR_UNEXPECTED_ERROR;
break;
}
}
}
if (!lReturn)
{
if (FillStreamParameters(pAACStreamParameters))
{
lReturn = WARN_STREAM_PARAM_CHANGE;
}
/* frame_length is used here to pass up the # of bytes
* processed. This is actually the # of bytes skipped
* during the Synchronization() call.
*/
pAACStreamParameters->frame_length = buffer->GetBytesSkipped();
/* Clear the number of bytes skipped so that bytes_skipped
* no longer accumulates across calls to IsDecodableFrame()
*/
buffer->ClearBytesSkipped();
}
return lReturn;
}
long CAacDecoderApi::DecodeFrame (AudioIOControl *poAudioIO,
AACStreamParameters *pAACStreamParameters)
{
long lReturn = ERR_NO_ERROR;
buffer->ClearBytesSkipped();
try
{
if (!input->IsAdifHeaderPresent ())
{
if (!cbValid)
{
cbValid = input->Read (readbuf, cbSize);
if (!cbValid)
buffer->SetEOF();
else
cbActual = cbValid;
}
//
// feed up to 'cbActual' bytes into decoder buffer
//
buffer->Feed(readbuf, cbActual, cbValid);
//
// sync
//
if (!buffer->IsDecodableFrame(*info))
{
lReturn = ERR_INVALID_BITSTREAM;
}
/* Parse the entire frame so that CRC can be verified *before* performing the decode. */
unsigned int uiValidBits1;
unsigned int uiValidBits2;
unsigned int uiBitsUsed;
uiValidBits1 = buffer->GetBitState();
/* (NULL == parse frame only) */
decoder->DecodeFrame(NULL, *info); //
uiValidBits2 = buffer->GetBitState();
uiBitsUsed = uiValidBits1 - uiValidBits2;
/* This function performs a final sanity check for frame synchronization.
* It will read in the next 15 bits looking for the 0xFFF frame
* sync word, id, and layer. If it does not find a legal sync, it will throw an
* ESyncError() exception.
*/
VerifySync();
/* Push back entire frame (this does not include the header) before calling DecodeFrame() a second
* time to actually decode.
*/
buffer->PushBack((int)uiBitsUsed);
/* Verify CRC prior to actual decode. */
if (!info->GetProtectionAbsent())
{
unsigned int CRCsyndrome;
/* If the CRC is invalid, this function will throw an ECRCError() */
buffer->IsCrcConsistent(&CRCsyndrome);
}
}
/* Perform actual decode. */
decoder->DecodeFrame(poAudioIO, *info);
if (FillStreamParameters(pAACStreamParameters))
{
/* Output parameter (Fs, NumChans, etc.) has changed */
lReturn = WARN_STREAM_PARAM_CHANGE;
}
}
catch (CAacException& e)
{
/* Map the exception to a return code. */
lReturn = TranslateException(e);
/* frame_length is used here to pass up the # of bytes
* processed. An error has occurred so no bytes were
* processed. CAacDecoderAPI::Synchronication() will
* be called next to search for next syncword and return
* the number of bytes processed (i.e. bytes skipped).
*/
pAACStreamParameters->frame_length = 0;
}
catch (...)
{
/* All exceptions thrown should be derived from CAacException and therefore
* should be caught above. Just in case, though we'll add this catch() statement
* to catch things like access violations, etc.
*/
lReturn = ERR_UNEXPECTED_ERROR;
/* frame_length is used here to pass up the # of bytes
* processed. An error has occurred so no bytes were
* processed. CAacDecoderAPI::Synchronication() will
* be called next to search for next syncword and return
* the number of bytes processed (i.e. bytes skipped).
*/
pAACStreamParameters->frame_length = 0;
}
return lReturn;
}
/********** PRIVATE METHODS ***********/
long CAacDecoderApi::TranslateException(CAacException& e)
{
long lReturn = ERR_SUBROUTINE_ERROR; /* Default to generic subroutine error. */
static const int ErrorMap[][2] =
{
{AAC_UNIMPLEMENTED, ERR_SUBROUTINE_ERROR },
{AAC_NOTADIFHEADER, ERR_INVALID_ADIF_HEADER },
{AAC_DOESNOTEXIST, ERR_INVALID_BITSTREAM },
{AAC_ENDOFSTREAM, ERR_END_OF_FILE },
{AAC_SYNCERROR, ERR_SYNC_ERROR },
{AAC_CRCERROR, WARN_CRC_FAILED },
{AAC_INPUT_BUFFER_EMPTY, ERR_SYNC_ERROR },
{AAC_INVALIDCODEBOOK, ERR_SUBROUTINE_ERROR },
#ifdef MAIN_PROFILE
{AAC_INVALIDPREDICTORRESET, ERR_SUBROUTINE_ERROR },
#endif
{AAC_UNSUPPORTEDWINDOWSHAPE,ERR_SUBROUTINE_ERROR },
{AAC_DOLBY_NOT_SUPPORTED, ERR_SUBROUTINE_ERROR },
{AAC_ILLEGAL_PROFILE, ERR_ILLEGAL_PROFILE }
};
#if defined (_DEBUG)
// cout << e.Explain() << endl;
#endif
for (int i = 0; i < sizeof(ErrorMap) / (2 * sizeof(int)); i++)
{
if (e.What() == ErrorMap[i][0])
{
lReturn = ErrorMap[i][1];
break;
}
}
return lReturn;
}
void CAacDecoderApi::VerifySync(void)
{
/* This function performs a final sanity check for frame synchronization.
* It will read in the next 16 bits looking for one of two things:
*
* 1) The 0xFFF frame sync word plus 1-bit ID and 2-bit layer.
* 2) 0x5249 (RI) of a RIFF header (in the case of concatenated RIFF+ADTS files).
*
* If it does not find a legal sync, it will throw an ESyncError() exception.
* Either way, all bits read will be pushed back.
*/
int nSyncWord = buffer->Get(16);
buffer->PushBack(16);
/* When looking for ADTS sync, examine only the 15 MS bits because the LSB is the
* 'protection absent' flag.
*/
if (!buffer->EndOf() && (nSyncWord & 0xFFFE) != 0xFFF8 && (nSyncWord != 0x5249))
{
throw ESyncError();
}
}
bool CAacDecoderApi::FillStreamParameters(AACStreamParameters *pAACStreamParameters)
{
bool bParamChanged = false; //Assume no audio parameter change.
static int nPreviousFs = 0;
static int nPreviousNumChannels = 0;
if (input->IsAdifHeaderPresent ())
{
pAACStreamParameters->stream_format = ADIF;
}
else if (input->IsRiffHeaderPresent ())
{
pAACStreamParameters->stream_format = RIFFADTS;
}
else
{
pAACStreamParameters->stream_format = ADTS;
}
if(decoder->HasDolbySpectralExtension() && decoder->HasDoubleLengthXForm())
{
// When UseDblLengthXfrm is set, the function info->GetSamplingRate
// will double the sampling rate that it returns. Therefore,
// pAACStreamParameters->sampling_frequency gets set to the correct
// sampling rate in the code line below this one.
info->SetUseDblLengthXfrm(true);
}
else
{
info->SetUseDblLengthXfrm(false);
}
pAACStreamParameters->sampling_frequency = info->GetSamplingRate();
pAACStreamParameters->num_channels = info->GetChannels();
pAACStreamParameters->bitrate = info->GetBitRate();
/* frame_length is used here to pass up the # of bytes
* processed. bytes_skipped needs to be added in here
* to account for concatenated RIFF+ADTS files.
*/
pAACStreamParameters->frame_length = info->GetFrameLength() + buffer->GetBytesSkipped();
pAACStreamParameters->protection_absent = info->GetProtectionAbsent();
pAACStreamParameters->copyright = info->GetOriginalCopy();
pAACStreamParameters->original_copy = info->GetHome();
if (nPreviousFs && nPreviousNumChannels)
{
if (pAACStreamParameters->sampling_frequency != nPreviousFs)
{
bParamChanged = true;
}
if (pAACStreamParameters->num_channels != nPreviousNumChannels)
{
bParamChanged = true;
/* Reset the number of channels to 0 so that AacDecoder::DecodeFrame() can
* re-add them as it parses the new bitstream.
*/
decoder->GetAdifHeader()->GetProgramConfig(0).ResetNonMCConfig();
}
}
nPreviousFs = pAACStreamParameters->sampling_frequency;
nPreviousNumChannels = pAACStreamParameters->num_channels;
return bParamChanged;
}

View File

@ -1,150 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/aacdecoderapi.h,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: aacdecoderapi.h
* project : MPEG-2 AAC Decoder
* contents/description: AAC decoder API
*
\***************************************************************************/
#ifndef __AACDECODERAPI_H__
#define __AACDECODERAPI_H__
#include <stdio.h>
#include "DataIO.h"
#include "audio_io.h"
/** AAC defines */
#define AAC_MAX_PROGRAMS 16
#define ADTS 0
#define ADIF 1
#define RIFFADTS 2
/** API return value defines */
#define ERR_NO_ERROR (0)
/* Fatal errors (must re-sync) */
#define ERR_INVALID_BITSTREAM (1)
#define ERR_INVALID_ADIF_HEADER (2)
#define ERR_SYNC_ERROR (3)
#define ERR_SUBROUTINE_ERROR (4)
#define ERR_END_OF_FILE (5)
#define ERR_INVALID_ADTS_HEADER (6)
#define ERR_INPUT_BUFFER_ERROR (7)
#define ERR_OUTPUT_BUFFER_ERROR (8)
#define ERR_ILLEGAL_PROFILE (9)
#define ERR_ILLEGAL_SAMP_RATE (10)
#define ERR_ILLEGAL_DATA_RATE (11)
#define ERR_ILLEGAL_CHANNELS (12)
#define ERR_CANNOT_SYNC_TO_ADIF (13)
#define ERR_UNEXPECTED_ERROR (14)
#define ERR_USER_ABORT (15)
#define MAX_EXEC_ERRORS (16)//Insert new errors before this
/* Warnings (keep decoding) */
#define WARN_CRC_FAILED (-1)
#define WARN_STREAM_PARAM_CHANGE (-2)
/** structure defines for MPEG-2 AAC API Object */
typedef struct {
long sampling_frequency;
long num_channels;
long bitrate;
short stream_format;
long frame_length;
short protection_absent;
short copyright;
short original_copy;
} AACStreamParameters;
/* Forward declarations */
class CAacDecoder;
class CPlainFile;
class CDolbyBitBuffer;
class CStreamInfo;
class CAacException;
/** MPEG-2 AAC API Object.
This is the API object that interfaces with the application code.
It wraps the bitstream element objects and calls their individual decoding methods.
To indicate unexpected events and error conditions that prevent correct operation,
an exception derived from \Ref{CAacException} will be thrown that should be caught
by the calling application's decoding loop.
*/
class CAacDecoderApi
{
enum
{
cbSize = 2048
};
CAacDecoder *decoder;
CPlainFile *input;
CDolbyBitBuffer *buffer;
CStreamInfo *info;
unsigned char readbuf[cbSize];
unsigned int cbValid, cbActual;
const static unsigned int sfTab[16];
long TranslateException(CAacException& e);
void VerifySync(void);
bool FillStreamParameters(AACStreamParameters *paacStreamParameters);
public :
/** Object Constructor.
Instantiates a decoder object capable of decoding one stream of
MPEG-2 AAC Audio Data.
bs The \Ref{CBitStream} object that the decoder will read from.
*/
CAacDecoderApi(DataIOControl *paacInput);
/** Object Destructor.
*/
~CAacDecoderApi();
/** AAC API Synchronize Method
Synchronizes to stream
*/
long Synchronize(AACStreamParameters *paacStreamParameters);
/** AAC Decoding Method.
This method delivers one frame of decoded pcm audio data.
info The configuration information.
*/
long DecodeFrame ( AudioIOControl *ppcmOutput,
AACStreamParameters *paacStreamParameters) ;
} ;
#endif

View File

@ -1,88 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/adif.cpp,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: adif.cpp
* project : MPEG-2 AAC Decoder
* contents/description: audio data interchange format header
*
\***************************************************************************/
#include "adif.h"
// CAUTION: some elements read more than 16bits,
// this is not supported by CDolbyBitStream::Get().
CAdifHeader::CAdifHeader ()
: m_CopyrightIdPresent (1),
m_OriginalCopy (1),
m_Home (1),
m_BitstreamType (1),
m_NumProgramConfigElements (4)
{
m_BitRate = 0 ;
}
CAdifHeader::~CAdifHeader ()
{
}
#include<stdio.h>
void CAdifHeader::Read (CDolbyBitStream &bs)
{
char A[4];
A[0]=(char)(bs.Get (8));
A[1]=(char)(bs.Get (8));
A[2]=(char)(bs.Get (8));
A[3]=(char)(bs.Get (8));
if (A[0]!= 'A') throw ENoAdifHeader () ;
if (A[1]!= 'D') throw ENoAdifHeader () ;
if (A[2]!= 'I') throw ENoAdifHeader () ;
if (A[3]!= 'F') throw ENoAdifHeader () ;
if (m_CopyrightIdPresent.Read (bs))
{
for (int i = 0 ; i < 9 ; i++)
{
bs.Get (8) ; // CopyrightId
}
}
m_OriginalCopy.Read (bs) ;
m_Home.Read (bs) ;
m_BitstreamType.Read (bs) ;
m_BitRate = bs.Get (16) ;
m_BitRate <<= 7 ;
m_BitRate |= bs.Get (7) ;
//
m_NumProgramConfigElements.Read (bs) ;
for (int i = 0 ; i <= m_NumProgramConfigElements ; i++)
{
if (m_BitstreamType == 0)
{
// we don't care much about adif_buffer_fullness
bs.Get (16) ;
bs.Get (4) ;
}
m_ProgramConfigElement[i].Read (bs);
}
}
CProgramConfig &CAdifHeader::GetProgramConfig (int index)
{
return m_ProgramConfigElement [index] ;
}

View File

@ -1,87 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/adif.h,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: adif.h
* project : MPEG-2 AAC Decoder
* contents/description: audio data interchange format header
*
\***************************************************************************/
#ifndef __ADIF_H__
#define __ADIF_H__
#include "bitsequence.h"
#include "programcfg.h"
#include "exception.h"
class CDolbyBitStream ;
/** Audio Data Interchange Format.
This class is able to read the header information from an ADIF file
and serves as a container for the Program Configuration Elements
\Ref{CProgramConfig} found in the bitstream.
*/
class CAdifHeader
{
public :
CAdifHeader () ;
~CAdifHeader () ;
void Read (CDolbyBitStream &bs) ;
CProgramConfig &GetProgramConfig (int index) ;
unsigned int GetBitRate (void) const
{
return m_BitRate ;
}
unsigned int GetNumProgramConfigElements (void) const
{
return m_NumProgramConfigElements;
}
unsigned int GetOriginalCopy (void) const
{
return m_OriginalCopy;
}
unsigned int GetHome (void) const
{
return m_Home;
}
protected :
enum
{
MaximumPCEs = 16
} ;
CVLBBitSequence m_CopyrightIdPresent ;
CVLBBitSequence m_OriginalCopy ;
CVLBBitSequence m_Home ;
CVLBBitSequence m_BitstreamType ;
CVLBBitSequence m_NumProgramConfigElements ;
CProgramConfig m_ProgramConfigElement [MaximumPCEs] ;
unsigned int m_BitRate ;
DECLARE_EXCEPTION(ENoAdifHeader, AAC_NOTADIFHEADER, "Not Valid ADIF Header") ;
} ;
#endif

View File

@ -1,12 +0,0 @@
#ifndef NULLSOFT_APIH
#define NULLSOFT_APIH
#include <api/service/api_service.h>
extern api_service *serviceManager;
#define WASABI_API_SVC serviceManager
#include <api/memmgr/api_memmgr.h>
extern api_memmgr *memmgrApi;
#define WASABI_API_MEMMGR memmgrApi
#endif

View File

@ -1,48 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/audio_io.cpp,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* filename: audio_io.cpp
* project : MPEG-2 AAC Decoder
* contents/description: Audio I/O include file
*
\***************************************************************************/
#include "audio_io_dsp.h"
#include "audio_io.h"
AudioIOControl::AudioIOControl()
:psFormatInfo(NULL),
iError(AUDIO_ERROR_NONE)
{}
AudioIOControl::AudioIOControl(AudioIOControl&oCopyObject)
:psFormatInfo(oCopyObject.psFormatInfo),
iError(oCopyObject.iError)
{}
AudioIOControl& AudioIOControl::operator=(AudioIOControl&oAssignmentObject)
{
psFormatInfo=oAssignmentObject.psFormatInfo;
iError=oAssignmentObject.iError;
return *this;
}
AudioIOControl::~AudioIOControl()
{}
int AudioIOControl::SetFormatInfo(AUDIO_FORMATINFO*psFormatInfo)
{
this->psFormatInfo=psFormatInfo;
return 0;
}
const AUDIO_FORMATINFO *AudioIOControl::GetFormatInfo() const
{
return psFormatInfo;
}

View File

@ -1,92 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/audio_io.h,v 1.1 2009/04/28 20:21:07 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: audio_io.h
* project : MPEG-2 AAC Decoder
* contents/description: Audio i/o header file
*
\***************************************************************************/
#include <stdlib.h>
//Base Audio Device Errors:
#ifndef AUDIO_ERROR
#define AUDIO_ERROR
#define AUDIO_ERROR_NONE 0
#define AUDIO_ERROR_ENDOF 1
#define AUDIO_ERROR_NO_DEVICE -1
#define AUDIO_ERROR_DEVICE_FAIL -2
#endif
//Known Audio Formats:
#ifndef AUDIO_FORMAT
#define AUDIO_FORMAT
#define AUDIO_FORMAT_PRIVATE 0
#define AUDIO_FORMAT_WAV 1
#define AUDIO_FORMAT_AU 2
#define AUDIO_FORMAT_IMA_ADPCM 3
#define AUDIO_FORMAT_WAVMAPPING 4
#define AUDIO_FORMAT_DIRECTSOUND 5
#define AUDIO_FORMAT_CD_AUDIO 6
#define AUDIO_FORMAT_GENERIC_FILE 97
#define AUDIO_FORMAT_UNKNOWN 100
#endif
//Audio Format Info Structure:
#ifndef AUDIO_FORMAT_INFO
#define AUDIO_FORMAT_INFO
#define AUDIO_INPUT 0
#define AUDIO_OUTPUT 1
class AUDIO_FORMATINFO{
public:
unsigned int uiSampleRate;
unsigned char ucNChannels;
};
#endif
#ifndef AUDIO_IO_CONTROL
#define AUDIO_IO_CONTROL
class AudioIOControl{
private:
AUDIO_FORMATINFO *psFormatInfo;
public:
AudioIOControl();
AudioIOControl(AudioIOControl&);
AudioIOControl(int _iNChannels, unsigned int _uiSampleRate);
~AudioIOControl();
virtual AudioIOControl& operator=(AudioIOControl&);
virtual int SetFormatInfo(AUDIO_FORMATINFO*);
const AUDIO_FORMATINFO *GetFormatInfo() const;
//virtual int IO(unsigned char**,int)=0;
//virtual int IO(short**,int)=0;
virtual int IO(float**,int)=0;
protected:
int iError;
short *pshOutBuf;
};
#endif /* AUDIO_IO_CONTROL */

View File

@ -1,532 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/audio_io_dsp.cpp,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* filename: audio_io.cpp
* project : MPEG-2 AAC Decoder
* contents/description: Audio I/O include file
*
\***************************************************************************/
#include "audio_io_dsp.h"
#include <stdio.h>
#include <math.h>
#include <assert.h>
#define CLIP_DLY 1
static double scaletab[NSCALETAB];
static const double invsampratetab[NSAMPRATE] =
{ 0.00001041667,
0.00001133787,
0.00001562500,
0.00002083333,
0.00002267574,
0.00003125000,
0.00004166667,
0.00004535147,
0.00006250000,
0.00008333333,
0.00009070295,
0.00012500000
};
static short limitcnttab[NSAMPRATE] =
{
96000/(CLIPDLY * XLIMDELAY),
88200/(CLIPDLY * XLIMDELAY),
64000/(CLIPDLY * XLIMDELAY),
48000/(CLIPDLY * XLIMDELAY),
44100/(CLIPDLY * XLIMDELAY),
32000/(CLIPDLY * XLIMDELAY),
24000/(CLIPDLY * XLIMDELAY),
22050/(CLIPDLY * XLIMDELAY),
16000/(CLIPDLY * XLIMDELAY),
12000/(CLIPDLY * XLIMDELAY),
11025/(CLIPDLY * XLIMDELAY),
8000/(CLIPDLY * XLIMDELAY)
};
AudioIODSP::AudioIODSP(int _iNChannels, unsigned int _uiSampRate)
: iNChannels(_iNChannels), uiSampRate(_uiSampRate)
{
int chan, i;
double upper, lower, limdelta, upperlim;
hsClipDly = new DLY_VARS*[iNChannels];
hsSmoothVars = new SMOOTH_VARS*[iNChannels];
for (chan = 0; chan < iNChannels; chan++)
{
hsClipDly[chan] = new DLY_VARS;
hsClipDly[chan]->bufptr = new float[DLYBUFSZ];
for (i = 0; i < DLYBUFSZ; i++)
{
hsClipDly[chan]->bufptr[i] = 0.0f;
}
hsClipDly[chan]->bufsize = DLYBUFSZ;
hsClipDly[chan]->delay = CLIPDLY;
hsClipDly[chan]->index = 0;
hsSmoothVars[chan] = new SMOOTH_VARS;
hsSmoothVars[chan]->dcy_count = 0;
hsSmoothVars[chan]->dcy_samp = 0.0;
}
pshOutBuf = new short[iNChannels*DLYBUFSZ];
for (i = 0; i < iNChannels*DLYBUFSZ; i++)
{
pshOutBuf[i] = 0;
}
pfDlyBuf = new float[DLYBUFSZ];
bHardClip = false;
for (chan = 0; chan < MAXCHANNELS; chan++)
{
fPrevClipScale[chan] = 1.0;
for (i = 0; i < CLIPDLY; i++)
{
fPrevDlyBuf[chan][i] = 0.0;
}
}
for (i = 0; i < DLYBUFSZ; i++)
{
pfDlyBuf[i] = 0.0;
}
upper = PEAKLIMIT;
lower = PMAXF;
limdelta = (upper - lower) / (NSCALETAB - 1);
for (i = 0; i < NSCALETAB; i++)
{
upperlim = lower + i * limdelta;
scaletab[i] = (float)(lower / upperlim - INTERP_CORRECTION_FACT);
}
}
AudioIODSP::~AudioIODSP()
{
int chan;
if (hsClipDly != NULL)
{
for (chan = 0; chan < iNChannels; chan++)
{
delete[] hsClipDly[chan]->bufptr;
delete hsClipDly[chan];
}
delete [] hsClipDly;
}
if (hsSmoothVars != NULL)
{
for (chan = 0; chan < iNChannels; chan++)
{
delete hsSmoothVars[chan];
}
delete [] hsSmoothVars;
}
if (pshOutBuf != NULL)
{
delete[] pshOutBuf;
}
if (pfDlyBuf != NULL)
{
delete[] pfDlyBuf;
}
}
void AudioIODSP::SetSamplingRate(unsigned int _uiSampRate)
{
int iSRateIndex;
float invSamp;
this->uiSampRate = _uiSampRate;
/* Set up limiter decay/delay params. */
switch (uiSampRate)
{
case (8000):
iSRateIndex = 0;
break;
case (11025):
iSRateIndex = 1;
break;
case (12000):
iSRateIndex = 2;
break;
case (16000):
iSRateIndex = 3;
break;
case (22050):
iSRateIndex = 4;
break;
case (24000):
iSRateIndex = 5;
break;
case (32000):
iSRateIndex = 6;
break;
case (44100):
iSRateIndex = 7;
break;
case (48000):
iSRateIndex = 8;
break;
case (64000):
iSRateIndex = 9;
break;
case (88200):
iSRateIndex = 10;
break;
case (96000):
iSRateIndex = 11;
break;
default:
bHardClip = true; /* Non-standard sample rate. Enable hard limiter in this case. */
}
invSamp = (float)invsampratetab[iSRateIndex]; /* inverse of samp rate*/
initLimitCnt = limitcnttab[iSRateIndex];
dcyDelta = (float)(1.0 - invSamp * 2.0 * CLIPDLY);
}
void AudioIODSP::Float_to_Int(float **fInput, int *iOutput, int iLength, int grpIndex, int bitResolution)
{
short sTemp, outNdx, chan, samp;
int iPWordLengthLim, iNWordLengthLim;
float fSamp;
short interleaveOut = iNChannels;
for (chan = 0; chan < iNChannels; chan++)
{
outNdx = chan;
for (samp = 0; samp < iLength; samp++)
{
fSamp = fInput[chan][grpIndex * iLength + samp];
iPWordLengthLim = (1 << (bitResolution - 1)) - 1;
iNWordLengthLim = -iPWordLengthLim - 1;
fSamp=(fSamp > (float)iPWordLengthLim) ? (float)iPWordLengthLim : fSamp;
fSamp=(fSamp < (float)iNWordLengthLim) ? (float)iNWordLengthLim : fSamp;
sTemp = (fSamp >= 0.0f) ? (short)(fSamp + 0.5f) : (short)(fSamp - 0.5f);
iOutput[outNdx] = (int)(sTemp >> bitResolution);
outNdx += interleaveOut;
} // and samp loop
} // end chan loop
}
void AudioIODSP::Float_to_Short_Clip(float **fInput, short *sOutput, int iLength, int grpIndex)
{
short samp;
short chan;
short interleaveIn = 1;
short interleaveOut = iNChannels;
float fSamp;
int outNdx;
#ifdef CLIP_DLY
short dlysamp;
float fClipScale;
float limitAmount;
float fLookAhead;
float *pfDlyBufW = pfDlyBuf + CLIPDLY;
float *pfDlyBuf_LookAhead, *fPrevDlyPtr;
float currLimitAmount;
#endif
assert(iLength >= CLIPDLY);
for (chan = 0; chan < iNChannels; chan++)
{
#ifdef CLIP_DLY
fPrevDlyPtr = fPrevDlyBuf[chan];
for (samp = 0; samp < CLIPDLY; samp++)
{
pfDlyBuf[samp] = fPrevDlyPtr[samp];
}
/* !!! The following line may cause a compile time warning or BoundsChecker error !!!
This is a speed optimization and is intended to work this way. fPrevDlyPtr will point
to a location outside of the buffer. The code that followswill not write to this location. */
fPrevDlyPtr -= (iLength - CLIPDLY); /* cue up the Prev buffer to allow samp to begin indexing
at position zero when samp = iLength - CLIPDLY */
outNdx = chan;
pfDlyBuf_LookAhead = fInput[chan] + grpIndex * iLength;
for (samp = 0; samp < iLength; samp++)
{
/* Call CalcAtten() to compute the amount of gain attenuation to apply to bring the current sample
below the clip threshold. Note that CalcAtten contains a delay and decay factor for each channel
to govern transitioning out of limiting. Thus even if the current sample does not clip, the value
fClipScale could be < 1.0 due to the hysteresis of the limiter in CalcAtten. */
fLookAhead = (float)fabs(fInput[chan][samp + grpIndex * iLength]);
fClipScale = CalcAtten(hsSmoothVars[chan], fLookAhead, PMAXF);
/* Limit current sample to not clip, as determined by the return value from CalcAtten() */
currLimitAmount = pfDlyBuf_LookAhead[samp] * fClipScale;
(samp < iLength - CLIPDLY) ? (pfDlyBufW[samp] = currLimitAmount) :
(fPrevDlyPtr[samp] = currLimitAmount);
limitAmount = fPrevClipScale[chan] - fClipScale; /* limitAmount > 0: going further into limiting */
/* limitAmount < 0: coming out of limiting */
/* if difference between limit amount from previous sample, and current limit limit amount is non-zero,
proceed back through previous samples to apply more (or less) clipping. Delta clipping amount is
difference between current and previous clip amount. Note that the delta clipping amount slopes
linearly to zero additional clipping as dlysamp advances towards CLIPDLY samples from the current sample.*/
if (limitAmount > 0.0)
{
for (dlysamp = -1; dlysamp > -CLIPDLY; dlysamp--)
{
currLimitAmount = (float)(1.0 - limitAmount * (CLIPDLY + dlysamp) * CLIPNORM);
(samp + dlysamp < iLength - CLIPDLY) ? (pfDlyBufW[samp + dlysamp] *= currLimitAmount) :
(fPrevDlyPtr[samp + dlysamp] *= currLimitAmount);
}
}
fPrevClipScale[chan] = fClipScale;
}
for (samp = 0; samp < iLength; samp++)
{
fSamp = pfDlyBuf[samp];
if (bHardClip)
{
fSamp=(fSamp > 32767.0f) ? 32767.0f : fSamp;
fSamp=(fSamp < -32768.0f) ? -32768.0f : fSamp;
}
else
{
assert(fSamp <= 32767.0);
assert(fSamp >= -32768.0);
}
sOutput[outNdx] = (fSamp >= 0.0f) ? (short)(fSamp + 0.5f) : (short)(fSamp - 0.5f);
outNdx += interleaveOut;
}
#else
outNdx = chan;
for (samp = 0; samp < iLength; samp++)
{
fSamp = fInput[chan][grpIndex * iLength + samp];
fSamp=(fSamp>32767.0f)?32767.0f:fSamp;
fSamp=(fSamp<-32768.0f)?-32768.0f:fSamp;
sOutput[outNdx]=(fSamp>=0.0f)?(short)(fSamp+0.5f):(short)(fSamp-0.5f);
outNdx += interleaveOut;
} /* end samp loop */
#endif
} /* end chan loop */
}
///////////////////////////////////////////////////////////////////
// AudioIODSP::Limiter
//
// Input: fBuffer[chans][samples] - data to be limited
// iLength - # of samples to be limited
// grpIndex - which chunk of data to limit
//
// Output: fBuffer[chans][samples] - limited data is written over
// input data
///////////////////////////////////////////////////////////////////
void AudioIODSP::ApplyLimiter(float **fBuffer, int iLength, int grpIndex)
{
short samp;
short chan;
float fSamp;
#ifdef CLIP_DLY
short dlysamp;
float fClipScale;
float limitAmount;
float fLookAhead;
float *pfDlyBufW = pfDlyBuf + CLIPDLY;
float *pfDlyBuf_LookAhead, *fPrevDlyPtr;
float currLimitAmount;
#endif
assert(iLength >= CLIPDLY);
for (chan = 0; chan < iNChannels; chan++)
{
#ifdef CLIP_DLY
fPrevDlyPtr = fPrevDlyBuf[chan];
for (samp = 0; samp < CLIPDLY; samp++)
{
pfDlyBuf[samp] = fPrevDlyPtr[samp];
}
/* !!! The following line may cause a compile time warning or BoundsChecker error !!!
This is a speed optimization and is intended to work this way. fPrevDlyPtr will point
to a location outside of the buffer. The code that followswill not write to this location. */
fPrevDlyPtr -= (iLength - CLIPDLY); /* cue up the Prev buffer to allow samp to begin indexing
at position zero when samp = iLength - CLIPDLY */
pfDlyBuf_LookAhead = fBuffer[chan] + grpIndex * iLength;
for (samp = 0; samp < iLength; samp++)
{
/* Call CalcAtten() to compute the amount of gain attenuation to apply to bring the current sample
below the clip threshold. Note that CalcAtten contains a delay and decay factor for each channel
to govern transitioning out of limiting. Thus even if the current sample does not clip, the value
fClipScale could be < 1.0 due to the hysteresis of the limiter in CalcAtten. */
fLookAhead = (float)fabs(fBuffer[chan][samp + grpIndex * iLength]);
fClipScale = CalcAtten(hsSmoothVars[chan], fLookAhead, PMAXF);
/* Limit current sample to not clip, as determined by the return value from CalcAtten() */
currLimitAmount = pfDlyBuf_LookAhead[samp] * fClipScale;
(samp < iLength - CLIPDLY) ? (pfDlyBufW[samp] = currLimitAmount) :
(fPrevDlyPtr[samp] = currLimitAmount);
limitAmount = fPrevClipScale[chan] - fClipScale; /* limitAmount > 0: going further into limiting */
/* limitAmount < 0: coming out of limiting */
/* if difference between limit amount from previous sample, and current limit limit amount is non-zero,
proceed back through previous samples to apply more (or less) clipping. Delta clipping amount is
difference between current and previous clip amount. Note that the delta clipping amount slopes
linearly to zero additional clipping as dlysamp advances towards CLIPDLY samples from the current sample.*/
if (limitAmount > 0.0)
{
for (dlysamp = -1; dlysamp > -CLIPDLY; dlysamp--)
{
currLimitAmount = (float)(1.0 - limitAmount * (CLIPDLY + dlysamp) * CLIPNORM);
(samp + dlysamp < iLength - CLIPDLY) ? (pfDlyBufW[samp + dlysamp] *= currLimitAmount) :
(fPrevDlyPtr[samp + dlysamp] *= currLimitAmount);
}
}
fPrevClipScale[chan] = fClipScale;
}
for (samp = 0; samp < iLength; samp++)
{
fSamp = pfDlyBuf[samp];
if (bHardClip)
{
fSamp=(fSamp > 32767.0f) ? 32767.0f : fSamp;
fSamp=(fSamp < -32768.0f) ? -32768.0f : fSamp;
}
else
{
assert(fSamp <= 32767.0);
assert(fSamp >= -32768.0);
}
fBuffer[chan][samp + grpIndex * iLength] = (fSamp >= 0.0f) ? (fSamp + 0.5f) : (fSamp - 0.5f);
}
#else
for (samp = 0; samp < iLength; samp++)
{
fSamp = fBuffer[chan][grpIndex * iLength + samp];
fSamp=(fSamp>32767.0f)?32767.0f:fSamp;
fSamp=(fSamp<-32768.0f)?-32768.0f:fSamp;
fBuffer[chan][grpIndex * iLength + samp] = (fSamp>=0.0f)?(fSamp+0.5f):(fSamp-0.5f);
} /* end samp loop */
#endif
} /* end chan loop */
}
/****
calcatten()
This routine calculates the amount of attenuation that must be applied to
prevent clipping beyond PMAXF (32768.0f). The output scale value varies
between thresh-6 dB and thresh. The input value is the maximum sample. If the
max sample is greater than thresh, then compute a scalefactor that:
1. Is proportional to the amount fMaxSamp exceeds thresh.
2. Reflects recent history of clipping by applying a delay and decay
in transitioning out of clipping.
****/
inline float AudioIODSP::CalcAtten(SMOOTH_VARS *smoothvars, float fMaxSamp, float thresh)
{
float scale;
float interp;
short index;
float limvalscl;
if ((fMaxSamp > thresh) || (smoothvars->dcy_samp > thresh))
{
if (fMaxSamp > PEAKLIMITM1) /* Hard limit in case fSample is 10 dB above full scale */
{
scale = (float)PMAXF / fMaxSamp;
smoothvars->dcy_samp = (float)PEAKLIMITM1;
smoothvars->dcy_count = initLimitCnt;
}
else
{
/****
If the input maximum sample is greater than the previous maximum sample, then
assign the new maximum as the sample to be delayed and decayed. On each
subsequent call to CalcAtten(), if there are no samples greater than dcy_samp,
then dcy_samp will hold its value for initLimitCnt calls to CalcAtten() before
sloping down to thresh.
****/
if (fMaxSamp > smoothvars->dcy_samp)
{
smoothvars->dcy_samp = fMaxSamp;
smoothvars->dcy_count = initLimitCnt;
}
else
{
if (smoothvars->dcy_count != 0) /* If delay before decay onset, decrement */
{
smoothvars->dcy_count--;
}
else if (smoothvars->dcy_samp > thresh)
{
smoothvars->dcy_samp = smoothvars->dcy_samp * dcyDelta;
}
/* else smoothvars->dcy_samp < thresh which will cause scale = 1.0 and smoothvars->dcy_samp = 0.0
for subsequent samples. */
}
/* This finds the scaled inverse of limval using a lookup table. Note that
since limval should always be less than 1.0, the index will always be less
than 32 and scaletab[index+1] will not go beyond the bounds of its array.*/
if (smoothvars->dcy_samp > thresh)
{
limvalscl = (float)((smoothvars->dcy_samp - thresh) * CX_LIMSCALE);
index = (short)limvalscl;
interp = limvalscl - index;
scale = (float)(scaletab[index] + interp * (scaletab[index+1] - scaletab[index]));
}
else /* This else case is only entered if dcyDelta scales dcy_samp to be less than thresh */
{
scale = 1.0;
smoothvars->dcy_samp = 0.0;
}
}
}
else
{
scale = 1.0;
smoothvars->dcy_samp = 0.0;
}
return (scale);
}

View File

@ -1,81 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/audio_io_dsp.h,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: audio_io_dsp.h
* project : MPEG-2 AAC Decoder
* contents/description: Audio DSP processing header file
*
\***************************************************************************/
#ifndef __AUDIO_IO_DSP_H__
#define __AUDIO_IO_DSP_H__
#define CLIPDLY 10
#define CLIPNORM (1.0/CLIPDLY)
#define DLYBUFSZ 128
#define PMAXF 32767.0f
#define PMAXFM1 (PMAXF-1)
#define NMAXF -32768.0f
#define MAXCHANNELS 2
#define NSAMPRATE 12
#define XLIMDELAY 5 // delay is 1/5 second before decay stage of clip delay return segment.
#define NSCALETAB 33
#define PEAKLIMIT (3.16*PMAXF) // Allows for 10 dB of smoothed limiting. Any overshoot greater
// than 10 dB is hard limited.
#define PEAKLIMITM1 (PEAKLIMIT-1)
#define INTERP_CORRECTION_FACT 0.013 // compensates for error between actual inverse and estimated inverse
// in scaletab table.
#define CX_LIMSCALE ((NSCALETAB-1)/(PEAKLIMIT-PMAXF))
typedef struct {
short index;
short delay;
short bufsize;
float *bufptr;
} DLY_VARS;
typedef struct {
short dcy_count;
float dcy_samp;
} SMOOTH_VARS;
class AudioIODSP{
private:
DLY_VARS **hsClipDly;
SMOOTH_VARS **hsSmoothVars;
int iNChannels;
bool bHardClip;
float *pfDlyBuf;
float fPrevDlyBuf[MAXCHANNELS][CLIPDLY];
float fPrevClipScale[MAXCHANNELS];
short initLimitCnt; // Amount of time to delay before decaying the limiter scaling value.
float dcyDelta; // Dcy_delta is the amount to attenuate the limiter scaling value
// on each call to CalcAtten().
unsigned int uiSampRate;
float AudioIODSP::CalcAtten(SMOOTH_VARS *smoothvars, float fMaxSamp, float thresh);
public:
short *pshOutBuf;
AudioIODSP(int _iNChannels, unsigned int _uiSampRate = 0);
~AudioIODSP();
void Float_to_Short_Clip(float **fInput, short *sOutput, int iLength, int grpIndex);
void Float_to_Int(float **fInput, int *iOutput, int iLength, int grpIndex,
int bitResolution);
void ApplyLimiter(float **fBuffer, int iLength, int grpIndex);
void SetSamplingRate(unsigned int _uiSampRate);
};
#endif /* __AUDIO_IO_DSP_H__ */

View File

@ -1,599 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/bitbuffer.cpp,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: bitbuffer.cpp
* project : MPEG-2 AAC Decoder
* contents/description: memory input class with transport format
*
\***************************************************************************/
#include "bitbuffer.h"
#include "streaminfo.h"
static const unsigned int Adts_Value_SyncWord = 0xFFF ;
static const unsigned int Adts_Value_SyncMSByte = 0xFF ;
static const unsigned int Adts_Value_MinHeaderLength = 56 ;
static const unsigned int Adts_Length_SyncWord = 12 ;
static const unsigned int Adts_Length_Id = 1 ;
static const unsigned int Adts_Length_Layer = 2 ;
static const unsigned int Adts_Length_ProtectionAbsent = 1 ;
static const unsigned int Adts_Length_Profile = 2 ;
static const unsigned int Adts_Length_SamplingFrequencyIndex = 4 ;
static const unsigned int Adts_Length_PrivateBit = 1 ;
static const unsigned int Adts_Length_ChannelConfiguration = 3 ;
static const unsigned int Adts_Length_OriginalCopy = 1 ;
static const unsigned int Adts_Length_Home = 1 ;
static const unsigned int Adts_Length_CopyrightIdentificationBit = 1 ;
static const unsigned int Adts_Length_CopyrightIdentificationStart = 1 ;
static const unsigned int Adts_Length_FrameLength = 13 ;
static const unsigned int Adts_Length_BufferFullness = 11 ;
static const unsigned int Adts_Length_NumberOfRawDataBlocksInFrame = 2 ;
static const unsigned int Adts_Length_CrcCheck = 16 ;
static char copyright_id[COPYRIGHT_SIZE];
static char copyright_id_temp[COPYRIGHT_SIZE];
static unsigned int cid_bitcount;
static unsigned int cid_bytecount;
DECLARE_EXCEPTION(ECRCError, AAC_CRCERROR, "CRC calculation failed");
DECLARE_EXCEPTION(EInputBufferError, AAC_INPUT_BUFFER_EMPTY, "No sync word found!");
DECLARE_EXCEPTION(ESyncError, AAC_SYNCERROR, "Synchronization Error!") ;
CDolbyBitBuffer::CDolbyBitBuffer ()
: CDolbyBitStream ()
{
m_IsADTSCompliant=true;
m_bFrameReadButNotDecoded = false;
Initialize () ;
}
CDolbyBitBuffer::~CDolbyBitBuffer()
{
}
void CDolbyBitBuffer::Initialize (void)
{
m_ValidBits = 0 ;
m_ReadOffset = 0 ;
m_BitCnt = 0 ;
m_BitNdx = 0 ;
m_EOF = false ;
for (int i = 0 ; i < BufferSize ; i++)
{
m_Buffer [i] = 0 ;
}
m_BlocksLeftInFrame = 0 ;
m_Markers = 0 ;
m_FrameCrcValue = InvalidCrcValue ;
cid_bitcount = BYTE_SIZE; // init copyright id bit counter
cid_bytecount = COPYRIGHT_SIZE; // inti copyright id byte counter
buffer_fullness = 0;
last_buffer_fullness = 0;
last_frame_length = 0;
bytes_skipped = 0;
hold_bytes_skipped = false;
number_of_raw_data_blocks_in_frame = 0;
}
long CDolbyBitBuffer::Get (int nBits)
{
unsigned short tmp, tmp1 ;
int nWordNdx = (m_BitNdx >> 4) << 1 ;
int nBitsAvail = 16 - (m_BitNdx & 15) ;
tmp = m_Buffer [nWordNdx] ;
tmp <<= 8 ;
tmp |= m_Buffer [nWordNdx + 1] ;
tmp <<= (m_BitNdx & 15) ;
if (nBits > nBitsAvail)
{
nWordNdx = (nWordNdx + 2) & (BufferSize - 1) ;
tmp1 = m_Buffer [nWordNdx] ;
tmp1 <<= 8 ;
tmp1 |= m_Buffer [nWordNdx + 1] ;
tmp1 >>= (16 - (m_BitNdx & 15)) ;
tmp |= tmp1 ;
}
tmp >>= (16 - nBits) ;
m_BitNdx = (m_BitNdx+nBits) & (BufferBits - 1) ;
m_BitCnt += nBits ;
m_ValidBits -= nBits ;
return tmp ;
}
void CDolbyBitBuffer::PushBack (int n)
{
m_BitCnt -= n ;
m_ValidBits += n ;
m_BitNdx = (m_BitNdx - n) & (BufferBits - 1) ;
}
void CDolbyBitBuffer::ByteAlign (void)
{
long alignment = m_BitCnt % 8 ;
if (alignment)
{
Get (8 - alignment) ;
}
m_BitCnt = 0 ;
}
bool CDolbyBitBuffer::IsDecodableFrame (CStreamInfo &info)
{
ByteAlign ();
if (FrameReadButNotDecoded())
{
ClearFrameReadButNotDecoded();
return true;
}
tryagain :
SetPositionMarker (AncillaryElementStart) ;
bytes_skipped += GetBitCount() >> 3;
if (m_ValidBits < Adts_Value_MinHeaderLength)
{
if (m_EOF) throw EEndOfFile () ;
else return false ;
}
/* Since the 1-bit ID must be 1 and the 2-bit layer must be 0, we can
* look for 15 bits of sync rather than just 12. We'll get 16 bits from the
* buffer and mask the top 15 bits for ease of readability.
*/
if ((Get(Adts_Length_SyncWord + 4) & 0xFFFE) != 0xFFF8)
{
PushBack (Adts_Length_SyncWord + 4) ;
while (m_ValidBits >> 3)
{
if (Get (8) == Adts_Value_SyncMSByte)
{
PushBack (8) ;
if ((Get(Adts_Length_SyncWord + 4) & 0xFFFE) == 0xFFF8)
{
PushBack (Adts_Length_SyncWord + 4) ;
goto tryagain ;
}
else
{
/* Push back 8 of the 16 bits we read. This will advance us by a byte. */
PushBack (Adts_Length_SyncWord - 4);
}
}
}
// syncword not found in BitBuffer so accumulate
// bytes skipped before throwing an error
bytes_skipped += GetBitCount() >> 3;
// eaten up input
if (m_EOF)
{
throw EEndOfFile();
}
else
{
throw EInputBufferError();
}
}
/* Push back the 4 extra bits we read beyond the 12-bit sync word. */
PushBack(4);
// adts_fixed_header
id = Get (Adts_Length_Id) ;
layer = Get (Adts_Length_Layer) ;
protection_absent = Get (Adts_Length_ProtectionAbsent) ;
profile = Get (Adts_Length_Profile) ;
sampling_frequency_index = Get (Adts_Length_SamplingFrequencyIndex) ;
private_bit = Get (Adts_Length_PrivateBit) ;
channel_configuration = Get (Adts_Length_ChannelConfiguration) ;
original_copy = Get (Adts_Length_OriginalCopy) ;
home = Get (Adts_Length_Home) ;
// adts_variable_header
copyright_identification_bit = Get (Adts_Length_CopyrightIdentificationBit) ;
copyright_identification_start = Get (Adts_Length_CopyrightIdentificationStart) ;
frame_length = Get (Adts_Length_FrameLength) ;
buffer_fullness = Get (Adts_Length_BufferFullness) ;
number_of_raw_data_blocks_in_frame = Get (Adts_Length_NumberOfRawDataBlocksInFrame) ;
unsigned int i;
if ((m_ValidBits >> 3) < (frame_length - (Adts_Value_MinHeaderLength / 8)))
{
if (m_EOF)
throw EEndOfFile () ;
PushBack (Adts_Value_MinHeaderLength) ;
return false ;
}
SetPositionMarker (AncillaryElementStop) ;
// adts_error_check
if (!protection_absent)
{
m_FrameCrcValue = Get (Adts_Length_CrcCheck) ;
}
if (layer != 0)
{
return false ;
}
// // //
ByteAlign () ;
// // // Copy data from ADTS header to info structure
info.SetProtectionAbsent(protection_absent);
info.SetOriginalCopy(original_copy);
info.SetHome(home);
info.SetFrameLength(frame_length);
// Assemble copyright ID
if (copyright_identification_start)
{
cid_bitcount = 0;
cid_bytecount = 0;
for (i=0; i<COPYRIGHT_SIZE; i++)
copyright_id[i] = copyright_id_temp[i];
copyright_id_temp[cid_bytecount++] = copyright_identification_bit;
cid_bitcount++;
}
else
{
if (cid_bitcount++ < BYTE_SIZE && cid_bytecount < COPYRIGHT_SIZE)
{
copyright_id_temp[cid_bytecount] <<= 1 | (copyright_identification_bit & 1);
if (cid_bitcount >= BYTE_SIZE)
{
cid_bitcount = 0;
cid_bytecount++;
}
}
else
{
// here, if counter overflow: delete copyright info
for (i=0; i<COPYRIGHT_SIZE; i++)
copyright_id[i] = 0;
}
}
for (i = 0; i < COPYRIGHT_SIZE; i++)
info.SetCopyrightID(copyright_id[i], i); // write copyright ID to info structure
unsigned int nextsync = m_BitNdx >> 3 ;
unsigned int header_length = 7 + (protection_absent ? 0 : 2) ;
nextsync += frame_length - header_length ;
nextsync %= BufferSize ;
// this is the only place where we assume the bitstream to be
// aligned on byte boundaries (which is true for software),
// maybe someday we might want to remove this restriction.
/* If a 'RIFF' header is detected (due to concatenated RIFF+ADTS files), look beyond it
* for the next ADTS sync.
*/
if (m_Buffer[nextsync] == 'R' &&
m_Buffer[(nextsync + 1) % BufferSize] == 'I' &&
m_Buffer[(nextsync + 2) % BufferSize] == 'F' &&
m_Buffer[(nextsync + 3) % BufferSize] == 'F'
)
{
bool bFoundDataChunk = true;
unsigned int uiMarker = nextsync;
while (m_Buffer[nextsync] != 'd' ||
m_Buffer[(nextsync + 1) % BufferSize] != 'a' ||
m_Buffer[(nextsync + 2) % BufferSize] != 't' ||
m_Buffer[(nextsync + 3) % BufferSize] != 'a'
)
{
nextsync = (nextsync + 1) % BufferSize;
if (nextsync == uiMarker)
{
/* We've gone all the way around our circular buffer without ever finding a 'data' chunk. */
bFoundDataChunk = false;
break;
}
}
if (bFoundDataChunk)
{
/* Skip over data chunk ID and length. The next bytes should be our ADTS sync word. */
nextsync += 8;
nextsync %= BufferSize;
}
}
if (m_Buffer[nextsync] == Adts_Value_SyncMSByte && (m_Buffer[(nextsync + 1) % BufferSize] & 0xFE) == 0xF8)
{
if (info.GetRawSamplingRate ())
{
float flen = (float) (info.GetSamplesPerFrame () * (number_of_raw_data_blocks_in_frame + 1)) ;
float bitrate = (float) (8 * last_frame_length + 32 * (buffer_fullness - last_buffer_fullness)) ;
m_ActualBitrate += (unsigned int) (bitrate / (flen / info.GetRawSamplingRate ())) ;
last_buffer_fullness = buffer_fullness ;
last_frame_length = frame_length ;
info.SetBitRate (m_ActualBitrate) ;
}
info.SetSamplingRateIndex (sampling_frequency_index) ;
info.SetProfile (profile) ;
info.SetChannelConfig (channel_configuration) ;
m_BlocksLeftInFrame = number_of_raw_data_blocks_in_frame ;
return true ;
}
else
{
if (!m_EOF)
{
// syncword not found in next frame, but
// current frame's header has already been
// read, so add it to the # of bytes skipped
bytes_skipped += header_length;
// hold on to the bytes skipped so that we can
// accumulate them across multiple calls to
// the function IsDecodableFrame
HoldBytesSkipped();
throw ESyncError();
}
else
{
return true;
}
}
}
void CDolbyBitBuffer::ClearBytesSkipped(void)
{
if (!hold_bytes_skipped)
{
bytes_skipped = 0;
}
else
{
// clear flag for next time around
hold_bytes_skipped = false;
}
}
void CDolbyBitBuffer::Feed (unsigned char pBuf [], unsigned int cbSize, unsigned int &cbValid)
{
pBuf = &pBuf [cbSize - cbValid] ;
unsigned int bTotal = 0 ;
unsigned int bToRead = (BufferBits - m_ValidBits) >> 3 ;
unsigned int noOfBytes = (bToRead < cbValid) ? bToRead : cbValid ;
while (noOfBytes > 0)
{
// split read to buffer size
bToRead = BufferSize - m_ReadOffset ;
bToRead = (bToRead < noOfBytes) ? bToRead : noOfBytes ;
// copy 'bToRead' bytes from 'ptr' to inputbuffer
for (unsigned int i = 0 ; i < bToRead ; i++)
{
m_Buffer [m_ReadOffset + i] = pBuf [i] ;
}
// add noOfBits to number of valid bits in buffer
m_ValidBits += bToRead * 8 ;
bTotal += bToRead ;
pBuf += bToRead ;
m_ReadOffset = (m_ReadOffset + bToRead) & (BufferSize - 1) ;
noOfBytes -= bToRead ;
}
cbValid -= bTotal ;
// invalidate crc markers
m_FrameCrcValue = InvalidCrcValue ;
m_Markers = 0 ;
}
// crc stuff
void CDolbyBitBuffer::SetPositionMarker (MarkerPosition position)
{
switch (position)
{
case SecondIndividualChannelStart :
m_Markers++ ;
case ChannelElementStart :
case AncillaryElementStart :
m_MarkerList [m_Markers] = CMarker (position, m_ValidBits, m_BitCnt, m_BitNdx) ;
break ;
case ChannelElementStop :
case AncillaryElementStop :
for (int i = 0 ; i < ((m_MarkerList [m_Markers].what == SecondIndividualChannelStart) ? 2 : 1) ; i++)
{
int delimiter = m_BitNdx + ((m_BitNdx > m_MarkerList [m_Markers - i].m_BitNdx) ? 0 : BufferBits) ;
m_MarkerList [m_Markers - i].m_elementBits = delimiter - m_MarkerList [m_Markers - i].m_BitNdx ;
}
m_Markers++ ;
break ;
}
}
void CDolbyBitBuffer::IsCrcConsistent (unsigned int *crcValue)
{
if (m_FrameCrcValue == InvalidCrcValue)
return;
CMarker current (CurrentPosition, m_ValidBits, m_BitCnt, m_BitNdx) ;
*crcValue = 0xFFFF ;
for (unsigned int i = 0 ; i < m_Markers ; i++)
{
RestoreMarker (m_MarkerList [i]) ;
switch (m_MarkerList [i].what)
{
case ChannelElementStart :
UpdateCrc (*crcValue, m_MarkerList [i].m_elementBits, 192) ;
break ;
case SecondIndividualChannelStart :
UpdateCrc (*crcValue, m_MarkerList [i].m_elementBits, 128) ;
break ;
case AncillaryElementStart :
UpdateCrc (*crcValue, m_MarkerList [i].m_elementBits) ;
break ;
}
}
RestoreMarker (current) ;
if (*crcValue != m_FrameCrcValue)
throw ECRCError();
return;
}
void CDolbyBitBuffer::UpdateCrc (unsigned int &crcValue, int numberOfBits, int minimumBits)
{
static const unsigned int HIGHBIT_MASK = 0x8000 ;
static const unsigned int CRC_POLY = 0x8005 ;
static const unsigned int crcTable [] =
{
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
} ;
if (minimumBits && (numberOfBits > minimumBits))
numberOfBits = minimumBits ;
for (int bytes = 0 ; bytes < (numberOfBits >> 3) ; bytes++)
{
crcValue = ((crcValue << 8) & 0xFF00) ^ crcTable [((crcValue >> 8) ^ Get (8)) & 0x00FF] ;
}
for (int bits = 0 ; bits < (numberOfBits & 0x07) ; bits++)
{
int flag = ((crcValue & HIGHBIT_MASK) ? 1 : 0) ^ Get (1) ;
crcValue <<= 1 ;
crcValue &= 0xFFFF ;
if (flag) crcValue ^= CRC_POLY ;
}
if (minimumBits && (minimumBits > numberOfBits))
{
numberOfBits = minimumBits - numberOfBits ;
for (int bytes = 0 ; bytes < (numberOfBits >> 3) ; bytes++)
{
crcValue = ((crcValue << 8) & 0xFF00) ^ crcTable [(crcValue >> 8) & 0x00FF] ;
}
for (int bits = 0 ; bits < (numberOfBits & 0x07) ; bits++)
{
int flag = (crcValue & HIGHBIT_MASK) ? 1 : 0 ;
crcValue <<= 1 ;
crcValue &= 0xFFFF ;
if (flag) crcValue ^= CRC_POLY ;
}
}
}

View File

@ -1,292 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/bitbuffer.h,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: bitbuffer.h
* project : MPEG-2 AAC Decoder
* contents/description: memory input class with transport format
*
\***************************************************************************/
#ifndef __BITBUFFER_H__
#define __BITBUFFER_H__
#include "bitstream.h"
#include "aacdecoderapi.h"
class CStreamInfo ;
/** A Memory-Based Input Class.
This class implements a memory-based \Ref{CDolbyBitStream} interface with an ADTS
transport layer. It performs basic detection and synchronization work.
*/
class CDolbyBitBuffer : public CDolbyBitStream
{
public :
CDolbyBitBuffer () ;
virtual ~CDolbyBitBuffer () ;
// implementation of the CDolbyBitStream interface
virtual void ByteAlign (void) ;
virtual void PushBack (int n) ;
virtual long Get (int n) ;
unsigned int GetBitState() {return m_ValidBits;}
virtual void DecrementBlocks() { m_BlocksLeftInFrame--;}
virtual void ResetBlocks() {m_BlocksLeftInFrame=0;}
virtual void SetPositionMarker (MarkerPosition position) ;
/** Data Feed Method.
This method feeds a number of input bytes from an external source into
the modulo bitbuffer that the decoder will read from. The call consumes
up to cbSize bytes from a given array pBuf. cbValid will be updated
to indicate the number of valid bytes left in pBuf. If cbValid
equals zero, all the data in the input array has been consumed and
the buffer should be refilled from the external source.
@param pBuf Pointer to input buffer with bitstream data.
@param cbSize Total size of pBuf input buffer array.
@param cbValid Number of valid bytes left in pBuf array.
*/
virtual void Feed (unsigned char pBuf [], unsigned int cbSize, unsigned int &cbValid) ;
/** Bitstream Synchronization Method.
Call this method to see if there is decodable data in this bitbuffer
object. Only ever let the decoder read a frame from this object if
the IsDecodableFrame() method returned true. In addition, this method
will fill in a \Ref{CStreamInfo} object on success to indicate the detected
bitstream parameters.
@param info The configuration information.
*/
bool IsDecodableFrame (CStreamInfo &info) ;
/** CRC Evaluation Method.
Call this method to see if the optional CRC error protection checksum
carried in the ADTS transport header matches the most recently decoded
audio frame.
If error protection information is of concern, this method must be
called immediately after the decoder has read an entire audio frame
from this bitbuffer object.
*/
void IsCrcConsistent (unsigned int *crcValue) ;
/** EOF Notification Method.
After being notified by this method, the bitbuffer will throw an
EEndOfFile exception the next time it runs out of data.
*/
void SetEOF (void)
{
m_EOF = true ;
}
bool EndOf(void)
{
return m_EOF;
}
virtual void SetFrameReadButNotDecoded(void)
{
m_bFrameReadButNotDecoded = true;
}
virtual void ClearFrameReadButNotDecoded(void)
{
m_bFrameReadButNotDecoded = false;
}
virtual bool FrameReadButNotDecoded(void)
{
return m_bFrameReadButNotDecoded;
}
virtual unsigned int GetBitCount(void)
{
return m_BitCnt;
}
/** Initialization/Reset Method.
Clears the buffer's internal memory and removes any possibly pending data.
*/
virtual void Initialize (void) ;
virtual unsigned int GetFrameLength(){return frame_length;}
virtual unsigned int GetNRDB(){return number_of_raw_data_blocks_in_frame;}
long GetBytesSkipped(void) { return bytes_skipped; }
void ClearBytesSkipped(void);
void HoldBytesSkipped(void) { hold_bytes_skipped = true; }
protected :
enum
{
BufferSize = 8192,
BufferBits = BufferSize*8,
InvalidCrcValue = 0xFFFFFFFF,
MaximumMarkers = 25*4
} ;
unsigned int m_ValidBits;
unsigned int m_ReadOffset;
unsigned int m_BitCnt;
unsigned int m_BitNdx;
unsigned int m_BlocksLeftInFrame ;
unsigned int m_FrameCrcValue ;
bool m_EOF ;
bool m_bFrameReadButNotDecoded;
unsigned char m_Buffer [BufferSize] ;
// adts_fixed_header
unsigned int id;
unsigned int layer;
unsigned int protection_absent;
unsigned int profile;
unsigned int sampling_frequency_index;
unsigned int private_bit;
unsigned int channel_configuration;
unsigned int original_copy;
unsigned int home;
// adts_variable_header
unsigned int copyright_identification_bit;
unsigned int copyright_identification_start;
unsigned int frame_length;
unsigned int buffer_fullness;
unsigned int last_buffer_fullness;
unsigned int last_frame_length;
unsigned int number_of_raw_data_blocks_in_frame;
// used to track # of bytes skipped
// during a re-synchronization
long bytes_skipped;
bool hold_bytes_skipped;
DECLARE_EXCEPTION(EUnimplemented, AAC_UNIMPLEMENTED, "Unimplemented Feature Used") ;
// bitrate averaging helper class
class CAverageNumber
{
enum
{
MaximumSize = 16
} ;
public :
CAverageNumber ()
{
m_Index = 0 ;
m_ActualCount=0;
for (int i = 0 ; i < MaximumSize ; i++)
m_Value [i] = 0 ;
}
~CAverageNumber () {}
CAverageNumber &operator += (unsigned int val)
{
m_Value [m_Index++ % MaximumSize] = val ;
if(m_ActualCount<MaximumSize) m_ActualCount++;
return *this ;
}
operator unsigned int() const
{
unsigned int val = 0 ;
for (unsigned int i = 0 ; i < m_ActualCount ; i++)
val += m_Value [i] ;
if(m_ActualCount) val/=m_ActualCount;
else val=0;
return (val) ;
}
protected :
unsigned int m_Value [MaximumSize] ;
unsigned int m_Index ;
unsigned int m_ActualCount;
} ;
CAverageNumber m_ActualBitrate ;
// crc
void UpdateCrc (unsigned int &crcValue, int numberOfBits, int minimumBits = 0) ;
class CMarker
{
public :
CMarker () {}
~CMarker () {}
CMarker (MarkerPosition pos, unsigned int validBits, unsigned int bitCnt, unsigned int bitNdx)
{
what = pos ;
m_ValidBits = validBits ;
m_BitCnt = bitCnt ;
m_BitNdx = bitNdx ;
}
MarkerPosition what ;
unsigned int m_elementBits ;
unsigned int m_ValidBits;
unsigned int m_BitCnt;
unsigned int m_BitNdx;
} ;
CMarker m_MarkerList [MaximumMarkers] ;
unsigned int m_Markers ;
void RestoreMarker (CMarker &marker)
{
m_ValidBits = marker.m_ValidBits ;
m_BitCnt = marker.m_BitCnt ;
m_BitNdx = marker.m_BitNdx ;
}
} ;
#endif

View File

@ -1,54 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/bitsequence.cpp,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: bitsequence.h
* project : MPEG-2 AAC Decoder
* contents/description: bitstream helper object
*
\***************************************************************************/
#include "bitsequence.h"
#include "bitstream.h"
CVLBBitSequence::CVLBBitSequence (const int length, const int value)
{
m_Length = length ;
m_Value = value ;
}
CVLBBitSequence::CVLBBitSequence (const int length /* == 0 */)
{
m_Length = length ;
m_Value = 0 ;
}
CVLBBitSequence::~CVLBBitSequence ()
{
}
CVLBBitSequence &CVLBBitSequence::operator= (int value)
{
m_Length = 0 ;
m_Value = value ;
return *this ;
}
CVLBBitSequence &CVLBBitSequence::operator+= (int value)
{
m_Value += value ;
return *this ;
}
int CVLBBitSequence::Read (CDolbyBitStream &bs, const int length)
{
m_Length = length ;
return Read (bs) ;
}

View File

@ -1,63 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/bitsequence.h,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: bitsequence.h
* project : MPEG-2 AAC Decoder
* contents/description: bitstream helper object
*
\***************************************************************************/
#ifndef __VLB_BITSEQUENCE_H__
#define __VLB_BITSEQUENCE_H__
#include "bitstream.h"
/** Bitstream Parser Utility.
This helper class is basically a numerical value that can read itself from a
\Ref{CDolbyBitStream} interface for convenience. The decoder almost completely
does the bitstream parsing through CVLBBitSequence rather than \Ref{CDolbyBitStream} directly.
*/
class CVLBBitSequence
{
public :
CVLBBitSequence (const int length = 0) ;
CVLBBitSequence (const int length, const int value) ;
~CVLBBitSequence () ;
int Read (CDolbyBitStream& bs, const int length) ;
int Read (CDolbyBitStream& bs)
{
m_Value = bs.Get (m_Length) ;
return m_Value ;
}
operator int() const
{
return m_Value ;
}
CVLBBitSequence &operator=(int) ;
CVLBBitSequence &operator+=(int) ;
protected :
int m_Length ;
int m_Value ;
} ;
#endif

View File

@ -1,150 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/bitstream.h,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: bitstream.h
* project : MPEG-2 AAC Decoder
* contents/description: input abstract base class
*
\***************************************************************************/
#ifndef __VLB_BITSTREAM_H__
#define __VLB_BITSTREAM_H__
#include "exception.h"
/** General Bitstream Input Base Class.
This abstract base class defines the interface that the \Ref{CAacDecoder} object will
read all of its bitstream input data from. Specialized classes for specific
application scenarios have to be derived from this interface.
*/
class CDolbyBitStream
{
public :
/// Object Constructor.
CDolbyBitStream ()
{
m_AdifHeaderPresent = false ;
m_RiffHeaderPresent = false ;
m_IsADTSCompliant = false;
}
/// Object Destructor.
virtual ~CDolbyBitStream () {}
/** Byte Alignment Method.
This method performs the byte_alignment() syntactic method on the input stream,
i.e. some bits will be discarded so that the next bits to be read would be aligned
on a byte boundary with respect to the last call to ByteAlign().
*/
virtual void ByteAlign (void) = 0 ;
/** Push Back Method.
This method ungets a number of bits erroneously read by the last Get() call.
NB: The number of bits to be stuffed back into the stream may never exceed the
number of bits returned by the immediately preceding Get() call.
@param n The number of bits to be pushed back.
*/
virtual void PushBack (int n) = 0 ;
/** Get Bits Method.
This method returns a number of sequential bits from the input bitstream.
This is the one and only read operation that the decoder will ever perform,
i.e. _all_ the data goes through this call.
@param n The number of bits to be retrieved.
*/
virtual long Get (int n) = 0 ;
/** ADIF detection Method.
This method indicates whether the decoder should read in and parse an ADIF header
before starting to decode the first frame of audio data.
*/
bool IsAdifHeaderPresent (void)
{
return m_AdifHeaderPresent ;
}
/** RIFF/ADTS detection Method.
This method indicates whether the decoder should read in and parse a RIFF header
before starting to decode the first frame of audio data.
*/
bool IsRiffHeaderPresent (void)
{
return m_RiffHeaderPresent;
}
bool IsADTSCompliant (void)
{
return m_IsADTSCompliant;
}
// CRC Markers for SetPositionMarker ().
typedef enum
{
ChannelElementStart,
ChannelElementStop,
AncillaryElementStart,
AncillaryElementStop,
SecondIndividualChannelStart,
CurrentPosition
} MarkerPosition ;
/** Position Marker Setting Method.
The decoder core can call this method to set position markers
in the bitstream. this facility can be used to implement
error-protection mechanisms in a derived class, for example,
if the underlying transport layer supports such a feature.
*/
virtual void SetPositionMarker (MarkerPosition position) {}
virtual void DecrementBlocks(){}
virtual void ResetBlocks() {}
virtual unsigned int GetFrameLength(){return 0;} //UNKNOWN IN ADIF
virtual unsigned int GetNRDB(){return 0;} //UNKNOWN IN ADIF
virtual void SetFrameReadButNotDecoded(void){}
virtual void ClearFrameReadButNotDecoded(void){}
virtual bool FrameReadButNotDecoded(void){return false;}
virtual unsigned int GetBitCount(void) {return 0;};
protected :
DECLARE_EXCEPTION(EDoesNotExist, AAC_DOESNOTEXIST, "Bitstream does not exist") ;
DECLARE_EXCEPTION(EEndOfFile, AAC_ENDOFSTREAM, "End of file reached") ;
bool m_AdifHeaderPresent;
bool m_RiffHeaderPresent;
bool m_IsADTSCompliant;
} ;
#endif

View File

@ -1,224 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/block.cpp,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: block.cpp
* project : MPEG-2 AAC Decoder
* contents/description: base class for CLongBlock, CShortBlock
*
\***************************************************************************/
#include <math.h> // pow()
#include "block.h"
#include "bitstream.h"
#include "channelinfo.h"
CBlock::CBlock (CChannelInfo &info)
: m_IcsInfo (info)
{
m_LongWindow [0] = m_OnlyLongWindowSine ;
m_ShortWindow [0] = m_OnlyShortWindowSine ;
#ifdef ONLY_SINE_WINDOW
m_LongWindow [1] = m_OnlyLongWindowSine ;
m_ShortWindow [1] = m_OnlyShortWindowSine ;
#else
m_LongWindow [1] = m_OnlyLongWindowKBD ;
m_ShortWindow [1] = m_OnlyShortWindowKBD ;
#endif
}
CBlock::~CBlock ()
{
}
int CBlock::DecodeHuffmanWord (CDolbyBitStream &bs, const unsigned int (*CodeBook) [HuffmanEntries])
{
unsigned int val, len ;
unsigned int index = 0, bits = HuffmanBits ;
while (true)
{
val = CodeBook [index][bs.Get (HuffmanBits)] ;
len = val >> 16 ;
if (len == 0)
{
index = val & 0xFFFF ;
bits += HuffmanBits ;
continue ;
}
else
{
if (len != bits)
{
bs.PushBack (bits - len) ;
}
val &= 0xFFFF ;
break ;
}
}
return val ;
}
int CBlock::GetEscape (CDolbyBitStream &bs, const int q)
{
int i, off, neg ;
if (q < 0)
{
if (q != -16) return q ;
neg = 1 ;
}
else
{
if (q != +16) return q ;
neg = 0;
}
for (i = 4 ; ; i++)
{
if (bs.Get (1) == 0)
break ;
}
if (i > 16)
{
off = bs.Get (i - 16) << 16 ;
off |= bs.Get (16) ;
}
else
{
off = bs.Get (i) ;
}
i = off + (1 << i) ;
if (neg) i = -i ;
return i ;
}
int CBlock::UnpackIndex (int idx, int *qp, const CodeBookDescription *hcb)
{
if (hcb->Dimension == 4)
{
int index = idx << 2 ;
qp [0] = hcb->NTuples [index] ;
qp [1] = hcb->NTuples [index + 1] ;
qp [2] = hcb->NTuples [index + 2] ;
qp [3] = hcb->NTuples [index + 3] ;
}
else
{
int index = idx << 1 ;
qp [0] = hcb->NTuples [index] ;
qp [1] = hcb->NTuples [index + 1] ;
}
return hcb->Dimension ;
}
float CBlock::InverseQuantize (int q)
{
if (q > 0)
{
if (q < InverseQuantTableSize)
{
return (m_InverseQuantTable [q]) ;
}
else
{
return (static_cast<float>(pow (static_cast<float>(q), 4.0F / 3.0F))) ;
}
}
else
{
q = -q ;
if (q < InverseQuantTableSize)
{
return (-m_InverseQuantTable [q]) ;
}
else
{
return (static_cast<float>(-pow (static_cast<float>(q), 4.0F / 3.0F))) ;
}
}
}
void CBlock::Read (CDolbyBitStream &bs, const int global_gain)
{
ReadSectionData (bs) ;
ReadScaleFactorData (bs, global_gain) ;
m_PulseData.Read (bs) ;
m_Tns.Read (m_IcsInfo, bs) ;
CVLBBitSequence GainControlDataPresent (1) ;
GainControlDataPresent.Read (bs) ;
if (GainControlDataPresent)
{
throw EUnimplemented () ;
}
ReadSpectralData (bs) ;
}
void CBlock::ApplyTools (void)
{
m_Tns.Apply (m_IcsInfo, *this) ;
}
CBlock &operator+= (CBlock &lhs, CBlock &rhs)
{
// operator+= sums up the spectral bins of two blocks
// in the frequency domain (must switch together)
// add two long blocks
if (lhs.m_IcsInfo.IsLongBlock () && rhs.m_IcsInfo.IsLongBlock ())
{
if (lhs.m_IcsInfo.GetWindowShape () == rhs.m_IcsInfo.GetWindowShape ())
{
for (int i = 0 ; i < CLongBlock::MaximumBins ; i++)
{
lhs.AccessSpectralData () [i] += rhs.AccessSpectralData () [i] ;
}
}
}
// add two short blocks
else if (lhs.m_IcsInfo.IsShortBlock () && rhs.m_IcsInfo.IsShortBlock ())
{
if (lhs.m_IcsInfo.GetWindowShape () == rhs.m_IcsInfo.GetWindowShape ())
{
for (int win = 0 ; win < CShortBlock::MaximumWindows ; win++)
{
for (int i = 0 ; i < CShortBlock::MaximumBins ; i++)
{
lhs.AccessSpectralData (win) [i] += rhs.AccessSpectralData (win) [i] ;
}
}
}
}
return lhs ;
}

View File

@ -1,343 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/block.h,v 1.2 2011/06/13 02:06:02 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: block.h
* project : MPEG-2 AAC Decoder
* contents/description: Defines abstract base class CBlock
*
* $Header: /cvs/root/winamp/vlb/block.h,v 1.2 2011/06/13 02:06:02 audiodsp Exp $
*
\***************************************************************************/
#ifndef __BLOCK_H__
#define __BLOCK_H__
#include "exception.h"
#include "pulsedata.h"
#include "tns.h"
#include "DolbyPayload.h"
class CChannelInfo ;
class CDolbyBitStream ;
class COverlapAddBuffer ;
#ifdef MAIN_PROFILE
class CPrediction ;
#endif
/** Spectral Data For Current Frame.
This abstract base class defines the interface and some common helper functions
for the classes holding the spectral coefficients of the current frame.
*/
class CBlock
{
// allow tools to call AccessXXX() methods
friend class CJointStereo ;
#ifdef MAIN_PROFILE
friend class CPrediction ;
#endif
friend class CTns ;
friend class CCouplingChannel ;
friend CBlock &operator+= (CBlock &, CBlock &) ;
public :
CBlock (CChannelInfo &) ;
virtual ~CBlock () ;
void Read (CDolbyBitStream &bs, const int global_gain) ;
virtual void ApplyTools (void) ;
virtual void FrequencyToTime (COverlapAddBuffer &, float [], const int) = 0 ;
//MSV
virtual void FrequencyToTime_Fast (COverlapAddBuffer&) = 0 ;
virtual void FrequencyToTime (COverlapAddBuffer &) = 0;
virtual SECTION_INFORMATION_STRUCT* GetSectionInfo() = 0;
// gimmicks
virtual void ApplyEqualizationMask (float Mask []) = 0 ;
// // //
enum
{
EqualizationMaskLength = 16,
ZERO_HCB = 0,
ESCBOOK = 11,
NSPECBOOKS = ESCBOOK + 1,
BOOKSCL = NSPECBOOKS,
RESERVED_HCB = 13,
INTENSITY_HCB2 = 14,
INTENSITY_HCB = 15,
InverseQuantTableSize = 1024,
ExpTableSize = 128,
HuffmanBits = 4,
HuffmanEntries = (1 << HuffmanBits)
} ;
virtual float *AccessSpectralData (int window = 0) = 0 ;
virtual float *AccessOutput() =0;
virtual short *AccessShortOutput() =0;
short FloatToShort (float pcm)
{
if (pcm < 0.0F)
{
pcm = -pcm ;
pcm += 0.5F ;
return (pcm > 32768.0F) ? -32768 : -((short) pcm) ;
}
else
{
pcm += 0.5F ;
return (pcm > 32767.0F) ? 32767 : (short) pcm ;
}
}
protected :
// overridable readers
virtual void ReadSectionData (CDolbyBitStream &bs) = 0 ;
virtual void ReadScaleFactorData (CDolbyBitStream &bs, const int global_gain) = 0 ;
virtual void ReadSpectralData (CDolbyBitStream &bs) = 0 ;
// tools interface
virtual int *AccessCodeBooks (int group) = 0 ;
virtual int *AccessScaleFactors (int group) = 0 ;
//
CChannelInfo &m_IcsInfo ;
CPulseData m_PulseData ;
CTns m_Tns ;
// Huffman Decoding
typedef struct tagCodeBookDescription
{
int Dimension ;
bool IsSigned ;
const unsigned int (*CodeBook)[HuffmanEntries] ;
const int *NTuples ;
} CodeBookDescription ;
int DecodeHuffmanWord (CDolbyBitStream &bs, const unsigned int (*CodeBook) [HuffmanEntries]) ;
int UnpackIndex (int idx, int *qp, const CodeBookDescription *hcb) ;
int GetEscape (CDolbyBitStream &bs, const int q) ;
static const CodeBookDescription HuffmanCodeBooks [13] ;
//
float InverseQuantize (int q) ;
int m_SectBits ;
// window functions
static const float m_OnlyLongWindowSine [1024] ;
static const float m_OnlyLongWindowKBD [1024] ;
static const float m_OnlyShortWindowSine [128] ;
static const float m_OnlyShortWindowKBD [128] ;
const float *m_LongWindow [2] ;
const float *m_ShortWindow [2] ;
// imdct
void Split (const float [], float [], float [], const float [], int) ;
void Merge (float [], const float [], const float [], int ) ;
void Dct1024 (float vec [], const float cosTerms []) ;
void Dct128 (float vec [], const float cosTerms []) ;
void Dct16 (float vec [], const float cosTerms []) ;
// speed-up tabes
static const float m_InverseQuantTable [CBlock::InverseQuantTableSize] ;
static const float m_ExpTable [CBlock::ExpTableSize] ;
// exceptions
DECLARE_EXCEPTION(EInvalidCodeBook, AAC_INVALIDCODEBOOK, "Invalid Huffman Codebook") ;
DECLARE_EXCEPTION(EUnimplemented, AAC_UNIMPLEMENTED, "Unimplemented Feature Used") ;
// platform dependent stuff
#if defined (WIN32) && defined (_M_IX86)
void PentiumOverlap (float output [], float spec [], float prev [], unsigned int stride);
#endif
} ;
/** Spectral Data For One Long Block.
This class holds the spectral coefficients for the current frame in case it's
a start block, a stop block or a regular long block.
*/
class CLongBlock : public CBlock
{
friend CBlock &operator+= (CBlock &, CBlock &) ;
public :
CLongBlock (CChannelInfo &) ;
virtual ~CLongBlock () ;
virtual void FrequencyToTime (COverlapAddBuffer &, float [], const int) ;
//MSV
virtual void FrequencyToTime_Fast (COverlapAddBuffer &) ;
virtual void FrequencyToTime (COverlapAddBuffer &);
// gimmicks
virtual void ApplyEqualizationMask (float Mask []) ;
//MSV:
virtual SECTION_INFORMATION_STRUCT* GetSectionInfo(){return (&sSectionInfoStruct);}
virtual float *AccessSpectralData (int window = 0) ;
virtual float *AccessOutput() {return m_Output;}
virtual short *AccessShortOutput() {return m_ShortOutput;}
private:
SECTION_INFORMATION_STRUCT sSectionInfoStruct;
protected :
// overridden readers
virtual void ReadSectionData (CDolbyBitStream &bs) ;
virtual void ReadScaleFactorData (CDolbyBitStream &bs, int const global_gain) ;
virtual void ReadSpectralData (CDolbyBitStream &bs) ;
// tools interface
virtual int *AccessCodeBooks (int group) ;
virtual int *AccessScaleFactors (int group) ;
int GetMaximumBins() { return MaximumBins; } ;
// private
void InverseTransform (float data []) ;
void ApplyWindowFunction (COverlapAddBuffer &Previous) ;
enum
{
MaximumScaleFactorBands = 64,
MaximumBins = 1024
} ;
int m_CodeBook [CLongBlock::MaximumScaleFactorBands] ;
int m_ScaleFactor [CLongBlock::MaximumScaleFactorBands] ;
float m_SpectralCoefficient [2 * CLongBlock::MaximumBins] ;
float m_Output[1024];
short m_ShortOutput[1024];
// platform dependent stuff
#if defined (WIN32) && defined (_M_IX86)
void PentiumWindow (float spec [], const float prev [], const float curr []) ;
#endif
} ;
/** Spectral Data For One Short Block.
This class holds the spectral coefficients for the current frame in case it's
a short block, i.e. consists of eight short windows.
*/
class CShortBlock : public CBlock
{
friend CBlock &operator+= (CBlock &, CBlock &) ;
public :
CShortBlock (CChannelInfo &) ;
virtual ~CShortBlock () ;
virtual void FrequencyToTime (COverlapAddBuffer &, float [], const int) ;
//MSV
virtual void FrequencyToTime_Fast (COverlapAddBuffer &) ;
virtual void FrequencyToTime (COverlapAddBuffer &);
// gimmicks
virtual void ApplyEqualizationMask (float Mask []) ;
virtual float *AccessSpectralData (int window = 0) ;
virtual float *AccessOutput() {return m_Output;}
virtual short *AccessShortOutput() {return m_ShortOutput;}
virtual SECTION_INFORMATION_STRUCT* GetSectionInfo(){return (&sSectionInfoStruct);}
private:
SECTION_INFORMATION_STRUCT sSectionInfoStruct;
protected :
// overridden readers
virtual void ReadSectionData (CDolbyBitStream &bs) ;
virtual void ReadScaleFactorData (CDolbyBitStream &bs, const int global_gain) ;
virtual void ReadSpectralData (CDolbyBitStream &bs) ;
// tools interface
virtual int *AccessCodeBooks (int group) ;
virtual int *AccessScaleFactors (int group) ;
// private
void InverseTransform (float data []) ;
void TransformWindows (COverlapAddBuffer &Previous, float EightWindowsBuffer []) ;
//
enum
{
MaximumWindows = 8,
MaximumGroups = MaximumWindows,
MaximumScaleFactorBands = 16,
MaximumBins = 128
} ;
int m_CodeBook [CShortBlock::MaximumGroups][CShortBlock::MaximumScaleFactorBands] ;
int m_ScaleFactor [CShortBlock::MaximumGroups][CShortBlock::MaximumScaleFactorBands] ;
float m_SpectralCoefficient [CShortBlock::MaximumWindows][2 * CShortBlock::MaximumBins] ;
float m_Output[1024];
short m_ShortOutput[1024];
} ;
#endif

View File

@ -1,843 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/channel.cpp,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: channel.cpp
* project : MPEG-2 AAC Decoder
* contents/description: independent channel stream object
*
\***************************************************************************/
#include <new.h> // displacement new
#include "channel.h"
#include "bitstream.h"
#include "bitsequence.h"
// // // Base class for CSingleChannel, CChannelPair
CChannelElement::CChannelElement (CDolbyBitStream &bs)
: m_bs (bs),
m_GlobalGain (8)
{
m_WantEqualizer = false ;
m_WantSpectralData = false ;
}
CChannelElement::~CChannelElement ()
{}
CBlock *CChannelElement::ReadICS (CChannelInfo &ics_info, unsigned long *memory)
{
// allocates and reads one individual_channel_stream
m_GlobalGain.Read (m_bs) ;
if (!ics_info.IsValid ())
{
ics_info.Read (m_bs) ;
}
CBlock *block ;
if (ics_info.IsLongBlock ())
{
block = new (static_cast<void *>(memory)) CLongBlock (ics_info) ;
}
else
{
block = new (static_cast<void *>(memory)) CShortBlock (ics_info) ;
}
block->Read (m_bs, m_GlobalGain) ;
// 'block' points to the same location as 'memory', but keeping the
// m_Block pointers as class members saves us a lot of typecasting
return block ;
}
void CChannelElement::SetEqualization (bool wantEQ, float Mask [])
{
m_WantEqualizer = wantEQ ;
if (wantEQ)
{
for (int i = 0 ; i < CBlock::EqualizationMaskLength ; i++)
{
m_EqualizerMask [i] = Mask [i] ;
}
}
}
// // // CSingleChannel wraps single_channel_element()
CSingleChannel::CSingleChannel (CDolbyBitStream &theBitstream)
: CChannelElement (theBitstream)
{
#ifdef MAIN_PROFILE
m_Prediction.FullReset () ;
#endif
poIMDCTObject=new IMDCTObject(4096,256);
poNormalIMDCTObject=new IMDCTObject(2048,128);
ppfData=new float*[1];
ppshData=new short*[1];
m_poAudioDSP = new AudioIODSP(1);
}
CSingleChannel::~CSingleChannel ()
{
delete poIMDCTObject;
delete poNormalIMDCTObject;
delete[] ppfData;
delete[] ppshData;
delete m_poAudioDSP;
}
void CSingleChannel::Read (const CStreamInfo &si)
{
m_IcsInfo.Reset (si) ;
m_Block = ReadICS (m_IcsInfo, m_BlockMemory) ;
}
void CSingleChannel::Decode (AudioIOControl *poAudioIO, CStreamInfo &info, int stride /* = 1 */)
{
if (m_IcsInfo.IsMainProfile ())
{
#ifdef MAIN_PROFILE
m_Prediction.Apply (m_IcsInfo, *m_Block) ;
#else
throw EIllegalProfile();
#endif
}
m_Block->ApplyTools () ;
if (m_WantEqualizer)
{
m_Block->ApplyEqualizationMask (m_EqualizerMask) ;
}
m_Block->FrequencyToTime_Fast (m_Previous) ;
ppfData[0]=m_Block->AccessOutput();
// ApplyLimiter is called to minimize distortion from clipping. The limiter can only
// be applied to 128 samples at a time so there must be several calls to limit all 1024
// samples in a block. This is due to the way the buffer allocation is done in the
// constructor of the AudioIODSP class.
int iLength = 1024;
int grpIndex = 0;
short sThisLength = (iLength < DLYBUFSZ) ? iLength : DLYBUFSZ;
m_poAudioDSP->SetSamplingRate(info.GetSamplingRate());
for (int sSamp = 0; sSamp < iLength; sSamp += sThisLength)
{
m_poAudioDSP->ApplyLimiter(ppfData, sThisLength, grpIndex);
sThisLength = ((iLength - sThisLength * grpIndex++) < DLYBUFSZ) ?
(iLength - sThisLength * grpIndex++) : DLYBUFSZ;
}
poAudioIO->IO(ppfData,1024);
m_Block->~CBlock () ;
}
void CSingleChannel::DecodeDolby ( AudioIOControl *poAudioIO,
DOLBY_PAYLOAD_STRUCT *psDSEInfo,
CStreamInfo &info,
int stride /* = 1 */)
{
int iWindowType;
int iWindowShape;
int i,j,grp_index,win_in_grp_index;
int startingBinForThisWindow, startingBaseBandBin, halfWindowLength;
int overall_window_number1, overall_window_number2;
int firstWinThisGrp;
float avgCopyEnergies[8][SE_MAX_NUM_BANDS];
int iBandCounter;
// previous window sequence
// need to keep this variable around to handle legacy code which forces
// spectral extend to rely on a special case for WindowSequence == 3
static int previousWindowSequence = 0;
// get pointer to spectral data
// these calls really need to depend on the blocktype -
// short blocks require the window number (0-7) to be passed
// to AccessSpectralData(); long blocks do not require this argument.
ppfData[0]=m_Block->AccessSpectralData();
// Apply DNS here.
// Only apply DNS if we have valid DNS information read from the SE bitstream.
// If there was a SE bitstream reading error of *any* kind, do not apply DNS.
if (psDSEInfo->iDolbyBitStreamWarning == 0)
{
// applyDNS() applies to all window groups at the same time, so there is
// no need to call applyDNS() for each window group individually.
applyDNS(ppfData[0],&psDSEInfo->asDNSInfoStruct[0],previousWindowSequence);
}
#ifdef MAIN_PROFILE
if (m_IcsInfo.IsMainProfile ())
{
m_Prediction.Apply (m_IcsInfo, *m_Block) ;
}
#endif
iWindowType=m_IcsInfo.GetWindowSequence();
iWindowShape=m_IcsInfo.GetWindowShape();
//Do TNS:
m_Block->ApplyTools () ;
// Spectral Extension.
// for each window group...
overall_window_number1 = 0;
overall_window_number2 = 0;
for(grp_index=0;grp_index<psDSEInfo->iGroupCount[0];grp_index++)
{
firstWinThisGrp = overall_window_number1;
// for each window within the current window group...
for(win_in_grp_index=0;
win_in_grp_index<psDSEInfo->iGroupLength[0][grp_index];
win_in_grp_index++,overall_window_number1++)
{
// compute some parameters depedent on short/long blocktype, window group number, and transform length
if (psDSEInfo->asDNSInfoStruct[0].iWindowSequence == 2)
{
// SHORT BLOCKS
startingBinForThisWindow = overall_window_number1*256;
startingBaseBandBin = 12;
halfWindowLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 256 : 128;
}
else
{
// LONG, STOP, START blocks
startingBinForThisWindow = 0;
#ifdef NEW_BUFFER_MODEL
startingBaseBandBin = 96;
#else
startingBaseBandBin = 100;
#endif
halfWindowLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 2048 : 1024;
}
computeAvgCopyEnergies(&ppfData[0][startingBinForThisWindow],
startingBaseBandBin,
psDSEInfo->aiCopyStop[0],
psDSEInfo->num_se_bands[0],
psDSEInfo->seBands[0][grp_index],
halfWindowLength,
psDSEInfo->asDNSInfoStruct[0].iWindowSequence,
avgCopyEnergies[overall_window_number1]);
}/* win_in_grp_index */
/* compute average energies for each group before passing into spectral extend */
// accumulate energies for this group
for(win_in_grp_index=1;
win_in_grp_index<psDSEInfo->iGroupLength[0][grp_index];
win_in_grp_index++)
{
for(iBandCounter=0;iBandCounter<psDSEInfo->num_se_bands[0];iBandCounter++)
{
avgCopyEnergies[firstWinThisGrp][iBandCounter] += avgCopyEnergies[firstWinThisGrp + win_in_grp_index][iBandCounter];
}
}
// find the average energy for this group
for(iBandCounter=0;iBandCounter<psDSEInfo->num_se_bands[0];iBandCounter++)
{
avgCopyEnergies[firstWinThisGrp][iBandCounter] /= psDSEInfo->iGroupLength[0][grp_index];
}
// copy this average energy to all values in the avgCopyEnergies array which correspond to windows in the current group
for(win_in_grp_index=1;
win_in_grp_index<psDSEInfo->iGroupLength[0][grp_index];
win_in_grp_index++)
{
for(iBandCounter=0;iBandCounter<psDSEInfo->num_se_bands[0];iBandCounter++)
{
avgCopyEnergies[firstWinThisGrp + win_in_grp_index][iBandCounter] = avgCopyEnergies[firstWinThisGrp][iBandCounter];
}
}
// for each window within the current window group...
for (win_in_grp_index=0;
win_in_grp_index<psDSEInfo->iGroupLength[0][grp_index];
win_in_grp_index++,overall_window_number2++)
{
firstWinThisGrp = overall_window_number2;
// check to see if dolby bitstream was read correctly.
// If so, spectral extend all windows, whether we're dealing with a long block or short block
if (psDSEInfo->iDolbyBitStreamWarning == 0)
{
// compute some parameters dependent short/long blocktype, window group number, and transform length
if (psDSEInfo->asDNSInfoStruct[0].iWindowSequence == 2)
{
// SHORT blocks
// The constant 256 is ugly here - but is equal to (2 * CShortBlock::MaximumBins).
// This is the spacing of the mdct coefficients in the buffer ppfData[n], independent
// of whether we're using a single or double length transform.
startingBinForThisWindow = overall_window_number2*256;
startingBaseBandBin = 12;
halfWindowLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 256 : 128;
}
else
{
// LONG, STOP, START blocks
startingBinForThisWindow = 0;
#ifdef NEW_BUFFER_MODEL
startingBaseBandBin = 96;
#else
startingBaseBandBin = 100;
#endif
halfWindowLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 2048 : 1024;
}
spectralExtend(&ppfData[0][startingBinForThisWindow],
startingBaseBandBin,
psDSEInfo->aiCopyStop[0],
psDSEInfo->sfm[0][grp_index],
psDSEInfo->num_se_bands[0],
psDSEInfo->seBands[0][grp_index],
psDSEInfo->delta_power_values[0][grp_index],
psDSEInfo->fdamp[0][grp_index],
halfWindowLength,
psDSEInfo->asDNSInfoStruct[0].iWindowSequence,
psDSEInfo->iSEPowerResolution,
previousWindowSequence,
avgCopyEnergies[overall_window_number2]);
}
else
{
// zero out the extension band of each window if there was a bitstream error.
// be careful here- we may be dealing with many short blocks or a single long block
if (psDSEInfo->asDNSInfoStruct[0].iWindowSequence == 2)
{
// SHORT blocks
for(i=0;i<8;i++) {
for(j=psDSEInfo->aiCopyStop[0]; j<256; j++)
{
ppfData[0][i*256+j]=0.0f;
}
}
}
else
{
// LONG, STOP, START blocks
for (i = psDSEInfo->aiCopyStop[0]; i<2048; i++)
{
ppfData[0][i] = 0.0f;
}
}
} // if psDSEInfo->iDolbyBitStreamWarning...
} // for win_in_grp_index
} // for grp_index
/* Double all TCs if using a double length x-form so we do not lose 6dB
* after the imdct.
*/
if (psDSEInfo->iUsesDoubleLengthXForm)
{
for (i = 0; i < 2048; i++)
{
ppfData[0][i] *= 2.0f;
}
}
// do the transform
if (psDSEInfo->iUsesDoubleLengthXForm)
{
poIMDCTObject->Transform(ppfData[0],iWindowType,iWindowShape);
// The limiter can only be applied to 128 samples at a time
// so there must be several calls to limit all 2048 samples
// in a block. This is due to the way the buffer allocation
// is done in the constructor of the AudioIODSP class
int iLength = 2048;
int grpIndex = 0;
int sThisLength = (iLength < DLYBUFSZ) ? iLength : DLYBUFSZ;
m_poAudioDSP->SetSamplingRate(info.GetSamplingRate());
for (int sSamp = 0; sSamp < iLength; sSamp += sThisLength)
{
// Limiter is applied to ppfData
m_poAudioDSP->ApplyLimiter(ppfData, sThisLength, grpIndex);
sThisLength = ((iLength - sThisLength * grpIndex++) < DLYBUFSZ) ?
(iLength - sThisLength * grpIndex++) : DLYBUFSZ;
}
poAudioIO->IO(ppfData,2048);
}
else
{
poNormalIMDCTObject->Transform(ppfData[0],iWindowType,iWindowShape);
// Apply Limiter so that distortion from clipping is minimized
// The limiter can only be applied to 128 samples at a time
// so there must be several calls to limit all 2048 samples
// in a block. This is due to the way the buffer allocation
// is done in the constructor of the AudioIODSP class
int iLength = 1024;
int grpIndex = 0;
short sThisLength = (iLength < DLYBUFSZ) ? iLength : DLYBUFSZ;
m_poAudioDSP->SetSamplingRate(info.GetSamplingRate());
for (int sSamp = 0; sSamp < iLength; sSamp += sThisLength)
{
// Limiter is applied to ppfData
m_poAudioDSP->ApplyLimiter(ppfData, sThisLength, grpIndex);
sThisLength = ((iLength - sThisLength * grpIndex++) < DLYBUFSZ) ?
(iLength - sThisLength * grpIndex++) : DLYBUFSZ;
}
poAudioIO->IO(ppfData,1024);
}
// update previousWindowSequence
previousWindowSequence = psDSEInfo->asDNSInfoStruct[0].iWindowSequence;
m_Block->~CBlock () ;
}
// // // CChannelPair wraps channel_pair_element()
CChannelPair::CChannelPair (CDolbyBitStream &theBitstream)
: CChannelElement (theBitstream),
m_CommonWindow (1)
{
#ifdef MAIN_PROFILE
m_Prediction [L].FullReset () ;
m_Prediction [R].FullReset () ;
#endif
ppoIMDCTObject = new IMDCTObject* [2];
ppoNormalIMDCTObject = new IMDCTObject* [2];
for (int n = 0; n < 2; n++)
{
ppoIMDCTObject[n] = new IMDCTObject(4096,256);
ppoNormalIMDCTObject[n] = new IMDCTObject(2048,128);
}
ppfData = new float*[2];
ppshData = new short*[2];
m_poAudioDSP = new AudioIODSP(2);
}
CChannelPair::~CChannelPair ()
{
for (int n = 0; n < 2; n++)
{
delete ppoIMDCTObject[n];
delete ppoNormalIMDCTObject[n];
}
delete[] ppoIMDCTObject;
delete[] ppoNormalIMDCTObject;
delete[] ppfData;
delete[] ppshData;
delete m_poAudioDSP;
}
void CChannelPair::Read (const CStreamInfo &si)
{
m_IcsInfo [L].Reset (si) ;
m_IcsInfo [R].Reset (si) ;
if (m_CommonWindow.Read (m_bs))
{
m_IcsInfo [L].Read (m_bs) ;
m_IcsInfo [R] = m_IcsInfo [L] ;
m_JointStereo.Read (m_IcsInfo [L], m_bs) ;
}
m_Block [L] = ReadICS (m_IcsInfo [L], m_BlockMemory [L]) ;
m_bs.SetPositionMarker (CDolbyBitStream::SecondIndividualChannelStart) ;
m_Block [R] = ReadICS (m_IcsInfo [R], m_BlockMemory [R]) ;
}
void CChannelPair::Decode (AudioIOControl *poAudioIO, CStreamInfo &info, int stride /* = 1 */)
{
#ifdef MAIN_PROFILE
// - apply prediction tool to left (coded) channel
// - calculate right channel from intensity position
// - apply prediction tool to right channel
// unfortunately this breaks m_JointStereo::Apply() into two steps
#endif
if (m_CommonWindow)
{
m_JointStereo.ApplyMS (m_IcsInfo [L], *m_Block [L], *m_Block [R]) ;
}
#ifdef MAIN_PROFILE
if (m_IcsInfo [L].IsMainProfile ())
{
m_Prediction [L].Apply (m_IcsInfo [L], *m_Block [L]) ;
}
#endif
if (m_CommonWindow)
{
m_JointStereo.ApplyIS (m_IcsInfo [L], *m_Block [L], *m_Block [R]) ;
}
#ifdef MAIN_PROFILE
if (m_IcsInfo [R].IsMainProfile ())
{
m_Prediction [R].Apply (m_IcsInfo [R], *m_Block [R]) ;
}
#endif
for (int channel = 0 ; channel < Channels ; channel++)
{
m_Block [channel]->ApplyTools () ;
if (m_WantEqualizer)
{
m_Block [channel]->ApplyEqualizationMask (m_EqualizerMask) ;
}
m_Block [channel]->FrequencyToTime_Fast (m_Previous [channel]) ;
ppfData[channel]=m_Block[channel]->AccessOutput();
}
// ApplyLimiter is called to minimize distortion from clipping. The limiter can only
// be applied to 128 samples at a time so there must be several calls to limit all
// samples in a block. This is due to the way the buffer allocation is done in the
// constructor of the AudioIODSP class.0
int iLength = 1024;
int grpIndex = 0;
int sThisLength = (iLength < DLYBUFSZ) ? iLength : DLYBUFSZ;
m_poAudioDSP->SetSamplingRate(info.GetSamplingRate());
for (int sSamp = 0; sSamp < iLength; sSamp += sThisLength)
{
m_poAudioDSP->ApplyLimiter(ppfData, sThisLength, grpIndex);
sThisLength = ((iLength - sThisLength * grpIndex++) < DLYBUFSZ) ?
(iLength - sThisLength * grpIndex++) : DLYBUFSZ;
}
poAudioIO->IO(ppfData,1024);
m_Block [L]->~CBlock () ;
m_Block [R]->~CBlock () ;
}
void CChannelPair::DecodeDolby (AudioIOControl *poAudioIO,
DOLBY_PAYLOAD_STRUCT *psDSEInfo,
CStreamInfo &info,
int stride /* = 1 */)
{
int channel, win_in_grp_index;
int iWindowType;
int iWindowShape;
int i,j,grp_index;
int startingBinForThisWindow;
int startingBaseBandBin;
int halfWindowLength;
int overall_window_number1, overall_window_number2;
float avgCopyEnergies[8][SE_MAX_NUM_BANDS];
int iBandCounter;
int firstWinThisGrp;
// need to keep this variable around to handle legacy code which forces
// spectral extend to rely on a special case for WindowSequence == 3
static int previousWindowSequence[2] = {0,0};
// apply DNS to each channel
// these calls really need to depend on the blocktype -
// short blocks require the window number (0-7) to be passed
// to AccessSpectralData(); long blocks do not require this argument.
ppfData[L]=m_Block[L]->AccessSpectralData();
ppfData[R]=m_Block[R]->AccessSpectralData();
// Apply DNS here
// Only apply DNS if we have valid DNS information read from the SE bitstream.
// If there was a SE bitstream reading error of *any* kind, do not apply DNS
if (psDSEInfo->iDolbyBitStreamWarning == 0)
{
// applyDNS() applies to all window groups at the same time, so there is
// no need to call applyDNS() for each window group individually.
applyDNS(ppfData[L],&psDSEInfo->asDNSInfoStruct[L],previousWindowSequence[L]);
applyDNS(ppfData[R],&psDSEInfo->asDNSInfoStruct[R],previousWindowSequence[R]);
}
#ifdef MAIN_PROFILE
// - apply prediction tool to left (coded) channel
// - calculate right channel from intensity position
// - apply prediction tool to right channel
// unfortunately this breaks m_JointStereo::Apply() into two steps
#endif
if (m_CommonWindow)
{
m_JointStereo.ApplyMS (m_IcsInfo [L], *m_Block [L], *m_Block [R]) ;
}
#ifdef MAIN_PROFILE
if (m_IcsInfo [L].IsMainProfile ())
{
m_Prediction [L].Apply (m_IcsInfo [L], *m_Block [L]) ;
}
#endif
if (m_CommonWindow)
{
m_JointStereo.ApplyIS (m_IcsInfo [L], *m_Block [L], *m_Block [R]) ;
}
#ifdef MAIN_PROFILE
if (m_IcsInfo [R].IsMainProfile ())
{
m_Prediction [R].Apply (m_IcsInfo [R], *m_Block [R]) ;
}
#endif
for (channel = 0 ; channel < Channels ; channel++)
{
iWindowType=m_IcsInfo[channel].GetWindowSequence();
iWindowShape=m_IcsInfo[channel].GetWindowShape();
ppfData[channel]=m_Block[channel]->AccessSpectralData();
// Apply TNS
m_Block [channel]->ApplyTools () ;
// Spectral Extension for Stereo Goes Here!
// for each window group...
overall_window_number1 = 0;
overall_window_number2 = 0;
for (grp_index=0;grp_index<psDSEInfo->iGroupCount[channel];grp_index++)
{
firstWinThisGrp = overall_window_number1;
// another window_in_group loop: compute average energy in this group for all bands in the current group
for (win_in_grp_index=0;
win_in_grp_index<psDSEInfo->iGroupLength[channel][grp_index];
win_in_grp_index++,overall_window_number1++)
{
// compute some parameters dependent short/long blocktype, window group number, and transform length
if (psDSEInfo->asDNSInfoStruct[channel].iWindowSequence == 2)
{
// SHORT blocks
// The constant 256 is ugly here - but is equal to (2 * CShortBlock::MaximumBins).
// This is the spacing of the mdct coefficients in the buffer ppfData[n], independent
// of whether we're using a single or double length transform.
startingBinForThisWindow = overall_window_number1*256;
startingBaseBandBin = 12;
halfWindowLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 256 : 128;
}
else
{
// LONG, STOP, START blocks
startingBinForThisWindow = 0;
#ifdef NEW_BUFFER_MODEL
startingBaseBandBin = 96;
#else
startingBaseBandBin = 100;
#endif
halfWindowLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 2048 : 1024;
}
computeAvgCopyEnergies(&ppfData[channel][startingBinForThisWindow],
startingBaseBandBin,
psDSEInfo->aiCopyStop[channel],
psDSEInfo->num_se_bands[channel],
psDSEInfo->seBands[channel][grp_index],
halfWindowLength,
psDSEInfo->asDNSInfoStruct[channel].iWindowSequence,
avgCopyEnergies[overall_window_number1]);
} /* win_in_grp_index */
/* compute average energies for each group before passing into spectral extend */
// accumulate energies for this group
for(win_in_grp_index=1;
win_in_grp_index<psDSEInfo->iGroupLength[channel][grp_index];
win_in_grp_index++)
{
for(iBandCounter=0;iBandCounter<psDSEInfo->num_se_bands[channel];iBandCounter++)
{
avgCopyEnergies[firstWinThisGrp][iBandCounter] += avgCopyEnergies[firstWinThisGrp + win_in_grp_index][iBandCounter];
}
}
// find the average energy for this group
for(iBandCounter=0;iBandCounter<psDSEInfo->num_se_bands[channel];iBandCounter++)
{
avgCopyEnergies[firstWinThisGrp][iBandCounter] /= psDSEInfo->iGroupLength[channel][grp_index];
}
// copy this average energy to all values in the avgCopyEnergies array which correspond to windows in the current group
for(win_in_grp_index=1;
win_in_grp_index<psDSEInfo->iGroupLength[channel][grp_index];
win_in_grp_index++)
{
for(iBandCounter=0;iBandCounter<psDSEInfo->num_se_bands[channel];iBandCounter++)
{
avgCopyEnergies[firstWinThisGrp + win_in_grp_index][iBandCounter] = avgCopyEnergies[firstWinThisGrp][iBandCounter];
}
}
// for each window within the current window group...
for (win_in_grp_index=0;
win_in_grp_index<psDSEInfo->iGroupLength[channel][grp_index];
win_in_grp_index++,overall_window_number2++)
{
firstWinThisGrp = overall_window_number2;
// check to see if dolby bitstream was read correctly.
// If so, spectral extend all windows, whether we're dealing with a long block or short block
if (psDSEInfo->iDolbyBitStreamWarning == 0)
{
// compute some parameters dependent short/long blocktype, window group number, and transform length
if (psDSEInfo->asDNSInfoStruct[channel].iWindowSequence == 2)
{
// SHORT blocks
// The constant 256 is ugly here - but is equal to (2 * CShortBlock::MaximumBins).
// This is the spacing of the mdct coefficients in the buffer ppfData[n], independent
// of whether we're using a single or double length transform.
startingBinForThisWindow = overall_window_number2*256;
startingBaseBandBin = 12;
halfWindowLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 256 : 128;
}
else
{
// LONG, STOP, START blocks
startingBinForThisWindow = 0;
#ifdef NEW_BUFFER_MODEL
startingBaseBandBin = 96;
#else
startingBaseBandBin = 100;
#endif
halfWindowLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 2048 : 1024;
}
spectralExtend (&ppfData[channel][startingBinForThisWindow],
startingBaseBandBin,
psDSEInfo->aiCopyStop[channel],
psDSEInfo->sfm[channel][grp_index],
psDSEInfo->num_se_bands[channel],
psDSEInfo->seBands[channel][grp_index],
psDSEInfo->delta_power_values[channel][grp_index],
psDSEInfo->fdamp[channel][grp_index],
halfWindowLength,
psDSEInfo->asDNSInfoStruct[channel].iWindowSequence,
psDSEInfo->iSEPowerResolution,
previousWindowSequence[channel],
avgCopyEnergies[overall_window_number2]);
}
else
{
// zero out the extension band of each window if there was a bitstream error.
// be careful here- we may be dealing with many short blocks or a single long block
if (psDSEInfo->asDNSInfoStruct[channel].iWindowSequence == 2)
{
// SHORT blocks
for(i=0;i<8;i++) {
for(j=psDSEInfo->aiCopyStop[channel]; j<256; j++)
{
ppfData[channel][i*256+j]=0.0f;
}
}
}
else
{
// LONG, STOP, START blocks
for (i = psDSEInfo->aiCopyStop[channel]; i<2048; i++)
{
ppfData[channel][i] = 0.0f;
}
}
} // if psDSEInfo->iDolbyBitStreamWarning...
} // for win_in_grp_index...
} // for grp_index...
/* Double all TCs if using a double length x-form so we do not lose 6dB
* after the imdct.
*/
if (psDSEInfo->iUsesDoubleLengthXForm)
{
for (i = 0; i < 2048; i++)
{
ppfData[channel][i] *= 2.0f;
}
}
// do the transform
if (psDSEInfo->iUsesDoubleLengthXForm)
{
ppoIMDCTObject[channel]->Transform(ppfData[channel],iWindowType,iWindowShape);
}
else
{
ppoNormalIMDCTObject[channel]->Transform(ppfData[channel],iWindowType,iWindowShape);
}
} // for channel
int iLength = (psDSEInfo->iUsesDoubleLengthXForm) ? 2048 : 1024;
int grpIndex = 0;
int sThisLength = (iLength < DLYBUFSZ) ? iLength : DLYBUFSZ;
m_poAudioDSP->SetSamplingRate(info.GetSamplingRate());
for (int sSamp = 0; sSamp < iLength; sSamp += sThisLength)
{
m_poAudioDSP->ApplyLimiter(ppfData, sThisLength, grpIndex);
sThisLength = ((iLength - sThisLength * grpIndex++) < DLYBUFSZ) ?
(iLength - sThisLength * grpIndex++) : DLYBUFSZ;
}
poAudioIO->IO(ppfData, iLength);
// update previousWindowSequence
previousWindowSequence[L] = psDSEInfo->asDNSInfoStruct[L].iWindowSequence;
previousWindowSequence[R] = psDSEInfo->asDNSInfoStruct[R].iWindowSequence;
m_Block [L]->~CBlock () ;
m_Block [R]->~CBlock () ;
}

View File

@ -1,280 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/channel.h,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: channel.h
* project : MPEG-2 AAC Decoder
* contents/description: independent channel stream object
*
***************************************************************************/
#ifndef __CHANNEL_H__
#define __CHANNEL_H__
#include "block.h"
#include "bitsequence.h"
#include "channelinfo.h"
#include "overlapadd.h"
#include "stereo.h"
#ifdef MAIN_PROFILE
#include "prediction.h"
#endif
#include "dolby_imdct.h"
#include "DolbyPayload.h"
#include "audio_io.h"
#include "audio_io_dsp.h"
class CDolbyBitStream ;
class CStreamInfo ;
class AudioIODSP ;
/** Base Class For Channel Elements.
This abstract base class defines the interface and some common internal
helper functions for channel elements.
*/
class CChannelElement
{
public :
CChannelElement (CDolbyBitStream &bs) ;
virtual ~CChannelElement () ;
/** Data type for time-domain output samples.
Change this to float if you prefer the decoder core to deliver its time
domain output data as floating point rather than 16 bit short integer.
*/
typedef short PcmType ;
/** Main serialization method.
This method completely retrieves the channel element's state from the
associated bitstream object. All syntactic element members will be
called to perform their respective bitstream parsing and read in
their values from the MPEG stream.
This interface method must be implemented by any derived class.
@param info This container objects holds relevant information on
the current stream's sampling rate, profile etc. which
is required to correctly interpret some bitfields.
*/
virtual void Read (const CStreamInfo &) = 0 ;
/** Main decoding method.
This is the actual workhorse function, it performs all processing
required for reconstruction of one complete frame of output data.
All active tools will be called to perform their work on the
spectral coefficients of our \Ref{CBlock} member object(s) and frequency
to time domain transform will be performed on all subwindows.
@param pcmbuf The output array to hold one frame of decoded data.
@param stride The interleave stride used to write the audio chunks.
*/
virtual void Decode (AudioIOControl *poAudioIO, CStreamInfo &info, int stride = 1) = 0 ;
/** Number of channels information method.
This method simply returns the number of output channels that the
implementing class will provide.
@return Number of channels.
*/
virtual int GetNumberOfChannels (void)
{
return 0 ;
}
/** Pseudo-EQ configuration method.
This is really just a gimmick and not encouraged for use in any
serious application. A coefficient mask can be provided that will
be applied to the spectral bins of our \Ref{CBlock} Members. Will
introduce bad aliasing artefacts.
@param wantEQ Flag to turn pseudo-EQ on/off. False by default.
@param Mask An array of CBlock::EqualizationMaskLength coefficients.
*/
void SetEqualization (bool wantEQ, float Mask []) ;
protected :
CBlock *ReadICS (CChannelInfo &ics_info, unsigned long *memory) ;
enum
{
BlockMemorySize = ((sizeof (CLongBlock) > sizeof (CShortBlock)) ?
sizeof (CLongBlock) : sizeof (CShortBlock)) /
sizeof (unsigned long) + 1
} ;
protected :
CDolbyBitStream &m_bs ;
CVLBBitSequence m_GlobalGain ;
bool m_WantEqualizer ;
bool m_WantSpectralData ;
float m_EqualizerMask [CBlock::EqualizationMaskLength] ;
AudioIODSP * m_poAudioDSP;
} ;
/** SCE Single Channel Element.
This class holds the data for one single audio channel, as represented
by the ID_SCE bitstream element, and defines its parsing and decoding order.
It consists of one \Ref{CBlock} member that holds the actual spectral bins for
a long block or a short block, and a time domain overlap-add buffer.
This class implements the \Ref{CChannelElement} interface.
*/
#ifdef MAIN_PROFILE
/* If MAIN_PROFILE is enabled, ID_SCE also includes an
instance of the \Ref{CPrediction} class to hold the state information for the
optional main profile backward-adaptive prediction tool. The predictor state
and overlap-add buffers are persistent between calls, so instances of this
class are not stateless and should only be used for one specific element
instance tag.
*/
#endif
class CSingleChannel : public CChannelElement
{
public :
CSingleChannel (CDolbyBitStream &bs) ;
~CSingleChannel () ;
virtual void Read (const CStreamInfo &) ;
virtual void Decode (AudioIOControl *poAudioIO, CStreamInfo &info, int stride = 1) ;
void DecodeDolby (AudioIOControl *poAudioIO,
DOLBY_PAYLOAD_STRUCT *psDSEInfo,
CStreamInfo &info,
int stride = 1) ;
virtual int GetNumberOfChannels (void)
{
return 1 ;
}
//MSV:
CBlock* GetBlock(){return m_Block;}
CChannelInfo *GetChannelInfo(){return &m_IcsInfo;}
protected :
CChannelInfo m_IcsInfo ;
CBlock *m_Block ;
COverlapAddBuffer m_Previous ;
#ifdef MAIN_PROFILE
CPrediction m_Prediction ;
#endif
unsigned long m_BlockMemory [CChannelElement::BlockMemorySize] ;
private:
IMDCTObject *poIMDCTObject;
IMDCTObject *poNormalIMDCTObject;
float **ppfData;
short **ppshData;
} ;
/** CPE Channel Pair Element.
This class holds the data for one pair of audio channels, as represented
by the ID_CPE bitstream element, and defines their parsing and decoding order.
It consists of a Left/Right-Pair of \Ref{CBlock} members that hold the actual
spectral bins for a long block or a short window sequence, a pair of
time domain overlap-add buffers and prediction tools, plus a joint stereo
processing tool and associated side information. The predictor state
and overlap-add buffers are persistent between calls, so instances of this
class are state-dependent and should only be used for one specific element
instance tag.
This class implements the \Ref{CChannelElement} interface.
*/
class CChannelPair : public CChannelElement
{
public :
CChannelPair (CDolbyBitStream &bs) ;
~CChannelPair () ;
virtual void Read (const CStreamInfo &) ;
virtual void Decode (AudioIOControl *poAudioIO, CStreamInfo &info, int stride = 1) ;
void DecodeDolby (AudioIOControl *poAudioIO,
DOLBY_PAYLOAD_STRUCT *psDSEInfo,
CStreamInfo &info,
int stride = 1) ;
virtual int GetNumberOfChannels (void)
{
return CChannelPair::Channels ;
}
//MSV:
CBlock* GetLeftBlock(){return m_Block[0];}
CBlock* GetRightBlock(){return m_Block[1];}
CChannelInfo *GetChannelInfo(){return m_IcsInfo;}
protected :
enum
{
L = 0,
R = 1,
Channels = 2
} ;
CVLBBitSequence m_CommonWindow ;
CChannelInfo m_IcsInfo [Channels] ;
CBlock *m_Block [Channels] ;
COverlapAddBuffer m_Previous [Channels] ;
#ifdef MAIN_PROFILE
CPrediction m_Prediction [Channels] ;
#endif
CJointStereo m_JointStereo ;
unsigned long m_BlockMemory [Channels][CChannelElement::BlockMemorySize] ;
private:
IMDCTObject **ppoIMDCTObject;
IMDCTObject **ppoNormalIMDCTObject;
float **ppfData;
short **ppshData;
} ;
DECLARE_EXCEPTION(EIllegalProfile, AAC_ILLEGAL_PROFILE, "Illegal Profile") ;
#endif

View File

@ -1,261 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/channelinfo.cpp,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: channelinfo.cpp
* project : MPEG-2 AAC Decoder
* contents/description: independent channel stream info object
*
\***************************************************************************/
#include "channelinfo.h"
#include "streaminfo.h"
// // // CChannelInfo wraps ics_info()
CChannelInfo::CChannelInfo ()
: m_IcsReservedBit (1),
m_WindowSequence (2),
m_WindowShape (1),
m_ScaleFactorGrouping (7),
m_PredictorDataPresent (1)
#ifdef MAIN_PROFILE
,
m_PredictorReset (1),
m_PredictorResetGroupNumber (5)
#endif
{
m_Valid = false ;
m_TotalSfBands = 0 ;
}
CChannelInfo::~CChannelInfo ()
{
}
int CChannelInfo::GetProfile (void) const
{
return m_Profile ;
}
bool CChannelInfo::IsValid (void) const
{
return m_Valid ;
}
void CChannelInfo::Reset (const CStreamInfo &si)
{
m_Valid = false ;
m_TotalSfBands = 0 ;
m_SamplingRateIndex = si.GetSamplingRateIndex () ;
m_Profile = si.GetProfile () ;
}
bool CChannelInfo::IsLongBlock (void) const
{
return (m_WindowSequence != EightShortSequence) ;
}
bool CChannelInfo::IsShortBlock (void) const
{
return (m_WindowSequence == EightShortSequence) ;
}
bool CChannelInfo::IsMainProfile (void) const
{
return (m_Profile == ProfileMain) ;
}
int CChannelInfo::GetWindowsPerFrame (void) const
{
return (m_WindowSequence == EightShortSequence) ? 8 : 1 ;
}
int CChannelInfo::GetWindowSequence (void) const
{
return m_WindowSequence ;
}
int CChannelInfo::GetWindowGroups (void) const
{
return m_WindowGroups ;
}
int CChannelInfo::GetWindowGroupLength (int index) const
{
return m_WindowGroupLength [index] ;
}
// scale factor band indices
const int *CChannelInfo::GetScaleFactorBandOffsets (void) const
{
if (IsLongBlock ())
{
return m_SamplingRateInfoTable [m_SamplingRateIndex].ScaleFactorBands_Long ;
}
else
{
return m_SamplingRateInfoTable [m_SamplingRateIndex].ScaleFactorBands_Short ;
}
}
int CChannelInfo::GetLastBin()
{
if (IsLongBlock())
{
return m_SamplingRateInfoTable[m_SamplingRateIndex].ScaleFactorBands_Long[m_MaxSfBands];
}
else
{
return m_SamplingRateInfoTable[m_SamplingRateIndex].ScaleFactorBands_Short[m_MaxSfBands];
}
}
int CChannelInfo::GetSamplingFrequency (void) const
{
return SamplingRateFromIndex (m_SamplingRateIndex) ;
}
int CChannelInfo::SamplingRateFromIndex (int index)
{
return m_SamplingRateInfoTable [index].SamplingFrequency ;
}
#ifdef MAIN_PROFILE
int CChannelInfo::GetMaximumPredictionBands (void) const
{
return m_SamplingRateInfoTable [m_SamplingRateIndex].MaximumPredictionBands ;
}
void CChannelInfo::DeactivatePrediction (int band)
{
if (band < GetMaximumPredictionBands ())
{
m_PredictionUsed [band] = false ;
}
}
#endif
void CChannelInfo::Read (CDolbyBitStream &bs)
{
m_IcsReservedBit.Read (bs) ;
m_WindowSequence.Read (bs) ;
m_WindowShape.Read (bs) ;
#ifdef ONLY_SINE_WINDOW
if (m_WindowShape == 1)
throw EUnsupportedWindowShape () ;
#endif
if (IsLongBlock ())
{
m_TotalSfBands = m_SamplingRateInfoTable [m_SamplingRateIndex].NumberOfScaleFactorBands_Long ;
m_MaxSfBands.Read (bs, 6) ;
if (m_PredictorDataPresent.Read (bs))
{
#ifdef MAIN_PROFILE
if (m_PredictorReset.Read (bs))
{
m_PredictorResetGroupNumber.Read (bs) ;
if ((m_PredictorResetGroupNumber < 1) || (m_PredictorResetGroupNumber > 30))
{
throw EInvalidPredictorReset () ;
}
}
int maxpred = (GetScaleFactorBandsTransmitted () < GetMaximumPredictionBands ()) ?
GetScaleFactorBandsTransmitted () : GetMaximumPredictionBands () ;
for (int band = 0 ; band < maxpred ; band++)
{
m_PredictionUsed [band] = bs.Get (1) ? true : false ;
}
#else
throw EIllegalProfile();
#endif
}
m_WindowGroups = 1 ;
m_WindowGroupLength [0] = 1 ;
}
else
{
m_TotalSfBands = m_SamplingRateInfoTable [m_SamplingRateIndex].NumberOfScaleFactorBands_Short ;
m_MaxSfBands.Read (bs, 4) ;
m_ScaleFactorGrouping.Read (bs) ;
// // // expand group lengths
m_WindowGroups = 0 ;
for (int i = 0 ; i < 7 ; i++)
{
int mask = 1 << (6 - i) ;
m_WindowGroupLength [i] = 1 ;
if (m_ScaleFactorGrouping & mask)
{
m_WindowGroupLength [m_WindowGroups]++ ;
}
else
{
m_WindowGroups++ ;
}
}
// loop runs to i < 7 only
m_WindowGroupLength [7] = 1 ;
m_WindowGroups++ ;
}
m_Valid = true ;
}
int CChannelInfo::GetMaximumTnsBands (void) const
{
static const int tns_max_bands_tbl [12][4] =
{
/* entry for each sampling rate
* 1 Main/LC long window
* 2 Main/LC short window
* 3 SSR long window
* 4 SSR short window
*/
{ 31, 9, 28, 7 }, /* 96000 */
{ 31, 9, 28, 7 }, /* 88200 */
{ 34, 10, 27, 7 }, /* 64000 */
{ 40, 14, 26, 6 }, /* 48000 */
{ 42, 14, 26, 6 }, /* 44100 */
{ 51, 14, 26, 6 }, /* 32000 */
{ 46, 14, 29, 7 }, /* 24000 */
{ 46, 14, 29, 7 }, /* 22050 */
{ 42, 14, 23, 8 }, /* 16000 */
{ 42, 14, 23, 8 }, /* 12000 */
{ 42, 14, 23, 8 }, /* 11025 */
{ 39, 14, 19, 7 }, /* 8000 */
} ;
int i = IsLongBlock () ? 0 : 1 ;
i += (GetProfile () == ProfileSSR) ? 2 : 0 ;
return tns_max_bands_tbl [m_SamplingRateIndex][i] ;
}

View File

@ -1,196 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/channelinfo.h,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: channelinfo.h
* project : MPEG-2 AAC Decoder
* contents/description: independent channel stream info object
*
* $Header: /cvs/root/winamp/vlb/channelinfo.h,v 1.1 2009/04/28 20:21:08 audiodsp Exp $
*
\***************************************************************************/
#ifndef __CHANNELINFO_H__
#define __CHANNELINFO_H__
#include "bitsequence.h"
#include "exception.h"
#include "streaminfo.h"
class CDolbyBitStream ;
class CProgramConfig ;
class CStreamInfo ;
/** Channel Element Side Information.
This class provides information essential to various parts of the decoder.
It reads the ics_info() bitstream elements and provides accordingly mapped
access to some static tables, first of all scale factor band widths.
*/
class CChannelInfo
{
public :
// // //
enum
{
OnlyLongSequence = 0,
LongStartSequence,
EightShortSequence,
LongStopSequence,
#ifdef MAIN_PROFILE
PredictionBandsTotal = 42,
#endif
ProfileMain = 0,
ProfileLowComplexity,
ProfileSSR,
ProfileReserved
} ;
// // //
CChannelInfo () ;
~CChannelInfo () ;
void Read (CDolbyBitStream &bs) ;
bool IsValid (void) const ;
bool IsLongBlock (void) const ;
bool IsShortBlock (void) const ;
bool IsMainProfile (void) const ;
void Reset (const CStreamInfo &) ;
int GetProfile (void) const ;
int GetWindowShape (void) const
{
return m_WindowShape ;
}
int GetWindowSequence (void) const ;
int GetWindowsPerFrame (void) const ;
int GetWindowGroups (void) const ;
int GetWindowGroupLength (int index) const ;
int GetScaleFactorBandsTransmitted (void) const
{
return m_MaxSfBands ;
}
int GetScaleFactorBandsTotal (void) const
{
return m_TotalSfBands ;
}
const int *GetScaleFactorBandOffsets (void) const ;
int GetSamplingFrequency (void) const ;
int GetMaximumTnsBands (void) const ;
#ifdef MAIN_PROFILE
// // // Prediction
int GetMaximumPredictionBands (void) const ;
bool GetPredictorDataPresent (void) const
{
return m_PredictorDataPresent ? true : false ;
}
bool GetPredictionUsedForBand (int band) const
{
return m_PredictionUsed [band] ;
}
bool GetPerformPredictorReset (void) const
{
if (GetPredictorDataPresent ())
{
return m_PredictorReset ? true : false ;
}
return false ;
}
int GetPredictorResetGroupNumber (void) const
{
return m_PredictorResetGroupNumber ;
}
void DeactivatePrediction (int band) ;
// // //
#endif
static int SamplingRateFromIndex (int index) ;
int GetSamplingIndex(){return m_SamplingRateIndex;}
int GetLastBin() ;
protected :
bool m_Valid ;
CVLBBitSequence m_IcsReservedBit ;
CVLBBitSequence m_WindowSequence ;
CVLBBitSequence m_WindowShape ;
CVLBBitSequence m_MaxSfBands ;
CVLBBitSequence m_ScaleFactorGrouping ;
// prediction
CVLBBitSequence m_PredictorDataPresent ;
#ifdef MAIN_PROFILE
CVLBBitSequence m_PredictorReset ;
CVLBBitSequence m_PredictorResetGroupNumber ;
bool m_PredictionUsed [CChannelInfo::PredictionBandsTotal] ;
// // //
#endif
int m_TotalSfBands ;
int m_SamplingRateIndex, m_Profile ;
int m_WindowGroups, m_WindowGroupLength [8] ;
// // //
#ifdef MAIN_PROFILE
DECLARE_EXCEPTION(EInvalidPredictorReset, AAC_INVALIDPREDICTORRESET, "Invalid Predictor Reset Group Indicated") ;
#endif
DECLARE_EXCEPTION(EUnsupportedWindowShape, AAC_UNSUPPORTEDWINDOWSHAPE, "Unsupported Window Shape Used") ;
DECLARE_EXCEPTION(EIllegalProfile, AAC_ILLEGAL_PROFILE, "Illegal Profile") ;
// // //
typedef struct
{
int SamplingFrequency ;
int NumberOfScaleFactorBands_Long ;
const int *ScaleFactorBands_Long ;
int NumberOfScaleFactorBands_Short ;
const int *ScaleFactorBands_Short ;
int MaximumPredictionBands ;
} SamplingRateInfo ;
static const SamplingRateInfo m_SamplingRateInfoTable [16] ;
} ;
#endif

View File

@ -1,52 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/datastream.cpp,v 1.1 2009/04/28 20:21:08 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: datastream.cpp
* project : MPEG-2 AAC Decoder
* contents/description: data stream element
*
\***************************************************************************/
#include "datastream.h"
CDataStream::CDataStream (CDolbyBitStream &bs)
: m_bs (bs),
m_DataByteAlignFlag (1),
m_Count (8),
m_EscCount (8)
{
}
CDataStream::~CDataStream ()
{
}
void CDataStream::Read (void)
{
m_DataByteAlignFlag.Read (m_bs) ;
m_Count.Read (m_bs) ;
if (m_Count == 255)
{
m_Count += m_EscCount.Read (m_bs) ;
}
if (m_DataByteAlignFlag)
{
m_bs.ByteAlign () ;
}
for (int i = 0 ; i < m_Count ; i++)
{
m_DataStreamByte [i].Read (m_bs, 8) ;
}
}

View File

@ -1,60 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/datastream.h,v 1.1 2009/04/28 20:21:09 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: datastream.h
* project : MPEG-2 AAC Decoder
* contents/description: data stream element
*
\***************************************************************************/
#ifndef __DATASTREAM_H__
#define __DATASTREAM_H__
#include "bitsequence.h"
/** DSE Data Stream Element.
This class represents a data stream element, that may be used to transport
additional user data embedded within the audio bitstream.
*/
class CDataStream
{
public :
CDataStream (CDolbyBitStream &) ;
~CDataStream () ;
void Read (void) ;
int Length (void)
{
return m_Count ;
}
protected :
CDolbyBitStream &m_bs ;
CVLBBitSequence m_DataByteAlignFlag ;
CVLBBitSequence m_Count ;
CVLBBitSequence m_EscCount ;
enum
{
MaximumElementLength = 512
} ;
CVLBBitSequence m_DataStreamByte [MaximumElementLength] ;
} ;
#endif

View File

@ -1,847 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/dolby_imdct.cpp,v 1.1 2009/04/28 20:21:09 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* filename: dolby_imdct.cpp
* project : MPEG-2 AAC Decoder
* contents/description: IMDCT transform routines
*
\***************************************************************************/
#include"dolby_imdct.h"
#ifdef INTERPOLATE_WINDOW
#include "window_tab.h"
#endif
/* #defines related to Izero and CalculateKBDWindowExact */
#define IzeroEPSILON 1E-21 /* Max error acceptable in Izero */
#define M_PI 3.14159265358979323846264338327950288f
/*------------------------ Window Functions ---------------------------*/
void Sine_Window(float*pfWindow,int iSize)
{
#ifdef INTERPOLATE_WINDOW
int count, j;
switch (iSize)
{
case 256:
for(j=0; j < iSize/2 ;j++)
{
pfWindow[j]=(float)(sin_short[j]);
}
break;
case 512:
count = 0;
for (j = 0; j < iSize/4-1; j++)
{
pfWindow[count++] = (float) sin_short[j];
pfWindow[count++] = (float) ((sin_short[j] + sin_short[j + 1]) * 0.5);
}
pfWindow[count++] = (float) sin_short[j];
pfWindow[count] = (float) 1.0;
break;
case 2048:
for(j=0; j < iSize/2 ;j++)
{
pfWindow[j]=(float)(sin_long[j]);
}
break;
case 4096:
count = 0;
for (j = 0; j < iSize/4-1; j++)
{
pfWindow[count++] = (float) sin_long[j];
pfWindow[count++] = (float) ((sin_long[j] + sin_long[j + 1]) * 0.5);
}
pfWindow[count++] = (float) sin_long[j];
pfWindow[count] = (float) 1.0;
break;
}
#else
int n;
for(n=0;n<iSize/2;n++){
pfWindow[n]=(float)(sin(pi*((float)n+0.5)/(float)iSize));
}
#endif
}
static float Izero(float x)
{
float sum,
u,
halfx,
temp;
int n;
sum = u = 1.0f;
n = 1;
halfx = x / 2.0f;
do
{
temp = halfx / (float) n;
n += 1;
temp *= temp;
u *= temp;
sum += u;
} while (u >= IzeroEPSILON * sum);
return (sum);
}
/*****************************************************************************
functionname: CalculateKBDWindowExact
description: calculates the window coefficients for the Kaiser-Bessel
derived window
returns:
input: window length, alpha
output: window coefficients
*****************************************************************************/
void CalculateKBDWindowExact(float * win, float alpha, int length)
{
int i;
float IBeta;
float tmp;
float sum = 0.0;
alpha *= M_PI;
IBeta = 1.0f / Izero(alpha);
/* calculate lower half of Kaiser Bessel window */
for (i = 0; i < (length >> 1); i++)
{
tmp = 4.0f * (float) i / (float) length - 1.0f;
win[i] = Izero(alpha * ((float) sqrt(1.0f - tmp * tmp))) * IBeta;
sum += win[i];
}
sum = 1.0f / sum;
tmp = 0.0;
/* calculate lower half of window */
for (i = 0; i < (length >> 1); i++)
{
tmp += win[i];
win[i] = (float) sqrt(tmp * sum);
}
}
void KBD_Window(float*pfWindow,int iSize)
{
#ifdef INTERPOLATE_WINDOW
int count, j;
switch (iSize)
{
case 256:
for(j=0; j < iSize/2 ;j++)
{
pfWindow[j]=(float)(KBD_short[j]);
}
break;
case 512:
count = 0;
for (j = 0; j < iSize/4-1; j++)
{
pfWindow[count++] = (float) KBD_short[j];
pfWindow[count++] = (float) ((KBD_short[j] + KBD_short[j + 1]) * 0.5);
}
pfWindow[count++] = (float) KBD_short[j];
pfWindow[count] = (float) 1.0;
break;
case 2048:
for(j=0; j < iSize/2 ;j++)
{
pfWindow[j]=(float)(KBD_long[j]);
}
break;
case 4096:
count = 0;
for (j = 0; j < iSize/4-1; j++)
{
pfWindow[count++] = (float) KBD_long[j];
pfWindow[count++] = (float) ((KBD_long[j] + KBD_long[j + 1]) * 0.5);
}
pfWindow[count++] = (float) KBD_long[j];
pfWindow[count] = (float) 1.0;
break;
}
#else
/* The stock AAC MP4 encoder calculates KBD windows with different alphas
depending on the blocklength. We must match those windows here. */
switch(iSize)
{
case 256:
case 512:
CalculateKBDWindowExact(pfWindow, 6.0, iSize);
break;
case 2048:
case 4096:
CalculateKBDWindowExact(pfWindow, 4.0, iSize);
break;
default:
CalculateKBDWindowExact(pfWindow, 4.0, iSize);
}
#endif
}
/*----------------------- DOLBY IMDCT ---------------------------------*/
IMDCTObject::IMDCTObject(int _iLongSize,
int _iOverlap)
:iLongSize(_iLongSize),
iHLongSize(_iLongSize/2),
iOverlap(_iOverlap),
iOldShape(0)
{
if(iLongSize==0){
return;
}
if(iOverlap==0){
return;
}
int n,k;
//Obtain memory for Short Windows:
//These arrays are larger than they need to be,
//but are made this large for convenience
iShortSize = iLongSize / 8;
iHShortSize = iHLongSize / 8;
pfShortWindowSin = new float[iHLongSize];
pfShortWindowKBD = new float[iHLongSize];
//Obtain memory for Longwindows:
pfLongWindowSin=new float[iHLongSize];
pfS2LWindowSin=new float[iHLongSize];
pfLongWindowKBD=new float[iHLongSize];
pfS2LWindowKBD=new float[iHLongSize];
//Obtain memory for temporary buffer:
pfTempBuffer=new float[iLongSize];
pfEightWindowsBuffer=new float[iLongSize];
pfSavedBuffer=new float[iHLongSize];
for(n=0;n<iHLongSize;n++) pfSavedBuffer[n]=0;
//Create Windows:
KBD_Window(pfLongWindowKBD,iLongSize);
Sine_Window(pfLongWindowSin,iLongSize);
//Create S2L Window:
KBD_Window(pfShortWindowKBD,iOverlap*2); // temporary
for(k=0,n=iHLongSize/2-iOverlap/2;k<iOverlap;k++,n++){
pfS2LWindowKBD[n]=pfShortWindowKBD[k];
}
for(n=0;n<iHLongSize/2-iOverlap/2;n++){
pfS2LWindowKBD[n]=0.0f;
}
for(n=iHLongSize/2+iOverlap/2;n<iHLongSize;n++){
pfS2LWindowKBD[n]=1.0f;
}
//Create correct length short window
KBD_Window(pfShortWindowKBD,iShortSize);
//Create S2L Window:
Sine_Window(pfShortWindowSin,iOverlap*2); // temporary
for(k=0,n=iHLongSize/2-iOverlap/2;k<iOverlap;k++,n++){
pfS2LWindowSin[n]=pfShortWindowSin[k];
}
for(n=0;n<iHLongSize/2-iOverlap/2;n++){
pfS2LWindowSin[n]=0.0f;
}
for(n=iHLongSize/2+iOverlap/2;n<iHLongSize;n++){
pfS2LWindowSin[n]=1.0f;
}
//Create correct length short window
Sine_Window(pfShortWindowSin,iShortSize);
// Compute Long Twiddles
iLongFFTSize=iLongSize/4;
pfReal=new float[iLongFFTSize];
pfImag=new float[iLongFFTSize];
pfRealLongTwiddle=new float[iLongFFTSize];
pfImagLongTwiddle=new float[iLongFFTSize];
pfRealLongTwiddle[0]=(float)(cos(0.125*2.0*pi/(float)iLongSize));
pfImagLongTwiddle[0]=(float)(sin(0.125*2.0*pi/(float)iLongSize));
for(n=1;n<iLongFFTSize;n++){
pfRealLongTwiddle[n]=(float)(cos(2.0*pi/(float)iLongSize))*pfRealLongTwiddle[n-1]-
(float)(sin(2.0*pi/(float)iLongSize))*pfImagLongTwiddle[n-1];
pfImagLongTwiddle[n]=(float)(cos(2.0*pi/(float)iLongSize))*pfImagLongTwiddle[n-1]+
(float)(sin(2.0*pi/(float)iLongSize))*pfRealLongTwiddle[n-1];
}
// Compute Short Twiddles
// these twiddles may be redundant - they may be able to be computed as a function
// of the long twiddles
iShortFFTSize=iShortSize/4;
pfRealShort=new float[iShortFFTSize];
pfImagShort=new float[iShortFFTSize];
pfRealShortTwiddle=new float[iShortFFTSize];
pfImagShortTwiddle=new float[iShortFFTSize];
pfRealShortTwiddle[0]=(float)(cos(0.125*2.0*pi/(float)iShortSize));
pfImagShortTwiddle[0]=(float)(sin(0.125*2.0*pi/(float)iShortSize));
for(n=1;n<iShortFFTSize;n++){
pfRealShortTwiddle[n]=(float)(cos(2.0*pi/(float)iShortSize))*pfRealShortTwiddle[n-1]-
(float)(sin(2.0*pi/(float)iShortSize))*pfImagShortTwiddle[n-1];
pfImagShortTwiddle[n]=(float)(cos(2.0*pi/(float)iShortSize))*pfImagShortTwiddle[n-1]+
(float)(sin(2.0*pi/(float)iShortSize))*pfRealShortTwiddle[n-1];
}
}
IMDCTObject::IMDCTObject()
:iLongSize(0),
iOverlap(0)
{
}
IMDCTObject::IMDCTObject(IMDCTObject&oCopy)
:iLongSize(oCopy.iLongSize),
iHLongSize(iLongSize/2),
iOverlap(oCopy.iOverlap),
iOldShape(oCopy.iOldShape)
{
if(iLongSize==0){
return;
}
if(iOverlap==0){
return;
}
int n,k;
//Obtain memory for Short Windows:
//These arrays are larger than they need to be,
//but are made this large for convenience
iShortSize = iLongSize / 8;
iHShortSize = iHLongSize / 8;
pfShortWindowSin = new float[iHLongSize];
pfShortWindowKBD = new float[iHLongSize];
//Obtain memory for windows:
pfLongWindowSin=new float[iHLongSize];
pfS2LWindowSin=new float[iHLongSize];
pfLongWindowKBD=new float[iHLongSize];
pfS2LWindowKBD=new float[iHLongSize];
//Obtain memory for temporary buffer:
pfTempBuffer=new float[iLongSize];
pfEightWindowsBuffer=new float[iLongSize];
pfSavedBuffer=new float[iHLongSize];
for(n=0;n<iHLongSize;n++) pfSavedBuffer[n]=0;
//Create Windows:
KBD_Window(pfLongWindowKBD,iLongSize);
Sine_Window(pfLongWindowSin,iLongSize);
//Create S2L Window:
KBD_Window(pfShortWindowKBD,iOverlap*2); // temporary
for(k=0,n=iHLongSize/2-iOverlap/2;k<iOverlap;k++,n++){
pfS2LWindowKBD[n]=pfShortWindowKBD[k];
}
for(n=0;n<iHLongSize/2-iOverlap/2;n++){
pfS2LWindowKBD[n]=0.0f;
}
for(n=iHLongSize/2+iOverlap/2;n<iHLongSize;n++){
pfS2LWindowKBD[n]=1.0f;
}
//Create correct length short window
KBD_Window(pfShortWindowKBD,iShortSize);
//Create S2L Window:
Sine_Window(pfShortWindowSin,iOverlap*2); // temporary
for(k=0,n=iHLongSize/2-iOverlap/2;k<iOverlap;k++,n++){
pfS2LWindowSin[n]=pfShortWindowSin[k];
}
for(n=0;n<iHLongSize/2-iOverlap/2;n++){
pfS2LWindowSin[n]=0.0f;
}
for(n=iHLongSize/2+iOverlap/2;n<iHLongSize;n++){
pfS2LWindowSin[n]=1.0f;
}
//Create correct length short window
Sine_Window(pfShortWindowSin,iShortSize);
// Compute Long Twiddles
iLongFFTSize=iLongSize/4;
pfReal=new float[iLongFFTSize];
pfImag=new float[iLongFFTSize];
pfRealLongTwiddle=new float[iLongFFTSize];
pfImagLongTwiddle=new float[iLongFFTSize];
pfRealLongTwiddle[0]=(float)(cos(0.125*2.0*pi/(float)iLongSize));
pfImagLongTwiddle[0]=(float)(sin(0.125*2.0*pi/(float)iLongSize));
for(n=1;n<iLongFFTSize;n++){
pfRealLongTwiddle[n]=(float)(cos(2.0*pi/(float)iLongSize))*pfRealLongTwiddle[n-1]-
(float)(sin(2.0*pi/(float)iLongSize))*pfImagLongTwiddle[n-1];
pfImagLongTwiddle[n]=(float)(cos(2.0*pi/(float)iLongSize))*pfImagLongTwiddle[n-1]+
(float)(sin(2.0*pi/(float)iLongSize))*pfRealLongTwiddle[n-1];
}
// Compute Short Twiddles
// these twiddles may be redundant - they may be able to be computed as a function
// of the long twiddles
iShortFFTSize=iShortSize/4;
pfRealShort=new float[iShortFFTSize];
pfImagShort=new float[iShortFFTSize];
pfRealShortTwiddle=new float[iShortFFTSize];
pfImagShortTwiddle=new float[iShortFFTSize];
pfRealShortTwiddle[0]=(float)(cos(0.125*2.0*pi/(float)iShortSize));
pfImagShortTwiddle[0]=(float)(sin(0.125*2.0*pi/(float)iShortSize));
for(n=1;n<iShortFFTSize;n++){
pfRealShortTwiddle[n]=(float)(cos(2.0*pi/(float)iShortSize))*pfRealShortTwiddle[n-1]-
(float)(sin(2.0*pi/(float)iShortSize))*pfImagShortTwiddle[n-1];
pfImagShortTwiddle[n]=(float)(cos(2.0*pi/(float)iShortSize))*pfImagShortTwiddle[n-1]+
(float)(sin(2.0*pi/(float)iShortSize))*pfRealShortTwiddle[n-1];
}
}
IMDCTObject& IMDCTObject::operator=(IMDCTObject&oCopy)
{
if(iLongSize!=0&&iOverlap!=0){
delete[] pfLongWindowKBD;
delete[] pfS2LWindowKBD;
delete[] pfLongWindowSin;
delete[] pfS2LWindowSin;
delete[] pfShortWindowSin;
delete[] pfShortWindowKBD;
delete[] pfSavedBuffer;
delete[] pfReal;
delete[] pfImag;
delete[] pfRealLongTwiddle;
delete[] pfImagLongTwiddle;
delete[] pfRealShort;
delete[] pfImagShort;
delete[] pfRealShortTwiddle;
delete[] pfImagShortTwiddle;
}
iLongSize=oCopy.iLongSize;
iHLongSize=iLongSize/2;
iShortSize=oCopy.iShortSize;
iHShortSize=iShortSize/2;
iOverlap=oCopy.iOverlap;
iOldShape=oCopy.iOldShape;
if(iLongSize==0){
return *this;
}
if(iOverlap==0){
return *this;
}
int n,k;
//Obtain memory for Short Windows:
//These arrays are larger than they need to be,
//but are made this large for convenience
iShortSize = iLongSize / 8;
iHShortSize = iHLongSize / 8;
pfShortWindowSin = new float[iHLongSize];
pfShortWindowKBD = new float[iHLongSize];
//Obtain memory for windows:
pfLongWindowSin=new float[iHLongSize];
pfS2LWindowSin=new float[iHLongSize];
pfLongWindowKBD=new float[iHLongSize];
pfS2LWindowKBD=new float[iHLongSize];
//Obtain memory for temporary buffer:
pfTempBuffer=new float[iLongSize];
pfEightWindowsBuffer=new float[iLongSize];
pfSavedBuffer=new float[iHLongSize];
for(n=0;n<iHLongSize;n++) pfSavedBuffer[n]=0;
//Create Windows:
KBD_Window(pfLongWindowKBD,iLongSize);
Sine_Window(pfLongWindowSin,iLongSize);
//Create S2L Window:
KBD_Window(pfShortWindowKBD,iOverlap*2); // temporary
for(k=0,n=iHLongSize/2-iOverlap/2;k<iOverlap;k++,n++){
pfS2LWindowKBD[n]=pfShortWindowKBD[k];
}
for(n=0;n<iHLongSize/2-iOverlap/2;n++){
pfS2LWindowKBD[n]=0.0f;
}
for(n=iHLongSize/2+iOverlap/2;n<iHLongSize;n++){
pfS2LWindowKBD[n]=1.0f;
}
//Create correct length short window
KBD_Window(pfShortWindowKBD,iShortSize);
//Create S2L Window:
Sine_Window(pfShortWindowSin,iOverlap*2); // temporary
for(k=0,n=iHLongSize/2-iOverlap/2;k<iOverlap;k++,n++){
pfS2LWindowSin[n]=pfShortWindowSin[k];
}
for(n=0;n<iHLongSize/2-iOverlap/2;n++){
pfS2LWindowSin[n]=0.0f;
}
for(n=iHLongSize/2+iOverlap/2;n<iHLongSize;n++){
pfS2LWindowSin[n]=1.0f;
}
//Create correct length short window
Sine_Window(pfShortWindowSin,iShortSize);
// Compute Long Twiddles
iLongFFTSize=iLongSize/4;
pfReal=new float[iLongFFTSize];
pfImag=new float[iLongFFTSize];
pfRealLongTwiddle=new float[iLongFFTSize];
pfImagLongTwiddle=new float[iLongFFTSize];
pfRealLongTwiddle[0]=(float)(cos(0.125*2.0*pi/(float)iLongSize));
pfImagLongTwiddle[0]=(float)(sin(0.125*2.0*pi/(float)iLongSize));
for(n=1;n<iLongFFTSize;n++){
pfRealLongTwiddle[n]=(float)(cos(2.0*pi/(float)iLongSize))*pfRealLongTwiddle[n-1]-
(float)(sin(2.0*pi/(float)iLongSize))*pfImagLongTwiddle[n-1];
pfImagLongTwiddle[n]=(float)(cos(2.0*pi/(float)iLongSize))*pfImagLongTwiddle[n-1]+
(float)(sin(2.0*pi/(float)iLongSize))*pfRealLongTwiddle[n-1];
}
// Compute Short Twiddles
// these twiddles may be redundant - they may be able to be computed as a function
// of the long twiddles
iShortFFTSize=iShortSize/4;
pfRealShort=new float[iShortFFTSize];
pfImagShort=new float[iShortFFTSize];
pfRealShortTwiddle=new float[iShortFFTSize];
pfImagShortTwiddle=new float[iShortFFTSize];
pfRealShortTwiddle[0]=(float)(cos(0.125*2.0*pi/(float)iShortSize));
pfImagShortTwiddle[0]=(float)(sin(0.125*2.0*pi/(float)iShortSize));
for(n=1;n<iShortFFTSize;n++){
pfRealShortTwiddle[n]=(float)(cos(2.0*pi/(float)iShortSize))*pfRealShortTwiddle[n-1]-
(float)(sin(2.0*pi/(float)iShortSize))*pfImagShortTwiddle[n-1];
pfImagShortTwiddle[n]=(float)(cos(2.0*pi/(float)iShortSize))*pfImagShortTwiddle[n-1]+
(float)(sin(2.0*pi/(float)iShortSize))*pfRealShortTwiddle[n-1];
}
return *this;
}
IMDCTObject::~IMDCTObject()
{
if(iLongSize!=0&&iOverlap!=0){
delete[] pfLongWindowKBD;
delete[] pfS2LWindowKBD;
delete[] pfLongWindowSin;
delete[] pfS2LWindowSin;
delete[] pfShortWindowSin;
delete[] pfShortWindowKBD;
delete[] pfSavedBuffer;
delete[] pfReal;
delete[] pfImag;
delete[] pfRealLongTwiddle;
delete[] pfImagLongTwiddle;
delete[] pfRealShort;
delete[] pfImagShort;
delete[] pfRealShortTwiddle;
delete[] pfImagShortTwiddle;
delete[] pfTempBuffer;
delete[] pfEightWindowsBuffer;
}
}
int IMDCTObject::Transform( float*pfData,
int iWindowType,
int iWindowShape)
{
int n,k;
float *pfWindowFirst;
float *pfWindowSecond;
int eightShortSequenceFlag;
float* pfDataShortBlock;
switch(iWindowType){
case 0:
if(iOldShape == SINE_WINDOW){
pfWindowFirst=pfLongWindowSin;
}
else{
pfWindowFirst=pfLongWindowKBD;
}
if(iWindowShape == SINE_WINDOW){
pfWindowSecond=pfLongWindowSin;
}
else{
pfWindowSecond=pfLongWindowKBD;
}
eightShortSequenceFlag = 0;
break;
case 1:
if(iOldShape == SINE_WINDOW){
pfWindowFirst=pfLongWindowSin;
}
else{
pfWindowFirst=pfLongWindowKBD;
}
if(iWindowShape == SINE_WINDOW){
pfWindowSecond=pfS2LWindowSin;
}
else{
pfWindowSecond=pfS2LWindowKBD;
}
eightShortSequenceFlag = 0;
break;
case 2:
eightShortSequenceFlag = 1;
break;
case 3:
if(iOldShape == SINE_WINDOW){
pfWindowFirst=pfS2LWindowSin;
}
else{
pfWindowFirst=pfS2LWindowKBD;
}
if(iWindowShape == SINE_WINDOW){
pfWindowSecond=pfLongWindowSin;
}
else{
pfWindowSecond=pfLongWindowKBD;
}
eightShortSequenceFlag = 0;
break;
default:
//printf("Invalid Window Type\n");
return -1;
}
if (eightShortSequenceFlag == 0)
{
//Copy Data
memcpy(pfTempBuffer,pfData,iHLongSize*sizeof(float));
//IMDCT:
imdct(pfTempBuffer, LONG_BLOCK);
//DGC Goes Here
//Window
for(n=0,k=iHLongSize-1;n<iHLongSize;n++,k--){
pfTempBuffer[n]*=pfWindowFirst[n];
pfTempBuffer[n+iHLongSize]*=pfWindowSecond[k];
}
} else {
//Copy coefficient Data to a (possibly larger) array in preparation
//for imdct.
//CNC: the use of the constact 256 is really ugly here!!!
//256 = (2 * CShortBlock::MaximumBins), but this expression
//is inconvenient to insert in the code below due to access restrictions.
//The hardcoding of the constant 256 refers to the fixed spacing
//of the mdct coefficients in the data pfData, independent of whether
//or not we're dealing with a single or a double length transform.
//Note: the imdct only requires N/2 freq. coefficients to
//produce N (time aliased) time samples. In the case of a double
//length transform, we'll need to copy the spectrally extended
//short blocks, one by one, to their proper place in the larger
//array, pfEightWindowsBuffer. Since the source and destination
//arrays might be of different sizes due to using a single *or* a
//double length transform, the block-to-block spacing of the mdct
//coefficients could be different in each of the arrays.
for (n=0;n<8;n++)
{
memcpy(&pfEightWindowsBuffer[n*iShortSize],
&pfData[n*256],
256*sizeof(float));
}
// clear the TempBuffer, which will hold the time-aliased
// output for the entire frame (all overlap-added short blocks)
for (k = 0 ; k < iLongSize ; k++)
{
pfTempBuffer[k] = 0 ;
}
for(n=0;n<8;n++)
{
// IMDCT
pfDataShortBlock = &pfEightWindowsBuffer[n*iShortSize];
imdct(pfDataShortBlock,SHORT_BLOCK);
// DGC goes here
// Window the time-aliased, time domain data.. Take into account possible window shape switching on
// the first of the eight short windows.
// Note that the AAC standard says that
// "The window shape of the previous block influences the first of the eight short blocks (w_0(m)) only."
// ISO/IEC 13818-7:1997(E), page 78.
// This means that the rising edge of the zeroth short block must match the previous window frame's window
// shape. However, all subsequent rising and falling edges of remaining short blocks should reflect the
// currently decoded window shape type.
if (n==0)
{
// rising edge depends on old shape
if (iOldShape == SINE_WINDOW)
{
for (k=0;k<iHShortSize;k++)
{
pfDataShortBlock[k]*=pfShortWindowSin[k];
}
}
else if (iOldShape == KBD_WINDOW)
{
for (k=0;k<iHShortSize;k++)
{
pfDataShortBlock[k]*=pfShortWindowKBD[k];
}
}
// falling edge reflects new shape
if (iWindowShape == SINE_WINDOW)
{
for (k=0;k<iHShortSize;k++)
{
pfDataShortBlock[k+iHShortSize]*=pfShortWindowSin[iHShortSize-k-1];
}
}
else if (iWindowShape == KBD_WINDOW)
{
for (k=0;k<iHShortSize;k++)
{
pfDataShortBlock[k+iHShortSize]*=pfShortWindowKBD[iHShortSize-k-1];
}
}
}
else // n != 0
{
if (iWindowShape == SINE_WINDOW)
{
for (k=0;k<iHShortSize;k++)
{
pfDataShortBlock[k]*=pfShortWindowSin[k];
pfDataShortBlock[k+iHShortSize]*=pfShortWindowSin[iHShortSize-k-1];
}
}
else if (iWindowShape == KBD_WINDOW)
{
for (k=0;k<iHShortSize;k++)
{
pfDataShortBlock[k]*=pfShortWindowKBD[k];
pfDataShortBlock[k+iHShortSize]*=pfShortWindowKBD[iHShortSize-k-1];
}
}
}
// overlap add the 8 windows in this block
for (k = 0 ; k < iShortSize ; k++)
{
pfTempBuffer[(iLongSize/4 - iShortSize/4) + (iHShortSize * n) + k] += pfDataShortBlock[k] ;
}
} // for n...
} // if (eightShortSequenceFlag...)
//OLA:
for(n=0;n<iHLongSize;n++){
pfData[n]=pfTempBuffer[n]+pfSavedBuffer[n];
}
//Update Saved Buffer:
memcpy(pfSavedBuffer,&pfTempBuffer[iHLongSize],iHLongSize*sizeof(float));
iOldShape=iWindowShape;
return 0;
}
void IMDCTObject::imdct(float*pfData, int blockType)
{
float fTempReal,fTempImag;
float fFactor;
int n,k,iLast,iRotation,iMiddle,iSize;
float *realData, *imagData, *realTwiddle, *imagTwiddle;
if (blockType == LONG_BLOCK)
{
iLast=iLongFFTSize;
iRotation=iLongFFTSize/2;
iMiddle=iHLongSize;
iSize=iLongSize;
fFactor=2.0f/(float)iLongSize;
realData = pfReal;
imagData = pfImag;
realTwiddle = pfRealLongTwiddle;
imagTwiddle = pfImagLongTwiddle;
}
else if (blockType == SHORT_BLOCK)
{
iLast=iShortFFTSize;
iRotation=iShortFFTSize/2;
iMiddle=iHShortSize;
iSize=iShortSize;
fFactor=2.0f/(float)iShortSize;
realData = pfRealShort;
imagData = pfImagShort;
realTwiddle = pfRealShortTwiddle;
imagTwiddle = pfImagShortTwiddle;
}
for(k=0;k<iLast;k++){
n=2*k;
fTempReal=-pfData[n];
fTempImag=pfData[iMiddle-1-n];
realData[k]=fTempReal*realTwiddle[k]-fTempImag*imagTwiddle[k];
imagData[k]=-fTempImag*realTwiddle[k]-fTempReal*imagTwiddle[k];
}
fftl(realData,imagData,iLast);
for(k=0;k<iLast;k++){
//conj!
fTempReal=fFactor*(realData[k]*realTwiddle[k]+imagData[k]*imagTwiddle[k]);
fTempImag=fFactor*(-imagData[k]*realTwiddle[k]+realData[k]*imagTwiddle[k]);
n=2*k;
pfData[iMiddle+iLast-1-n]=fTempReal;
pfData[iLast+n]=fTempImag;
if(k<iRotation){
pfData[iMiddle+iLast+n]=fTempReal;
pfData[iLast-1-n]=-fTempImag;
}
else{
pfData[n-iLast]=-fTempReal;
pfData[iLast+iSize-1-n]=fTempImag;
}
}
}

View File

@ -1,94 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/dolby_imdct.h,v 1.1 2009/04/28 20:21:09 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* filename: dolby_mdct.h
* project : MPEG-2 AAC Decoder
* contents/description: Inverse MDCT include file
*
\***************************************************************************/
#ifndef _DOLBY_IMDCT_H
#define _DOLBY_IMDCT_H
#include<math.h>
#include<string.h>
#include"fft.h"
/*#define INTERPOLATE_WINDOW */
class IMDCTObject{
public:
IMDCTObject(int _iLongSize,
int _iOverlap);
IMDCTObject();
IMDCTObject(IMDCTObject&oCopy);
IMDCTObject& operator=(IMDCTObject&oCopy);
~IMDCTObject();
int Transform( float*pfData,
int iWindowType,
int iWindowShape);
private:
enum {
LONG_BLOCK,
SHORT_BLOCK
};
enum {
LONG_WINDOW = 0,
START_WINDOW = 1,
EIGHT_SHORT_SEQUENCE = 2,
STOP_WINDOW = 3
};
enum {
SINE_WINDOW = 0,
KBD_WINDOW = 1
};
void imdct(float* pfData, int blocktype);
private:
int iLongSize;
int iShortSize;
int iHLongSize;
int iHShortSize;
int iOverlap;
int iOldShape;
//Windows:
float*pfLongWindowSin;
float*pfS2LWindowSin;
float*pfShortWindowSin;
float*pfLongWindowKBD;
float*pfS2LWindowKBD;
float*pfShortWindowKBD;
float*pfTempBuffer;
float*pfEightWindowsBuffer;
float*pfSavedBuffer;
//MDCT Data:
int iLongFFTSize;
int iShortFFTSize;
float*pfReal;
float*pfImag;
float*pfRealLongTwiddle;
float*pfImagLongTwiddle;
float*pfRealShort;
float*pfImagShort;
float*pfRealShortTwiddle;
float*pfImagShortTwiddle;
};
#endif

View File

@ -1,91 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/exception.h,v 1.1 2009/04/28 20:21:09 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: exception.cpp
* project : MPEG-2 AAC Decoder
* contents/description: common exception object
*
* $Header: /cvs/root/winamp/vlb/exception.h,v 1.1 2009/04/28 20:21:09 audiodsp Exp $
*
\***************************************************************************/
#ifndef __EXCEPTION_H__
#define __EXCEPTION_H__
#define AAC_OK 0x0000
#define AAC_FAILURE_BASE 0x1000
#define AAC_UNIMPLEMENTED (AAC_FAILURE_BASE | 1)
#define AAC_NOTADIFHEADER (AAC_FAILURE_BASE | 2)
#define AAC_DOESNOTEXIST (AAC_FAILURE_BASE | 3)
#define AAC_ENDOFSTREAM (AAC_FAILURE_BASE | 4)
#define AAC_SYNCERROR (AAC_FAILURE_BASE | 5)
#define AAC_CRCERROR (AAC_FAILURE_BASE | 6)
#define AAC_INPUT_BUFFER_EMPTY (AAC_FAILURE_BASE | 7)
#define AAC_INVALIDCODEBOOK (AAC_FAILURE_BASE | 8)
#ifdef MAIN_PROFILE
#define AAC_INVALIDPREDICTORRESET (AAC_FAILURE_BASE | 9)
#endif
#define AAC_UNSUPPORTEDWINDOWSHAPE (AAC_FAILURE_BASE | 10)
#define AAC_DOLBY_NOT_SUPPORTED (AAC_FAILURE_BASE | 11)
#define AAC_ILLEGAL_PROFILE (AAC_FAILURE_BASE | 12)
#ifdef __cplusplus
/** Base Class For Exceptions.
This class defines the interface that all exceptions possibly thrown by
\Ref{CAacDecoder} or its input objects are derived from.
*/
class CAacException
{
public :
/// Exception Constructor.
CAacException (int _value, char *_text) : value(_value), text(_text) {} ;
/// Exception Destructor.
~CAacException () {} ;
/** Exception Code Method.
This method returns an exception status code, that can be used programatically.
*/
int What () { return value ; }
/** Exception Text Method.
This method returns a pointer to a plain text explanation of what happened.
It might be used e.g. for user notification messages or the like.
*/
char *Explain () { return text ; }
protected :
int value ;
char *text ;
} ;
#define DECLARE_EXCEPTION(a,b,c) class a : public CAacException { public : a () : CAacException (b, c) {} ; }
#endif
#endif

View File

@ -1,65 +0,0 @@
#include "factory_nsvVlb.h"
#include "NSVFactory.h"
static const char serviceName[] = "Dolby VLB NSV Decoder";
// {69D8A07C-ECE4-44f8-9C40-12506422A882}
static const GUID nsv_vlb_guid =
{ 0x69d8a07c, 0xece4, 0x44f8, { 0x9c, 0x40, 0x12, 0x50, 0x64, 0x22, 0xa8, 0x82 } };
static NSVFactory nsvFactory;
FOURCC NSVVLBFactory::GetServiceType()
{
return WaSvc::NSVFACTORY;
}
const char *NSVVLBFactory::GetServiceName()
{
return serviceName;
}
GUID NSVVLBFactory::GetGUID()
{
return nsv_vlb_guid;
}
void *NSVVLBFactory::GetInterface(int global_lock)
{
svc_nsvFactory *ifc = &nsvFactory;
return ifc;
}
int NSVVLBFactory::SupportNonLockingInterface()
{
return 1;
}
int NSVVLBFactory::ReleaseInterface(void *ifc)
{
return 1;
}
const char *NSVVLBFactory::GetTestString()
{
return 0;
}
int NSVVLBFactory::ServiceNotify(int msg, int param1, int param2)
{
return 1;
}
#define CBCLASS NSVVLBFactory
START_DISPATCH;
CB(WASERVICEFACTORY_GETSERVICETYPE, GetServiceType)
CB(WASERVICEFACTORY_GETSERVICENAME, GetServiceName)
CB(WASERVICEFACTORY_GETGUID, GetGUID)
CB(WASERVICEFACTORY_GETINTERFACE, GetInterface)
CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface)
CB(WASERVICEFACTORY_RELEASEINTERFACE, ReleaseInterface)
CB(WASERVICEFACTORY_GETTESTSTRING, GetTestString)
CB(WASERVICEFACTORY_SERVICENOTIFY, ServiceNotify)
END_DISPATCH;
#undef CBCLASS

View File

@ -1,25 +0,0 @@
#ifndef NULLSOFT_FACTORY_NSVFACTORY_H
#define NULLSOFT_FACTORY_NSVFACTORY_H
//#include "api__vlb.h"
#include <api/service/waservicefactory.h>
#include <api/service/services.h>
class NSVVLBFactory : public waServiceFactory
{
public:
FOURCC GetServiceType();
const char *GetServiceName();
GUID GetGUID();
void *GetInterface(int global_lock);
int SupportNonLockingInterface();
int ReleaseInterface(void *ifc);
const char *GetTestString();
int ServiceNotify(int msg, int param1, int param2);
protected:
RECVS_DISPATCH;
};
#endif

View File

@ -1,66 +0,0 @@
//#define GUID_EQUALS_DEFINED
#include "api__vlb.h"
#include "factory_vlbdecoder.h"
#include "VlbDecoder.h"
static const char serviceName[] = "Dolby VLB Decoder";
FOURCC VLBDecoderFactory::GetServiceType()
{
return WaSvc::OBJECT;
}
const char *VLBDecoderFactory::GetServiceName()
{
return serviceName;
}
GUID VLBDecoderFactory::GetGUID()
{
return obj_vlbDecoderGUID;
}
void *VLBDecoderFactory::GetInterface(int global_lock)
{
obj_vlbDecoder *ifc=new VLBDecoder;
// if (global_lock)
// WASABI_API_SVC->service_lock(this, (void *)ifc);
return ifc;
}
int VLBDecoderFactory::SupportNonLockingInterface()
{
return 1;
}
int VLBDecoderFactory::ReleaseInterface(void *ifc)
{
//WASABI_API_SVC->service_unlock(ifc);
obj_vlbDecoder *decoder = static_cast<obj_vlbDecoder *>(ifc);
VLBDecoder *vlbDecoder = static_cast<VLBDecoder *>(decoder);
delete vlbDecoder;
return 1;
}
const char *VLBDecoderFactory::GetTestString()
{
return NULL;
}
int VLBDecoderFactory::ServiceNotify(int msg, int param1, int param2)
{
return 1;
}
#define CBCLASS VLBDecoderFactory
START_DISPATCH;
CB(WASERVICEFACTORY_GETSERVICETYPE, GetServiceType)
CB(WASERVICEFACTORY_GETSERVICENAME, GetServiceName)
CB(WASERVICEFACTORY_GETGUID, GetGUID)
CB(WASERVICEFACTORY_GETINTERFACE, GetInterface)
CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface)
CB(WASERVICEFACTORY_RELEASEINTERFACE, ReleaseInterface)
CB(WASERVICEFACTORY_GETTESTSTRING, GetTestString)
CB(WASERVICEFACTORY_SERVICENOTIFY, ServiceNotify)
END_DISPATCH;
#undef CBCLASS

View File

@ -1,23 +0,0 @@
#ifndef NULLSOFT_FACTORY_VLBDECODER_H
#define NULLSOFT_FACTORY_VLBDECODER_H
#include <api/service/waservicefactory.h>
#include <api/service/services.h>
class VLBDecoderFactory : public waServiceFactory
{
public:
FOURCC GetServiceType();
const char *GetServiceName();
GUID GetGUID();
void *GetInterface(int global_lock);
int SupportNonLockingInterface();
int ReleaseInterface(void *ifc);
const char *GetTestString();
int ServiceNotify(int msg, int param1, int param2);
protected:
RECVS_DISPATCH;
};
#endif

View File

@ -1,317 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/fft.cpp,v 1.1 2009/04/28 20:21:09 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* filename: fft.cpp
* project : MPEG-2 AAC Decoder
* contents/description: Standard FFT routine
*
\***************************************************************************/
/* Description: This function calculates a 1024,256 or 128 point fft via
decimation in frequency algorithm described in "Digital Signal
Processing" by Oppenheim and Schafer, refer to pages 304 (flow
chart) and 330-332 (Fotran program in problem 5). Modified to
get only desired block sizes. */
#include"fft.h"
#ifndef PI
#define PI 3.14159265358979
#endif
#define HOTSWAP(a,b) fTemp=a; a=b; b=fTemp;
void fftl(float *pfReal, float *pfImag,int iSize)
{
static int iInit=0;
static int iPower2=0;
static int iTransformSize=0;
static float *pfTwiddleReal=0;
static float *pfTwiddleImag=0;
if(iSize!=iTransformSize){
iInit=0;
}
if(!iInit){
int iCounter;
if((iSize-1)&iSize){
//printf("FFT Length Must be Radix 2!\n");
return;
}
free(pfTwiddleReal);
free(pfTwiddleImag);
iTransformSize=iSize;
pfTwiddleReal=(float*)malloc(iSize/2*sizeof(float));
pfTwiddleImag=(float*)malloc(iSize/2*sizeof(float));
for(iCounter=0;iCounter<iSize/2;iCounter++){
pfTwiddleReal[iCounter]=(float)(cos(2.0*PI/(double)iSize*(double)iCounter));
pfTwiddleImag[iCounter]=(float)(-1.0*sin(2.0*PI/(double)iSize*(double)iCounter));
}
iPower2=0;
for(iCounter=1;iCounter<iSize;iCounter<<=1) iPower2++;
iInit++;
}
/* Perform Fast Fourier Transform: */
/* With Help From Figure 6.11 pp 464 */
/* John G. Proakis,"Digital Signal Processing," 3rd Edt. */
/* 1996 Prentice Hall */
int iSkip;
int iFFTCounter;
int iCounter1;
int iCounter2;
int iOffset;
int iHSize;
iHSize=iSize>>1;
iFFTCounter=1;
for(iSkip=iHSize;iSkip>0;iSkip>>=1){
iOffset=0;
for(iCounter1=0;iCounter1<iFFTCounter;iCounter1++){
int iOffset1;
int iOffset2;
int iTwiddleOffset;
iOffset1=iOffset;
iOffset2=iOffset1+iSkip;
iTwiddleOffset=0;
for(iCounter2=0;iCounter2<iSkip;iCounter2++){
float fTemp;
fTemp=pfReal[iOffset1];
pfReal[iOffset1]+=pfReal[iOffset2];
pfReal[iOffset2]=fTemp-pfReal[iOffset2];
fTemp=pfImag[iOffset1];
pfImag[iOffset1]+=pfImag[iOffset2];
pfImag[iOffset2]=fTemp-pfImag[iOffset2];
if(iCounter2){
fTemp=pfReal[iOffset2];
pfReal[iOffset2]=pfReal[iOffset2]*pfTwiddleReal[iTwiddleOffset]-
pfImag[iOffset2]*pfTwiddleImag[iTwiddleOffset];
pfImag[iOffset2]=fTemp*pfTwiddleImag[iTwiddleOffset]+
pfImag[iOffset2]*pfTwiddleReal[iTwiddleOffset];
}
iOffset1++;
iOffset2++;
iTwiddleOffset+=iFFTCounter;
}
iOffset+=(iSkip<<1);
}
iFFTCounter<<=1;
}
/*Reorder Data: */
iCounter1=0;
for(iCounter2=0;iCounter2<iSize-1;iCounter2++){
int iCounter3;
if(iCounter2<iCounter1){
float fTemp;
HOTSWAP(pfReal[iCounter2],pfReal[iCounter1]);
HOTSWAP(pfImag[iCounter2],pfImag[iCounter1]);
}
iCounter3=iHSize;
while(iCounter3<=iCounter1){
iCounter1-=iCounter3;
iCounter3=iCounter3>>1;
}
iCounter1=iCounter1+iCounter3;
}
}
/*
void fftl(float* xreal,float* ximag,int N)
{
int m,mm1;
static int init=0;
int nv2,nm1,mp;
static float wreal[13][13],wimag[13][13];
int i,j,k,l;
int ip,le,le1;
float treal,timag,ureal,uimag;
if (init==0){
memset((char*) wreal,0,sizeof(wreal));
memset((char*)wimag,0,sizeof(wimag));
m=13;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[0][l]=(float)(cosl(pi/le1));
wimag[0][l]=-1.0f*(float)(sinl(pi/le1));
}
m=12;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[1][l]=(float)(cosl(pi/le1));
wimag[1][l]=-1.0f*(float)(sinl(pi/le1));
}
m=11;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[2][l]=(float)(cosl(pi/le1));
wimag[2][l]=-1.0f*(float)(sinl(pi/le1));
}
m=10;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[3][l]=(float)(cosl(pi/le1));
wimag[3][l]=-1.0f*(float)(sinl(pi/le1));
}
m=9;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[4][l]=(float)(cosl(pi/le1));
wimag[4][l]=-1.0f*(float)(sinl(pi/le1));
}
m=8;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[5][l]=(float)(cosl(pi/le1));
wimag[5][l]=-1.0f*(float)(sinl(pi/le1));
}
m=7;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[6][l]=(float)(cosl(pi/le1));
wimag[6][l]=-1.0f*(float)(sinl(pi/le1));
}
m=6;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[7][l]=(float)(cosl(pi/le1));
wimag[7][l]=-1.0f*(float)(sinl(pi/le1));
}
m=5;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[8][l]=(float)(cosl(pi/le1));
wimag[8][l]=-1.0f*(float)(sinl(pi/le1));
}
m=4;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[9][l]=(float)(cosl(pi/le1));
wimag[9][l]=-1.0f*(float)(sinl(pi/le1));
}
m=3;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[10][l]=(float)(cosl(pi/le1));
wimag[10][l]=-1.0f*(float)(sinl(pi/le1));
}
m=2;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[11][l]=(float)(cosl(pi/le1));
wimag[11][l]=-1.0f*(float)(sinl(pi/le1));
}
m=1;
for(l=0;l<m;l++){
le=1<<(m-l);
le1=le>>1;
wreal[12][l]=(float)(cosl(pi/le1));
wimag[12][l]=-1.0f*(float)(sinl(pi/le1));
}
init++;
}
switch(N){
case 8192: m=13;mp=0;break;
case 4096: m=12;mp=1;break;
case 2048: m=11;mp=2;break;
case 1024: m=10;mp=3;break;
case 512: m=9;mp=4;break;
case 256:m=8;mp=5;break;
case 128:m=7;mp=6;break;
case 64:m=6;mp=7;break;
case 32:m=5;mp=8;break;
case 16:m=4;mp=9;break;
case 8:m=3;mp=10;break;
case 4:m=2;mp=11;break;
case 2:m=1;mp=12;break;
default: printf("FFT ERROR! %d\n",N);return;
}
mm1=m-1;
nv2=N>>1;
nm1=N-1;
for(l=0;l<mm1;l++){
le=1<<(m-l);
le1=le>>1;
ureal=1;
uimag=0;
for(j=0;j<le1;j++){
for(i=j;i<N;i+=le){
ip=i+le1;
treal=xreal[i]+xreal[ip];
timag=ximag[i]+ximag[ip];
xreal[ip]=xreal[i]-xreal[ip];
ximag[ip]=ximag[i]-ximag[ip];
xreal[i]=treal;
ximag[i]=timag;
treal=xreal[ip];
xreal[ip]=xreal[ip]*ureal-ximag[ip]*uimag;
ximag[ip]=ximag[ip]*ureal+treal*uimag;
}
treal=ureal;
ureal=ureal*wreal[mp][l]-uimag*wimag[mp][l];
uimag=uimag*wreal[mp][l]+treal*wimag[mp][l];
}
}
for(i=0;i<N;i+=2){
ip=i+1;
treal=xreal[i]+xreal[ip];
timag=ximag[i]+ximag[ip];
xreal[ip]=xreal[i]-xreal[ip];
ximag[ip]=ximag[i]-ximag[ip];
xreal[i]=treal;
ximag[i]=timag;
}
j=0;
for(i=0;i<nm1;i++){
if(i<j){
treal=xreal[j];
timag=ximag[j];
xreal[j]=xreal[i];
ximag[j]=ximag[i];
xreal[i]=treal;
ximag[i]=timag;
}
k=nv2;
while(k<=j){
j=j-k;
k=k>>1;
}
j=j+k;
}
}
*/

View File

@ -1,30 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/fft.h,v 1.1 2009/04/28 20:21:09 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* filename: fft.h
* project : MPEG-2 AAC Decoder
* contents/description: FFT include file
*
* $Header: /cvs/root/winamp/vlb/fft.h,v 1.1 2009/04/28 20:21:09 audiodsp Exp $
*
\***************************************************************************/
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#ifndef FFTH
#define FFTH
#ifndef pi
#define pi 3.1415926535897932384626434f
#endif
void fftl(float* ,float* ,int );
#endif

View File

@ -1,875 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/imdct.cpp,v 1.2 2011/06/13 02:06:03 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: imdct.cpp
* project : MPEG-2 AAC Decoder
* contents/description: inverse modified discrete cosine transform
*
\***************************************************************************/
#include "block.h"
static const float CosTable_2048 [2048] =
{
0.500000F, 0.500001F, 0.500004F, 0.500007F, 0.500012F, 0.500018F, 0.500025F, 0.500033F,
0.500043F, 0.500053F, 0.500065F, 0.500078F, 0.500092F, 0.500107F, 0.500124F, 0.500141F,
0.500160F, 0.500180F, 0.500201F, 0.500224F, 0.500247F, 0.500272F, 0.500298F, 0.500325F,
0.500353F, 0.500383F, 0.500413F, 0.500445F, 0.500478F, 0.500512F, 0.500548F, 0.500584F,
0.500622F, 0.500661F, 0.500701F, 0.500742F, 0.500785F, 0.500828F, 0.500873F, 0.500919F,
0.500966F, 0.501015F, 0.501064F, 0.501115F, 0.501167F, 0.501220F, 0.501275F, 0.501330F,
0.501387F, 0.501445F, 0.501504F, 0.501564F, 0.501626F, 0.501689F, 0.501752F, 0.501818F,
0.501884F, 0.501951F, 0.502020F, 0.502090F, 0.502161F, 0.502233F, 0.502307F, 0.502381F,
0.502457F, 0.502535F, 0.502613F, 0.502692F, 0.502773F, 0.502855F, 0.502938F, 0.503023F,
0.503108F, 0.503195F, 0.503283F, 0.503372F, 0.503463F, 0.503554F, 0.503647F, 0.503741F,
0.503837F, 0.503933F, 0.504031F, 0.504130F, 0.504230F, 0.504331F, 0.504434F, 0.504538F,
0.504643F, 0.504750F, 0.504857F, 0.504966F, 0.505076F, 0.505187F, 0.505300F, 0.505414F,
0.505529F, 0.505645F, 0.505762F, 0.505881F, 0.506001F, 0.506122F, 0.506245F, 0.506369F,
0.506494F, 0.506620F, 0.506747F, 0.506876F, 0.507006F, 0.507137F, 0.507270F, 0.507404F,
0.507539F, 0.507675F, 0.507813F, 0.507952F, 0.508092F, 0.508233F, 0.508376F, 0.508520F,
0.508665F, 0.508812F, 0.508960F, 0.509109F, 0.509259F, 0.509411F, 0.509564F, 0.509718F,
0.509874F, 0.510030F, 0.510189F, 0.510348F, 0.510509F, 0.510671F, 0.510834F, 0.510999F,
0.511165F, 0.511332F, 0.511501F, 0.511671F, 0.511842F, 0.512014F, 0.512188F, 0.512363F,
0.512540F, 0.512718F, 0.512897F, 0.513077F, 0.513259F, 0.513442F, 0.513627F, 0.513813F,
0.514000F, 0.514189F, 0.514379F, 0.514570F, 0.514762F, 0.514956F, 0.515152F, 0.515348F,
0.515547F, 0.515746F, 0.515947F, 0.516149F, 0.516352F, 0.516557F, 0.516764F, 0.516971F,
0.517180F, 0.517391F, 0.517603F, 0.517816F, 0.518031F, 0.518247F, 0.518464F, 0.518683F,
0.518903F, 0.519125F, 0.519348F, 0.519572F, 0.519798F, 0.520025F, 0.520254F, 0.520484F,
0.520716F, 0.520949F, 0.521183F, 0.521419F, 0.521657F, 0.521895F, 0.522136F, 0.522377F,
0.522620F, 0.522865F, 0.523111F, 0.523359F, 0.523608F, 0.523858F, 0.524110F, 0.524363F,
0.524618F, 0.524875F, 0.525132F, 0.525392F, 0.525653F, 0.525915F, 0.526179F, 0.526444F,
0.526711F, 0.526979F, 0.527249F, 0.527521F, 0.527793F, 0.528068F, 0.528344F, 0.528621F,
0.528900F, 0.529181F, 0.529463F, 0.529747F, 0.530032F, 0.530319F, 0.530607F, 0.530897F,
0.531189F, 0.531482F, 0.531776F, 0.532072F, 0.532370F, 0.532670F, 0.532970F, 0.533273F,
0.533577F, 0.533883F, 0.534190F, 0.534499F, 0.534810F, 0.535122F, 0.535436F, 0.535751F,
0.536069F, 0.536387F, 0.536708F, 0.537030F, 0.537353F, 0.537679F, 0.538006F, 0.538334F,
0.538665F, 0.538997F, 0.539331F, 0.539666F, 0.540003F, 0.540342F, 0.540682F, 0.541024F,
0.541368F, 0.541714F, 0.542061F, 0.542410F, 0.542761F, 0.543113F, 0.543468F, 0.543824F,
0.544181F, 0.544541F, 0.544902F, 0.545265F, 0.545630F, 0.545996F, 0.546365F, 0.546735F,
0.547107F, 0.547480F, 0.547856F, 0.548233F, 0.548612F, 0.548993F, 0.549376F, 0.549760F,
0.550147F, 0.550535F, 0.550925F, 0.551317F, 0.551711F, 0.552107F, 0.552504F, 0.552903F,
0.553305F, 0.553708F, 0.554113F, 0.554520F, 0.554929F, 0.555340F, 0.555752F, 0.556167F,
0.556584F, 0.557002F, 0.557422F, 0.557845F, 0.558269F, 0.558695F, 0.559124F, 0.559554F,
0.559986F, 0.560420F, 0.560857F, 0.561295F, 0.561735F, 0.562177F, 0.562621F, 0.563068F,
0.563516F, 0.563966F, 0.564419F, 0.564873F, 0.565330F, 0.565788F, 0.566249F, 0.566712F,
0.567177F, 0.567644F, 0.568113F, 0.568584F, 0.569057F, 0.569533F, 0.570010F, 0.570490F,
0.570972F, 0.571456F, 0.571942F, 0.572430F, 0.572921F, 0.573414F, 0.573909F, 0.574406F,
0.574905F, 0.575407F, 0.575911F, 0.576417F, 0.576925F, 0.577436F, 0.577948F, 0.578463F,
0.578981F, 0.579501F, 0.580023F, 0.580547F, 0.581073F, 0.581602F, 0.582134F, 0.582667F,
0.583203F, 0.583742F, 0.584282F, 0.584825F, 0.585371F, 0.585919F, 0.586469F, 0.587022F,
0.587577F, 0.588134F, 0.588694F, 0.589257F, 0.589822F, 0.590389F, 0.590959F, 0.591531F,
0.592106F, 0.592684F, 0.593264F, 0.593846F, 0.594431F, 0.595019F, 0.595609F, 0.596201F,
0.596797F, 0.597395F, 0.597995F, 0.598598F, 0.599204F, 0.599812F, 0.600423F, 0.601037F,
0.601653F, 0.602272F, 0.602894F, 0.603519F, 0.604146F, 0.604776F, 0.605408F, 0.606044F,
0.606682F, 0.607323F, 0.607967F, 0.608613F, 0.609262F, 0.609915F, 0.610570F, 0.611227F,
0.611888F, 0.612552F, 0.613218F, 0.613887F, 0.614560F, 0.615235F, 0.615913F, 0.616594F,
0.617278F, 0.617965F, 0.618655F, 0.619348F, 0.620044F, 0.620743F, 0.621445F, 0.622150F,
0.622859F, 0.623570F, 0.624284F, 0.625002F, 0.625722F, 0.626446F, 0.627173F, 0.627903F,
0.628636F, 0.629373F, 0.630113F, 0.630856F, 0.631602F, 0.632351F, 0.633104F, 0.633860F,
0.634619F, 0.635382F, 0.636147F, 0.636917F, 0.637689F, 0.638465F, 0.639245F, 0.640028F,
0.640814F, 0.641604F, 0.642397F, 0.643193F, 0.643994F, 0.644797F, 0.645604F, 0.646415F,
0.647229F, 0.648047F, 0.648869F, 0.649694F, 0.650523F, 0.651355F, 0.652191F, 0.653031F,
0.653874F, 0.654721F, 0.655572F, 0.656427F, 0.657285F, 0.658147F, 0.659014F, 0.659883F,
0.660757F, 0.661635F, 0.662516F, 0.663402F, 0.664291F, 0.665184F, 0.666082F, 0.666983F,
0.667888F, 0.668798F, 0.669711F, 0.670629F, 0.671550F, 0.672476F, 0.673406F, 0.674340F,
0.675278F, 0.676220F, 0.677167F, 0.678118F, 0.679073F, 0.680033F, 0.680996F, 0.681964F,
0.682937F, 0.683914F, 0.684895F, 0.685881F, 0.686871F, 0.687866F, 0.688865F, 0.689869F,
0.690877F, 0.691890F, 0.692907F, 0.693929F, 0.694956F, 0.695987F, 0.697024F, 0.698064F,
0.699110F, 0.700160F, 0.701216F, 0.702276F, 0.703341F, 0.704411F, 0.705485F, 0.706565F,
0.707650F, 0.708739F, 0.709834F, 0.710934F, 0.712039F, 0.713149F, 0.714264F, 0.715384F,
0.716510F, 0.717641F, 0.718777F, 0.719918F, 0.721065F, 0.722217F, 0.723374F, 0.724537F,
0.725705F, 0.726879F, 0.728058F, 0.729243F, 0.730434F, 0.731630F, 0.732832F, 0.734039F,
0.735252F, 0.736471F, 0.737696F, 0.738926F, 0.740162F, 0.741405F, 0.742653F, 0.743907F,
0.745167F, 0.746433F, 0.747705F, 0.748984F, 0.750268F, 0.751559F, 0.752856F, 0.754159F,
0.755468F, 0.756784F, 0.758106F, 0.759435F, 0.760770F, 0.762112F, 0.763460F, 0.764814F,
0.766176F, 0.767544F, 0.768918F, 0.770300F, 0.771688F, 0.773083F, 0.774485F, 0.775894F,
0.777309F, 0.778732F, 0.780162F, 0.781599F, 0.783043F, 0.784495F, 0.785953F, 0.787419F,
0.788892F, 0.790373F, 0.791861F, 0.793356F, 0.794859F, 0.796370F, 0.797888F, 0.799414F,
0.800948F, 0.802489F, 0.804038F, 0.805596F, 0.807161F, 0.808734F, 0.810315F, 0.811904F,
0.813502F, 0.815108F, 0.816721F, 0.818344F, 0.819974F, 0.821614F, 0.823261F, 0.824917F,
0.826582F, 0.828256F, 0.829938F, 0.831629F, 0.833329F, 0.835038F, 0.836756F, 0.838483F,
0.840219F, 0.841964F, 0.843719F, 0.845482F, 0.847256F, 0.849038F, 0.850830F, 0.852632F,
0.854444F, 0.856265F, 0.858096F, 0.859937F, 0.861788F, 0.863648F, 0.865519F, 0.867400F,
0.869292F, 0.871193F, 0.873105F, 0.875028F, 0.876961F, 0.878905F, 0.880859F, 0.882824F,
0.884800F, 0.886787F, 0.888786F, 0.890795F, 0.892815F, 0.894847F, 0.896890F, 0.898945F,
0.901011F, 0.903089F, 0.905178F, 0.907279F, 0.909393F, 0.911518F, 0.913655F, 0.915805F,
0.917967F, 0.920141F, 0.922328F, 0.924528F, 0.926740F, 0.928965F, 0.931202F, 0.933453F,
0.935717F, 0.937994F, 0.940285F, 0.942589F, 0.944906F, 0.947238F, 0.949582F, 0.951941F,
0.954314F, 0.956701F, 0.959102F, 0.961518F, 0.963948F, 0.966392F, 0.968851F, 0.971326F,
0.973815F, 0.976319F, 0.978838F, 0.981373F, 0.983923F, 0.986489F, 0.989071F, 0.991668F,
0.994282F, 0.996911F, 0.999557F, 1.002220F, 1.004899F, 1.007595F, 1.010307F, 1.013037F,
1.015784F, 1.018548F, 1.021330F, 1.024129F, 1.026946F, 1.029781F, 1.032635F, 1.035506F,
1.038396F, 1.041305F, 1.044233F, 1.047179F, 1.050145F, 1.053130F, 1.056134F, 1.059158F,
1.062202F, 1.065266F, 1.068351F, 1.071455F, 1.074581F, 1.077727F, 1.080894F, 1.084083F,
1.087293F, 1.090524F, 1.093778F, 1.097053F, 1.100351F, 1.103671F, 1.107014F, 1.110380F,
1.113769F, 1.117181F, 1.120618F, 1.124077F, 1.127561F, 1.131070F, 1.134603F, 1.138160F,
1.141743F, 1.145351F, 1.148985F, 1.152645F, 1.156330F, 1.160042F, 1.163781F, 1.167547F,
1.171340F, 1.175160F, 1.179008F, 1.182885F, 1.186789F, 1.190723F, 1.194685F, 1.198676F,
1.202698F, 1.206749F, 1.210830F, 1.214942F, 1.219085F, 1.223259F, 1.227464F, 1.231702F,
1.235972F, 1.240274F, 1.244610F, 1.248978F, 1.253381F, 1.257818F, 1.262289F, 1.266795F,
1.271336F, 1.275913F, 1.280526F, 1.285176F, 1.289863F, 1.294587F, 1.299348F, 1.304148F,
1.308987F, 1.313865F, 1.318782F, 1.323740F, 1.328738F, 1.333777F, 1.338858F, 1.343980F,
1.349146F, 1.354354F, 1.359606F, 1.364902F, 1.370242F, 1.375628F, 1.381060F, 1.386537F,
1.392062F, 1.397635F, 1.403255F, 1.408924F, 1.414643F, 1.420411F, 1.426230F, 1.432101F,
1.438023F, 1.443998F, 1.450026F, 1.456108F, 1.462245F, 1.468437F, 1.474685F, 1.480990F,
1.487353F, 1.493775F, 1.500255F, 1.506796F, 1.513397F, 1.520061F, 1.526786F, 1.533575F,
1.540429F, 1.547348F, 1.554332F, 1.561384F, 1.568504F, 1.575692F, 1.582951F, 1.590281F,
1.597682F, 1.605157F, 1.612705F, 1.620329F, 1.628029F, 1.635807F, 1.643663F, 1.651598F,
1.659615F, 1.667714F, 1.675896F, 1.684163F, 1.692516F, 1.700956F, 1.709485F, 1.718104F,
1.726814F, 1.735617F, 1.744514F, 1.753508F, 1.762598F, 1.771788F, 1.781078F, 1.790470F,
1.799966F, 1.809568F, 1.819277F, 1.829095F, 1.839024F, 1.849066F, 1.859222F, 1.869495F,
1.879887F, 1.890399F, 1.901034F, 1.911794F, 1.922681F, 1.933697F, 1.944844F, 1.956126F,
1.967544F, 1.979101F, 1.990799F, 2.002640F, 2.014629F, 2.026766F, 2.039056F, 2.051500F,
2.064102F, 2.076865F, 2.089791F, 2.102884F, 2.116148F, 2.129585F, 2.143198F, 2.156992F,
2.170970F, 2.185135F, 2.199492F, 2.214044F, 2.228794F, 2.243748F, 2.258910F, 2.274283F,
2.289872F, 2.305682F, 2.321717F, 2.337982F, 2.354483F, 2.371223F, 2.388209F, 2.405446F,
2.422939F, 2.440694F, 2.458717F, 2.477015F, 2.495592F, 2.514456F, 2.533614F, 2.553072F,
2.572837F, 2.592917F, 2.613318F, 2.634050F, 2.655119F, 2.676535F, 2.698305F, 2.720439F,
2.742945F, 2.765834F, 2.789114F, 2.812796F, 2.836891F, 2.861409F, 2.886361F, 2.911759F,
2.937614F, 2.963941F, 2.990750F, 3.018056F, 3.045872F, 3.074214F, 3.103095F, 3.132531F,
3.162538F, 3.193134F, 3.224335F, 3.256160F, 3.288627F, 3.321755F, 3.355566F, 3.390081F,
3.425320F, 3.461309F, 3.498070F, 3.535629F, 3.574011F, 3.613245F, 3.653358F, 3.694381F,
3.736344F, 3.779280F, 3.823224F, 3.868211F, 3.914279F, 3.961467F, 4.009816F, 4.059369F,
4.110172F, 4.162272F, 4.215721F, 4.270570F, 4.326876F, 4.384697F, 4.444094F, 4.505134F,
4.567885F, 4.632419F, 4.698814F, 4.767152F, 4.837518F, 4.910005F, 4.984708F, 5.061732F,
5.141187F, 5.223187F, 5.307859F, 5.395334F, 5.485753F, 5.579268F, 5.676041F, 5.776243F,
5.880061F, 5.987694F, 6.099355F, 6.215275F, 6.335701F, 6.460902F, 6.591167F, 6.726808F,
6.868167F, 7.015611F, 7.169541F, 7.330395F, 7.498651F, 7.674831F, 7.859508F, 8.053311F,
8.256933F, 8.471140F, 8.696777F, 8.934786F, 9.186211F, 9.452218F, 9.734114F, 10.033366F,
10.351625F, 10.690763F, 11.052902F, 11.440462F, 11.856219F, 12.303363F, 12.785587F, 13.307186F,
13.873188F, 14.489513F, 15.163182F, 15.902588F, 16.717843F, 17.621247F, 18.627913F, 19.756614F,
21.030970F, 22.481117F, 24.146120F, 26.077544F, 28.344889F, 31.044135F, 34.311669F, 38.348066F,
43.460868F, 50.146880F, 59.264216F, 72.433758F, 93.128825F, 130.380047F, 217.299736F, 651.898673F,
0.500001F, 0.500005F, 0.500015F, 0.500029F, 0.500048F, 0.500071F, 0.500099F, 0.500132F,
0.500170F, 0.500212F, 0.500260F, 0.500311F, 0.500368F, 0.500429F, 0.500495F, 0.500566F,
0.500641F, 0.500722F, 0.500806F, 0.500896F, 0.500991F, 0.501090F, 0.501194F, 0.501302F,
0.501416F, 0.501534F, 0.501657F, 0.501785F, 0.501917F, 0.502055F, 0.502197F, 0.502344F,
0.502496F, 0.502652F, 0.502814F, 0.502980F, 0.503151F, 0.503327F, 0.503508F, 0.503694F,
0.503885F, 0.504080F, 0.504281F, 0.504486F, 0.504696F, 0.504911F, 0.505131F, 0.505357F,
0.505587F, 0.505822F, 0.506062F, 0.506307F, 0.506557F, 0.506812F, 0.507072F, 0.507337F,
0.507607F, 0.507882F, 0.508162F, 0.508448F, 0.508738F, 0.509034F, 0.509335F, 0.509641F,
0.509952F, 0.510268F, 0.510590F, 0.510916F, 0.511248F, 0.511585F, 0.511928F, 0.512276F,
0.512629F, 0.512987F, 0.513351F, 0.513720F, 0.514094F, 0.514474F, 0.514859F, 0.515250F,
0.515646F, 0.516048F, 0.516455F, 0.516867F, 0.517285F, 0.517709F, 0.518138F, 0.518573F,
0.519014F, 0.519460F, 0.519912F, 0.520369F, 0.520832F, 0.521301F, 0.521776F, 0.522256F,
0.522742F, 0.523235F, 0.523733F, 0.524236F, 0.524746F, 0.525262F, 0.525784F, 0.526311F,
0.526845F, 0.527385F, 0.527930F, 0.528482F, 0.529041F, 0.529605F, 0.530175F, 0.530752F,
0.531335F, 0.531924F, 0.532520F, 0.533122F, 0.533730F, 0.534345F, 0.534966F, 0.535594F,
0.536228F, 0.536869F, 0.537516F, 0.538170F, 0.538831F, 0.539498F, 0.540172F, 0.540853F,
0.541541F, 0.542235F, 0.542937F, 0.543645F, 0.544361F, 0.545083F, 0.545813F, 0.546549F,
0.547293F, 0.548044F, 0.548802F, 0.549568F, 0.550341F, 0.551121F, 0.551908F, 0.552704F,
0.553506F, 0.554316F, 0.555134F, 0.555959F, 0.556793F, 0.557633F, 0.558482F, 0.559339F,
0.560203F, 0.561075F, 0.561956F, 0.562844F, 0.563741F, 0.564646F, 0.565559F, 0.566480F,
0.567410F, 0.568348F, 0.569295F, 0.570250F, 0.571214F, 0.572186F, 0.573167F, 0.574157F,
0.575156F, 0.576163F, 0.577180F, 0.578206F, 0.579240F, 0.580284F, 0.581338F, 0.582400F,
0.583472F, 0.584554F, 0.585644F, 0.586745F, 0.587855F, 0.588975F, 0.590105F, 0.591245F,
0.592395F, 0.593555F, 0.594725F, 0.595905F, 0.597095F, 0.598296F, 0.599508F, 0.600730F,
0.601963F, 0.603206F, 0.604460F, 0.605726F, 0.607002F, 0.608289F, 0.609588F, 0.610898F,
0.612219F, 0.613552F, 0.614897F, 0.616253F, 0.617621F, 0.619001F, 0.620393F, 0.621797F,
0.623214F, 0.624643F, 0.626084F, 0.627538F, 0.629004F, 0.630484F, 0.631976F, 0.633481F,
0.635000F, 0.636532F, 0.638077F, 0.639636F, 0.641208F, 0.642795F, 0.644395F, 0.646009F,
0.647638F, 0.649281F, 0.650938F, 0.652610F, 0.654297F, 0.655999F, 0.657716F, 0.659448F,
0.661195F, 0.662959F, 0.664737F, 0.666532F, 0.668343F, 0.670169F, 0.672013F, 0.673872F,
0.675749F, 0.677642F, 0.679552F, 0.681480F, 0.683425F, 0.685387F, 0.687368F, 0.689366F,
0.691383F, 0.693418F, 0.695471F, 0.697543F, 0.699635F, 0.701745F, 0.703875F, 0.706025F,
0.708194F, 0.710383F, 0.712593F, 0.714824F, 0.717075F, 0.719347F, 0.721640F, 0.723955F,
0.726292F, 0.728650F, 0.731031F, 0.733435F, 0.735861F, 0.738310F, 0.740783F, 0.743279F,
0.745799F, 0.748344F, 0.750913F, 0.753507F, 0.756126F, 0.758770F, 0.761440F, 0.764136F,
0.766859F, 0.769608F, 0.772385F, 0.775188F, 0.778020F, 0.780880F, 0.783768F, 0.786685F,
0.789632F, 0.792608F, 0.795614F, 0.798650F, 0.801717F, 0.804816F, 0.807946F, 0.811109F,
0.814304F, 0.817532F, 0.820793F, 0.824088F, 0.827418F, 0.830782F, 0.834182F, 0.837618F,
0.841090F, 0.844599F, 0.848146F, 0.851730F, 0.855353F, 0.859015F, 0.862717F, 0.866459F,
0.870241F, 0.874065F, 0.877931F, 0.881840F, 0.885793F, 0.889789F, 0.893830F, 0.897916F,
0.902048F, 0.906227F, 0.910454F, 0.914729F, 0.919053F, 0.923426F, 0.927851F, 0.932326F,
0.936854F, 0.941435F, 0.946070F, 0.950760F, 0.955506F, 0.960308F, 0.965168F, 0.970087F,
0.975065F, 0.980104F, 0.985204F, 0.990367F, 0.995595F, 1.000887F, 1.006245F, 1.011670F,
1.017164F, 1.022727F, 1.028362F, 1.034068F, 1.039848F, 1.045703F, 1.051635F, 1.057644F,
1.063732F, 1.069900F, 1.076151F, 1.082486F, 1.088906F, 1.095413F, 1.102008F, 1.108694F,
1.115472F, 1.122344F, 1.129313F, 1.136378F, 1.143544F, 1.150812F, 1.158183F, 1.165661F,
1.173247F, 1.180943F, 1.188752F, 1.196677F, 1.204719F, 1.212882F, 1.221168F, 1.229579F,
1.238119F, 1.246790F, 1.255595F, 1.264538F, 1.273620F, 1.282847F, 1.292220F, 1.301744F,
1.311421F, 1.321256F, 1.331252F, 1.341414F, 1.351744F, 1.362248F, 1.372929F, 1.383793F,
1.394842F, 1.406083F, 1.417521F, 1.429159F, 1.441004F, 1.453060F, 1.465334F, 1.477831F,
1.490557F, 1.503518F, 1.516721F, 1.530173F, 1.543880F, 1.557850F, 1.572089F, 1.586607F,
1.601410F, 1.616508F, 1.631908F, 1.647620F, 1.663654F, 1.680019F, 1.696725F, 1.713783F,
1.731204F, 1.748999F, 1.767181F, 1.785761F, 1.804754F, 1.824172F, 1.844031F, 1.864344F,
1.885128F, 1.906398F, 1.928172F, 1.950468F, 1.973305F, 1.996701F, 2.020679F, 2.045258F,
2.070463F, 2.096317F, 2.122844F, 2.150072F, 2.178029F, 2.206743F, 2.236246F, 2.266570F,
2.297749F, 2.329820F, 2.362822F, 2.396796F, 2.431783F, 2.467831F, 2.504988F, 2.543305F,
2.582837F, 2.623642F, 2.665783F, 2.709326F, 2.754341F, 2.800904F, 2.849096F, 2.899003F,
2.950718F, 3.004340F, 3.059976F, 3.117742F, 3.177762F, 3.240168F, 3.305107F, 3.372734F,
3.443220F, 3.516748F, 3.593520F, 3.673754F, 3.757688F, 3.845585F, 3.937730F, 4.034439F,
4.136057F, 4.242967F, 4.355593F, 4.474405F, 4.599924F, 4.732735F, 4.873491F, 5.022924F,
5.181861F, 5.351237F, 5.532114F, 5.725702F, 5.933388F, 6.156768F, 6.397687F, 6.658295F,
6.941104F, 7.249074F, 7.585716F, 7.955227F, 8.362662F, 8.814173F, 9.317313F, 9.881472F,
10.518458F, 11.243340F, 12.075649F, 13.041169F, 14.174650F, 15.524081F, 17.157657F, 19.175663F,
21.731872F, 25.074687F, 29.633163F, 36.217742F, 46.565084F, 65.190503F, 108.650157F, 325.949442F,
0.500002F, 0.500021F, 0.500059F, 0.500115F, 0.500191F, 0.500285F, 0.500398F, 0.500530F,
0.500681F, 0.500851F, 0.501040F, 0.501247F, 0.501474F, 0.501720F, 0.501986F, 0.502270F,
0.502574F, 0.502896F, 0.503239F, 0.503601F, 0.503982F, 0.504383F, 0.504803F, 0.505243F,
0.505703F, 0.506183F, 0.506683F, 0.507204F, 0.507744F, 0.508304F, 0.508885F, 0.509487F,
0.510109F, 0.510752F, 0.511416F, 0.512101F, 0.512807F, 0.513535F, 0.514283F, 0.515054F,
0.515846F, 0.516660F, 0.517497F, 0.518355F, 0.519236F, 0.520140F, 0.521066F, 0.522015F,
0.522988F, 0.523984F, 0.525003F, 0.526047F, 0.527114F, 0.528206F, 0.529322F, 0.530463F,
0.531629F, 0.532820F, 0.534036F, 0.535279F, 0.536547F, 0.537842F, 0.539163F, 0.540512F,
0.541887F, 0.543290F, 0.544721F, 0.546180F, 0.547668F, 0.549184F, 0.550730F, 0.552305F,
0.553910F, 0.555546F, 0.557212F, 0.558909F, 0.560638F, 0.562399F, 0.564192F, 0.566019F,
0.567878F, 0.569771F, 0.571699F, 0.573661F, 0.575658F, 0.577692F, 0.579761F, 0.581868F,
0.584012F, 0.586194F, 0.588414F, 0.590674F, 0.592973F, 0.595313F, 0.597695F, 0.600118F,
0.602583F, 0.605092F, 0.607644F, 0.610242F, 0.612884F, 0.615574F, 0.618310F, 0.621094F,
0.623927F, 0.626809F, 0.629742F, 0.632727F, 0.635764F, 0.638855F, 0.642000F, 0.645200F,
0.648458F, 0.651772F, 0.655146F, 0.658580F, 0.662075F, 0.665633F, 0.669254F, 0.672940F,
0.676693F, 0.680514F, 0.684404F, 0.688365F, 0.692398F, 0.696505F, 0.700688F, 0.704947F,
0.709286F, 0.713706F, 0.718208F, 0.722795F, 0.727468F, 0.732230F, 0.737083F, 0.742028F,
0.747069F, 0.752207F, 0.757445F, 0.762785F, 0.768230F, 0.773783F, 0.779446F, 0.785223F,
0.791116F, 0.797128F, 0.803263F, 0.809523F, 0.815913F, 0.822436F, 0.829096F, 0.835896F,
0.842840F, 0.849933F, 0.857179F, 0.864583F, 0.872148F, 0.879881F, 0.887785F, 0.895867F,
0.904132F, 0.912585F, 0.921233F, 0.930082F, 0.939138F, 0.948408F, 0.957900F, 0.967620F,
0.977577F, 0.987778F, 0.998232F, 1.008949F, 1.019937F, 1.031206F, 1.042766F, 1.054629F,
1.066806F, 1.079308F, 1.092148F, 1.105340F, 1.118897F, 1.132833F, 1.147165F, 1.161909F,
1.177081F, 1.192700F, 1.208786F, 1.225358F, 1.242438F, 1.260049F, 1.278215F, 1.296963F,
1.316319F, 1.336312F, 1.356974F, 1.378338F, 1.400439F, 1.423314F, 1.447005F, 1.471554F,
1.497008F, 1.523416F, 1.550832F, 1.579313F, 1.608922F, 1.639725F, 1.671794F, 1.705209F,
1.740054F, 1.776420F, 1.814409F, 1.854130F, 1.895701F, 1.939254F, 1.984932F, 2.032892F,
2.083307F, 2.136369F, 2.192289F, 2.251303F, 2.313671F, 2.379685F, 2.449672F, 2.523998F,
2.603077F, 2.687375F, 2.777424F, 2.873830F, 2.977284F, 3.088586F, 3.208658F, 3.338574F,
3.479591F, 3.633190F, 3.801124F, 3.985493F, 4.188825F, 4.414194F, 4.665379F, 4.947073F,
5.265181F, 5.627237F, 6.043007F, 6.525382F, 7.091739F, 7.766070F, 8.582473F, 9.591092F,
10.868813F, 12.539837F, 14.818691F, 18.110597F, 23.283884F, 32.596211F, 54.325654F, 162.974915F,
0.500009F, 0.500085F, 0.500235F, 0.500462F, 0.500763F, 0.501141F, 0.501595F, 0.502125F,
0.502733F, 0.503417F, 0.504180F, 0.505021F, 0.505941F, 0.506941F, 0.508022F, 0.509184F,
0.510428F, 0.511756F, 0.513168F, 0.514666F, 0.516250F, 0.517923F, 0.519685F, 0.521538F,
0.523483F, 0.525522F, 0.527657F, 0.529889F, 0.532221F, 0.534654F, 0.537191F, 0.539834F,
0.542585F, 0.545447F, 0.548422F, 0.551514F, 0.554724F, 0.558057F, 0.561515F, 0.565101F,
0.568820F, 0.572675F, 0.576671F, 0.580810F, 0.585098F, 0.589539F, 0.594138F, 0.598901F,
0.603832F, 0.608937F, 0.614223F, 0.619696F, 0.625362F, 0.631228F, 0.637303F, 0.643593F,
0.650108F, 0.656856F, 0.663846F, 0.671089F, 0.678595F, 0.686375F, 0.694442F, 0.702808F,
0.711486F, 0.720491F, 0.729838F, 0.739544F, 0.749625F, 0.760102F, 0.770993F, 0.782320F,
0.794107F, 0.806377F, 0.819158F, 0.832478F, 0.846368F, 0.860861F, 0.875993F, 0.891804F,
0.908335F, 0.925632F, 0.943746F, 0.962731F, 0.982646F, 1.003557F, 1.025536F, 1.048659F,
1.073015F, 1.098699F, 1.125816F, 1.154484F, 1.184833F, 1.217009F, 1.251175F, 1.287515F,
1.326234F, 1.367566F, 1.411777F, 1.459169F, 1.510089F, 1.564935F, 1.624170F, 1.688329F,
1.758041F, 1.834046F, 1.917221F, 2.008616F, 2.109495F, 2.221394F, 2.346203F, 2.486268F,
2.644542F, 2.824791F, 3.031899F, 3.272312F, 3.554715F, 3.891108F, 4.298538F, 4.802076F,
5.440166F, 6.274908F, 7.413567F, 9.058751F, 11.644627F, 16.300023F, 27.163978F, 81.487842F,
0.500038F, 0.500339F, 0.500943F, 0.501851F, 0.503065F, 0.504590F, 0.506431F, 0.508592F,
0.511082F, 0.513906F, 0.517076F, 0.520600F, 0.524491F, 0.528761F, 0.533425F, 0.538499F,
0.544002F, 0.549953F, 0.556375F, 0.563292F, 0.570731F, 0.578722F, 0.587299F, 0.596499F,
0.606362F, 0.616936F, 0.628269F, 0.640420F, 0.653452F, 0.667435F, 0.682450F, 0.698587F,
0.715946F, 0.734645F, 0.754813F, 0.776601F, 0.800180F, 0.825749F, 0.853537F, 0.883811F,
0.916884F, 0.953126F, 0.992973F, 1.036949F, 1.085685F, 1.139949F, 1.200683F, 1.269061F,
1.346558F, 1.435055F, 1.536994F, 1.655597F, 1.795205F, 1.961818F, 2.163958F, 2.414160F,
2.731645F, 3.147462F, 3.715243F, 4.536291F, 5.827688F, 8.153849F, 13.584290F, 40.744688F,
0.500151F, 0.501358F, 0.503789F, 0.507471F, 0.512451F, 0.518793F, 0.526577F, 0.535910F,
0.546920F, 0.559770F, 0.574655F, 0.591819F, 0.611557F, 0.634239F, 0.660320F, 0.690372F,
0.725121F, 0.765494F, 0.812702F, 0.868345F, 0.934584F, 1.014408F, 1.112072F, 1.233833F,
1.389294F, 1.593972F, 1.874676F, 2.282050F, 2.924628F, 4.084611F, 6.796751F, 20.373878F,
0.500603F, 0.505471F, 0.515447F, 0.531043F, 0.553104F, 0.582935F, 0.622504F, 0.674808F,
0.744536F, 0.839350F, 0.972568F, 1.169440F, 1.484165F, 2.057781F, 3.407608F, 10.190008F,
0.502419F, 0.522499F, 0.566944F, 0.646822F, 0.788155F, 1.060678F, 1.722447F, 5.101149F,
0.509796F, 0.601345F, 0.899976F, 2.562915F, 0.541196F, 1.306563F, 0.707107F, 0.000000F
} ;
static const float CosTable_256 [256] =
{
0.500009F, 0.500085F, 0.500235F, 0.500462F, 0.500763F, 0.501141F, 0.501595F, 0.502125F,
0.502733F, 0.503417F, 0.504180F, 0.505021F, 0.505941F, 0.506941F, 0.508022F, 0.509184F,
0.510428F, 0.511756F, 0.513168F, 0.514666F, 0.516250F, 0.517923F, 0.519685F, 0.521538F,
0.523483F, 0.525522F, 0.527657F, 0.529889F, 0.532221F, 0.534654F, 0.537191F, 0.539834F,
0.542585F, 0.545447F, 0.548422F, 0.551514F, 0.554724F, 0.558057F, 0.561515F, 0.565101F,
0.568820F, 0.572675F, 0.576671F, 0.580810F, 0.585098F, 0.589539F, 0.594138F, 0.598901F,
0.603832F, 0.608937F, 0.614223F, 0.619696F, 0.625362F, 0.631228F, 0.637303F, 0.643593F,
0.650108F, 0.656856F, 0.663846F, 0.671089F, 0.678595F, 0.686375F, 0.694442F, 0.702808F,
0.711486F, 0.720491F, 0.729838F, 0.739544F, 0.749625F, 0.760102F, 0.770993F, 0.782320F,
0.794107F, 0.806377F, 0.819158F, 0.832478F, 0.846368F, 0.860861F, 0.875993F, 0.891804F,
0.908335F, 0.925632F, 0.943746F, 0.962731F, 0.982646F, 1.003557F, 1.025536F, 1.048659F,
1.073015F, 1.098699F, 1.125816F, 1.154484F, 1.184833F, 1.217009F, 1.251175F, 1.287515F,
1.326234F, 1.367566F, 1.411777F, 1.459169F, 1.510089F, 1.564935F, 1.624170F, 1.688329F,
1.758041F, 1.834046F, 1.917221F, 2.008616F, 2.109495F, 2.221394F, 2.346203F, 2.486268F,
2.644542F, 2.824791F, 3.031899F, 3.272312F, 3.554715F, 3.891108F, 4.298538F, 4.802076F,
5.440166F, 6.274908F, 7.413567F, 9.058751F, 11.644627F, 16.300023F, 27.163978F, 81.487842F,
0.500038F, 0.500339F, 0.500943F, 0.501851F, 0.503065F, 0.504590F, 0.506431F, 0.508592F,
0.511082F, 0.513906F, 0.517076F, 0.520600F, 0.524491F, 0.528761F, 0.533425F, 0.538499F,
0.544002F, 0.549953F, 0.556375F, 0.563292F, 0.570731F, 0.578722F, 0.587299F, 0.596499F,
0.606362F, 0.616936F, 0.628269F, 0.640420F, 0.653452F, 0.667435F, 0.682450F, 0.698587F,
0.715946F, 0.734645F, 0.754813F, 0.776601F, 0.800180F, 0.825749F, 0.853537F, 0.883811F,
0.916884F, 0.953126F, 0.992973F, 1.036949F, 1.085685F, 1.139949F, 1.200683F, 1.269061F,
1.346558F, 1.435055F, 1.536994F, 1.655597F, 1.795205F, 1.961818F, 2.163958F, 2.414160F,
2.731645F, 3.147462F, 3.715243F, 4.536291F, 5.827688F, 8.153849F, 13.584290F, 40.744688F,
0.500151F, 0.501358F, 0.503789F, 0.507471F, 0.512451F, 0.518793F, 0.526577F, 0.535910F,
0.546920F, 0.559770F, 0.574655F, 0.591819F, 0.611557F, 0.634239F, 0.660320F, 0.690372F,
0.725121F, 0.765494F, 0.812702F, 0.868345F, 0.934584F, 1.014408F, 1.112072F, 1.233833F,
1.389294F, 1.593972F, 1.874676F, 2.282050F, 2.924628F, 4.084611F, 6.796751F, 20.373878F,
0.500603F, 0.505471F, 0.515447F, 0.531043F, 0.553104F, 0.582935F, 0.622504F, 0.674808F,
0.744536F, 0.839350F, 0.972568F, 1.169440F, 1.484165F, 2.057781F, 3.407608F, 10.190008F,
0.502419F, 0.522499F, 0.566944F, 0.646822F, 0.788155F, 1.060678F, 1.722447F, 5.101149F,
0.509796F, 0.601345F, 0.899976F, 2.562915F, 0.541196F, 1.306563F, 0.707107F, 0.000000F
} ;
void CBlock::Dct16 (float vec [], const float cosTerms [])
{
float tmp_e0, tmp_e1, tmp_e2, tmp_e3, tmp_e4, tmp_e5, tmp_e6, tmp_e7 ;
float tmp_o0, tmp_o1, tmp_o2, tmp_o3, tmp_o4, tmp_o5, tmp_o6, tmp_o7 ;
tmp_e0 = vec [0] + vec [15] ;
tmp_e1 = vec [1] + vec [14] ;
tmp_e2 = vec [2] + vec [13] ;
tmp_e3 = vec [3] + vec [12] ;
tmp_e4 = vec [4] + vec [11] ;
tmp_e5 = vec [5] + vec [10] ;
tmp_e6 = vec [6] + vec [9] ;
tmp_e7 = vec [7] + vec [8] ;
tmp_o0 = (vec [0] - vec [15]) * cosTerms [0] ;
tmp_o1 = (vec [1] - vec [14]) * cosTerms [1] ;
tmp_o2 = (vec [2] - vec [13]) * cosTerms [2] ;
tmp_o3 = (vec [3] - vec [12]) * cosTerms [3] ;
tmp_o4 = (vec [4] - vec [11]) * cosTerms [4] ;
tmp_o5 = (vec [5] - vec [10]) * cosTerms [5] ;
tmp_o6 = (vec [6] - vec [9]) * cosTerms [6] ;
tmp_o7 = (vec [7] - vec [8]) * cosTerms [7] ;
// dct8 (tmp_e, cosTerms + 8) ;
float itmp_e0, itmp_e1, itmp_e2, itmp_e3 ;
float itmp_o0, itmp_o1, itmp_o2, itmp_o3 ;
itmp_e0 = tmp_e0 + tmp_e7 ;
itmp_e1 = tmp_e1 + tmp_e6 ;
itmp_e2 = tmp_e2 + tmp_e5 ;
itmp_e3 = tmp_e3 + tmp_e4 ;
itmp_o0 = (tmp_e0 - tmp_e7) * cosTerms [8] ;
itmp_o1 = (tmp_e1 - tmp_e6) * cosTerms [9] ;
itmp_o2 = (tmp_e2 - tmp_e5) * cosTerms [10] ;
itmp_o3 = (tmp_e3 - tmp_e4) * cosTerms [11] ;
float cosTerms12 = cosTerms [12] ;
float cosTerms13 = cosTerms [13] ;
float cosTerms14 = cosTerms [14] ;
// even part
float tmp0, tmp1, tmp2, tmp3 ;
tmp0 = itmp_e0 + itmp_e3 ;
tmp1 = (itmp_e0 - itmp_e3) * cosTerms12 ;
tmp2 = itmp_e1 + itmp_e2 ;
tmp3 = (itmp_e1 - itmp_e2) * cosTerms13 ;
vec [0] = tmp0 + tmp2 ;
vec [4] = tmp1 + tmp3;
vec [12] = (tmp1 - tmp3) * cosTerms14 ;
vec [8] = (tmp0 - tmp2) * cosTerms14 ;
vec [4] += vec [12] ;
// odd part
tmp0 = itmp_o0 + itmp_o3 ;
tmp2 = itmp_o1 + itmp_o2 ;
tmp1 = (itmp_o0 - itmp_o3) * cosTerms12 ;
tmp3 = (itmp_o1 - itmp_o2) * cosTerms13 ;
itmp_o0 = tmp0 + tmp2 ;
itmp_o1 = tmp1 + tmp3;
itmp_o3 = (tmp1 - tmp3) * cosTerms14 ;
itmp_o2 = (tmp0 - tmp2) * cosTerms14 ;
itmp_o1 += itmp_o3 ;
vec [2] = itmp_o0 + itmp_o1 ;
vec [6] = itmp_o1 + itmp_o2 ;
vec [10] = itmp_o2 + itmp_o3 ;
vec [14] = itmp_o3 ;
// dct8 (tmp_o, cosTerms + 8) ;
itmp_e0 = tmp_o0 + tmp_o7 ;
itmp_e1 = tmp_o1 + tmp_o6 ;
itmp_e2 = tmp_o2 + tmp_o5 ;
itmp_e3 = tmp_o3 + tmp_o4 ;
itmp_o0 = (tmp_o0 - tmp_o7) * cosTerms [8] ;
itmp_o1 = (tmp_o1 - tmp_o6) * cosTerms [9] ;
itmp_o2 = (tmp_o2 - tmp_o5) * cosTerms [10] ;
itmp_o3 = (tmp_o3 - tmp_o4) * cosTerms [11] ;
// even part
tmp0 = itmp_e0 + itmp_e3 ;
tmp1 = (itmp_e0 - itmp_e3) * cosTerms12 ;
tmp2 = itmp_e1 + itmp_e2 ;
tmp3 = (itmp_e1 - itmp_e2) * cosTerms13 ;
tmp_o0 = tmp0 + tmp2 ;
tmp_o2 = tmp1 + tmp3;
tmp_o6 = (tmp1 - tmp3) * cosTerms14 ;
tmp_o4 = (tmp0 - tmp2) * cosTerms14 ;
tmp_o2 += tmp_o6 ;
// odd part
tmp0 = itmp_o0 + itmp_o3 ;
tmp2 = itmp_o1 + itmp_o2 ;
tmp1 = (itmp_o0 - itmp_o3) * cosTerms12 ;
tmp3 = (itmp_o1 - itmp_o2) * cosTerms13 ;
itmp_o0 = tmp0 + tmp2 ;
itmp_o1 = tmp1 + tmp3;
itmp_o3 = (tmp1 - tmp3) * cosTerms14 ;
itmp_o2 = (tmp0 - tmp2) * cosTerms14 ;
itmp_o1 += itmp_o3 ;
tmp_o1 = itmp_o0 + itmp_o1 ;
tmp_o3 = itmp_o1 + itmp_o2 ;
tmp_o5 = itmp_o2 + itmp_o3 ;
vec [1] = tmp_o0 + tmp_o1 ;
vec [3] = tmp_o1 + tmp_o2 ;
vec [5] = tmp_o2 + tmp_o3 ;
vec [7] = tmp_o3 + tmp_o4 ;
vec [9] = tmp_o4 + tmp_o5 ;
vec [11] = tmp_o5 + tmp_o6 ;
vec [13] = tmp_o6 + itmp_o3 ;
vec [15] = itmp_o3 ;
}
void CBlock::Dct128 (float vec [], const float cosTerms [])
{
float tmp_e4 [64], tmp_o4 [64] ;
float tmp_e5 [32], tmp_o5 [32] ;
float tmp_e6 [16], tmp_o6 [16] ;
Split (vec, tmp_e4, tmp_o4, cosTerms, 128) ;
Split (tmp_e4, tmp_e5, tmp_o5, cosTerms + 64, 64) ;
Split (tmp_e5, tmp_e6, tmp_o6, cosTerms + 96, 32) ;
Dct16 (tmp_e6, cosTerms + 112) ; // Even Terms
Dct16 (tmp_o6, cosTerms + 112) ; // Odd Terms
Merge (tmp_e5, tmp_e6, tmp_o6, 32) ;
Split (tmp_o5, tmp_e6, tmp_o6, cosTerms + 96, 32) ;
Dct16 (tmp_e6, cosTerms + 112) ; // Even Terms
Dct16 (tmp_o6, cosTerms + 112) ; // Odd Terms
Merge (tmp_o5, tmp_e6, tmp_o6, 32) ;
Merge (tmp_e4, tmp_e5, tmp_o5, 64) ;
Split (tmp_o4, tmp_e5, tmp_o5, cosTerms + 64, 64) ;
Split (tmp_e5, tmp_e6, tmp_o6, cosTerms + 96, 32) ;
Dct16 (tmp_e6, cosTerms + 112) ; // Even Terms
Dct16 (tmp_o6, cosTerms + 112) ; // Odd Terms
Merge (tmp_e5, tmp_e6, tmp_o6, 32) ;
Split (tmp_o5, tmp_e6, tmp_o6, cosTerms + 96, 32) ;
Dct16 (tmp_e6, cosTerms + 112) ; // Even Terms
Dct16 (tmp_o6, cosTerms + 112) ; // Odd Terms
Merge (tmp_o5, tmp_e6, tmp_o6, 32) ;
Merge (tmp_o4, tmp_e5, tmp_o5, 64) ;
Merge (vec, tmp_e4, tmp_o4, 128) ;
}
void CBlock::Dct1024 (float vec [], const float cosTerms [])
{
float tmp_e0 [512], tmp_o0 [512] ;
float tmp_e1 [256], tmp_o1 [256] ;
float tmp_e2 [128], tmp_o2 [128] ;
Split (vec, tmp_e0, tmp_o0, cosTerms, 1024) ;
Split (tmp_e0, tmp_e1, tmp_o1, cosTerms + 512, 512) ;
Split (tmp_e1, tmp_e2, tmp_o2, cosTerms + 768, 256) ;
Dct128 (tmp_e2, cosTerms + 896) ; // Even Terms
Dct128 (tmp_o2, cosTerms + 896) ; // Odd Terms
Merge (tmp_e1, tmp_e2, tmp_o2, 256) ;
Split (tmp_o1, tmp_e2, tmp_o2, cosTerms + 768, 256) ;
Dct128 (tmp_e2, cosTerms + 896) ; // Even Terms
Dct128 (tmp_o2, cosTerms + 896) ; // Odd Terms
Merge (tmp_o1, tmp_e2, tmp_o2, 256) ;
Merge (tmp_e0, tmp_e1, tmp_o1, 512) ;
Split (tmp_o0, tmp_e1, tmp_o1, cosTerms + 512, 512) ;
Split (tmp_e1, tmp_e2, tmp_o2, cosTerms + 768, 256) ;
Dct128 (tmp_e2, cosTerms + 896) ; // Even Terms
Dct128 (tmp_o2, cosTerms + 896) ; // Odd Terms
Merge (tmp_e1, tmp_e2, tmp_o2, 256) ;
Split (tmp_o1, tmp_e2, tmp_o2, cosTerms + 768, 256) ;
Dct128 (tmp_e2, cosTerms + 896) ; // Even Terms
Dct128 (tmp_o2, cosTerms + 896) ; // Odd Terms
Merge (tmp_o1, tmp_e2, tmp_o2, 256) ;
Merge (tmp_o0, tmp_e1, tmp_o1, 512) ;
Merge (vec, tmp_e0, tmp_o0, 1024) ;
}
void CLongBlock::InverseTransform (float data [])
{
const int N = 2048 ;
float tmp_out [N / 2] ;
int i ;
for (i = 0 ; i < N / 2 ; i++)
{
tmp_out [i] = (data [i] * (2.0F / N))* CosTable_2048 [i] ;
}
Dct1024 (tmp_out, &CosTable_2048 [N / 2]) ;
for (i = 0 ; i < N / 2 - 1 ; i++)
{
tmp_out [i] += tmp_out [i + 1] ;
}
for (i = 0 ; i < N / 4 ; i++)
{
data [i] = tmp_out [N / 4 + i] ;
data [N / 2 - i - 1] = -tmp_out [N / 4 + i] ;
data [N / 2 + N / 4 + i] = -tmp_out [i] ;
data [N / 2 + N / 4 - i - 1] = -tmp_out [i] ;
}
}
void CShortBlock::InverseTransform (float data [])
{
const int N = 256 ;
float tmp_out [N / 2] ;
int i ;
for (i = 0 ; i < N / 2 ; i++)
{
tmp_out [i] = (data [i] * (2.0F / N)) * CosTable_256 [i] ;
}
Dct128 (tmp_out, &CosTable_256 [N / 2]) ;
for (i = 0 ; i < N / 2 - 1 ; i++)
{
tmp_out [i] += tmp_out [i + 1] ;
}
for (i = 0 ; i < N / 4 ; i++)
{
data [i] = tmp_out [N / 4 + i] ;
data [N / 2 - i - 1] = -tmp_out [N / 4 + i] ;
data [N / 2 + N / 4 + i] = -tmp_out [i] ;
data [N / 2 + N / 4 - i -1] = -tmp_out [i] ;
}
}
#if defined (WIN32) && defined (_M_IX86)
#pragma message (__FILE__": using x86 inline assembler")
void CBlock::Split (const float vector [], float tmp_e [], float tmp_o [], const float cosTerms [], int vecsize)
{
// tmp_e [i] = t0 + t1 ;
// tmp_o [i] = (t0 - t1) * cosTerms [i] ;
_asm
{
mov ecx, vecsize
shr ecx, 1
mov esi, dword ptr [vector]
mov edi, dword ptr [cosTerms]
mov eax, dword ptr [tmp_e]
mov ebx, dword ptr [tmp_o]
mov edx, dword ptr [vecsize]
shl edx, 2
add edx, esi
fldz
label :
fld dword ptr [esi]
fld dword ptr [esi]
fsub dword ptr [edx-4]
fxch st(1)
fadd dword ptr [edx-4]
fxch st(2)
fld dword ptr [esi+4]
fld dword ptr [esi+4]
fsub dword ptr [edx-8]
fxch st(1)
fadd dword ptr [edx-8]
fxch st(3)
fmul dword ptr [edi]
fxch st(4)
fstp dword ptr [eax]
fmul dword ptr [edi+4]
fxch st(2)
fstp dword ptr [eax+4]
fxch st(2)
fstp dword ptr [ebx]
add esi, 8
add edi, 8
fstp dword ptr [ebx+4]
// // //
fld dword ptr [esi]
fld dword ptr [esi]
fsub dword ptr [edx-12]
fxch st(1)
fadd dword ptr [edx-12]
fxch st(2)
fld dword ptr [esi+4]
fld dword ptr [esi+4]
fsub dword ptr [edx-16]
fxch st(1)
fadd dword ptr [edx-16]
fxch st(3)
fmul dword ptr [edi]
fxch st(4)
fstp dword ptr [eax+8]
fmul dword ptr [edi+4]
fxch st(2)
fstp dword ptr [eax+12]
fxch st(2)
fstp dword ptr [ebx+8]
add esi, 8
add edi, 8
fstp dword ptr [ebx+12]
// // //
sub edx, 16
add eax, 16
add ebx, 16
sub ecx, 4
jne label
fstp st(0)
}
}
void CBlock::Merge (float vector [], const float tmp_e [], const float tmp_o [], int vecsize)
{
__asm
{
mov ecx, vecsize
shr ecx, 1
sub ecx, 8
mov edx, dword ptr [tmp_o]
mov edi, dword ptr [tmp_e]
mov esi, dword ptr [vector]
label :
fld dword ptr [edx + ecx*4]
fadd dword ptr [edx + ecx*4 + 4]
fld dword ptr [edx + ecx*4 + 4]
fadd dword ptr [edx + ecx*4 + 8]
fld dword ptr [edx + ecx*4 + 8]
fadd dword ptr [edx + ecx*4 + 12]
fld dword ptr [edx + ecx*4 + 12]
fadd dword ptr [edx + ecx*4 + 16]
fxch st(3)
fstp dword ptr [esi + ecx*8 + 4]
mov eax, dword ptr [edi + ecx*4]
mov ebx, dword ptr [edi + ecx*4 + 4]
fstp dword ptr [esi + ecx*8 + 20]
mov dword ptr [esi + ecx*8], eax
mov dword ptr [esi + ecx*8 + 8], ebx
fstp dword ptr [esi + ecx*8 + 12]
mov eax, dword ptr [edi + ecx*4 + 8]
mov ebx, dword ptr [edi + ecx*4 + 12]
fstp dword ptr [esi + ecx*8 + 28]
mov dword ptr [esi + ecx*8 + 16], eax
mov dword ptr [esi + ecx*8 + 24], ebx
fld dword ptr [edx + ecx*4 + 16]
fadd dword ptr [edx + ecx*4 + 20]
fld dword ptr [edx + ecx*4 + 20]
fadd dword ptr [edx + ecx*4 + 24]
fld dword ptr [edx + ecx*4 + 24]
fadd dword ptr [edx + ecx*4 + 28]
fld dword ptr [edx + ecx*4 + 28]
fadd dword ptr [edx + ecx*4 + 32]
fxch st(3)
fstp dword ptr [esi + ecx*8 + 36]
mov eax, dword ptr [edi + ecx*4 + 16]
mov ebx, dword ptr [edi + ecx*4 + 20]
fstp dword ptr [esi + ecx*8 + 52]
mov dword ptr [esi + ecx*8 + 32], eax
mov dword ptr [esi + ecx*8 + 40], ebx
fstp dword ptr [esi + ecx*8 + 44]
mov eax, dword ptr [edi + ecx*4 + 24]
mov ebx, dword ptr [edi + ecx*4 + 28]
fstp dword ptr [esi + ecx*8 + 60]
mov dword ptr [esi + ecx*8 + 48], eax
mov dword ptr [esi + ecx*8 + 56], ebx
sub ecx, 8
jne label
// zero element
fld dword ptr [edx]
fadd dword ptr [edx + 4]
fld dword ptr [edx + 4]
fadd dword ptr [edx + 8]
fld dword ptr [edx + 8]
fadd dword ptr [edx + 12]
fld dword ptr [edx + 12]
fadd dword ptr [edx + 16]
fxch st(3)
fstp dword ptr [esi + 4]
mov eax, dword ptr [edi]
mov ebx, dword ptr [edi + 4]
fstp dword ptr [esi + 20]
mov dword ptr [esi], eax
mov dword ptr [esi + 8], ebx
fstp dword ptr [esi + 12]
mov eax, dword ptr [edi + 8]
mov ebx, dword ptr [edi + 12]
fstp dword ptr [esi + 28]
mov dword ptr [esi + 16], eax
mov dword ptr [esi + 24], ebx
fld dword ptr [edx + 16]
fadd dword ptr [edx + 20]
fld dword ptr [edx + 20]
fadd dword ptr [edx + 24]
fld dword ptr [edx + 24]
fadd dword ptr [edx + 28]
fld dword ptr [edx + 28]
fadd dword ptr [edx + 32]
fxch st(3)
fstp dword ptr [esi + 36]
mov eax, dword ptr [edi + 16]
mov ebx, dword ptr [edi + 20]
fstp dword ptr [esi + 52]
mov dword ptr [esi + 32], eax
mov dword ptr [esi + 40], ebx
fstp dword ptr [esi + 44]
mov eax, dword ptr [edi + 24]
mov ebx, dword ptr [edi + 28]
fstp dword ptr [esi + 60]
mov dword ptr [esi + 48], eax
mov dword ptr [esi + 56], ebx
}
vector [vecsize - 2] = tmp_e [vecsize / 2 - 1] ;
vector [vecsize - 1] = tmp_o [vecsize / 2 - 1] ;
}
#else
void CBlock::Split (const float vector [], float tmp_e [], float tmp_o [], const float cosTerms [], int vecsize)
{
for (int i = 0 ; i < vecsize / 2 ; i++)
{
tmp_e [i] = vector [i] + vector [vecsize - i - 1] ;
tmp_o [i] = (vector [i] - vector [vecsize - i - 1]) * cosTerms [i] ;
}
}
void CBlock::Merge (float vector [], const float tmp_e [], const float tmp_o [], int vecsize)
{
for (int i = 0 ; i < vecsize / 2 - 1 ; i++)
{
vector [i * 2] = tmp_e [i] ;
vector [i * 2 + 1] = tmp_o [i] + tmp_o [i + 1] ;
}
vector [vecsize - 2] = tmp_e [vecsize / 2 - 1] ;
vector [vecsize - 1] = tmp_o [vecsize / 2 - 1] ;
}
#endif

View File

@ -1,512 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/longblock.cpp,v 1.2 2011/06/13 02:06:03 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: longblock.cpp
* project : MPEG-2 AAC Decoder
* contents/description: long window sequence object
*
* $Header: /cvs/root/winamp/vlb/longblock.cpp,v 1.2 2011/06/13 02:06:03 audiodsp Exp $
*
\***************************************************************************/
#include <math.h> // pow()
#include "block.h"
#include "bitstream.h"
#include "channelinfo.h"
#include "overlapadd.h"
#ifdef MAIN_PROFILE
#include "prediction.h"
#endif
// ctor/dtor
CLongBlock::CLongBlock (CChannelInfo &info)
: CBlock (info)
{
m_SectBits = 5 ;
}
CLongBlock::~CLongBlock ()
{
}
// low-level access
float *CLongBlock::AccessSpectralData (int /* window = 0 */)
{
return m_SpectralCoefficient ;
}
int *CLongBlock::AccessCodeBooks (int /* group */)
{
return m_CodeBook ;
}
int *CLongBlock::AccessScaleFactors (int /* group */)
{
return m_ScaleFactor ;
}
// readers
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void CLongBlock::ReadSectionData (CDolbyBitStream &bs)
{
CVLBBitSequence sect_cb (4) ;
CVLBBitSequence sect_len_incr (m_SectBits) ;
int sect_esc_val = (1 << m_SectBits) - 1 ;
int band ; // msdev not ansi
//Section Information:
int iNumberOfSections;
iNumberOfSections=0;
sSectionInfoStruct.aiSectionCount[0]=0;
sSectionInfoStruct.aaiSectionStart[0][0]=0;
for (band = 0 ; band < m_IcsInfo.GetScaleFactorBandsTransmitted () ; )
{
sect_cb.Read (bs) ;
sect_len_incr.Read (bs) ;
int sect_len = 0 ;
while (sect_len_incr == sect_esc_val)
{
sect_len += sect_esc_val ;
sect_len_incr.Read (bs) ;
}
sect_len += sect_len_incr ;
for (int top = band + sect_len ; band < top ; band++)
{
m_CodeBook [band] = sect_cb ;
if ((m_CodeBook [band] == BOOKSCL) ||
(m_CodeBook [band] == RESERVED_HCB)
)
{
throw EInvalidCodeBook () ;
}
}
sSectionInfoStruct.aaiSectionCodebooks[0][iNumberOfSections]=sect_cb;
sSectionInfoStruct.aaiSectionStart[0][iNumberOfSections+1]=band;
sSectionInfoStruct.aaiSectionEnd[0][iNumberOfSections]=band;
sSectionInfoStruct.aiSectionCount[0]++;
iNumberOfSections++;
}
if(band < m_IcsInfo.GetScaleFactorBandsTotal() && m_IcsInfo.GetScaleFactorBandsTransmitted()){
sSectionInfoStruct.aaiSectionCodebooks[0][iNumberOfSections]=ZERO_HCB;
sSectionInfoStruct.aaiSectionEnd[0][iNumberOfSections]= m_IcsInfo.GetScaleFactorBandsTotal ();
sSectionInfoStruct.aiSectionCount[0]++;
iNumberOfSections++;
}
for ( ; band < m_IcsInfo.GetScaleFactorBandsTotal () ; band++)
{
m_CodeBook [band] = ZERO_HCB ;
}
}
void CLongBlock::ReadScaleFactorData (CDolbyBitStream &bs, const int global_gain)
{
const CodeBookDescription *hcb = &HuffmanCodeBooks [BOOKSCL] ;
int factor = global_gain ;
int position = 0 ;
int temp ;
for (int band = 0 ; band < m_IcsInfo.GetScaleFactorBandsTransmitted () ; band++)
{
switch (m_CodeBook [band])
{
case ZERO_HCB : // zero book
m_ScaleFactor [band] = 0 ;
break ;
default : // regular scale factor
temp = DecodeHuffmanWord (bs, hcb->CodeBook) ;
factor += temp - 60 ; // MIDFAC 1.5 dB
m_ScaleFactor [band] = factor - 100 ;
break ;
case INTENSITY_HCB : // intensity steering
case INTENSITY_HCB2 :
temp = DecodeHuffmanWord (bs, hcb->CodeBook) ;
position += temp - 60 ;
m_ScaleFactor [band] = position - 100 ;
#ifdef MAIN_PROFILE
// use of intensity stereo overrides prediction_used mask
m_IcsInfo.DeactivatePrediction (band) ;
#endif
break ;
}
}
}
void CLongBlock::ReadSpectralData (CDolbyBitStream &bs)
{
int QuantizedCoef [MaximumBins] ;
int index, band ; // msdev for scoping not ansi
for (index = 0 ; index < MaximumBins ; index++)
{
QuantizedCoef [index] = 0 ;
}
const int *BandOffsets = m_IcsInfo.GetScaleFactorBandOffsets () ;
for (band = 0 ; band < m_IcsInfo.GetScaleFactorBandsTransmitted () ; band++)
{
if ((m_CodeBook [band] == ZERO_HCB) ||
(m_CodeBook [band] == INTENSITY_HCB) ||
(m_CodeBook [band] == INTENSITY_HCB2)
)
continue ;
const CodeBookDescription *hcb = &HuffmanCodeBooks [m_CodeBook [band]] ;
int step = 0 ;
for (index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index += step)
{
step = UnpackIndex (DecodeHuffmanWord (bs, hcb->CodeBook), &QuantizedCoef [index], hcb) ;
if (!hcb->IsSigned)
{
for (int i = 0 ; i < step ; i++)
{
if (QuantizedCoef [index + i])
{
if (bs.Get (1)) // sign bit
{
QuantizedCoef [index + i] = -QuantizedCoef [index + i] ;
}
}
}
}
if (m_CodeBook [band] == ESCBOOK)
{
QuantizedCoef [index] = GetEscape (bs, QuantizedCoef [index]) ;
QuantizedCoef [index + 1] = GetEscape (bs, QuantizedCoef [index + 1]) ;
}
}
}
m_PulseData.Apply (m_IcsInfo, QuantizedCoef) ;
// dequantize and apply scalefactors
for (index = 0, band = 0 ; band < m_IcsInfo.GetScaleFactorBandsTransmitted () ; band++)
{
float factor = static_cast<float>(m_ScaleFactor [band]) ;
if ((factor >= 0) && (factor < ExpTableSize))
{
factor = m_ExpTable [m_ScaleFactor [band]] ;
}
else
{
if (m_ScaleFactor [band] == -100)
{
for (index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index++)
{
m_SpectralCoefficient [index] = 0.0F ;
}
continue ;
}
factor = static_cast<float>(pow (2.0F, 0.25F * factor)) ;
}
for (index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index++)
{
m_SpectralCoefficient [index] = InverseQuantize (QuantizedCoef [index]) * factor ;
}
}
// zero out spectral data beyond max_sfb
// index is now first bin of max_sfb+1
for ( ; index < MaximumBins ; index++)
{
m_SpectralCoefficient [index] = 0.0F ;
}
}
void CLongBlock::ApplyWindowFunction (COverlapAddBuffer &Previous)
{
int i ;
switch (m_IcsInfo.GetWindowSequence ())
{
case CChannelInfo::OnlyLongSequence :
#if defined (WIN32) && defined (_M_IX86)
PentiumWindow (m_SpectralCoefficient, m_LongWindow [Previous.GetWindowShape ()], m_LongWindow [m_IcsInfo.GetWindowShape ()]) ;
#else
for (i = 0 ; i < 1024 ; i++)
{
m_SpectralCoefficient [i] *= m_LongWindow [Previous.GetWindowShape ()][i] ;
m_SpectralCoefficient [1024 + i] *= m_LongWindow [m_IcsInfo.GetWindowShape ()][1023 - i] ;
}
#endif
break ;
case CChannelInfo::LongStartSequence :
for (i = 0 ; i < 1024 ; i++)
{
m_SpectralCoefficient [i] *= m_LongWindow [Previous.GetWindowShape ()][i] ;
}
for (i = 0 ; i < 128 ; i++)
{
m_SpectralCoefficient [1472 + i] *= m_ShortWindow [m_IcsInfo.GetWindowShape ()][127 - i] ;
}
for (i = 1600 ; i < 2048 ; i++)
{
m_SpectralCoefficient [i] = 0.0F ;
}
break ;
case CChannelInfo::LongStopSequence :
for (i = 0 ; i < 448 ; i++)
{
m_SpectralCoefficient [i] = 0.0F ;
}
for (i = 0 ; i < 128 ; i++)
{
m_SpectralCoefficient [448 + i] *= m_ShortWindow [Previous.GetWindowShape ()][i] ;
}
for (i = 0 ; i < 1024 ; i++)
{
m_SpectralCoefficient [1024 + i] *= m_LongWindow [m_IcsInfo.GetWindowShape ()][1023 - i] ;
}
break ;
}
Previous.SetWindowShape (m_IcsInfo.GetWindowShape ()) ;
}
void CLongBlock::FrequencyToTime_Fast (COverlapAddBuffer &Previous)
{
InverseTransform (m_SpectralCoefficient) ;
ApplyWindowFunction (Previous) ;
#if defined (WIN32) && defined (_M_IX86)
PentiumOverlap (m_Output, m_SpectralCoefficient, Previous.AccessBuffer (), 1) ;
#else
for (int i = 0 ; i < 1024 ; i++)
{
// add first half and old data
m_Output[i] = m_SpectralCoefficient [i] + Previous [i] ;
// store second half as old data
Previous [i] = m_SpectralCoefficient [1024 + i] ;
}
#endif
}
void CLongBlock::FrequencyToTime (COverlapAddBuffer &Previous, float Output [], const int stride)
{
InverseTransform (m_SpectralCoefficient) ;
ApplyWindowFunction (Previous) ;
for (int i = 0 ; i < 1024 ; i++)
{
// add first half and old data
Output [i * stride] = m_SpectralCoefficient [i] + Previous [i] ;
// store second half as old data
Previous [i] = m_SpectralCoefficient [1024 + i] ;
}
}
void CLongBlock::FrequencyToTime (COverlapAddBuffer &Previous)
{
InverseTransform (m_SpectralCoefficient) ;
ApplyWindowFunction (Previous) ;
for (int i = 0 ; i < 1024 ; i++)
{
m_Output[i]=m_SpectralCoefficient [i] + Previous [i] ;
Previous [i] = m_SpectralCoefficient [1024 + i] ;
}
}
void CLongBlock::ApplyEqualizationMask (float Mask [])
{
for (int i = 0 ; i < EqualizationMaskLength ; i++)
{
for (int j = 0 ; j < (MaximumBins / EqualizationMaskLength) ; j++)
{
m_SpectralCoefficient [(MaximumBins / EqualizationMaskLength) * i + j] *= Mask [i] ;
}
}
}
#if defined (WIN32) && defined (_M_IX86)
#pragma message (__FILE__": using x86 inline assembler")
// this CBlock method goes here, because we'd prefer it to be inlined
// with CLongBlock. not all compilers support inter-module optimizations.
void CBlock::PentiumOverlap (float output [], float spec [], float prev [], unsigned int stride)
{
const float minval = -32767.0F ;
__asm
{
shl stride, 2 // stride *= sizeof(float)
mov esi, dword ptr [output] // esi is pcm output pointer
mov ebx, 0x00 // ebx is buffer index
mov edx, dword ptr [spec]
mov ecx, dword ptr [prev]
entry:
fld dword ptr [edx + ebx*4] // get: spec [i]
fadd dword ptr [ecx + ebx*4] // get: spec [i] + prev [i]
mov eax, dword ptr [edx + ebx*4 + 0x1000] // get: spec [1024 + i]
mov dword ptr [ecx + ebx*4],eax // put: prev [i] = spec [1024 + i]
fst dword ptr [esi] // put: output [i] = spec [i] + prev [i]
add esi, stride
fstp st(0)
inc ebx
cmp ebx, 1024
jne entry
}
}
void CLongBlock::PentiumWindow (float spec [], const float prev [], const float curr [])
{
__asm
{
mov ebx, 0x0100
mov edx, dword ptr [spec]
mov esi, dword ptr [curr]
mov ecx, dword ptr [prev]
add esi, 4 * 0x03FC
entry:
// previous shape
fldz
fld dword ptr [edx]
fmul dword ptr [ecx]
fxch
fld dword ptr [edx + 0x04]
fmul dword ptr [ecx + 0x04]
fxch
fld dword ptr [edx + 0x08]
fmul dword ptr [ecx + 0x08]
fxch
fld dword ptr [edx + 0x0C]
fmul dword ptr [ecx + 0x0C]
fxch st(4)
fstp dword ptr [edx]
fxch st(2)
fstp dword ptr [edx + 0x04]
fstp dword ptr [edx + 0x08]
fxch
fstp dword ptr [edx + 0x0C]
// current shape
fld dword ptr [edx + 0x1000]
fmul dword ptr [esi + 0x0C]
fxch
fld dword ptr [edx + 0x1004]
fmul dword ptr [esi + 0x08]
fxch
fld dword ptr [edx + 0x1008]
fmul dword ptr [esi + 0x04]
fxch
fld dword ptr [edx + 0x100C]
fmul dword ptr [esi]
fxch st(4)
fstp dword ptr [edx + 0x1000]
fxch st(2)
fstp dword ptr [edx + 0x1004]
fstp dword ptr [edx + 0x1008]
fstp st(0)
fstp dword ptr [edx + 0x100C]
add edx, 0x10
sub esi, 0x10
add ecx, 0x10
dec ebx
jne entry
}
}
#endif

View File

@ -1,170 +0,0 @@
#include "nsv_vlb.h"
///////////////////////////////////////////////////////////////////////
//
// NSV VLB Decoder
//
///////////////////////////////////////////////////////////////////////
VLB_Decoder::VLB_Decoder()
{
aacdec = new CAacDecoderApi( &datain );
fused = 0;
needsync = 1;
packets_in_since_flush = 0;
packets_decoded_since_flush = 0;
}
VLB_Decoder::~VLB_Decoder()
{
delete aacdec;
}
void VLB_Decoder::flush()
{
datain.Empty();
dataout.Empty();
//OutputDebugString("FLUSH\n");
// JF> this seems to be necessary for me at least, to have aacdec's internal buffer and state get reset :/
// (especially for AAC files, but I got it to do weird stuff on VLB files too :/)
// might be cleaner to see if we can just clear it somehow manually.. hmm..
delete aacdec;
aacdec = new CAacDecoderApi( &datain );
fused = 0;
needsync = 1;
packets_in_since_flush = 0;
packets_decoded_since_flush = 0;
}
int VLB_Decoder::decode( void *in, int in_len,
void *out, int *out_len,
unsigned int out_fmt[8] )
{
// This function gets called with 1 nsv frame's worth of audio data.
// That could mean 1 OR MORE audio packets. (or zero?)
// Just process the smallest amount (1 packet) and return 0 if you
// finished processing this big chunk, or 1 if you need to work on
// extracting more audio (from this same nsv frame) on the next call.
// RETURN VALUES:
// 1: call me again w/same buffer (and contents) next time
// 0: give me a new buffer (w/new frame contents) next time
AUDIO_FORMATINFO info;
int rval = 1;
if (!dataout.BytesAvail())
{
int l = datain.GetInputFree(); // the # of bytes that datain still has room for
if ( l > in_len - fused ) l = in_len - fused;
if ( l > 0)
{
datain.Fill( (unsigned char *)in + fused, l );
fused += l;
}
/*********************************/
if (in_len > 0)
packets_in_since_flush++;
#define PACKETS_TO_PREBUFFER_BEFORE_SYNCHRONIZE 2
if (needsync && packets_in_since_flush < PACKETS_TO_PREBUFFER_BEFORE_SYNCHRONIZE)
{
// Don't allow ourselves to call Synchronize() until we've actually received
// TWO audio packets. We need two because Synchronize() peeks ahead beyond
// the first packet, and throws an exception if the second one isn't also available.
// (note that if we were worried about getting partial frames from the nsv decoder,
// we'd want to set PACKETS_TO_PREBUFFER==3...)
fused = 0;
*out_len = 0;
return 0;
}
/*********************************/
if (!datain.GetSize())
{
if ( fused >= in_len ) rval = fused = 0; // get more data
*out_len = 0;
return rval;
}
if (needsync)
{
int status = aacdec->Synchronize( &params ); // returns # of bytes skipped forward through 'datain' in params.frame_length
if (status)
{
// ERROR
*out_len = 0;
if ( fused >= in_len ) rval = fused = 0; // get more data
return rval;
}
needsync = 0;
// NOTE: as long as the NSV file was encoded properly (i.e. all vlb audio packets were
// sent to the encoder intact, never split among two nsv frames), we don't have to worry
// about ever getting back a partial frame from the NSV decoder; it will sync for us,
// and hand us the 1st complete audio packet it can find.
// In short: Synchronize() should always return with params.frame_length==0.
/*
int bytes_skipped = params.frame_length;
if (bytes_skipped)
{
// here we assume that the first packet was partially or entirely skipped through
// (but that the 2nd and 3rd packets were 100% okay), so we won't try to decode
// that first packet.
packets_in_since_flush--;
}
*/
info.ucNChannels = (unsigned char) params.num_channels;
info.uiSampleRate = params.sampling_frequency;
dataout.SetFormatInfo( &info );
}
while (packets_decoded_since_flush < packets_in_since_flush)
{
int status = aacdec->DecodeFrame( &dataout, &params ); // returns # of bytes consumed from 'datain' in params.frame_length
packets_decoded_since_flush++;
if ( status > ERR_NO_ERROR && status != ERR_END_OF_FILE)
{
// ERROR
flush();
break;
}
}
if (packets_decoded_since_flush > 64)
{
// avoid overflow, but don't let either of these vars drop back to 0, 1, or 2!
packets_in_since_flush -= 32;
packets_decoded_since_flush -= 32;
}
}
int l = dataout.BytesAvail();
if (l > 0)
{
if ( l > *out_len ) l = *out_len;
else *out_len = l;
dataout.PullBytes( (unsigned char *)out, l );
info = dataout.GetFormatInfo();
out_fmt[0] = NSV_MAKETYPE( 'P', 'C', 'M', ' ' );
out_fmt[1] = info.uiSampleRate;
out_fmt[2] = info.ucNChannels;
out_fmt[3] = 16;
out_fmt[4] = params.bitrate;
}
else *out_len = 0;
return rval;
}

View File

@ -1,42 +0,0 @@
#pragma once
#include "aacdecoderapi.h"
#include "vlbout.h"
#include "VLBIO.h"
#include "../nsv/dec_if.h"
#include "../nsv/nsvlib.h"
/*
#if (defined WIN32 && !defined __ICL)
// Ignore libraries the aacplus library references (but doesn't need)
#pragma comment(linker, "-nodefaultlib:libmmt.lib")
#pragma comment(linker, "-nodefaultlib:libircmt.lib")
#pragma comment(linker, "-nodefaultlib:svml_disp.lib")
#endif
*/
///////////////////////////////////////////////////////////////////////
//
// Class Declarations
//
///////////////////////////////////////////////////////////////////////
class VLB_Decoder : public IAudioDecoder
{
public:
VLB_Decoder();
~VLB_Decoder();
int decode( void *in, int in_len,
void *out, int *out_len,
unsigned int out_fmt[8] );
void flush();
private:
//FILE* m_f;
CAacDecoderApi *aacdec;
VLBIn datain;
VLBOut dataout;
AACStreamParameters params;
int fused;
int needsync;
int packets_in_since_flush;
int packets_decoded_since_flush;
};

View File

@ -1 +0,0 @@
#include "obj_vlbDecoder.h"

View File

@ -1,65 +0,0 @@
#ifndef NULLSOFT_VLB_OBJ_VLBDECODER_H
#define NULLSOFT_VLB_OBJ_VLBDECODER_H
#include "aacdecoderapi.h"
#include <bfc/dispatch.h>
class obj_vlbDecoder : public Dispatchable
{
protected:
obj_vlbDecoder() {}
~obj_vlbDecoder() {}
public:
int Open(DataIOControl *paacInput);
void Close();
long Synchronize(AACStreamParameters *paacStreamParameters);
long DecodeFrame(AACStreamParameters *paacStreamParameters);
void Flush();
size_t Read(void *buffer, size_t bufferlen);
enum
{
OBJ_VLBDECODER_OPEN = 0,
OBJ_VLBDECODER_CLOSE = 1,
OBJ_VLBDECODER_SYNCHRONIZE = 2,
OBJ_VLBDECODER_DECODEFRAME = 3,
OBJ_VLBDECODER_FLUSH = 4,
OBJ_VLBDECODER_READ = 5,
};
};
inline int obj_vlbDecoder::Open(DataIOControl *paacInput)
{
return _call(OBJ_VLBDECODER_OPEN, (int)0, paacInput);
}
inline void obj_vlbDecoder::Close()
{
_voidcall(OBJ_VLBDECODER_CLOSE);
}
inline long obj_vlbDecoder::Synchronize(AACStreamParameters *paacStreamParameters)
{
return _call(OBJ_VLBDECODER_SYNCHRONIZE, (long)ERR_SYNC_ERROR, paacStreamParameters);
}
inline long obj_vlbDecoder::DecodeFrame(AACStreamParameters *paacStreamParameters)
{
return _call(OBJ_VLBDECODER_DECODEFRAME, (long)ERR_INVALID_BITSTREAM, paacStreamParameters);
}
inline void obj_vlbDecoder::Flush()
{
_voidcall(OBJ_VLBDECODER_FLUSH);
}
inline size_t obj_vlbDecoder::Read(void *buffer, size_t bufferlen)
{
return _call(OBJ_VLBDECODER_READ, (size_t)0, buffer, bufferlen);
}
// {A9F0E37C-69BA-48d7-BFEB-1C85A9F5A2FA}
static const GUID obj_vlbDecoderGUID =
{ 0xa9f0e37c, 0x69ba, 0x48d7, { 0xbf, 0xeb, 0x1c, 0x85, 0xa9, 0xf5, 0xa2, 0xfa } };
#endif

View File

@ -1,89 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/overlapadd.h,v 1.2 2011/06/13 02:06:03 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: overlapadd.h
* project : MPEG-2 AAC Decoder
* contents/description: time domain overlap add buffer object
*
\***************************************************************************/
#ifndef __OVERLAPADD_H__
#define __OVERLAPADD_H__
/** Buffer For Time Domain Overlap/Add Data.
This simple helper class provides a self-initializing buffer for one frame
worth of time domain signal data, associated window shape information and
appropriate access methods.
*/
class COverlapAddBuffer
{
protected :
enum
{
BufferSize = 1024
} ;
public :
COverlapAddBuffer ()
{
m_WindowShape = 0 ;
for (int i = 0 ; i < COverlapAddBuffer::BufferSize ; i++)
{
m_Buffer [i] = 0.0F ;
}
}
~COverlapAddBuffer () {} ;
// buffer access
float &operator [] (int index)
{
return m_Buffer [index] ;
}
// window shape access
int GetWindowShape (void) const
{
return m_WindowShape ;
}
void SetWindowShape (int shape)
{
m_WindowShape = shape ;
}
#if defined (WIN32) && defined (_M_IX86)
float *AccessBuffer (void)
{
return m_Buffer ;
}
#endif
protected :
int m_WindowShape ;
float m_Buffer [COverlapAddBuffer::BufferSize] ;
} ;
#endif

View File

@ -1,168 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/plainfile.cpp,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: plainfile.cpp
* project : MPEG-2 AAC Decoder
* contents/description: tiny file reader input class
*
\***************************************************************************/
#include "plainfile.h"
#include <memory.h>
#include <stddef.h> // for intptr_t
const unsigned long CPlainFile::m_ValidMask [32] =
{
0x00000000, 0x00000001, 0x00000003, 0x00000007,
0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F,
0x000000FF, 0x000001FF, 0x000003FF, 0x000007FF,
0x00000FFF, 0x00001FFF, 0x00003FFF, 0x00007FFF,
0x0000FFFF, 0x0001FFFF, 0x0003FFFF, 0x0007FFFF,
0x000FFFFF, 0x001FFFFF, 0x003FFFFF, 0x007FFFFF,
0x00FFFFFF, 0x01FFFFFF, 0x03FFFFFF, 0x07FFFFFF,
0x0FFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF
} ;
// public
CPlainFile::CPlainFile (DataIOControl *aacData)
: CDolbyBitStream ()
{
m_InputData = aacData ;
if (m_InputData->DICGetLastError()) throw EDoesNotExist () ;
m_ValidBits = 0 ;
m_Data = 0 ;
// detect adif header
m_sendadifbits=0;
#if 0 // FUCK ADIF HEADERS, THEY BLOW DONKEYBALLZ
memset(m_tmpadifbits,0,sizeof(m_tmpadifbits));
m_InputData->IO(m_tmpadifbits, 1, 4) ;
//m_InputData->Seek(0,SEEK_SET) ;
char *adif=m_tmpadifbits;
if ((adif [0] == 'A') &&
(adif [1] == 'D') &&
(adif [2] == 'I') &&
(adif [3] == 'F')
)
{
m_AdifHeaderPresent = true ;
m_sendadifbits=0;
}
else
if ((adif [0] == 'R') &&
(adif [1] == 'I') &&
(adif [2] == 'F') &&
(adif [3] == 'F')
)
{
m_RiffHeaderPresent = true ;
m_sendadifbits=0;
}
#endif
}
CPlainFile::~CPlainFile ()
{
//fclose (m_InputFile) ;
}
long CPlainFile::Get (int n)
{
if (m_ValidBits <= 16)
{
m_Data = (m_Data << 16) | GetShort () ;
m_ValidBits += 16 ;
}
m_ValidBits -= n ;
return ((m_Data >> m_ValidBits) & m_ValidMask [n]) ;
}
void CPlainFile::ByteAlign (void)
{
if (m_ValidBits <= 16)
{
m_Data = (m_Data << 16) | GetShort () ;
m_ValidBits += 16 ;
}
while (m_ValidBits & 0x07)
{
m_ValidBits-- ;
}
}
void CPlainFile::PushBack (int n)
{
m_ValidBits += n ;
}
int CPlainFile::Read (void *pData, int cBytes)
{
if(m_sendadifbits)
{
cBytes-=4; //CT> I assume that it'll always be >4 at this point in the exec.
memcpy(pData,m_tmpadifbits,4);
intptr_t a=(intptr_t)pData+4;
pData=(void*)a;
m_sendadifbits=0;
}
return m_InputData->IO(pData,1,cBytes) ;
}
// protected
long CPlainFile::GetShort (void)
{
int c1;
int c2;
m_InputData->IO(&c1,1,1);
m_InputData->IO(&c2,1,1);
if (m_InputData->EndOf())
throw EEndOfFile () ;
c1&=0xff;
c2&=0xff;
return (c1 << 8) | c2 ;
}
#define SYNCWORD 0x0fff
#define SYNCMASK 0x0fff
#define SYNCLENGTH 12
#define REMLENGTH 16
#define MAX_SEARCH 100000
int CPlainFile::LockAndLoad()
{
int iCount;
unsigned int dwSync;
dwSync=0;
iCount=0;
while(iCount<MAX_SEARCH && dwSync!=SYNCWORD){
int iTemp;
dwSync<<=8;
m_InputData->IO(&iTemp,1,1);
if (m_InputData->EndOf())
throw EEndOfFile () ;
dwSync+=iTemp;
dwSync&=SYNCMASK;
iCount++;
}
m_Data=dwSync;
m_ValidBits=REMLENGTH;
if(iCount<MAX_SEARCH) return 1;
else return 0;
}

View File

@ -1,75 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/plainfile.h,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: plainfile.h
* project : MPEG-2 AAC Decoder
* contents/description: tiny file reader input class
*
\***************************************************************************/
#ifndef __PLAINFILE_H__
#define __PLAINFILE_H__
#include <stdio.h>
#include "bitstream.h"
#include "DataIO.h"
/** A Simple File Reading Input Class.
This class is a simple input class adhering to the CDolbyBitStream interface. It can
be used to read raw and ADIF-style bitstreams.
*/
class CPlainFile : public CDolbyBitStream
{
public :
CPlainFile (DataIOControl *aacData) ;
virtual ~CPlainFile () ;
// // //
virtual void ByteAlign (void) ;
virtual long Get (int n) ;
virtual void PushBack (int n) ;
/** Raw Block Read Method.
This method sequentially reads chunks of data from the input file.
@param pData The buffer where the data chunk should be stored.
@param cBytes The number of bytes to read.
@return The number of bytes actually read.
*/
int Read (void *pData, int cBytes) ;
int LockAndLoad();
protected :
long GetShort (void) ;
DataIOControl *m_InputData ;
int m_ValidBits ;
unsigned long m_Data ;
static const unsigned long m_ValidMask [32] ;
char m_tmpadifbits[4]; //CT
int m_sendadifbits;
} ;
#endif

View File

@ -1,244 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/prediction.cpp,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
#ifdef MAIN_PROFILE
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: prediction.cpp
* project : MPEG-2 AAC Decoder
* contents/description: prediction tool
*
\***************************************************************************/
#include "prediction.h"
#include "channelinfo.h"
#include "block.h"
//////////////////////////////////////////////////////////////////////////////
// CQuantizedFloat
const float CPrediction::CQuantizedFloat::m_Mantissa [128] =
{
0.953125F, 0.945313F, 0.937500F, 0.929688F, 0.925781F, 0.917969F, 0.910156F, 0.902344F,
0.898438F, 0.890625F, 0.882813F, 0.878906F, 0.871094F, 0.867188F, 0.859375F, 0.851563F,
0.847656F, 0.839844F, 0.835938F, 0.828125F, 0.824219F, 0.820313F, 0.812500F, 0.808594F,
0.800781F, 0.796875F, 0.792969F, 0.785156F, 0.781250F, 0.777344F, 0.773438F, 0.765625F,
0.761719F, 0.757813F, 0.753906F, 0.750000F, 0.742188F, 0.738281F, 0.734375F, 0.730469F,
0.726563F, 0.722656F, 0.718750F, 0.714844F, 0.710938F, 0.707031F, 0.699219F, 0.695313F,
0.691406F, 0.687500F, 0.683594F, 0.679688F, 0.679688F, 0.675781F, 0.671875F, 0.667969F,
0.664063F, 0.660156F, 0.656250F, 0.652344F, 0.648438F, 0.644531F, 0.640625F, 0.640625F,
0.636719F, 0.632813F, 0.628906F, 0.625000F, 0.621094F, 0.621094F, 0.617188F, 0.613281F,
0.609375F, 0.605469F, 0.605469F, 0.601563F, 0.597656F, 0.593750F, 0.593750F, 0.589844F,
0.585938F, 0.582031F, 0.582031F, 0.578125F, 0.574219F, 0.574219F, 0.570313F, 0.566406F,
0.566406F, 0.562500F, 0.558594F, 0.558594F, 0.554688F, 0.550781F, 0.550781F, 0.546875F,
0.542969F, 0.542969F, 0.539063F, 0.539063F, 0.535156F, 0.531250F, 0.531250F, 0.527344F,
0.527344F, 0.523438F, 0.519531F, 0.519531F, 0.515625F, 0.515625F, 0.511719F, 0.511719F,
0.507813F, 0.507813F, 0.503906F, 0.503906F, 0.500000F, 0.498047F, 0.496094F, 0.494141F,
0.492188F, 0.490234F, 0.488281F, 0.486328F, 0.484375F, 0.482422F, 0.480469F, 0.478516F
} ;
const float CPrediction::CQuantizedFloat::m_Exponent [256] =
{
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F, 0.000000e+000F,
5.000000e-001F, 2.500000e-001F, 1.250000e-001F, 6.250000e-002F, 3.125000e-002F, 1.562500e-002F, 7.812500e-003F, 3.906250e-003F,
1.953125e-003F, 9.765625e-004F, 4.882813e-004F, 2.441406e-004F, 1.220703e-004F, 6.103516e-005F, 3.051758e-005F, 1.525879e-005F,
7.629395e-006F, 3.814697e-006F, 1.907349e-006F, 9.536743e-007F, 4.768372e-007F, 2.384186e-007F, 1.192093e-007F, 5.960464e-008F,
2.980232e-008F, 1.490116e-008F, 7.450581e-009F, 3.725290e-009F, 1.862645e-009F, 9.313226e-010F, 4.656613e-010F, 2.328306e-010F,
1.164153e-010F, 5.820766e-011F, 2.910383e-011F, 1.455192e-011F, 7.275958e-012F, 3.637979e-012F, 1.818989e-012F, 9.094947e-013F,
4.547474e-013F, 2.273737e-013F, 1.136868e-013F, 5.684342e-014F, 2.842171e-014F, 1.421085e-014F, 7.105427e-015F, 3.552714e-015F,
1.776357e-015F, 8.881784e-016F, 4.440892e-016F, 2.220446e-016F, 1.110223e-016F, 5.551115e-017F, 2.775558e-017F, 1.387779e-017F,
6.938894e-018F, 3.469447e-018F, 1.734723e-018F, 8.673617e-019F, 4.336809e-019F, 2.168404e-019F, 1.084202e-019F, 5.421011e-020F,
2.710505e-020F, 1.355253e-020F, 6.776264e-021F, 3.388132e-021F, 1.694066e-021F, 8.470329e-022F, 4.235165e-022F, 2.117582e-022F,
1.058791e-022F, 5.293956e-023F, 2.646978e-023F, 1.323489e-023F, 6.617445e-024F, 3.308722e-024F, 1.654361e-024F, 8.271806e-025F,
4.135903e-025F, 2.067952e-025F, 1.033976e-025F, 5.169879e-026F, 2.584939e-026F, 1.292470e-026F, 6.462349e-027F, 3.231174e-027F,
1.615587e-027F, 8.077936e-028F, 4.038968e-028F, 2.019484e-028F, 1.009742e-028F, 5.048710e-029F, 2.524355e-029F, 1.262177e-029F,
6.310887e-030F, 3.155444e-030F, 1.577722e-030F, 7.888609e-031F, 3.944305e-031F, 1.972152e-031F, 9.860761e-032F, 4.930381e-032F,
2.465190e-032F, 1.232595e-032F, 6.162976e-033F, 3.081488e-033F, 1.540744e-033F, 7.703720e-034F, 3.851860e-034F, 1.925930e-034F,
9.629650e-035F, 4.814825e-035F, 2.407412e-035F, 1.203706e-035F, 6.018531e-036F, 3.009266e-036F, 1.504633e-036F, 7.523164e-037F,
3.761582e-037F, 1.880791e-037F, 9.403955e-038F, 4.701977e-038F, 2.350989e-038F, 1.175494e-038F, 5.877472e-039F, 0.000000e+000F
} ;
float CPrediction::CQuantizedFloat::GetBDivVar (void)
{
// description: compute division of B/VAR by means of two look up tables
// returns: single precision float (B/VAR)
unsigned int mntInd = m_Value & 0x007F0000 ; // extract the 7-bit mantissa index
unsigned int expInd = m_Value & 0x7F800000 ; // extract the 8-bit exponent index
return m_Mantissa [mntInd >> 16] * m_Exponent [expInd >> 23] ;
}
//////////////////////////////////////////////////////////////////////////////
// CPredictionState
float CPrediction::CPredictionState::FloatRoundInfinity (float x)
{
// description: rounds 32 bit single precision number to 16 bit precision
// float towards infinity (non IEEE comform)
// returns: rounded float
// input: 32 bit single precision float
unsigned int t = DWORDCAST(x) ;
unsigned int flag = t & 0x8000 ;
t &= 0xFFFF0000L ; // zero out bits below LSB
x = FLOATCAST(t) ;
// if the below-LSB part of the mantissa is 0.5 or above, round to inf
if (flag)
{
// we need to add 1 LSB. However, since the mantissa always includes
// a hidden MSB of 1, i.e. 2^e * 1, we need to subtract that afterwards.
unsigned int c1 = t & 0xFF800000L ; // 2^e * 1
unsigned int c2 = c1 | 0x00010000L ; // LSB
x -= FLOATCAST(c1);
x += FLOATCAST(c2);
}
return x ;
}
float CPrediction::CPredictionState::GetPredictedValue (void)
{
// description: performs prediction for one MDCT bin
// returns: predicted value
// input: state variable handle, prediction buffer handle
float k [CPrediction::Order] ;
for (int i = 0 ; i < CPrediction::Order ; i++)
{
// compute (b / VAR) * COR
k [i] = m_var [i].GetBDivVar () * m_cor [i] ;
}
// compute the estimate, round it to nearest infinity and store it
return FloatRoundInfinity (k [0] * m_r [0] + k [1] * m_r [1]) ;
}
void CPrediction::CPredictionState::Update (float value)
{
const float ALPHA = 0.90625F ;
const float A = 0.953125F ;
float e [CPrediction::Order] ;
float k0 = m_cor [0] * m_var [0].GetBDivVar () ;
e [0] = value ;
e [1] = e [0] - k0 * m_r [0] ;
for (int i = 0 ; i < CPrediction::Order ; i++)
{
float r = m_r [i] ;
m_var [i] = ALPHA * m_var [i] + (0.5F) * (r * r + e [i] * e [i]) ;
m_cor [i] = ALPHA * m_cor [i] + e [i] * r ;
}
m_r [1] = A * (m_r [0] - k0 * e [0]) ;
m_r [0] = A * e [0] ;
}
//////////////////////////////////////////////////////////////////////////////
// CPrediction
CPrediction::CPrediction ()
{
}
CPrediction::~CPrediction ()
{
}
void CPrediction::FullReset (void)
{
for (int i = 0 ; i < CPrediction::MaximumPredictedBins ; i++)
{
m_State [i].Reset () ;
}
}
void CPrediction::Apply (const CChannelInfo &info, CBlock &spectrum)
{
// short blocks
if (info.IsShortBlock ())
{
FullReset () ;
return ;
}
// long blocks
const int *BandOffsets = info.GetScaleFactorBandOffsets () ;
// apply predicted value to transmitted error value
if (info.GetPredictorDataPresent ())
{
for (int band = 0 ; band < info.GetMaximumPredictionBands () ; band++)
{
if (info.GetPredictionUsedForBand (band))
{
for (int index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index++)
{
spectrum.AccessSpectralData () [index] += m_State [index].GetPredictedValue () ;
}
}
}
}
// update state
for (int band = 0 ; band < info.GetMaximumPredictionBands () ; band++)
{
for (int index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index++)
{
m_State [index].Update (spectrum.AccessSpectralData () [index]) ;
}
}
// perform cyclic reset
if (info.GetPerformPredictorReset ())
{
int group = info.GetPredictorResetGroupNumber () - 1 ;
int maxbin = BandOffsets [info.GetMaximumPredictionBands ()] ;
for (int index = group ; index < maxbin ; index += 30)
{
m_State [index].Reset () ;
}
}
}
#endif

View File

@ -1,127 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/prediction.h,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
#ifdef MAIN_PROFILE
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: prediction.h
* project : MPEG-2 AAC Decoder
* contents/description: prediction tool
*
\***************************************************************************/
#ifndef __PREDICTION_H__
#define __PREDICTION_H__
#define DWORDCAST(x) (*(unsigned int*)&(x))
#define FLOATCAST(x) (*(float*)&(x))
class CChannelInfo ;
class CBlock ;
/** Intra Channel Prediction.
This class represents the MPEG-2 AAC Main Profile intra channel prediction
tool. It holds the state information for a second order backward-adaptive
lattice structure predictor for each spectral component, and can be applied
to the spectral coefficients in the main profile only.
Prediction is a profile-dependent tool and the CPrediction implementation
follows the Read()/Apply() convention used for all tools.
*/
class CPrediction
{
public :
CPrediction () ;
~CPrediction () ;
void Apply (const CChannelInfo &info, CBlock &spectrum) ;
void FullReset (void) ;
enum
{
MaximumPredictedBins = 672,
Order = 2 // Order of the backward adaptive lattice filter
} ;
protected :
class CQuantizedFloat
{
public :
operator float () const
{
return FLOATCAST(m_Value) ;
}
CQuantizedFloat &operator=(float assigned)
{
m_Value = DWORDCAST(assigned) & 0xFFFF0000 ;
return *this ;
}
float GetBDivVar (void) ;
protected :
unsigned int m_Value ;
static const float m_Mantissa [128] ;
static const float m_Exponent [256] ;
} ;
// State variables of the backward adaptive predictor
// (according to lattice structure in IS)
class CPredictionState
{
public :
CPredictionState ()
{
Reset () ;
}
~CPredictionState () {}
float GetPredictedValue (void) ;
void Update (float value) ;
void Reset (void)
{
for (int i = 0 ; i < Order ; i++)
{
m_cor [i] = 0.0F ;
m_var [i] = 1.0F ;
m_r [i] = 0.0F ;
}
}
protected :
float FloatRoundInfinity (float x) ;
CQuantizedFloat m_r [Order] ; // r coefficient
CQuantizedFloat m_cor [Order] ; // correlation coefficient
CQuantizedFloat m_var [Order] ; // variance coefficient
} ;
CPredictionState m_State [MaximumPredictedBins] ;
} ;
#endif
#endif

View File

@ -1,302 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/programcfg.cpp,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: programcfg.cpp
* project : MPEG-2 AAC Decoder
* contents/description: program config element
*
\***************************************************************************/
#include "programcfg.h"
CProgramConfig::CProgramConfig ()
: m_ElementInstanceTag (4),
m_Profile (2),
m_SamplingFrequencyIndex (4),
m_NumLfeChannelElements (2),
m_NumAssocDataElements (3),
m_NumValidCcElements (4),
m_MonoMixdownPresent (1),
m_MonoMixdownElementNumber (4),
m_StereoMixdownPresent (1),
m_StereoMixdownElementNumber (4),
m_MatrixMixdownIndexPresent (1),
m_MatrixMixdownIndex (2),
m_PseudoSurroundEnable (1),
m_CommentFieldBytes (8)
{
m_ExplicitMapping = false ;
m_NonMC_ConfigSet = false ;
for (int row = FrontRow ; row < SpeakerRows ; row++)
{
m_NumberOfChannels [row] = 0 ;
m_NumberOfChannelElements [row] = 0 ;
}
}
CProgramConfig::~CProgramConfig ()
{
}
void CProgramConfig::ResetNonMCConfig(void)
{
m_ExplicitMapping = false ;
m_NonMC_ConfigSet = false ;
for (int row = FrontRow ; row < SpeakerRows ; row++)
{
m_NumberOfChannels [row] = 0 ;
m_NumberOfChannelElements [row] = 0 ;
}
}
void CProgramConfig::Read (CDolbyBitStream &bs)
{
int i, row;
m_ElementInstanceTag.Read(bs) ;
m_Profile.Read (bs) ;
m_SamplingFrequencyIndex.Read (bs) ;
for (row = FrontRow ; row < SpeakerRows ; row++)
m_NumberOfChannelElements [row].Read (bs, 4) ;
m_NumLfeChannelElements.Read (bs) ;
m_NumAssocDataElements.Read (bs) ;
m_NumValidCcElements.Read (bs) ;
if (m_MonoMixdownPresent.Read (bs))
{
m_MonoMixdownElementNumber.Read (bs) ;
}
if (m_StereoMixdownPresent.Read (bs))
{
m_StereoMixdownElementNumber.Read (bs) ;
}
if (m_MatrixMixdownIndexPresent.Read (bs))
{
m_MatrixMixdownIndex.Read (bs) ;
m_PseudoSurroundEnable.Read (bs) ;
}
m_NumChannels = 0;
for (row = FrontRow ; row < SpeakerRows ; row++)
{
m_NumberOfChannels [row] = 0 ;
for (i = 0 ; i < m_NumberOfChannelElements [row] ; i++)
{
m_ChannelElementIsCpe [row][i].Read (bs, 1) ;
m_ChannelElementTagSelect [row][i].Read (bs, 4) ;
m_NumberOfChannels [row] += m_ChannelElementIsCpe [row][i] ? 2 : 1 ;
m_NumChannels += m_NumberOfChannels [row];
}
}
for (i = 0 ; i < m_NumLfeChannelElements ; i++)
{
m_LfeElementTagSelect [i].Read (bs, 4) ;
}
for (i = 0 ; i < m_NumAssocDataElements ; i++)
{
m_AssocDataElementTagSelect [i].Read (bs, 4) ;
}
for (i = 0 ; i < m_NumValidCcElements ; i++)
{
m_CcElementIsIndSw [i].Read (bs, 1) ;
m_ValidCcElementTagSelect [i].Read (bs, 4) ;
}
// comment
bs.ByteAlign () ;
m_CommentFieldBytes.Read (bs) ;
CVLBBitSequence text (8) ;
for (i = 0 ; i < m_CommentFieldBytes ; i++)
{
text.Read (bs) ;
if (i < MaximumCommentLength)
{
m_Comment [i] = text ;
}
}
m_ExplicitMapping = true ;
}
// the decoder calls this method with every
// new element id found in the bitstream.
bool CProgramConfig::AddChannel (const int tag, const bool isCPE)
{
if (!m_NonMC_ConfigSet)
{
m_NonMC_Tag = tag ;
m_NonMC_IsCPE = isCPE ;
m_NonMC_ConfigSet = true ;
return true ;
}
else
{
return ((m_NonMC_IsCPE == isCPE) && (m_NonMC_Tag == tag)) ;
}
}
bool CProgramConfig::AddSingleChannel (const int tag)
{
if (m_ExplicitMapping)
{
for (int row = 0 ; row < SpeakerRows ; row++)
{
for (int i = 0 ; i < m_NumberOfChannelElements [row] ; i++)
{
if ((m_ChannelElementTagSelect [row][i] == tag) && !m_ChannelElementIsCpe [row][i])
return true ;
}
}
return false ;
}
return true ;
}
bool CProgramConfig::AddChannelPair (const int tag)
{
if (m_ExplicitMapping)
{
for (int row = FrontRow ; row < SpeakerRows ; row++)
{
for (int i = 0 ; i < m_NumberOfChannelElements [row] ; i++)
{
if ((m_ChannelElementTagSelect [row][i] == tag) && m_ChannelElementIsCpe [row][i])
return true ;
}
}
return false ;
}
return true ;
}
bool CProgramConfig::AddCouplingChannel (const int tag)
{
if (m_ExplicitMapping)
{
for (int i = 0 ; i < m_NumValidCcElements ; i++)
{
if (m_ValidCcElementTagSelect [i] == tag)
{
// inc num_coupling_chan;
return true ;
}
}
return false ;
}
return true ;
}
bool CProgramConfig::AddLowFrequencyChannel (const int tag)
{
if (m_ExplicitMapping)
{
for (int i = 0 ; i < m_NumLfeChannelElements ; i++)
{
if (m_LfeElementTagSelect [i] == tag) return true ;
}
return false ;
}
return true ;
}
bool CProgramConfig::IsChannelLocatedAt (const int row, const int tag)
{
for (int i = 0 ; i < m_NumberOfChannelElements [row] ; i++)
{
if (!m_ChannelElementIsCpe [row][i] && (m_ChannelElementTagSelect [row][i] == tag))
return true ;
}
return false ;
}
bool CProgramConfig::IsChannelPairLocatedAt (const int row, const int tag)
{
for (int i = 0 ; i < m_NumberOfChannelElements [row] ; i++)
{
if (m_ChannelElementIsCpe [row][i] && (m_ChannelElementTagSelect [row][i] == tag))
return true ;
}
return false ;
}
int CProgramConfig::GetNumberOfElements (const int row)
{
return m_NumberOfChannelElements [row] ;
}
int CProgramConfig::GetNumberOfChannels (const int row)
{
return m_NumberOfChannels [row] ;
}
int CProgramConfig::GetElementTag (const int row, const int index)
{
return m_ChannelElementTagSelect [row][index] ;
}
bool CProgramConfig::IsChannelPair (const int row, const int index)
{
return m_ChannelElementIsCpe [row][index] ? true : false ;
}
int CProgramConfig::GetNumberOfLowFrequencyChannels (void)
{
return m_NumLfeChannelElements ;
}
int CProgramConfig::GetLowFrequencyChannelTag (const int index)
{
return m_LfeElementTagSelect [index] ;
}
char* CProgramConfig::GetCommentFieldData (void)
{
char* comment = new char[m_CommentFieldBytes];
for (int i = 0; i < m_CommentFieldBytes; i++)
comment[i] = m_Comment[i];
return comment;
}

View File

@ -1,222 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/programcfg.h,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: programcfg.h
* project : MPEG-2 AAC Decoder
* contents/description: program config element
*
\***************************************************************************/
#ifndef __PROGRAMCFG_H__
#define __PROGRAMCFG_H__
#include "bitsequence.h"
class CDolbyBitStream ;
/** PCE Program Configuration Element.
This class holds the program configuration data read from the bitstream
and maps the decoded channels according to the currently active program.
*/
class CProgramConfig
{
enum
{
FrontRow = 0,
SideRow = 1,
BackRow = 2,
SpeakerRows = 3,
MaximumChannels = 16,
MaximumCommentLength = 64
} ;
CVLBBitSequence m_ElementInstanceTag;
CVLBBitSequence m_Profile ;
CVLBBitSequence m_SamplingFrequencyIndex ;
CVLBBitSequence m_NumLfeChannelElements ;
CVLBBitSequence m_NumAssocDataElements ;
CVLBBitSequence m_NumValidCcElements ;
CVLBBitSequence m_MonoMixdownPresent ;
CVLBBitSequence m_MonoMixdownElementNumber ;
CVLBBitSequence m_StereoMixdownPresent ;
CVLBBitSequence m_StereoMixdownElementNumber ;
CVLBBitSequence m_MatrixMixdownIndexPresent ;
CVLBBitSequence m_MatrixMixdownIndex ;
CVLBBitSequence m_PseudoSurroundEnable ;
CVLBBitSequence m_NumberOfChannelElements [SpeakerRows] ;
CVLBBitSequence m_ChannelElementIsCpe [SpeakerRows][MaximumChannels] ;
CVLBBitSequence m_ChannelElementTagSelect [SpeakerRows][MaximumChannels] ;
CVLBBitSequence m_LfeElementTagSelect [MaximumChannels] ;
CVLBBitSequence m_AssocDataElementTagSelect [MaximumChannels] ;
CVLBBitSequence m_CcElementIsIndSw [MaximumChannels] ;
CVLBBitSequence m_ValidCcElementTagSelect [MaximumChannels] ;
CVLBBitSequence m_CommentFieldBytes ;
char m_Comment [MaximumCommentLength] ;
unsigned int m_NumChannels;
public :
CProgramConfig () ;
~CProgramConfig () ;
void ResetNonMCConfig(void);
void Read (CDolbyBitStream &bs) ;
//
bool AddChannel (const int tag, const bool isCPE) ;
//
bool AddSingleChannel (const int tag) ;
bool AddChannelPair (const int tag) ;
bool AddCouplingChannel (const int tag) ;
bool AddLowFrequencyChannel (const int tag) ;
// explicit query
bool IsFrontChannel (const int tag) { return IsChannelLocatedAt (FrontRow, tag) ; }
bool IsFrontChannelPair (const int tag) { return IsChannelPairLocatedAt (FrontRow, tag) ; }
bool IsBackChannel (const int tag) { return IsChannelLocatedAt (BackRow, tag) ; }
bool IsBackChannelPair (const int tag) { return IsChannelPairLocatedAt (BackRow, tag) ; }
// query by index
int GetNumberOfElements (const int row) ;
int GetNumberOfChannels (const int row) ;
int GetElementTag (const int row, const int index) ;
bool IsChannelPair (const int row, const int index) ;
int GetNumberOfLowFrequencyChannels (void) ;
int GetLowFrequencyChannelTag (const int index) ;
//
bool HasSpeakerMapping (void) const
{
return m_ExplicitMapping ;
}
unsigned int GetElementInstnaceTag (void) const
{
return m_ElementInstanceTag ;
}
unsigned int GetProfile (void) const
{
return m_Profile ;
}
unsigned int GetSamplingFrequencyIndex (void) const
{
return m_SamplingFrequencyIndex ;
}
unsigned int GetNumChannels (void) const
{
return m_NumChannels ;
}
unsigned int GetNumFrontChannels (void) const
{
return m_NumberOfChannelElements[FrontRow] ;
}
unsigned int GetNumSideChannels (void) const
{
return m_NumberOfChannelElements[SideRow] ;
}
unsigned int GetNumBackChannels (void) const
{
return m_NumberOfChannelElements[BackRow] ;
}
unsigned int GetNumLfeChannels (void) const
{
return m_NumLfeChannelElements ;
}
unsigned int GetNumCouplingChannels (void) const
{
return m_NumValidCcElements ;
}
unsigned int GetCouplingChannelTag (int index) const
{
return m_ValidCcElementTagSelect[index] ;
}
unsigned int GetMonoMixdownPresent (void) const
{
return m_MonoMixdownPresent ;
}
unsigned int GetStereoMixdownPresent (void) const
{
return m_StereoMixdownPresent ;
}
unsigned int GetMatrixMixdownPresent (void) const
{
return m_MatrixMixdownIndexPresent ;
}
unsigned int GetPseudoSurroundPresent (void) const
{
return m_PseudoSurroundEnable ;
}
char* GetCommentFieldData (void);
protected :
bool IsChannelLocatedAt (const int row, const int tag) ;
bool IsChannelPairLocatedAt (const int row, const int tag) ;
// non-multichannel configuration
bool m_NonMC_ConfigSet ;
bool m_NonMC_IsCPE ;
int m_NonMC_Tag ;
//
bool m_ExplicitMapping ;
unsigned int m_NumberOfChannels [SpeakerRows] ;
} ;
#endif

View File

@ -1,62 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/pulsedata.cpp,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: pulsedata.cpp
* project : MPEG-2 AAC Decoder
* contents/description: pulse data tool
*
\***************************************************************************/
#include "pulsedata.h"
#include "bitstream.h"
#include "channelinfo.h"
CPulseData::CPulseData ()
: m_PulseDataPresent (1),
m_NumberPulse (2),
m_PulseStartBand (6)
{
}
CPulseData::~CPulseData ()
{
}
void CPulseData::Read (CDolbyBitStream &bs)
{
if (m_PulseDataPresent.Read (bs))
{
m_NumberPulse.Read (bs) ;
m_PulseStartBand.Read (bs) ;
for (int i = 0 ; i <= m_NumberPulse ; i++)
{
m_PulseOffset [i].Read (bs, 5) ;
m_PulseAmp [i].Read (bs, 4) ;
}
}
}
void CPulseData::Apply (const CChannelInfo &info, int coef [])
{
if (m_PulseDataPresent)
{
int k = info.GetScaleFactorBandOffsets () [(int) m_PulseStartBand] ;
for (int i = 0 ; i <= m_NumberPulse ; i++)
{
k += m_PulseOffset [i] ;
if (coef [k] > 0) coef [k] += m_PulseAmp [i] ;
else coef [k] -= m_PulseAmp [i] ;
}
}
}

View File

@ -1,61 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/pulsedata.h,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: pulsedata.cpp
* project : MPEG-2 AAC Decoder
* contents/description: pulse data tool
*
\***************************************************************************/
#ifndef __PULSEDATA_H__
#define __PULSEDATA_H__
#include "bitsequence.h"
class CChannelInfo ;
/** Pulse Data Processing.
This class represents the pulse data noiseless coding tool for decoding and
applying pulse data to the spectral coefficients of the current block.
The Pulse Data tool is not profile-dependent and the CPulseData implementation
follows the Read()/Apply() convention used for all tools.
*/
class CPulseData
{
public :
CPulseData () ;
~CPulseData () ;
void Read (CDolbyBitStream &bs) ;
void Apply (const CChannelInfo &info, int coef []) ;
enum
{
MaximumLines = 4
} ;
protected :
CVLBBitSequence m_PulseDataPresent ;
CVLBBitSequence m_NumberPulse ;
CVLBBitSequence m_PulseStartBand ;
CVLBBitSequence m_PulseOffset [MaximumLines] ;
CVLBBitSequence m_PulseAmp [MaximumLines] ;
} ;
#endif

View File

@ -1,17 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by logo.rc
//
#define IDB_BITMAP1 101
#define IDB_BITMAP2 102
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,14 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by vlb.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,420 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/shortblock.cpp,v 1.2 2011/06/13 02:06:03 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: shortblock.cpp
* project : MPEG-2 AAC Decoder
* contents/description: eight short window sequence object
*
\***************************************************************************/
#include <math.h> // pow()
#include "block.h"
#include "bitstream.h"
#include "channelinfo.h"
#include "overlapadd.h"
#ifdef MAIN_PROFILE
#include "prediction.h"
#endif
// ctor/dtor
CShortBlock::CShortBlock (CChannelInfo &info)
: CBlock (info)
{
m_SectBits = 3 ;
}
CShortBlock::~CShortBlock ()
{
}
// low-level access
float *CShortBlock::AccessSpectralData (int window)
{
return m_SpectralCoefficient [window] ;
}
int *CShortBlock::AccessCodeBooks (int group)
{
return m_CodeBook [group] ;
}
int *CShortBlock::AccessScaleFactors (int group)
{
return m_ScaleFactor [group] ;
}
// readers
void CShortBlock::ReadSectionData (CDolbyBitStream &bs)
{
CVLBBitSequence sect_cb (4) ;
CVLBBitSequence sect_len_incr (m_SectBits) ;
int sect_esc_val = (1 << m_SectBits) - 1 ;
//Section Information:
int iNumberOfSections;
for (int group = 0 ; group < m_IcsInfo.GetWindowGroups () ; group++)
{
int band ; // msdev not ansi
// initialize first group's section info
iNumberOfSections=0;
sSectionInfoStruct.aiSectionCount[group]=0;
sSectionInfoStruct.aaiSectionStart[group][0]=0;
for (band = 0 ; band < m_IcsInfo.GetScaleFactorBandsTransmitted () ; )
{
sect_cb.Read (bs) ;
sect_len_incr.Read (bs) ;
int sect_len = 0 ;
while (sect_len_incr == sect_esc_val)
{
sect_len += sect_esc_val ;
sect_len_incr.Read (bs) ;
}
sect_len += sect_len_incr ;
for (int top = band + sect_len ; band < top ; band++)
{
m_CodeBook [group][band] = sect_cb ;
if ((m_CodeBook [group][band] == BOOKSCL) ||
(m_CodeBook [group][band] == RESERVED_HCB)
)
{
throw EInvalidCodeBook () ;
}
}
sSectionInfoStruct.aaiSectionCodebooks[group][iNumberOfSections]=sect_cb;
sSectionInfoStruct.aaiSectionStart[group][iNumberOfSections+1]=band;
sSectionInfoStruct.aaiSectionEnd[group][iNumberOfSections]=band;
sSectionInfoStruct.aiSectionCount[group]++;
iNumberOfSections++;
} // for band
if(band < m_IcsInfo.GetScaleFactorBandsTotal() && m_IcsInfo.GetScaleFactorBandsTransmitted()){
sSectionInfoStruct.aaiSectionCodebooks[group][iNumberOfSections]=ZERO_HCB;
sSectionInfoStruct.aaiSectionEnd[group][iNumberOfSections]= m_IcsInfo.GetScaleFactorBandsTotal ();
sSectionInfoStruct.aiSectionCount[group]++;
iNumberOfSections++;
}
for ( ; band < m_IcsInfo.GetScaleFactorBandsTotal () ; band++)
{
m_CodeBook [group][band] = ZERO_HCB ;
}
} // for group..
}
void CShortBlock::ReadScaleFactorData (CDolbyBitStream &bs, const int global_gain)
{
const CodeBookDescription *hcb = &HuffmanCodeBooks [BOOKSCL] ;
int factor = global_gain ;
int position = 0 ;
int temp ;
for (int group = 0 ; group < m_IcsInfo.GetWindowGroups () ; group++)
{
for (int band = 0 ; band < m_IcsInfo.GetScaleFactorBandsTransmitted () ; band++)
{
switch (m_CodeBook [group][band])
{
case ZERO_HCB : // zero book
m_ScaleFactor [group][band] = 0 ;
break ;
default : // decode scale factor
temp = DecodeHuffmanWord (bs, hcb->CodeBook) ;
factor += temp - 60 ; // MIDFAC 1.5 dB
m_ScaleFactor [group][band] = factor - 100 ;
break ;
case INTENSITY_HCB : // intensity steering
case INTENSITY_HCB2 :
temp = DecodeHuffmanWord (bs, hcb->CodeBook) ;
position += temp - 60 ;
m_ScaleFactor [group][band] = position - 100 ;
break ;
}
}
}
}
void CShortBlock::ReadSpectralData (CDolbyBitStream &bs)
{
const int *BandOffsets = m_IcsInfo.GetScaleFactorBandOffsets () ;
int QuantizedCoef [MaximumWindows][MaximumBins] ;
int window, group ;
// // // clear coeffs
for (window = 0 ; window < MaximumWindows ; window++)
{
for (int index = 0 ; index < MaximumBins ; index++)
{
QuantizedCoef [window][index] = 0 ;
}
}
// // // read interleaved coeffs
int groupoffset = 0 ;
for (group = 0 ; group < m_IcsInfo.GetWindowGroups () ; group++)
{
for (int band = 0 ; band < m_IcsInfo.GetScaleFactorBandsTransmitted () ; band++)
{
const CodeBookDescription *hcb = &HuffmanCodeBooks [m_CodeBook [group][band]] ;
for (int groupwin = 0 ; groupwin < m_IcsInfo.GetWindowGroupLength (group) ; groupwin++)
{
if ((m_CodeBook [group][band] == ZERO_HCB) ||
(m_CodeBook [group][band] == INTENSITY_HCB) ||
(m_CodeBook [group][band] == INTENSITY_HCB2)
)
continue ;
int window = groupoffset + groupwin ;
int step = 0 ;
for (int index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index += step)
{
step = UnpackIndex (DecodeHuffmanWord (bs, hcb->CodeBook), &QuantizedCoef [window][index], hcb) ;
if (!hcb->IsSigned)
{
for (int i = 0 ; i < step ; i++)
{
if (QuantizedCoef [window][index + i])
{
if (bs.Get (1)) // sign bit
{
QuantizedCoef [window][index + i] = -QuantizedCoef [window][index + i] ;
}
}
}
}
if (m_CodeBook [group][band] == ESCBOOK)
{
QuantizedCoef [window][index] = GetEscape (bs, QuantizedCoef [window][index]) ;
QuantizedCoef [window][index + 1] = GetEscape (bs, QuantizedCoef [window][index + 1]) ;
}
}
}
}
groupoffset += m_IcsInfo.GetWindowGroupLength (group) ;
}
// // //
for (window = 0, group = 0 ; group < m_IcsInfo.GetWindowGroups () ; group++)
{
for (int groupwin = 0 ; groupwin < m_IcsInfo.GetWindowGroupLength (group) ; groupwin++, window++)
{
// dequantize
for (int index = 0 ; index < MaximumBins ; index++)
{
m_SpectralCoefficient [window][index] = InverseQuantize (QuantizedCoef [window][index]) ;
}
// apply scalefactors
for (int band = 0 ; band < m_IcsInfo.GetScaleFactorBandsTransmitted () ; band++)
{
float factor = static_cast<float>(m_ScaleFactor [group][band]) ;
if ((factor >= 0) && (factor < ExpTableSize))
{
factor = m_ExpTable [m_ScaleFactor [group][band]] ;
}
else
{
factor = static_cast<float>(pow (2.0F, 0.25F * factor)) ;
}
if (m_ScaleFactor [group][band] != -100)
{
for (int index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index++)
{
m_SpectralCoefficient [window][index] *= factor ;
}
}
else
{
for (int index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index++)
{
m_SpectralCoefficient [window][index] = 0.0F ;
}
}
}
}
}
}
void CShortBlock::TransformWindows (COverlapAddBuffer &Previous, float EightWindowsBuffer [])
{
for (int i = 0 ; i < 2048 ; i++)
{
EightWindowsBuffer [i] = 0 ;
}
for (int window = 0 ; window < MaximumWindows ; window++)
{
float *theSpectrum = m_SpectralCoefficient [window] ;
InverseTransform (theSpectrum) ;
if (window == 0)
{
for (int i = 0 ; i < 128 ; i++)
{
theSpectrum [i] *= m_ShortWindow [Previous.GetWindowShape ()][i] ;
theSpectrum [128 + i] *= m_ShortWindow [m_IcsInfo.GetWindowShape ()][127 - i] ;
}
}
else
{
for (int i = 0 ; i < 128 ; i++)
{
theSpectrum [i] *= m_ShortWindow [m_IcsInfo.GetWindowShape ()][i] ;
theSpectrum [128 + i] *= m_ShortWindow [m_IcsInfo.GetWindowShape ()][127 - i] ;
}
}
// overlap add the 8 windows in this block
for (int i = 0 ; i < 256 ; i++)
{
EightWindowsBuffer [448 + 128 * window + i] += theSpectrum [i] ;
}
}
Previous.SetWindowShape (m_IcsInfo.GetWindowShape ()) ;
}
/*
void CShortBlock::FrequencyToTime (COverlapAddBuffer &Previous, short Output [], const int stride)
{
float EightWindowsBuffer [2048] ;
TransformWindows (Previous, EightWindowsBuffer) ;
#if defined (WIN32) && defined (_M_IX86)
PentiumOverlap (m_Output, EightWindowsBuffer, Previous.AccessBuffer (), stride) ;
#else
for (int j = 0 ; j < 1024 ; j++)
{
// add first half and old data
Output [j * stride] = FloatToShort (EightWindowsBuffer [j] + Previous [j]) ;
// store second half as old data
Previous [j] = EightWindowsBuffer [1024 + j] ;
}
#endif
}
*/
void CShortBlock::FrequencyToTime_Fast (COverlapAddBuffer &Previous)
{
float EightWindowsBuffer [2048] ;
TransformWindows (Previous, EightWindowsBuffer) ;
#if defined (WIN32) && defined (_M_IX86)
PentiumOverlap (m_Output, EightWindowsBuffer, Previous.AccessBuffer (), 1) ;
#else
for (int j = 0 ; j < 1024 ; j++)
{
// add first half and old data
m_Output [j] = EightWindowsBuffer [j] + Previous [j];
// store second half as old data
Previous [j] = EightWindowsBuffer [1024 + j] ;
}
#endif
}
void CShortBlock::FrequencyToTime (COverlapAddBuffer &Previous, float Output [], const int stride)
{
float EightWindowsBuffer [2048] ;
TransformWindows (Previous, EightWindowsBuffer) ;
for (int j = 0 ; j < 1024 ; j++)
{
// add first half and old data
Output [j * stride] = EightWindowsBuffer [j] + Previous [j] ;
// store second half as old data
Previous [j] = EightWindowsBuffer [1024 + j] ;
}
}
void CShortBlock::FrequencyToTime (COverlapAddBuffer &Previous)
{
float EightWindowsBuffer [2048] ;
TransformWindows (Previous, EightWindowsBuffer) ;
for (int j = 0 ; j < 1024 ; j++)
{
m_Output [j] = EightWindowsBuffer [j] + Previous [j] ;
Previous [j] = EightWindowsBuffer [1024 + j] ;
}
}
void CShortBlock::ApplyEqualizationMask (float Mask [])
{
for (int window = 0 ; window < MaximumWindows ; window++)
{
for (int i = 0 ; i < EqualizationMaskLength ; i++)
{
for (int j = 0 ; j < (MaximumBins / EqualizationMaskLength) ; j++)
{
m_SpectralCoefficient [window][(MaximumBins / EqualizationMaskLength) * i + j] *= Mask [i] ;
}
}
}
}

View File

@ -1,158 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/stereo.cpp,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: stereo.cpp
* project : MPEG-2 AAC Decoder
* contents/description: mid/side and intensity stereo processing
*
\***************************************************************************/
#include <math.h>
#include "stereo.h"
#include "bitstream.h"
#include "channelinfo.h"
#include "block.h"
CJointStereo::CJointStereo ()
: m_MsMaskPresent (2)
{
}
CJointStereo::~CJointStereo ()
{
}
void CJointStereo::Read (const CChannelInfo &info, CDolbyBitStream &bs)
{
m_MsMaskPresent.Read (bs) ;
int group, band ;
switch (m_MsMaskPresent)
{
case 0 : // no M/S
for (group = 0 ; group < info.GetWindowGroups () ; group++)
{
for (band = 0 ; band < info.GetScaleFactorBandsTransmitted () ; band++)
{
m_MsUsed [group][band] = false ;
}
}
break ;
case 1 : // read ms_used
for (group = 0 ; group < info.GetWindowGroups () ; group++)
{
for (band = 0 ; band < info.GetScaleFactorBandsTransmitted () ; band++)
{
m_MsUsed [group][band] = bs.Get (1) ? true : false ;
}
}
break ;
case 2 : // full spectrum M/S
for (group = 0 ; group < info.GetWindowGroups () ; group++)
{
for (band = 0 ; band < info.GetScaleFactorBandsTransmitted () ; band++)
{
m_MsUsed [group][band] = true ;
}
}
break ;
}
}
// mid / side
void CJointStereo::ApplyMS (const CChannelInfo &info, CBlock &left, CBlock &right)
{
const int *BandOffsets = info.GetScaleFactorBandOffsets () ;
for (int window = 0, group = 0 ; group < info.GetWindowGroups () ; group++)
{
for (int groupwin = 0 ; groupwin < info.GetWindowGroupLength (group) ; groupwin++, window++)
{
float *LeftSpectrum = left.AccessSpectralData (window) ;
float *RightSpectrum = right.AccessSpectralData (window) ;
for (int band = 0 ; band < info.GetScaleFactorBandsTransmitted () ; band++)
{
if (m_MsUsed [group][band] == true)
{
for (int index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index++)
{
float LeftCoefficient = LeftSpectrum [index] ;
float RightCoefficient = RightSpectrum [index] ;
LeftSpectrum [index] = LeftCoefficient + RightCoefficient ;
RightSpectrum [index] = LeftCoefficient - RightCoefficient ;
}
}
}
}
}
}
// intensity
void CJointStereo::ApplyIS (const CChannelInfo &info, CBlock &left, CBlock &right)
{
const int *BandOffsets = info.GetScaleFactorBandOffsets () ;
for (int window = 0, group = 0 ; group < info.GetWindowGroups () ; group++)
{
int *CodeBook = right.AccessCodeBooks (group) ;
int *ScaleFactor = right.AccessScaleFactors (group) ;
for (int groupwin = 0 ; groupwin < info.GetWindowGroupLength (group) ; groupwin++, window++)
{
float *LeftSpectrum = left.AccessSpectralData (window) ;
float *RightSpectrum = right.AccessSpectralData (window) ;
for (int band = 0 ; band < info.GetScaleFactorBandsTransmitted () ; band++)
{
if ((CodeBook [band] == CBlock::INTENSITY_HCB) ||
(CodeBook [band] == CBlock::INTENSITY_HCB2)
)
{
float scale = (float) pow (0.5F, 0.25F * (ScaleFactor [band] + 100)) ;
if (m_MsUsed [group][band])
{
if (CodeBook [band] == CBlock::INTENSITY_HCB) // _NOT_ in-phase
{
scale *= -1 ;
}
}
else
{
if (CodeBook [band] == CBlock::INTENSITY_HCB2) // out-of-phase
{
scale *= -1 ;
}
}
for (int index = BandOffsets [band] ; index < BandOffsets [band + 1] ; index++)
{
RightSpectrum [index] = LeftSpectrum [index] * scale ;
}
}
}
}
}
}

View File

@ -1,62 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/stereo.h,v 1.1 2009/04/28 20:21:10 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: stereo.h
* project : MPEG-2 AAC Decoder
* contents/description: mid/side and intensity stereo processing
*
\***************************************************************************/
#ifndef __STEREO_H__
#define __STEREO_H__
#include "bitsequence.h"
class CChannelInfo ;
class CBlock ;
/** Joint Stereo Processing.
This class represents the stereo processing tool for decoding mid/side and
intensity coded bands of spectral coefficients.
The Stereo Processing tool is not profile-dependent and the CJointStereo
implementation follows the Read()/Apply() convention used for all tools
as far as applicable.
*/
class CJointStereo
{
public :
CJointStereo () ;
~CJointStereo () ;
void Read (const CChannelInfo &info, CDolbyBitStream &bs) ;
void ApplyMS (const CChannelInfo &info, CBlock &left, CBlock &right) ;
void ApplyIS (const CChannelInfo &info, CBlock &left, CBlock &right) ;
protected :
enum
{
MaximumGroups = 8,
MaximumBands = 64
} ;
bool m_MsUsed [CJointStereo::MaximumGroups][CJointStereo::MaximumBands] ;
CVLBBitSequence m_MsMaskPresent ;
} ;
#endif

View File

@ -1,394 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/streaminfo.h,v 1.1 2009/04/28 20:21:11 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: streaminfo.h
* project : MPEG-2 AAC Decoder
* contents/description: current bitstream parameters
*
\***************************************************************************/
#ifndef __STREAMINFO_H__
#define __STREAMINFO_H__
#define COPYRIGHT_SIZE 9
#define BYTE_SIZE 8
typedef struct
{
unsigned int m_SamplingRateIndex ;
unsigned int m_SamplingRate ;
unsigned int m_Profile ;
unsigned int m_ChannelConfig ;
unsigned int m_Channels ;
unsigned int m_BitRate ;
unsigned int m_ProtectionAbsent;
unsigned int m_OriginalCopy;
unsigned int m_Home;
char m_CopyrightID[COPYRIGHT_SIZE];
unsigned int m_FrameLength;
unsigned int m_ChannelMask ;
unsigned int m_NumberOfFrontChannels ;
unsigned int m_NumberOfSideChannels ;
unsigned int m_NumberOfBackChannels ;
unsigned int m_NumberOfLfeChannels ;
unsigned int m_ADTSFrameLength;
unsigned int m_ADTSNumberOfRawDataBlocks;
bool m_UseDblLengthXfrm;
} STREAMINFO, * PSTREAMINFO ;
#ifdef __cplusplus
/** Stream Configuration and Information.
This class holds configuration and information data for a stream to be decoded. It
provides the calling application as well as the decoder with substantial information,
e.g. profile, sampling rate, number of channels found in the bitstream etc.
*/
class CStreamInfo : protected STREAMINFO
{
public :
/// Object Constructor. Initializes all the STREAMINFO members to zero.
CStreamInfo ()
{
m_SamplingRateIndex = 0 ;
m_SamplingRate = 0 ;
m_Profile = 0 ;
m_ChannelConfig = 0 ;
m_Channels = 0 ;
m_BitRate = 0 ;
m_UseDblLengthXfrm = false;
}
virtual ~CStreamInfo()
{
}
void SetUseDblLengthXfrm(bool flag)
{
m_UseDblLengthXfrm = flag;
}
/// Configures the sampling rate by index.
void SetSamplingRateIndex (unsigned int sf)
{
m_SamplingRateIndex = sf ;
}
/// Retrieves the sampling rate by index.
unsigned int GetSamplingRateIndex (void) const
{
return m_SamplingRateIndex ;
}
/// Configures the decoder profile.
void SetProfile (unsigned int profile)
{
m_Profile = profile ;
}
/// Retrieves the decoder profile.
unsigned int GetProfile (void) const
{
return m_Profile ;
}
/// Configures the channel configuration.
void SetChannelConfig (unsigned int config)
{
m_ChannelConfig = config ;
}
/// Retrieves the channel configuration.
unsigned int GetChannelConfig (void) const
{
return m_ChannelConfig ;
}
/// Configures the number of decoded channels (by value).
void SetChannels (unsigned int chan)
{
m_Channels = chan ;
}
/// Configures the number of decoded channels (incrementally).
void IncChannels (unsigned int chan)
{
m_Channels += chan ;
}
/// Retrieves the number of decoded channels.
unsigned int GetChannels (void) const
{
return m_Channels ;
}
/// Configures the bitrate.
void SetBitRate (unsigned int bps)
{
m_BitRate = bps ;
}
/// Retrieves the bitrate.
unsigned int GetBitRate (void) const
{
return m_BitRate ;
}
/// Configures the sampling rate by value.
void SetSamplingRate (unsigned int sf)
{
m_SamplingRate = sf ;
}
/// Retrieves the sampling rate by value.
unsigned int GetSamplingRate (void) const
{
if (m_UseDblLengthXfrm)
{
return m_SamplingRate << 1;
}
else
{
return m_SamplingRate ;
}
}
/// Retrieves the sampling rate by value.
unsigned int GetRawSamplingRate (void) const
{
return m_SamplingRate ;
}
/// Configures the protection absent flag.
void SetProtectionAbsent (unsigned int pa)
{
m_ProtectionAbsent = pa ;
}
/// Retrieves the protection absent flag.
unsigned int GetProtectionAbsent (void) const
{
return m_ProtectionAbsent ;
}
/// Configures the original copy flag.
void SetOriginalCopy (unsigned int oc)
{
m_OriginalCopy = oc ;
}
/// Retrieves the original copy flag.
unsigned int GetOriginalCopy (void) const
{
return m_OriginalCopy ;
}
/// Configures the home flag.
void SetHome (unsigned int h)
{
m_Home = h ;
}
/// Retrieves the home flag.
unsigned int GetHome (void) const
{
return m_Home ;
}
/// Configures the copyright id.
void SetCopyrightID (char cid, int index)
{
m_CopyrightID[index] = cid ;
}
/// Retrieves the copyright id.
char GetCopyrightID (int index) const
{
return m_CopyrightID[index] ;
}
/// Configures the frame length.
void SetFrameLength (unsigned int fl)
{
m_FrameLength = fl ;
}
/// Retrieves the frame length.
unsigned int GetFrameLength (void) const
{
return m_FrameLength ;
}
// Configures the channel present indicator mask
void SetChannelMask (unsigned int channelMask)
{
m_ChannelMask = channelMask ;
}
/// Retrieves the channel present indicator mask
unsigned int GetChannelMask (void)
{
return m_ChannelMask ;
}
/// Configures the number of front channels
void SetNumberOfFrontChannels (unsigned int frontChannels)
{
m_NumberOfFrontChannels = frontChannels ;
}
/// Retrieves the number of front channels
int GetNumberOfFrontChannels (void)
{
return m_NumberOfFrontChannels ;
}
/// Configures the number of side channels
void SetNumberOfSideChannels (unsigned int sideChannels)
{
m_NumberOfSideChannels = sideChannels ;
}
/// Retrieves the number of side channels
int GetNumberOfSideChannels (void)
{
return m_NumberOfSideChannels ;
}
/// Configures the number of back channels
void SetNumberOfBackChannels (unsigned int backChannels)
{
m_NumberOfBackChannels = backChannels ;
}
/// Retrieves the number of back channels
int GetNumberOfBackChannels (void)
{
return m_NumberOfBackChannels ;
}
// Configures the number of Low Frequency Enhancement channels
void SetNumberOfLfeChannels (unsigned int lfeChannels)
{
m_NumberOfLfeChannels = lfeChannels ;
}
// Retrieves the number of Low Frequency Enhancement channels
int GetNumberOfLfeChannels (void)
{
return m_NumberOfLfeChannels ;
}
//
enum
{
SamplesPerFrame = 1024
} ;
/// Retrieves the number of delivered samples per audio frame.
unsigned int GetSamplesPerFrame (void) const
{
return SamplesPerFrame ;
}
/// Retrieves the number of delivered bytes per audio frame
unsigned int GetOutputBytes (void) const
{
return GetSamplesPerFrame () * GetChannels () * sizeof (short) ;
}
void setSampleRate();
} ;
#endif
/// constants for speaker positions and channel index mapping
enum
{
Channel_FrontLeft = 0,
Channel_FrontRight = 1,
Channel_FrontCenter = 2,
Channel_LowFrequency = 3,
Channel_BackLeft = 4,
Channel_BackRight = 5,
Channel_FrontLeftOfCenter = 6,
Channel_FrontRightOfCenter = 7,
Channel_BackCenter = 8,
Channel_SideLeft = 9,
Channel_SideRight = 10,
Speaker_StandardPositions,
Speaker_FrontLeft = 1 << Channel_FrontLeft,
Speaker_FrontRight = 1 << Channel_FrontRight,
Speaker_FrontCenter = 1 << Channel_FrontCenter,
Speaker_LowFrequency = 1 << Channel_LowFrequency,
Speaker_BackLeft = 1 << Channel_BackLeft,
Speaker_BackRight = 1 << Channel_BackRight,
Speaker_FrontLeftOfCenter = 1 << Channel_FrontLeftOfCenter,
Speaker_FrontRightOfCenter = 1 << Channel_FrontRightOfCenter,
Speaker_BackCenter = 1 << Channel_BackCenter,
Speaker_SideLeft = 1 << Channel_SideLeft,
Speaker_SideRight = 1 << Channel_SideRight,
Speaker_FrontSpeakers = Speaker_FrontLeft + Speaker_FrontRight + Speaker_FrontCenter
} ;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,214 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/tns.cpp,v 1.1 2009/04/28 20:21:11 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: tns.cpp
* project : MPEG-2 AAC Decoder
* contents/description: temporal noise shaping
*
\***************************************************************************/
#include <math.h>
#include "tns.h"
#include "channelinfo.h"
#include "block.h"
CTns::CTns ()
: m_TnsDataPresent (1)
{
}
CTns::~CTns ()
{
}
void CTns::Read (const CChannelInfo &info, CDolbyBitStream &bs)
{
m_TnsDataPresent.Read (bs) ;
if (!m_TnsDataPresent) return ;
CVLBBitSequence n_filt (info.IsLongBlock () ? 2 : 1) ;
CVLBBitSequence length (info.IsLongBlock () ? 6 : 4) ;
CVLBBitSequence order (info.IsLongBlock () ? 5 : 3) ;
CVLBBitSequence direction (1) ;
CVLBBitSequence coef_compress (1) ;
CVLBBitSequence coef_res (1) ;
for (int window = 0 ; window < info.GetWindowsPerFrame () ; window++)
{
m_NumberOfFilters [window] = n_filt.Read (bs) ;
if (n_filt)
{
coef_res.Read (bs) ;
int nextstopband = info.GetScaleFactorBandsTotal () ;
for (int index = 0 ; index < n_filt ; index++)
{
CFilter &filter = m_Filter [window][index] ;
length.Read (bs) ;
filter.m_StartBand = nextstopband - length ;
filter.m_StopBand = nextstopband ;
nextstopband = filter.m_StartBand ;
filter.m_Order = order.Read (bs) ;
if (order)
{
filter.m_Direction = direction.Read (bs) ? -1 : 1 ;
coef_compress.Read (bs) ;
filter.m_Resolution = coef_res + 3 ;
static const int sgn_mask [] = { 0x2, 0x4, 0x8 } ;
static const int neg_mask [] = { ~0x3, ~0x7, ~0xF } ;
int s_mask = sgn_mask [coef_res + 1 - coef_compress] ;
int n_mask = neg_mask [coef_res + 1 - coef_compress] ;
for (int i = 0 ; i < order ; i++)
{
CVLBBitSequence coef (filter.m_Resolution - coef_compress) ;
coef.Read (bs) ;
filter.m_Coeff [i] = ((int) coef & s_mask) ? ((int) coef | n_mask) : (int) coef ;
}
}
}
}
}
}
void CTns::Apply (const CChannelInfo &info, CBlock &spectrum)
{
if (!m_TnsDataPresent) return ;
float CoeffLPC [MaximumOrder + 1] ;
for (int window = 0 ; window < info.GetWindowsPerFrame () ; window++)
{
for (int index = 0 ; index < m_NumberOfFilters [window] ; index++)
{
CFilter &filter = m_Filter [window][index] ;
DecodeCoefficients (filter, CoeffLPC) ;
int start = Minimum (filter.m_StartBand, info.GetMaximumTnsBands (),
info.GetScaleFactorBandsTransmitted ()) ;
start = info.GetScaleFactorBandOffsets () [start] ;
int stop = Minimum (filter.m_StopBand, info.GetMaximumTnsBands (),
info.GetScaleFactorBandsTransmitted ()) ;
stop = info.GetScaleFactorBandOffsets () [stop] ;
int size = stop - start ;
if (size <= 0) continue ;
Filter (&spectrum.AccessSpectralData (window) [start], size,
filter.m_Direction, CoeffLPC, filter.m_Order) ;
}
}
}
void CTns::DecodeCoefficients (CFilter &filter, float *a)
{
float tmp [MaximumOrder + 1], b [MaximumOrder + 1] ;
// Inverse quantization
const float pi2 = 3.14159265358979323846F / 2.0F ;
float iqfac = ((1 << (filter.m_Resolution - 1)) - 0.5F) / pi2 ;
float iqfac_m = ((1 << (filter.m_Resolution - 1)) + 0.5F) / pi2 ;
int i ;
for (i = 0 ; i < filter.m_Order ; i++)
{
tmp [i + 1] = (float) sin (filter.m_Coeff [i] / ((filter.m_Coeff [i] >= 0) ? iqfac : iqfac_m)) ;
}
// Conversion to LPC coefficients - Markel and Gray, pg. 95
a [0] = 1.0F ;
for (int m = 1 ; m <= filter.m_Order ; m++)
{
b [0] = a [0] ;
for (i = 1 ; i < m ; i++)
{
b [i] = a [i] + tmp [m] * a [m - i] ;
}
b [m] = tmp [m] ;
for (i = 0 ; i <= m ; i++)
{
a [i] = b [i] ;
}
}
}
void CTns::Filter (float *spec, int size, int inc, float *lpc, int order)
{
// - Simple all-pole filter of order "order" defined by
// y(n) = x(n) - a(2)*y(n-1) - ... - a(order+1)*y(n-order)
//
// - The state variables of the filter are initialized to zero every time
//
// - The output data is written over the input data ("in-place operation")
//
// - An input vector of "size" samples is processed and the index increment
// to the next data sample is given by "inc"
int i, j;
float y, state [MaximumOrder] ;
for (i = 0 ; i < order ; i++)
{
state [i] = 0.0F ;
}
if (inc == -1)
{
spec += size - 1 ;
}
for (i = 0 ; i < size ; i++)
{
y = *spec;
for (j = 0 ; j < order ; j++)
{
y -= lpc [j + 1] * state [j] ;
}
for (j = order - 1 ; j > 0 ; j--)
{
state [j] = state [j - 1] ;
}
state [0] = y ;
*spec = y ;
spec += inc ;
}
}

View File

@ -1,86 +0,0 @@
/* $Header: /cvs/root/winamp/vlb/tns.h,v 1.1 2009/04/28 20:21:11 audiodsp Exp $ */
/***************************************************************************\
*
* Copyright 2000-2002 Dolby Laboratories, Inc. All Rights
* Reserved. Do not copy. Do not distribute.
* Confidential information.
*
* (C) copyright Fraunhofer - IIS (1998)
* All Rights Reserved
*
* filename: tns.h
* project : MPEG-2 AAC Decoder
* contents/description: temporal noise shaping
*
\***************************************************************************/
#ifndef __TNS_H__
#define __TNS_H__
#include "bitsequence.h"
class CChannelInfo ;
class CBlock ;
/** Temporal Noise Shaping.
This class represents the temporal noise shaping tool for decoding and
applying tns filter data to the spectral coefficients of the current block.
TNS is a profile-dependent tool and the CTns implementation follows the
Read()/Apply() convention used for all tools.
*/
class CTns
{
public :
CTns () ;
~CTns () ;
void Read (const CChannelInfo &info, CDolbyBitStream &bs) ;
void Apply (const CChannelInfo &info, CBlock &spectrum) ;
enum
{
MaximumWindows = 8,
MaximumBands = 49,
MaximumOrder = 31,
MaximumFilters = 3
} ;
protected :
CVLBBitSequence m_TnsDataPresent ;
class CFilter
{
public :
int m_StartBand ;
int m_StopBand ;
int m_Direction ;
int m_Resolution ;
int m_Order ;
int m_Coeff [MaximumOrder] ;
} ;
int m_NumberOfFilters [MaximumWindows] ;
CFilter m_Filter [MaximumWindows][MaximumFilters] ;
int Minimum (int a, int b, int c)
{
int t = (a < b ) ? a : b ;
return (t < c) ? t : c ;
}
void DecodeCoefficients (CFilter &filter, float *a) ;
void Filter (float *spec, int size, int inc, float *lpc, int order) ;
} ;
#endif

View File

@ -1,39 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
#include "../Winamp/buildType.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION WINAMP_PRODUCTVER
PRODUCTVERSION WINAMP_PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Winamp SA"
VALUE "FileDescription", "Winamp 5.x System Component"
VALUE "FileVersion", STR_WINAMP_PRODUCTVER
VALUE "InternalName", "vlb.w5s"
VALUE "LegalCopyright", "Copyright © 2005-2023 Winamp SA"
VALUE "LegalTrademarks", "Nullsoft and Winamp are trademarks of Winamp SA"
VALUE "OriginalFilename", "vlb.w5s"
VALUE "ProductName", "Winamp VLB Decoder Service"
VALUE "ProductVersion", STR_WINAMP_PRODUCTVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

View File

@ -1,76 +0,0 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource1.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource1.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#include ""version.rc2""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#include "version.rc2"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,30 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vlb", "vlb.vcxproj", "{2E7AB185-8E16-4458-BF5A-853B6619CC3B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2E7AB185-8E16-4458-BF5A-853B6619CC3B}.Debug|Win32.ActiveCfg = Debug|Win32
{2E7AB185-8E16-4458-BF5A-853B6619CC3B}.Debug|Win32.Build.0 = Debug|Win32
{2E7AB185-8E16-4458-BF5A-853B6619CC3B}.Debug|x64.ActiveCfg = Debug|x64
{2E7AB185-8E16-4458-BF5A-853B6619CC3B}.Debug|x64.Build.0 = Debug|x64
{2E7AB185-8E16-4458-BF5A-853B6619CC3B}.Release|Win32.ActiveCfg = Release|Win32
{2E7AB185-8E16-4458-BF5A-853B6619CC3B}.Release|Win32.Build.0 = Release|Win32
{2E7AB185-8E16-4458-BF5A-853B6619CC3B}.Release|x64.ActiveCfg = Release|x64
{2E7AB185-8E16-4458-BF5A-853B6619CC3B}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {74224C5F-B8F5-4611-AA1F-A0CD1F71234B}
EndGlobalSection
EndGlobal

View File

@ -1,324 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2E7AB185-8E16-4458-BF5A-853B6619CC3B}</ProjectGuid>
<RootNamespace>vlb</RootNamespace>
<WindowsTargetPlatformVersion>10.0.19041.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(PlatformShortName)_$(Configuration)\</OutDir>
<IntDir>$(PlatformShortName)_$(Configuration)\</IntDir>
<TargetExt>.w5s</TargetExt>
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(PlatformShortName)_$(Configuration)\</OutDir>
<IntDir>$(PlatformShortName)_$(Configuration)\</IntDir>
<TargetExt>.w5s</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(PlatformShortName)_$(Configuration)\</OutDir>
<IntDir>$(PlatformShortName)_$(Configuration)\</IntDir>
<TargetExt>.w5s</TargetExt>
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(PlatformShortName)_$(Configuration)\</OutDir>
<IntDir>$(PlatformShortName)_$(Configuration)\</IntDir>
<TargetExt>.w5s</TargetExt>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<VcpkgConfiguration>Debug</VcpkgConfiguration>
<VcpkgTriplet>x86-windows-static-md</VcpkgTriplet>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<VcpkgTriplet>x86-windows-static-md</VcpkgTriplet>
<VcpkgConfiguration>Debug</VcpkgConfiguration>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<VcpkgTriplet>x86-windows-static-md</VcpkgTriplet>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<VcpkgTriplet>x86-windows-static-md</VcpkgTriplet>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<ImportLibrary>$(ProjectDir)x86_Debug\$(ProjectName).lib</ImportLibrary>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\
xcopy /Y /D $(IntDir)$(TargetName).pdb ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\ </Command>
<Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\'</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<ImportLibrary>$(ProjectDir)x64_Debug\$(ProjectName).lib</ImportLibrary>
<SubSystem>Windows</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<PostBuildEvent>
<Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\
xcopy /Y /D $(IntDir)$(TargetName).pdb ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\ </Command>
<Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\'</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>../Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<ImportLibrary>$(ProjectDir)x86_Release\$(ProjectName).lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<PostBuildEvent>
<Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\ </Command>
<Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\'</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MinSpace</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>../Wasabi;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>true</BufferSecurityCheck>
<FunctionLevelLinking>true</FunctionLevelLinking>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<ForceConformanceInForLoopScope>true</ForceConformanceInForLoopScope>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<ProgramDataBaseFileName>$(IntDir)$(TargetName).pdb</ProgramDataBaseFileName>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<ImportLibrary>$(ProjectDir)x64_Release\$(ProjectName).lib</ImportLibrary>
<SubSystem>Windows</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<PostBuildEvent>
<Command>xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\ </Command>
<Message>Post build event: 'xcopy /Y /D $(OutDir)$(TargetName)$(TargetExt) ..\..\Build\Winamp_$(PlatformShortName)_$(Configuration)\System\'</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="aacdecoder.cpp" />
<ClCompile Include="aacdecoderapi.cpp" />
<ClCompile Include="adif.cpp" />
<ClCompile Include="audio_io.cpp" />
<ClCompile Include="audio_io_dsp.cpp" />
<ClCompile Include="bitbuffer.cpp" />
<ClCompile Include="bitsequence.cpp" />
<ClCompile Include="block.cpp" />
<ClCompile Include="channel.cpp" />
<ClCompile Include="channelinfo.cpp" />
<ClCompile Include="datastream.cpp" />
<ClCompile Include="DolbyPayload.cpp" />
<ClCompile Include="dolby_imdct.cpp" />
<ClCompile Include="factory_nsvVlb.cpp" />
<ClCompile Include="factory_vlbDecoder.cpp" />
<ClCompile Include="fft.cpp" />
<ClCompile Include="imdct.cpp" />
<ClCompile Include="longblock.cpp" />
<ClCompile Include="NSVFactory.cpp" />
<ClCompile Include="nsv_vlb.cpp" />
<ClCompile Include="obj_vlbDecoder.cpp" />
<ClCompile Include="plainfile.cpp" />
<ClCompile Include="prediction.cpp" />
<ClCompile Include="programcfg.cpp" />
<ClCompile Include="pulsedata.cpp" />
<ClCompile Include="shortblock.cpp" />
<ClCompile Include="stereo.cpp" />
<ClCompile Include="tables.cpp" />
<ClCompile Include="tns.cpp" />
<ClCompile Include="VlbDecoder.cpp" />
<ClCompile Include="VLBIO.cpp" />
<ClCompile Include="w5s.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="aacdecoder.h" />
<ClInclude Include="aacdecoderapi.h" />
<ClInclude Include="adif.h" />
<ClInclude Include="api__vlb.h" />
<ClInclude Include="audio_io.h" />
<ClInclude Include="audio_io_dsp.h" />
<ClInclude Include="bitbuffer.h" />
<ClInclude Include="bitsequence.h" />
<ClInclude Include="bitstream.h" />
<ClInclude Include="block.h" />
<ClInclude Include="channel.h" />
<ClInclude Include="channelinfo.h" />
<ClInclude Include="DataIO.h" />
<ClInclude Include="datastream.h" />
<ClInclude Include="DolbyPayload.h" />
<ClInclude Include="dolby_imdct.h" />
<ClInclude Include="exception.h" />
<ClInclude Include="factory_nsvVlb.h" />
<ClInclude Include="factory_vlbDecoder.h" />
<ClInclude Include="fft.h" />
<ClInclude Include="NSVFactory.h" />
<ClInclude Include="nsv_vlb.h" />
<ClInclude Include="obj_vlbDecoder.h" />
<ClInclude Include="overlapadd.h" />
<ClInclude Include="plainfile.h" />
<ClInclude Include="prediction.h" />
<ClInclude Include="programcfg.h" />
<ClInclude Include="pulsedata.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="resource1.h" />
<ClInclude Include="stereo.h" />
<ClInclude Include="streaminfo.h" />
<ClInclude Include="tns.h" />
<ClInclude Include="VlbDecoder.h" />
<ClInclude Include="window_tab.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="vlb.rc" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Wasabi\Wasabi.vcxproj">
<Project>{3e0bfa8a-b86a-42e9-a33f-ec294f823f7f}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,224 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="w5s.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="VLBIO.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="VlbDecoder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tns.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tables.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stereo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="shortblock.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pulsedata.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="programcfg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="prediction.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="plainfile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="obj_vlbDecoder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NSVFactory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="nsv_vlb.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="longblock.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="imdct.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="fft.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="factory_vlbDecoder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="factory_nsvVlb.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dolby_imdct.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DolbyPayload.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="datastream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="channelinfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="channel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="block.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="bitsequence.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="bitbuffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="audio_io_dsp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="audio_io.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="adif.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="aacdecoderapi.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="aacdecoder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="aacdecoder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="aacdecoderapi.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="adif.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="api__vlb.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="audio_io.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="audio_io_dsp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bitbuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bitsequence.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="bitstream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="block.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="channel.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="channelinfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DataIO.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="datastream.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dolby_imdct.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DolbyPayload.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="exception.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="factory_nsvVlb.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="factory_vlbDecoder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="fft.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nsv_vlb.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="NSVFactory.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="obj_vlbDecoder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="overlapadd.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="plainfile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="prediction.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="programcfg.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pulsedata.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stereo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="streaminfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="tns.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="VlbDecoder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="window_tab.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{2b3efc06-1046-47a4-956e-af652b688c1f}</UniqueIdentifier>
</Filter>
<Filter Include="Ressource Files">
<UniqueIdentifier>{0398d98a-dea2-4fea-bf3b-abb9658ea82f}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{21521068-58d4-46cd-91ed-25876514b0f0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="vlb.rc">
<Filter>Ressource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -1,20 +0,0 @@
#pragma once
#define BUFSIZE 16384
#define OBUFSIZE 65536
#include "audio_io.h"
class VLBOut : public AudioIOControl {
public:
VLBOut() { size = pos = 0; }
virtual ~VLBOut() { }
virtual int IO( float **, int );
virtual int SetFormatInfo( AUDIO_FORMATINFO *info ) { format = *info; return AUDIO_ERROR_NONE; }
AUDIO_FORMATINFO GetFormatInfo() { return format; }
int BytesAvail() { return size; }
virtual void PullBytes( unsigned char *buf, int nbytes );
void Empty(){ size = 0; }
private:
unsigned char data[OBUFSIZE];
int size,pos;
AUDIO_FORMATINFO format;
};

View File

@ -1,78 +0,0 @@
#include "factory_vlbDecoder.h"
#include "factory_nsvVlb.h"
#include "api__vlb.h"
#include <bfc/platform/export.h>
#include "../Agave/Component/ifc_wa5component.h"
class VLBComponent : public ifc_wa5component
{
public:
void RegisterServices(api_service *service);
int RegisterServicesSafeModeOk();
void DeregisterServices(api_service *service);
protected:
RECVS_DISPATCH;
};
template <class api_T>
void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
{
if (WASABI_API_SVC)
{
waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
if (factory)
api_t = reinterpret_cast<api_T *>( factory->getInterface() );
}
}
template <class api_T>
void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
{
if (WASABI_API_SVC && api_t)
{
waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
if (factory)
factory->releaseInterface(api_t);
}
api_t = NULL;
}
VLBDecoderFactory vlbDecoderFactory;
NSVVLBFactory nsvDecoderFactory;
VLBComponent vlbComponent;
api_service *WASABI_API_SVC=0;
api_memmgr *WASABI_API_MEMMGR = 0;
void VLBComponent::RegisterServices(api_service *service)
{
WASABI_API_SVC = service;
WASABI_API_SVC->service_register(&vlbDecoderFactory);
WASABI_API_SVC->service_register(&nsvDecoderFactory);
ServiceBuild(WASABI_API_MEMMGR, memMgrApiServiceGuid);
}
int VLBComponent::RegisterServicesSafeModeOk()
{
return 1;
}
void VLBComponent::DeregisterServices(api_service *service)
{
service->service_deregister(&vlbDecoderFactory);
service->service_deregister(&nsvDecoderFactory);
ServiceRelease(WASABI_API_MEMMGR, memMgrApiServiceGuid);
}
extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
{
return &vlbComponent;
}
#define CBCLASS VLBComponent
START_DISPATCH;
VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
CB(15, RegisterServicesSafeModeOk)
VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
END_DISPATCH;
#undef CBCLASS

File diff suppressed because it is too large Load Diff