aboutsummaryrefslogtreecommitdiff
path: root/Src/aacdec
diff options
context:
space:
mode:
Diffstat (limited to 'Src/aacdec')
-rw-r--r--Src/aacdec/ADTSAACDecoder.cpp387
-rw-r--r--Src/aacdec/ADTSAACDecoder.h42
-rw-r--r--Src/aacdec/ADTSHeader.c110
-rw-r--r--Src/aacdec/ADTSHeader.h34
-rw-r--r--Src/aacdec/AVIAACDecoder.cpp173
-rw-r--r--Src/aacdec/AVIAACDecoder.h41
-rw-r--r--Src/aacdec/FLVAACDecoder.cpp159
-rw-r--r--Src/aacdec/FLVAACDecoder.h45
-rw-r--r--Src/aacdec/MKVAACDecoder.cpp159
-rw-r--r--Src/aacdec/MKVAACDecoder.h48
-rw-r--r--Src/aacdec/MP4AACDecoder.cpp236
-rw-r--r--Src/aacdec/MP4AACDecoder.h40
-rw-r--r--Src/aacdec/NSVAACDecoder.cpp229
-rw-r--r--Src/aacdec/NSVAACDecoder.h52
-rw-r--r--Src/aacdec/aacdec.rc76
-rw-r--r--Src/aacdec/aacdec.sln20
-rw-r--r--Src/aacdec/aacdec.vcproj356
-rw-r--r--Src/aacdec/api.cpp5
-rw-r--r--Src/aacdec/api.h14
-rw-r--r--Src/aacdec/incs/bitbuffer_c.h96
-rw-r--r--Src/aacdec/incs/mp4AudioDecIfc.h160
-rw-r--r--Src/aacdec/incs/mp4dec_asc/audioobjecttypes.h89
-rw-r--r--Src/aacdec/incs/mp4dec_asc/audiospecificconfig_c.h127
-rw-r--r--Src/aacdec/incs/mp4dec_asc/celpspecificconfig_c.h64
-rw-r--r--Src/aacdec/incs/mp4dec_asc/eldspecificconfig_c.h75
-rw-r--r--Src/aacdec/incs/mp4dec_asc/epspecificconfig_c.h89
-rw-r--r--Src/aacdec/incs/mp4dec_asc/gaspecificconfig_c.h61
-rw-r--r--Src/aacdec/incs/mp4dec_asc/hvxcspecificconfig_c.h43
-rw-r--r--Src/aacdec/incs/mp4dec_asc/mpeg12specificconfig_c.h43
-rw-r--r--Src/aacdec/incs/mp4dec_asc/programcfg_c.h140
-rw-r--r--Src/aacdec/incs/mp4dec_asc/slsspecificconfig_c.h51
-rw-r--r--Src/aacdec/incs/mp4dec_asc/spatialspecificconfig_c.h49
-rw-r--r--Src/aacdec/incs/mp4dec_helpers/aubuffer_c.h62
-rw-r--r--Src/aacdec/incs/mp4dec_helpers/bitstream_c.h83
-rw-r--r--Src/aacdec/incs/mp4dec_helpers/cubuffer_c.h340
-rw-r--r--Src/aacdec/incs/mp4dec_helpers/err_code.h84
-rw-r--r--Src/aacdec/incs/mp4dec_helpers/machine.h101
-rw-r--r--Src/aacdec/incs/mp4dec_helpers/usrparam.h138
-rw-r--r--Src/aacdec/incs/sac_dec_ssc_struct.h272
-rw-r--r--Src/aacdec/libs/Win32/HdAacDeclib.libbin0 -> 213874 bytes
-rw-r--r--Src/aacdec/libs/Win32/concealMDCTlib.libbin0 -> 85576 bytes
-rw-r--r--Src/aacdec/libs/Win32/fdreverblib.libbin0 -> 16552 bytes
-rw-r--r--Src/aacdec/libs/Win32/libirc.libbin0 -> 375334 bytes
-rw-r--r--Src/aacdec/libs/Win32/limiterlib.libbin0 -> 8606 bytes
-rw-r--r--Src/aacdec/libs/Win32/mathlib.libbin0 -> 174798 bytes
-rw-r--r--Src/aacdec/libs/Win32/mp4audiodec.libbin0 -> 654478 bytes
-rw-r--r--Src/aacdec/libs/Win32/mpegsDeclib.libbin0 -> 8822 bytes
-rw-r--r--Src/aacdec/libs/Win32/qmflib.libbin0 -> 61062 bytes
-rw-r--r--Src/aacdec/libs/Win32/readonlybitbuflib.libbin0 -> 4776 bytes
-rw-r--r--Src/aacdec/libs/Win32/sbrdecoderlib.libbin0 -> 189410 bytes
-rw-r--r--Src/aacdec/libs/Win32/spaceDeclib.libbin0 -> 583462 bytes
-rw-r--r--Src/aacdec/libs/Win32/utillib.libbin0 -> 52544 bytes
-rw-r--r--Src/aacdec/main.cpp100
-rw-r--r--Src/aacdec/resource.h14
-rw-r--r--Src/aacdec/version.rc239
55 files changed, 4546 insertions, 0 deletions
diff --git a/Src/aacdec/ADTSAACDecoder.cpp b/Src/aacdec/ADTSAACDecoder.cpp
new file mode 100644
index 00000000..d26ae94a
--- /dev/null
+++ b/Src/aacdec/ADTSAACDecoder.cpp
@@ -0,0 +1,387 @@
+#include "ADTSAACDecoder.h"
+#include "ADTSHeader.h"
+#include "../nsutil/pcm.h"
+#include <bfc/error.h>
+
+#define PRE_PADDING_MAGIC_WORD 'lluN'
+#define POST_PADDING_MAGIC_WORD 'tfos'
+
+#pragma pack(push, 1)
+struct AncillaryData
+{
+ int magicWord; // set to 'lluN' for pre-delay, 'tfos' for post-delay
+ unsigned short padding;
+};
+#pragma pack(pop)
+
+ADTSAACDecoder::ADTSAACDecoder()
+{
+ predelay = 0;
+ decoder = 0;
+ access_unit = 0;
+ composition_unit = 0;
+ useFloat = false; /* we'll fix during Initialize */
+ gain=1.0f; /* we'll fix during Initialize */
+ channels = 2; /* we'll fix during Initialize */
+ // get bps
+ bitsPerSample = 16; /* we'll fix during Initialize */
+ allowRG = false; /* we'll fix during Initialize */
+}
+
+int ADTSAACDecoder::Initialize(bool forceMono, bool reverse_stereo, bool allowSurround, int maxBits, bool _allowRG, bool _useFloat, bool _useCRC)
+{
+ allowRG = _allowRG;
+ useFloat = _useFloat;
+
+ if (_useFloat)
+ {
+ bitsPerSample = 32;
+ }
+ else if (maxBits >= 24)
+ {
+ bitsPerSample = 24;
+ }
+ else
+ {
+ bitsPerSample = 16;
+ }
+
+ if (forceMono)
+ channels = 1;
+ else if (allowSurround)
+ channels = 8;
+ else
+ channels = 2;
+
+
+ /* with FhG's API, we can't actually create a decoder until we have the ASC.
+ best we can do right now is create the access unit object */
+ access_unit = CAccessUnit_Create(0, 0);
+ if (access_unit)
+ return adts::SUCCESS;
+ else
+ return adts::FAILURE;
+}
+
+bool ADTSAACDecoder::Open(ifc_mpeg_stream_reader *file)
+{
+ if (allowRG)
+ gain = file->MPEGStream_Gain();
+
+ return true;
+}
+
+void ADTSAACDecoder::Close()
+{
+ mp4AudioDecoder_Destroy(&decoder);
+ decoder=0;
+ CAccessUnit_Destroy(&access_unit);
+ CCompositionUnit_Destroy(&composition_unit);
+}
+
+void ADTSAACDecoder::GetOutputParameters(size_t *numBits, int *numChannels, int *sampleRate)
+{
+ CCompositionUnit_GetSamplingRate(composition_unit, (unsigned int *)sampleRate);
+
+
+ *numChannels = channels;
+ *numBits = bitsPerSample;
+}
+
+void ADTSAACDecoder::CalculateFrameSize(int *frameSize)
+{
+ unsigned int samples_per_channel;
+ if (decoder && CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel) == MP4AUDIODEC_OK)
+ *frameSize = samples_per_channel*channels;
+ else
+ *frameSize = 0;
+}
+
+void ADTSAACDecoder::Flush(ifc_mpeg_stream_reader *file)
+{
+ mp4AudioDecoder_Reset(decoder, MP4AUDIODECPARAM_DEFAULT, 0);
+}
+
+size_t ADTSAACDecoder::GetCurrentBitrate()
+{
+ int current_bitrate;
+ if (CCompositionUnit_GetProperty(composition_unit, CUBUFFER_AVGBITRATE, &current_bitrate) == MP4AUDIODEC_OK)
+ {
+ return current_bitrate/1000;
+ }
+ else
+ return 0;
+}
+
+size_t ADTSAACDecoder::GetDecoderDelay()
+{
+ return predelay;
+}
+
+static int ADTSSync(const uint8_t *buffer, size_t bytes_in_buffer, size_t *header_position)
+{
+ for (size_t position=0;position<bytes_in_buffer;position++)
+ {
+ // find POTENTIAL sync
+ if (buffer[position] == 0xFF && bytes_in_buffer - position >= 7)
+ {
+ ADTSHeader header;
+ if (nsaac_adts_parse(&header, &buffer[position]) == NErr_Success)
+ {
+ int frame_length = header.frame_length;
+ if (frame_length && bytes_in_buffer - position - frame_length >= 7)
+ {
+ ADTSHeader header2;
+ if (nsaac_adts_parse(&header2, &buffer[position+frame_length]) == NErr_Success)
+ {
+ // verify that parameters match
+ if (nsaac_adts_match(&header, &header2) != NErr_True)
+ return NErr_Changed;
+
+ // do a dummy read to advance the stream
+ *header_position = position;
+ return NErr_Success;
+ }
+ }
+ else
+ {
+ /* not enough in the buffer to verify the next header */
+ *header_position = position;
+ return NErr_NeedMoreData;
+ }
+ }
+ }
+ }
+ return NErr_False;
+}
+
+static int ReturnIsEOF(ifc_mpeg_stream_reader *file)
+{
+ if (file->MPEGStream_EOF())
+ return adts::ENDOFFILE;
+ else
+ return adts::NEEDMOREDATA;
+}
+
+int ADTSAACDecoder::Internal_Decode(ifc_mpeg_stream_reader *file, const void *input, size_t input_length, unsigned __int8 *output, size_t outputSize, size_t *outputWritten, size_t *bitrate, size_t *endCut)
+{
+ CAccessUnit_Reset(access_unit);
+ CAccessUnit_Assign(access_unit, (const unsigned char *)input, input_length);
+ CCompositionUnit_Reset(composition_unit);
+ MP4_RESULT result = mp4AudioDecoder_DecodeFrame(decoder, &access_unit, composition_unit);
+
+ if (result == MP4AUDIODEC_OK)
+ {
+ /* check ancillary data for gapless data */
+ unsigned int ancillary_fields, ancillary_bytes;
+ if (CCompositionUnit_GetAncDataCount(composition_unit, &ancillary_fields, &ancillary_bytes) == MP4AUDIODEC_OK)
+ {
+ for (unsigned int i=0;i<ancillary_fields;i++)
+ {
+ unsigned char *ancillary_data;
+ unsigned int ancillary_size;
+ unsigned int ancillary_tag;
+ CCompositionUnit_GetAncDataByPos(composition_unit, i, &ancillary_data, &ancillary_size, &ancillary_tag);
+ if (ancillary_tag == ANCDATA_IS_AAC_DSE_TAG15 && ancillary_size == 6)
+ {
+ /* this is only safe on x86 because of alignment and endian */
+ const AncillaryData *data = (const AncillaryData *)ancillary_data;
+ if (data->magicWord == PRE_PADDING_MAGIC_WORD)
+ {
+ predelay = data->padding;
+ }
+ else if (data->magicWord == POST_PADDING_MAGIC_WORD)
+ {
+ *endCut = data->padding;
+ }
+ }
+ }
+ }
+
+ unsigned int channels;
+ unsigned int samples_per_channel;
+ if (CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel) != MP4AUDIODEC_OK
+ || CCompositionUnit_GetChannels(composition_unit, &channels) != MP4AUDIODEC_OK)
+ return adts::FAILURE;
+
+ if (samples_per_channel == 0)
+ return adts::NEEDMOREDATA;
+ const float *audio_output = 0;
+
+ size_t num_samples = samples_per_channel * channels;
+ size_t output_size = num_samples * (bitsPerSample/8);
+ if (output_size > outputSize)
+ return adts::FAILURE;
+
+ *outputWritten = output_size;
+ CCompositionUnit_GetPcmPtr(composition_unit, &audio_output);
+ if (!useFloat)
+ {
+ nsutil_pcm_FloatToInt_Interleaved_Gain(output, audio_output, bitsPerSample, num_samples, gain/32768.0f);
+ }
+ else
+ {
+ for (size_t i = 0;i != num_samples;i++)
+ ((float *)output)[i] = audio_output[i] * gain / 32768.0f;
+ }
+
+ int br;
+ CCompositionUnit_GetProperty(composition_unit, CUBUFFER_CURRENTBITRATE, &br);
+ *bitrate = br/1000;
+
+ return adts::SUCCESS;
+ }
+ else
+ return adts::FAILURE;
+}
+
+static void ConfigureADTS(CSAudioSpecificConfig* asc, nsaac_adts_header_t header)
+{
+ asc->m_aot = (AUDIO_OBJECT_TYPE)(header->profile + 1);
+ asc->m_channelConfiguration = header->channel_configuration;
+ asc->m_channels = nsaac_adts_get_channel_count(header);
+ asc->m_nrOfStreams = 1;
+ asc->m_samplesPerFrame = 1024;
+ asc->m_samplingFrequencyIndex = header->sample_rate_index;
+ asc->m_samplingFrequency = nsaac_adts_get_samplerate(header);
+ asc->m_avgBitRate = 0; /* only needed for tvq */
+ asc->m_mpsPresentFlag = -1;
+ asc->m_saocPresentFlag = -1;
+ asc->m_ldmpsPresentFlag = -1;
+}
+
+int ADTSAACDecoder::Sync(ifc_mpeg_stream_reader *file, unsigned __int8 *output, size_t outputSize, size_t *outputWritten, size_t *bitrate)
+{
+ /* ok this will be interesting. we'll peek from the input buffer and try to synchronize on an ADTS header */
+ uint8_t peek_buffer[16384] = {0};
+ size_t bytes_read = 0;
+ if (file->MPEGStream_Peek(peek_buffer, sizeof(peek_buffer), &bytes_read) != 0)
+ {
+ return adts::FAILURE;
+ }
+
+ size_t header_position=0;
+ int ret = ADTSSync(peek_buffer, bytes_read, &header_position);
+ if (ret == NErr_NeedMoreData)
+ {
+ // this one means we found one sync but not enough to verify the next frame
+
+ // if the header was at the start of the block, then unfortunately this might be the LAST adts frame in the file, so let's just pass it the decoder and hope for the best
+ if (header_position != 0)
+ {
+ if (file->MPEGStream_EOF())
+ return adts::ENDOFFILE;
+
+ /* dummy read to advance the stream */
+ file->MPEGStream_Read(peek_buffer, header_position, &header_position);
+ return adts::NEEDMOREDATA;
+ }
+ }
+ else if (ret == NErr_False)
+ {
+ if (file->MPEGStream_EOF())
+ return adts::ENDOFFILE;
+
+ // not even a potential sync found
+ /* dummy read to advance the stream */
+ file->MPEGStream_Read(peek_buffer, bytes_read, &bytes_read);
+ return adts::NEEDMOREDATA;
+ }
+ else if (ret != NErr_Success)
+ {
+ if (file->MPEGStream_EOF())
+ return adts::ENDOFFILE;
+
+ return adts::FAILURE;
+ }
+
+
+ ADTSHeader header;
+ if (nsaac_adts_parse(&header, &peek_buffer[header_position]) == NErr_Success)
+ {
+ CSAudioSpecificConfig asc;
+ memset(&asc, 0, sizeof(asc));
+ ConfigureADTS(&asc, &header);
+
+ if (!decoder)
+ {
+ CSAudioSpecificConfig *asc_array = &asc;
+ decoder = mp4AudioDecoder_Create(&asc_array, 1);
+ if (decoder)
+ {
+ mp4AudioDecoder_SetParam(decoder, TDL_MODE, SWITCH_OFF);
+ mp4AudioDecoder_SetParam(decoder, CONCEALMENT_ENERGYINTERPOLATION, SWITCH_OFF);
+ composition_unit = CCompositionUnit_Create(max(asc.m_channels, 8), asc.m_samplesPerFrame * 2, asc.m_samplingFrequency, 6144, CUBUFFER_PCMTYPE_FLOAT);
+ }
+ if (!decoder || !composition_unit)
+ return adts::FAILURE;
+ }
+
+ /* all this error checking might be uncessary, since in theory we did a successful peek above. but you never know ... */
+ if (file->MPEGStream_Read(peek_buffer, header_position, &bytes_read)) /* dummy read to advance the stream */
+ return adts::FAILURE;
+
+ if (bytes_read != header_position)
+ return ReturnIsEOF(file);
+
+ if (file->MPEGStream_Read(peek_buffer, header.frame_length, &bytes_read)) /* read ADTS frame */
+ return adts::FAILURE;
+
+ if (bytes_read != header.frame_length)
+ return ReturnIsEOF(file);
+
+ if (bytes_read < 7) /* bad header data? */
+ return adts::FAILURE;
+
+ /* ok, we've created the decoder, but we should really decode the frame to see if there's VBR, PS or MPEGS in it */
+ size_t header_size = nsaac_adts_get_header_size(&header);
+
+ size_t endCut;
+ int ret = Internal_Decode(file, peek_buffer+header_size, bytes_read-header_size, output, outputSize, outputWritten, bitrate, &endCut);
+ if (ret == adts::SUCCESS)
+ CCompositionUnit_GetChannels(composition_unit, &channels);
+ return ret;
+ }
+ return adts::FAILURE;
+}
+
+int ADTSAACDecoder::Decode(ifc_mpeg_stream_reader *file, unsigned __int8 *output, size_t outputSize, size_t *outputWritten, size_t *bitrate, size_t *endCut)
+{
+ uint8_t peek_buffer[8192] = {0};
+ size_t bytes_read = 0;
+
+ file->MPEGStream_Peek(peek_buffer, 7, &bytes_read);
+ if (bytes_read != 7)
+ return ReturnIsEOF(file);
+
+ ADTSHeader header;
+ if (nsaac_adts_parse(&header, peek_buffer) == NErr_Success)
+ {
+ if (header.frame_length < 7)
+ return adts::FAILURE;
+
+ file->MPEGStream_Peek(peek_buffer, header.frame_length, &bytes_read);
+ if (bytes_read != header.frame_length)
+ return ReturnIsEOF(file);
+ file->MPEGStream_Read(peek_buffer, header.frame_length, &bytes_read);
+
+ size_t header_size = nsaac_adts_get_header_size(&header);
+ return Internal_Decode(file, peek_buffer+header_size, bytes_read-header_size, output, outputSize, outputWritten, bitrate, endCut);
+ }
+ else
+ {
+ /* Resynchronize */
+ return Sync(file, output, outputSize, outputWritten, bitrate);
+ }
+
+}
+
+int ADTSAACDecoder::GetLayer()
+{
+ return 4;
+}
+
+void ADTSAACDecoder::Release()
+{
+ delete this;
+} \ No newline at end of file
diff --git a/Src/aacdec/ADTSAACDecoder.h b/Src/aacdec/ADTSAACDecoder.h
new file mode 100644
index 00000000..5fb89b17
--- /dev/null
+++ b/Src/aacdec/ADTSAACDecoder.h
@@ -0,0 +1,42 @@
+#pragma once
+#include "../in_mp3/adts.h"
+#include "incs/mp4AudioDecIfc.h"
+
+// {19450308-90D7-4E45-8A9D-DC71E67123E2}
+static const GUID adts_aac_guid =
+{ 0x19450308, 0x90d7, 0x4e45, { 0x8a, 0x9d, 0xdc, 0x71, 0xe6, 0x71, 0x23, 0xe2 } };
+
+class ADTSAACDecoder : public adts
+{
+public:
+ static const char *getServiceName() { return "AAC ADTS Decoder"; }
+ static GUID getServiceGuid() { return adts_aac_guid; }
+ ADTSAACDecoder();
+ int Initialize(bool forceMono, bool reverse_stereo, bool allowSurround, int maxBits, bool allowRG, bool _useFloat, bool _useCRC);
+ bool Open(ifc_mpeg_stream_reader *file);
+ void Close();
+ void GetOutputParameters(size_t *numBits, int *numChannels, int *sampleRate);
+ void CalculateFrameSize(int *frameSize);
+ void Flush(ifc_mpeg_stream_reader *file);
+ size_t GetCurrentBitrate();
+ size_t GetDecoderDelay();
+ int Sync(ifc_mpeg_stream_reader *file, unsigned __int8 *output, size_t outputSize, size_t *outputWritten, size_t *bitrate);
+ int Decode(ifc_mpeg_stream_reader *file, unsigned __int8 *output, size_t outputSize, size_t *outputWritten, size_t *bitrate, size_t *endCut);
+ int GetLayer();
+ void Release();
+
+private:
+ int Internal_Decode(ifc_mpeg_stream_reader *file, const void *input, size_t input_length, unsigned __int8 *output, size_t outputSize, size_t *outputWritten, size_t *bitrate, size_t *endCut);
+
+ mp4AudioDecoderHandle decoder;
+ CCompositionUnitPtr composition_unit; /* output */
+ CAccessUnitPtr access_unit; /* input */
+
+ int bitsPerSample;
+ unsigned int channels;
+ float gain;
+ bool allowRG;
+ bool useFloat;
+ size_t predelay;
+
+}; \ No newline at end of file
diff --git a/Src/aacdec/ADTSHeader.c b/Src/aacdec/ADTSHeader.c
new file mode 100644
index 00000000..8e683270
--- /dev/null
+++ b/Src/aacdec/ADTSHeader.c
@@ -0,0 +1,110 @@
+#include "ADTSHeader.h"
+#include <bfc/error.h>
+
+enum
+{
+ ADTS_NOT_PROTECTED=1,
+ ADTS_PROTECTED=0,
+ ADTS_SYNC = 0xFFF,
+ ADTS_MAIN = 0x00,
+ ADTS_LC = 0x01,
+ ADTS_SSR = 0x10,
+ ADTS_LTP = 0x11,
+};
+
+
+int nsaac_adts_parse(nsaac_adts_header_t header, const uint8_t *buffer)
+{
+ unsigned int syncword = (buffer[0] << 4) | (buffer[1] >> 4);
+ unsigned int layer;
+ unsigned int sample_rate_index;
+ if (syncword != ADTS_SYNC)
+ return NErr_LostSynchronization;
+
+ header->syncword = syncword;
+ header->id = (buffer[1] >> 3) & 1;
+ layer = (buffer[1] >> 1) & 3;
+ if (layer != 0)
+ return NErr_WrongFormat;
+ header->layer = layer;
+ header->protection = (buffer[1]) & 1;
+ header->profile = (buffer[2] >> 6) & 3;
+ sample_rate_index = (buffer[2] >> 2) & 0xF;
+ if (sample_rate_index == 15)
+ return NErr_UnsupportedFormat; // might actually be OK if we can separately signal the sample rate
+
+ if (sample_rate_index > 13)
+ return NErr_Reserved;
+
+ header->sample_rate_index = sample_rate_index;
+ header->private_bit = (buffer[2] >> 1) & 1;
+ header->channel_configuration = ((buffer[2] & 1) << 2) | ((buffer[3] >> 6) & 3);
+ header->original = (buffer[3] >> 5) &1;
+ header->home = (buffer[3] >> 4) &1;
+
+ //copyright_identification_bit = (buffer[3] >> 3) & 1;
+ //copyright_identification_start = (buffer[3] >> 2) & 1;
+ header->frame_length = ((buffer[3] & 3) << 11) | (buffer[4]<<3) | ((buffer[5] >> 5) & 7);
+ header->buffer_fullness = ((buffer[5] & 0x1F) << 6) | (buffer[6] >> 2);
+ header->num_data_blocks = buffer[6] & 3;
+ return NErr_Success;
+}
+
+
+static const unsigned int aac_sratetab[] =
+{
+ 96000,
+ 88200,
+ 64000,
+ 48000,
+ 44100,
+ 32000,
+ 24000,
+ 22050,
+ 16000,
+ 12000,
+ 11025,
+ 8000,
+ 7350,
+};
+
+unsigned int nsaac_adts_get_samplerate(nsaac_adts_header_t header)
+{
+ return aac_sratetab[header->sample_rate_index];
+}
+
+int nsaac_adts_match(nsaac_adts_header_t header1, nsaac_adts_header_t header2)
+{
+ if (header1->id != header2->id)
+ return NErr_False;
+
+ if (header1->profile != header2->profile)
+ return NErr_False;
+
+ if (header1->sample_rate_index != header2->sample_rate_index)
+ return NErr_False;
+
+ if (header1->channel_configuration != header2->channel_configuration)
+ return NErr_False;
+
+ return NErr_True;
+}
+
+int nsaac_adts_get_channel_count(nsaac_adts_header_t header)
+{
+ switch(header->channel_configuration)
+ {
+ case 7:
+ return 8;
+ default:
+ return header->channel_configuration;
+ }
+}
+
+size_t nsaac_adts_get_header_size(nsaac_adts_header_t header)
+{
+ if (header->protection == ADTS_PROTECTED)
+ return 9;
+ else
+ return 7;
+} \ No newline at end of file
diff --git a/Src/aacdec/ADTSHeader.h b/Src/aacdec/ADTSHeader.h
new file mode 100644
index 00000000..f6f7c202
--- /dev/null
+++ b/Src/aacdec/ADTSHeader.h
@@ -0,0 +1,34 @@
+#pragma once
+#include <bfc/platform/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct ADTSHeader
+{
+ unsigned int syncword;
+ unsigned int layer;
+ unsigned int id;
+ unsigned int protection;
+ unsigned int profile;
+ unsigned int sample_rate_index;
+ unsigned int private_bit;
+ unsigned int channel_configuration;
+ unsigned int original;
+ unsigned int home;
+ size_t frame_length;
+ unsigned int buffer_fullness;
+ unsigned int num_data_blocks;
+} ADTSHeader, *nsaac_adts_header_t;
+
+/* must be 7 bytes */
+int nsaac_adts_parse(nsaac_adts_header_t header, const uint8_t *buffer);
+unsigned int nsaac_adts_get_samplerate(nsaac_adts_header_t header);
+int nsaac_adts_match(nsaac_adts_header_t header1, nsaac_adts_header_t header2);
+int nsaac_adts_get_channel_count(nsaac_adts_header_t header);
+size_t nsaac_adts_get_header_size(nsaac_adts_header_t header);
+
+#ifdef __cplusplus
+}
+#endif \ No newline at end of file
diff --git a/Src/aacdec/AVIAACDecoder.cpp b/Src/aacdec/AVIAACDecoder.cpp
new file mode 100644
index 00000000..570b50c9
--- /dev/null
+++ b/Src/aacdec/AVIAACDecoder.cpp
@@ -0,0 +1,173 @@
+#include "AVIAACDecoder.h"
+#include <math.h>
+#include "../nsutil/pcm.h"
+
+int AVIDecoder::CreateAudioDecoder(const nsavi::AVIH *avi_header,
+ const nsavi::STRH *stream_header, const nsavi::STRF *stream_format, const nsavi::STRD *stream_data,
+ unsigned int preferred_bits, unsigned int max_channels, bool floating_point,
+ ifc_aviaudiodecoder **decoder)
+{
+ nsavi::audio_format *waveformat = (nsavi::audio_format *)stream_format;
+
+ if (waveformat->format == nsavi::audio_format_aac)
+ {
+ AVIAACDecoder *aac_decoder = AVIAACDecoder::Create(waveformat, preferred_bits, max_channels, floating_point);
+ if (aac_decoder)
+ {
+ *decoder = aac_decoder;
+ return CREATEDECODER_SUCCESS;
+ }
+ return CREATEDECODER_SUCCESS;
+ }
+
+ return CREATEDECODER_NOT_MINE;
+
+}
+
+#define CBCLASS AVIDecoder
+START_DISPATCH;
+CB(CREATE_AUDIO_DECODER, CreateAudioDecoder)
+END_DISPATCH;
+#undef CBCLASS
+
+AVIAACDecoder *AVIAACDecoder::Create(const nsavi::audio_format *waveformat, unsigned int preferred_bits, unsigned int max_channels, bool floating_point)
+{
+ if (!floating_point)
+ {
+ if (preferred_bits >= 24)
+ preferred_bits=24;
+ else
+ preferred_bits=16;
+ }
+ /*if (!max_channels)
+ max_channels = 8;*/
+
+ if (waveformat->extra_size_bytes)
+ {
+ CSAudioSpecificConfig asc;
+ memset(&asc, 0, sizeof(asc));
+ if (mp4AudioDecoder_ascParse((const unsigned char *)(waveformat + 1), waveformat->extra_size_bytes, &asc) == MP4AUDIODEC_OK)
+ {
+ CSAudioSpecificConfig *asc_array = &asc;;
+ mp4AudioDecoderHandle decoder = mp4AudioDecoder_Create(&asc_array, 1);
+ if (decoder)
+ {
+ mp4AudioDecoder_SetParam(decoder, TDL_MODE, SWITCH_OFF);
+ mp4AudioDecoder_SetParam(decoder, CONCEALMENT_ENERGYINTERPOLATION, SWITCH_OFF);
+ CCompositionUnitPtr composition_unit = CCompositionUnit_Create(max(asc.m_channels, 8), asc.m_samplesPerFrame * 2, asc.m_samplingFrequency, 6144, CUBUFFER_PCMTYPE_FLOAT);
+ if (composition_unit)
+ {
+ CAccessUnitPtr access_unit = CAccessUnit_Create(0, 0);
+ if (access_unit)
+ {
+ return new AVIAACDecoder(decoder, access_unit, composition_unit, preferred_bits, floating_point);
+ }
+ CCompositionUnit_Destroy(&composition_unit);
+ }
+ mp4AudioDecoder_Destroy(&decoder);
+ }
+ }
+ }
+
+ return 0;
+}
+
+AVIAACDecoder::AVIAACDecoder(mp4AudioDecoderHandle decoder, CAccessUnitPtr access_unit, CCompositionUnitPtr composition_unit, unsigned int bps, bool floating_point)
+: decoder(decoder), access_unit(access_unit), composition_unit(composition_unit), bps(bps), floating_point(floating_point)
+{
+}
+
+int AVIAACDecoder::OutputFrameSize(size_t *frame_size)
+{
+ if (!decoder)
+ return AVI_FAILURE;
+
+ unsigned int samples_per_channel;
+ unsigned int channels;
+ if (CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel) != MP4AUDIODEC_OK
+|| CCompositionUnit_GetChannels(composition_unit, &channels) != MP4AUDIODEC_OK)
+ return AVI_FAILURE;
+
+ *frame_size = samples_per_channel*channels;
+ return AVI_SUCCESS;
+}
+
+int AVIAACDecoder::GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample, bool *isFloat)
+{
+ /* TODO: verify that it's safe to call these, e.g. one frame has been decoded successfully */
+ CCompositionUnit_GetSamplingRate(composition_unit, sampleRate);
+ CCompositionUnit_GetChannels(composition_unit, channels);
+
+ *bitsPerSample = bps;
+ *isFloat = floating_point;
+ return AVI_SUCCESS;
+}
+
+int AVIAACDecoder::DecodeChunk(uint16_t type, void **inputBuffer, size_t *inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes)
+{
+ CAccessUnit_Reset(access_unit);
+ CAccessUnit_Assign(access_unit, (const unsigned char *)*inputBuffer, *inputBufferBytes);
+ CCompositionUnit_Reset(composition_unit);
+ MP4_RESULT result = mp4AudioDecoder_DecodeFrame(decoder, &access_unit, composition_unit);
+
+ if (result == MP4AUDIODEC_OK)
+ {
+ unsigned int bits_remaining;
+ unsigned int bits_read;
+ CAccessUnit_GetBitCount(access_unit, &bits_read);
+ CAccessUnit_GetValidBits(access_unit, &bits_remaining);
+ *inputBuffer = (uint8_t *)(*inputBuffer) + bits_read/8;
+ *inputBufferBytes = bits_remaining/8;
+
+ unsigned int channels;
+ unsigned int samples_per_channel;
+ CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel);
+ CCompositionUnit_GetChannels(composition_unit, &channels);
+ const float *audio_output = 0;
+ size_t num_samples = samples_per_channel * channels;
+ size_t output_size = num_samples * (bps/8);
+ if (output_size > *outputBufferBytes)
+ return AVI_FAILURE;
+
+ *outputBufferBytes = output_size;
+ CCompositionUnit_GetPcmPtr(composition_unit, &audio_output);
+ if (!floating_point)
+ {
+ nsutil_pcm_FloatToInt_Interleaved_Gain(outputBuffer, audio_output, bps, num_samples, 1.0f/32768.0f);
+ }
+ else
+ {
+ for (size_t i = 0;i != num_samples;i++)
+ ((float *)outputBuffer)[i] = audio_output[i] / 32768.0f;
+ }
+
+ return AVI_SUCCESS;
+ }
+ else
+ return AVI_FAILURE;
+
+}
+
+void AVIAACDecoder::Flush()
+{
+ mp4AudioDecoder_Reset(decoder, MP4AUDIODECPARAM_DEFAULT, 0);
+}
+
+void AVIAACDecoder::Close()
+{
+ mp4AudioDecoder_Destroy(&decoder);
+ CAccessUnit_Destroy(&access_unit);
+ CCompositionUnit_Destroy(&composition_unit);
+
+ delete this;
+}
+
+#define CBCLASS AVIAACDecoder
+START_DISPATCH;
+CB(OUTPUT_FRAME_SIZE, OutputFrameSize)
+CB(GET_OUTPUT_PROPERTIES, GetOutputProperties)
+CB(DECODE_CHUNK, DecodeChunk)
+VCB(FLUSH, Flush)
+VCB(CLOSE, Close)
+END_DISPATCH;
+#undef CBCLASS \ No newline at end of file
diff --git a/Src/aacdec/AVIAACDecoder.h b/Src/aacdec/AVIAACDecoder.h
new file mode 100644
index 00000000..21623ee5
--- /dev/null
+++ b/Src/aacdec/AVIAACDecoder.h
@@ -0,0 +1,41 @@
+#pragma once
+#include "../in_avi/svc_avidecoder.h"
+#include "../in_avi/ifc_aviaudiodecoder.h"
+#include "incs/mp4AudioDecIfc.h"
+
+// {4033D2BF-F217-4e8e-877B-2269CD04CA52}
+static const GUID avi_aac_guid =
+{ 0x4033d2bf, 0xf217, 0x4e8e, { 0x87, 0x7b, 0x22, 0x69, 0xcd, 0x4, 0xca, 0x52 } };
+
+class AVIDecoder : public svc_avidecoder
+{
+public:
+ static const char *getServiceName() { return "AAC AVI Decoder"; }
+ static GUID getServiceGuid() { return avi_aac_guid; }
+ int CreateAudioDecoder(const nsavi::AVIH *avi_header, const nsavi::STRH *stream_header, const nsavi::STRF *stream_format, const nsavi::STRD *stream_data, unsigned int preferred_bits, unsigned int max_channels, bool floating_point, ifc_aviaudiodecoder **decoder);
+protected:
+ RECVS_DISPATCH;
+};
+
+class AVIAACDecoder : public ifc_aviaudiodecoder
+{
+public:
+ AVIAACDecoder(mp4AudioDecoderHandle decoder, CAccessUnitPtr access_unit, CCompositionUnitPtr composition_unit, unsigned int bps, bool floating_point);
+ static AVIAACDecoder *Create(const nsavi::audio_format *stream_format, unsigned int preferred_bits, unsigned int max_channels, bool floating_point);
+protected:
+ RECVS_DISPATCH;
+private:
+ /* ifc_aviaudiodecoder implementation */
+ int OutputFrameSize(size_t *frame_size);
+ int GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample, bool *isFloat);
+ int DecodeChunk(uint16_t type, void **inputBuffer, size_t *inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes);
+ void Flush();
+ void Close();
+
+ /* data */
+ mp4AudioDecoderHandle decoder;
+ CCompositionUnitPtr composition_unit; /* output */
+ CAccessUnitPtr access_unit; /* input */
+ unsigned int bps;
+ bool floating_point;
+}; \ No newline at end of file
diff --git a/Src/aacdec/FLVAACDecoder.cpp b/Src/aacdec/FLVAACDecoder.cpp
new file mode 100644
index 00000000..cf1d0b6d
--- /dev/null
+++ b/Src/aacdec/FLVAACDecoder.cpp
@@ -0,0 +1,159 @@
+#include "FLVAACDecoder.h"
+#include <math.h>
+#include "../nsutil/pcm.h"
+
+int FLVDecoder::CreateAudioDecoder(int stereo, int bits, int sample_rate, int format_type, ifc_flvaudiodecoder **decoder)
+{
+ if (format_type == FLV::AUDIO_FORMAT_AAC)
+ {
+ CAccessUnitPtr access_unit = CAccessUnit_Create(0, 0);
+ if (!access_unit)
+ return CREATEDECODER_FAILURE;
+
+ FLVAAC *aac = new FLVAAC(access_unit);
+ if (!aac)
+ {
+ CAccessUnit_Destroy(&access_unit);
+ return CREATEDECODER_FAILURE;
+ }
+ *decoder = aac;
+ return CREATEDECODER_SUCCESS;
+ }
+ return CREATEDECODER_NOT_MINE;
+}
+
+int FLVDecoder::HandlesAudio(int format_type)
+{
+ if (format_type == FLV::AUDIO_FORMAT_AAC)
+ {
+ return CREATEDECODER_SUCCESS;
+ }
+ return CREATEDECODER_NOT_MINE;
+}
+
+#define CBCLASS FLVDecoder
+START_DISPATCH;
+CB(CREATE_AUDIO_DECODER, CreateAudioDecoder)
+CB(HANDLES_AUDIO, HandlesAudio)
+END_DISPATCH;
+#undef CBCLASS
+
+/* --- */
+FLVAAC::FLVAAC(CAccessUnitPtr access_unit) : access_unit(access_unit)
+{
+ bps = 16;
+ preDelay=0;
+ got_decoder_config = false;
+ decoder = 0;
+ composition_unit = 0;
+}
+
+int FLVAAC::GetOutputFormat(unsigned int *sample_rate, unsigned int *channels, unsigned int *_bits)
+{
+ /* TODO: verify that it's safe to call these, e.g. one frame has been decoded successfully */
+ CCompositionUnit_GetSamplingRate(composition_unit, sample_rate);
+ CCompositionUnit_GetChannels(composition_unit, channels);
+
+ *_bits = bps;
+ return FLV_AUDIO_SUCCESS;
+}
+
+int FLVAAC::DecodeSample(const void *input_buffer, size_t input_buffer_bytes, void *samples, size_t *samples_size_bytes, double *bitrate)
+{
+ const uint8_t *type = (const uint8_t *)input_buffer;
+ if (type[0] == 0)
+ {
+ CSAudioSpecificConfig asc;
+ memset(&asc, 0, sizeof(asc));
+ if (mp4AudioDecoder_ascParse(type+1, input_buffer_bytes-1, &asc) == MP4AUDIODEC_OK)
+ {
+ CSAudioSpecificConfig *asc_array = &asc;;
+ decoder = mp4AudioDecoder_Create(&asc_array, 1);
+ if (decoder)
+ {
+ mp4AudioDecoder_SetParam(decoder, TDL_MODE, SWITCH_OFF);
+ mp4AudioDecoder_SetParam(decoder, CONCEALMENT_ENERGYINTERPOLATION, SWITCH_OFF);
+ composition_unit = CCompositionUnit_Create(max(asc.m_channels, 8), asc.m_samplesPerFrame * 2, asc.m_samplingFrequency, 6144, CUBUFFER_PCMTYPE_FLOAT);
+ if (composition_unit)
+ {
+ got_decoder_config=true;
+ *samples_size_bytes=0;
+ return FLV_AUDIO_SUCCESS;
+ }
+ mp4AudioDecoder_Destroy(&decoder);
+ }
+ }
+ return FLV_AUDIO_FAILURE;
+ }
+ else if (type[0] == 1)
+ {
+ CAccessUnit_Reset(access_unit);
+ CAccessUnit_Assign(access_unit, type+1, input_buffer_bytes-1);
+ CCompositionUnit_Reset(composition_unit);
+ MP4_RESULT result = mp4AudioDecoder_DecodeFrame(decoder, &access_unit, composition_unit);
+
+ if (result == MP4AUDIODEC_OK)
+ {
+ unsigned int channels;
+ unsigned int samples_per_channel;
+ CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel);
+ CCompositionUnit_GetChannels(composition_unit, &channels);
+ const float *audio_output = 0;
+ size_t num_samples = samples_per_channel * channels;
+ size_t output_size = num_samples * (bps/8);
+ if (output_size > *samples_size_bytes)
+ return FLV_AUDIO_FAILURE;
+
+ *samples_size_bytes = output_size;
+ CCompositionUnit_GetPcmPtr(composition_unit, &audio_output);
+ nsutil_pcm_FloatToInt_Interleaved_Gain(samples, audio_output, bps, num_samples, 1.0f/32768.0f);
+
+ int br;
+ CCompositionUnit_GetProperty(composition_unit, CUBUFFER_CURRENTBITRATE, &br);
+ *bitrate = (double)br/1000.0;
+ return FLV_AUDIO_SUCCESS;
+ }
+ else
+ return FLV_AUDIO_FAILURE;
+
+ }
+ else
+ return FLV_AUDIO_FAILURE;
+}
+
+void FLVAAC::Flush()
+{
+ mp4AudioDecoder_Reset(decoder, MP4AUDIODECPARAM_DEFAULT, 0);
+}
+
+void FLVAAC::Close()
+{
+ mp4AudioDecoder_Destroy(&decoder);
+ CAccessUnit_Destroy(&access_unit);
+ CCompositionUnit_Destroy(&composition_unit);
+ delete this;
+}
+
+int FLVAAC::Ready()
+{
+ return !!got_decoder_config;
+}
+
+void FLVAAC::SetPreferences(unsigned int _max_channels, unsigned int preferred_bits)
+{
+ if (preferred_bits)
+ bps = preferred_bits;
+
+ // TODO: max channels
+}
+
+#define CBCLASS FLVAAC
+START_DISPATCH;
+CB(FLV_AUDIO_GETOUTPUTFORMAT, GetOutputFormat)
+CB(FLV_AUDIO_DECODE, DecodeSample)
+VCB(FLV_AUDIO_FLUSH, Flush)
+VCB(FLV_AUDIO_CLOSE, Close)
+CB(FLV_AUDIO_READY, Ready)
+VCB(FLV_AUDIO_SETPREFERENCES, SetPreferences)
+END_DISPATCH;
+#undef CBCLASS
diff --git a/Src/aacdec/FLVAACDecoder.h b/Src/aacdec/FLVAACDecoder.h
new file mode 100644
index 00000000..9041c1cd
--- /dev/null
+++ b/Src/aacdec/FLVAACDecoder.h
@@ -0,0 +1,45 @@
+#pragma once
+#include "../in_flv/svc_flvdecoder.h"
+#include "../in_flv/FLVAudioHeader.h"
+#include "../in_flv/ifc_flvaudiodecoder.h"
+
+#include "incs/mp4AudioDecIfc.h"
+
+// {7FD8F2D0-7490-45fd-B741-BF3F9EEF0BE4}
+static const GUID flv_aac_guid =
+{ 0x7fd8f2d0, 0x7490, 0x45fd, { 0xb7, 0x41, 0xbf, 0x3f, 0x9e, 0xef, 0xb, 0xe4 } };
+
+
+class FLVDecoder : public svc_flvdecoder
+{
+public:
+ static const char *getServiceName() { return "AAC FLV Decoder"; }
+ static GUID getServiceGuid() { return flv_aac_guid; }
+ int CreateAudioDecoder(int stereo, int bits, int sample_rate, int format, ifc_flvaudiodecoder **decoder);
+ int HandlesAudio(int format_type);
+protected:
+ RECVS_DISPATCH;
+};
+
+class FLVAAC : public ifc_flvaudiodecoder
+{
+public:
+ FLVAAC(CAccessUnitPtr access_unit);
+ int GetOutputFormat(unsigned int *sample_rate, unsigned int *channels, unsigned int *bits);
+ int DecodeSample(const void *input_buffer, size_t input_buffer_bytes, void *samples, size_t *samples_size_bytes, double *bitrate);
+ void Flush();
+ void Close();
+ int Ready();
+ void SetPreferences(unsigned int max_channels, unsigned int preferred_bits);
+private:
+/* data */
+ mp4AudioDecoderHandle decoder;
+ CCompositionUnitPtr composition_unit; /* output */
+ CAccessUnitPtr access_unit; /* input */
+ unsigned int bps;
+ size_t preDelay;
+ bool got_decoder_config;
+
+protected:
+ RECVS_DISPATCH;
+};
diff --git a/Src/aacdec/MKVAACDecoder.cpp b/Src/aacdec/MKVAACDecoder.cpp
new file mode 100644
index 00000000..b19e1a25
--- /dev/null
+++ b/Src/aacdec/MKVAACDecoder.cpp
@@ -0,0 +1,159 @@
+#include "MKVAACDecoder.h"
+#include <math.h>
+#include "../nsutil/pcm.h"
+MKVAACDecoder::MKVAACDecoder(mp4AudioDecoderHandle decoder, CAccessUnitPtr access_unit, CCompositionUnitPtr composition_unit, unsigned int bps, bool floating_point)
+: decoder(decoder), access_unit(access_unit), composition_unit(composition_unit), bps(bps), floating_point(floating_point)
+{
+
+}
+
+MKVAACDecoder *MKVAACDecoder::Create(const nsmkv::TrackEntryData *track_entry_data, const nsmkv::AudioData *audio_data, unsigned int preferred_bits, unsigned int max_channels, bool floating_point)
+{
+ if (!floating_point)
+ {
+ if (preferred_bits >= 24)
+ preferred_bits=24;
+ else
+ preferred_bits=16;
+ }
+ /*if (!max_channels)
+ max_channels = 8;*/
+
+ if (track_entry_data->codec_private && track_entry_data->codec_private_len)
+ {
+ CSAudioSpecificConfig asc;
+ memset(&asc, 0, sizeof(asc));
+ if (mp4AudioDecoder_ascParse((const unsigned char *)track_entry_data->codec_private, track_entry_data->codec_private_len, &asc) == MP4AUDIODEC_OK)
+ {
+ CSAudioSpecificConfig *asc_array = &asc;;
+ mp4AudioDecoderHandle decoder = mp4AudioDecoder_Create(&asc_array, 1);
+ if (decoder)
+ {
+ mp4AudioDecoder_SetParam(decoder, TDL_MODE, SWITCH_OFF);
+ mp4AudioDecoder_SetParam(decoder, CONCEALMENT_ENERGYINTERPOLATION, SWITCH_OFF);
+ CCompositionUnitPtr composition_unit = CCompositionUnit_Create(max(asc.m_channels, 8), asc.m_samplesPerFrame * 2, asc.m_samplingFrequency, 6144, CUBUFFER_PCMTYPE_FLOAT);
+ if (composition_unit)
+ {
+ CAccessUnitPtr access_unit = CAccessUnit_Create(0, 0);
+ if (access_unit)
+ {
+ return new MKVAACDecoder(decoder, access_unit, composition_unit, preferred_bits, floating_point);
+ }
+ CCompositionUnit_Destroy(&composition_unit);
+ }
+ mp4AudioDecoder_Destroy(&decoder);
+ }
+ }
+ }
+
+ return 0;
+}
+
+int MKVAACDecoder::GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample, bool *isFloat)
+{
+ /* TODO: verify that it's safe to call these, e.g. one frame has been decoded successfully, otherwise call MKV_NEED_MORE_INPUT */
+ CCompositionUnit_GetSamplingRate(composition_unit, sampleRate);
+ CCompositionUnit_GetChannels(composition_unit, channels);
+
+ *bitsPerSample = bps;
+ *isFloat = floating_point;
+ return MKV_SUCCESS;
+}
+
+void MKVAACDecoder::Flush()
+{
+ mp4AudioDecoder_Reset(decoder, MP4AUDIODECPARAM_DEFAULT, 0);
+}
+
+int MKVAACDecoder::OutputFrameSize(size_t *frame_size)
+{
+ if (!decoder)
+ return MKV_FAILURE;
+
+ unsigned int samples_per_channel;
+ unsigned int channels;
+ if (CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel) != MP4AUDIODEC_OK
+ || CCompositionUnit_GetChannels(composition_unit, &channels) != MP4AUDIODEC_OK)
+ return MKV_FAILURE;
+
+ *frame_size = samples_per_channel*channels;
+ return MKV_SUCCESS;
+}
+
+void MKVAACDecoder::Close()
+{
+ mp4AudioDecoder_Destroy(&decoder);
+ CAccessUnit_Destroy(&access_unit);
+ CCompositionUnit_Destroy(&composition_unit);
+ delete this;
+}
+
+int MKVAACDecoder::DecodeBlock(void *inputBuffer, size_t inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes)
+{
+ CAccessUnit_Reset(access_unit);
+ CAccessUnit_Assign(access_unit, (const unsigned char *)inputBuffer, inputBufferBytes);
+ CCompositionUnit_Reset(composition_unit);
+ MP4_RESULT result = mp4AudioDecoder_DecodeFrame(decoder, &access_unit, composition_unit);
+
+ if (result == MP4AUDIODEC_OK)
+ {
+ unsigned int channels;
+ unsigned int samples_per_channel;
+ CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel);
+ CCompositionUnit_GetChannels(composition_unit, &channels);
+ const float *audio_output = 0;
+ size_t num_samples = samples_per_channel * channels;
+ size_t output_size = num_samples * (bps/8);
+ if (output_size > *outputBufferBytes)
+ return MKV_FAILURE;
+
+ *outputBufferBytes = output_size;
+ CCompositionUnit_GetPcmPtr(composition_unit, &audio_output);
+ if (!floating_point)
+ {
+ nsutil_pcm_FloatToInt_Interleaved_Gain(outputBuffer, audio_output, bps, num_samples, 1.0f/32768.0f);
+ }
+ else
+ {
+ for (size_t i = 0;i != num_samples;i++)
+ ((float *)outputBuffer)[i] = audio_output[i] / 32768.0f;
+ }
+
+ return MKV_SUCCESS;
+ }
+ else
+ return MKV_FAILURE;
+}
+
+#define CBCLASS MKVAACDecoder
+START_DISPATCH;
+CB(OUTPUT_FRAME_SIZE, OutputFrameSize)
+CB(GET_OUTPUT_PROPERTIES, GetOutputProperties)
+CB(DECODE_BLOCK, DecodeBlock)
+VCB(FLUSH, Flush)
+VCB(CLOSE, Close)
+END_DISPATCH;
+#undef CBCLASS
+
+
+int MKVDecoder::CreateAudioDecoder(const char *codec_id, const nsmkv::TrackEntryData *track_entry_data, const nsmkv::AudioData *audio_data, unsigned int preferred_bits, unsigned int max_channels,bool floating_point, ifc_mkvaudiodecoder **decoder)
+{
+ if (!strcmp(codec_id, "A_AAC"))
+ {
+ MKVAACDecoder *aac_decoder = MKVAACDecoder::Create(track_entry_data, audio_data, preferred_bits, max_channels, floating_point);
+ if (aac_decoder)
+ {
+ *decoder = aac_decoder;
+ return CREATEDECODER_SUCCESS;
+ }
+ return CREATEDECODER_FAILURE;
+ }
+
+ return CREATEDECODER_NOT_MINE;
+}
+
+#define CBCLASS MKVDecoder
+START_DISPATCH;
+CB(CREATE_AUDIO_DECODER, CreateAudioDecoder)
+END_DISPATCH;
+#undef CBCLASS \ No newline at end of file
diff --git a/Src/aacdec/MKVAACDecoder.h b/Src/aacdec/MKVAACDecoder.h
new file mode 100644
index 00000000..b4d5f904
--- /dev/null
+++ b/Src/aacdec/MKVAACDecoder.h
@@ -0,0 +1,48 @@
+#pragma once
+#include "../in_mkv/ifc_mkvaudiodecoder.h"
+#include "incs/mp4AudioDecIfc.h"
+#include "../nsmkv/Tracks.h"
+#include "../in_mkv/svc_mkvdecoder.h"
+
+// {7405C1CE-6CD6-4975-B22B-8DBABAA64C44}
+static const GUID AACMKVGUID =
+{ 0x7405c1ce, 0x6cd6, 0x4975, { 0xb2, 0x2b, 0x8d, 0xba, 0xba, 0xa6, 0x4c, 0x44 } };
+
+
+class MKVDecoder : public svc_mkvdecoder
+{
+public:
+ static const char *getServiceName() { return "AAC MKV Decoder"; }
+ static GUID getServiceGuid() { return AACMKVGUID; }
+ int CreateAudioDecoder(const char *codec_id, const nsmkv::TrackEntryData *track_entry_data, const nsmkv::AudioData *audio_data, unsigned int preferred_bits, unsigned int preferred_channels, bool floating_point, ifc_mkvaudiodecoder **decoder);
+protected:
+ RECVS_DISPATCH;
+};
+
+class MKVAACDecoder : public ifc_mkvaudiodecoder
+{
+public:
+ static MKVAACDecoder *Create(const nsmkv::TrackEntryData *track_entry_data, const nsmkv::AudioData *audio_data, unsigned int preferred_bits, unsigned int max_channels, bool floating_point);
+
+protected:
+ RECVS_DISPATCH;
+private:
+ /* ifc_mkvaudiodecoder implementation */
+ int OutputFrameSize(size_t *frame_size);
+ int GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample, bool *isFloat);
+ int DecodeBlock(void *inputBuffer, size_t inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes);
+ void Flush();
+ void Close();
+
+private:
+ MKVAACDecoder(mp4AudioDecoderHandle decoder, CAccessUnitPtr access_unit, CCompositionUnitPtr composition_unit, unsigned int bps, bool floating_point);
+
+ /* internal implementation */
+
+ /* data */
+ mp4AudioDecoderHandle decoder;
+ CCompositionUnitPtr composition_unit; /* output */
+ CAccessUnitPtr access_unit; /* input */
+ unsigned int bps;
+ bool floating_point;
+ }; \ No newline at end of file
diff --git a/Src/aacdec/MP4AACDecoder.cpp b/Src/aacdec/MP4AACDecoder.cpp
new file mode 100644
index 00000000..c8f00003
--- /dev/null
+++ b/Src/aacdec/MP4AACDecoder.cpp
@@ -0,0 +1,236 @@
+#include "MP4AACDecoder.h"
+#include "api.h"
+#include <math.h>
+#include <bfc/platform/minmax.h>
+#include "../nsutil/pcm.h"
+
+
+
+// {B6CB4A7C-A8D0-4c55-8E60-9F7A7A23DA0F}
+static const GUID playbackConfigGroupGUID =
+ { 0xb6cb4a7c, 0xa8d0, 0x4c55, { 0x8e, 0x60, 0x9f, 0x7a, 0x7a, 0x23, 0xda, 0xf } };
+
+MP4AACDecoder::MP4AACDecoder()
+{
+ preDelay = 0;
+ decoder = 0;
+ access_unit = 0;
+ composition_unit = 0;
+ isFloat = false;
+ gain=1.0f;
+ // get bps
+ bitsPerSample = AGAVE_API_CONFIG->GetUnsigned(playbackConfigGroupGUID, L"bits", 16);
+ if (bitsPerSample >= 24) bitsPerSample = 24;
+ else bitsPerSample = 16;
+
+ // get max channels
+ if (AGAVE_API_CONFIG->GetBool(playbackConfigGroupGUID, L"surround", true))
+ maxChannels = 6;
+ else if (AGAVE_API_CONFIG->GetBool(playbackConfigGroupGUID, L"mono", false))
+ maxChannels = 1;
+ else
+ maxChannels = 2;
+}
+
+int MP4AACDecoder::Open()
+{
+ /* with FhG's API, we can't actually create a decoder until we have the ASC.
+ best we can do right now is create the access unit object */
+ access_unit = CAccessUnit_Create(0, 0);
+ if (access_unit)
+ return MP4_SUCCESS;
+ else
+ return MP4_FAILURE;
+}
+
+int MP4AACDecoder::OpenEx(size_t _bits, size_t _maxChannels, bool useFloat)
+{
+ isFloat = useFloat;
+ if (isFloat)
+ {
+ bitsPerSample = 32;
+ }
+ else
+ {
+ if (_bits)
+ bitsPerSample = _bits;
+ if (bitsPerSample >= 24) bitsPerSample = 24;
+ else bitsPerSample = 16;
+ }
+ if (_maxChannels)
+ maxChannels = _maxChannels;
+ return Open();
+}
+
+int MP4AACDecoder::GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *_bitsPerSample)
+{
+ bool dummy;
+ return GetOutputPropertiesEx(sampleRate, channels, _bitsPerSample, &dummy);
+}
+
+int MP4AACDecoder::GetOutputPropertiesEx(unsigned int *sampleRate, unsigned int *channels, unsigned int *_bitsPerSample, bool *useFloat)
+{
+ /* TODO: verify that it's safe to call these, e.g. one frame has been decoded successfully, otherwise call MKV_NEED_MORE_INPUT */
+ CCompositionUnit_GetSamplingRate(composition_unit, sampleRate);
+ CCompositionUnit_GetChannels(composition_unit, channels);
+
+ *_bitsPerSample = bitsPerSample;
+ *useFloat = isFloat;
+ return MP4_SUCCESS;
+}
+
+void MP4AACDecoder::Flush()
+{
+ mp4AudioDecoder_Reset(decoder, MP4AUDIODECPARAM_DEFAULT, 0);
+}
+
+int MP4AACDecoder::GetCurrentBitrate(unsigned int *bitrate)
+{
+ int current_bitrate;
+ if (CCompositionUnit_GetProperty(composition_unit, CUBUFFER_CURRENTBITRATE, &current_bitrate) == MP4AUDIODEC_OK)
+ {
+ *bitrate = current_bitrate/1000;
+ return MP4_SUCCESS;
+ }
+ else
+ return MP4_GETCURRENTBITRATE_UNKNOWN;
+}
+
+int MP4AACDecoder::DecodeSample(void *inputBuffer, size_t inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes)
+{
+ CAccessUnit_Reset(access_unit);
+ CAccessUnit_Assign(access_unit, (const unsigned char *)inputBuffer, inputBufferBytes);
+ CCompositionUnit_Reset(composition_unit);
+ MP4_RESULT result = mp4AudioDecoder_DecodeFrame(decoder, &access_unit, composition_unit);
+
+ if (result == MP4AUDIODEC_OK)
+ {
+ unsigned int channels;
+ unsigned int samples_per_channel;
+ if (CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel) != MP4AUDIODEC_OK
+ || CCompositionUnit_GetChannels(composition_unit, &channels) != MP4AUDIODEC_OK)
+ return MP4_FAILURE;
+ const float *audio_output = 0;
+
+ size_t num_samples = samples_per_channel * channels;
+ size_t output_size = num_samples * (bitsPerSample/8);
+ if (output_size > *outputBufferBytes)
+ return MP4_FAILURE;
+
+ *outputBufferBytes = output_size;
+ CCompositionUnit_GetPcmPtr(composition_unit, &audio_output);
+ if (!isFloat)
+ {
+ nsutil_pcm_FloatToInt_Interleaved_Gain(outputBuffer, audio_output, bitsPerSample, num_samples, gain/32768.0f);
+ }
+ else
+ {
+ for (size_t i = 0;i != num_samples;i++)
+ ((float *)outputBuffer)[i] = audio_output[i] * gain / 32768.0f;
+ }
+
+ return MP4_SUCCESS;
+ }
+ else
+ return MP4_FAILURE;
+}
+
+int MP4AACDecoder::OutputFrameSize(size_t *frameSize)
+{
+ if (!decoder)
+ return MP4_FAILURE;
+
+ unsigned int samples_per_channel;
+ unsigned int channels;
+ if (CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel) != MP4AUDIODEC_OK
+ || CCompositionUnit_GetChannels(composition_unit, &channels) != MP4AUDIODEC_OK)
+ return MP4_FAILURE;
+
+ *frameSize = samples_per_channel*channels;
+ return MP4_SUCCESS;
+}
+
+
+int MP4AACDecoder::AudioSpecificConfiguration(void *buffer, size_t buffer_size) // reads ASC block from mp4 file
+{
+ // TODO: error check
+ if (buffer && buffer_size)
+ {
+ CSAudioSpecificConfig asc;
+ memset(&asc, 0, sizeof(asc));
+ if (mp4AudioDecoder_ascParse((const unsigned char *)buffer, buffer_size, &asc) == MP4AUDIODEC_OK)
+ {
+ CSAudioSpecificConfig *asc_array = &asc;;
+ decoder = mp4AudioDecoder_Create(&asc_array, 1);
+ if (decoder)
+ {
+ mp4AudioDecoder_SetParam(decoder, TDL_MODE, SWITCH_OFF);
+ mp4AudioDecoder_SetParam(decoder, CONCEALMENT_ENERGYINTERPOLATION, SWITCH_OFF);
+ composition_unit = CCompositionUnit_Create(max(asc.m_channels, 8), asc.m_samplesPerFrame * 2, asc.m_samplingFrequency, 6144, CUBUFFER_PCMTYPE_FLOAT);
+ return MP4_SUCCESS;
+ }
+ }
+ }
+
+ return MP4_FAILURE;
+}
+
+void MP4AACDecoder::Close()
+{
+ mp4AudioDecoder_Destroy(&decoder);
+ CAccessUnit_Destroy(&access_unit);
+ CCompositionUnit_Destroy(&composition_unit);
+}
+
+int MP4AACDecoder::CanHandleCodec(const char *codecName)
+{
+ return !strcmp(codecName, "mp4a");
+}
+
+int MP4AACDecoder::CanHandleType(uint8_t type)
+{
+ switch (type)
+ {
+ case MP4_TYPE_MPEG4_AUDIO:
+ return 1;
+ case MP4_TYPE_MPEG2_AAC_LC_AUDIO:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+int MP4AACDecoder::CanHandleMPEG4Type(uint8_t type)
+{
+ switch (type)
+ {
+ case MP4_MPEG4_TYPE_AAC_LC_AUDIO:
+ case MP4_MPEG4_TYPE_AAC_HE_AUDIO:
+ case MP4_MPEG4_TYPE_PARAMETRIC_STEREO:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+#ifdef CBCLASS
+#undef CBCLASS
+#endif
+
+#define CBCLASS MP4AACDecoder
+START_DISPATCH;
+CB(MPEG4_AUDIO_OPEN, Open)
+CB(MPEG4_AUDIO_OPEN_EX, OpenEx)
+CB(MPEG4_AUDIO_ASC, AudioSpecificConfiguration)
+CB(MPEG4_AUDIO_BITRATE, GetCurrentBitrate)
+CB(MPEG4_AUDIO_FRAMESIZE, OutputFrameSize)
+CB(MPEG4_AUDIO_OUTPUTINFO, GetOutputProperties)
+CB(MPEG4_AUDIO_OUTPUTINFO_EX, GetOutputPropertiesEx)
+CB(MPEG4_AUDIO_DECODE, DecodeSample)
+VCB(MPEG4_AUDIO_FLUSH, Flush)
+VCB(MPEG4_AUDIO_CLOSE, Close)
+CB(MPEG4_AUDIO_HANDLES_CODEC, CanHandleCodec)
+CB(MPEG4_AUDIO_HANDLES_TYPE, CanHandleType)
+CB(MPEG4_AUDIO_HANDLES_MPEG4_TYPE, CanHandleMPEG4Type)
+CB(MPEG4_AUDIO_SET_GAIN, SetGain)
+END_DISPATCH;
diff --git a/Src/aacdec/MP4AACDecoder.h b/Src/aacdec/MP4AACDecoder.h
new file mode 100644
index 00000000..ebde1d48
--- /dev/null
+++ b/Src/aacdec/MP4AACDecoder.h
@@ -0,0 +1,40 @@
+#pragma once
+#include "../in_mp4/mpeg4audio.h"
+#include "incs/mp4AudioDecIfc.h"
+
+// {654B5212-018E-45f6-88CF-75862C85D99A}
+static const GUID mp4_aac_guid = { 0x654b5212, 0x18e, 0x45f6, { 0x88, 0xcf, 0x75, 0x86, 0x2c, 0x85, 0xd9, 0x9a } };
+
+class MP4AACDecoder : public MP4AudioDecoder
+{
+public:
+ static const char *getServiceName() { return "AAC MP4 Decoder"; }
+ static GUID getServiceGuid() { return mp4_aac_guid; }
+ MP4AACDecoder();
+ int Open();
+ int OpenEx(size_t bits, size_t maxChannels, bool useFloat);
+ void Close();
+ int GetCurrentBitrate(unsigned int *bitrate);
+ int AudioSpecificConfiguration(void *buffer, size_t buffer_size); // reads ASC block from mp4 file
+ void Flush();
+ int GetOutputProperties(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample);
+ int GetOutputPropertiesEx(unsigned int *sampleRate, unsigned int *channels, unsigned int *bitsPerSample, bool *useFloat);
+ int DecodeSample(void *inputBuffer, size_t inputBufferBytes, void *outputBuffer, size_t *outputBufferBytes);
+ int OutputFrameSize(size_t *frameSize);
+ int CanHandleCodec(const char *codecName);
+ int CanHandleType(uint8_t type);
+ int CanHandleMPEG4Type(uint8_t type);
+ int SetGain(float _gain) { gain=_gain; return MP4_SUCCESS; }
+private:
+ mp4AudioDecoderHandle decoder;
+ CCompositionUnitPtr composition_unit; /* output */
+ CAccessUnitPtr access_unit; /* input */
+
+ size_t preDelay;
+ unsigned int bitsPerSample;
+ size_t maxChannels;
+ bool isFloat;
+ float gain;
+protected:
+ RECVS_DISPATCH;
+};
diff --git a/Src/aacdec/NSVAACDecoder.cpp b/Src/aacdec/NSVAACDecoder.cpp
new file mode 100644
index 00000000..94a6efd7
--- /dev/null
+++ b/Src/aacdec/NSVAACDecoder.cpp
@@ -0,0 +1,229 @@
+#include "NSVAACDecoder.h"
+
+#include <assert.h>
+#include "api.h"
+#include "../nsv/nsvlib.h"
+#include "api.h"
+#include "../nsv/nsvlib.h"
+#include "../nsv/dec_if.h"
+#include <string.h>
+#include <bfc/platform/export.h>
+#include "NSVAACDecoder.h"
+#include <bfc/error.h>
+#ifndef MIN
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+#endif
+
+NSVAACDecoder *NSVAACDecoder::CreateDecoder()
+{
+ CAccessUnitPtr access_unit = CAccessUnit_Create(0, 0);
+ if (!access_unit)
+ return 0;
+
+ NSVAACDecoder *decoder=0;
+ WASABI_API_MEMMGR->New(&decoder);
+ if (!decoder)
+ {
+ CAccessUnit_Destroy(&access_unit);
+ return 0;
+ }
+ decoder->Initialize(access_unit);
+ return decoder;
+}
+
+NSVAACDecoder::NSVAACDecoder()
+{
+ access_unit = 0;
+ composition_unit = 0;
+ decoder = 0;
+ source_position=0;
+ out_left=0;
+ in_position=0;
+}
+
+NSVAACDecoder::~NSVAACDecoder()
+{
+ mp4AudioDecoder_Destroy(&decoder);
+ CAccessUnit_Destroy(&access_unit);
+ CCompositionUnit_Destroy(&composition_unit);
+}
+
+void NSVAACDecoder::Initialize(CAccessUnitPtr _access_unit)
+{
+ access_unit = _access_unit;
+}
+
+void NSVAACDecoder::flush()
+{
+ if (decoder)
+ mp4AudioDecoder_Reset(decoder, MP4AUDIODECPARAM_DEFAULT, 0);
+}
+
+
+static void ConfigureADTS(CSAudioSpecificConfig* asc, nsaac_adts_header_t header)
+{
+ asc->m_aot = (AUDIO_OBJECT_TYPE)(header->profile + 1);
+ asc->m_channelConfiguration = header->channel_configuration;
+ asc->m_channels = nsaac_adts_get_channel_count(header);
+ asc->m_nrOfStreams = 1;
+ asc->m_samplesPerFrame = 1024;
+ asc->m_samplingFrequencyIndex = header->sample_rate_index;
+ asc->m_samplingFrequency = nsaac_adts_get_samplerate(header);
+ asc->m_avgBitRate = 0; /* only needed for tvq */
+ asc->m_mpsPresentFlag = -1;
+ asc->m_saocPresentFlag = -1;
+ asc->m_ldmpsPresentFlag = -1;
+}
+
+// returns -1 on error, 0 on success (done with data in 'in'), 1 on success
+// but to pass 'in' again next time around.
+int NSVAACDecoder::decode(void *in, int in_len, void *out, int *out_len, unsigned int out_fmt[8])
+{
+ if (out_left)
+ {
+ unsigned int channels;
+ unsigned int sample_rate;
+ if (CCompositionUnit_GetChannels(composition_unit, &channels) != MP4AUDIODEC_OK
+ || CCompositionUnit_GetSamplingRate(composition_unit, &sample_rate) != MP4AUDIODEC_OK)
+ return -1;
+
+
+ out_fmt[0] = NSV_MAKETYPE('P', 'C', 'M', ' ');
+ out_fmt[1] = sample_rate;
+ out_fmt[2] = channels;
+ out_fmt[3] = 16;
+
+ const uint8_t *audio_output=0;
+ CCompositionUnit_GetPcmPtr(composition_unit, &audio_output);
+ size_t copy_size = min(out_left, *out_len);
+ memcpy(out, audio_output + source_position, copy_size);
+ *out_len = copy_size;
+ out_left -= copy_size;
+ source_position += copy_size;
+ return 1;
+;
+ }
+
+ in = (uint8_t *)in + in_position;
+ in_len -= in_position;
+
+ if (in_len > 7)
+ {
+ ADTSHeader header;
+ if (nsaac_adts_parse(&header, (const uint8_t *)in) == NErr_Success)
+ {
+ if (!decoder)
+ {
+ CSAudioSpecificConfig asc;
+ memset(&asc, 0, sizeof(asc));
+ ConfigureADTS(&asc, &header);
+
+ CSAudioSpecificConfig *asc_array = &asc;
+ decoder = mp4AudioDecoder_Create(&asc_array, 1);
+ if (decoder)
+ {
+ mp4AudioDecoder_SetParam(decoder, TDL_MODE, SWITCH_ON);
+ mp4AudioDecoder_SetParam(decoder, CONCEALMENT_ENERGYINTERPOLATION, SWITCH_OFF);
+ composition_unit = CCompositionUnit_Create(max(asc.m_channels, 8), asc.m_samplesPerFrame * 2, asc.m_samplingFrequency, 6144, CUBUFFER_PCMTYPE_INT16);
+ }
+ if (!decoder || !composition_unit)
+ {
+ in_position=0;
+ return -1;
+ }
+ }
+ if (header.frame_length > in_len)
+ {
+ in_position=0;
+ return -1;
+ }
+ if (header.frame_length != in_len)
+ {
+ in_position+=header.frame_length;
+ }
+ else
+ {
+ in_position=0;
+ }
+
+ CAccessUnit_Reset(access_unit);
+ CAccessUnit_Assign(access_unit, (const uint8_t *)in + 7, header.frame_length-7);
+ CCompositionUnit_Reset(composition_unit);
+ MP4_RESULT result = mp4AudioDecoder_DecodeFrame(decoder, &access_unit, composition_unit);
+
+ if (result == MP4AUDIODEC_OK)
+ {
+ unsigned int channels;
+ unsigned int samples_per_channel;
+ unsigned int sample_rate;
+ if (CCompositionUnit_GetSamplesPerChannel(composition_unit, &samples_per_channel) != MP4AUDIODEC_OK
+ || CCompositionUnit_GetChannels(composition_unit, &channels) != MP4AUDIODEC_OK
+ || CCompositionUnit_GetSamplingRate(composition_unit, &sample_rate) != MP4AUDIODEC_OK)
+ return -1;
+
+ size_t num_samples = samples_per_channel * channels;
+ size_t output_size = num_samples * 2 /* 16 bits */;
+
+ const uint16_t *audio_output=0;
+ CCompositionUnit_GetPcmPtr(composition_unit, &audio_output);
+ size_t copy_size = min(output_size, *out_len);
+ memcpy(out, audio_output, copy_size);
+ *out_len = copy_size;
+ out_left = output_size - copy_size;
+ source_position = copy_size;
+
+ out_fmt[0] = NSV_MAKETYPE('P', 'C', 'M', ' ');
+ out_fmt[1] = sample_rate;
+ out_fmt[2] = channels;
+ out_fmt[3] = 16;
+
+ int br;
+ CCompositionUnit_GetProperty(composition_unit, CUBUFFER_AVGBITRATE, &br);
+ out_fmt[4] =br/1000;
+ if (in_position)
+ return 1;
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+
+ }
+ else
+ {
+ in_position=0;
+ return -1;
+ }
+ }
+ *out_len = 0;
+ in_position=0;
+ return 0;
+
+}
+
+
+
+IAudioDecoder *NSVDecoder::CreateAudioDecoder(FOURCC format, IAudioOutput **output)
+{
+ switch (format)
+ {
+ case NSV_MAKETYPE('A', 'A', 'C', ' ') :
+ case NSV_MAKETYPE('A', 'A', 'C', 'P'):
+ case NSV_MAKETYPE('A', 'P', 'L', ' '):
+ {
+ NSVAACDecoder *dec = NSVAACDecoder::CreateDecoder();
+ return dec;
+ }
+
+ default:
+ return 0;
+ }
+}
+
+
+#define CBCLASS NSVDecoder
+START_DISPATCH;
+CB(SVC_NSVFACTORY_CREATEAUDIODECODER, CreateAudioDecoder)
+END_DISPATCH;
+#undef CBCLASS
diff --git a/Src/aacdec/NSVAACDecoder.h b/Src/aacdec/NSVAACDecoder.h
new file mode 100644
index 00000000..56b7bf25
--- /dev/null
+++ b/Src/aacdec/NSVAACDecoder.h
@@ -0,0 +1,52 @@
+#pragma once
+#include "../nsv/dec_if.h"
+#include "incs/mp4AudioDecIfc.h"
+#include <bfc/platform/types.h>
+#include "ADTSHeader.h"
+#include "../nsv/svc_nsvFactory.h"
+
+// {55632E28-8171-4670-AE5D-CF714900C62E}
+static const GUID NSV_AAC_GUID =
+{ 0x55632e28, 0x8171, 0x4670, { 0xae, 0x5d, 0xcf, 0x71, 0x49, 0x0, 0xc6, 0x2e } };
+
+class NSVDecoder : public svc_nsvFactory
+{
+public:
+ static const char *getServiceName() { return "AAC NSV Decoder"; }
+ static GUID getServiceGuid() { return NSV_AAC_GUID; }
+ IAudioDecoder *CreateAudioDecoder(FOURCC format, IAudioOutput **output);
+
+protected:
+ RECVS_DISPATCH;
+};
+
+class NSVAACDecoder : public IAudioDecoder
+{
+public:
+ static NSVAACDecoder *CreateDecoder();
+ NSVAACDecoder();
+ ~NSVAACDecoder();
+ void Initialize(CAccessUnitPtr access_unit);
+ int decode(void *in, int in_len, void *out, int *out_len, unsigned int out_fmt[8]);
+ void flush();
+ bool OK();
+
+private:
+ void FillOutputFormat(unsigned int out_fmt[8]);
+ void CopyToOutput(void *out, int *out_len);
+
+private:
+ /* data */
+ mp4AudioDecoderHandle decoder;
+ CCompositionUnitPtr composition_unit; /* output */
+ CAccessUnitPtr access_unit; /* input */
+
+ int in_position;
+ int out_left;
+ size_t source_position;
+// unsigned char pcm_buf[65536*2];
+// int pcm_buf_used;
+// int readpos;
+// unsigned int cbvalid;
+};
+
diff --git a/Src/aacdec/aacdec.rc b/Src/aacdec/aacdec.rc
new file mode 100644
index 00000000..fcff7711
--- /dev/null
+++ b/Src/aacdec/aacdec.rc
@@ -0,0 +1,76 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.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
+ "resource.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
+
diff --git a/Src/aacdec/aacdec.sln b/Src/aacdec/aacdec.sln
new file mode 100644
index 00000000..dca410e0
--- /dev/null
+++ b/Src/aacdec/aacdec.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aacdec", "aacdec.vcproj", "{54B42829-727D-4B31-A370-5FC83F4C30AB}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {54B42829-727D-4B31-A370-5FC83F4C30AB}.Debug|Win32.ActiveCfg = Debug|Win32
+ {54B42829-727D-4B31-A370-5FC83F4C30AB}.Debug|Win32.Build.0 = Debug|Win32
+ {54B42829-727D-4B31-A370-5FC83F4C30AB}.Release|Win32.ActiveCfg = Release|Win32
+ {54B42829-727D-4B31-A370-5FC83F4C30AB}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Src/aacdec/aacdec.vcproj b/Src/aacdec/aacdec.vcproj
new file mode 100644
index 00000000..82aea309
--- /dev/null
+++ b/Src/aacdec/aacdec.vcproj
@@ -0,0 +1,356 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="aacdec"
+ ProjectGUID="{54B42829-727D-4B31-A370-5FC83F4C30AB}"
+ RootNamespace="aacdec"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../Wasabi"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;AACDEC_EXPORTS"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="../nsutil/nsutil.lib"
+ OutputFile="$(ProgramFiles)\winamp\system\aacdec.w5s"
+ LinkIncremental="2"
+ IgnoreDefaultLibraryNames="libmmd.lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
+ SubSystem="2"
+ ImportLibrary="$(IntDir)\$(ProjectName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="1"
+ AdditionalIncludeDirectories="../Wasabi"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;AACDEC_EXPORTS"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ BufferSecurityCheck="false"
+ RuntimeTypeInfo="false"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ DisableSpecificWarnings="4018"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="../nsutil/nsutil.lib msvcrt.lib"
+ OutputFile="$(ProgramFiles)\winamp\system\aacdec.w5s"
+ LinkIncremental="1"
+ GenerateManifest="false"
+ IgnoreAllDefaultLibraries="true"
+ IgnoreDefaultLibraryNames="libmmd.lib;msvcprt.lib"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/$(ProjectName).pdb"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ ImportLibrary="$(IntDir)\$(ProjectName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\ADTSHeader.c"
+ >
+ </File>
+ <File
+ RelativePath=".\ADTSHeader.h"
+ >
+ </File>
+ <File
+ RelativePath=".\api.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\api.h"
+ >
+ </File>
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="AVI"
+ >
+ <File
+ RelativePath=".\AVIAACDecoder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\AVIAACDecoder.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="libs"
+ >
+ <File
+ RelativePath=".\libs\Win32\concealMDCTlib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\fdreverblib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\HdAacDeclib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\libirc.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\limiterlib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\mathlib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\mp4audiodec.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\mpegsDeclib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\qmflib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\readonlybitbuflib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\sbrdecoderlib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\spaceDeclib.lib"
+ >
+ </File>
+ <File
+ RelativePath=".\libs\Win32\utillib.lib"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="MKV"
+ >
+ <File
+ RelativePath=".\MKVAACDecoder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\MKVAACDecoder.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="MP4"
+ >
+ <File
+ RelativePath=".\MP4AACDecoder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\MP4AACDecoder.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="FLV"
+ >
+ <File
+ RelativePath=".\FLVAACDecoder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\FLVAACDecoder.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="MPEG Stream"
+ >
+ <File
+ RelativePath=".\ADTSAACDecoder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ADTSAACDecoder.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="NSV"
+ >
+ <File
+ RelativePath=".\NSVAACDecoder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\NSVAACDecoder.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ >
+ <File
+ RelativePath=".\aacdec.rc"
+ >
+ </File>
+ <File
+ RelativePath=".\resource.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Src/aacdec/api.cpp b/Src/aacdec/api.cpp
new file mode 100644
index 00000000..7072cfc3
--- /dev/null
+++ b/Src/aacdec/api.cpp
@@ -0,0 +1,5 @@
+#include "api.h"
+
+api_service *WASABI_API_SVC=0;
+api_config *AGAVE_API_CONFIG=0;
+api_memmgr *WASABI_API_MEMMGR=0;
diff --git a/Src/aacdec/api.h b/Src/aacdec/api.h
new file mode 100644
index 00000000..3a9bced9
--- /dev/null
+++ b/Src/aacdec/api.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <api/service/api_service.h>
+extern api_service *serviceManager;
+#define WASABI_API_SVC serviceManager
+
+
+#include "../Agave/Config/api_config.h"
+extern api_config *configApi;
+#define AGAVE_API_CONFIG configApi
+
+#include <api/memmgr/api_memmgr.h>
+extern api_memmgr *memmgrApi;
+#define WASABI_API_MEMMGR memmgrApi
diff --git a/Src/aacdec/incs/bitbuffer_c.h b/Src/aacdec/incs/bitbuffer_c.h
new file mode 100644
index 00000000..bab4ca27
--- /dev/null
+++ b/Src/aacdec/incs/bitbuffer_c.h
@@ -0,0 +1,96 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (1998)
+ * All Rights Reserved
+ *
+ * filename: bitbuffer_c.h
+ * project : MPEG-4 Audio Decoder
+ * author : Stefan Gewinner gew@iis.fhg.de
+ * contents/description: memory input class with transport format
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/bitbuffer_c.h,v 1.3 2012/05/08 20:16:49 audiodsp Exp $
+ *
+\***************************************************************************/
+
+#ifndef __BITBUFFER_C_H__
+#define __BITBUFFER_C_H__
+
+#include "mp4dec_helpers/machine.h"
+#include "mp4dec_helpers/bitstream_c.h"
+
+struct CSStreamInfo;
+
+enum
+{
+ CSBitBuffer_BufferSize = 8192,
+ CSBitBuffer_BufferBits = CSBitBuffer_BufferSize*8,
+
+ /* CBitBuffer_InvalidCrcValue = 0xFFFFFFFF, */
+ CBitBuffer_MaximumMarkers = 25*4
+
+ /* , CAverageNumber_MaximumSize = 16 */
+};
+
+
+typedef struct
+{
+ CSBitStream_MarkerPosition what ;
+
+ UINT32 m_elementBits ;
+
+ UINT32 m_ValidBits;
+ UINT32 m_BitCnt;
+ UINT32 m_BitNdx;
+
+} CMarker, *CMarkerPtr ;
+
+typedef struct CSBitBuffer
+{
+ CSBitStream base ;
+
+ UINT32 m_ValidBits;
+ UINT32 m_ReadOffset;
+ UINT32 m_BitCnt;
+ UINT32 m_BitNdx;
+
+ UINT32 m_FramesLeftInPacket ;
+ UINT32 m_FrameCrcValue ;
+
+ INT32 m_isEOF ;
+
+ UINT8 m_Buffer [CSBitBuffer_BufferSize] ;
+
+ /* CAverageNumber m_ActualBitrate ; */
+
+ UINT32 m_LastBufferFullness ;
+ UINT32 m_LastFrameLength ;
+
+ CMarker m_MarkerList [CBitBuffer_MaximumMarkers] ;
+ UINT32 m_Markers ;
+
+} CSBitBuffer, *CSBitBufferPtr ;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void CSBitBuffer_Initialize(CSBitBufferPtr self);
+
+void CSBitBuffer_Feed(CSBitBufferPtr self, const UINT8 pBuf[], const UINT32 cbSize, UINT32 *cbValid);
+
+INT32 CSBitBuffer_IsDecodableFrame(CSBitBufferPtr self, struct CSStreamInfo *info);
+INT32 CSBitBuffer_IsCrcConsistent(CSBitBufferPtr self) ;
+
+void CSBitBuffer_SetEOF(CSBitBufferPtr self) ;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Src/aacdec/incs/mp4AudioDecIfc.h b/Src/aacdec/incs/mp4AudioDecIfc.h
new file mode 100644
index 00000000..e65dcce4
--- /dev/null
+++ b/Src/aacdec/incs/mp4AudioDecIfc.h
@@ -0,0 +1,160 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2001)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4AudioDecIfc.h,v 1.3 2012/05/08 20:16:49 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: interface to mpeg-4 audio decoder
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __MP4AUDIODECIFC_H__
+#define __MP4AUDIODECIFC_H__
+
+
+#include "mp4dec_helpers/err_code.h"
+
+#include "mp4dec_asc/audiospecificconfig_c.h"
+#include "mp4dec_helpers/usrparam.h"
+
+#include "mp4dec_helpers/aubuffer_c.h"
+#include "mp4dec_helpers/cubuffer_c.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#if defined(WIN32) || defined(WIN64)
+ #pragma pack(push, 8)
+#endif
+
+
+/* data types */
+
+typedef struct mp4AudioDecoder_VersionInfo {
+ char dateTime[80];
+ char versionNo[40];
+ char options[1024];
+ char options_ext[4096];
+} mp4AudioDecoder_VersionInfo;
+
+
+/* Opaque declaration of decoder handle */
+struct mp4AudioDecoder;
+typedef struct mp4AudioDecoder* mp4AudioDecoderHandle;
+
+
+/* mandatory decoder functions */
+
+mp4AudioDecoderHandle MP4AUDIODECAPI mp4AudioDecoder_Create(
+ const struct CSAudioSpecificConfig * const asc[],
+ const unsigned int noOfLayers
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_SetParam(
+ const mp4AudioDecoderHandle self,
+ const unsigned int param,
+ const float value
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_DecodeFrame(
+ mp4AudioDecoderHandle self,
+ struct CAccessUnit* auBuffer[],
+ struct CCompositionUnit* cuBuffer
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_Destroy(mp4AudioDecoderHandle* self);
+
+
+/* utility functions */
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_Reset(
+ mp4AudioDecoderHandle self,
+ const unsigned int param,
+ int value
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_Flush(
+ mp4AudioDecoderHandle self,
+ struct CCompositionUnit* cuBuffer
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_GetBufferFullness(
+ const mp4AudioDecoderHandle self,
+ const unsigned int layer,
+ unsigned int* bufferfullness
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_GetSamplesPerFrame(
+ const mp4AudioDecoderHandle self,
+ unsigned int* spf
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_SetOutputLayer(
+ const mp4AudioDecoderHandle self,
+ const unsigned int outputLayer
+ );
+
+/* MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_SetSpeedPitch( */
+/* const mp4AudioDecoderHandle self, */
+/* const float speedChangeFactor, */
+/* const float pitchChangeFactor */
+/* ); */
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_GetLastError(const mp4AudioDecoderHandle self);
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_GetLibraryVersion(mp4AudioDecoder_VersionInfo* versionInfo);
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_ascParse(
+ const unsigned char* decSpecificInfoBuf,
+ const unsigned int decSpecificInfoBuf_len,
+ struct CSAudioSpecificConfig* asc
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_ascParseStream(
+ const unsigned char* decSpecificInfoBuf,
+ struct CSAudioSpecificConfig* asc,
+ int* bitsRead
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_ascParseExt(
+ const unsigned char* const decSpecificInfoBuf[],
+ const unsigned int decSpecificInfoBuf_len[],
+ const unsigned int avgBitrate[],
+ const unsigned int streams,
+ unsigned int* layers, /* out */
+ struct CSAudioSpecificConfig* asc[], /* out */
+ unsigned int streamsPerLayer[] /* out */
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_ascPrint(
+ unsigned int layers, /* in */
+ struct CSAudioSpecificConfig* asc[], /* in */
+ unsigned int stringLen, /* in */
+ unsigned char string[] /* ptr in, content out */
+ );
+
+MP4_RESULT MP4AUDIODECAPI mp4AudioDecoder_GetPcmWidth(
+ const unsigned char* const decSpecificInfoBuf[],
+ const unsigned int decSpecificInfoBuf_len[],
+ const unsigned int streams,
+ unsigned int* pcmwidth /* out */
+ );
+
+
+#if defined(WIN32) || defined(WIN64)
+ #pragma pack(pop)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MP4AUDIODECIFC_H__ */
diff --git a/Src/aacdec/incs/mp4dec_asc/audioobjecttypes.h b/Src/aacdec/incs/mp4dec_asc/audioobjecttypes.h
new file mode 100644
index 00000000..b064a209
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/audioobjecttypes.h
@@ -0,0 +1,89 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (1998)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/audioobjecttypes.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * contents/description: the MPEG-4 Audio object types
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __AUDIOOBJECTTYPES_H__
+#define __AUDIOOBJECTTYPES_H__
+
+typedef enum _AUDIO_OBJECT_TYPE
+{
+ AOT_NULL_OBJECT = 0, /* Null Object (PCM or invalid) */
+ AOT_AAC_MAIN = 1, /* AAC Main Object */
+ AOT_AAC_LC = 2, /* AAC LC Object */
+ AOT_AAC_SSR = 3, /* AAC SSR Object */
+ AOT_AAC_LTP = 4, /* AAC LTP Object */
+ AOT_SBR = 5, /* Meta: SBR, Spectral Band Replication */
+ AOT_AAC_SCAL = 6, /* AAC Scalable Object */
+ AOT_TWIN_VQ = 7, /* TwinVQ Object */
+ AOT_CELP = 8, /* CELP Object */
+ AOT_HVXC = 9, /* HVXC Object */
+ AOT_RSVD_10 = 10, /* (reserved) */
+ AOT_RSVD_11 = 11, /* (reserved) */
+ AOT_TTSI = 12, /* TTSI Object */
+ AOT_MAIN_SYNTH = 13, /* Main Synthetic Object */
+ AOT_WAV_TAB_SYNTH = 14, /* Wavetable Synthesis Object */
+ AOT_GEN_MIDI = 15, /* General MIDI Object */
+ AOT_ALG_SYNTH_AUD_FX = 16, /* Algorithmic Synthesis and Audio FX Object */
+ AOT_ER_AAC_LC = 17, /* Error Resilient(ER) AAC LC Object */
+ AOT_RSVD_18 = 18, /* (reserved) */
+ AOT_ER_AAC_LTP = 19, /* Error Resilient(ER) AAC LTP Object */
+ AOT_ER_AAC_SCAL = 20, /* Error Resilient(ER) AAC Scalable Object */
+ AOT_ER_TWIN_VQ = 21, /* Error Resilient(ER) TwinVQ Object */
+ AOT_ER_BSAC = 22, /* Error Resilient(ER) BSAC Object */
+ AOT_ER_AAC_LD = 23, /* Error Resilient(ER) AAC LD Object */
+ AOT_ER_CELP = 24, /* Error Resilient(ER) CELP Object */
+ AOT_ER_HVXC = 25, /* Error Resilient(ER) HVXC Object */
+ AOT_ER_HILN = 26, /* Error Resilient(ER) HILN Object */
+ AOT_ER_PARA = 27, /* Error Resilient(ER) Parametric Object */
+ AOT_RSVD_28 = 28, /* might become SSC */
+ AOT_PS = 29, /* Meta: PS, Parametric Stereo */
+ AOT_MPEGS = 30, /* MPEG surround */
+
+ AOT_ESCAPE = 31, /* escape AOT for AOTs > 31 */
+
+ AOT_MP3ONMP4_L1 = 32, /* MPEG-Layer-1 in MPEG-4 */
+ AOT_MP3ONMP4_L2 = 33, /* MPEG-Layer-2 in MPEG-4 */
+ AOT_MP3ONMP4_L3 = 34, /* MPEG-Layer-3 in MPEG-4 */
+ AOT_RSVD_35 = 35, /* DST */
+ AOT_RSVD_36 = 36, /* ALS */
+ AOT_SLS = 37, /* SLS w/ core */
+ AOT_SLS_NC = 38, /* SLS non-core */
+ AOT_ER_AAC_ELD = 39, /* ER AAC LD with LD filterbank */
+
+ AOT_RSVD_40 = 40, /* reserved */
+ AOT_RSVD_41 = 41, /* reserved */
+ AOT_RSVD_42 = 42, /* reserved */
+
+ AOT_SAOC = 43, /* SAOC */
+ AOT_LD_MPEGS = 44, /* Low Delay MPEG surround */
+
+ AOT_LZM30 = 94, /* (reserved) */
+ AOT_LZM31 = 95, /* (reserved) */
+
+ AOT_MP2_AAC_MAIN = 128, /* virtual AOT MP2 Main Profile */
+ AOT_MP2_AAC_LC = 129, /* virtual AOT MP2 Low Complexity Profile */
+ AOT_MP2_AAC_SSR = 130, /* virtual AOT MP2 Scalable Sampling Rate Profile */
+
+ AOT_PLAIN_MP1 = 131, /* virtual AOT for plain mp1 decoding */
+ AOT_PLAIN_MP2 = 132, /* virtual AOT for plain mp2 decoding */
+ AOT_PLAIN_MP3 = 133, /* virtual AOT for plain mp3 decoding */
+ AOT_DAB = 134, /* virtual AOT for DAB (Layer2 w/ scalefactor CRC) */
+
+ AOT_INVALID = 555, /* dummy AOT for empty switch/case statements */
+ AOT_DUMMY = 556 /* dummy AOT for empty switch/case statements */
+
+} AUDIO_OBJECT_TYPE;
+
+#endif
diff --git a/Src/aacdec/incs/mp4dec_asc/audiospecificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/audiospecificconfig_c.h
new file mode 100644
index 00000000..cea33cdb
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/audiospecificconfig_c.h
@@ -0,0 +1,127 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (1998)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/audiospecificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: interface to audioSpecificConfig
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __AUDIOSPECIFICCONFIG_C_H__
+#define __AUDIOSPECIFICCONFIG_C_H__
+
+#include "mp4dec_asc/audioobjecttypes.h"
+#include "mp4dec_asc/gaspecificconfig_c.h"
+#include "mp4dec_asc/celpspecificconfig_c.h"
+#include "mp4dec_asc/hvxcspecificconfig_c.h"
+#include "mp4dec_asc/spatialspecificconfig_c.h"
+#include "mp4dec_asc/slsspecificconfig_c.h"
+#include "mp4dec_asc/mpeg12specificconfig_c.h"
+#include "mp4dec_asc/epspecificconfig_c.h"
+#include "mp4dec_asc/eldspecificconfig_c.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+typedef struct CSAudioSpecificConfig {
+
+ AUDIO_OBJECT_TYPE m_aot;
+ AUDIO_OBJECT_TYPE m_origAot;
+ unsigned int m_samplingFrequencyIndex;
+ unsigned int m_samplingFrequency;
+ int m_channelConfiguration;
+ int m_epConfig;
+ unsigned int m_directMapping;
+
+ /* SBR/PS extension */
+ int m_sbrPresentFlag;
+ int m_psPresentFlag;
+ int m_mpsPresentFlag;
+ int m_saocPresentFlag;
+ int m_ldmpsPresentFlag;
+ AUDIO_OBJECT_TYPE m_extensionAudioObjectType;
+ unsigned int m_extensionSamplingFrequencyIndex;
+ unsigned int m_extensionSamplingFrequency;
+
+ /* */
+ unsigned int m_nrOfStreams;
+ unsigned int m_avgBitRate;
+ unsigned int m_layer;
+
+ /* derived values */
+ int m_channels;
+ unsigned int m_samplesPerFrame;
+
+ /* aot-specific asc's */
+ CSGaSpecificConfig m_gaSpecificConfig;
+ CSCelpSpecificConfig m_celpSpecificConfig;
+ HvxcSpecificConfig m_hvxcSpecificConfig;
+ CSSpatialSpecificConfig m_mpegsSpecificConfig;
+ CSSpatialSpecificConfig m_saocSpecificConfig;
+ CSSpatialSpecificConfig m_ldmpegsSpecificConfig;
+ CSMpeg12SpecificConfig m_mpeg12SpecificConfig;
+ CSSlsSpecificConfig m_slsSpecificConfig;
+ CSEldSpecificConfig m_eldSpecificConfig;
+ CEpSpecificConfig m_epSpecificConfig;
+
+} CSAudioSpecificConfig, *CSAudioSpecificConfigPtr;
+
+int AudioSpecificConfig_ParseLatm_amv0(
+ CSAudioSpecificConfigPtr self,
+ struct CSBitStream *bs
+ );
+
+int AudioSpecificConfig_ParseLatm_amv1(
+ CSAudioSpecificConfigPtr self,
+ struct CSBitStream *bs
+ );
+
+int AudioSpecificConfig_ParseExt(
+ CSAudioSpecificConfigPtr self,
+ CSAudioSpecificConfigPtr baselayer,
+ struct CSBitStream *bs,
+ unsigned int streamsPerLayer,
+ unsigned int avgBitrate,
+ unsigned int latm_flag
+ );
+
+void AudioSpecificConfig_Copy(
+ CSAudioSpecificConfigPtr self,
+ const CSAudioSpecificConfigPtr asc
+ );
+
+int AudioSpecificConfig_Compare(
+ const CSAudioSpecificConfigPtr self,
+ const CSAudioSpecificConfigPtr asc
+ );
+
+#ifdef ASC_PRINT
+int AudioSpecificConfig_Print(
+ const CSAudioSpecificConfigPtr asc,
+ char string[]
+ );
+#endif
+
+AUDIO_OBJECT_TYPE __GetAotFromAsc(CSAudioSpecificConfigPtr asc);
+int __GetLayerFromAsc(
+ CSAudioSpecificConfigPtr asc,
+ CSAudioSpecificConfigPtr asc_base
+ );
+char* __GetAotString(AUDIO_OBJECT_TYPE aot);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AUDIOSPECIFICCONFIG_H__ */
diff --git a/Src/aacdec/incs/mp4dec_asc/celpspecificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/celpspecificconfig_c.h
new file mode 100644
index 00000000..0c157fb9
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/celpspecificconfig_c.h
@@ -0,0 +1,64 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2002)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/celpspecificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: celp specific config interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __CELPSPECIFICCONFIG_C_H__
+#define __CELPSPECIFICCONFIG_C_H__
+
+#include "mp4dec_asc/audioobjecttypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+enum {
+ MPE = 0,
+ RPE = 1,
+ fs8KHz = 0,
+ fs16KHz = 1
+};
+
+typedef struct CSCelpSpecificConfig
+{
+ int m_IsBaseLayer;
+ int m_ExcitationMode;
+ int m_SampleRateMode;
+ int m_FineRateControl;
+ int m_RPE_Configuration;
+ int m_MPE_Configuration;
+ int m_NumEnhLayers;
+ int m_BandwidthScalabilityMode;
+ int m_SilenceCompression;
+ int m_BWS_configuration;
+ int m_CelpBrsId;
+
+ unsigned int m_isBWSLayer;
+
+} CSCelpSpecificConfig, *CSCelpSpecificConfigPtr;
+
+void CelpSpecificConfig_Parse(CSCelpSpecificConfigPtr self, CSCelpSpecificConfigPtr baselayer, const AUDIO_OBJECT_TYPE aot, struct CSBitStream *bs);
+int CelpSpecificConfig_GetSamplesPerFrame(CSCelpSpecificConfigPtr self);
+int CelpSpecificConfig_GetLayer(CSCelpSpecificConfigPtr csc, CSCelpSpecificConfigPtr csc_base);
+void CelpSpecificConfig_Copy(CSCelpSpecificConfigPtr dst, const CSCelpSpecificConfigPtr src);
+int CelpSpecificConfig_Print(CSCelpSpecificConfigPtr self, char string[], const AUDIO_OBJECT_TYPE aot);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CELPSPECIFICCONFIG_H__ */
diff --git a/Src/aacdec/incs/mp4dec_asc/eldspecificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/eldspecificconfig_c.h
new file mode 100644
index 00000000..5f6f4a3b
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/eldspecificconfig_c.h
@@ -0,0 +1,75 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2007)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/eldspecificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: eld specific specific config parser - interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __ELDPECIFICCONFIG_C_H__
+#define __ELDPECIFICCONFIG_C_H__
+
+#include "mp4dec_asc/audioobjecttypes.h"
+
+#define MAX_SBR_HEADER_SIZE 4
+#define MAX_ELD_SBR_ELEMENTS 8
+#define MAX_ELD_EXTENSIONS 6
+#define MAX_ELD_EXTENSIONS_LENGTH 32
+
+#define ASC_ELD_ELDEXT_TERM 0x0000
+#define ASC_ELD_ELDEXT_SAOC 0x0001
+#define ASC_ELD_ELDEXT_LDSAC 0x0002
+#define ASC_ELD_ELDEXT_PSEUDOMC 0x0003
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+typedef struct {
+ int tag;
+ int length;
+ unsigned char config_payload[MAX_ELD_EXTENSIONS_LENGTH];
+} ELD_EXTENSION;
+
+typedef struct CSEldSpecificConfig {
+ unsigned int m_frameLengthFlag;
+
+ unsigned int m_vcb11Flag;
+ unsigned int m_rvlcFlag;
+ unsigned int m_hcrFlag;
+
+ unsigned int m_ldSbrPresentFlag;
+ unsigned int m_ldSbrSamplingRateFlag;
+ unsigned int m_ldSbrCrcFlag;
+
+ unsigned int m_useLDQMFTimeAlignment;
+
+ unsigned char m_ldSbrHeaderData[MAX_ELD_SBR_ELEMENTS][MAX_SBR_HEADER_SIZE];
+ ELD_EXTENSION m_eldExtension[MAX_ELD_EXTENSIONS];
+
+} CSEldSpecificConfig, *CSEldSpecificConfigPtr;
+
+void EldSpecificConfig_Parse(CSEldSpecificConfigPtr self, struct CSBitStream *bs, const int channelConfiguration, const AUDIO_OBJECT_TYPE aot, int* ldmpspresent, int* saocpresent);
+void EldSpecificConfig_Copy(CSEldSpecificConfigPtr self, const CSEldSpecificConfigPtr gasc);
+int EldSpecificConfig_Compare(const CSEldSpecificConfigPtr self, const CSEldSpecificConfigPtr eldsc, const AUDIO_OBJECT_TYPE aot);
+#ifdef ASC_PRINT
+int EldSpecificConfig_Print(const CSEldSpecificConfigPtr eldsc, char string[], const int channelConfiguration, const AUDIO_OBJECT_TYPE aot);
+#endif
+ELD_EXTENSION* getEldExtension( int tag, const CSEldSpecificConfigPtr eldsc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ELDPECIFICCONFIG_H__ */
diff --git a/Src/aacdec/incs/mp4dec_asc/epspecificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/epspecificconfig_c.h
new file mode 100644
index 00000000..e9cc1a5d
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/epspecificconfig_c.h
@@ -0,0 +1,89 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2002)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/epspecificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: EP specific config interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+
+#ifndef __EPSPECIFICCONFIG_C_H__
+#define __EPSPECIFICCONFIG_C_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+typedef struct CEpClassConfig {
+ unsigned int m_LengthEsc;
+ unsigned int m_RateEsc;
+ unsigned int m_CrcLengthEsc;
+
+ unsigned int m_ConcatenateFlag;
+ unsigned int m_FecType;
+ unsigned int m_TerminationSwitch;
+
+ unsigned int m_InterleaveSwitch;
+ unsigned int m_ClassOptional;
+
+ unsigned int m_NoBitsForLength;
+ unsigned int m_ClassLength;
+
+ unsigned int m_ClassRate;
+ unsigned int m_ClassCrcLength;
+} CEpClassConfig, *CEpClassConfigPtr;
+
+typedef struct CPredSetConfig {
+
+ unsigned int m_NoOfClasses;
+ unsigned int m_ClassReorderedOutput;
+ unsigned int *m_ClassOutputOrder;
+ CEpClassConfig *m_EpClassConfig;
+} CPredSetConfig, *CPredSetConfigPtr;
+
+
+typedef struct CEPBuffer {
+ unsigned char* m_pData;
+ unsigned int m_noBytes;
+ unsigned int m_noBits;
+} CEPBuffer, *CEPBufferPtr;
+
+typedef struct CEPSpecificConfig {
+
+ unsigned int m_NoOfPredSets;
+ unsigned int m_InterleaveType;
+ unsigned int m_BitStuffing;
+ unsigned int m_NoOfConcatenatedFrames;
+
+ unsigned int m_HeaderProtection;
+ unsigned int m_HeaderRate;
+ unsigned int m_HeaderCrcLength;
+
+ unsigned int m_RSFecCapability;
+
+ CPredSetConfig *m_psc;
+ CEPBuffer m_epTmpBuffer;
+
+} CEpSpecificConfig, *CEpSpecificConfigPtr;
+
+int EpSpecificConfig_Parse(CEpSpecificConfigPtr self, struct CSBitStream *bs);
+int EpSpecificConfig_Copy(CEpSpecificConfigPtr self, CEpSpecificConfigPtr epsc);
+int EpSpecificConfig_Compare(CEpSpecificConfigPtr self, CEpSpecificConfigPtr epsc);
+void EpSpecificConfig_Free(CEpSpecificConfigPtr self);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Src/aacdec/incs/mp4dec_asc/gaspecificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/gaspecificconfig_c.h
new file mode 100644
index 00000000..fe96e626
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/gaspecificconfig_c.h
@@ -0,0 +1,61 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (1998)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/gaspecificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: global audio specific config interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __GASPECIFICCONFIG_C_H__
+#define __GASPECIFICCONFIG_C_H__
+
+#include "mp4dec_asc/audioobjecttypes.h"
+#include "mp4dec_asc/programcfg_c.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+typedef struct CSGaSpecificConfig {
+ unsigned int m_frameLengthFlag;
+ unsigned int m_dependsOnCoreCoder;
+ unsigned int m_coreCoderDelay;
+
+ unsigned int m_extensionFlag;
+ unsigned int m_extensionFlag3;
+
+ unsigned int m_layer;
+ unsigned int m_numOfSubFrame;
+ unsigned int m_layerLength;
+
+ unsigned int m_vcb11Flag;
+ unsigned int m_rvlcFlag;
+ unsigned int m_hcrFlag;
+
+ CSProgramConfig m_progrConfigElement;
+
+} CSGaSpecificConfig, *CSGaSpecificConfigPtr;
+
+void GaSpecificConfig_Parse(CSGaSpecificConfigPtr self, struct CSBitStream *bs, const int channelConfiguration, const AUDIO_OBJECT_TYPE aot);
+void GaSpecificConfig_Copy(CSGaSpecificConfigPtr self, const CSGaSpecificConfigPtr gasc);
+int GaSpecificConfig_Compare(const CSGaSpecificConfigPtr self, const CSGaSpecificConfigPtr gasc, const AUDIO_OBJECT_TYPE aot);
+#ifdef ASC_PRINT
+int GaSpecificConfig_Print(const CSGaSpecificConfigPtr gasc, char string[], const int channelConfiguration, const AUDIO_OBJECT_TYPE aot);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GASPECIFICCONFIG_H__ */
diff --git a/Src/aacdec/incs/mp4dec_asc/hvxcspecificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/hvxcspecificconfig_c.h
new file mode 100644
index 00000000..06a0b070
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/hvxcspecificconfig_c.h
@@ -0,0 +1,43 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2002)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/hvxcspecificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: HVXC specific config interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __HVXCSPECIFICCONFIG_C_H__
+#define __HVXCSPECIFICCONFIG_C_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+typedef struct HvxcSpecificConfig {
+ int m_isBaseLayer;
+ int m_DPvarMode;
+ int m_DPrateMode;
+ int m_DPextensionFlag;
+ int m_vrScalFlag;
+} HvxcSpecificConfig, *HvxcSpecificConfigPtr;
+
+void HvxcSpecificConfig_Parse( HvxcSpecificConfigPtr self, HvxcSpecificConfigPtr baselayer, struct CSBitStream *bs);
+void HvxcSpecificConfig_Copy(HvxcSpecificConfigPtr dst, const HvxcSpecificConfigPtr src);
+int HvxcSpecificConfig_Print( HvxcSpecificConfigPtr self, char string[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __HVXCSPECIFICCONFIG_H__ */
diff --git a/Src/aacdec/incs/mp4dec_asc/mpeg12specificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/mpeg12specificconfig_c.h
new file mode 100644
index 00000000..686028d5
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/mpeg12specificconfig_c.h
@@ -0,0 +1,43 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2003)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/mpeg12specificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: MP3OnMP4 specific config interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __MPEG12SPECIFICCONFIG_C_H__
+#define __MPEG12SPECIFICCONFIG_C_H__
+
+#include "mp4dec_asc/audioobjecttypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+typedef struct CSMpeg12SpecificConfig {
+ /* unsigned int m_ID; */
+ /* unsigned int m_layer; */
+ unsigned int m_reserved;
+} CSMpeg12SpecificConfig, *CSMpeg12SpecificConfigPtr;
+
+int Mpeg12SpecificConfig_Parse(CSMpeg12SpecificConfigPtr self, struct CSBitStream *bs);
+/* void Mpeg12SpecificConfig_Set(CSMpeg12SpecificConfigPtr self, const CSMpeg12SpecificConfigPtr mp12sc, const AUDIO_OBJECT_TYPE aot); */
+/* int Mpeg12SpecificConfig_Compare(const CSMpeg12SpecificConfigPtr self, const CSMpeg12SpecificConfigPtr mp12sc, const AUDIO_OBJECT_TYPE aot); */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __MPEG12SPECIFICCONFIG_H__ */
diff --git a/Src/aacdec/incs/mp4dec_asc/programcfg_c.h b/Src/aacdec/incs/mp4dec_asc/programcfg_c.h
new file mode 100644
index 00000000..45c1c6cf
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/programcfg_c.h
@@ -0,0 +1,140 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2002)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/programcfg_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: program config specific description
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+
+#ifndef __PROGRAMCFGC_H__
+#define __PROGRAMCFGC_H__
+
+#include "mp4dec_helpers/cubuffer_c.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+enum
+{
+ /* PCE settings */
+ CSProgramConfig_FrontRow = 0,
+ CSProgramConfig_SideRow = 1,
+ CSProgramConfig_BackRow = 2,
+ CSProgramConfig_SpeakerRows = 3,
+
+ CSProgramConfig_MaximumChannels = 16,
+ CSProgramConfig_MaximumCommentLength = 256,
+
+ /* aac profile definitions */
+ CAAC_ProfileMain = 0,
+ CAAC_ProfileLowComplexity,
+ CAAC_ProfileSSR,
+ CAAC_ProfileLTP,
+ CAAC_ProfileScalable,
+ CAAC_ProfileReserved
+};
+
+
+typedef struct CSProgramConfig
+{
+ /* non-multichannel configuration */
+
+ int m_NonMC_ConfigSet;
+ int m_NonMC_IsCPE;
+
+ int m_NonMC_Tag;
+
+ /* */
+
+ int m_ExplicitMapping;
+
+ int m_Profile;
+ int m_SamplingFrequencyIndex;
+
+ int m_NumLfeChannelElements;
+ int m_NumAssocDataElements;
+ int m_NumValidCcElements;
+
+ int m_MonoMixdownPresent;
+ int m_MonoMixdownElementNumber;
+
+ int m_StereoMixdownPresent;
+ int m_StereoMixdownElementNumber;
+
+ int m_MatrixMixdownIndexPresent;
+ int m_MatrixMixdownIndex;
+ int m_PseudoSurroundEnable;
+
+ unsigned int m_NumberOfChannels[CSProgramConfig_SpeakerRows];
+ int m_NumberOfChannelElements[CSProgramConfig_SpeakerRows];
+
+ int m_ChannelElementIsCpe[CSProgramConfig_SpeakerRows][CSProgramConfig_MaximumChannels];
+ unsigned int m_ChannelElementTagSelect[CSProgramConfig_SpeakerRows][CSProgramConfig_MaximumChannels];
+
+ unsigned int m_LfeElementTagSelect[CSProgramConfig_MaximumChannels];
+ unsigned int m_AssocDataElementTagSelect[CSProgramConfig_MaximumChannels];
+
+ int m_CcElementIsIndSw[CSProgramConfig_MaximumChannels];
+ unsigned int m_ValidCcElementTagSelect[CSProgramConfig_MaximumChannels];
+
+ int m_CommentFieldBytes;
+ unsigned char m_Comment[CSProgramConfig_MaximumCommentLength];
+
+} CSProgramConfig, *CSProgramConfigPtr;
+
+/* methods */
+
+void CSProgramConfig_Initialize(CSProgramConfigPtr self);
+void CSProgramConfig_Read (CSProgramConfigPtr self, struct CSBitStream *bs);
+void CSProgramConfig_ReadExt (CSProgramConfigPtr self, struct CSBitStream *bs, CCompositionUnitPtr cubuffer, const unsigned int tag);
+void CSProgramConfig_Copy (CSProgramConfigPtr dst, const CSProgramConfigPtr src);
+
+int CSProgramConfig_AddChannel(CSProgramConfigPtr self, const unsigned int tag, const unsigned int isCPE);
+
+
+int CSProgramConfig_AddSingleChannel (CSProgramConfigPtr self, const unsigned int tag);
+int CSProgramConfig_AddChannelPair (CSProgramConfigPtr self, const unsigned int tag);
+int CSProgramConfig_AddCouplingChannel (CSProgramConfigPtr self, const unsigned int tag);
+int CSProgramConfig_AddLowFrequencyChannel(CSProgramConfigPtr self, const unsigned int tag);
+
+int CSProgramConfig_IsChannelLocatedAt (CSProgramConfigPtr self, const unsigned int row, const unsigned int tag);
+int CSProgramConfig_IsChannelPairLocatedAt(CSProgramConfigPtr self, const unsigned int row, const unsigned int tag);
+
+/* explicit query */
+
+
+/* query by index */
+
+int CSProgramConfig_GetNumberOfElements(CSProgramConfigPtr self, const unsigned int row);
+int CSProgramConfig_GetNumberOfChannels(CSProgramConfigPtr self);
+int CSProgramConfig_GetNumberOfChannelsPerRow(CSProgramConfigPtr self, const unsigned int row);
+
+int CSProgramConfig_GetElementTag(CSProgramConfigPtr self, const unsigned int row, const unsigned int index);
+int CSProgramConfig_IsChannelPair(CSProgramConfigPtr self, const unsigned int row, const unsigned int index);
+
+int CSProgramConfig_GetNumberOfLowFrequencyChannels(CSProgramConfigPtr self);
+int CSProgramConfig_GetLowFrequencyChannelTag (CSProgramConfigPtr self, const unsigned int index);
+
+/* */
+
+int CSProgramConfig_GetSamplingRateIndex(CSProgramConfigPtr self);
+int CSProgramConfig_GetProfile (CSProgramConfigPtr self);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Src/aacdec/incs/mp4dec_asc/slsspecificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/slsspecificconfig_c.h
new file mode 100644
index 00000000..499d493b
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/slsspecificconfig_c.h
@@ -0,0 +1,51 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2007)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/slsspecificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: sls specific config interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __SLSSPECIFICCONFIG_C_H__
+#define __SLSSPECIFICCONFIG_C_H__
+
+#include "mp4dec_asc/audioobjecttypes.h"
+#include "mp4dec_asc/programcfg_c.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct CSBitStream;
+
+typedef struct CSSlsSpecificConfig {
+ unsigned int m_pcmWordLength;
+ unsigned int m_aacCorePresent;
+ unsigned int m_lleMainStream;
+ unsigned int m_reservedBit;
+ unsigned int m_frameLength;
+
+ CSProgramConfig m_progrConfigElement;
+} CSSlsSpecificConfig, *CSSlsSpecificConfigPtr;
+
+int getSlsFrameLen(int idx);
+
+int SlsSpecificConfig_Parse(CSSlsSpecificConfigPtr self, struct CSBitStream *bs, const int channelConfiguration);
+/* void SlsSpecificConfig_Set(CSSlsSpecificConfigPtr self, const CSSlsSpecificConfigPtr slssc, const AUDIO_OBJECT_TYPE aot); */
+/* int SlsSpecificConfig_Compare(const CSSlsSpecificConfigPtr self, const CSSlsSpecificConfigPtr slssc, const AUDIO_OBJECT_TYPE aot); */
+int SlsSpecificConfig_Print(CSSlsSpecificConfigPtr self, char string[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLSSPECIFICCONFIG_H__ */
diff --git a/Src/aacdec/incs/mp4dec_asc/spatialspecificconfig_c.h b/Src/aacdec/incs/mp4dec_asc/spatialspecificconfig_c.h
new file mode 100644
index 00000000..842140a5
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_asc/spatialspecificconfig_c.h
@@ -0,0 +1,49 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2007)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_asc/spatialspecificconfig_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: spatial specific config interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __SPATIALSPECIFICCONFIG_C_H__
+#define __SPATIALSPECIFICCONFIG_C_H__
+
+#include "mp4dec_asc/audioobjecttypes.h"
+#include "sac_dec_ssc_struct.h"
+
+#define MAX_SSC_SIZE (256)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct CSBitStream;
+
+typedef struct CSSpatialSpecificConfig {
+ unsigned int m_sacPayloadEmbedding;
+ unsigned char m_sscbinarybuffer[MAX_SSC_SIZE];
+ unsigned int m_ssclen;
+ SPATIAL_SPECIFIC_CONFIG m_sscstruct;
+ unsigned int m_isLdmps;
+} CSSpatialSpecificConfig, *CSSpatialSpecificConfigPtr;
+
+ int SpatialSpecificConfig_Parse(CSSpatialSpecificConfigPtr self, struct CSBitStream *bs, unsigned int isLdmps);
+/* void SpatialSpecificConfig_Set(CSSpatialSpecificConfigPtr self, const CSSpatialSpecificConfigPtr mpegssc, const AUDIO_OBJECT_TYPE aot); */
+/* int SpatialSpecificConfig_Compare(const CSSpatialSpecificConfigPtr self, const CSSpatialSpecificConfigPtr mpegssc, const AUDIO_OBJECT_TYPE aot); */
+int SpatialSpecificConfig_Print(CSSpatialSpecificConfigPtr self, char string[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SPATIALSPECIFICCONFIG_H__ */
diff --git a/Src/aacdec/incs/mp4dec_helpers/aubuffer_c.h b/Src/aacdec/incs/mp4dec_helpers/aubuffer_c.h
new file mode 100644
index 00000000..4c80892f
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_helpers/aubuffer_c.h
@@ -0,0 +1,62 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (1998)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_helpers/aubuffer_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: access unit module public interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __AUBUFFERC_H__
+#define __AUBUFFERC_H__
+
+#include "mp4dec_helpers/err_code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(WIN32) || defined(WIN64)
+ #pragma pack(push, 8)
+#endif
+
+
+/* Opaque declaration of access unit handle */
+struct CAccessUnit;
+typedef struct CAccessUnit* CAccessUnitPtr;
+
+CAccessUnitPtr MP4AUDIODECAPI CAccessUnit_Create(const unsigned char *pBuffer, const unsigned int size);
+
+MP4_RESULT MP4AUDIODECAPI CAccessUnit_Reset (const CAccessUnitPtr self);
+
+MP4_RESULT MP4AUDIODECAPI CAccessUnit_Assign(const CAccessUnitPtr self,
+ const unsigned char *pBuffer,
+ const unsigned int size);
+
+MP4_RESULT MP4AUDIODECAPI CAccessUnit_GetBitCount(const CAccessUnitPtr self, unsigned int* nBits);
+MP4_RESULT MP4AUDIODECAPI CAccessUnit_GetValidBits(const CAccessUnitPtr self, unsigned int* nBits);
+
+MP4_RESULT MP4AUDIODECAPI CAccessUnit_MarkAsInvalid(const CAccessUnitPtr self);
+
+int MP4AUDIODECAPI CAccessUnit_IsValid(const CAccessUnitPtr self);
+
+MP4_RESULT MP4AUDIODECAPI CAccessUnit_Destroy(CAccessUnitPtr *self);
+
+#if defined(WIN32) || defined(WIN64)
+ #pragma pack(pop)
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Src/aacdec/incs/mp4dec_helpers/bitstream_c.h b/Src/aacdec/incs/mp4dec_helpers/bitstream_c.h
new file mode 100644
index 00000000..223e7f4b
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_helpers/bitstream_c.h
@@ -0,0 +1,83 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2000)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_helpers/bitstream_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: bitstream module interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __BITSTREAMC_H__
+#define __BITSTREAMC_H__
+
+#include "mp4dec_helpers/machine.h"
+
+/* CRC Markers for SetPositionMarker(). */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum CSBitStream_MarkerPosition
+{
+ CSBitStream_ChannelElementStart,
+ CSBitStream_ChannelElementStop,
+ CSBitStream_AncillaryElementStart,
+ CSBitStream_AncillaryElementStop,
+ CSBitStream_SecondIndividualChannelStart,
+ CSBitStream_CurrentPosition
+
+} CSBitStream_MarkerPosition;
+
+typedef enum {
+ NO_EPCONF = -1,
+ EPCONF0 = 0,
+ EPCONF1 = 1,
+ EPCONF2 = 2,
+ EPCONF3 = 3
+} __epconf_types;
+
+typedef struct CSBitStream
+{
+ void (*ByteAlign) (struct CSBitStream *self);
+ void (*PushBack) (struct CSBitStream *self, INT32 n);
+ INT32 (*Get) (struct CSBitStream *self, INT32 elemID, INT32 n);
+
+ void (*SetPositionMarker) (struct CSBitStream *self, INT32 id);
+ void (*SetCRCPositionMarker) (struct CSBitStream *self, CSBitStream_MarkerPosition position) ;
+
+ INT32 (*GetBitCount) (struct CSBitStream *self);
+ INT32 (*GetValidBits) (struct CSBitStream *self);
+ INT32 (*GetValidBitsEp1) (struct CSBitStream *self, INT32 err_sens_class);
+
+ UINT8* (*GetDataPointer) (struct CSBitStream *self);
+
+ UINT32 m_BitsInCache;
+ UINT32 m_CacheWord;
+ INT32 m_erFlag;
+
+} CSBitStream, *CSBitStreamPtr;
+
+INT32 __getBits (CSBitStreamPtr self, INT32 elemID, INT32 nBits);
+void __pushBack (CSBitStreamPtr self, INT32 nBits);
+void __byteAlign (CSBitStreamPtr self);
+void __setPositionMarker (CSBitStreamPtr self, INT32 id);
+void __setCRCPositionMarker (CSBitStreamPtr self, CSBitStream_MarkerPosition position) ;
+INT32 __getBitCount (CSBitStreamPtr self);
+INT32 __getValidBits (CSBitStreamPtr self);
+INT32 __getValidBits_ep1 (CSBitStreamPtr self, INT32 err_sens_class);
+UINT8* __getDataPointer (CSBitStreamPtr self);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/Src/aacdec/incs/mp4dec_helpers/cubuffer_c.h b/Src/aacdec/incs/mp4dec_helpers/cubuffer_c.h
new file mode 100644
index 00000000..dc211256
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_helpers/cubuffer_c.h
@@ -0,0 +1,340 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2001)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_helpers/cubuffer_c.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: composition unit module public interface
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __CUBUFFER_C_H__
+#define __CUBUFFER_C_H__
+
+#include "mp4dec_helpers/err_code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ CUBUFFER_MAXCHANNELS = 100,
+ CUBUFFER_MAXSAMPLESPERCHANNEL = 8192,
+ CUBUFFER_MAXANCBYTES = 65536
+} __cubuffer_constants;
+
+
+typedef enum {
+ CUBUFFER_PCMTYPE_FLOAT = 0x55,
+ CUBUFFER_PCMTYPE_INT32,
+ CUBUFFER_PCMTYPE_INT24,
+ /* CUBUFFER_PCMTYPE_INT20, */
+ CUBUFFER_PCMTYPE_INT16
+ /* ,CUBUFFER_PCMTYPE_INT8 */
+} CUBUFFER_PCMTYPE;
+
+typedef enum {
+ ANCDATA_IS_INVALID = 0x00, /* default after calloc */
+
+ ANCDATA_IS_COMPLETE_MP2FRAME,
+ ANCDATA_IS_MP2ANCILLARYDATA,
+ ANCDATA_IS_MP3ANCILLARYDATA,
+ ANCDATA_IS_MP3SCF,
+ ANCDATA_IS_MPEGS_AU,
+
+ ANCDATA_IS_AAC_EXT_DRC,
+ ANCDATA_IS_AAC_EXT_SAC,
+ ANCDATA_IS_AAC_EXT_LDSAC,
+ ANCDATA_IS_AAC_EXT_SAOC,
+ ANCDATA_IS_AAC_EXT_SCESBR,
+ ANCDATA_IS_AAC_EXT_CPESBR,
+ ANCDATA_IS_AAC_EXT_SCESBRCRC,
+ ANCDATA_IS_AAC_EXT_CPESBRCRC,
+ ANCDATA_IS_AAC_ELD_SCESBR,
+ ANCDATA_IS_AAC_ELD_CPESBR,
+ ANCDATA_IS_AAC_ELD_SCESBRCRC,
+ ANCDATA_IS_AAC_ELD_CPESBRCRC,
+ ANCDATA_IS_AAC_EXT_FILLDATA, /* is always 10100101 */
+ ANCDATA_IS_AAC_EXT_DATAELEMENT_ANCDATA,
+ ANCDATA_IS_AAC_EXT_DATAELEMENT_DEFAULT,
+ ANCDATA_IS_AAC_EXT_FIL,
+ ANCDATA_IS_AAC_EXT_DEFAULT,
+
+ ANCDATA_IS_AAC_DSE_TAG0 = 0x80,
+ ANCDATA_IS_AAC_DSE_TAG1,
+ ANCDATA_IS_AAC_DSE_TAG2,
+ ANCDATA_IS_AAC_DSE_TAG3,
+ ANCDATA_IS_AAC_DSE_TAG4,
+ ANCDATA_IS_AAC_DSE_TAG5,
+ ANCDATA_IS_AAC_DSE_TAG6,
+ ANCDATA_IS_AAC_DSE_TAG7,
+ ANCDATA_IS_AAC_DSE_TAG8,
+ ANCDATA_IS_AAC_DSE_TAG9,
+ ANCDATA_IS_AAC_DSE_TAG10,
+ ANCDATA_IS_AAC_DSE_TAG11,
+ ANCDATA_IS_AAC_DSE_TAG12,
+ ANCDATA_IS_AAC_DSE_TAG13,
+ ANCDATA_IS_AAC_DSE_TAG14,
+ ANCDATA_IS_AAC_DSE_TAG15,
+
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG0 = 0x90,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG1,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG2,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG3,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG4,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG5,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG6,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG7,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG8,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG9,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG10,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG11,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG12,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG13,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG14,
+ ANCDATA_IS_AAC_PCE_COMMENTFIELD_TAG15,
+
+ ANCDATA_IS_INCOMPLETE = 0x0fd,
+ BUFFER_IS_TOOSMALL_WITH_CLIPPED_DATA = 0xfe,
+ BUFFER_IS_TOOSMALL_NOMORE_DATA = 0x0ff
+} __cubuffer_ancDataBufTags;
+
+
+typedef enum {
+ CUBUFFER_CHANNEL_IS_INVALID = 0x0000, /* default after init/calloc */ /* todo: we shouldn't name this INVALID, but DEFAULT or NOT_MAPPED or so ... */
+
+ CUBUFFER_CHANNEL_IS_NOTMAPPED = 0x0001, /* a valid pcm channel is here, but could not be mapped to a valid position */
+ CUBUFFER_CHANNEL_IS_ELSEWHERE, /* position is out of z-plane */
+
+ CUBUFFER_CHANNEL_IS_CENTER = 0x0008,
+ CUBUFFER_CHANNEL_IS_REARCENTER,
+
+ CUBUFFER_CHANNEL_IS_LEFT0 = 0x0010,
+ CUBUFFER_CHANNEL_IS_LEFT1,
+ CUBUFFER_CHANNEL_IS_LEFT2,
+ CUBUFFER_CHANNEL_IS_LEFT3,
+ CUBUFFER_CHANNEL_IS_LEFT4,
+ CUBUFFER_CHANNEL_IS_LEFT5,
+ CUBUFFER_CHANNEL_IS_LEFT6,
+ CUBUFFER_CHANNEL_IS_LEFT7,
+ CUBUFFER_CHANNEL_IS_LEFT8,
+ CUBUFFER_CHANNEL_IS_LEFT9,
+ CUBUFFER_CHANNEL_IS_LEFT10,
+ CUBUFFER_CHANNEL_IS_LEFT11,
+ CUBUFFER_CHANNEL_IS_LEFT12,
+ CUBUFFER_CHANNEL_IS_LEFT13,
+ CUBUFFER_CHANNEL_IS_LEFT14,
+ CUBUFFER_CHANNEL_IS_LEFT15,
+
+ CUBUFFER_CHANNEL_IS_LEFTSIDE0 = 0x0020,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE1,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE2,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE3,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE4,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE5,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE6,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE7,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE8,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE9,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE10,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE11,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE12,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE13,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE14,
+ CUBUFFER_CHANNEL_IS_LEFTSIDE15,
+
+ CUBUFFER_CHANNEL_IS_LEFTBACK0 = 0x0030,
+ CUBUFFER_CHANNEL_IS_LEFTBACK1,
+ CUBUFFER_CHANNEL_IS_LEFTBACK2,
+ CUBUFFER_CHANNEL_IS_LEFTBACK3,
+ CUBUFFER_CHANNEL_IS_LEFTBACK4,
+ CUBUFFER_CHANNEL_IS_LEFTBACK5,
+ CUBUFFER_CHANNEL_IS_LEFTBACK6,
+ CUBUFFER_CHANNEL_IS_LEFTBACK7,
+ CUBUFFER_CHANNEL_IS_LEFTBACK8,
+ CUBUFFER_CHANNEL_IS_LEFTBACK9,
+ CUBUFFER_CHANNEL_IS_LEFTBACK10,
+ CUBUFFER_CHANNEL_IS_LEFTBACK11,
+ CUBUFFER_CHANNEL_IS_LEFTBACK12,
+ CUBUFFER_CHANNEL_IS_LEFTBACK13,
+ CUBUFFER_CHANNEL_IS_LEFTBACK14,
+ CUBUFFER_CHANNEL_IS_LEFTBACK15,
+
+ CUBUFFER_CHANNEL_IS_RIGHT0 = 0x0050,
+ CUBUFFER_CHANNEL_IS_RIGHT1,
+ CUBUFFER_CHANNEL_IS_RIGHT2,
+ CUBUFFER_CHANNEL_IS_RIGHT3,
+ CUBUFFER_CHANNEL_IS_RIGHT4,
+ CUBUFFER_CHANNEL_IS_RIGHT5,
+ CUBUFFER_CHANNEL_IS_RIGHT6,
+ CUBUFFER_CHANNEL_IS_RIGHT7,
+ CUBUFFER_CHANNEL_IS_RIGHT8,
+ CUBUFFER_CHANNEL_IS_RIGHT9,
+ CUBUFFER_CHANNEL_IS_RIGHT10,
+ CUBUFFER_CHANNEL_IS_RIGHT11,
+ CUBUFFER_CHANNEL_IS_RIGHT12,
+ CUBUFFER_CHANNEL_IS_RIGHT13,
+ CUBUFFER_CHANNEL_IS_RIGHT14,
+ CUBUFFER_CHANNEL_IS_RIGHT15,
+
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE0 = 0x0060,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE1,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE2,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE3,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE4,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE5,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE6,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE7,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE8,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE9,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE10,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE11,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE12,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE13,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE14,
+ CUBUFFER_CHANNEL_IS_RIGHTSIDE15,
+
+ CUBUFFER_CHANNEL_IS_RIGHTBACK0 = 0x0070,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK1,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK2,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK3,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK4,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK5,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK6,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK7,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK8,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK9,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK10,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK11,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK12,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK13,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK14,
+ CUBUFFER_CHANNEL_IS_RIGHTBACK15,
+
+ CUBUFFER_CHANNEL_IS_SUB0 = 0x0090,
+ CUBUFFER_CHANNEL_IS_SUB1,
+ CUBUFFER_CHANNEL_IS_SUB2,
+ CUBUFFER_CHANNEL_IS_SUB3,
+ CUBUFFER_CHANNEL_IS_SUB4,
+ CUBUFFER_CHANNEL_IS_SUB5,
+ CUBUFFER_CHANNEL_IS_SUB6,
+ CUBUFFER_CHANNEL_IS_SUB7,
+ CUBUFFER_CHANNEL_IS_SUB8,
+ CUBUFFER_CHANNEL_IS_SUB9,
+ CUBUFFER_CHANNEL_IS_SUB10,
+ CUBUFFER_CHANNEL_IS_SUB11,
+ CUBUFFER_CHANNEL_IS_SUB12,
+ CUBUFFER_CHANNEL_IS_SUB13,
+ CUBUFFER_CHANNEL_IS_SUB14,
+ CUBUFFER_CHANNEL_IS_SUB15,
+
+ CUBUFFER_CHANNELMAPPING_LAST_ELEMENT
+} __cubuffer_channelMappingTagTypes;
+
+
+typedef enum {
+ CUBUFFER_INVALID_VALUE = -1,
+
+ __cubuffer_flags_start = 10000,
+ CUBUFFER_VALIDCHANNELS,
+ CUBUFFER_CHANNELSMAPPED,
+ CUBUFFER_VALIDSAMPLES,
+ CUBUFFER_SAMPLERATE,
+ CUBUFFER_NROFLAYERS,
+ CUBUFFER_CURRENTBITRATE,
+ CUBUFFER_AVGBITRATE,
+ CUBUFFER_DECODERDELAY,
+ /* CUBUFFER_TIMESTAMP, */
+ CUBUFFER_PCMTYPE_PROP,
+
+ CUBUFFER_HAS_SBR,
+ CUBUFFER_HAS_PS,
+ CUBUFFER_HAS_EBCC,
+ CUBUFFER_HAS_MPEG_SURROUND,
+ CUBUFFER_HAS_BLINDUPMIX,
+ /* CUBUFFER_HAS_IMPLICIT, */
+
+ /* CUBUFFER_CONFIGCHANGED, */
+ CUBUFFER_WAS_CONCEALED,
+ CUBUFFER_TDL_GAINREDUCTION,
+ CUBUFFER_IS_LOSSLESS,
+ CUBUFFER_HAS_BEEP,
+ CUBUFFER_HAS_SBRSYNCPOINT,
+
+
+ /* special property: warning/message. All warnings and messages are or'd with CUBUFFER_MESSAGE */
+ CUBUFFER_MESSAGE = 0x8000000,
+
+ __cubuffer_flags_end
+} __cubuffer_properties;
+
+
+
+#if defined(WIN32) || defined(WIN64)
+ #pragma pack(push, 8)
+#endif
+
+
+/* Opaque declaration of cubuffer handle */
+struct CCompositionUnit;
+typedef struct CCompositionUnit* CCompositionUnitPtr;
+
+
+/* mandatory interface */
+CCompositionUnitPtr MP4AUDIODECAPI CCompositionUnit_Create(
+ const unsigned int channels,
+ const unsigned int samplesPerChannel,
+ const unsigned int samplingRate,
+ const unsigned int sizeAncData,
+ const CUBUFFER_PCMTYPE cutype
+ );
+
+CCompositionUnitPtr MP4AUDIODECAPI CCompositionUnit_CreateExt(
+ const unsigned int channels,
+ const unsigned int samplesPerChannel,
+ const unsigned int samplingRate,
+ const unsigned int sizeAncData,
+ const CUBUFFER_PCMTYPE pcmtype,
+ void* pcmBuf,
+ const unsigned int pcmBufSize
+ );
+
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_Destroy(CCompositionUnitPtr *self);
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_Reset(CCompositionUnitPtr self);
+
+/* for signalling channel mapping of the (interleaved) pcm output channels */
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetChannelMapping(CCompositionUnitPtr self, const unsigned int channelNr, unsigned int* tag);
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetInvChannelMapping(CCompositionUnitPtr self, const unsigned int tagType, unsigned int* channel);
+
+/* anc data handling */
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetAncDataCount(CCompositionUnitPtr self, unsigned int* nFields, unsigned int* nBytes);
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetAncDataByPos(CCompositionUnitPtr self, const unsigned int nr, unsigned char** ptr, unsigned int* size, unsigned int* tag);
+
+/* retrieve cu-buffer parameters */
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetChannels(CCompositionUnitPtr self, unsigned int* nchannels);
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetSamplesPerChannel(CCompositionUnitPtr self, unsigned int* samplesPerChannel);
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetSamplingRate(CCompositionUnitPtr self, unsigned int* fs);
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetPcmPtr(CCompositionUnitPtr self, void* buf);
+
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetProperty(CCompositionUnitPtr self, const unsigned int prop, int* value);
+
+MP4_RESULT MP4AUDIODECAPI CCompositionUnit_GetNextMessage(CCompositionUnitPtr self, int* value);
+
+
+#if defined(WIN32) || defined(WIN64)
+ #pragma pack(pop)
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CUBUFFER_C_H__ */
diff --git a/Src/aacdec/incs/mp4dec_helpers/err_code.h b/Src/aacdec/incs/mp4dec_helpers/err_code.h
new file mode 100644
index 00000000..f4dc5d5b
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_helpers/err_code.h
@@ -0,0 +1,84 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (1998)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_helpers/err_code.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: exported error codes
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __ERR_CODE_H__
+#define __ERR_CODE_H__
+
+
+typedef int MP4_RESULT;
+
+#ifndef MP4AUDIODECAPI
+ #if defined(WIN32) || defined(WIN64)
+ #define MP4AUDIODECAPI __stdcall
+ #else
+ #define MP4AUDIODECAPI
+ #endif
+#endif
+
+
+enum {
+ MP4AUDIODEC_OK = 0,
+
+ __exported_error_codes_start = -100,
+
+ MP4AUDIODEC_NOT_OK = __exported_error_codes_start,
+ MP4AUDIODEC_INVALID_HANDLE,
+ MP4AUDIODEC_INVALID_POINTER,
+ MP4AUDIODEC_INVALID_PARAMETER,
+ MP4AUDIODEC_INVALID_VALUE,
+ MP4AUDIODEC_INVALID_AUBUFFER,
+ MP4AUDIODEC_INVALID_CUBUFFER,
+ MP4AUDIODEC_INVALID_CHANNELCONFIG,
+ MP4AUDIODEC_INVALID_NROFCHANNELS,
+ MP4AUDIODEC_INVALID_SAMPLERATE,
+ MP4AUDIODEC_INVALID_SAMPLESPERFRAME,
+ MP4AUDIODEC_INVALID_EPCONFIG,
+ MP4AUDIODEC_OUTOFMEMORY,
+ MP4AUDIODEC_NOT_IMPLEMENTED,
+ MP4AUDIODEC_AOT_NOT_SUPPORTED,
+ MP4AUDIODEC_NOLAYERSTODECODE,
+ MP4AUDIODEC_INVALID_FRAME_LENGTH,
+ MP4AUDIODEC_TOOMANYLAYERS,
+ MP4AUDIODEC_UNKNOWNERROR,
+
+ MP4AUDIODEC_INVALID_CORECODER,
+ MP4AUDIODEC_CELP_INVALIDCONFIG,
+
+ MP4AUDIODEC_AUBUFFER_TOOMANYSUBFRAMES,
+ MP4AUDIODEC_AUBUFFER_TOOSMALL,
+
+ MP4AUDIODEC_CUBUFFER_TAGTYPE_NOTFOUND,
+ MP4AUDIODEC_CUBUFFER_INVALIDPARAM,
+ MP4AUDIODEC_CUBUFFER_NOMORE_ANCDATA,
+ MP4AUDIODEC_CUBUFFER_PROPERTYNOTFOUND,
+ MP4AUDIODEC_CUBUFFER_NOTENOUGHCHANNELS,
+ MP4AUDIODEC_CUBUFFER_NOTENOUGHSAMPLES,
+ MP4AUDIODEC_CUBUFFER_NOMORE_MESSAGES,
+ MP4AUDIODEC_CUBUFFER_INVALIDPCMTYPE,
+
+ MP4AUDIODEC_EP_PARSEERROR,
+ MP4AUDIODEC_EP_PARSEERROR_DIRECTMAPPING,
+
+ MP4AUDIODEC_SBRLIBERROR,
+ MP4AUDIODEC_SBR_INVALID_ELEID,
+
+ MP4AUDIODEC_MPEGS_ERROR,
+
+ __exported_error_codes_end
+};
+
+#endif
diff --git a/Src/aacdec/incs/mp4dec_helpers/machine.h b/Src/aacdec/incs/mp4dec_helpers/machine.h
new file mode 100644
index 00000000..bd10ffa2
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_helpers/machine.h
@@ -0,0 +1,101 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (1998)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_helpers/machine.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: machine dependent type definitions
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __MACHINE_H
+#define __MACHINE_H
+
+#define inline __inline
+
+#include <math.h>
+
+#ifdef _MSC_VER
+#include <basetsd.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef signed char INT8;
+typedef signed short INT16;
+typedef signed int INT32;
+typedef signed int INT;
+typedef float FLOAT;
+typedef double DOUBLE;
+
+/* typedef long LONG; */
+/* typedef unsigned long ULONG; */
+/* typedef unsigned int UINT; */
+/* typedef signed int INT; */
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned int UINT32;
+
+#if defined _MSC_VER
+#define ALIGN16 __declspec(align(16))
+#elif defined __GNUC__ && !defined __sparc__ && !defined __sparc_v9__
+#define ALIGN16 __attribute__((aligned(16)))
+#else
+#define ALIGN16
+#endif
+
+#ifndef INT64
+#if !(defined(WIN32) || defined(WIN64))
+#define INT64 long long
+#else
+#define INT64 __int64
+#endif
+
+#endif
+
+
+static inline double FhgSqrt(DOUBLE a){
+ return(sqrt(a));
+}
+static inline double FhgExp(DOUBLE a){
+ return(exp((double) a));
+}
+static inline double FhgPow(DOUBLE a, DOUBLE b){
+ return(pow((double) a, (double) b));
+}
+static inline double FhgSin(DOUBLE a){
+ return(sin((double) a));
+}
+static inline double FhgFloor(DOUBLE a){
+ return(floor((double) a));
+}
+static inline double FhgCos(DOUBLE a){
+ return(cos((double) a));
+}
+static inline double FhgFabs(DOUBLE a){
+ return(fabs((double) a));
+}
+static inline double FhgTan(DOUBLE a){
+ return(tan((double) a));
+}
+static inline double FhgCeil(DOUBLE a){
+ return(ceil((double) a));
+}
+static inline double FhgLog(DOUBLE a){
+ return(log((double) a));
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #define __MACHINE_H */
diff --git a/Src/aacdec/incs/mp4dec_helpers/usrparam.h b/Src/aacdec/incs/mp4dec_helpers/usrparam.h
new file mode 100644
index 00000000..a7be6be9
--- /dev/null
+++ b/Src/aacdec/incs/mp4dec_helpers/usrparam.h
@@ -0,0 +1,138 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2001)
+ * All Rights Reserved
+ *
+ * $Header: /cvs/root/winamp/aacdec/incs/mp4dec_helpers/usrparam.h,v 1.3 2012/05/08 20:16:50 audiodsp Exp $
+ * project : MPEG-4 Audio Decoder
+ * contents/description: user changeable parameters, common struct
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __USERPARAM_H__
+#define __USERPARAM_H__
+
+
+typedef enum {
+ MP4AUDIODECPARAM_DEFAULT = 0,
+ MP4AUDIODECPARAM_ALL = MP4AUDIODECPARAM_DEFAULT
+} __mp4AudioDecoder_ResetParam;
+
+
+typedef enum {
+ INVALID_PARAM = 0,
+
+ __usrparam_param_start = 1000,
+ /* postprocessor tools */
+ DECODE_IMPLICIT,
+ DECODE_SBR,
+ DECODE_PS,
+ DECODE_EBCC,
+ DECODE_MPEGS,
+ DECODE_DRC,
+
+ /* mpeg surround params */
+ MPEGS_UPMIX_TYPE, /* for demo only */
+ MPEGS_HRTF_MODEL, /* for demo only */
+ MPEGS_PART_COMPLEX, /* for demo only */
+ MPEGS_LEVEL, /* for demo only */
+ MPEGS_BINAURAL_FRONT_ANGLE, /* for demo only */
+ MPEGS_BINAURAL_REAR_ANGLE, /* for demo only */
+ MPEGS_BINAURAL_DISTANCE, /* for demo only */
+ MPEGS_BINAURAL_DIALOG_CLARITY, /* for demo only */
+ MPEGS_BINAURAL_QUALITY, /* for demo only */
+ MPEGS_BINAURAL_PRESET,
+
+ /* DRC params */
+ DRC_BOOST,
+ DRC_COMPRESS,
+ DRC_TARGET_REF,
+
+ /* concealment params */
+ CONCEALMENT_ENERGYINTERPOLATION,
+ CONCEALMENT_TECHNIQUE,
+ CONCEALMENT_ATTENUATION,
+
+ /* time domain limiter */
+ TDL_MODE,
+
+ /* hvxc */
+ HVXC_DELAYMODE, /* for conformance test only */
+ HVXC_TESTMODE, /* for conformance test only */
+ HVXC_PITCHFACTOR, /* for conformance test only */
+ HVXC_SPEEDFACTOR, /* for conformance test only */
+
+ /* sls */
+ SLS_TRUNCATIONRATE, /* max sls bitrate per channel to decode, for demo only */
+
+ /* sbr */
+ SBR_LOWPOWERMODE, /* for demo only */
+
+ /* scalable */
+ SCAL_SETOUTPUTLAYER,
+
+ /* advanced windowing - adjusts non-meaningful window sequence transitions */
+ WINDOW_ADJUST_PARAM,
+
+ /* PCM buffer re-shuffling */
+ WAVE_REMAPPING,
+
+ /* debugging only */
+ VERBOSE_LEVEL,
+
+ /* further params come here */
+
+ __usrparam_param_dummy
+} __mp4AudioDecoder_ConfigureParameters;
+
+
+typedef enum {
+
+ /* general values */
+ SWITCH_OFF = 0,
+ SWITCH_ON = 1,
+ SWITCH_DISABLED = 0,
+ SWITCH_ENABLED = 1,
+
+ __usrparam_value_start = 10000,
+
+ /** concealment settings **/
+
+ /* preferred */
+ CONCEALMENT_TECHNIQUE_NOISESUBST_FAST_STATIC_PRS = 7,
+
+ /* for debugging and historic reasons */
+ CONCEALMENT_TECHNIQUE_OFF = 0,
+ CONCEALMENT_TECHNIQUE_MUTING = 1,
+ CONCEALMENT_TECHNIQUE_REPETITION = 2,
+ CONCEALMENT_TECHNIQUE_NOISESUBST_FAST = 3,
+ CONCEALMENT_TECHNIQUE_NOISESUBST_IIR = 5,
+ CONCEALMENT_TECHNIQUE_NOISESUBST_IIR_STATIC_PRS = 9,
+
+ /* experimental - not recommended in production environments */
+ CONCEALMENT_TECHNIQUE_NOISESUBST_FAST_PLUS_PRED = 4,
+ CONCEALMENT_TECHNIQUE_NOISESUBST_IIR_PLUS_PRED = 6,
+ CONCEALMENT_TECHNIQUE_NOISESUBST_FAST_STATIC_PRS_PLUS_PRED = 8,
+ CONCEALMENT_TECHNIQUE_NOISESUBST_IIR_STATIC_PRS_PLUS_PRED = 10,
+
+ /** advanced windowing **/
+ WINDOW_ADJUST_PARAM_OFF = 0,
+ WINDOW_ADJUST_PARAM_ON_ONLY_CURRENT = 1,
+ WINDOW_ADJUST_PARAM_ON_PREF_LONG = 2,
+ WINDOW_ADJUST_PARAM_ON_PREF_SHORT = 3,
+
+ __usrparam_value_dummy
+} __mp4AudioDecoder_ConfigureValues;
+
+
+#define SLS_TRUNCATIONRATE_OFF (-1.0f)
+#define SLS_TRUNCATIONRATE_MIN (32000.0f)
+#define WINDOW_ADJUST_PARAM_DEFAULT (WINDOW_ADJUST_PARAM_OFF)
+
+#endif
diff --git a/Src/aacdec/incs/sac_dec_ssc_struct.h b/Src/aacdec/incs/sac_dec_ssc_struct.h
new file mode 100644
index 00000000..f306943a
--- /dev/null
+++ b/Src/aacdec/incs/sac_dec_ssc_struct.h
@@ -0,0 +1,272 @@
+/***************************************************************************\
+ *
+ * (C) copyright Fraunhofer - IIS (2007)
+ * All Rights Reserved
+ *
+ * $Id: sac_dec_ssc_struct.h,v 1.3 2012/05/08 20:16:49 audiodsp Exp $
+ * project : MPEG surround decoder lib
+ * contents/description: interface - spatial specific config struct
+ *
+ * This software and/or program is protected by copyright law and
+ * international treaties. Any reproduction or distribution of this
+ * software and/or program, or any portion of it, may result in severe
+ * civil and criminal penalties, and will be prosecuted to the maximum
+ * extent possible under law.
+ *
+\***************************************************************************/
+
+#ifndef __SAC_DEC_SSC_STRUCT_H__
+#define __SAC_DEC_SSC_STRUCT_H__
+
+
+#define MAX_NUM_QMF_BANDS (128)
+#define MAX_TIME_SLOTS (72)
+#define MAX_INPUT_CHANNELS (6)
+#define MAX_OUTPUT_CHANNELS (8)
+#define MAX_NUM_OTT (5)
+#define MAX_NUM_TTT (1)
+#define MAX_NUM_EXT_TYPES ( 8 )
+#define MAX_PARAMETER_BANDS (28)
+
+#define MAX_ARBITRARY_TREE_LEVELS ( 2 )
+#define MAX_OUTPUT_CHANNELS_AT ( MAX_OUTPUT_CHANNELS * (1<<MAX_ARBITRARY_TREE_LEVELS) )
+#define MAX_ARBITRARY_TREE_INDEX ( (1<<(MAX_ARBITRARY_TREE_LEVELS+1))-1 )
+
+
+
+typedef enum {
+
+ SPATIALDEC_FREQ_RES_40 = 40,
+ SPATIALDEC_FREQ_RES_28 = 28,
+ SPATIALDEC_FREQ_RES_23 = 23,
+ SPATIALDEC_FREQ_RES_20 = 20,
+ SPATIALDEC_FREQ_RES_15 = 15,
+ SPATIALDEC_FREQ_RES_14 = 14,
+ SPATIALDEC_FREQ_RES_10 = 10,
+ SPATIALDEC_FREQ_RES_7 = 7,
+ SPATIALDEC_FREQ_RES_5 = 5,
+ SPATIALDEC_FREQ_RES_4 = 4
+
+} SPATIALDEC_FREQ_RES;
+
+typedef enum {
+
+ SPATIALDEC_QUANT_FINE_DEF = 0,
+ SPATIALDEC_QUANT_EDQ1 = 1,
+ SPATIALDEC_QUANT_EDQ2 = 2,
+ SPATIALDEC_QUANT_RSVD3 = 3,
+ SPATIALDEC_QUANT_RSVD4 = 4,
+ SPATIALDEC_QUANT_RSVD5 = 5,
+ SPATIALDEC_QUANT_RSVD6 = 6,
+ SPATIALDEC_QUANT_RSVD7 = 7
+
+} SPATIALDEC_QUANT_MODE;
+
+typedef enum {
+
+ SPATIALDEC_MODE_5151 = 0,
+ SPATIALDEC_MODE_5152 = 1,
+ SPATIALDEC_MODE_525 = 2,
+ SPATIALDEC_MODE_RSVD3 = 3,
+ SPATIALDEC_MODE_RSVD4 = 4,
+ SPATIALDEC_MODE_RSVD5 = 5,
+ SPATIALDEC_MODE_RSVD6 = 6,
+ SPATIALDEC_MODE_RSVD7 = 7,
+ SPATIALDEC_MODE_RSVD8 = 8,
+ SPATIALDEC_MODE_RSVD9 = 9,
+ SPATIALDEC_MODE_RSVD10 = 10,
+ SPATIALDEC_MODE_RSVD11 = 11,
+ SPATIALDEC_MODE_RSVD12 = 12,
+ SPATIALDEC_MODE_RSVD13 = 13,
+ SPATIALDEC_MODE_RSVD14 = 14,
+ SPATIALDEC_MODE_SIGNAL
+
+} SPATIALDEC_TREE_CONFIG;
+
+
+
+typedef enum {
+
+ SPATIALDEC_GAIN_MODE0 = 0,
+ SPATIALDEC_GAIN_RSVD1 = 1,
+ SPATIALDEC_GAIN_RSVD2 = 2,
+ SPATIALDEC_GAIN_RSVD3 = 3,
+ SPATIALDEC_GAIN_RSVD4 = 4,
+ SPATIALDEC_GAIN_RSVD5 = 5,
+ SPATIALDEC_GAIN_RSVD6 = 6,
+ SPATIALDEC_GAIN_RSVD7 = 7,
+ SPATIALDEC_GAIN_RSVD8 = 8,
+ SPATIALDEC_GAIN_RSVD9 = 9,
+ SPATIALDEC_GAIN_RSVD10 = 10,
+ SPATIALDEC_GAIN_RSVD11 = 11,
+ SPATIALDEC_GAIN_RSVD12 = 12,
+ SPATIALDEC_GAIN_RSVD13 = 13,
+ SPATIALDEC_GAIN_RSVD14 = 14,
+ SPATIALDEC_GAIN_RSVD15 = 15
+
+} SPATIALDEC_FIXED_GAINS;
+
+
+typedef enum {
+
+ SPATIALDEC_TS_TPNOWHITE = 0,
+ SPATIALDEC_TS_TPWHITE = 1,
+ SPATIALDEC_TS_TES = 2,
+ SPATIALDEC_TS_NOTS = 3,
+ SPATIALDEC_TS_RSVD4 = 4,
+ SPATIALDEC_TS_RSVD5 = 5,
+ SPATIALDEC_TS_RSVD6 = 6,
+ SPATIALDEC_TS_RSVD7 = 7,
+ SPATIALDEC_TS_RSVD8 = 8,
+ SPATIALDEC_TS_RSVD9 = 9,
+ SPATIALDEC_TS_RSVD10 = 10,
+ SPATIALDEC_TS_RSVD11 = 11,
+ SPATIALDEC_TS_RSVD12 = 12,
+ SPATIALDEC_TS_RSVD13 = 13,
+ SPATIALDEC_TS_RSVD14 = 14,
+ SPATIALDEC_TS_RSVD15 = 15
+
+} SPATIALDEC_TS_CONF;
+
+
+typedef enum {
+
+ SPATIALDEC_DECORR_MODE0 = 0,
+ SPATIALDEC_DECORR_MODE1 = 1,
+ SPATIALDEC_DECORR_MODE2 = 2,
+ SPATIALDEC_DECORR_RSVD3 = 3,
+ SPATIALDEC_DECORR_RSVD4 = 4,
+ SPATIALDEC_DECORR_RSVD5 = 5,
+ SPATIALDEC_DECORR_RSVD6 = 6,
+ SPATIALDEC_DECORR_RSVD7 = 7,
+ SPATIALDEC_DECORR_RSVD8 = 8,
+ SPATIALDEC_DECORR_RSVD9 = 9,
+ SPATIALDEC_DECORR_RSVD10 = 10,
+ SPATIALDEC_DECORR_RSVD11 = 11,
+ SPATIALDEC_DECORR_RSVD12 = 12,
+ SPATIALDEC_DECORR_RSVD13 = 13,
+ SPATIALDEC_DECORR_RSVD14 = 14,
+ SPATIALDEC_DECORR_RSVD15 = 15
+
+} SPATIALDEC_DECORR_CONF;
+
+
+typedef struct T_SPATIALDEC_TREE_DESC {
+
+ /* tbd */
+ int tmp;
+
+} SPATIALDEC_TREE_DESC;
+
+
+typedef struct T_SPATIALDEC_OTT_CONF {
+
+ int nOttBands;
+
+} SPATIALDEC_OTT_CONF;
+
+
+typedef enum {
+
+ SPATIALDEC_TTT_PRED_DECORR = 0,
+ SPATIALDEC_TTT_PRED_NODECORR = 1,
+ SPATIALDEC_TTT_RSVD2 = 2,
+ SPATIALDEC_TTT_ENERGY_SUB = 3,
+ SPATIALDEC_TTT_RSVD4 = 4,
+ SPATIALDEC_TTT_ENERGY_NOSUB = 5,
+ SPATIALDEC_TTT_RSVD6 = 6,
+ SPATIALDEC_TTT_RSVD7 = 7
+
+} SPATIALDEC_TTT_MODE;
+
+
+typedef struct T_SPATIALDEC_TTT_CONF {
+
+ int bTttDualMode;
+ SPATIALDEC_TTT_MODE tttModeLow;
+ SPATIALDEC_TTT_MODE tttModeHigh;
+ int nTttBandsLow;
+
+} SPATIALDEC_TTT_CONF;
+
+
+typedef struct T_SPATIALDEC_RESIDUAL_CONF {
+
+ int bResidualPresent;
+ int nResidualBands;
+
+} SPATIALDEC_RESIDUAL_CONF;
+
+
+typedef struct T_SPATIAL_SPECIFIC_CONFIG {
+
+ int samplingFreq;
+ int nTimeSlots;
+ int LdMode;
+ SPATIALDEC_FREQ_RES freqRes;
+ SPATIALDEC_TREE_CONFIG treeConfig;
+ SPATIALDEC_QUANT_MODE quantMode;
+ int bOneIcc;
+ int bArbitraryDownmix;
+
+ int arbitraryDownmixResidualSamplingFreq;
+ int arbitraryDownmixResidualFramesPerSpatialFrame;
+ int arbitraryDownmixResidualBands;
+
+ int bResidualCoding;
+ SPATIALDEC_FIXED_GAINS bsFixedGainSur;
+ SPATIALDEC_FIXED_GAINS bsFixedGainLFE;
+ SPATIALDEC_FIXED_GAINS bsFixedGainDMX;
+
+
+ int bMatrixMode;
+ SPATIALDEC_TS_CONF tempShapeConfig;
+ SPATIALDEC_DECORR_CONF decorrConfig;
+ SPATIALDEC_TREE_DESC *pTreeDesc;
+
+ int nInputChannels; /* derived from treeConfig */
+ int nOutputChannels; /* derived from treeConfig */
+
+
+ /* ott config */
+ int nOttBoxes; /* derived from treeConfig */
+ SPATIALDEC_OTT_CONF OttConfig[MAX_NUM_OTT]; /* dimension nOttBoxes */
+
+ /* ttt config */
+ int nTttBoxes; /* derived from treeConfig */
+ SPATIALDEC_TTT_CONF TttConfig[MAX_NUM_TTT]; /* dimension nTttBoxes */
+
+ /* residual config */
+ int residualSamplingFreq;
+ int nResidualFramesPerSpatialFrame;
+ SPATIALDEC_RESIDUAL_CONF ResidualConfig[MAX_NUM_OTT+MAX_NUM_TTT]; /* dimension (nOttBoxes + nTttBoxes) */
+
+ int sacExtCnt;
+ int sacExtType[MAX_NUM_EXT_TYPES];
+ int envQuantMode;
+
+ int bArbitraryTree;
+ int numOutChanAT;
+ int numOttBoxesAT;
+ int OutputChannelPosAT[MAX_OUTPUT_CHANNELS_AT];
+ int OttBoxPresentAT[MAX_OUTPUT_CHANNELS][MAX_ARBITRARY_TREE_INDEX];
+ int OttDefaultCldAT[MAX_OUTPUT_CHANNELS*MAX_ARBITRARY_TREE_INDEX];
+ int OttModeLfeAT[MAX_OUTPUT_CHANNELS*MAX_ARBITRARY_TREE_INDEX];
+ int OttBandsAT[MAX_OUTPUT_CHANNELS*MAX_ARBITRARY_TREE_INDEX];
+
+ int b3DaudioMode;
+ int b3DaudioHRTFset;
+ int HRTFfreqRes;
+ int HRTFnumBand;
+ int HRTFnumChan;
+ int HRTFasymmetric;
+ int HRTFlevelLeft[MAX_OUTPUT_CHANNELS][MAX_PARAMETER_BANDS];
+ int HRTFlevelRight[MAX_OUTPUT_CHANNELS][MAX_PARAMETER_BANDS];
+ int HRTFphase[MAX_OUTPUT_CHANNELS];
+ int HRTFphaseLR[MAX_OUTPUT_CHANNELS][MAX_PARAMETER_BANDS];
+ int HRTFicc[MAX_OUTPUT_CHANNELS];
+ int HRTFiccLR[MAX_OUTPUT_CHANNELS][MAX_PARAMETER_BANDS];
+
+} SPATIAL_SPECIFIC_CONFIG;
+
+#endif
diff --git a/Src/aacdec/libs/Win32/HdAacDeclib.lib b/Src/aacdec/libs/Win32/HdAacDeclib.lib
new file mode 100644
index 00000000..729cf861
--- /dev/null
+++ b/Src/aacdec/libs/Win32/HdAacDeclib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/concealMDCTlib.lib b/Src/aacdec/libs/Win32/concealMDCTlib.lib
new file mode 100644
index 00000000..daf5e77e
--- /dev/null
+++ b/Src/aacdec/libs/Win32/concealMDCTlib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/fdreverblib.lib b/Src/aacdec/libs/Win32/fdreverblib.lib
new file mode 100644
index 00000000..318eb235
--- /dev/null
+++ b/Src/aacdec/libs/Win32/fdreverblib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/libirc.lib b/Src/aacdec/libs/Win32/libirc.lib
new file mode 100644
index 00000000..1ee341bd
--- /dev/null
+++ b/Src/aacdec/libs/Win32/libirc.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/limiterlib.lib b/Src/aacdec/libs/Win32/limiterlib.lib
new file mode 100644
index 00000000..9fb55ac6
--- /dev/null
+++ b/Src/aacdec/libs/Win32/limiterlib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/mathlib.lib b/Src/aacdec/libs/Win32/mathlib.lib
new file mode 100644
index 00000000..d6e55f04
--- /dev/null
+++ b/Src/aacdec/libs/Win32/mathlib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/mp4audiodec.lib b/Src/aacdec/libs/Win32/mp4audiodec.lib
new file mode 100644
index 00000000..d1e7e68b
--- /dev/null
+++ b/Src/aacdec/libs/Win32/mp4audiodec.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/mpegsDeclib.lib b/Src/aacdec/libs/Win32/mpegsDeclib.lib
new file mode 100644
index 00000000..40c24c0d
--- /dev/null
+++ b/Src/aacdec/libs/Win32/mpegsDeclib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/qmflib.lib b/Src/aacdec/libs/Win32/qmflib.lib
new file mode 100644
index 00000000..9b78ebfe
--- /dev/null
+++ b/Src/aacdec/libs/Win32/qmflib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/readonlybitbuflib.lib b/Src/aacdec/libs/Win32/readonlybitbuflib.lib
new file mode 100644
index 00000000..a943e2fd
--- /dev/null
+++ b/Src/aacdec/libs/Win32/readonlybitbuflib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/sbrdecoderlib.lib b/Src/aacdec/libs/Win32/sbrdecoderlib.lib
new file mode 100644
index 00000000..25d5e195
--- /dev/null
+++ b/Src/aacdec/libs/Win32/sbrdecoderlib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/spaceDeclib.lib b/Src/aacdec/libs/Win32/spaceDeclib.lib
new file mode 100644
index 00000000..49b2b377
--- /dev/null
+++ b/Src/aacdec/libs/Win32/spaceDeclib.lib
Binary files differ
diff --git a/Src/aacdec/libs/Win32/utillib.lib b/Src/aacdec/libs/Win32/utillib.lib
new file mode 100644
index 00000000..1ee42e55
--- /dev/null
+++ b/Src/aacdec/libs/Win32/utillib.lib
Binary files differ
diff --git a/Src/aacdec/main.cpp b/Src/aacdec/main.cpp
new file mode 100644
index 00000000..3f556c9d
--- /dev/null
+++ b/Src/aacdec/main.cpp
@@ -0,0 +1,100 @@
+#include "api.h"
+
+#include "../nu/Singleton.h"
+#include "../nu/factoryt.h"
+#include "AVIAACDecoder.h"
+#include "FLVAACDecoder.h"
+#include "MKVAACDecoder.h"
+#include "MP4AACDecoder.h"
+#include "ADTSAACDecoder.h"
+#include "NSVAACDecoder.h"
+#include <bfc/platform/export.h>
+#include "../Agave/Component/ifc_wa5component.h"
+
+class AACDecoderComponent : 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 = (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 = 0;
+}
+
+static SingletonServiceFactory<svc_avidecoder, AVIDecoder> avi_factory;
+static AVIDecoder avi_decoder;
+static SingletonServiceFactory<svc_mkvdecoder, MKVDecoder> mkv_factory;
+static MKVDecoder mkv_decoder;
+static SingletonServiceFactory<svc_flvdecoder, FLVDecoder> flv_factory;
+static FLVDecoder flv_decoder;
+static ServiceFactoryT<MP4AudioDecoder, MP4AACDecoder> mp4_factory;
+static ServiceFactoryT<adts, ADTSAACDecoder> adts_factory;
+
+static NSVDecoder nsv_decoder;
+static SingletonServiceFactory<svc_nsvFactory, NSVDecoder> nsv_factory;
+
+void AACDecoderComponent::RegisterServices(api_service *service)
+{
+ WASABI_API_SVC = service;
+ avi_factory.Register(WASABI_API_SVC, &avi_decoder);
+ mkv_factory.Register(WASABI_API_SVC, &mkv_decoder);
+ flv_factory.Register(WASABI_API_SVC, &flv_decoder);
+ nsv_factory.Register(WASABI_API_SVC, &nsv_decoder);
+ mp4_factory.Register(WASABI_API_SVC);
+ adts_factory.Register(WASABI_API_SVC);
+ ServiceBuild(AGAVE_API_CONFIG, AgaveConfigGUID);
+ ServiceBuild(WASABI_API_MEMMGR, memMgrApiServiceGuid);
+}
+
+void AACDecoderComponent::DeregisterServices(api_service *service)
+{
+ avi_factory.Deregister(WASABI_API_SVC);
+ mkv_factory.Deregister(WASABI_API_SVC);
+ mp4_factory.Deregister(WASABI_API_SVC);
+ flv_factory.Deregister(WASABI_API_SVC);
+ nsv_factory.Deregister(WASABI_API_SVC);
+ adts_factory.Deregister(WASABI_API_SVC);
+ ServiceRelease(AGAVE_API_CONFIG, AgaveConfigGUID);
+ ServiceRelease(WASABI_API_MEMMGR, memMgrApiServiceGuid);
+}
+
+int AACDecoderComponent::RegisterServicesSafeModeOk()
+{
+ return 1;
+}
+
+AACDecoderComponent aac_decoder_component;
+extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
+{
+ return &aac_decoder_component;
+}
+
+#define CBCLASS AACDecoderComponent
+START_DISPATCH;
+VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
+CB(15, RegisterServicesSafeModeOk)
+VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
+END_DISPATCH;
+#undef CBCLASS \ No newline at end of file
diff --git a/Src/aacdec/resource.h b/Src/aacdec/resource.h
new file mode 100644
index 00000000..d3a2838b
--- /dev/null
+++ b/Src/aacdec/resource.h
@@ -0,0 +1,14 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by aacdec.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
diff --git a/Src/aacdec/version.rc2 b/Src/aacdec/version.rc2
new file mode 100644
index 00000000..08bafc85
--- /dev/null
+++ b/Src/aacdec/version.rc2
@@ -0,0 +1,39 @@
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 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", "aacdec.w5s"
+ VALUE "LegalCopyright", "Copyright © 2005-2019 Winamp SA"
+ VALUE "LegalTrademarks", "Nullsoft and Winamp are trademarks of Winamp SA"
+ VALUE "OriginalFilename", "aacdec.w5s"
+ VALUE "ProductName", "Winamp AAC Decoder Service"
+ VALUE "ProductVersion", STR_WINAMP_PRODUCTVER
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END