@@ -122,10 +122,35 @@ public: | |||||
bool isLooping; | bool isLooping; | ||||
//============================================================================== | //============================================================================== | ||||
bool operator== (const CurrentPositionInfo& other) const noexcept; | |||||
bool operator!= (const CurrentPositionInfo& other) const noexcept; | |||||
void resetToDefault(); | |||||
bool operator== (const CurrentPositionInfo& other) const noexcept | |||||
{ | |||||
return timeInSamples == other.timeInSamples | |||||
&& ppqPosition == other.ppqPosition | |||||
&& editOriginTime == other.editOriginTime | |||||
&& ppqPositionOfLastBarStart == other.ppqPositionOfLastBarStart | |||||
&& frameRate == other.frameRate | |||||
&& isPlaying == other.isPlaying | |||||
&& isRecording == other.isRecording | |||||
&& bpm == other.bpm | |||||
&& timeSigNumerator == other.timeSigNumerator | |||||
&& timeSigDenominator == other.timeSigDenominator | |||||
&& ppqLoopStart == other.ppqLoopStart | |||||
&& ppqLoopEnd == other.ppqLoopEnd | |||||
&& isLooping == other.isLooping; | |||||
} | |||||
bool operator!= (const CurrentPositionInfo& other) const noexcept | |||||
{ | |||||
return ! operator== (other); | |||||
} | |||||
void resetToDefault() | |||||
{ | |||||
zerostruct (*this); | |||||
timeSigNumerator = 4; | |||||
timeSigDenominator = 4; | |||||
bpm = 120; | |||||
} | |||||
}; | }; | ||||
//============================================================================== | //============================================================================== | ||||
@@ -32,7 +32,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest | |||||
{ | { | ||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
*reinterpret_cast<uint16*> (intData) = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
*unalignedPointerCast<uint16*> (intData) = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
intData += destBytesPerSample; | intData += destBytesPerSample; | ||||
} | } | ||||
} | } | ||||
@@ -43,7 +43,7 @@ void AudioDataConverters::convertFloatToInt16LE (const float* source, void* dest | |||||
for (int i = numSamples; --i >= 0;) | for (int i = numSamples; --i >= 0;) | ||||
{ | { | ||||
intData -= destBytesPerSample; | intData -= destBytesPerSample; | ||||
*reinterpret_cast<uint16*> (intData) = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
*unalignedPointerCast<uint16*> (intData) = ByteOrder::swapIfBigEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -57,7 +57,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest | |||||
{ | { | ||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
*reinterpret_cast<uint16*> (intData) = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
*unalignedPointerCast<uint16*> (intData) = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
intData += destBytesPerSample; | intData += destBytesPerSample; | ||||
} | } | ||||
} | } | ||||
@@ -68,7 +68,7 @@ void AudioDataConverters::convertFloatToInt16BE (const float* source, void* dest | |||||
for (int i = numSamples; --i >= 0;) | for (int i = numSamples; --i >= 0;) | ||||
{ | { | ||||
intData -= destBytesPerSample; | intData -= destBytesPerSample; | ||||
*reinterpret_cast<uint16*> (intData) = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
*unalignedPointerCast<uint16*> (intData) = ByteOrder::swapIfLittleEndian ((uint16) (short) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -132,7 +132,7 @@ void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest | |||||
{ | { | ||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
*reinterpret_cast<uint32*> (intData) = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
*unalignedPointerCast<uint32*> (intData) = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
intData += destBytesPerSample; | intData += destBytesPerSample; | ||||
} | } | ||||
} | } | ||||
@@ -143,7 +143,7 @@ void AudioDataConverters::convertFloatToInt32LE (const float* source, void* dest | |||||
for (int i = numSamples; --i >= 0;) | for (int i = numSamples; --i >= 0;) | ||||
{ | { | ||||
intData -= destBytesPerSample; | intData -= destBytesPerSample; | ||||
*reinterpret_cast<uint32*> (intData) = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
*unalignedPointerCast<uint32*> (intData) = ByteOrder::swapIfBigEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -157,7 +157,7 @@ void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest | |||||
{ | { | ||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
*reinterpret_cast<uint32*> (intData) = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
*unalignedPointerCast<uint32*> (intData) = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
intData += destBytesPerSample; | intData += destBytesPerSample; | ||||
} | } | ||||
} | } | ||||
@@ -168,7 +168,7 @@ void AudioDataConverters::convertFloatToInt32BE (const float* source, void* dest | |||||
for (int i = numSamples; --i >= 0;) | for (int i = numSamples; --i >= 0;) | ||||
{ | { | ||||
intData -= destBytesPerSample; | intData -= destBytesPerSample; | ||||
*reinterpret_cast<uint32*> (intData) = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
*unalignedPointerCast<uint32*> (intData) = ByteOrder::swapIfLittleEndian ((uint32) roundToInt (jlimit (-maxVal, maxVal, maxVal * source[i]))); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -181,10 +181,10 @@ void AudioDataConverters::convertFloatToFloat32LE (const float* source, void* de | |||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
*reinterpret_cast<float*> (d) = source[i]; | |||||
*unalignedPointerCast<float*> (d) = source[i]; | |||||
#if JUCE_BIG_ENDIAN | #if JUCE_BIG_ENDIAN | ||||
*reinterpret_cast<uint32*> (d) = ByteOrder::swap (*reinterpret_cast<uint32*> (d)); | |||||
*unalignedPointerCast<uint32*> (d) = ByteOrder::swap (*unalignedPointerCast<uint32*> (d)); | |||||
#endif | #endif | ||||
d += destBytesPerSample; | d += destBytesPerSample; | ||||
@@ -199,10 +199,10 @@ void AudioDataConverters::convertFloatToFloat32BE (const float* source, void* de | |||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
*reinterpret_cast<float*> (d) = source[i]; | |||||
*unalignedPointerCast<float*> (d) = source[i]; | |||||
#if JUCE_LITTLE_ENDIAN | #if JUCE_LITTLE_ENDIAN | ||||
*reinterpret_cast<uint32*> (d) = ByteOrder::swap (*reinterpret_cast<uint32*> (d)); | |||||
*unalignedPointerCast<uint32*> (d) = ByteOrder::swap (*unalignedPointerCast<uint32*> (d)); | |||||
#endif | #endif | ||||
d += destBytesPerSample; | d += destBytesPerSample; | ||||
@@ -219,7 +219,7 @@ void AudioDataConverters::convertInt16LEToFloat (const void* source, float* dest | |||||
{ | { | ||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
dest[i] = scale * (short) ByteOrder::swapIfBigEndian (*reinterpret_cast<const uint16*> (intData)); | |||||
dest[i] = scale * (short) ByteOrder::swapIfBigEndian (*unalignedPointerCast<const uint16*> (intData)); | |||||
intData += srcBytesPerSample; | intData += srcBytesPerSample; | ||||
} | } | ||||
} | } | ||||
@@ -230,7 +230,7 @@ void AudioDataConverters::convertInt16LEToFloat (const void* source, float* dest | |||||
for (int i = numSamples; --i >= 0;) | for (int i = numSamples; --i >= 0;) | ||||
{ | { | ||||
intData -= srcBytesPerSample; | intData -= srcBytesPerSample; | ||||
dest[i] = scale * (short) ByteOrder::swapIfBigEndian (*reinterpret_cast<const uint16*> (intData)); | |||||
dest[i] = scale * (short) ByteOrder::swapIfBigEndian (*unalignedPointerCast<const uint16*> (intData)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -244,7 +244,7 @@ void AudioDataConverters::convertInt16BEToFloat (const void* source, float* dest | |||||
{ | { | ||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
dest[i] = scale * (short) ByteOrder::swapIfLittleEndian (*reinterpret_cast<const uint16*> (intData)); | |||||
dest[i] = scale * (short) ByteOrder::swapIfLittleEndian (*unalignedPointerCast<const uint16*> (intData)); | |||||
intData += srcBytesPerSample; | intData += srcBytesPerSample; | ||||
} | } | ||||
} | } | ||||
@@ -255,7 +255,7 @@ void AudioDataConverters::convertInt16BEToFloat (const void* source, float* dest | |||||
for (int i = numSamples; --i >= 0;) | for (int i = numSamples; --i >= 0;) | ||||
{ | { | ||||
intData -= srcBytesPerSample; | intData -= srcBytesPerSample; | ||||
dest[i] = scale * (short) ByteOrder::swapIfLittleEndian (*reinterpret_cast<const uint16*> (intData)); | |||||
dest[i] = scale * (short) ByteOrder::swapIfLittleEndian (*unalignedPointerCast<const uint16*> (intData)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -319,7 +319,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* source, float* dest | |||||
{ | { | ||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
dest[i] = scale * (float) ByteOrder::swapIfBigEndian (*reinterpret_cast<const uint32*> (intData)); | |||||
dest[i] = scale * (float) ByteOrder::swapIfBigEndian (*unalignedPointerCast<const uint32*> (intData)); | |||||
intData += srcBytesPerSample; | intData += srcBytesPerSample; | ||||
} | } | ||||
} | } | ||||
@@ -330,7 +330,7 @@ void AudioDataConverters::convertInt32LEToFloat (const void* source, float* dest | |||||
for (int i = numSamples; --i >= 0;) | for (int i = numSamples; --i >= 0;) | ||||
{ | { | ||||
intData -= srcBytesPerSample; | intData -= srcBytesPerSample; | ||||
dest[i] = scale * (float) ByteOrder::swapIfBigEndian (*reinterpret_cast<const uint32*> (intData)); | |||||
dest[i] = scale * (float) ByteOrder::swapIfBigEndian (*unalignedPointerCast<const uint32*> (intData)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -344,7 +344,7 @@ void AudioDataConverters::convertInt32BEToFloat (const void* source, float* dest | |||||
{ | { | ||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
dest[i] = scale * (float) ByteOrder::swapIfLittleEndian (*reinterpret_cast<const uint32*> (intData)); | |||||
dest[i] = scale * (float) ByteOrder::swapIfLittleEndian (*unalignedPointerCast<const uint32*> (intData)); | |||||
intData += srcBytesPerSample; | intData += srcBytesPerSample; | ||||
} | } | ||||
} | } | ||||
@@ -355,7 +355,7 @@ void AudioDataConverters::convertInt32BEToFloat (const void* source, float* dest | |||||
for (int i = numSamples; --i >= 0;) | for (int i = numSamples; --i >= 0;) | ||||
{ | { | ||||
intData -= srcBytesPerSample; | intData -= srcBytesPerSample; | ||||
dest[i] = scale * (float) ByteOrder::swapIfLittleEndian (*reinterpret_cast<const uint32*> (intData)); | |||||
dest[i] = scale * (float) ByteOrder::swapIfLittleEndian (*unalignedPointerCast<const uint32*> (intData)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -366,10 +366,10 @@ void AudioDataConverters::convertFloat32LEToFloat (const void* source, float* de | |||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
dest[i] = *reinterpret_cast<const float*> (s); | |||||
dest[i] = *unalignedPointerCast<const float*> (s); | |||||
#if JUCE_BIG_ENDIAN | #if JUCE_BIG_ENDIAN | ||||
auto d = reinterpret_cast<uint32*> (dest + i); | |||||
auto d = unalignedPointerCast<uint32*> (dest + i); | |||||
*d = ByteOrder::swap (*d); | *d = ByteOrder::swap (*d); | ||||
#endif | #endif | ||||
@@ -383,10 +383,10 @@ void AudioDataConverters::convertFloat32BEToFloat (const void* source, float* de | |||||
for (int i = 0; i < numSamples; ++i) | for (int i = 0; i < numSamples; ++i) | ||||
{ | { | ||||
dest[i] = *reinterpret_cast<const float*> (s); | |||||
dest[i] = *unalignedPointerCast<const float*> (s); | |||||
#if JUCE_LITTLE_ENDIAN | #if JUCE_LITTLE_ENDIAN | ||||
auto d = reinterpret_cast<uint32*> (dest + i); | |||||
auto d = unalignedPointerCast<uint32*> (dest + i); | |||||
*d = ByteOrder::swap (*d); | *d = ByteOrder::swap (*d); | ||||
#endif | #endif | ||||
@@ -409,8 +409,8 @@ public: | |||||
auto numSamplesToCopy = (size_t) jmin (newNumSamples, size); | auto numSamplesToCopy = (size_t) jmin (newNumSamples, size); | ||||
auto newChannels = reinterpret_cast<Type**> (newData.get()); | |||||
auto newChan = reinterpret_cast<Type*> (newData + channelListSize); | |||||
auto newChannels = unalignedPointerCast<Type**> (newData.get()); | |||||
auto newChan = unalignedPointerCast<Type*> (newData + channelListSize); | |||||
for (int j = 0; j < newNumChannels; ++j) | for (int j = 0; j < newNumChannels; ++j) | ||||
{ | { | ||||
@@ -442,10 +442,10 @@ public: | |||||
{ | { | ||||
allocatedBytes = newTotalBytes; | allocatedBytes = newTotalBytes; | ||||
allocatedData.allocate (newTotalBytes, clearExtraSpace || isClear); | allocatedData.allocate (newTotalBytes, clearExtraSpace || isClear); | ||||
channels = reinterpret_cast<Type**> (allocatedData.get()); | |||||
channels = unalignedPointerCast<Type**> (allocatedData.get()); | |||||
} | } | ||||
auto* chan = reinterpret_cast<Type*> (allocatedData + channelListSize); | |||||
auto* chan = unalignedPointerCast<Type*> (allocatedData + channelListSize); | |||||
for (int i = 0; i < newNumChannels; ++i) | for (int i = 0; i < newNumChannels; ++i) | ||||
{ | { | ||||
@@ -1127,7 +1127,7 @@ private: | |||||
void allocateData() | void allocateData() | ||||
{ | { | ||||
#if (! JUCE_GCC) || (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 | |||||
#if ! JUCE_PROJUCER_LIVE_BUILD && (! JUCE_GCC || (__GNUC__ * 100 + __GNUC_MINOR__) >= 409) | |||||
static_assert (alignof (Type) <= detail::maxAlignment, | static_assert (alignof (Type) <= detail::maxAlignment, | ||||
"AudioBuffer cannot hold types with alignment requirements larger than that guaranteed by malloc"); | "AudioBuffer cannot hold types with alignment requirements larger than that guaranteed by malloc"); | ||||
#endif | #endif | ||||
@@ -1142,8 +1142,8 @@ private: | |||||
allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (Type) + channelListSize + 32; | allocatedBytes = (size_t) numChannels * (size_t) size * sizeof (Type) + channelListSize + 32; | ||||
allocatedData.malloc (allocatedBytes); | allocatedData.malloc (allocatedBytes); | ||||
channels = reinterpret_cast<Type**> (allocatedData.get()); | |||||
auto chan = reinterpret_cast<Type*> (allocatedData + channelListSize); | |||||
channels = unalignedPointerCast<Type**> (allocatedData.get()); | |||||
auto chan = unalignedPointerCast<Type*> (allocatedData + channelListSize); | |||||
for (int i = 0; i < numChannels; ++i) | for (int i = 0; i < numChannels; ++i) | ||||
{ | { | ||||
@@ -1167,7 +1167,7 @@ private: | |||||
else | else | ||||
{ | { | ||||
allocatedData.malloc (numChannels + 1, sizeof (Type*)); | allocatedData.malloc (numChannels + 1, sizeof (Type*)); | ||||
channels = reinterpret_cast<Type**> (allocatedData.get()); | |||||
channels = unalignedPointerCast<Type**> (allocatedData.get()); | |||||
} | } | ||||
for (int i = 0; i < numChannels; ++i) | for (int i = 0; i < numChannels; ++i) | ||||
@@ -32,7 +32,7 @@ | |||||
ID: juce_audio_basics | ID: juce_audio_basics | ||||
vendor: juce | vendor: juce | ||||
version: 6.0.0 | |||||
version: 6.0.4 | |||||
name: JUCE audio and MIDI data classes | name: JUCE audio and MIDI data classes | ||||
description: Classes for audio buffer manipulation, midi message handling, synthesis, etc. | description: Classes for audio buffer manipulation, midi message handling, synthesis, etc. | ||||
website: http://www.juce.com/juce | website: http://www.juce.com/juce | ||||
@@ -136,7 +136,7 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Receives events from a MidiKeyboardState object. */ | /** Receives events from a MidiKeyboardState object. */ | ||||
class Listener | |||||
class JUCE_API Listener | |||||
{ | { | ||||
public: | public: | ||||
//============================================================================== | //============================================================================== | ||||
@@ -401,7 +401,7 @@ public: | |||||
/** Returns true if the message is an aftertouch event. | /** Returns true if the message is an aftertouch event. | ||||
For aftertouch events, use the getNoteNumber() method to find out the key | For aftertouch events, use the getNoteNumber() method to find out the key | ||||
that it applies to, and getAftertouchValue() to find out the amount. Use | |||||
that it applies to, and getAfterTouchValue() to find out the amount. Use | |||||
getChannel() to find out the channel. | getChannel() to find out the channel. | ||||
@see getAftertouchValue, getNoteNumber | @see getAftertouchValue, getNoteNumber | ||||
@@ -177,8 +177,9 @@ static void addIfNotNull (OwnedArray<AudioIODeviceType>& list, AudioIODeviceType | |||||
void AudioDeviceManager::createAudioDeviceTypes (OwnedArray<AudioIODeviceType>& list) | void AudioDeviceManager::createAudioDeviceTypes (OwnedArray<AudioIODeviceType>& list) | ||||
{ | { | ||||
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_WASAPI (false)); | |||||
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_WASAPI (true)); | |||||
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_WASAPI (WASAPIDeviceMode::shared)); | |||||
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_WASAPI (WASAPIDeviceMode::exclusive)); | |||||
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_WASAPI (WASAPIDeviceMode::sharedLowLatency)); | |||||
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_DirectSound()); | addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_DirectSound()); | ||||
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_ASIO()); | addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_ASIO()); | ||||
addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_CoreAudio()); | addIfNotNull (list, AudioIODeviceType::createAudioIODeviceType_CoreAudio()); | ||||
@@ -544,6 +545,8 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup | |||||
else if (currentAudioDevice != nullptr) | else if (currentAudioDevice != nullptr) | ||||
return {}; | return {}; | ||||
stopDevice(); | |||||
if (getCurrentDeviceTypeObject() == nullptr | if (getCurrentDeviceTypeObject() == nullptr | ||||
|| (newSetup.inputDeviceName.isEmpty() && newSetup.outputDeviceName.isEmpty())) | || (newSetup.inputDeviceName.isEmpty() && newSetup.outputDeviceName.isEmpty())) | ||||
{ | { | ||||
@@ -555,8 +558,6 @@ String AudioDeviceManager::setAudioDeviceSetup (const AudioDeviceSetup& newSetup | |||||
return {}; | return {}; | ||||
} | } | ||||
stopDevice(); | |||||
String error; | String error; | ||||
if (currentSetup.inputDeviceName != newSetup.inputDeviceName | if (currentSetup.inputDeviceName != newSetup.inputDeviceName | ||||
@@ -42,48 +42,105 @@ void AudioIODeviceType::callDeviceChangeListeners() | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
#if ! JUCE_MAC | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_CoreAudio() { return nullptr; } | |||||
#if JUCE_MAC | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_CoreAudio() { return new CoreAudioClasses::CoreAudioIODeviceType(); } | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_CoreAudio() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! JUCE_IOS | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_iOSAudio() { return nullptr; } | |||||
#if JUCE_IOS | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_iOSAudio() { return new iOSAudioIODeviceType(); } | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_iOSAudio() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! (JUCE_WINDOWS && JUCE_WASAPI) | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (bool) { return nullptr; } | |||||
#if JUCE_WINDOWS && JUCE_WASAPI | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (WASAPIDeviceMode deviceMode) | |||||
{ | |||||
auto windowsVersion = SystemStats::getOperatingSystemType(); | |||||
if (windowsVersion < SystemStats::WinVista | |||||
|| (WasapiClasses::isLowLatencyMode (deviceMode) && windowsVersion < SystemStats::Windows10)) | |||||
return nullptr; | |||||
return new WasapiClasses::WASAPIAudioIODeviceType (deviceMode); | |||||
} | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (bool exclusiveMode) | |||||
{ | |||||
return createAudioIODeviceType_WASAPI (exclusiveMode ? WASAPIDeviceMode::exclusive | |||||
: WASAPIDeviceMode::shared); | |||||
} | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (WASAPIDeviceMode) { return nullptr; } | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (bool) { return nullptr; } | |||||
#endif | #endif | ||||
#if ! (JUCE_WINDOWS && JUCE_DIRECTSOUND) | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_DirectSound() { return nullptr; } | |||||
#if JUCE_WINDOWS && JUCE_DIRECTSOUND | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_DirectSound() { return new DSoundAudioIODeviceType(); } | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_DirectSound() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! (JUCE_WINDOWS && JUCE_ASIO) | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ASIO() { return nullptr; } | |||||
#if JUCE_WINDOWS && JUCE_ASIO | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ASIO() { return new ASIOAudioIODeviceType(); } | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ASIO() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! (JUCE_LINUX && JUCE_ALSA) | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ALSA() { return nullptr; } | |||||
#if JUCE_LINUX && JUCE_ALSA | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ALSA() { return createAudioIODeviceType_ALSA_PCMDevices(); } | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ALSA() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! (JUCE_LINUX && JUCE_JACK) | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_JACK() { return nullptr; } | |||||
#if JUCE_LINUX && JUCE_JACK | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_JACK() { return new JackAudioIODeviceType(); } | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_JACK() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! (JUCE_LINUX && JUCE_BELA) | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Bela() { return nullptr; } | |||||
#if JUCE_LINUX && JUCE_BELA | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Bela() { return new BelaAudioIODeviceType(); } | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Bela() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! JUCE_ANDROID | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android() { return nullptr; } | |||||
#if JUCE_ANDROID | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android() | |||||
{ | |||||
#if JUCE_USE_ANDROID_OBOE | |||||
if (isOboeAvailable()) | |||||
return nullptr; | |||||
#endif | |||||
#if JUCE_USE_ANDROID_OPENSLES | |||||
if (isOpenSLAvailable()) | |||||
return nullptr; | |||||
#endif | |||||
return new AndroidAudioIODeviceType(); | |||||
} | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Android() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! (JUCE_ANDROID && JUCE_USE_ANDROID_OPENSLES) | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_OpenSLES() { return nullptr; } | |||||
#if JUCE_ANDROID && JUCE_USE_ANDROID_OPENSLES | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_OpenSLES() | |||||
{ | |||||
return isOpenSLAvailable() ? new OpenSLAudioDeviceType() : nullptr; | |||||
} | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_OpenSLES() { return nullptr; } | |||||
#endif | #endif | ||||
#if ! (JUCE_ANDROID && JUCE_USE_ANDROID_OBOE) | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Oboe() { return nullptr; } | |||||
#if JUCE_ANDROID && JUCE_USE_ANDROID_OBOE | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Oboe() | |||||
{ | |||||
return isOboeAvailable() ? new OboeAudioIODeviceType() : nullptr; | |||||
} | |||||
#else | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Oboe() { return nullptr; } | |||||
#endif | #endif | ||||
} // namespace juce | } // namespace juce |
@@ -149,8 +149,8 @@ public: | |||||
static AudioIODeviceType* createAudioIODeviceType_CoreAudio(); | static AudioIODeviceType* createAudioIODeviceType_CoreAudio(); | ||||
/** Creates an iOS device type if it's available on this platform, or returns null. */ | /** Creates an iOS device type if it's available on this platform, or returns null. */ | ||||
static AudioIODeviceType* createAudioIODeviceType_iOSAudio(); | static AudioIODeviceType* createAudioIODeviceType_iOSAudio(); | ||||
/** Creates a WASAPI device type if it's available on this platform, or returns null. */ | |||||
static AudioIODeviceType* createAudioIODeviceType_WASAPI (bool exclusiveMode); | |||||
/** Creates a WASAPI device type in the specified mode if it's available on this platform, or returns null. */ | |||||
static AudioIODeviceType* createAudioIODeviceType_WASAPI (WASAPIDeviceMode deviceMode); | |||||
/** Creates a DirectSound device type if it's available on this platform, or returns null. */ | /** Creates a DirectSound device type if it's available on this platform, or returns null. */ | ||||
static AudioIODeviceType* createAudioIODeviceType_DirectSound(); | static AudioIODeviceType* createAudioIODeviceType_DirectSound(); | ||||
/** Creates an ASIO device type if it's available on this platform, or returns null. */ | /** Creates an ASIO device type if it's available on this platform, or returns null. */ | ||||
@@ -168,6 +168,9 @@ public: | |||||
/** Creates a Bela device type if it's available on this platform, or returns null. */ | /** Creates a Bela device type if it's available on this platform, or returns null. */ | ||||
static AudioIODeviceType* createAudioIODeviceType_Bela(); | static AudioIODeviceType* createAudioIODeviceType_Bela(); | ||||
/** This method has been deprecated. You should call the method which takes a WASAPIDeviceMode instead. */ | |||||
JUCE_DEPRECATED (static AudioIODeviceType* createAudioIODeviceType_WASAPI (bool exclusiveMode)); | |||||
protected: | protected: | ||||
explicit AudioIODeviceType (const String& typeName); | explicit AudioIODeviceType (const String& typeName); | ||||
@@ -45,6 +45,8 @@ | |||||
#include "juce_audio_devices.h" | #include "juce_audio_devices.h" | ||||
#include "native/juce_MidiDataConcatenator.h" | |||||
//============================================================================== | //============================================================================== | ||||
#if JUCE_MAC | #if JUCE_MAC | ||||
#define Point CarbonDummyPointName | #define Point CarbonDummyPointName | ||||
@@ -55,6 +57,9 @@ | |||||
#undef Point | #undef Point | ||||
#undef Component | #undef Component | ||||
#include "native/juce_mac_CoreAudio.cpp" | |||||
#include "native/juce_mac_CoreMidi.cpp" | |||||
#elif JUCE_IOS | #elif JUCE_IOS | ||||
#import <AudioToolbox/AudioToolbox.h> | #import <AudioToolbox/AudioToolbox.h> | ||||
#import <AVFoundation/AVFoundation.h> | #import <AVFoundation/AVFoundation.h> | ||||
@@ -64,13 +69,21 @@ | |||||
#import <CoreMIDI/MIDINetworkSession.h> | #import <CoreMIDI/MIDINetworkSession.h> | ||||
#endif | #endif | ||||
#include "native/juce_ios_Audio.cpp" | |||||
#include "native/juce_mac_CoreMidi.cpp" | |||||
//============================================================================== | //============================================================================== | ||||
#elif JUCE_WINDOWS | #elif JUCE_WINDOWS | ||||
#if JUCE_WASAPI | #if JUCE_WASAPI | ||||
#include <mmreg.h> | #include <mmreg.h> | ||||
#include "native/juce_win32_WASAPI.cpp" | |||||
#endif | #endif | ||||
#if JUCE_USE_WINRT_MIDI && JUCE_MSVC | |||||
#if JUCE_DIRECTSOUND | |||||
#include "native/juce_win32_DirectSound.cpp" | |||||
#endif | |||||
#if JUCE_USE_WINRT_MIDI && (JUCE_MSVC || JUCE_CLANG) | |||||
/* If you cannot find any of the header files below then you are probably | /* If you cannot find any of the header files below then you are probably | ||||
attempting to use the Windows 10 Bluetooth Low Energy API. For this to work you | attempting to use the Windows 10 Bluetooth Low Energy API. For this to work you | ||||
need to install version 10.0.14393.0 of the Windows Standalone SDK and you may | need to install version 10.0.14393.0 of the Windows Standalone SDK and you may | ||||
@@ -93,6 +106,8 @@ | |||||
JUCE_END_IGNORE_WARNINGS_MSVC | JUCE_END_IGNORE_WARNINGS_MSVC | ||||
#endif | #endif | ||||
#include "native/juce_win32_Midi.cpp" | |||||
#if JUCE_ASIO | #if JUCE_ASIO | ||||
/* This is very frustrating - we only need to use a handful of definitions from | /* This is very frustrating - we only need to use a handful of definitions from | ||||
a couple of the header files in Steinberg's ASIO SDK, and it'd be easy to copy | a couple of the header files in Steinberg's ASIO SDK, and it'd be easy to copy | ||||
@@ -114,6 +129,7 @@ | |||||
needed - so to simplify things, you could just copy these into your JUCE directory). | needed - so to simplify things, you could just copy these into your JUCE directory). | ||||
*/ | */ | ||||
#include <iasiodrv.h> | #include <iasiodrv.h> | ||||
#include "native/juce_win32_ASIO.cpp" | |||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
@@ -128,6 +144,7 @@ | |||||
just set the JUCE_ALSA flag to 0. | just set the JUCE_ALSA flag to 0. | ||||
*/ | */ | ||||
#include <alsa/asoundlib.h> | #include <alsa/asoundlib.h> | ||||
#include "native/juce_linux_ALSA.cpp" | |||||
#endif | #endif | ||||
#if JUCE_JACK | #if JUCE_JACK | ||||
@@ -140,6 +157,7 @@ | |||||
JUCE with low latency audio support, just set the JUCE_JACK flag to 0. | JUCE with low latency audio support, just set the JUCE_JACK flag to 0. | ||||
*/ | */ | ||||
#include <jack/jack.h> | #include <jack/jack.h> | ||||
#include "native/juce_linux_JackAudio.cpp" | |||||
#endif | #endif | ||||
#if JUCE_BELA | #if JUCE_BELA | ||||
@@ -149,89 +167,18 @@ | |||||
*/ | */ | ||||
#include <Bela.h> | #include <Bela.h> | ||||
#include <Midi.h> | #include <Midi.h> | ||||
#include "native/juce_linux_Bela.cpp" | |||||
#endif | #endif | ||||
#undef SIZEOF | #undef SIZEOF | ||||
//============================================================================== | |||||
#elif JUCE_ANDROID | |||||
#if JUCE_USE_ANDROID_OPENSLES | |||||
#include <SLES/OpenSLES.h> | |||||
#include <SLES/OpenSLES_Android.h> | |||||
#include <SLES/OpenSLES_AndroidConfiguration.h> | |||||
#endif | |||||
#if JUCE_USE_ANDROID_OBOE | |||||
#if JUCE_USE_ANDROID_OPENSLES | |||||
#error "Oboe cannot be enabled at the same time as openSL! Please disable JUCE_USE_ANDROID_OPENSLES" | |||||
#endif | |||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter", | |||||
"-Wzero-as-null-pointer-constant", | |||||
"-Winconsistent-missing-destructor-override", | |||||
"-Wshadow-field-in-constructor", | |||||
"-Wshadow-field") | |||||
#include <oboe/Oboe.h> | |||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE | |||||
#endif | |||||
#endif | |||||
#include "audio_io/juce_AudioDeviceManager.cpp" | |||||
#include "audio_io/juce_AudioIODevice.cpp" | |||||
#include "audio_io/juce_AudioIODeviceType.cpp" | |||||
#include "midi_io/juce_MidiMessageCollector.cpp" | |||||
#include "midi_io/juce_MidiDevices.cpp" | |||||
#include "sources/juce_AudioSourcePlayer.cpp" | |||||
#include "sources/juce_AudioTransportSource.cpp" | |||||
#include "native/juce_MidiDataConcatenator.h" | |||||
//============================================================================== | |||||
#if JUCE_MAC | |||||
#include "native/juce_mac_CoreAudio.cpp" | |||||
#include "native/juce_mac_CoreMidi.cpp" | |||||
//============================================================================== | |||||
#elif JUCE_IOS | |||||
#include "native/juce_ios_Audio.cpp" | |||||
#include "native/juce_mac_CoreMidi.cpp" | |||||
//============================================================================== | |||||
#elif JUCE_WINDOWS | |||||
#if JUCE_WASAPI | |||||
#include "native/juce_win32_WASAPI.cpp" | |||||
#endif | |||||
#if JUCE_DIRECTSOUND | |||||
#include "native/juce_win32_DirectSound.cpp" | |||||
#endif | |||||
#include "native/juce_win32_Midi.cpp" | |||||
#if JUCE_ASIO | |||||
#include "native/juce_win32_ASIO.cpp" | |||||
#endif | |||||
//============================================================================== | |||||
#elif JUCE_LINUX | |||||
#if JUCE_ALSA | |||||
#include "native/juce_linux_ALSA.cpp" | |||||
#endif | |||||
#if JUCE_JACK | |||||
#include "native/juce_linux_JackAudio.cpp" | |||||
#endif | |||||
#if JUCE_BELA | |||||
#include "native/juce_linux_Bela.cpp" | |||||
#else | |||||
#if ! JUCE_BELA | |||||
#include "native/juce_linux_Midi.cpp" | #include "native/juce_linux_Midi.cpp" | ||||
#endif | #endif | ||||
//============================================================================== | //============================================================================== | ||||
#elif JUCE_ANDROID | #elif JUCE_ANDROID | ||||
#include "native/juce_android_Audio.cpp" | #include "native/juce_android_Audio.cpp" | ||||
#include "native/juce_android_Midi.cpp" | #include "native/juce_android_Midi.cpp" | ||||
@@ -239,10 +186,25 @@ | |||||
#include "native/juce_android_HighPerformanceAudioHelpers.h" | #include "native/juce_android_HighPerformanceAudioHelpers.h" | ||||
#if JUCE_USE_ANDROID_OPENSLES | #if JUCE_USE_ANDROID_OPENSLES | ||||
#include <SLES/OpenSLES.h> | |||||
#include <SLES/OpenSLES_Android.h> | |||||
#include <SLES/OpenSLES_AndroidConfiguration.h> | |||||
#include "native/juce_android_OpenSL.cpp" | #include "native/juce_android_OpenSL.cpp" | ||||
#endif | #endif | ||||
#if JUCE_USE_ANDROID_OBOE | #if JUCE_USE_ANDROID_OBOE | ||||
#if JUCE_USE_ANDROID_OPENSLES | |||||
#error "Oboe cannot be enabled at the same time as openSL! Please disable JUCE_USE_ANDROID_OPENSLES" | |||||
#endif | |||||
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wunused-parameter", | |||||
"-Wzero-as-null-pointer-constant", | |||||
"-Winconsistent-missing-destructor-override", | |||||
"-Wshadow-field-in-constructor", | |||||
"-Wshadow-field") | |||||
#include <oboe/Oboe.h> | |||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE | |||||
#include "native/juce_android_Oboe.cpp" | #include "native/juce_android_Oboe.cpp" | ||||
#endif | #endif | ||||
#endif | #endif | ||||
@@ -259,3 +221,11 @@ namespace juce | |||||
bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; } | bool JUCE_CALLTYPE SystemAudioVolume::setMuted (bool) { jassertfalse; return false; } | ||||
} | } | ||||
#endif | #endif | ||||
#include "audio_io/juce_AudioDeviceManager.cpp" | |||||
#include "audio_io/juce_AudioIODevice.cpp" | |||||
#include "audio_io/juce_AudioIODeviceType.cpp" | |||||
#include "midi_io/juce_MidiMessageCollector.cpp" | |||||
#include "midi_io/juce_MidiDevices.cpp" | |||||
#include "sources/juce_AudioSourcePlayer.cpp" | |||||
#include "sources/juce_AudioTransportSource.cpp" |
@@ -32,7 +32,7 @@ | |||||
ID: juce_audio_devices | ID: juce_audio_devices | ||||
vendor: juce | vendor: juce | ||||
version: 6.0.0 | |||||
version: 6.0.4 | |||||
name: JUCE audio and MIDI I/O device classes | name: JUCE audio and MIDI I/O device classes | ||||
description: Classes to play and record from audio and MIDI I/O devices | description: Classes to play and record from audio and MIDI I/O devices | ||||
website: http://www.juce.com/juce | website: http://www.juce.com/juce | ||||
@@ -88,21 +88,12 @@ | |||||
#endif | #endif | ||||
/** Config: JUCE_WASAPI | /** Config: JUCE_WASAPI | ||||
Enables WASAPI audio devices (Windows Vista and above). See also the | |||||
JUCE_WASAPI_EXCLUSIVE flag. | |||||
Enables WASAPI audio devices (Windows Vista and above). | |||||
*/ | */ | ||||
#ifndef JUCE_WASAPI | #ifndef JUCE_WASAPI | ||||
#define JUCE_WASAPI 1 | #define JUCE_WASAPI 1 | ||||
#endif | #endif | ||||
/** Config: JUCE_WASAPI_EXCLUSIVE | |||||
Enables WASAPI audio devices in exclusive mode (Windows Vista and above). | |||||
*/ | |||||
#ifndef JUCE_WASAPI_EXCLUSIVE | |||||
#define JUCE_WASAPI_EXCLUSIVE 0 | |||||
#endif | |||||
/** Config: JUCE_DIRECTSOUND | /** Config: JUCE_DIRECTSOUND | ||||
Enables DirectSound audio (MS Windows only). | Enables DirectSound audio (MS Windows only). | ||||
*/ | */ | ||||
@@ -174,6 +165,22 @@ | |||||
//============================================================================== | //============================================================================== | ||||
#include "midi_io/juce_MidiDevices.h" | #include "midi_io/juce_MidiDevices.h" | ||||
#include "midi_io/juce_MidiMessageCollector.h" | #include "midi_io/juce_MidiMessageCollector.h" | ||||
namespace juce | |||||
{ | |||||
/** Available modes for the WASAPI audio device. | |||||
Pass one of these to the AudioIODeviceType::createAudioIODeviceType_WASAPI() | |||||
method to create a WASAPI AudioIODeviceType object in this mode. | |||||
*/ | |||||
enum class WASAPIDeviceMode | |||||
{ | |||||
shared, | |||||
exclusive, | |||||
sharedLowLatency | |||||
}; | |||||
} | |||||
#include "audio_io/juce_AudioIODevice.h" | #include "audio_io/juce_AudioIODevice.h" | ||||
#include "audio_io/juce_AudioIODeviceType.h" | #include "audio_io/juce_AudioIODeviceType.h" | ||||
#include "audio_io/juce_SystemAudioVolume.h" | #include "audio_io/juce_SystemAudioVolume.h" | ||||
@@ -164,12 +164,16 @@ public: | |||||
/** Deprecated. */ | /** Deprecated. */ | ||||
static std::unique_ptr<MidiInput> openDevice (int, MidiInputCallback*); | static std::unique_ptr<MidiInput> openDevice (int, MidiInputCallback*); | ||||
/** @internal */ | |||||
class Pimpl; | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
explicit MidiInput (const String&, const String&); | explicit MidiInput (const String&, const String&); | ||||
MidiDeviceInfo deviceInfo; | MidiDeviceInfo deviceInfo; | ||||
void* internal = nullptr; | |||||
std::unique_ptr<Pimpl> internal; | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiInput) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiInput) | ||||
}; | }; | ||||
@@ -350,6 +354,9 @@ public: | |||||
/** Deprecated. */ | /** Deprecated. */ | ||||
static std::unique_ptr<MidiOutput> openDevice (int); | static std::unique_ptr<MidiOutput> openDevice (int); | ||||
/** @internal */ | |||||
class Pimpl; | |||||
private: | private: | ||||
//============================================================================== | //============================================================================== | ||||
struct PendingMessage | struct PendingMessage | ||||
@@ -368,7 +375,9 @@ private: | |||||
void run() override; | void run() override; | ||||
MidiDeviceInfo deviceInfo; | MidiDeviceInfo deviceInfo; | ||||
void* internal = nullptr; | |||||
std::unique_ptr<Pimpl> internal; | |||||
CriticalSection lock; | CriticalSection lock; | ||||
PendingMessage* firstMessage = nullptr; | PendingMessage* firstMessage = nullptr; | ||||
@@ -1299,9 +1299,4 @@ AudioIODeviceType* createAudioIODeviceType_ALSA_PCMDevices() | |||||
return new ALSAAudioIODeviceType (false, "ALSA"); | return new ALSAAudioIODeviceType (false, "ALSA"); | ||||
} | } | ||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ALSA() | |||||
{ | |||||
return createAudioIODeviceType_ALSA_PCMDevices(); | |||||
} | |||||
} // namespace juce | } // namespace juce |
@@ -24,12 +24,12 @@ namespace juce | |||||
{ | { | ||||
//============================================================================== | //============================================================================== | ||||
class BelaMidiInput | |||||
class MidiInput::Pimpl | |||||
{ | { | ||||
public: | public: | ||||
static Array<BelaMidiInput*> midiInputs; | |||||
static Array<Pimpl*> midiInputs; | |||||
BelaMidiInput (const String& port, MidiInput* input, MidiInputCallback* callback) | |||||
Pimpl (const String& port, MidiInput* input, MidiInputCallback* callback) | |||||
: midiInput (input), midiPort (port), midiCallback (callback) | : midiInput (input), midiPort (port), midiCallback (callback) | ||||
{ | { | ||||
jassert (midiCallback != nullptr); | jassert (midiCallback != nullptr); | ||||
@@ -38,7 +38,7 @@ public: | |||||
buffer.resize (32); | buffer.resize (32); | ||||
} | } | ||||
~BelaMidiInput() | |||||
~Pimpl() | |||||
{ | { | ||||
stop(); | stop(); | ||||
midiInputs.removeAllInstancesOf (this); | midiInputs.removeAllInstancesOf (this); | ||||
@@ -76,7 +76,7 @@ public: | |||||
} | } | ||||
if (receivedBytes > 0) | if (receivedBytes > 0) | ||||
pushMidiData (receivedBytes); | |||||
pushMidiData ((int) receivedBytes); | |||||
} | } | ||||
static Array<MidiDeviceInfo> getDevices (bool input) | static Array<MidiDeviceInfo> getDevices (bool input) | ||||
@@ -141,7 +141,7 @@ private: | |||||
snd_rawmidi_info_t* info; | snd_rawmidi_info_t* info; | ||||
snd_rawmidi_info_alloca (&info); | snd_rawmidi_info_alloca (&info); | ||||
snd_rawmidi_info_set_device (info, device); | |||||
snd_rawmidi_info_set_device (info, (unsigned int) device); | |||||
snd_rawmidi_info_set_stream (info, input ? SND_RAWMIDI_STREAM_INPUT | snd_rawmidi_info_set_stream (info, input ? SND_RAWMIDI_STREAM_INPUT | ||||
: SND_RAWMIDI_STREAM_OUTPUT); | : SND_RAWMIDI_STREAM_OUTPUT); | ||||
@@ -173,10 +173,10 @@ private: | |||||
Midi midi; | Midi midi; | ||||
MidiDataConcatenator concatenator { 512 }; | MidiDataConcatenator concatenator { 512 }; | ||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BelaMidiInput) | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Pimpl) | |||||
}; | }; | ||||
Array<BelaMidiInput*> BelaMidiInput::midiInputs; | |||||
Array<MidiInput::Pimpl*> MidiInput::Pimpl::midiInputs; | |||||
//============================================================================== | //============================================================================== | ||||
@@ -366,7 +366,7 @@ public: | |||||
String getLastError() override { return lastError; } | String getLastError() override { return lastError; } | ||||
//============================================================================== | //============================================================================== | ||||
int getCurrentBufferSizeSamples() override { return actualBufferSize; } | |||||
int getCurrentBufferSizeSamples() override { return (int) actualBufferSize; } | |||||
double getCurrentSampleRate() override { return 44100.0; } | double getCurrentSampleRate() override { return 44100.0; } | ||||
int getCurrentBitDepth() override { return 16; } | int getCurrentBitDepth() override { return 16; } | ||||
BigInteger getActiveOutputChannels() const override { BigInteger b; b.setRange (0, actualNumberOfOutputs, true); return b; } | BigInteger getActiveOutputChannels() const override { BigInteger b; b.setRange (0, actualNumberOfOutputs, true); return b; } | ||||
@@ -384,8 +384,8 @@ private: | |||||
bool setup (BelaContext& context) | bool setup (BelaContext& context) | ||||
{ | { | ||||
actualBufferSize = context.audioFrames; | actualBufferSize = context.audioFrames; | ||||
actualNumberOfInputs = context.audioInChannels + context.analogInChannels; | |||||
actualNumberOfOutputs = context.audioOutChannels + context.analogOutChannels; | |||||
actualNumberOfInputs = (int) (context.audioInChannels + context.analogInChannels); | |||||
actualNumberOfOutputs = (int) (context.audioOutChannels + context.analogOutChannels); | |||||
isBelaOpen = true; | isBelaOpen = true; | ||||
firstCallback = true; | firstCallback = true; | ||||
@@ -405,7 +405,7 @@ private: | |||||
ScopedLock lock (callbackLock); | ScopedLock lock (callbackLock); | ||||
// Check for and process and midi | // Check for and process and midi | ||||
for (auto midiInput : BelaMidiInput::midiInputs) | |||||
for (auto midiInput : MidiInput::Pimpl::midiInputs) | |||||
midiInput->poll(); | midiInput->poll(); | ||||
if (callback != nullptr) | if (callback != nullptr) | ||||
@@ -413,27 +413,29 @@ private: | |||||
jassert (context.audioFrames <= actualBufferSize); | jassert (context.audioFrames <= actualBufferSize); | ||||
jassert ((context.flags & BELA_FLAG_INTERLEAVED) == 0); | jassert ((context.flags & BELA_FLAG_INTERLEAVED) == 0); | ||||
using Frames = decltype (context.audioFrames); | |||||
// Setup channelInBuffers | // Setup channelInBuffers | ||||
for (int ch = 0; ch < actualNumberOfInputs; ++ch) | for (int ch = 0; ch < actualNumberOfInputs; ++ch) | ||||
{ | { | ||||
if (ch < analogChannelStart) | if (ch < analogChannelStart) | ||||
channelInBuffer[ch] = &context.audioIn[ch * context.audioFrames]; | |||||
channelInBuffer[ch] = &context.audioIn[(Frames) ch * context.audioFrames]; | |||||
else | else | ||||
channelInBuffer[ch] = &context.analogIn[(ch - analogChannelStart) * context.analogFrames]; | |||||
channelInBuffer[ch] = &context.analogIn[(Frames) (ch - analogChannelStart) * context.analogFrames]; | |||||
} | } | ||||
// Setup channelOutBuffers | // Setup channelOutBuffers | ||||
for (int ch = 0; ch < actualNumberOfOutputs; ++ch) | for (int ch = 0; ch < actualNumberOfOutputs; ++ch) | ||||
{ | { | ||||
if (ch < analogChannelStart) | if (ch < analogChannelStart) | ||||
channelOutBuffer[ch] = &context.audioOut[ch * context.audioFrames]; | |||||
channelOutBuffer[ch] = &context.audioOut[(Frames) ch * context.audioFrames]; | |||||
else | else | ||||
channelOutBuffer[ch] = &context.analogOut[(ch - analogChannelStart) * context.audioFrames]; | |||||
channelOutBuffer[ch] = &context.analogOut[(Frames) (ch - analogChannelStart) * context.audioFrames]; | |||||
} | } | ||||
callback->audioDeviceIOCallback (channelInBuffer.getData(), actualNumberOfInputs, | callback->audioDeviceIOCallback (channelInBuffer.getData(), actualNumberOfInputs, | ||||
channelOutBuffer.getData(), actualNumberOfOutputs, | channelOutBuffer.getData(), actualNumberOfOutputs, | ||||
context.audioFrames); | |||||
(int) context.audioFrames); | |||||
} | } | ||||
} | } | ||||
@@ -521,25 +523,19 @@ struct BelaAudioIODeviceType : public AudioIODeviceType | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BelaAudioIODeviceType) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BelaAudioIODeviceType) | ||||
}; | }; | ||||
//============================================================================== | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_Bela() | |||||
{ | |||||
return new BelaAudioIODeviceType(); | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
MidiInput::MidiInput (const String& deviceName, const String& deviceID) | MidiInput::MidiInput (const String& deviceName, const String& deviceID) | ||||
: deviceInfo (deviceName, deviceID) | : deviceInfo (deviceName, deviceID) | ||||
{ | { | ||||
} | } | ||||
MidiInput::~MidiInput() { delete static_cast<BelaMidiInput*> (internal); } | |||||
void MidiInput::start() { static_cast<BelaMidiInput*> (internal)->start(); } | |||||
void MidiInput::stop() { static_cast<BelaMidiInput*> (internal)->stop(); } | |||||
MidiInput::~MidiInput() = default; | |||||
void MidiInput::start() { internal->start(); } | |||||
void MidiInput::stop() { internal->stop(); } | |||||
Array<MidiDeviceInfo> MidiInput::getAvailableDevices() | Array<MidiDeviceInfo> MidiInput::getAvailableDevices() | ||||
{ | { | ||||
return BelaMidiInput::getDevices (true); | |||||
return Pimpl::getDevices (true); | |||||
} | } | ||||
MidiDeviceInfo MidiInput::getDefaultDevice() | MidiDeviceInfo MidiInput::getDefaultDevice() | ||||
@@ -553,7 +549,7 @@ std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier | |||||
return {}; | return {}; | ||||
std::unique_ptr<MidiInput> midiInput (new MidiInput (deviceIdentifier, deviceIdentifier)); | std::unique_ptr<MidiInput> midiInput (new MidiInput (deviceIdentifier, deviceIdentifier)); | ||||
midiInput->internal = new BelaMidiInput (deviceIdentifier, midiInput.get(), callback); | |||||
midiInput->internal = std::make_unique<Pimpl> (deviceIdentifier, midiInput.get(), callback); | |||||
return midiInput; | return midiInput; | ||||
} | } | ||||
@@ -587,7 +583,8 @@ std::unique_ptr<MidiInput> MidiInput::openDevice (int index, MidiInputCallback* | |||||
//============================================================================== | //============================================================================== | ||||
// TODO: Add Bela MidiOutput support | // TODO: Add Bela MidiOutput support | ||||
MidiOutput::~MidiOutput() {} | |||||
class MidiOutput::Pimpl {}; | |||||
MidiOutput::~MidiOutput() = default; | |||||
void MidiOutput::sendMessageNow (const MidiMessage&) {} | void MidiOutput::sendMessageNow (const MidiMessage&) {} | ||||
Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() { return {}; } | Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() { return {}; } | ||||
MidiDeviceInfo MidiOutput::getDefaultDevice() { return {}; } | MidiDeviceInfo MidiOutput::getDefaultDevice() { return {}; } | ||||
@@ -36,9 +36,11 @@ static void* juce_loadJackFunction (const char* const name) | |||||
#define JUCE_DECL_JACK_FUNCTION(return_type, fn_name, argument_types, arguments) \ | #define JUCE_DECL_JACK_FUNCTION(return_type, fn_name, argument_types, arguments) \ | ||||
return_type fn_name argument_types \ | return_type fn_name argument_types \ | ||||
{ \ | { \ | ||||
using ReturnType = return_type; \ | |||||
typedef return_type (*fn_type) argument_types; \ | typedef return_type (*fn_type) argument_types; \ | ||||
static fn_type fn = (fn_type) juce_loadJackFunction (#fn_name); \ | static fn_type fn = (fn_type) juce_loadJackFunction (#fn_name); \ | ||||
return (fn != nullptr) ? ((*fn) arguments) : (return_type) 0; \ | |||||
jassert (fn != nullptr); \ | |||||
return (fn != nullptr) ? ((*fn) arguments) : ReturnType(); \ | |||||
} | } | ||||
#define JUCE_DECL_VOID_JACK_FUNCTION(fn_name, argument_types, arguments) \ | #define JUCE_DECL_VOID_JACK_FUNCTION(fn_name, argument_types, arguments) \ | ||||
@@ -46,30 +48,35 @@ static void* juce_loadJackFunction (const char* const name) | |||||
{ \ | { \ | ||||
typedef void (*fn_type) argument_types; \ | typedef void (*fn_type) argument_types; \ | ||||
static fn_type fn = (fn_type) juce_loadJackFunction (#fn_name); \ | static fn_type fn = (fn_type) juce_loadJackFunction (#fn_name); \ | ||||
jassert (fn != nullptr); \ | |||||
if (fn != nullptr) (*fn) arguments; \ | if (fn != nullptr) (*fn) arguments; \ | ||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
JUCE_DECL_JACK_FUNCTION (jack_client_t*, jack_client_open, (const char* client_name, jack_options_t options, jack_status_t* status, ...), (client_name, options, status)); | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_client_close, (jack_client_t *client), (client)); | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_activate, (jack_client_t* client), (client)); | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_deactivate, (jack_client_t* client), (client)); | |||||
JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_get_buffer_size, (jack_client_t* client), (client)); | |||||
JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_get_sample_rate, (jack_client_t* client), (client)); | |||||
JUCE_DECL_VOID_JACK_FUNCTION (jack_on_shutdown, (jack_client_t* client, void (*function)(void* arg), void* arg), (client, function, arg)); | |||||
JUCE_DECL_JACK_FUNCTION (void* , jack_port_get_buffer, (jack_port_t* port, jack_nframes_t nframes), (port, nframes)); | |||||
JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_port_get_total_latency, (jack_client_t* client, jack_port_t* port), (client, port)); | |||||
JUCE_DECL_JACK_FUNCTION (jack_port_t* , jack_port_register, (jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size), (client, port_name, port_type, flags, buffer_size)); | |||||
JUCE_DECL_VOID_JACK_FUNCTION (jack_set_error_function, (void (*func)(const char*)), (func)); | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_set_process_callback, (jack_client_t* client, JackProcessCallback process_callback, void* arg), (client, process_callback, arg)); | |||||
JUCE_DECL_JACK_FUNCTION (const char**, jack_get_ports, (jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags), (client, port_name_pattern, type_name_pattern, flags)); | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_connect, (jack_client_t* client, const char* source_port, const char* destination_port), (client, source_port, destination_port)); | |||||
JUCE_DECL_JACK_FUNCTION (const char*, jack_port_name, (const jack_port_t* port), (port)); | |||||
JUCE_DECL_JACK_FUNCTION (void*, jack_set_port_connect_callback, (jack_client_t* client, JackPortConnectCallback connect_callback, void* arg), (client, connect_callback, arg)); | |||||
JUCE_DECL_JACK_FUNCTION (jack_port_t* , jack_port_by_id, (jack_client_t* client, jack_port_id_t port_id), (client, port_id)); | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_port_connected, (const jack_port_t* port), (port)); | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_port_connected_to, (const jack_port_t* port, const char* port_name), (port, port_name)); | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_set_xrun_callback, (jack_client_t* client, JackXRunCallback xrun_callback, void* arg), (client, xrun_callback, arg)); | |||||
JUCE_DECL_JACK_FUNCTION (jack_client_t*, jack_client_open, (const char* client_name, jack_options_t options, jack_status_t* status, ...), (client_name, options, status)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_client_close, (jack_client_t *client), (client)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_activate, (jack_client_t* client), (client)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_deactivate, (jack_client_t* client), (client)) | |||||
JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_get_buffer_size, (jack_client_t* client), (client)) | |||||
JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_get_sample_rate, (jack_client_t* client), (client)) | |||||
JUCE_DECL_VOID_JACK_FUNCTION (jack_on_shutdown, (jack_client_t* client, void (*function)(void* arg), void* arg), (client, function, arg)) | |||||
JUCE_DECL_VOID_JACK_FUNCTION (jack_on_info_shutdown, (jack_client_t* client, JackInfoShutdownCallback function, void* arg), (client, function, arg)) | |||||
JUCE_DECL_JACK_FUNCTION (void* , jack_port_get_buffer, (jack_port_t* port, jack_nframes_t nframes), (port, nframes)) | |||||
JUCE_DECL_JACK_FUNCTION (jack_nframes_t, jack_port_get_total_latency, (jack_client_t* client, jack_port_t* port), (client, port)) | |||||
JUCE_DECL_JACK_FUNCTION (jack_port_t* , jack_port_register, (jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size), (client, port_name, port_type, flags, buffer_size)) | |||||
JUCE_DECL_VOID_JACK_FUNCTION (jack_set_error_function, (void (*func)(const char*)), (func)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_set_process_callback, (jack_client_t* client, JackProcessCallback process_callback, void* arg), (client, process_callback, arg)) | |||||
JUCE_DECL_JACK_FUNCTION (const char**, jack_get_ports, (jack_client_t* client, const char* port_name_pattern, const char* type_name_pattern, unsigned long flags), (client, port_name_pattern, type_name_pattern, flags)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_connect, (jack_client_t* client, const char* source_port, const char* destination_port), (client, source_port, destination_port)) | |||||
JUCE_DECL_JACK_FUNCTION (const char*, jack_port_name, (const jack_port_t* port), (port)) | |||||
JUCE_DECL_JACK_FUNCTION (void*, jack_set_port_connect_callback, (jack_client_t* client, JackPortConnectCallback connect_callback, void* arg), (client, connect_callback, arg)) | |||||
JUCE_DECL_JACK_FUNCTION (jack_port_t* , jack_port_by_id, (jack_client_t* client, jack_port_id_t port_id), (client, port_id)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_port_connected, (const jack_port_t* port), (port)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_port_connected_to, (const jack_port_t* port, const char* port_name), (port, port_name)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_set_xrun_callback, (jack_client_t* client, JackXRunCallback xrun_callback, void* arg), (client, xrun_callback, arg)) | |||||
JUCE_DECL_JACK_FUNCTION (int, jack_port_flags, (const jack_port_t* port), (port)) | |||||
JUCE_DECL_JACK_FUNCTION (jack_port_t*, jack_port_by_name, (jack_client_t* client, const char* name), (client, name)) | |||||
JUCE_DECL_VOID_JACK_FUNCTION (jack_free, (void* ptr), (ptr)) | |||||
#if JUCE_DEBUG | #if JUCE_DEBUG | ||||
#define JACK_LOGGING_ENABLED 1 | #define JACK_LOGGING_ENABLED 1 | ||||
@@ -115,56 +122,56 @@ namespace | |||||
struct JackPortIterator | struct JackPortIterator | ||||
{ | { | ||||
JackPortIterator (jack_client_t* const client, const bool forInput) | JackPortIterator (jack_client_t* const client, const bool forInput) | ||||
: ports (nullptr), index (-1) | |||||
{ | { | ||||
if (client != nullptr) | if (client != nullptr) | ||||
ports = juce::jack_get_ports (client, nullptr, nullptr, | |||||
forInput ? JackPortIsOutput : JackPortIsInput); | |||||
// (NB: This looks like it's the wrong way round, but it is correct!) | |||||
} | |||||
~JackPortIterator() | |||||
{ | |||||
::free (ports); | |||||
ports.reset (juce::jack_get_ports (client, nullptr, nullptr, | |||||
forInput ? JackPortIsInput : JackPortIsOutput)); | |||||
} | } | ||||
bool next() | bool next() | ||||
{ | { | ||||
if (ports == nullptr || ports [index + 1] == nullptr) | |||||
if (ports == nullptr || ports.get()[index + 1] == nullptr) | |||||
return false; | return false; | ||||
name = CharPointer_UTF8 (ports[++index]); | |||||
clientName = name.upToFirstOccurrenceOf (":", false, false); | |||||
name = CharPointer_UTF8 (ports.get()[++index]); | |||||
return true; | return true; | ||||
} | } | ||||
const char** ports; | |||||
int index; | |||||
String getClientName() const | |||||
{ | |||||
return name.upToFirstOccurrenceOf (":", false, false); | |||||
} | |||||
String getChannelName() const | |||||
{ | |||||
return name.fromFirstOccurrenceOf (":", false, false); | |||||
} | |||||
struct Free | |||||
{ | |||||
void operator() (const char** ptr) const noexcept { juce::jack_free (ptr); } | |||||
}; | |||||
std::unique_ptr<const char*, Free> ports; | |||||
int index = -1; | |||||
String name; | String name; | ||||
String clientName; | |||||
}; | }; | ||||
class JackAudioIODeviceType; | |||||
static Array<JackAudioIODeviceType*> activeDeviceTypes; | |||||
//============================================================================== | //============================================================================== | ||||
class JackAudioIODevice : public AudioIODevice | class JackAudioIODevice : public AudioIODevice | ||||
{ | { | ||||
public: | public: | ||||
JackAudioIODevice (const String& deviceName, | |||||
const String& inId, | |||||
const String& outId) | |||||
: AudioIODevice (deviceName, "JACK"), | |||||
inputId (inId), | |||||
outputId (outId), | |||||
deviceIsOpen (false), | |||||
callback (nullptr), | |||||
totalNumberOfInputChannels (0), | |||||
totalNumberOfOutputChannels (0) | |||||
{ | |||||
jassert (deviceName.isNotEmpty()); | |||||
jack_status_t status; | |||||
JackAudioIODevice (const String& inName, | |||||
const String& outName, | |||||
std::function<void()> notifyIn) | |||||
: AudioIODevice (outName.isEmpty() ? inName : outName, "JACK"), | |||||
inputName (inName), | |||||
outputName (outName), | |||||
notifyChannelsChanged (std::move (notifyIn)) | |||||
{ | |||||
jassert (outName.isNotEmpty() || inName.isNotEmpty()); | |||||
jack_status_t status = {}; | |||||
client = juce::jack_client_open (JUCE_JACK_CLIENT_NAME, JackNoStartServer, &status); | client = juce::jack_client_open (JUCE_JACK_CLIENT_NAME, JackNoStartServer, &status); | ||||
if (client == nullptr) | if (client == nullptr) | ||||
@@ -179,10 +186,10 @@ public: | |||||
const StringArray inputChannels (getInputChannelNames()); | const StringArray inputChannels (getInputChannelNames()); | ||||
for (int i = 0; i < inputChannels.size(); ++i) | for (int i = 0; i < inputChannels.size(); ++i) | ||||
{ | { | ||||
String inputName; | |||||
inputName << "in_" << ++totalNumberOfInputChannels; | |||||
String inputChannelName; | |||||
inputChannelName << "in_" << ++totalNumberOfInputChannels; | |||||
inputPorts.add (juce::jack_port_register (client, inputName.toUTF8(), | |||||
inputPorts.add (juce::jack_port_register (client, inputChannelName.toUTF8(), | |||||
JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0)); | JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0)); | ||||
} | } | ||||
@@ -190,10 +197,10 @@ public: | |||||
const StringArray outputChannels (getOutputChannelNames()); | const StringArray outputChannels (getOutputChannelNames()); | ||||
for (int i = 0; i < outputChannels.size(); ++i) | for (int i = 0; i < outputChannels.size(); ++i) | ||||
{ | { | ||||
String outputName; | |||||
outputName << "out_" << ++totalNumberOfOutputChannels; | |||||
String outputChannelName; | |||||
outputChannelName << "out_" << ++totalNumberOfOutputChannels; | |||||
outputPorts.add (juce::jack_port_register (client, outputName.toUTF8(), | |||||
outputPorts.add (juce::jack_port_register (client, outputChannelName.toUTF8(), | |||||
JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)); | JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0)); | ||||
} | } | ||||
@@ -202,7 +209,7 @@ public: | |||||
} | } | ||||
} | } | ||||
~JackAudioIODevice() | |||||
~JackAudioIODevice() override | |||||
{ | { | ||||
close(); | close(); | ||||
if (client != nullptr) | if (client != nullptr) | ||||
@@ -212,19 +219,19 @@ public: | |||||
} | } | ||||
} | } | ||||
StringArray getChannelNames (bool forInput) const | |||||
StringArray getChannelNames (const String& clientName, bool forInput) const | |||||
{ | { | ||||
StringArray names; | StringArray names; | ||||
for (JackPortIterator i (client, forInput); i.next();) | for (JackPortIterator i (client, forInput); i.next();) | ||||
if (i.clientName == getName()) | |||||
names.add (i.name.fromFirstOccurrenceOf (":", false, false)); | |||||
if (i.getClientName() == clientName) | |||||
names.add (i.getChannelName()); | |||||
return names; | return names; | ||||
} | } | ||||
StringArray getOutputChannelNames() override { return getChannelNames (false); } | |||||
StringArray getInputChannelNames() override { return getChannelNames (true); } | |||||
StringArray getOutputChannelNames() override { return getChannelNames (outputName, true); } | |||||
StringArray getInputChannelNames() override { return getChannelNames (inputName, false); } | |||||
Array<double> getAvailableSampleRates() override | Array<double> getAvailableSampleRates() override | ||||
{ | { | ||||
@@ -241,15 +248,29 @@ public: | |||||
Array<int> sizes; | Array<int> sizes; | ||||
if (client != nullptr) | if (client != nullptr) | ||||
sizes.add (juce::jack_get_buffer_size (client)); | |||||
sizes.add (static_cast<int> (juce::jack_get_buffer_size (client))); | |||||
return sizes; | return sizes; | ||||
} | } | ||||
int getDefaultBufferSize() override { return getCurrentBufferSizeSamples(); } | int getDefaultBufferSize() override { return getCurrentBufferSizeSamples(); } | ||||
int getCurrentBufferSizeSamples() override { return client != nullptr ? juce::jack_get_buffer_size (client) : 0; } | |||||
double getCurrentSampleRate() override { return client != nullptr ? juce::jack_get_sample_rate (client) : 0; } | |||||
int getCurrentBufferSizeSamples() override { return client != nullptr ? static_cast<int> (juce::jack_get_buffer_size (client)) : 0; } | |||||
double getCurrentSampleRate() override { return client != nullptr ? static_cast<int> (juce::jack_get_sample_rate (client)) : 0; } | |||||
template <typename Fn> | |||||
void forEachClientChannel (const String& clientName, bool isInput, Fn&& fn) | |||||
{ | |||||
auto index = 0; | |||||
for (JackPortIterator i (client, isInput); i.next();) | |||||
{ | |||||
if (i.getClientName() != clientName) | |||||
continue; | |||||
fn (i.ports.get()[i.index], index); | |||||
index += 1; | |||||
} | |||||
} | |||||
String open (const BigInteger& inputChannels, const BigInteger& outputChannels, | String open (const BigInteger& inputChannels, const BigInteger& outputChannels, | ||||
double /* sampleRate */, int /* bufferSizeSamples */) override | double /* sampleRate */, int /* bufferSizeSamples */) override | ||||
@@ -263,38 +284,55 @@ public: | |||||
lastError.clear(); | lastError.clear(); | ||||
close(); | close(); | ||||
xruns = 0; | |||||
xruns.store (0, std::memory_order_relaxed); | |||||
juce::jack_set_process_callback (client, processCallback, this); | juce::jack_set_process_callback (client, processCallback, this); | ||||
juce::jack_set_port_connect_callback (client, portConnectCallback, this); | juce::jack_set_port_connect_callback (client, portConnectCallback, this); | ||||
juce::jack_on_shutdown (client, shutdownCallback, this); | juce::jack_on_shutdown (client, shutdownCallback, this); | ||||
juce::jack_on_info_shutdown (client, infoShutdownCallback, this); | |||||
juce::jack_set_xrun_callback (client, xrunCallback, this); | juce::jack_set_xrun_callback (client, xrunCallback, this); | ||||
juce::jack_activate (client); | juce::jack_activate (client); | ||||
deviceIsOpen = true; | deviceIsOpen = true; | ||||
if (! inputChannels.isZero()) | if (! inputChannels.isZero()) | ||||
{ | { | ||||
for (JackPortIterator i (client, true); i.next();) | |||||
forEachClientChannel (inputName, false, [&] (const char* portName, int index) | |||||
{ | { | ||||
if (inputChannels [i.index] && i.clientName == getName()) | |||||
{ | |||||
int error = juce::jack_connect (client, i.ports[i.index], juce::jack_port_name ((jack_port_t*) inputPorts[i.index])); | |||||
if (error != 0) | |||||
JUCE_JACK_LOG ("Cannot connect input port " + String (i.index) + " (" + i.name + "), error " + String (error)); | |||||
} | |||||
} | |||||
if (! inputChannels[index]) | |||||
return; | |||||
jassert (index < inputPorts.size()); | |||||
const auto* source = portName; | |||||
const auto* inputPort = inputPorts[index]; | |||||
jassert (juce::jack_port_flags (juce::jack_port_by_name (client, source)) & JackPortIsOutput); | |||||
jassert (juce::jack_port_flags (inputPort) & JackPortIsInput); | |||||
auto error = juce::jack_connect (client, source, juce::jack_port_name (inputPort)); | |||||
if (error != 0) | |||||
JUCE_JACK_LOG ("Cannot connect input port " + String (index) + " (" + portName + "), error " + String (error)); | |||||
}); | |||||
} | } | ||||
if (! outputChannels.isZero()) | if (! outputChannels.isZero()) | ||||
{ | { | ||||
for (JackPortIterator i (client, false); i.next();) | |||||
forEachClientChannel (outputName, true, [&] (const char* portName, int index) | |||||
{ | { | ||||
if (outputChannels [i.index] && i.clientName == getName()) | |||||
{ | |||||
int error = juce::jack_connect (client, juce::jack_port_name ((jack_port_t*) outputPorts[i.index]), i.ports[i.index]); | |||||
if (error != 0) | |||||
JUCE_JACK_LOG ("Cannot connect output port " + String (i.index) + " (" + i.name + "), error " + String (error)); | |||||
} | |||||
} | |||||
if (! outputChannels[index]) | |||||
return; | |||||
jassert (index < outputPorts.size()); | |||||
const auto* outputPort = outputPorts[index]; | |||||
const auto* destination = portName; | |||||
jassert (juce::jack_port_flags (outputPort) & JackPortIsOutput); | |||||
jassert (juce::jack_port_flags (juce::jack_port_by_name (client, destination)) & JackPortIsInput); | |||||
auto error = juce::jack_connect (client, juce::jack_port_name (outputPort), destination); | |||||
if (error != 0) | |||||
JUCE_JACK_LOG ("Cannot connect output port " + String (index) + " (" + portName + "), error " + String (error)); | |||||
}); | |||||
} | } | ||||
updateActivePorts(); | updateActivePorts(); | ||||
@@ -308,12 +346,15 @@ public: | |||||
if (client != nullptr) | if (client != nullptr) | ||||
{ | { | ||||
juce::jack_deactivate (client); | |||||
const auto result = juce::jack_deactivate (client); | |||||
jassert (result == 0); | |||||
ignoreUnused (result); | |||||
juce::jack_set_xrun_callback (client, xrunCallback, nullptr); | juce::jack_set_xrun_callback (client, xrunCallback, nullptr); | ||||
juce::jack_set_process_callback (client, processCallback, nullptr); | juce::jack_set_process_callback (client, processCallback, nullptr); | ||||
juce::jack_set_port_connect_callback (client, portConnectCallback, nullptr); | juce::jack_set_port_connect_callback (client, portConnectCallback, nullptr); | ||||
juce::jack_on_shutdown (client, shutdownCallback, nullptr); | juce::jack_on_shutdown (client, shutdownCallback, nullptr); | ||||
juce::jack_on_info_shutdown (client, infoShutdownCallback, nullptr); | |||||
} | } | ||||
deviceIsOpen = false; | deviceIsOpen = false; | ||||
@@ -347,7 +388,7 @@ public: | |||||
bool isPlaying() override { return callback != nullptr; } | bool isPlaying() override { return callback != nullptr; } | ||||
int getCurrentBitDepth() override { return 32; } | int getCurrentBitDepth() override { return 32; } | ||||
String getLastError() override { return lastError; } | String getLastError() override { return lastError; } | ||||
int getXRunCount() const noexcept override { return xruns; } | |||||
int getXRunCount() const noexcept override { return xruns.load (std::memory_order_relaxed); } | |||||
BigInteger getActiveOutputChannels() const override { return activeOutputChannels; } | BigInteger getActiveOutputChannels() const override { return activeOutputChannels; } | ||||
BigInteger getActiveInputChannels() const override { return activeInputChannels; } | BigInteger getActiveInputChannels() const override { return activeInputChannels; } | ||||
@@ -357,7 +398,7 @@ public: | |||||
int latency = 0; | int latency = 0; | ||||
for (int i = 0; i < outputPorts.size(); i++) | for (int i = 0; i < outputPorts.size(); i++) | ||||
latency = jmax (latency, (int) juce::jack_port_get_total_latency (client, (jack_port_t*) outputPorts [i])); | |||||
latency = jmax (latency, (int) juce::jack_port_get_total_latency (client, outputPorts[i])); | |||||
return latency; | return latency; | ||||
} | } | ||||
@@ -367,14 +408,36 @@ public: | |||||
int latency = 0; | int latency = 0; | ||||
for (int i = 0; i < inputPorts.size(); i++) | for (int i = 0; i < inputPorts.size(); i++) | ||||
latency = jmax (latency, (int) juce::jack_port_get_total_latency (client, (jack_port_t*) inputPorts [i])); | |||||
latency = jmax (latency, (int) juce::jack_port_get_total_latency (client, inputPorts[i])); | |||||
return latency; | return latency; | ||||
} | } | ||||
String inputId, outputId; | |||||
String inputName, outputName; | |||||
private: | private: | ||||
//============================================================================== | |||||
class MainThreadDispatcher : private AsyncUpdater | |||||
{ | |||||
public: | |||||
explicit MainThreadDispatcher (JackAudioIODevice& device) : ref (device) {} | |||||
~MainThreadDispatcher() override { cancelPendingUpdate(); } | |||||
void updateActivePorts() | |||||
{ | |||||
if (MessageManager::getInstance()->isThisTheMessageThread()) | |||||
handleAsyncUpdate(); | |||||
else | |||||
triggerAsyncUpdate(); | |||||
} | |||||
private: | |||||
void handleAsyncUpdate() override { ref.updateActivePorts(); } | |||||
JackAudioIODevice& ref; | |||||
}; | |||||
//============================================================================== | |||||
void process (const int numSamples) | void process (const int numSamples) | ||||
{ | { | ||||
int numActiveInChans = 0, numActiveOutChans = 0; | int numActiveInChans = 0, numActiveOutChans = 0; | ||||
@@ -382,17 +445,17 @@ private: | |||||
for (int i = 0; i < totalNumberOfInputChannels; ++i) | for (int i = 0; i < totalNumberOfInputChannels; ++i) | ||||
{ | { | ||||
if (activeInputChannels[i]) | if (activeInputChannels[i]) | ||||
if (jack_default_audio_sample_t* in | |||||
= (jack_default_audio_sample_t*) juce::jack_port_get_buffer ((jack_port_t*) inputPorts.getUnchecked(i), numSamples)) | |||||
inChans [numActiveInChans++] = (float*) in; | |||||
if (auto* in = (jack_default_audio_sample_t*) juce::jack_port_get_buffer (inputPorts.getUnchecked (i), | |||||
static_cast<jack_nframes_t> (numSamples))) | |||||
inChans[numActiveInChans++] = (float*) in; | |||||
} | } | ||||
for (int i = 0; i < totalNumberOfOutputChannels; ++i) | for (int i = 0; i < totalNumberOfOutputChannels; ++i) | ||||
{ | { | ||||
if (activeOutputChannels[i]) | if (activeOutputChannels[i]) | ||||
if (jack_default_audio_sample_t* out | |||||
= (jack_default_audio_sample_t*) juce::jack_port_get_buffer ((jack_port_t*) outputPorts.getUnchecked(i), numSamples)) | |||||
outChans [numActiveOutChans++] = (float*) out; | |||||
if (auto* out = (jack_default_audio_sample_t*) juce::jack_port_get_buffer (outputPorts.getUnchecked (i), | |||||
static_cast<jack_nframes_t> (numSamples))) | |||||
outChans[numActiveOutChans++] = (float*) out; | |||||
} | } | ||||
const ScopedLock sl (callbackLock); | const ScopedLock sl (callbackLock); | ||||
@@ -406,14 +469,14 @@ private: | |||||
else | else | ||||
{ | { | ||||
for (int i = 0; i < numActiveOutChans; ++i) | for (int i = 0; i < numActiveOutChans; ++i) | ||||
zeromem (outChans[i], sizeof (float) * numSamples); | |||||
zeromem (outChans[i], static_cast<size_t> (numSamples) * sizeof (float)); | |||||
} | } | ||||
} | } | ||||
static int processCallback (jack_nframes_t nframes, void* callbackArgument) | static int processCallback (jack_nframes_t nframes, void* callbackArgument) | ||||
{ | { | ||||
if (callbackArgument != nullptr) | if (callbackArgument != nullptr) | ||||
((JackAudioIODevice*) callbackArgument)->process (nframes); | |||||
((JackAudioIODevice*) callbackArgument)->process (static_cast<int> (nframes)); | |||||
return 0; | return 0; | ||||
} | } | ||||
@@ -431,11 +494,11 @@ private: | |||||
BigInteger newOutputChannels, newInputChannels; | BigInteger newOutputChannels, newInputChannels; | ||||
for (int i = 0; i < outputPorts.size(); ++i) | for (int i = 0; i < outputPorts.size(); ++i) | ||||
if (juce::jack_port_connected ((jack_port_t*) outputPorts.getUnchecked(i))) | |||||
if (juce::jack_port_connected (outputPorts.getUnchecked (i))) | |||||
newOutputChannels.setBit (i); | newOutputChannels.setBit (i); | ||||
for (int i = 0; i < inputPorts.size(); ++i) | for (int i = 0; i < inputPorts.size(); ++i) | ||||
if (juce::jack_port_connected ((jack_port_t*) inputPorts.getUnchecked(i))) | |||||
if (juce::jack_port_connected (inputPorts.getUnchecked (i))) | |||||
newInputChannels.setBit (i); | newInputChannels.setBit (i); | ||||
if (newOutputChannels != activeOutputChannels | if (newOutputChannels != activeOutputChannels | ||||
@@ -451,14 +514,15 @@ private: | |||||
if (oldCallback != nullptr) | if (oldCallback != nullptr) | ||||
start (oldCallback); | start (oldCallback); | ||||
sendDeviceChangedCallback(); | |||||
if (notifyChannelsChanged != nullptr) | |||||
notifyChannelsChanged(); | |||||
} | } | ||||
} | } | ||||
static void portConnectCallback (jack_port_id_t, jack_port_id_t, int, void* arg) | static void portConnectCallback (jack_port_id_t, jack_port_id_t, int, void* arg) | ||||
{ | { | ||||
if (JackAudioIODevice* device = static_cast<JackAudioIODevice*> (arg)) | if (JackAudioIODevice* device = static_cast<JackAudioIODevice*> (arg)) | ||||
device->updateActivePorts(); | |||||
device->mainThreadDispatcher.updateActivePorts(); | |||||
} | } | ||||
static void threadInitCallback (void* /* callbackArgument */) | static void threadInitCallback (void* /* callbackArgument */) | ||||
@@ -477,81 +541,76 @@ private: | |||||
} | } | ||||
} | } | ||||
static void infoShutdownCallback (jack_status_t code, const char* reason, void* arg) | |||||
{ | |||||
jassert (code == 0); | |||||
ignoreUnused (code); | |||||
JUCE_JACK_LOG ("Shutting down with message:"); | |||||
JUCE_JACK_LOG (reason); | |||||
ignoreUnused (reason); | |||||
shutdownCallback (arg); | |||||
} | |||||
static void errorCallback (const char* msg) | static void errorCallback (const char* msg) | ||||
{ | { | ||||
JUCE_JACK_LOG ("JackAudioIODevice::errorCallback " + String (msg)); | JUCE_JACK_LOG ("JackAudioIODevice::errorCallback " + String (msg)); | ||||
ignoreUnused (msg); | |||||
} | } | ||||
static void sendDeviceChangedCallback(); | |||||
bool deviceIsOpen; | |||||
jack_client_t* client; | |||||
bool deviceIsOpen = false; | |||||
jack_client_t* client = nullptr; | |||||
String lastError; | String lastError; | ||||
AudioIODeviceCallback* callback; | |||||
AudioIODeviceCallback* callback = nullptr; | |||||
CriticalSection callbackLock; | CriticalSection callbackLock; | ||||
HeapBlock<float*> inChans, outChans; | HeapBlock<float*> inChans, outChans; | ||||
int totalNumberOfInputChannels; | |||||
int totalNumberOfOutputChannels; | |||||
Array<void*> inputPorts, outputPorts; | |||||
int totalNumberOfInputChannels = 0; | |||||
int totalNumberOfOutputChannels = 0; | |||||
Array<jack_port_t*> inputPorts, outputPorts; | |||||
BigInteger activeInputChannels, activeOutputChannels; | BigInteger activeInputChannels, activeOutputChannels; | ||||
int xruns; | |||||
}; | |||||
std::atomic<int> xruns { 0 }; | |||||
std::function<void()> notifyChannelsChanged; | |||||
MainThreadDispatcher mainThreadDispatcher { *this }; | |||||
}; | |||||
//============================================================================== | //============================================================================== | ||||
class JackAudioIODeviceType; | |||||
class JackAudioIODeviceType : public AudioIODeviceType | class JackAudioIODeviceType : public AudioIODeviceType | ||||
{ | { | ||||
public: | public: | ||||
JackAudioIODeviceType() | JackAudioIODeviceType() | ||||
: AudioIODeviceType ("JACK"), | |||||
hasScanned (false) | |||||
{ | |||||
activeDeviceTypes.add (this); | |||||
} | |||||
~JackAudioIODeviceType() | |||||
{ | |||||
activeDeviceTypes.removeFirstMatchingValue (this); | |||||
} | |||||
: AudioIODeviceType ("JACK") | |||||
{} | |||||
void scanForDevices() | void scanForDevices() | ||||
{ | { | ||||
hasScanned = true; | hasScanned = true; | ||||
inputNames.clear(); | inputNames.clear(); | ||||
inputIds.clear(); | |||||
outputNames.clear(); | outputNames.clear(); | ||||
outputIds.clear(); | |||||
if (juce_libjackHandle == nullptr) juce_libjackHandle = dlopen ("libjack.so.0", RTLD_LAZY); | if (juce_libjackHandle == nullptr) juce_libjackHandle = dlopen ("libjack.so.0", RTLD_LAZY); | ||||
if (juce_libjackHandle == nullptr) juce_libjackHandle = dlopen ("libjack.so", RTLD_LAZY); | if (juce_libjackHandle == nullptr) juce_libjackHandle = dlopen ("libjack.so", RTLD_LAZY); | ||||
if (juce_libjackHandle == nullptr) return; | if (juce_libjackHandle == nullptr) return; | ||||
jack_status_t status; | |||||
jack_status_t status = {}; | |||||
// open a dummy client | // open a dummy client | ||||
if (jack_client_t* const client = juce::jack_client_open ("JuceJackDummy", JackNoStartServer, &status)) | |||||
if (auto* const client = juce::jack_client_open ("JuceJackDummy", JackNoStartServer, &status)) | |||||
{ | { | ||||
// scan for output devices | // scan for output devices | ||||
for (JackPortIterator i (client, false); i.next();) | for (JackPortIterator i (client, false); i.next();) | ||||
{ | |||||
if (i.clientName != (JUCE_JACK_CLIENT_NAME) && ! inputNames.contains (i.clientName)) | |||||
{ | |||||
inputNames.add (i.clientName); | |||||
inputIds.add (i.ports [i.index]); | |||||
} | |||||
} | |||||
if (i.getClientName() != (JUCE_JACK_CLIENT_NAME) && ! inputNames.contains (i.getClientName())) | |||||
inputNames.add (i.getClientName()); | |||||
// scan for input devices | // scan for input devices | ||||
for (JackPortIterator i (client, true); i.next();) | for (JackPortIterator i (client, true); i.next();) | ||||
{ | |||||
if (i.clientName != (JUCE_JACK_CLIENT_NAME) && ! outputNames.contains (i.clientName)) | |||||
{ | |||||
outputNames.add (i.clientName); | |||||
outputIds.add (i.ports [i.index]); | |||||
} | |||||
} | |||||
if (i.getClientName() != (JUCE_JACK_CLIENT_NAME) && ! outputNames.contains (i.getClientName())) | |||||
outputNames.add (i.getClientName()); | |||||
juce::jack_client_close (client); | juce::jack_client_close (client); | ||||
} | } | ||||
@@ -580,8 +639,8 @@ public: | |||||
jassert (hasScanned); // need to call scanForDevices() before doing this | jassert (hasScanned); // need to call scanForDevices() before doing this | ||||
if (JackAudioIODevice* d = dynamic_cast<JackAudioIODevice*> (device)) | if (JackAudioIODevice* d = dynamic_cast<JackAudioIODevice*> (device)) | ||||
return asInput ? inputIds.indexOf (d->inputId) | |||||
: outputIds.indexOf (d->outputId); | |||||
return asInput ? inputNames.indexOf (d->inputName) | |||||
: outputNames.indexOf (d->outputName); | |||||
return -1; | return -1; | ||||
} | } | ||||
@@ -595,34 +654,17 @@ public: | |||||
const int outputIndex = outputNames.indexOf (outputDeviceName); | const int outputIndex = outputNames.indexOf (outputDeviceName); | ||||
if (inputIndex >= 0 || outputIndex >= 0) | if (inputIndex >= 0 || outputIndex >= 0) | ||||
return new JackAudioIODevice (outputIndex >= 0 ? outputDeviceName | |||||
: inputDeviceName, | |||||
inputIds [inputIndex], | |||||
outputIds [outputIndex]); | |||||
return new JackAudioIODevice (inputDeviceName, outputDeviceName, | |||||
[this] { callDeviceChangeListeners(); }); | |||||
return nullptr; | return nullptr; | ||||
} | } | ||||
void portConnectionChange() { callDeviceChangeListeners(); } | |||||
private: | private: | ||||
StringArray inputNames, outputNames, inputIds, outputIds; | |||||
bool hasScanned; | |||||
StringArray inputNames, outputNames; | |||||
bool hasScanned = false; | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JackAudioIODeviceType) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (JackAudioIODeviceType) | ||||
}; | }; | ||||
void JackAudioIODevice::sendDeviceChangedCallback() | |||||
{ | |||||
for (int i = activeDeviceTypes.size(); --i >= 0;) | |||||
if (JackAudioIODeviceType* d = activeDeviceTypes[i]) | |||||
d->portConnectionChange(); | |||||
} | |||||
//============================================================================== | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_JACK() | |||||
{ | |||||
return new JackAudioIODeviceType(); | |||||
} | |||||
} // namespace juce | } // namespace juce |
@@ -25,10 +25,6 @@ namespace juce | |||||
#if JUCE_ALSA | #if JUCE_ALSA | ||||
//============================================================================== | |||||
namespace | |||||
{ | |||||
//============================================================================== | //============================================================================== | ||||
class AlsaClient : public ReferenceCountedObject | class AlsaClient : public ReferenceCountedObject | ||||
{ | { | ||||
@@ -453,9 +449,23 @@ static AlsaClient::Port* iterateMidiDevices (bool forInput, | |||||
return port; | return port; | ||||
} | } | ||||
} // namespace | |||||
struct AlsaPortPtr | |||||
{ | |||||
explicit AlsaPortPtr (AlsaClient::Port* p) | |||||
: ptr (p) {} | |||||
~AlsaPortPtr() noexcept { AlsaClient::getInstance()->deletePort (ptr); } | |||||
AlsaClient::Port* ptr = nullptr; | |||||
}; | |||||
//============================================================================== | //============================================================================== | ||||
class MidiInput::Pimpl : public AlsaPortPtr | |||||
{ | |||||
public: | |||||
using AlsaPortPtr::AlsaPortPtr; | |||||
}; | |||||
Array<MidiDeviceInfo> MidiInput::getAvailableDevices() | Array<MidiDeviceInfo> MidiInput::getAvailableDevices() | ||||
{ | { | ||||
Array<MidiDeviceInfo> devices; | Array<MidiDeviceInfo> devices; | ||||
@@ -485,7 +495,7 @@ std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier | |||||
std::unique_ptr<MidiInput> midiInput (new MidiInput (port->portName, deviceIdentifier)); | std::unique_ptr<MidiInput> midiInput (new MidiInput (port->portName, deviceIdentifier)); | ||||
port->setupInput (midiInput.get(), callback); | port->setupInput (midiInput.get(), callback); | ||||
midiInput->internal = port; | |||||
midiInput->internal = std::make_unique<Pimpl> (port); | |||||
return midiInput; | return midiInput; | ||||
} | } | ||||
@@ -501,7 +511,7 @@ std::unique_ptr<MidiInput> MidiInput::createNewDevice (const String& deviceName, | |||||
std::unique_ptr<MidiInput> midiInput (new MidiInput (deviceName, getFormattedPortIdentifier (client->getId(), port->portId))); | std::unique_ptr<MidiInput> midiInput (new MidiInput (deviceName, getFormattedPortIdentifier (client->getId(), port->portId))); | ||||
port->setupInput (midiInput.get(), callback); | port->setupInput (midiInput.get(), callback); | ||||
midiInput->internal = port; | |||||
midiInput->internal = std::make_unique<Pimpl> (port); | |||||
return midiInput; | return midiInput; | ||||
} | } | ||||
@@ -536,20 +546,25 @@ MidiInput::MidiInput (const String& deviceName, const String& deviceIdentifier) | |||||
MidiInput::~MidiInput() | MidiInput::~MidiInput() | ||||
{ | { | ||||
stop(); | stop(); | ||||
AlsaClient::getInstance()->deletePort (static_cast<AlsaClient::Port*> (internal)); | |||||
} | } | ||||
void MidiInput::start() | void MidiInput::start() | ||||
{ | { | ||||
static_cast<AlsaClient::Port*> (internal)->enableCallback (true); | |||||
internal->ptr->enableCallback (true); | |||||
} | } | ||||
void MidiInput::stop() | void MidiInput::stop() | ||||
{ | { | ||||
static_cast<AlsaClient::Port*> (internal)->enableCallback (false); | |||||
internal->ptr->enableCallback (false); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
class MidiOutput::Pimpl : public AlsaPortPtr | |||||
{ | |||||
public: | |||||
using AlsaPortPtr::AlsaPortPtr; | |||||
}; | |||||
Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() | Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() | ||||
{ | { | ||||
Array<MidiDeviceInfo> devices; | Array<MidiDeviceInfo> devices; | ||||
@@ -577,7 +592,7 @@ std::unique_ptr<MidiOutput> MidiOutput::openDevice (const String& deviceIdentifi | |||||
std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (port->portName, deviceIdentifier)); | std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (port->portName, deviceIdentifier)); | ||||
port->setupOutput(); | port->setupOutput(); | ||||
midiOutput->internal = port; | |||||
midiOutput->internal = std::make_unique<Pimpl> (port); | |||||
return midiOutput; | return midiOutput; | ||||
} | } | ||||
@@ -593,7 +608,7 @@ std::unique_ptr<MidiOutput> MidiOutput::createNewDevice (const String& deviceNam | |||||
std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (deviceName, getFormattedPortIdentifier (client->getId(), port->portId))); | std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (deviceName, getFormattedPortIdentifier (client->getId(), port->portId))); | ||||
port->setupOutput(); | port->setupOutput(); | ||||
midiOutput->internal = port; | |||||
midiOutput->internal = std::make_unique<Pimpl> (port); | |||||
return midiOutput; | return midiOutput; | ||||
} | } | ||||
@@ -623,17 +638,18 @@ std::unique_ptr<MidiOutput> MidiOutput::openDevice (int index) | |||||
MidiOutput::~MidiOutput() | MidiOutput::~MidiOutput() | ||||
{ | { | ||||
stopBackgroundThread(); | stopBackgroundThread(); | ||||
AlsaClient::getInstance()->deletePort (static_cast<AlsaClient::Port*> (internal)); | |||||
} | } | ||||
void MidiOutput::sendMessageNow (const MidiMessage& message) | void MidiOutput::sendMessageNow (const MidiMessage& message) | ||||
{ | { | ||||
static_cast<AlsaClient::Port*> (internal)->sendMessageNow (message); | |||||
internal->ptr->sendMessageNow (message); | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
#else | #else | ||||
class MidiInput::Pimpl {}; | |||||
// (These are just stub functions if ALSA is unavailable...) | // (These are just stub functions if ALSA is unavailable...) | ||||
MidiInput::MidiInput (const String& deviceName, const String& deviceID) | MidiInput::MidiInput (const String& deviceName, const String& deviceID) | ||||
: deviceInfo (deviceName, deviceID) | : deviceInfo (deviceName, deviceID) | ||||
@@ -651,6 +667,8 @@ StringArray MidiInput::getDevices() | |||||
int MidiInput::getDefaultDeviceIndex() { return 0;} | int MidiInput::getDefaultDeviceIndex() { return 0;} | ||||
std::unique_ptr<MidiInput> MidiInput::openDevice (int, MidiInputCallback*) { return {}; } | std::unique_ptr<MidiInput> MidiInput::openDevice (int, MidiInputCallback*) { return {}; } | ||||
class MidiOutput::Pimpl {}; | |||||
MidiOutput::~MidiOutput() {} | MidiOutput::~MidiOutput() {} | ||||
void MidiOutput::sendMessageNow (const MidiMessage&) {} | void MidiOutput::sendMessageNow (const MidiMessage&) {} | ||||
Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() { return {}; } | Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() { return {}; } | ||||
@@ -2234,12 +2234,6 @@ private: | |||||
}; | }; | ||||
//============================================================================== | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_CoreAudio() | |||||
{ | |||||
return new CoreAudioClasses::CoreAudioIODeviceType(); | |||||
} | |||||
#undef JUCE_COREAUDIOLOG | #undef JUCE_COREAUDIOLOG | ||||
} // namespace juce | } // namespace juce |
@@ -393,6 +393,12 @@ namespace CoreMidiHelpers | |||||
} | } | ||||
} | } | ||||
class MidiInput::Pimpl : public CoreMidiHelpers::MidiPortAndCallback | |||||
{ | |||||
public: | |||||
using MidiPortAndCallback::MidiPortAndCallback; | |||||
}; | |||||
//============================================================================== | //============================================================================== | ||||
Array<MidiDeviceInfo> MidiInput::getAvailableDevices() | Array<MidiDeviceInfo> MidiInput::getAvailableDevices() | ||||
{ | { | ||||
@@ -424,7 +430,7 @@ std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier | |||||
if (CHECK_ERROR (MIDIObjectGetStringProperty (endpoint, kMIDIPropertyName, &cfName.cfString))) | if (CHECK_ERROR (MIDIObjectGetStringProperty (endpoint, kMIDIPropertyName, &cfName.cfString))) | ||||
{ | { | ||||
MIDIPortRef port; | MIDIPortRef port; | ||||
auto mpc = std::make_unique<MidiPortAndCallback> (*callback); | |||||
auto mpc = std::make_unique<Pimpl> (*callback); | |||||
if (CHECK_ERROR (MIDIInputPortCreate (client, cfName.cfString, midiInputProc, mpc.get(), &port))) | if (CHECK_ERROR (MIDIInputPortCreate (client, cfName.cfString, midiInputProc, mpc.get(), &port))) | ||||
{ | { | ||||
@@ -435,10 +441,11 @@ std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier | |||||
std::unique_ptr<MidiInput> midiInput (new MidiInput (endpointInfo.name, endpointInfo.identifier)); | std::unique_ptr<MidiInput> midiInput (new MidiInput (endpointInfo.name, endpointInfo.identifier)); | ||||
mpc->input = midiInput.get(); | mpc->input = midiInput.get(); | ||||
midiInput->internal = mpc.get(); | |||||
auto* ptr = mpc.get(); | |||||
midiInput->internal = std::move (mpc); | |||||
const ScopedLock sl (callbackLock); | const ScopedLock sl (callbackLock); | ||||
activeCallbacks.add (mpc.release()); | |||||
activeCallbacks.add (ptr); | |||||
return midiInput; | return midiInput; | ||||
} | } | ||||
@@ -462,7 +469,7 @@ std::unique_ptr<MidiInput> MidiInput::createNewDevice (const String& deviceName, | |||||
if (auto client = getGlobalMidiClient()) | if (auto client = getGlobalMidiClient()) | ||||
{ | { | ||||
auto mpc = std::make_unique<MidiPortAndCallback> (*callback); | |||||
auto mpc = std::make_unique<Pimpl> (*callback); | |||||
mpc->active = false; | mpc->active = false; | ||||
MIDIEndpointRef endpoint; | MIDIEndpointRef endpoint; | ||||
@@ -491,10 +498,11 @@ std::unique_ptr<MidiInput> MidiInput::createNewDevice (const String& deviceName, | |||||
std::unique_ptr<MidiInput> midiInput (new MidiInput (deviceName, String (deviceIdentifier))); | std::unique_ptr<MidiInput> midiInput (new MidiInput (deviceName, String (deviceIdentifier))); | ||||
mpc->input = midiInput.get(); | mpc->input = midiInput.get(); | ||||
midiInput->internal = mpc.get(); | |||||
auto* ptr = mpc.get(); | |||||
midiInput->internal = std::move (mpc); | |||||
const ScopedLock sl (callbackLock); | const ScopedLock sl (callbackLock); | ||||
activeCallbacks.add (mpc.release()); | |||||
activeCallbacks.add (ptr); | |||||
return midiInput; | return midiInput; | ||||
} | } | ||||
@@ -529,24 +537,27 @@ MidiInput::MidiInput (const String& deviceName, const String& deviceIdentifier) | |||||
{ | { | ||||
} | } | ||||
MidiInput::~MidiInput() | |||||
{ | |||||
delete static_cast<CoreMidiHelpers::MidiPortAndCallback*> (internal); | |||||
} | |||||
MidiInput::~MidiInput() = default; | |||||
void MidiInput::start() | void MidiInput::start() | ||||
{ | { | ||||
const ScopedLock sl (CoreMidiHelpers::callbackLock); | const ScopedLock sl (CoreMidiHelpers::callbackLock); | ||||
static_cast<CoreMidiHelpers::MidiPortAndCallback*> (internal)->active = true; | |||||
internal->active = true; | |||||
} | } | ||||
void MidiInput::stop() | void MidiInput::stop() | ||||
{ | { | ||||
const ScopedLock sl (CoreMidiHelpers::callbackLock); | const ScopedLock sl (CoreMidiHelpers::callbackLock); | ||||
static_cast<CoreMidiHelpers::MidiPortAndCallback*> (internal)->active = false; | |||||
internal->active = false; | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
class MidiOutput::Pimpl : public CoreMidiHelpers::MidiPortAndEndpoint | |||||
{ | |||||
public: | |||||
using MidiPortAndEndpoint::MidiPortAndEndpoint; | |||||
}; | |||||
Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() | Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() | ||||
{ | { | ||||
return CoreMidiHelpers::findDevices (false); | return CoreMidiHelpers::findDevices (false); | ||||
@@ -581,7 +592,7 @@ std::unique_ptr<MidiOutput> MidiOutput::openDevice (const String& deviceIdentifi | |||||
if (CHECK_ERROR (MIDIOutputPortCreate (client, cfName.cfString, &port))) | if (CHECK_ERROR (MIDIOutputPortCreate (client, cfName.cfString, &port))) | ||||
{ | { | ||||
std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (endpointInfo.name, endpointInfo.identifier)); | std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (endpointInfo.name, endpointInfo.identifier)); | ||||
midiOutput->internal = new MidiPortAndEndpoint (port, endpoint); | |||||
midiOutput->internal = std::make_unique<Pimpl> (port, endpoint); | |||||
return midiOutput; | return midiOutput; | ||||
} | } | ||||
@@ -622,7 +633,7 @@ std::unique_ptr<MidiOutput> MidiOutput::createNewDevice (const String& deviceNam | |||||
if (CHECK_ERROR (MIDIObjectSetIntegerProperty (endpoint, kMIDIPropertyUniqueID, (SInt32) deviceIdentifier))) | if (CHECK_ERROR (MIDIObjectSetIntegerProperty (endpoint, kMIDIPropertyUniqueID, (SInt32) deviceIdentifier))) | ||||
{ | { | ||||
std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (deviceName, String (deviceIdentifier))); | std::unique_ptr<MidiOutput> midiOutput (new MidiOutput (deviceName, String (deviceIdentifier))); | ||||
midiOutput->internal = new MidiPortAndEndpoint (0, endpoint); | |||||
midiOutput->internal = std::make_unique<Pimpl> ((UInt32) 0, endpoint); | |||||
return midiOutput; | return midiOutput; | ||||
} | } | ||||
@@ -655,8 +666,6 @@ std::unique_ptr<MidiOutput> MidiOutput::openDevice (int index) | |||||
MidiOutput::~MidiOutput() | MidiOutput::~MidiOutput() | ||||
{ | { | ||||
stopBackgroundThread(); | stopBackgroundThread(); | ||||
delete static_cast<CoreMidiHelpers::MidiPortAndEndpoint*> (internal); | |||||
} | } | ||||
void MidiOutput::sendMessageNow (const MidiMessage& message) | void MidiOutput::sendMessageNow (const MidiMessage& message) | ||||
@@ -715,7 +724,7 @@ void MidiOutput::sendMessageNow (const MidiMessage& message) | |||||
return; | return; | ||||
} | } | ||||
static_cast<CoreMidiHelpers::MidiPortAndEndpoint*> (internal)->send (packetToSend); | |||||
internal->send (packetToSend); | |||||
} | } | ||||
#undef CHECK_ERROR | #undef CHECK_ERROR | ||||
@@ -504,7 +504,7 @@ public: | |||||
{ | { | ||||
inBuffers[n] = ioBufferSpace + (currentBlockSizeSamples * n); | inBuffers[n] = ioBufferSpace + (currentBlockSizeSamples * n); | ||||
ASIOChannelInfo channelInfo = { 0 }; | |||||
ASIOChannelInfo channelInfo = {}; | |||||
channelInfo.channel = i; | channelInfo.channel = i; | ||||
channelInfo.isInput = 1; | channelInfo.isInput = 1; | ||||
asioObject->getChannelInfo (&channelInfo); | asioObject->getChannelInfo (&channelInfo); | ||||
@@ -526,7 +526,7 @@ public: | |||||
{ | { | ||||
outBuffers[n] = ioBufferSpace + (currentBlockSizeSamples * (numActiveInputChans + n)); | outBuffers[n] = ioBufferSpace + (currentBlockSizeSamples * (numActiveInputChans + n)); | ||||
ASIOChannelInfo channelInfo = { 0 }; | |||||
ASIOChannelInfo channelInfo = {}; | |||||
channelInfo.channel = i; | channelInfo.channel = i; | ||||
channelInfo.isInput = 0; | channelInfo.isInput = 0; | ||||
asioObject->getChannelInfo (&channelInfo); | asioObject->getChannelInfo (&channelInfo); | ||||
@@ -673,10 +673,10 @@ public: | |||||
lastCallback->audioDeviceStopped(); | lastCallback->audioDeviceStopped(); | ||||
} | } | ||||
String getLastError() { return error; } | |||||
bool hasControlPanel() const { return true; } | |||||
String getLastError() override { return error; } | |||||
bool hasControlPanel() const override { return true; } | |||||
bool showControlPanel() | |||||
bool showControlPanel() override | |||||
{ | { | ||||
JUCE_ASIO_LOG ("showing control panel"); | JUCE_ASIO_LOG ("showing control panel"); | ||||
@@ -767,7 +767,7 @@ private: | |||||
bool deviceIsOpen = false, isStarted = false, buffersCreated = false; | bool deviceIsOpen = false, isStarted = false, buffersCreated = false; | ||||
std::atomic<bool> calledback { false }; | std::atomic<bool> calledback { false }; | ||||
bool littleEndian = false, postOutput = true, needToReset = false; | |||||
bool postOutput = true, needToReset = false; | |||||
bool insideControlPanelModalLoop = false; | bool insideControlPanelModalLoop = false; | ||||
bool shouldUsePreferredSize = false; | bool shouldUsePreferredSize = false; | ||||
int xruns = 0; | int xruns = 0; | ||||
@@ -785,7 +785,7 @@ private: | |||||
String getChannelName (int index, bool isInput) const | String getChannelName (int index, bool isInput) const | ||||
{ | { | ||||
ASIOChannelInfo channelInfo = { 0 }; | |||||
ASIOChannelInfo channelInfo = {}; | |||||
channelInfo.channel = index; | channelInfo.channel = index; | ||||
channelInfo.isInput = isInput ? 1 : 0; | channelInfo.isInput = isInput ? 1 : 0; | ||||
asioObject->getChannelInfo (&channelInfo); | asioObject->getChannelInfo (&channelInfo); | ||||
@@ -1065,7 +1065,7 @@ private: | |||||
for (int i = 0; i < totalNumOutputChans; ++i) | for (int i = 0; i < totalNumOutputChans; ++i) | ||||
{ | { | ||||
ASIOChannelInfo channelInfo = { 0 }; | |||||
ASIOChannelInfo channelInfo = {}; | |||||
channelInfo.channel = i; | channelInfo.channel = i; | ||||
channelInfo.isInput = 0; | channelInfo.isInput = 0; | ||||
asioObject->getChannelInfo (&channelInfo); | asioObject->getChannelInfo (&channelInfo); | ||||
@@ -1640,9 +1640,4 @@ void sendASIODeviceChangeToListeners (ASIOAudioIODeviceType* type) | |||||
type->sendDeviceChangeToListeners(); | type->sendDeviceChangeToListeners(); | ||||
} | } | ||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_ASIO() | |||||
{ | |||||
return new ASIOAudioIODeviceType(); | |||||
} | |||||
} // namespace juce | } // namespace juce |
@@ -1282,10 +1282,4 @@ private: | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DSoundAudioIODeviceType) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DSoundAudioIODeviceType) | ||||
}; | }; | ||||
//============================================================================== | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_DirectSound() | |||||
{ | |||||
return new DSoundAudioIODeviceType(); | |||||
} | |||||
} // namespace juce | } // namespace juce |
@@ -29,37 +29,39 @@ | |||||
namespace juce | namespace juce | ||||
{ | { | ||||
struct MidiServiceType | |||||
class MidiInput::Pimpl | |||||
{ | { | ||||
struct InputWrapper | |||||
{ | |||||
virtual ~InputWrapper() {} | |||||
public: | |||||
virtual ~Pimpl() noexcept = default; | |||||
virtual String getDeviceIdentifier() = 0; | |||||
virtual String getDeviceName() = 0; | |||||
virtual String getDeviceIdentifier() = 0; | |||||
virtual String getDeviceName() = 0; | |||||
virtual void start() = 0; | |||||
virtual void stop() = 0; | |||||
}; | |||||
virtual void start() = 0; | |||||
virtual void stop() = 0; | |||||
}; | |||||
struct OutputWrapper | |||||
{ | |||||
virtual ~OutputWrapper() {} | |||||
class MidiOutput::Pimpl | |||||
{ | |||||
public: | |||||
virtual ~Pimpl() noexcept = default; | |||||
virtual String getDeviceIdentifier() = 0; | |||||
virtual String getDeviceName() = 0; | |||||
virtual String getDeviceIdentifier() = 0; | |||||
virtual String getDeviceName() = 0; | |||||
virtual void sendMessageNow (const MidiMessage&) = 0; | |||||
}; | |||||
virtual void sendMessageNow (const MidiMessage&) = 0; | |||||
}; | |||||
MidiServiceType() {} | |||||
virtual ~MidiServiceType() {} | |||||
struct MidiServiceType | |||||
{ | |||||
MidiServiceType() = default; | |||||
virtual ~MidiServiceType() noexcept = default; | |||||
virtual Array<MidiDeviceInfo> getAvailableDevices (bool) = 0; | virtual Array<MidiDeviceInfo> getAvailableDevices (bool) = 0; | ||||
virtual MidiDeviceInfo getDefaultDevice (bool) = 0; | virtual MidiDeviceInfo getDefaultDevice (bool) = 0; | ||||
virtual InputWrapper* createInputWrapper (MidiInput&, const String&, MidiInputCallback&) = 0; | |||||
virtual OutputWrapper* createOutputWrapper (const String&) = 0; | |||||
virtual MidiInput::Pimpl* createInputWrapper (MidiInput&, const String&, MidiInputCallback&) = 0; | |||||
virtual MidiOutput::Pimpl* createOutputWrapper (const String&) = 0; | |||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiServiceType) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MidiServiceType) | ||||
}; | }; | ||||
@@ -82,12 +84,12 @@ struct Win32MidiService : public MidiServiceType, | |||||
: Win32OutputWrapper::getDefaultDevice(); | : Win32OutputWrapper::getDefaultDevice(); | ||||
} | } | ||||
InputWrapper* createInputWrapper (MidiInput& input, const String& deviceIdentifier, MidiInputCallback& callback) override | |||||
MidiInput::Pimpl* createInputWrapper (MidiInput& input, const String& deviceIdentifier, MidiInputCallback& callback) override | |||||
{ | { | ||||
return new Win32InputWrapper (*this, input, deviceIdentifier, callback); | return new Win32InputWrapper (*this, input, deviceIdentifier, callback); | ||||
} | } | ||||
OutputWrapper* createOutputWrapper (const String& deviceIdentifier) override | |||||
MidiOutput::Pimpl* createOutputWrapper (const String& deviceIdentifier) override | |||||
{ | { | ||||
return new Win32OutputWrapper (*this, deviceIdentifier); | return new Win32OutputWrapper (*this, deviceIdentifier); | ||||
} | } | ||||
@@ -384,7 +386,7 @@ private: | |||||
} | } | ||||
}; | }; | ||||
struct Win32InputWrapper : public InputWrapper, | |||||
struct Win32InputWrapper : public MidiInput::Pimpl, | |||||
public Win32MidiDeviceQuery<Win32InputWrapper> | public Win32MidiDeviceQuery<Win32InputWrapper> | ||||
{ | { | ||||
Win32InputWrapper (Win32MidiService& parentService, MidiInput& midiInput, const String& deviceIdentifier, MidiInputCallback& c) | Win32InputWrapper (Win32MidiService& parentService, MidiInput& midiInput, const String& deviceIdentifier, MidiInputCallback& c) | ||||
@@ -508,7 +510,7 @@ private: | |||||
}; | }; | ||||
//============================================================================== | //============================================================================== | ||||
struct Win32OutputWrapper : public OutputWrapper, | |||||
struct Win32OutputWrapper : public MidiOutput::Pimpl, | |||||
public Win32MidiDeviceQuery<Win32OutputWrapper> | public Win32MidiDeviceQuery<Win32OutputWrapper> | ||||
{ | { | ||||
Win32OutputWrapper (Win32MidiService& p, const String& deviceIdentifier) | Win32OutputWrapper (Win32MidiService& p, const String& deviceIdentifier) | ||||
@@ -763,12 +765,12 @@ public: | |||||
: outputDeviceWatcher->getDefaultDevice(); | : outputDeviceWatcher->getDefaultDevice(); | ||||
} | } | ||||
InputWrapper* createInputWrapper (MidiInput& input, const String& deviceIdentifier, MidiInputCallback& callback) override | |||||
MidiInput::Pimpl* createInputWrapper (MidiInput& input, const String& deviceIdentifier, MidiInputCallback& callback) override | |||||
{ | { | ||||
return new WinRTInputWrapper (*this, input, deviceIdentifier, callback); | return new WinRTInputWrapper (*this, input, deviceIdentifier, callback); | ||||
} | } | ||||
OutputWrapper* createOutputWrapper (const String& deviceIdentifier) override | |||||
MidiOutput::Pimpl* createOutputWrapper (const String& deviceIdentifier) override | |||||
{ | { | ||||
return new WinRTOutputWrapper (*this, deviceIdentifier); | return new WinRTOutputWrapper (*this, deviceIdentifier); | ||||
} | } | ||||
@@ -1554,7 +1556,7 @@ private: | |||||
}; | }; | ||||
//============================================================================== | //============================================================================== | ||||
struct WinRTInputWrapper final : public InputWrapper, | |||||
struct WinRTInputWrapper final : public MidiInput::Pimpl, | |||||
private WinRTIOWrapper<IMidiInPortStatics, IMidiInPort> | private WinRTIOWrapper<IMidiInPortStatics, IMidiInPort> | ||||
{ | { | ||||
@@ -1708,7 +1710,7 @@ private: | |||||
}; | }; | ||||
//============================================================================== | //============================================================================== | ||||
struct WinRTOutputWrapper final : public OutputWrapper, | |||||
struct WinRTOutputWrapper final : public MidiOutput::Pimpl, | |||||
private WinRTIOWrapper <IMidiOutPortStatics, IMidiOutPort> | private WinRTIOWrapper <IMidiOutPortStatics, IMidiOutPort> | ||||
{ | { | ||||
WinRTOutputWrapper (WinRTMidiService& service, const String& deviceIdentifier) | WinRTOutputWrapper (WinRTMidiService& service, const String& deviceIdentifier) | ||||
@@ -1865,7 +1867,7 @@ std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier | |||||
return {}; | return {}; | ||||
std::unique_ptr<MidiInput> in (new MidiInput ({}, deviceIdentifier)); | std::unique_ptr<MidiInput> in (new MidiInput ({}, deviceIdentifier)); | ||||
std::unique_ptr<MidiServiceType::InputWrapper> wrapper; | |||||
std::unique_ptr<Pimpl> wrapper; | |||||
try | try | ||||
{ | { | ||||
@@ -1877,7 +1879,7 @@ std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier | |||||
} | } | ||||
in->setName (wrapper->getDeviceName()); | in->setName (wrapper->getDeviceName()); | ||||
in->internal = wrapper.release(); | |||||
in->internal = std::move (wrapper); | |||||
return in; | return in; | ||||
} | } | ||||
@@ -1907,13 +1909,10 @@ MidiInput::MidiInput (const String& deviceName, const String& deviceIdentifier) | |||||
{ | { | ||||
} | } | ||||
MidiInput::~MidiInput() | |||||
{ | |||||
delete static_cast<MidiServiceType::InputWrapper*> (internal); | |||||
} | |||||
MidiInput::~MidiInput() = default; | |||||
void MidiInput::start() { static_cast<MidiServiceType::InputWrapper*> (internal)->start(); } | |||||
void MidiInput::stop() { static_cast<MidiServiceType::InputWrapper*> (internal)->stop(); } | |||||
void MidiInput::start() { internal->start(); } | |||||
void MidiInput::stop() { internal->stop(); } | |||||
//============================================================================== | //============================================================================== | ||||
Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() | Array<MidiDeviceInfo> MidiOutput::getAvailableDevices() | ||||
@@ -1931,7 +1930,7 @@ std::unique_ptr<MidiOutput> MidiOutput::openDevice (const String& deviceIdentifi | |||||
if (deviceIdentifier.isEmpty()) | if (deviceIdentifier.isEmpty()) | ||||
return {}; | return {}; | ||||
std::unique_ptr<MidiServiceType::OutputWrapper> wrapper; | |||||
std::unique_ptr<Pimpl> wrapper; | |||||
try | try | ||||
{ | { | ||||
@@ -1945,7 +1944,7 @@ std::unique_ptr<MidiOutput> MidiOutput::openDevice (const String& deviceIdentifi | |||||
std::unique_ptr<MidiOutput> out; | std::unique_ptr<MidiOutput> out; | ||||
out.reset (new MidiOutput (wrapper->getDeviceName(), deviceIdentifier)); | out.reset (new MidiOutput (wrapper->getDeviceName(), deviceIdentifier)); | ||||
out->internal = wrapper.release(); | |||||
out->internal = std::move (wrapper); | |||||
return out; | return out; | ||||
} | } | ||||
@@ -1973,12 +1972,11 @@ std::unique_ptr<MidiOutput> MidiOutput::openDevice (int index) | |||||
MidiOutput::~MidiOutput() | MidiOutput::~MidiOutput() | ||||
{ | { | ||||
stopBackgroundThread(); | stopBackgroundThread(); | ||||
delete static_cast<MidiServiceType::OutputWrapper*> (internal); | |||||
} | } | ||||
void MidiOutput::sendMessageNow (const MidiMessage& message) | void MidiOutput::sendMessageNow (const MidiMessage& message) | ||||
{ | { | ||||
static_cast<MidiServiceType::OutputWrapper*> (internal)->sendMessageNow (message); | |||||
internal->sendMessageNow (message); | |||||
} | } | ||||
} // namespace juce | } // namespace juce |
@@ -208,6 +208,29 @@ enum AUDCLNT_SHAREMODE | |||||
AUDCLNT_SHAREMODE_EXCLUSIVE | AUDCLNT_SHAREMODE_EXCLUSIVE | ||||
}; | }; | ||||
enum AUDIO_STREAM_CATEGORY | |||||
{ | |||||
AudioCategory_Other = 0, | |||||
AudioCategory_ForegroundOnlyMedia, | |||||
AudioCategory_BackgroundCapableMedia, | |||||
AudioCategory_Communications, | |||||
AudioCategory_Alerts, | |||||
AudioCategory_SoundEffects, | |||||
AudioCategory_GameEffects, | |||||
AudioCategory_GameMedia, | |||||
AudioCategory_GameChat, | |||||
AudioCategory_Speech, | |||||
AudioCategory_Movie, | |||||
AudioCategory_Media | |||||
}; | |||||
struct AudioClientProperties | |||||
{ | |||||
UINT32 cbSize; | |||||
BOOL bIsOffload; | |||||
AUDIO_STREAM_CATEGORY eCategory; | |||||
}; | |||||
JUCE_IUNKNOWNCLASS (IAudioClient, "1CB9AD4C-DBFA-4c32-B178-C2F568A703B2") | JUCE_IUNKNOWNCLASS (IAudioClient, "1CB9AD4C-DBFA-4c32-B178-C2F568A703B2") | ||||
{ | { | ||||
JUCE_COMCALL Initialize (AUDCLNT_SHAREMODE, DWORD, REFERENCE_TIME, REFERENCE_TIME, const WAVEFORMATEX*, LPCGUID) = 0; | JUCE_COMCALL Initialize (AUDCLNT_SHAREMODE, DWORD, REFERENCE_TIME, REFERENCE_TIME, const WAVEFORMATEX*, LPCGUID) = 0; | ||||
@@ -224,6 +247,20 @@ JUCE_IUNKNOWNCLASS (IAudioClient, "1CB9AD4C-DBFA-4c32-B178-C2F568A703B2") | |||||
JUCE_COMCALL GetService (REFIID, void**) = 0; | JUCE_COMCALL GetService (REFIID, void**) = 0; | ||||
}; | }; | ||||
JUCE_COMCLASS (IAudioClient2, "726778CD-F60A-4eda-82DE-E47610CD78AA") : public IAudioClient | |||||
{ | |||||
JUCE_COMCALL IsOffloadCapable (AUDIO_STREAM_CATEGORY, BOOL*) = 0; | |||||
JUCE_COMCALL SetClientProperties (const AudioClientProperties*) = 0; | |||||
JUCE_COMCALL GetBufferSizeLimits (const WAVEFORMATEX*, BOOL, REFERENCE_TIME*, REFERENCE_TIME*) = 0; | |||||
}; | |||||
JUCE_COMCLASS (IAudioClient3, "1CB9AD4C-DBFA-4c32-B178-C2F568A703B2") : public IAudioClient2 | |||||
{ | |||||
JUCE_COMCALL GetSharedModeEnginePeriod (const WAVEFORMATEX*, UINT32*, UINT32*, UINT32*, UINT32*) = 0; | |||||
JUCE_COMCALL GetCurrentSharedModeEnginePeriod (WAVEFORMATEX**, UINT32*) = 0; | |||||
JUCE_COMCALL InitializeSharedAudioStream (DWORD, UINT32, const WAVEFORMATEX*, LPCGUID) = 0; | |||||
}; | |||||
JUCE_IUNKNOWNCLASS (IAudioCaptureClient, "C8ADBD64-E71E-48a0-A4DE-185C395CD317") | JUCE_IUNKNOWNCLASS (IAudioCaptureClient, "C8ADBD64-E71E-48a0-A4DE-185C395CD317") | ||||
{ | { | ||||
JUCE_COMCALL GetBuffer (BYTE**, UINT32*, DWORD*, UINT64*, UINT64*) = 0; | JUCE_COMCALL GetBuffer (BYTE**, UINT32*, DWORD*, UINT64*, UINT64*) = 0; | ||||
@@ -322,87 +359,76 @@ String getDeviceID (IMMDevice* device) | |||||
return s; | return s; | ||||
} | } | ||||
EDataFlow getDataFlow (const ComSmartPtr<IMMDevice>& device) | |||||
static EDataFlow getDataFlow (const ComSmartPtr<IMMDevice>& device) | |||||
{ | { | ||||
EDataFlow flow = eRender; | EDataFlow flow = eRender; | ||||
ComSmartPtr<IMMEndpoint> endPoint; | |||||
if (check (device.QueryInterface (endPoint))) | |||||
(void) check (endPoint->GetDataFlow (&flow)); | |||||
if (auto endpoint = device.getInterface<IMMEndpoint>()) | |||||
(void) check (endpoint->GetDataFlow (&flow)); | |||||
return flow; | return flow; | ||||
} | } | ||||
int refTimeToSamples (const REFERENCE_TIME& t, double sampleRate) noexcept | |||||
static int refTimeToSamples (const REFERENCE_TIME& t, double sampleRate) noexcept | |||||
{ | { | ||||
return roundToInt (sampleRate * ((double) t) * 0.0000001); | return roundToInt (sampleRate * ((double) t) * 0.0000001); | ||||
} | } | ||||
REFERENCE_TIME samplesToRefTime (int numSamples, double sampleRate) noexcept | |||||
static REFERENCE_TIME samplesToRefTime (int numSamples, double sampleRate) noexcept | |||||
{ | { | ||||
return (REFERENCE_TIME) ((numSamples * 10000.0 * 1000.0 / sampleRate) + 0.5); | return (REFERENCE_TIME) ((numSamples * 10000.0 * 1000.0 / sampleRate) + 0.5); | ||||
} | } | ||||
void copyWavFormat (WAVEFORMATEXTENSIBLE& dest, const WAVEFORMATEX* src) noexcept | |||||
static void copyWavFormat (WAVEFORMATEXTENSIBLE& dest, const WAVEFORMATEX* src) noexcept | |||||
{ | { | ||||
memcpy (&dest, src, src->wFormatTag == WAVE_FORMAT_EXTENSIBLE ? sizeof (WAVEFORMATEXTENSIBLE) | memcpy (&dest, src, src->wFormatTag == WAVE_FORMAT_EXTENSIBLE ? sizeof (WAVEFORMATEXTENSIBLE) | ||||
: sizeof (WAVEFORMATEX)); | : sizeof (WAVEFORMATEX)); | ||||
} | } | ||||
static bool isExclusiveMode (WASAPIDeviceMode deviceMode) noexcept | |||||
{ | |||||
return deviceMode == WASAPIDeviceMode::exclusive; | |||||
} | |||||
static bool isLowLatencyMode (WASAPIDeviceMode deviceMode) noexcept | |||||
{ | |||||
return deviceMode == WASAPIDeviceMode::sharedLowLatency; | |||||
} | |||||
static bool supportsSampleRateConversion (WASAPIDeviceMode deviceMode) noexcept | |||||
{ | |||||
return deviceMode == WASAPIDeviceMode::shared; | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
class WASAPIDeviceBase | class WASAPIDeviceBase | ||||
{ | { | ||||
public: | public: | ||||
WASAPIDeviceBase (const ComSmartPtr<IMMDevice>& d, bool exclusiveMode) | |||||
: device (d), useExclusiveMode (exclusiveMode) | |||||
WASAPIDeviceBase (const ComSmartPtr<IMMDevice>& d, WASAPIDeviceMode mode) | |||||
: device (d), | |||||
deviceMode (mode) | |||||
{ | { | ||||
clientEvent = CreateEvent (nullptr, false, false, nullptr); | clientEvent = CreateEvent (nullptr, false, false, nullptr); | ||||
ComSmartPtr<IAudioClient> tempClient (createClient()); | ComSmartPtr<IAudioClient> tempClient (createClient()); | ||||
if (tempClient == nullptr) | if (tempClient == nullptr) | ||||
return; | return; | ||||
REFERENCE_TIME defaultPeriod, minPeriod; | |||||
if (! check (tempClient->GetDevicePeriod (&defaultPeriod, &minPeriod))) | |||||
return; | |||||
WAVEFORMATEXTENSIBLE format; | |||||
WAVEFORMATEX* mixFormat = nullptr; | |||||
if (! check (tempClient->GetMixFormat (&mixFormat))) | |||||
if (! getClientMixFormat (tempClient, format)) | |||||
return; | return; | ||||
WAVEFORMATEXTENSIBLE format; | |||||
copyWavFormat (format, mixFormat); | |||||
CoTaskMemFree (mixFormat); | |||||
actualNumChannels = numChannels = format.Format.nChannels; | actualNumChannels = numChannels = format.Format.nChannels; | ||||
defaultSampleRate = format.Format.nSamplesPerSec; | defaultSampleRate = format.Format.nSamplesPerSec; | ||||
minBufferSize = refTimeToSamples (minPeriod, defaultSampleRate); | |||||
defaultBufferSize = refTimeToSamples (defaultPeriod, defaultSampleRate); | |||||
mixFormatChannelMask = format.dwChannelMask; | |||||
rates.addUsingDefaultSort (defaultSampleRate); | rates.addUsingDefaultSort (defaultSampleRate); | ||||
mixFormatChannelMask = format.dwChannelMask; | |||||
if (useExclusiveMode | |||||
&& findSupportedFormat (tempClient, defaultSampleRate, format.dwChannelMask, format)) | |||||
{ | |||||
// Got a format that is supported by the device so we can ask what sample rates are supported (in whatever format) | |||||
} | |||||
for (auto rate : { 8000, 11025, 16000, 22050, 32000, | |||||
44100, 48000, 88200, 96000, 176400, | |||||
192000, 352800, 384000, 705600, 768000 }) | |||||
{ | |||||
if (rates.contains (rate)) | |||||
continue; | |||||
format.Format.nSamplesPerSec = (DWORD) rate; | |||||
format.Format.nAvgBytesPerSec = (DWORD) (format.Format.nSamplesPerSec * format.Format.nChannels * format.Format.wBitsPerSample / 8); | |||||
if (isExclusiveMode (deviceMode)) | |||||
findSupportedFormat (tempClient, defaultSampleRate, mixFormatChannelMask, format); | |||||
if (SUCCEEDED (tempClient->IsFormatSupported (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE | |||||
: AUDCLNT_SHAREMODE_SHARED, | |||||
(WAVEFORMATEX*) &format, 0))) | |||||
if (! rates.contains (rate)) | |||||
rates.addUsingDefaultSort (rate); | |||||
} | |||||
querySupportedBufferSizes (format, tempClient); | |||||
querySupportedSampleRates (format, tempClient); | |||||
} | } | ||||
virtual ~WASAPIDeviceBase() | virtual ~WASAPIDeviceBase() | ||||
@@ -487,11 +513,14 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
ComSmartPtr<IMMDevice> device; | ComSmartPtr<IMMDevice> device; | ||||
ComSmartPtr<IAudioClient> client; | ComSmartPtr<IAudioClient> client; | ||||
WASAPIDeviceMode deviceMode; | |||||
double sampleRate = 0, defaultSampleRate = 0; | double sampleRate = 0, defaultSampleRate = 0; | ||||
int numChannels = 0, actualNumChannels = 0; | int numChannels = 0, actualNumChannels = 0; | ||||
int minBufferSize = 0, defaultBufferSize = 0, latencySamples = 0; | int minBufferSize = 0, defaultBufferSize = 0, latencySamples = 0; | ||||
int lowLatencyBufferSizeMultiple = 0, lowLatencyMaxBufferSize = 0; | |||||
DWORD mixFormatChannelMask = 0; | DWORD mixFormatChannelMask = 0; | ||||
const bool useExclusiveMode; | |||||
Array<double> rates; | Array<double> rates; | ||||
HANDLE clientEvent = {}; | HANDLE clientEvent = {}; | ||||
BigInteger channels; | BigInteger channels; | ||||
@@ -582,6 +611,84 @@ private: | |||||
return newClient; | return newClient; | ||||
} | } | ||||
static bool getClientMixFormat (ComSmartPtr<IAudioClient>& client, WAVEFORMATEXTENSIBLE& format) | |||||
{ | |||||
WAVEFORMATEX* mixFormat = nullptr; | |||||
if (! check (client->GetMixFormat (&mixFormat))) | |||||
return false; | |||||
copyWavFormat (format, mixFormat); | |||||
CoTaskMemFree (mixFormat); | |||||
return true; | |||||
} | |||||
//============================================================================== | |||||
void querySupportedBufferSizes (WAVEFORMATEXTENSIBLE format, ComSmartPtr<IAudioClient>& audioClient) | |||||
{ | |||||
if (isLowLatencyMode (deviceMode)) | |||||
{ | |||||
if (auto audioClient3 = audioClient.getInterface<IAudioClient3>()) | |||||
{ | |||||
UINT32 defaultPeriod = 0, fundamentalPeriod = 0, minPeriod = 0, maxPeriod = 0; | |||||
if (check (audioClient3->GetSharedModeEnginePeriod ((WAVEFORMATEX*) &format, | |||||
&defaultPeriod, | |||||
&fundamentalPeriod, | |||||
&minPeriod, | |||||
&maxPeriod))) | |||||
{ | |||||
minBufferSize = minPeriod; | |||||
defaultBufferSize = defaultPeriod; | |||||
lowLatencyMaxBufferSize = maxPeriod; | |||||
lowLatencyBufferSizeMultiple = fundamentalPeriod; | |||||
} | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
REFERENCE_TIME defaultPeriod, minPeriod; | |||||
if (! check (audioClient->GetDevicePeriod (&defaultPeriod, &minPeriod))) | |||||
return; | |||||
minBufferSize = refTimeToSamples (minPeriod, defaultSampleRate); | |||||
defaultBufferSize = refTimeToSamples (defaultPeriod, defaultSampleRate); | |||||
} | |||||
} | |||||
void querySupportedSampleRates (WAVEFORMATEXTENSIBLE format, ComSmartPtr<IAudioClient>& audioClient) | |||||
{ | |||||
for (auto rate : { 8000, 11025, 16000, 22050, 32000, | |||||
44100, 48000, 88200, 96000, 176400, | |||||
192000, 352800, 384000, 705600, 768000 }) | |||||
{ | |||||
if (rates.contains (rate)) | |||||
continue; | |||||
format.Format.nSamplesPerSec = (DWORD) rate; | |||||
format.Format.nAvgBytesPerSec = (DWORD) (format.Format.nSamplesPerSec * format.Format.nChannels * format.Format.wBitsPerSample / 8); | |||||
WAVEFORMATEX* nearestFormat = nullptr; | |||||
if (SUCCEEDED (audioClient->IsFormatSupported (isExclusiveMode (deviceMode) ? AUDCLNT_SHAREMODE_EXCLUSIVE | |||||
: AUDCLNT_SHAREMODE_SHARED, | |||||
(WAVEFORMATEX*) &format, | |||||
isExclusiveMode (deviceMode) ? nullptr | |||||
: &nearestFormat))) | |||||
{ | |||||
if (nearestFormat != nullptr) | |||||
rate = nearestFormat->nSamplesPerSec; | |||||
if (! rates.contains (rate)) | |||||
rates.addUsingDefaultSort (rate); | |||||
} | |||||
CoTaskMemFree (nearestFormat); | |||||
} | |||||
} | |||||
struct AudioSampleFormat | struct AudioSampleFormat | ||||
{ | { | ||||
bool useFloat; | bool useFloat; | ||||
@@ -613,22 +720,35 @@ private: | |||||
format.SubFormat = sampleFormat.useFloat ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM; | format.SubFormat = sampleFormat.useFloat ? KSDATAFORMAT_SUBTYPE_IEEE_FLOAT : KSDATAFORMAT_SUBTYPE_PCM; | ||||
format.dwChannelMask = newMixFormatChannelMask; | format.dwChannelMask = newMixFormatChannelMask; | ||||
WAVEFORMATEXTENSIBLE* nearestFormat = nullptr; | |||||
WAVEFORMATEX* nearestFormat = nullptr; | |||||
HRESULT hr = clientToUse->IsFormatSupported (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE | |||||
: AUDCLNT_SHAREMODE_SHARED, | |||||
HRESULT hr = clientToUse->IsFormatSupported (isExclusiveMode (deviceMode) ? AUDCLNT_SHAREMODE_EXCLUSIVE | |||||
: AUDCLNT_SHAREMODE_SHARED, | |||||
(WAVEFORMATEX*) &format, | (WAVEFORMATEX*) &format, | ||||
useExclusiveMode ? nullptr : (WAVEFORMATEX**) &nearestFormat); | |||||
isExclusiveMode (deviceMode) ? nullptr | |||||
: &nearestFormat); | |||||
logFailure (hr); | logFailure (hr); | ||||
if (hr == S_FALSE && format.Format.nSamplesPerSec == nearestFormat->Format.nSamplesPerSec) | |||||
auto supportsSRC = supportsSampleRateConversion (deviceMode); | |||||
if (hr == S_FALSE | |||||
&& nearestFormat != nullptr | |||||
&& (format.Format.nSamplesPerSec == nearestFormat->nSamplesPerSec | |||||
|| supportsSRC)) | |||||
{ | { | ||||
copyWavFormat (format, (const WAVEFORMATEX*) nearestFormat); | |||||
copyWavFormat (format, nearestFormat); | |||||
if (supportsSRC) | |||||
{ | |||||
format.Format.nSamplesPerSec = (DWORD) newSampleRate; | |||||
format.Format.nAvgBytesPerSec = (DWORD) (format.Format.nSamplesPerSec * format.Format.nBlockAlign); | |||||
} | |||||
hr = S_OK; | hr = S_OK; | ||||
} | } | ||||
CoTaskMemFree (nearestFormat); | CoTaskMemFree (nearestFormat); | ||||
return check (hr); | |||||
return hr == S_OK; | |||||
} | } | ||||
bool findSupportedFormat (IAudioClient* clientToUse, double newSampleRate, | bool findSupportedFormat (IAudioClient* clientToUse, double newSampleRate, | ||||
@@ -652,50 +772,88 @@ private: | |||||
return false; | return false; | ||||
} | } | ||||
bool tryInitialisingWithBufferSize (int bufferSizeSamples) | |||||
DWORD getStreamFlags() | |||||
{ | { | ||||
WAVEFORMATEXTENSIBLE format; | |||||
DWORD streamFlags = 0x40000; /*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/ | |||||
if (findSupportedFormat (client, sampleRate, mixFormatChannelMask, format)) | |||||
if (supportsSampleRateConversion (deviceMode)) | |||||
streamFlags |= (0x80000000 /*AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM*/ | |||||
| 0x8000000); /*AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY*/ | |||||
return streamFlags; | |||||
} | |||||
bool initialiseLowLatencyClient (int bufferSizeSamples, WAVEFORMATEXTENSIBLE format) | |||||
{ | |||||
if (auto audioClient3 = client.getInterface<IAudioClient3>()) | |||||
return check (audioClient3->InitializeSharedAudioStream (getStreamFlags(), | |||||
bufferSizeSamples, | |||||
(WAVEFORMATEX*) &format, | |||||
nullptr)); | |||||
return false; | |||||
} | |||||
bool initialiseStandardClient (int bufferSizeSamples, WAVEFORMATEXTENSIBLE format) | |||||
{ | |||||
REFERENCE_TIME defaultPeriod = 0, minPeriod = 0; | |||||
check (client->GetDevicePeriod (&defaultPeriod, &minPeriod)); | |||||
if (isExclusiveMode (deviceMode) && bufferSizeSamples > 0) | |||||
defaultPeriod = jmax (minPeriod, samplesToRefTime (bufferSizeSamples, format.Format.nSamplesPerSec)); | |||||
for (;;) | |||||
{ | { | ||||
REFERENCE_TIME defaultPeriod = 0, minPeriod = 0; | |||||
GUID session; | |||||
auto hr = client->Initialize (isExclusiveMode (deviceMode) ? AUDCLNT_SHAREMODE_EXCLUSIVE | |||||
: AUDCLNT_SHAREMODE_SHARED, | |||||
getStreamFlags(), | |||||
defaultPeriod, | |||||
isExclusiveMode (deviceMode) ? defaultPeriod : 0, | |||||
(WAVEFORMATEX*) &format, | |||||
&session); | |||||
if (check (hr)) | |||||
return true; | |||||
check (client->GetDevicePeriod (&defaultPeriod, &minPeriod)); | |||||
// Handle the "alignment dance" : http://msdn.microsoft.com/en-us/library/windows/desktop/dd370875(v=vs.85).aspx (see Remarks) | |||||
if (hr != MAKE_HRESULT (1, 0x889, 0x19)) // AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED | |||||
break; | |||||
if (useExclusiveMode && bufferSizeSamples > 0) | |||||
defaultPeriod = jmax (minPeriod, samplesToRefTime (bufferSizeSamples, format.Format.nSamplesPerSec)); | |||||
UINT32 numFrames = 0; | |||||
if (! check (client->GetBufferSize (&numFrames))) | |||||
break; | |||||
for (;;) | |||||
{ | |||||
GUID session; | |||||
HRESULT hr = client->Initialize (useExclusiveMode ? AUDCLNT_SHAREMODE_EXCLUSIVE : AUDCLNT_SHAREMODE_SHARED, | |||||
0x40000 /*AUDCLNT_STREAMFLAGS_EVENTCALLBACK*/, | |||||
defaultPeriod, useExclusiveMode ? defaultPeriod : 0, (WAVEFORMATEX*) &format, &session); | |||||
// Recreate client | |||||
client = nullptr; | |||||
client = createClient(); | |||||
if (check (hr)) | |||||
{ | |||||
actualNumChannels = format.Format.nChannels; | |||||
const bool isFloat = format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE && format.SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; | |||||
bytesPerSample = format.Format.wBitsPerSample / 8; | |||||
bytesPerFrame = format.Format.nBlockAlign; | |||||
defaultPeriod = samplesToRefTime (numFrames, format.Format.nSamplesPerSec); | |||||
} | |||||
updateFormat (isFloat); | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
// Handle the "alignment dance" : http://msdn.microsoft.com/en-us/library/windows/desktop/dd370875(v=vs.85).aspx (see Remarks) | |||||
if (hr != MAKE_HRESULT (1, 0x889, 0x19)) // AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED | |||||
break; | |||||
bool tryInitialisingWithBufferSize (int bufferSizeSamples) | |||||
{ | |||||
WAVEFORMATEXTENSIBLE format; | |||||
UINT32 numFrames = 0; | |||||
if (! check (client->GetBufferSize (&numFrames))) | |||||
break; | |||||
if (findSupportedFormat (client, sampleRate, mixFormatChannelMask, format)) | |||||
{ | |||||
auto isInitialised = isLowLatencyMode (deviceMode) ? initialiseLowLatencyClient (bufferSizeSamples, format) | |||||
: initialiseStandardClient (bufferSizeSamples, format); | |||||
if (isInitialised) | |||||
{ | |||||
actualNumChannels = format.Format.nChannels; | |||||
const bool isFloat = format.Format.wFormatTag == WAVE_FORMAT_EXTENSIBLE && format.SubFormat == KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; | |||||
bytesPerSample = format.Format.wBitsPerSample / 8; | |||||
bytesPerFrame = format.Format.nBlockAlign; | |||||
// Recreate client | |||||
client = nullptr; | |||||
client = createClient(); | |||||
updateFormat (isFloat); | |||||
defaultPeriod = samplesToRefTime (numFrames, format.Format.nSamplesPerSec); | |||||
return true; | |||||
} | } | ||||
} | } | ||||
@@ -709,8 +867,8 @@ private: | |||||
class WASAPIInputDevice : public WASAPIDeviceBase | class WASAPIInputDevice : public WASAPIDeviceBase | ||||
{ | { | ||||
public: | public: | ||||
WASAPIInputDevice (const ComSmartPtr<IMMDevice>& d, bool exclusiveMode) | |||||
: WASAPIDeviceBase (d, exclusiveMode) | |||||
WASAPIInputDevice (const ComSmartPtr<IMMDevice>& d, WASAPIDeviceMode mode) | |||||
: WASAPIDeviceBase (d, mode) | |||||
{ | { | ||||
} | } | ||||
@@ -872,8 +1030,8 @@ private: | |||||
class WASAPIOutputDevice : public WASAPIDeviceBase | class WASAPIOutputDevice : public WASAPIDeviceBase | ||||
{ | { | ||||
public: | public: | ||||
WASAPIOutputDevice (const ComSmartPtr<IMMDevice>& d, bool exclusiveMode) | |||||
: WASAPIDeviceBase (d, exclusiveMode) | |||||
WASAPIOutputDevice (const ComSmartPtr<IMMDevice>& d, WASAPIDeviceMode mode) | |||||
: WASAPIDeviceBase (d, mode) | |||||
{ | { | ||||
} | } | ||||
@@ -931,7 +1089,7 @@ public: | |||||
if (numChannels <= 0) | if (numChannels <= 0) | ||||
return 0; | return 0; | ||||
if (! useExclusiveMode) | |||||
if (! isExclusiveMode (deviceMode)) | |||||
{ | { | ||||
UINT32 padding = 0; | UINT32 padding = 0; | ||||
@@ -953,7 +1111,7 @@ public: | |||||
while (bufferSize > 0) | while (bufferSize > 0) | ||||
{ | { | ||||
// This is needed in order not to drop any input data if the output device endpoint buffer was full | // This is needed in order not to drop any input data if the output device endpoint buffer was full | ||||
if ((! useExclusiveMode) && inputDevice != nullptr | |||||
if ((! isExclusiveMode (deviceMode)) && inputDevice != nullptr | |||||
&& WaitForSingleObject (inputDevice->clientEvent, 0) == WAIT_OBJECT_0) | && WaitForSingleObject (inputDevice->clientEvent, 0) == WAIT_OBJECT_0) | ||||
inputDevice->handleDeviceBuffer(); | inputDevice->handleDeviceBuffer(); | ||||
@@ -968,7 +1126,7 @@ public: | |||||
break; | break; | ||||
} | } | ||||
if (useExclusiveMode && WaitForSingleObject (clientEvent, 1000) == WAIT_TIMEOUT) | |||||
if (isExclusiveMode (deviceMode) && WaitForSingleObject (clientEvent, 1000) == WAIT_TIMEOUT) | |||||
break; | break; | ||||
uint8* outputData = nullptr; | uint8* outputData = nullptr; | ||||
@@ -1002,12 +1160,12 @@ public: | |||||
const String& typeName, | const String& typeName, | ||||
const String& outputDeviceID, | const String& outputDeviceID, | ||||
const String& inputDeviceID, | const String& inputDeviceID, | ||||
bool exclusiveMode) | |||||
WASAPIDeviceMode mode) | |||||
: AudioIODevice (deviceName, typeName), | : AudioIODevice (deviceName, typeName), | ||||
Thread ("JUCE WASAPI"), | Thread ("JUCE WASAPI"), | ||||
outputDeviceId (outputDeviceID), | outputDeviceId (outputDeviceID), | ||||
inputDeviceId (inputDeviceID), | inputDeviceId (inputDeviceID), | ||||
useExclusiveMode (exclusiveMode) | |||||
deviceMode (mode) | |||||
{ | { | ||||
} | } | ||||
@@ -1026,21 +1184,48 @@ public: | |||||
{ | { | ||||
jassert (inputDevice != nullptr || outputDevice != nullptr); | jassert (inputDevice != nullptr || outputDevice != nullptr); | ||||
sampleRates.clear(); | |||||
if (inputDevice != nullptr && outputDevice != nullptr) | if (inputDevice != nullptr && outputDevice != nullptr) | ||||
{ | { | ||||
defaultSampleRate = jmin (inputDevice->defaultSampleRate, outputDevice->defaultSampleRate); | defaultSampleRate = jmin (inputDevice->defaultSampleRate, outputDevice->defaultSampleRate); | ||||
minBufferSize = jmin (inputDevice->minBufferSize, outputDevice->minBufferSize); | |||||
minBufferSize = jmax (inputDevice->minBufferSize, outputDevice->minBufferSize); | |||||
defaultBufferSize = jmax (inputDevice->defaultBufferSize, outputDevice->defaultBufferSize); | defaultBufferSize = jmax (inputDevice->defaultBufferSize, outputDevice->defaultBufferSize); | ||||
sampleRates = inputDevice->rates; | |||||
sampleRates.removeValuesNotIn (outputDevice->rates); | |||||
if (isLowLatencyMode (deviceMode)) | |||||
{ | |||||
lowLatencyMaxBufferSize = jmin (inputDevice->lowLatencyMaxBufferSize, outputDevice->lowLatencyMaxBufferSize); | |||||
lowLatencyBufferSizeMultiple = jmax (inputDevice->lowLatencyBufferSizeMultiple, outputDevice->lowLatencyBufferSizeMultiple); | |||||
} | |||||
sampleRates.addArray (inputDevice->rates); | |||||
if (supportsSampleRateConversion (deviceMode)) | |||||
{ | |||||
for (auto r : outputDevice->rates) | |||||
if (! sampleRates.contains (r)) | |||||
sampleRates.addUsingDefaultSort (r); | |||||
} | |||||
else | |||||
{ | |||||
sampleRates.removeValuesNotIn (outputDevice->rates); | |||||
} | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
WASAPIDeviceBase* d = inputDevice != nullptr ? static_cast<WASAPIDeviceBase*> (inputDevice.get()) | |||||
: static_cast<WASAPIDeviceBase*> (outputDevice.get()); | |||||
auto* d = inputDevice != nullptr ? static_cast<WASAPIDeviceBase*> (inputDevice.get()) | |||||
: static_cast<WASAPIDeviceBase*> (outputDevice.get()); | |||||
defaultSampleRate = d->defaultSampleRate; | defaultSampleRate = d->defaultSampleRate; | ||||
minBufferSize = d->minBufferSize; | minBufferSize = d->minBufferSize; | ||||
defaultBufferSize = d->defaultBufferSize; | defaultBufferSize = d->defaultBufferSize; | ||||
if (isLowLatencyMode (deviceMode)) | |||||
{ | |||||
lowLatencyMaxBufferSize = d->lowLatencyMaxBufferSize; | |||||
lowLatencyBufferSizeMultiple = d->lowLatencyBufferSizeMultiple; | |||||
} | |||||
sampleRates = d->rates; | sampleRates = d->rates; | ||||
} | } | ||||
@@ -1050,13 +1235,28 @@ public: | |||||
if (minBufferSize != defaultBufferSize) | if (minBufferSize != defaultBufferSize) | ||||
bufferSizes.addUsingDefaultSort (minBufferSize); | bufferSizes.addUsingDefaultSort (minBufferSize); | ||||
int n = 64; | |||||
for (int i = 0; i < 40; ++i) | |||||
if (isLowLatencyMode (deviceMode)) | |||||
{ | { | ||||
if (n >= minBufferSize && n <= 2048 && ! bufferSizes.contains (n)) | |||||
bufferSizes.addUsingDefaultSort (n); | |||||
auto size = minBufferSize; | |||||
while (size < lowLatencyMaxBufferSize) | |||||
{ | |||||
size += lowLatencyBufferSizeMultiple; | |||||
n += (n < 512) ? 32 : (n < 1024 ? 64 : 128); | |||||
if (! bufferSizes.contains (size)) | |||||
bufferSizes.addUsingDefaultSort (size); | |||||
} | |||||
} | |||||
else | |||||
{ | |||||
int n = 64; | |||||
for (int i = 0; i < 40; ++i) | |||||
{ | |||||
if (n >= minBufferSize && n <= 2048 && ! bufferSizes.contains (n)) | |||||
bufferSizes.addUsingDefaultSort (n); | |||||
n += (n < 512) ? 32 : (n < 1024 ? 64 : 128); | |||||
} | |||||
} | } | ||||
return true; | return true; | ||||
@@ -1131,7 +1331,7 @@ public: | |||||
return lastError; | return lastError; | ||||
} | } | ||||
if (useExclusiveMode) | |||||
if (isExclusiveMode (deviceMode)) | |||||
{ | { | ||||
// This is to make sure that the callback uses actualBufferSize in case of exclusive mode | // This is to make sure that the callback uses actualBufferSize in case of exclusive mode | ||||
if (inputDevice != nullptr && outputDevice != nullptr && inputDevice->actualBufferSize != outputDevice->actualBufferSize) | if (inputDevice != nullptr && outputDevice != nullptr && inputDevice->actualBufferSize != outputDevice->actualBufferSize) | ||||
@@ -1297,7 +1497,7 @@ public: | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
if (useExclusiveMode && WaitForSingleObject (inputDevice->clientEvent, 0) == WAIT_OBJECT_0) | |||||
if (isExclusiveMode (deviceMode) && WaitForSingleObject (inputDevice->clientEvent, 0) == WAIT_OBJECT_0) | |||||
inputDevice->handleDeviceBuffer(); | inputDevice->handleDeviceBuffer(); | ||||
} | } | ||||
@@ -1347,9 +1547,10 @@ private: | |||||
// Device stats... | // Device stats... | ||||
std::unique_ptr<WASAPIInputDevice> inputDevice; | std::unique_ptr<WASAPIInputDevice> inputDevice; | ||||
std::unique_ptr<WASAPIOutputDevice> outputDevice; | std::unique_ptr<WASAPIOutputDevice> outputDevice; | ||||
const bool useExclusiveMode; | |||||
WASAPIDeviceMode deviceMode; | |||||
double defaultSampleRate = 0; | double defaultSampleRate = 0; | ||||
int minBufferSize = 0, defaultBufferSize = 0; | int minBufferSize = 0, defaultBufferSize = 0; | ||||
int lowLatencyMaxBufferSize = 0, lowLatencyBufferSizeMultiple = 0; | |||||
int latencyIn = 0, latencyOut = 0; | int latencyIn = 0, latencyOut = 0; | ||||
Array<double> sampleRates; | Array<double> sampleRates; | ||||
Array<int> bufferSizes; | Array<int> bufferSizes; | ||||
@@ -1399,9 +1600,9 @@ private: | |||||
auto flow = getDataFlow (device); | auto flow = getDataFlow (device); | ||||
if (deviceId == inputDeviceId && flow == eCapture) | if (deviceId == inputDeviceId && flow == eCapture) | ||||
inputDevice.reset (new WASAPIInputDevice (device, useExclusiveMode)); | |||||
inputDevice.reset (new WASAPIInputDevice (device, deviceMode)); | |||||
else if (deviceId == outputDeviceId && flow == eRender) | else if (deviceId == outputDeviceId && flow == eRender) | ||||
outputDevice.reset (new WASAPIOutputDevice (device, useExclusiveMode)); | |||||
outputDevice.reset (new WASAPIOutputDevice (device, deviceMode)); | |||||
} | } | ||||
return (outputDeviceId.isEmpty() || (outputDevice != nullptr && outputDevice->isOk())) | return (outputDeviceId.isEmpty() || (outputDevice != nullptr && outputDevice->isOk())) | ||||
@@ -1458,10 +1659,10 @@ class WASAPIAudioIODeviceType : public AudioIODeviceType, | |||||
private DeviceChangeDetector | private DeviceChangeDetector | ||||
{ | { | ||||
public: | public: | ||||
WASAPIAudioIODeviceType (bool exclusive) | |||||
: AudioIODeviceType (exclusive ? "Windows Audio (Exclusive Mode)" : "Windows Audio"), | |||||
WASAPIAudioIODeviceType (WASAPIDeviceMode mode) | |||||
: AudioIODeviceType (getDeviceTypename (mode)), | |||||
DeviceChangeDetector (L"Windows Audio"), | DeviceChangeDetector (L"Windows Audio"), | ||||
exclusiveMode (exclusive) | |||||
deviceMode (mode) | |||||
{ | { | ||||
} | } | ||||
@@ -1529,7 +1730,7 @@ public: | |||||
getTypeName(), | getTypeName(), | ||||
outputDeviceIds [outputIndex], | outputDeviceIds [outputIndex], | ||||
inputDeviceIds [inputIndex], | inputDeviceIds [inputIndex], | ||||
exclusiveMode)); | |||||
deviceMode)); | |||||
if (! device->initialise()) | if (! device->initialise()) | ||||
device = nullptr; | device = nullptr; | ||||
@@ -1543,7 +1744,7 @@ public: | |||||
StringArray inputDeviceNames, inputDeviceIds; | StringArray inputDeviceNames, inputDeviceIds; | ||||
private: | private: | ||||
const bool exclusiveMode; | |||||
WASAPIDeviceMode deviceMode; | |||||
bool hasScanned = false; | bool hasScanned = false; | ||||
ComSmartPtr<IMMDeviceEnumerator> enumerator; | ComSmartPtr<IMMDeviceEnumerator> enumerator; | ||||
@@ -1698,6 +1899,17 @@ private: | |||||
callDeviceChangeListeners(); | callDeviceChangeListeners(); | ||||
} | } | ||||
//============================================================================== | |||||
static String getDeviceTypename (WASAPIDeviceMode mode) | |||||
{ | |||||
if (mode == WASAPIDeviceMode::shared) return "Windows Audio"; | |||||
if (mode == WASAPIDeviceMode::sharedLowLatency) return "Windows Audio (Low Latency Mode)"; | |||||
if (mode == WASAPIDeviceMode::exclusive) return "Windows Audio (Exclusive Mode)"; | |||||
jassertfalse; | |||||
return {}; | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
JUCE_DECLARE_WEAK_REFERENCEABLE (WASAPIAudioIODeviceType) | JUCE_DECLARE_WEAK_REFERENCEABLE (WASAPIAudioIODeviceType) | ||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WASAPIAudioIODeviceType) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WASAPIAudioIODeviceType) | ||||
@@ -1756,19 +1968,6 @@ struct MMDeviceMasterVolume | |||||
} | } | ||||
//============================================================================== | |||||
AudioIODeviceType* AudioIODeviceType::createAudioIODeviceType_WASAPI (bool exclusiveMode) | |||||
{ | |||||
#if ! JUCE_WASAPI_EXCLUSIVE | |||||
if (exclusiveMode) | |||||
return nullptr; | |||||
#endif | |||||
return SystemStats::getOperatingSystemType() >= SystemStats::WinVista | |||||
? new WasapiClasses::WASAPIAudioIODeviceType (exclusiveMode) | |||||
: nullptr; | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
#define JUCE_SYSTEMAUDIOVOL_IMPLEMENTED 1 | #define JUCE_SYSTEMAUDIOVOL_IMPLEMENTED 1 | ||||
float JUCE_CALLTYPE SystemAudioVolume::getGain() { return WasapiClasses::MMDeviceMasterVolume().getGain(); } | float JUCE_CALLTYPE SystemAudioVolume::getGain() { return WasapiClasses::MMDeviceMasterVolume().getGain(); } | ||||
@@ -47,7 +47,9 @@ namespace OggVorbisNamespace | |||||
"-Wsign-conversion", | "-Wsign-conversion", | ||||
"-Wswitch-default", | "-Wswitch-default", | ||||
"-Wredundant-decls", | "-Wredundant-decls", | ||||
"-Wmisleading-indentation") | |||||
"-Wmisleading-indentation", | |||||
"-Wmissing-prototypes", | |||||
"-Wcast-align") | |||||
#include "oggvorbis/vorbisenc.h" | #include "oggvorbis/vorbisenc.h" | ||||
#include "oggvorbis/codec.h" | #include "oggvorbis/codec.h" | ||||
@@ -55,27 +57,27 @@ namespace OggVorbisNamespace | |||||
#include "oggvorbis/bitwise.c" | #include "oggvorbis/bitwise.c" | ||||
#include "oggvorbis/framing.c" | #include "oggvorbis/framing.c" | ||||
#include "oggvorbis/libvorbis-1.3.2/lib/analysis.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/bitrate.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/block.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/codebook.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/envelope.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/floor0.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/floor1.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/info.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/lpc.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/lsp.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/mapping0.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/mdct.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/psy.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/registry.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/res0.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/sharedbook.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/smallft.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/synthesis.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/vorbisenc.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/vorbisfile.c" | |||||
#include "oggvorbis/libvorbis-1.3.2/lib/window.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/analysis.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/bitrate.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/block.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/codebook.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/envelope.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/floor0.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/floor1.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/info.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/lpc.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/lsp.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/mapping0.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/mdct.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/psy.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/registry.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/res0.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/sharedbook.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/smallft.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/synthesis.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/vorbisenc.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/vorbisfile.c" | |||||
#include "oggvorbis/libvorbis-1.3.7/lib/window.c" | |||||
JUCE_END_IGNORE_WARNINGS_MSVC | JUCE_END_IGNORE_WARNINGS_MSVC | ||||
JUCE_END_IGNORE_WARNINGS_GCC_LIKE | JUCE_END_IGNORE_WARNINGS_GCC_LIKE | ||||
@@ -265,32 +265,23 @@ private: | |||||
void scanFileForDetails() | void scanFileForDetails() | ||||
{ | { | ||||
ComSmartPtr<IWMHeaderInfo> wmHeaderInfo; | |||||
HRESULT hr = wmSyncReader.QueryInterface (wmHeaderInfo); | |||||
if (SUCCEEDED (hr)) | |||||
if (auto wmHeaderInfo = wmSyncReader.getInterface<IWMHeaderInfo>()) | |||||
{ | { | ||||
QWORD lengthInNanoseconds = 0; | QWORD lengthInNanoseconds = 0; | ||||
WORD lengthOfLength = sizeof (lengthInNanoseconds); | WORD lengthOfLength = sizeof (lengthInNanoseconds); | ||||
WORD streamNum = 0; | WORD streamNum = 0; | ||||
WMT_ATTR_DATATYPE wmAttrDataType; | WMT_ATTR_DATATYPE wmAttrDataType; | ||||
hr = wmHeaderInfo->GetAttributeByName (&streamNum, L"Duration", &wmAttrDataType, | |||||
(BYTE*) &lengthInNanoseconds, &lengthOfLength); | |||||
ComSmartPtr<IWMProfile> wmProfile; | |||||
hr = wmSyncReader.QueryInterface (wmProfile); | |||||
wmHeaderInfo->GetAttributeByName (&streamNum, L"Duration", &wmAttrDataType, | |||||
(BYTE*) &lengthInNanoseconds, &lengthOfLength); | |||||
if (SUCCEEDED (hr)) | |||||
if (auto wmProfile = wmSyncReader.getInterface<IWMProfile>()) | |||||
{ | { | ||||
ComSmartPtr<IWMStreamConfig> wmStreamConfig; | ComSmartPtr<IWMStreamConfig> wmStreamConfig; | ||||
hr = wmProfile->GetStream (0, wmStreamConfig.resetAndGetPointerAddress()); | |||||
auto hr = wmProfile->GetStream (0, wmStreamConfig.resetAndGetPointerAddress()); | |||||
if (SUCCEEDED (hr)) | if (SUCCEEDED (hr)) | ||||
{ | { | ||||
ComSmartPtr<IWMMediaProps> wmMediaProperties; | |||||
hr = wmStreamConfig.QueryInterface (wmMediaProperties); | |||||
if (SUCCEEDED (hr)) | |||||
if (auto wmMediaProperties = wmStreamConfig.getInterface<IWMMediaProps>()) | |||||
{ | { | ||||
DWORD sizeMediaType; | DWORD sizeMediaType; | ||||
hr = wmMediaProperties->GetMediaType (0, &sizeMediaType); | hr = wmMediaProperties->GetMediaType (0, &sizeMediaType); | ||||
@@ -1,23 +1,25 @@ | |||||
===================================================================== | ===================================================================== | ||||
I've incorporated Ogg-Vorbis directly into the JUCE codebase because it makes | |||||
Ogg-Vorbis is incorporated directly into the JUCE codebase because it makes | |||||
things much easier than having to make all your builds link correctly to | things much easier than having to make all your builds link correctly to | ||||
the appropriate libraries on every different platform. | the appropriate libraries on every different platform. | ||||
I've made minimal changes to the Ogg-Vorbis code - just tweaked a few include | |||||
paths to make it build smoothly, and added some headers to allow you to exclude | |||||
it from the build. | |||||
There are minimal changes to the Ogg-Vorbis code - a few include paths have | |||||
been changed to make it build smoothly, and some headers have been added to | |||||
allow you to exclude it from the build. Any significant code modifications | |||||
are marked clearly by "JUCE CHANGE STARTS HERE" and "JUCE_CHANGE_ENDS_HERE" | |||||
comments. | |||||
===================================================================== | ===================================================================== | ||||
The following license is the BSD-style license that comes with the | |||||
Ogg-Vorbis distribution, and which applies just to the header files I've | |||||
included in this directory. For more info, and to get the rest of the | |||||
distribution, visit the Ogg-Vorbis homepage: www.vorbis.com | |||||
The following license is the BSD-style license that comes with the Ogg-Vorbis | |||||
distribution, and which applies just to the header files included in this | |||||
directory. For more info, and to get the rest of the distribution, visit the | |||||
Ogg-Vorbis homepage: https://xiph.org/vorbis | |||||
===================================================================== | ===================================================================== | ||||
Copyright (c) 2002-2004 Xiph.org Foundation | |||||
Copyright (c) 2002-2020 Xiph.org Foundation | |||||
Redistribution and use in source and binary forms, with or without | Redistribution and use in source and binary forms, with or without | ||||
modification, are permitted provided that the following conditions | modification, are permitted provided that the following conditions | ||||
@@ -1,242 +1,241 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
******************************************************************** | |||||
function: libvorbis codec headers | |||||
last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _vorbis_codec_h_ | |||||
#define _vorbis_codec_h_ | |||||
#ifdef __cplusplus | |||||
extern "C" | |||||
{ | |||||
#endif /* __cplusplus */ | |||||
#include "ogg.h" | |||||
typedef struct vorbis_info{ | |||||
int version; | |||||
int channels; | |||||
long rate; | |||||
/* The below bitrate declarations are *hints*. | |||||
Combinations of the three values carry the following implications: | |||||
all three set to the same value: | |||||
implies a fixed rate bitstream | |||||
only nominal set: | |||||
implies a VBR stream that averages the nominal bitrate. No hard | |||||
upper/lower limit | |||||
upper and or lower set: | |||||
implies a VBR bitstream that obeys the bitrate limits. nominal | |||||
may also be set to give a nominal rate. | |||||
none set: | |||||
the coder does not care to speculate. | |||||
*/ | |||||
long bitrate_upper; | |||||
long bitrate_nominal; | |||||
long bitrate_lower; | |||||
long bitrate_window; | |||||
void *codec_setup; | |||||
} vorbis_info; | |||||
/* vorbis_dsp_state buffers the current vorbis audio | |||||
analysis/synthesis state. The DSP state belongs to a specific | |||||
logical bitstream ****************************************************/ | |||||
typedef struct vorbis_dsp_state{ | |||||
int analysisp; | |||||
vorbis_info *vi; | |||||
float **pcm; | |||||
float **pcmret; | |||||
int pcm_storage; | |||||
int pcm_current; | |||||
int pcm_returned; | |||||
int preextrapolate; | |||||
int eofflag; | |||||
long lW; | |||||
long W; | |||||
long nW; | |||||
long centerW; | |||||
ogg_int64_t granulepos; | |||||
ogg_int64_t sequence; | |||||
ogg_int64_t glue_bits; | |||||
ogg_int64_t time_bits; | |||||
ogg_int64_t floor_bits; | |||||
ogg_int64_t res_bits; | |||||
void *backend_state; | |||||
} vorbis_dsp_state; | |||||
typedef struct vorbis_block{ | |||||
/* necessary stream state for linking to the framing abstraction */ | |||||
float **pcm; /* this is a pointer into local storage */ | |||||
oggpack_buffer opb; | |||||
long lW; | |||||
long W; | |||||
long nW; | |||||
int pcmend; | |||||
int mode; | |||||
int eofflag; | |||||
ogg_int64_t granulepos; | |||||
ogg_int64_t sequence; | |||||
vorbis_dsp_state *vd; /* For read-only access of configuration */ | |||||
/* local storage to avoid remallocing; it's up to the mapping to | |||||
structure it */ | |||||
void *localstore; | |||||
long localtop; | |||||
long localalloc; | |||||
long totaluse; | |||||
struct alloc_chain *reap; | |||||
/* bitmetrics for the frame */ | |||||
long glue_bits; | |||||
long time_bits; | |||||
long floor_bits; | |||||
long res_bits; | |||||
void *internal; | |||||
} vorbis_block; | |||||
/* vorbis_block is a single block of data to be processed as part of | |||||
the analysis/synthesis stream; it belongs to a specific logical | |||||
bitstream, but is independent from other vorbis_blocks belonging to | |||||
that logical bitstream. *************************************************/ | |||||
struct alloc_chain{ | |||||
void *ptr; | |||||
struct alloc_chain *next; | |||||
}; | |||||
/* vorbis_info contains all the setup information specific to the | |||||
specific compression/decompression mode in progress (eg, | |||||
psychoacoustic settings, channel setup, options, codebook | |||||
etc). vorbis_info and substructures are in backends.h. | |||||
*********************************************************************/ | |||||
/* the comments are not part of vorbis_info so that vorbis_info can be | |||||
static storage */ | |||||
typedef struct vorbis_comment{ | |||||
/* unlimited user comment fields. libvorbis writes 'libvorbis' | |||||
whatever vendor is set to in encode */ | |||||
char **user_comments; | |||||
int *comment_lengths; | |||||
int comments; | |||||
char *vendor; | |||||
} vorbis_comment; | |||||
/* libvorbis encodes in two abstraction layers; first we perform DSP | |||||
and produce a packet (see docs/analysis.txt). The packet is then | |||||
coded into a framed OggSquish bitstream by the second layer (see | |||||
docs/framing.txt). Decode is the reverse process; we sync/frame | |||||
the bitstream and extract individual packets, then decode the | |||||
packet back into PCM audio. | |||||
The extra framing/packetizing is used in streaming formats, such as | |||||
files. Over the net (such as with UDP), the framing and | |||||
packetization aren't necessary as they're provided by the transport | |||||
and the streaming layer is not used */ | |||||
/* Vorbis PRIMITIVES: general ***************************************/ | |||||
extern void vorbis_info_init(vorbis_info *vi); | |||||
extern void vorbis_info_clear(vorbis_info *vi); | |||||
extern int vorbis_info_blocksize(vorbis_info *vi,int zo); | |||||
extern void vorbis_comment_init(vorbis_comment *vc); | |||||
extern void vorbis_comment_add(vorbis_comment *vc, const char *comment); | |||||
extern void vorbis_comment_add_tag(vorbis_comment *vc, | |||||
const char *tag, const char *contents); | |||||
extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count); | |||||
extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag); | |||||
extern void vorbis_comment_clear(vorbis_comment *vc); | |||||
extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); | |||||
extern int vorbis_block_clear(vorbis_block *vb); | |||||
extern void vorbis_dsp_clear(vorbis_dsp_state *v); | |||||
extern double vorbis_granule_time(vorbis_dsp_state *v, | |||||
ogg_int64_t granulepos); | |||||
extern const char *vorbis_version_string(void); | |||||
/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ | |||||
extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); | |||||
extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op); | |||||
extern int vorbis_analysis_headerout(vorbis_dsp_state *v, | |||||
vorbis_comment *vc, | |||||
ogg_packet *op, | |||||
ogg_packet *op_comm, | |||||
ogg_packet *op_code); | |||||
extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); | |||||
extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); | |||||
extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); | |||||
extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op); | |||||
extern int vorbis_bitrate_addblock(vorbis_block *vb); | |||||
extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, | |||||
ogg_packet *op); | |||||
/* Vorbis PRIMITIVES: synthesis layer *******************************/ | |||||
extern int vorbis_synthesis_idheader(ogg_packet *op); | |||||
extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, | |||||
ogg_packet *op); | |||||
extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); | |||||
extern int vorbis_synthesis_restart(vorbis_dsp_state *v); | |||||
extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); | |||||
extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); | |||||
extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); | |||||
extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm); | |||||
extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm); | |||||
extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); | |||||
extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); | |||||
extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag); | |||||
extern int vorbis_synthesis_halfrate_p(vorbis_info *v); | |||||
/* Vorbis ERRORS and return codes ***********************************/ | |||||
#define OV_FALSE -1 | |||||
#define OV_EOF -2 | |||||
#define OV_HOLE -3 | |||||
#define OV_EREAD -128 | |||||
#define OV_EFAULT -129 | |||||
#define OV_EIMPL -130 | |||||
#define OV_EINVAL -131 | |||||
#define OV_ENOTVORBIS -132 | |||||
#define OV_EBADHEADER -133 | |||||
#define OV_EVERSION -134 | |||||
#define OV_ENOTAUDIO -135 | |||||
#define OV_EBADPACKET -136 | |||||
#define OV_EBADLINK -137 | |||||
#define OV_ENOSEEK -138 | |||||
#ifdef __cplusplus | |||||
} | |||||
#endif /* __cplusplus */ | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
******************************************************************** | |||||
function: libvorbis codec headers | |||||
********************************************************************/ | |||||
#ifndef _vorbis_codec_h_ | |||||
#define _vorbis_codec_h_ | |||||
#ifdef __cplusplus | |||||
extern "C" | |||||
{ | |||||
#endif /* __cplusplus */ | |||||
#include "ogg.h" | |||||
typedef struct vorbis_info{ | |||||
int version; | |||||
int channels; | |||||
long rate; | |||||
/* The below bitrate declarations are *hints*. | |||||
Combinations of the three values carry the following implications: | |||||
all three set to the same value: | |||||
implies a fixed rate bitstream | |||||
only nominal set: | |||||
implies a VBR stream that averages the nominal bitrate. No hard | |||||
upper/lower limit | |||||
upper and or lower set: | |||||
implies a VBR bitstream that obeys the bitrate limits. nominal | |||||
may also be set to give a nominal rate. | |||||
none set: | |||||
the coder does not care to speculate. | |||||
*/ | |||||
long bitrate_upper; | |||||
long bitrate_nominal; | |||||
long bitrate_lower; | |||||
long bitrate_window; | |||||
void *codec_setup; | |||||
} vorbis_info; | |||||
/* vorbis_dsp_state buffers the current vorbis audio | |||||
analysis/synthesis state. The DSP state belongs to a specific | |||||
logical bitstream ****************************************************/ | |||||
typedef struct vorbis_dsp_state{ | |||||
int analysisp; | |||||
vorbis_info *vi; | |||||
float **pcm; | |||||
float **pcmret; | |||||
int pcm_storage; | |||||
int pcm_current; | |||||
int pcm_returned; | |||||
int preextrapolate; | |||||
int eofflag; | |||||
long lW; | |||||
long W; | |||||
long nW; | |||||
long centerW; | |||||
ogg_int64_t granulepos; | |||||
ogg_int64_t sequence; | |||||
ogg_int64_t glue_bits; | |||||
ogg_int64_t time_bits; | |||||
ogg_int64_t floor_bits; | |||||
ogg_int64_t res_bits; | |||||
void *backend_state; | |||||
} vorbis_dsp_state; | |||||
typedef struct vorbis_block{ | |||||
/* necessary stream state for linking to the framing abstraction */ | |||||
float **pcm; /* this is a pointer into local storage */ | |||||
oggpack_buffer opb; | |||||
long lW; | |||||
long W; | |||||
long nW; | |||||
int pcmend; | |||||
int mode; | |||||
int eofflag; | |||||
ogg_int64_t granulepos; | |||||
ogg_int64_t sequence; | |||||
vorbis_dsp_state *vd; /* For read-only access of configuration */ | |||||
/* local storage to avoid remallocing; it's up to the mapping to | |||||
structure it */ | |||||
void *localstore; | |||||
long localtop; | |||||
long localalloc; | |||||
long totaluse; | |||||
struct alloc_chain *reap; | |||||
/* bitmetrics for the frame */ | |||||
long glue_bits; | |||||
long time_bits; | |||||
long floor_bits; | |||||
long res_bits; | |||||
void *internal; | |||||
} vorbis_block; | |||||
/* vorbis_block is a single block of data to be processed as part of | |||||
the analysis/synthesis stream; it belongs to a specific logical | |||||
bitstream, but is independent from other vorbis_blocks belonging to | |||||
that logical bitstream. *************************************************/ | |||||
struct alloc_chain{ | |||||
void *ptr; | |||||
struct alloc_chain *next; | |||||
}; | |||||
/* vorbis_info contains all the setup information specific to the | |||||
specific compression/decompression mode in progress (eg, | |||||
psychoacoustic settings, channel setup, options, codebook | |||||
etc). vorbis_info and substructures are in backends.h. | |||||
*********************************************************************/ | |||||
/* the comments are not part of vorbis_info so that vorbis_info can be | |||||
static storage */ | |||||
typedef struct vorbis_comment{ | |||||
/* unlimited user comment fields. libvorbis writes 'libvorbis' | |||||
whatever vendor is set to in encode */ | |||||
char **user_comments; | |||||
int *comment_lengths; | |||||
int comments; | |||||
char *vendor; | |||||
} vorbis_comment; | |||||
/* libvorbis encodes in two abstraction layers; first we perform DSP | |||||
and produce a packet (see docs/analysis.txt). The packet is then | |||||
coded into a framed OggSquish bitstream by the second layer (see | |||||
docs/framing.txt). Decode is the reverse process; we sync/frame | |||||
the bitstream and extract individual packets, then decode the | |||||
packet back into PCM audio. | |||||
The extra framing/packetizing is used in streaming formats, such as | |||||
files. Over the net (such as with UDP), the framing and | |||||
packetization aren't necessary as they're provided by the transport | |||||
and the streaming layer is not used */ | |||||
/* Vorbis PRIMITIVES: general ***************************************/ | |||||
extern void vorbis_info_init(vorbis_info *vi); | |||||
extern void vorbis_info_clear(vorbis_info *vi); | |||||
extern int vorbis_info_blocksize(vorbis_info *vi,int zo); | |||||
extern void vorbis_comment_init(vorbis_comment *vc); | |||||
extern void vorbis_comment_add(vorbis_comment *vc, const char *comment); | |||||
extern void vorbis_comment_add_tag(vorbis_comment *vc, | |||||
const char *tag, const char *contents); | |||||
extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count); | |||||
extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag); | |||||
extern void vorbis_comment_clear(vorbis_comment *vc); | |||||
extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); | |||||
extern int vorbis_block_clear(vorbis_block *vb); | |||||
extern void vorbis_dsp_clear(vorbis_dsp_state *v); | |||||
extern double vorbis_granule_time(vorbis_dsp_state *v, | |||||
ogg_int64_t granulepos); | |||||
extern const char *vorbis_version_string(void); | |||||
/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ | |||||
extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); | |||||
extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op); | |||||
extern int vorbis_analysis_headerout(vorbis_dsp_state *v, | |||||
vorbis_comment *vc, | |||||
ogg_packet *op, | |||||
ogg_packet *op_comm, | |||||
ogg_packet *op_code); | |||||
extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); | |||||
extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); | |||||
extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); | |||||
extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op); | |||||
extern int vorbis_bitrate_addblock(vorbis_block *vb); | |||||
extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, | |||||
ogg_packet *op); | |||||
/* Vorbis PRIMITIVES: synthesis layer *******************************/ | |||||
extern int vorbis_synthesis_idheader(ogg_packet *op); | |||||
extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, | |||||
ogg_packet *op); | |||||
extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); | |||||
extern int vorbis_synthesis_restart(vorbis_dsp_state *v); | |||||
extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); | |||||
extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); | |||||
extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); | |||||
extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm); | |||||
extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm); | |||||
extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); | |||||
extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); | |||||
extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag); | |||||
extern int vorbis_synthesis_halfrate_p(vorbis_info *v); | |||||
/* Vorbis ERRORS and return codes ***********************************/ | |||||
#define OV_FALSE -1 | |||||
#define OV_EOF -2 | |||||
#define OV_HOLE -3 | |||||
#define OV_EREAD -128 | |||||
#define OV_EFAULT -129 | |||||
#define OV_EIMPL -130 | |||||
#define OV_EINVAL -131 | |||||
#define OV_ENOTVORBIS -132 | |||||
#define OV_EBADHEADER -133 | |||||
#define OV_EVERSION -134 | |||||
#define OV_ENOTAUDIO -135 | |||||
#define OV_EBADPACKET -136 | |||||
#define OV_EBADLINK -137 | |||||
#define OV_ENOSEEK -138 | |||||
#ifdef __cplusplus | |||||
} | |||||
#endif /* __cplusplus */ | |||||
#endif |
@@ -7,4 +7,8 @@ typedef int32_t ogg_int32_t; | |||||
typedef unsigned int ogg_uint32_t; | typedef unsigned int ogg_uint32_t; | ||||
typedef int64_t ogg_int64_t; | typedef int64_t ogg_int64_t; | ||||
// JUCE CHANGE STARTS HERE | |||||
typedef unsigned long long ogg_uint64_t; | |||||
// JUCE CHANGE ENDS HERE | |||||
#endif | #endif |
@@ -0,0 +1,278 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE Ogg CONTAINER SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2018 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
********************************************************************/ | |||||
#include "os_types.h" | |||||
static const ogg_uint32_t crc_lookup[8][256]={ | |||||
{0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, | |||||
0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd, | |||||
0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75, | |||||
0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd, | |||||
0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5, | |||||
0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d, | |||||
0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95, | |||||
0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d, | |||||
0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072, | |||||
0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca, | |||||
0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02, | |||||
0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba, | |||||
0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692, | |||||
0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a, | |||||
0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2, | |||||
0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a, | |||||
0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb, | |||||
0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53, | |||||
0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b, | |||||
0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623, | |||||
0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b, | |||||
0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3, | |||||
0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b, | |||||
0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3, | |||||
0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c, | |||||
0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,0x68860bfd,0x6c47164a,0x61043093,0x65c52d24, | |||||
0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec, | |||||
0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654, | |||||
0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c, | |||||
0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4, | |||||
0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c, | |||||
0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4}, | |||||
{0x00000000,0xd219c1dc,0xa0f29e0f,0x72eb5fd3,0x452421a9,0x973de075,0xe5d6bfa6,0x37cf7e7a, | |||||
0x8a484352,0x5851828e,0x2abadd5d,0xf8a31c81,0xcf6c62fb,0x1d75a327,0x6f9efcf4,0xbd873d28, | |||||
0x10519b13,0xc2485acf,0xb0a3051c,0x62bac4c0,0x5575baba,0x876c7b66,0xf58724b5,0x279ee569, | |||||
0x9a19d841,0x4800199d,0x3aeb464e,0xe8f28792,0xdf3df9e8,0x0d243834,0x7fcf67e7,0xadd6a63b, | |||||
0x20a33626,0xf2baf7fa,0x8051a829,0x524869f5,0x6587178f,0xb79ed653,0xc5758980,0x176c485c, | |||||
0xaaeb7574,0x78f2b4a8,0x0a19eb7b,0xd8002aa7,0xefcf54dd,0x3dd69501,0x4f3dcad2,0x9d240b0e, | |||||
0x30f2ad35,0xe2eb6ce9,0x9000333a,0x4219f2e6,0x75d68c9c,0xa7cf4d40,0xd5241293,0x073dd34f, | |||||
0xbabaee67,0x68a32fbb,0x1a487068,0xc851b1b4,0xff9ecfce,0x2d870e12,0x5f6c51c1,0x8d75901d, | |||||
0x41466c4c,0x935fad90,0xe1b4f243,0x33ad339f,0x04624de5,0xd67b8c39,0xa490d3ea,0x76891236, | |||||
0xcb0e2f1e,0x1917eec2,0x6bfcb111,0xb9e570cd,0x8e2a0eb7,0x5c33cf6b,0x2ed890b8,0xfcc15164, | |||||
0x5117f75f,0x830e3683,0xf1e56950,0x23fca88c,0x1433d6f6,0xc62a172a,0xb4c148f9,0x66d88925, | |||||
0xdb5fb40d,0x094675d1,0x7bad2a02,0xa9b4ebde,0x9e7b95a4,0x4c625478,0x3e890bab,0xec90ca77, | |||||
0x61e55a6a,0xb3fc9bb6,0xc117c465,0x130e05b9,0x24c17bc3,0xf6d8ba1f,0x8433e5cc,0x562a2410, | |||||
0xebad1938,0x39b4d8e4,0x4b5f8737,0x994646eb,0xae893891,0x7c90f94d,0x0e7ba69e,0xdc626742, | |||||
0x71b4c179,0xa3ad00a5,0xd1465f76,0x035f9eaa,0x3490e0d0,0xe689210c,0x94627edf,0x467bbf03, | |||||
0xfbfc822b,0x29e543f7,0x5b0e1c24,0x8917ddf8,0xbed8a382,0x6cc1625e,0x1e2a3d8d,0xcc33fc51, | |||||
0x828cd898,0x50951944,0x227e4697,0xf067874b,0xc7a8f931,0x15b138ed,0x675a673e,0xb543a6e2, | |||||
0x08c49bca,0xdadd5a16,0xa83605c5,0x7a2fc419,0x4de0ba63,0x9ff97bbf,0xed12246c,0x3f0be5b0, | |||||
0x92dd438b,0x40c48257,0x322fdd84,0xe0361c58,0xd7f96222,0x05e0a3fe,0x770bfc2d,0xa5123df1, | |||||
0x189500d9,0xca8cc105,0xb8679ed6,0x6a7e5f0a,0x5db12170,0x8fa8e0ac,0xfd43bf7f,0x2f5a7ea3, | |||||
0xa22feebe,0x70362f62,0x02dd70b1,0xd0c4b16d,0xe70bcf17,0x35120ecb,0x47f95118,0x95e090c4, | |||||
0x2867adec,0xfa7e6c30,0x889533e3,0x5a8cf23f,0x6d438c45,0xbf5a4d99,0xcdb1124a,0x1fa8d396, | |||||
0xb27e75ad,0x6067b471,0x128ceba2,0xc0952a7e,0xf75a5404,0x254395d8,0x57a8ca0b,0x85b10bd7, | |||||
0x383636ff,0xea2ff723,0x98c4a8f0,0x4add692c,0x7d121756,0xaf0bd68a,0xdde08959,0x0ff94885, | |||||
0xc3cab4d4,0x11d37508,0x63382adb,0xb121eb07,0x86ee957d,0x54f754a1,0x261c0b72,0xf405caae, | |||||
0x4982f786,0x9b9b365a,0xe9706989,0x3b69a855,0x0ca6d62f,0xdebf17f3,0xac544820,0x7e4d89fc, | |||||
0xd39b2fc7,0x0182ee1b,0x7369b1c8,0xa1707014,0x96bf0e6e,0x44a6cfb2,0x364d9061,0xe45451bd, | |||||
0x59d36c95,0x8bcaad49,0xf921f29a,0x2b383346,0x1cf74d3c,0xceee8ce0,0xbc05d333,0x6e1c12ef, | |||||
0xe36982f2,0x3170432e,0x439b1cfd,0x9182dd21,0xa64da35b,0x74546287,0x06bf3d54,0xd4a6fc88, | |||||
0x6921c1a0,0xbb38007c,0xc9d35faf,0x1bca9e73,0x2c05e009,0xfe1c21d5,0x8cf77e06,0x5eeebfda, | |||||
0xf33819e1,0x2121d83d,0x53ca87ee,0x81d34632,0xb61c3848,0x6405f994,0x16eea647,0xc4f7679b, | |||||
0x79705ab3,0xab699b6f,0xd982c4bc,0x0b9b0560,0x3c547b1a,0xee4dbac6,0x9ca6e515,0x4ebf24c9}, | |||||
{0x00000000,0x01d8ac87,0x03b1590e,0x0269f589,0x0762b21c,0x06ba1e9b,0x04d3eb12,0x050b4795, | |||||
0x0ec56438,0x0f1dc8bf,0x0d743d36,0x0cac91b1,0x09a7d624,0x087f7aa3,0x0a168f2a,0x0bce23ad, | |||||
0x1d8ac870,0x1c5264f7,0x1e3b917e,0x1fe33df9,0x1ae87a6c,0x1b30d6eb,0x19592362,0x18818fe5, | |||||
0x134fac48,0x129700cf,0x10fef546,0x112659c1,0x142d1e54,0x15f5b2d3,0x179c475a,0x1644ebdd, | |||||
0x3b1590e0,0x3acd3c67,0x38a4c9ee,0x397c6569,0x3c7722fc,0x3daf8e7b,0x3fc67bf2,0x3e1ed775, | |||||
0x35d0f4d8,0x3408585f,0x3661add6,0x37b90151,0x32b246c4,0x336aea43,0x31031fca,0x30dbb34d, | |||||
0x269f5890,0x2747f417,0x252e019e,0x24f6ad19,0x21fdea8c,0x2025460b,0x224cb382,0x23941f05, | |||||
0x285a3ca8,0x2982902f,0x2beb65a6,0x2a33c921,0x2f388eb4,0x2ee02233,0x2c89d7ba,0x2d517b3d, | |||||
0x762b21c0,0x77f38d47,0x759a78ce,0x7442d449,0x714993dc,0x70913f5b,0x72f8cad2,0x73206655, | |||||
0x78ee45f8,0x7936e97f,0x7b5f1cf6,0x7a87b071,0x7f8cf7e4,0x7e545b63,0x7c3daeea,0x7de5026d, | |||||
0x6ba1e9b0,0x6a794537,0x6810b0be,0x69c81c39,0x6cc35bac,0x6d1bf72b,0x6f7202a2,0x6eaaae25, | |||||
0x65648d88,0x64bc210f,0x66d5d486,0x670d7801,0x62063f94,0x63de9313,0x61b7669a,0x606fca1d, | |||||
0x4d3eb120,0x4ce61da7,0x4e8fe82e,0x4f5744a9,0x4a5c033c,0x4b84afbb,0x49ed5a32,0x4835f6b5, | |||||
0x43fbd518,0x4223799f,0x404a8c16,0x41922091,0x44996704,0x4541cb83,0x47283e0a,0x46f0928d, | |||||
0x50b47950,0x516cd5d7,0x5305205e,0x52dd8cd9,0x57d6cb4c,0x560e67cb,0x54679242,0x55bf3ec5, | |||||
0x5e711d68,0x5fa9b1ef,0x5dc04466,0x5c18e8e1,0x5913af74,0x58cb03f3,0x5aa2f67a,0x5b7a5afd, | |||||
0xec564380,0xed8eef07,0xefe71a8e,0xee3fb609,0xeb34f19c,0xeaec5d1b,0xe885a892,0xe95d0415, | |||||
0xe29327b8,0xe34b8b3f,0xe1227eb6,0xe0fad231,0xe5f195a4,0xe4293923,0xe640ccaa,0xe798602d, | |||||
0xf1dc8bf0,0xf0042777,0xf26dd2fe,0xf3b57e79,0xf6be39ec,0xf766956b,0xf50f60e2,0xf4d7cc65, | |||||
0xff19efc8,0xfec1434f,0xfca8b6c6,0xfd701a41,0xf87b5dd4,0xf9a3f153,0xfbca04da,0xfa12a85d, | |||||
0xd743d360,0xd69b7fe7,0xd4f28a6e,0xd52a26e9,0xd021617c,0xd1f9cdfb,0xd3903872,0xd24894f5, | |||||
0xd986b758,0xd85e1bdf,0xda37ee56,0xdbef42d1,0xdee40544,0xdf3ca9c3,0xdd555c4a,0xdc8df0cd, | |||||
0xcac91b10,0xcb11b797,0xc978421e,0xc8a0ee99,0xcdaba90c,0xcc73058b,0xce1af002,0xcfc25c85, | |||||
0xc40c7f28,0xc5d4d3af,0xc7bd2626,0xc6658aa1,0xc36ecd34,0xc2b661b3,0xc0df943a,0xc10738bd, | |||||
0x9a7d6240,0x9ba5cec7,0x99cc3b4e,0x981497c9,0x9d1fd05c,0x9cc77cdb,0x9eae8952,0x9f7625d5, | |||||
0x94b80678,0x9560aaff,0x97095f76,0x96d1f3f1,0x93dab464,0x920218e3,0x906bed6a,0x91b341ed, | |||||
0x87f7aa30,0x862f06b7,0x8446f33e,0x859e5fb9,0x8095182c,0x814db4ab,0x83244122,0x82fceda5, | |||||
0x8932ce08,0x88ea628f,0x8a839706,0x8b5b3b81,0x8e507c14,0x8f88d093,0x8de1251a,0x8c39899d, | |||||
0xa168f2a0,0xa0b05e27,0xa2d9abae,0xa3010729,0xa60a40bc,0xa7d2ec3b,0xa5bb19b2,0xa463b535, | |||||
0xafad9698,0xae753a1f,0xac1ccf96,0xadc46311,0xa8cf2484,0xa9178803,0xab7e7d8a,0xaaa6d10d, | |||||
0xbce23ad0,0xbd3a9657,0xbf5363de,0xbe8bcf59,0xbb8088cc,0xba58244b,0xb831d1c2,0xb9e97d45, | |||||
0xb2275ee8,0xb3fff26f,0xb19607e6,0xb04eab61,0xb545ecf4,0xb49d4073,0xb6f4b5fa,0xb72c197d}, | |||||
{0x00000000,0xdc6d9ab7,0xbc1a28d9,0x6077b26e,0x7cf54c05,0xa098d6b2,0xc0ef64dc,0x1c82fe6b, | |||||
0xf9ea980a,0x258702bd,0x45f0b0d3,0x999d2a64,0x851fd40f,0x59724eb8,0x3905fcd6,0xe5686661, | |||||
0xf7142da3,0x2b79b714,0x4b0e057a,0x97639fcd,0x8be161a6,0x578cfb11,0x37fb497f,0xeb96d3c8, | |||||
0x0efeb5a9,0xd2932f1e,0xb2e49d70,0x6e8907c7,0x720bf9ac,0xae66631b,0xce11d175,0x127c4bc2, | |||||
0xeae946f1,0x3684dc46,0x56f36e28,0x8a9ef49f,0x961c0af4,0x4a719043,0x2a06222d,0xf66bb89a, | |||||
0x1303defb,0xcf6e444c,0xaf19f622,0x73746c95,0x6ff692fe,0xb39b0849,0xd3ecba27,0x0f812090, | |||||
0x1dfd6b52,0xc190f1e5,0xa1e7438b,0x7d8ad93c,0x61082757,0xbd65bde0,0xdd120f8e,0x017f9539, | |||||
0xe417f358,0x387a69ef,0x580ddb81,0x84604136,0x98e2bf5d,0x448f25ea,0x24f89784,0xf8950d33, | |||||
0xd1139055,0x0d7e0ae2,0x6d09b88c,0xb164223b,0xade6dc50,0x718b46e7,0x11fcf489,0xcd916e3e, | |||||
0x28f9085f,0xf49492e8,0x94e32086,0x488eba31,0x540c445a,0x8861deed,0xe8166c83,0x347bf634, | |||||
0x2607bdf6,0xfa6a2741,0x9a1d952f,0x46700f98,0x5af2f1f3,0x869f6b44,0xe6e8d92a,0x3a85439d, | |||||
0xdfed25fc,0x0380bf4b,0x63f70d25,0xbf9a9792,0xa31869f9,0x7f75f34e,0x1f024120,0xc36fdb97, | |||||
0x3bfad6a4,0xe7974c13,0x87e0fe7d,0x5b8d64ca,0x470f9aa1,0x9b620016,0xfb15b278,0x277828cf, | |||||
0xc2104eae,0x1e7dd419,0x7e0a6677,0xa267fcc0,0xbee502ab,0x6288981c,0x02ff2a72,0xde92b0c5, | |||||
0xcceefb07,0x108361b0,0x70f4d3de,0xac994969,0xb01bb702,0x6c762db5,0x0c019fdb,0xd06c056c, | |||||
0x3504630d,0xe969f9ba,0x891e4bd4,0x5573d163,0x49f12f08,0x959cb5bf,0xf5eb07d1,0x29869d66, | |||||
0xa6e63d1d,0x7a8ba7aa,0x1afc15c4,0xc6918f73,0xda137118,0x067eebaf,0x660959c1,0xba64c376, | |||||
0x5f0ca517,0x83613fa0,0xe3168dce,0x3f7b1779,0x23f9e912,0xff9473a5,0x9fe3c1cb,0x438e5b7c, | |||||
0x51f210be,0x8d9f8a09,0xede83867,0x3185a2d0,0x2d075cbb,0xf16ac60c,0x911d7462,0x4d70eed5, | |||||
0xa81888b4,0x74751203,0x1402a06d,0xc86f3ada,0xd4edc4b1,0x08805e06,0x68f7ec68,0xb49a76df, | |||||
0x4c0f7bec,0x9062e15b,0xf0155335,0x2c78c982,0x30fa37e9,0xec97ad5e,0x8ce01f30,0x508d8587, | |||||
0xb5e5e3e6,0x69887951,0x09ffcb3f,0xd5925188,0xc910afe3,0x157d3554,0x750a873a,0xa9671d8d, | |||||
0xbb1b564f,0x6776ccf8,0x07017e96,0xdb6ce421,0xc7ee1a4a,0x1b8380fd,0x7bf43293,0xa799a824, | |||||
0x42f1ce45,0x9e9c54f2,0xfeebe69c,0x22867c2b,0x3e048240,0xe26918f7,0x821eaa99,0x5e73302e, | |||||
0x77f5ad48,0xab9837ff,0xcbef8591,0x17821f26,0x0b00e14d,0xd76d7bfa,0xb71ac994,0x6b775323, | |||||
0x8e1f3542,0x5272aff5,0x32051d9b,0xee68872c,0xf2ea7947,0x2e87e3f0,0x4ef0519e,0x929dcb29, | |||||
0x80e180eb,0x5c8c1a5c,0x3cfba832,0xe0963285,0xfc14ccee,0x20795659,0x400ee437,0x9c637e80, | |||||
0x790b18e1,0xa5668256,0xc5113038,0x197caa8f,0x05fe54e4,0xd993ce53,0xb9e47c3d,0x6589e68a, | |||||
0x9d1cebb9,0x4171710e,0x2106c360,0xfd6b59d7,0xe1e9a7bc,0x3d843d0b,0x5df38f65,0x819e15d2, | |||||
0x64f673b3,0xb89be904,0xd8ec5b6a,0x0481c1dd,0x18033fb6,0xc46ea501,0xa419176f,0x78748dd8, | |||||
0x6a08c61a,0xb6655cad,0xd612eec3,0x0a7f7474,0x16fd8a1f,0xca9010a8,0xaae7a2c6,0x768a3871, | |||||
0x93e25e10,0x4f8fc4a7,0x2ff876c9,0xf395ec7e,0xef171215,0x337a88a2,0x530d3acc,0x8f60a07b}, | |||||
{0x00000000,0x490d678d,0x921acf1a,0xdb17a897,0x20f48383,0x69f9e40e,0xb2ee4c99,0xfbe32b14, | |||||
0x41e90706,0x08e4608b,0xd3f3c81c,0x9afeaf91,0x611d8485,0x2810e308,0xf3074b9f,0xba0a2c12, | |||||
0x83d20e0c,0xcadf6981,0x11c8c116,0x58c5a69b,0xa3268d8f,0xea2bea02,0x313c4295,0x78312518, | |||||
0xc23b090a,0x8b366e87,0x5021c610,0x192ca19d,0xe2cf8a89,0xabc2ed04,0x70d54593,0x39d8221e, | |||||
0x036501af,0x4a686622,0x917fceb5,0xd872a938,0x2391822c,0x6a9ce5a1,0xb18b4d36,0xf8862abb, | |||||
0x428c06a9,0x0b816124,0xd096c9b3,0x999bae3e,0x6278852a,0x2b75e2a7,0xf0624a30,0xb96f2dbd, | |||||
0x80b70fa3,0xc9ba682e,0x12adc0b9,0x5ba0a734,0xa0438c20,0xe94eebad,0x3259433a,0x7b5424b7, | |||||
0xc15e08a5,0x88536f28,0x5344c7bf,0x1a49a032,0xe1aa8b26,0xa8a7ecab,0x73b0443c,0x3abd23b1, | |||||
0x06ca035e,0x4fc764d3,0x94d0cc44,0xddddabc9,0x263e80dd,0x6f33e750,0xb4244fc7,0xfd29284a, | |||||
0x47230458,0x0e2e63d5,0xd539cb42,0x9c34accf,0x67d787db,0x2edae056,0xf5cd48c1,0xbcc02f4c, | |||||
0x85180d52,0xcc156adf,0x1702c248,0x5e0fa5c5,0xa5ec8ed1,0xece1e95c,0x37f641cb,0x7efb2646, | |||||
0xc4f10a54,0x8dfc6dd9,0x56ebc54e,0x1fe6a2c3,0xe40589d7,0xad08ee5a,0x761f46cd,0x3f122140, | |||||
0x05af02f1,0x4ca2657c,0x97b5cdeb,0xdeb8aa66,0x255b8172,0x6c56e6ff,0xb7414e68,0xfe4c29e5, | |||||
0x444605f7,0x0d4b627a,0xd65ccaed,0x9f51ad60,0x64b28674,0x2dbfe1f9,0xf6a8496e,0xbfa52ee3, | |||||
0x867d0cfd,0xcf706b70,0x1467c3e7,0x5d6aa46a,0xa6898f7e,0xef84e8f3,0x34934064,0x7d9e27e9, | |||||
0xc7940bfb,0x8e996c76,0x558ec4e1,0x1c83a36c,0xe7608878,0xae6deff5,0x757a4762,0x3c7720ef, | |||||
0x0d9406bc,0x44996131,0x9f8ec9a6,0xd683ae2b,0x2d60853f,0x646de2b2,0xbf7a4a25,0xf6772da8, | |||||
0x4c7d01ba,0x05706637,0xde67cea0,0x976aa92d,0x6c898239,0x2584e5b4,0xfe934d23,0xb79e2aae, | |||||
0x8e4608b0,0xc74b6f3d,0x1c5cc7aa,0x5551a027,0xaeb28b33,0xe7bfecbe,0x3ca84429,0x75a523a4, | |||||
0xcfaf0fb6,0x86a2683b,0x5db5c0ac,0x14b8a721,0xef5b8c35,0xa656ebb8,0x7d41432f,0x344c24a2, | |||||
0x0ef10713,0x47fc609e,0x9cebc809,0xd5e6af84,0x2e058490,0x6708e31d,0xbc1f4b8a,0xf5122c07, | |||||
0x4f180015,0x06156798,0xdd02cf0f,0x940fa882,0x6fec8396,0x26e1e41b,0xfdf64c8c,0xb4fb2b01, | |||||
0x8d23091f,0xc42e6e92,0x1f39c605,0x5634a188,0xadd78a9c,0xe4daed11,0x3fcd4586,0x76c0220b, | |||||
0xccca0e19,0x85c76994,0x5ed0c103,0x17dda68e,0xec3e8d9a,0xa533ea17,0x7e244280,0x3729250d, | |||||
0x0b5e05e2,0x4253626f,0x9944caf8,0xd049ad75,0x2baa8661,0x62a7e1ec,0xb9b0497b,0xf0bd2ef6, | |||||
0x4ab702e4,0x03ba6569,0xd8adcdfe,0x91a0aa73,0x6a438167,0x234ee6ea,0xf8594e7d,0xb15429f0, | |||||
0x888c0bee,0xc1816c63,0x1a96c4f4,0x539ba379,0xa878886d,0xe175efe0,0x3a624777,0x736f20fa, | |||||
0xc9650ce8,0x80686b65,0x5b7fc3f2,0x1272a47f,0xe9918f6b,0xa09ce8e6,0x7b8b4071,0x328627fc, | |||||
0x083b044d,0x413663c0,0x9a21cb57,0xd32cacda,0x28cf87ce,0x61c2e043,0xbad548d4,0xf3d82f59, | |||||
0x49d2034b,0x00df64c6,0xdbc8cc51,0x92c5abdc,0x692680c8,0x202be745,0xfb3c4fd2,0xb231285f, | |||||
0x8be90a41,0xc2e46dcc,0x19f3c55b,0x50fea2d6,0xab1d89c2,0xe210ee4f,0x390746d8,0x700a2155, | |||||
0xca000d47,0x830d6aca,0x581ac25d,0x1117a5d0,0xeaf48ec4,0xa3f9e949,0x78ee41de,0x31e32653}, | |||||
{0x00000000,0x1b280d78,0x36501af0,0x2d781788,0x6ca035e0,0x77883898,0x5af02f10,0x41d82268, | |||||
0xd9406bc0,0xc26866b8,0xef107130,0xf4387c48,0xb5e05e20,0xaec85358,0x83b044d0,0x989849a8, | |||||
0xb641ca37,0xad69c74f,0x8011d0c7,0x9b39ddbf,0xdae1ffd7,0xc1c9f2af,0xecb1e527,0xf799e85f, | |||||
0x6f01a1f7,0x7429ac8f,0x5951bb07,0x4279b67f,0x03a19417,0x1889996f,0x35f18ee7,0x2ed9839f, | |||||
0x684289d9,0x736a84a1,0x5e129329,0x453a9e51,0x04e2bc39,0x1fcab141,0x32b2a6c9,0x299aabb1, | |||||
0xb102e219,0xaa2aef61,0x8752f8e9,0x9c7af591,0xdda2d7f9,0xc68ada81,0xebf2cd09,0xf0dac071, | |||||
0xde0343ee,0xc52b4e96,0xe853591e,0xf37b5466,0xb2a3760e,0xa98b7b76,0x84f36cfe,0x9fdb6186, | |||||
0x0743282e,0x1c6b2556,0x311332de,0x2a3b3fa6,0x6be31dce,0x70cb10b6,0x5db3073e,0x469b0a46, | |||||
0xd08513b2,0xcbad1eca,0xe6d50942,0xfdfd043a,0xbc252652,0xa70d2b2a,0x8a753ca2,0x915d31da, | |||||
0x09c57872,0x12ed750a,0x3f956282,0x24bd6ffa,0x65654d92,0x7e4d40ea,0x53355762,0x481d5a1a, | |||||
0x66c4d985,0x7decd4fd,0x5094c375,0x4bbcce0d,0x0a64ec65,0x114ce11d,0x3c34f695,0x271cfbed, | |||||
0xbf84b245,0xa4acbf3d,0x89d4a8b5,0x92fca5cd,0xd32487a5,0xc80c8add,0xe5749d55,0xfe5c902d, | |||||
0xb8c79a6b,0xa3ef9713,0x8e97809b,0x95bf8de3,0xd467af8b,0xcf4fa2f3,0xe237b57b,0xf91fb803, | |||||
0x6187f1ab,0x7aaffcd3,0x57d7eb5b,0x4cffe623,0x0d27c44b,0x160fc933,0x3b77debb,0x205fd3c3, | |||||
0x0e86505c,0x15ae5d24,0x38d64aac,0x23fe47d4,0x622665bc,0x790e68c4,0x54767f4c,0x4f5e7234, | |||||
0xd7c63b9c,0xccee36e4,0xe196216c,0xfabe2c14,0xbb660e7c,0xa04e0304,0x8d36148c,0x961e19f4, | |||||
0xa5cb3ad3,0xbee337ab,0x939b2023,0x88b32d5b,0xc96b0f33,0xd243024b,0xff3b15c3,0xe41318bb, | |||||
0x7c8b5113,0x67a35c6b,0x4adb4be3,0x51f3469b,0x102b64f3,0x0b03698b,0x267b7e03,0x3d53737b, | |||||
0x138af0e4,0x08a2fd9c,0x25daea14,0x3ef2e76c,0x7f2ac504,0x6402c87c,0x497adff4,0x5252d28c, | |||||
0xcaca9b24,0xd1e2965c,0xfc9a81d4,0xe7b28cac,0xa66aaec4,0xbd42a3bc,0x903ab434,0x8b12b94c, | |||||
0xcd89b30a,0xd6a1be72,0xfbd9a9fa,0xe0f1a482,0xa12986ea,0xba018b92,0x97799c1a,0x8c519162, | |||||
0x14c9d8ca,0x0fe1d5b2,0x2299c23a,0x39b1cf42,0x7869ed2a,0x6341e052,0x4e39f7da,0x5511faa2, | |||||
0x7bc8793d,0x60e07445,0x4d9863cd,0x56b06eb5,0x17684cdd,0x0c4041a5,0x2138562d,0x3a105b55, | |||||
0xa28812fd,0xb9a01f85,0x94d8080d,0x8ff00575,0xce28271d,0xd5002a65,0xf8783ded,0xe3503095, | |||||
0x754e2961,0x6e662419,0x431e3391,0x58363ee9,0x19ee1c81,0x02c611f9,0x2fbe0671,0x34960b09, | |||||
0xac0e42a1,0xb7264fd9,0x9a5e5851,0x81765529,0xc0ae7741,0xdb867a39,0xf6fe6db1,0xedd660c9, | |||||
0xc30fe356,0xd827ee2e,0xf55ff9a6,0xee77f4de,0xafafd6b6,0xb487dbce,0x99ffcc46,0x82d7c13e, | |||||
0x1a4f8896,0x016785ee,0x2c1f9266,0x37379f1e,0x76efbd76,0x6dc7b00e,0x40bfa786,0x5b97aafe, | |||||
0x1d0ca0b8,0x0624adc0,0x2b5cba48,0x3074b730,0x71ac9558,0x6a849820,0x47fc8fa8,0x5cd482d0, | |||||
0xc44ccb78,0xdf64c600,0xf21cd188,0xe934dcf0,0xa8ecfe98,0xb3c4f3e0,0x9ebce468,0x8594e910, | |||||
0xab4d6a8f,0xb06567f7,0x9d1d707f,0x86357d07,0xc7ed5f6f,0xdcc55217,0xf1bd459f,0xea9548e7, | |||||
0x720d014f,0x69250c37,0x445d1bbf,0x5f7516c7,0x1ead34af,0x058539d7,0x28fd2e5f,0x33d52327}, | |||||
{0x00000000,0x4f576811,0x9eaed022,0xd1f9b833,0x399cbdf3,0x76cbd5e2,0xa7326dd1,0xe86505c0, | |||||
0x73397be6,0x3c6e13f7,0xed97abc4,0xa2c0c3d5,0x4aa5c615,0x05f2ae04,0xd40b1637,0x9b5c7e26, | |||||
0xe672f7cc,0xa9259fdd,0x78dc27ee,0x378b4fff,0xdfee4a3f,0x90b9222e,0x41409a1d,0x0e17f20c, | |||||
0x954b8c2a,0xda1ce43b,0x0be55c08,0x44b23419,0xacd731d9,0xe38059c8,0x3279e1fb,0x7d2e89ea, | |||||
0xc824f22f,0x87739a3e,0x568a220d,0x19dd4a1c,0xf1b84fdc,0xbeef27cd,0x6f169ffe,0x2041f7ef, | |||||
0xbb1d89c9,0xf44ae1d8,0x25b359eb,0x6ae431fa,0x8281343a,0xcdd65c2b,0x1c2fe418,0x53788c09, | |||||
0x2e5605e3,0x61016df2,0xb0f8d5c1,0xffafbdd0,0x17cab810,0x589dd001,0x89646832,0xc6330023, | |||||
0x5d6f7e05,0x12381614,0xc3c1ae27,0x8c96c636,0x64f3c3f6,0x2ba4abe7,0xfa5d13d4,0xb50a7bc5, | |||||
0x9488f9e9,0xdbdf91f8,0x0a2629cb,0x457141da,0xad14441a,0xe2432c0b,0x33ba9438,0x7cedfc29, | |||||
0xe7b1820f,0xa8e6ea1e,0x791f522d,0x36483a3c,0xde2d3ffc,0x917a57ed,0x4083efde,0x0fd487cf, | |||||
0x72fa0e25,0x3dad6634,0xec54de07,0xa303b616,0x4b66b3d6,0x0431dbc7,0xd5c863f4,0x9a9f0be5, | |||||
0x01c375c3,0x4e941dd2,0x9f6da5e1,0xd03acdf0,0x385fc830,0x7708a021,0xa6f11812,0xe9a67003, | |||||
0x5cac0bc6,0x13fb63d7,0xc202dbe4,0x8d55b3f5,0x6530b635,0x2a67de24,0xfb9e6617,0xb4c90e06, | |||||
0x2f957020,0x60c21831,0xb13ba002,0xfe6cc813,0x1609cdd3,0x595ea5c2,0x88a71df1,0xc7f075e0, | |||||
0xbadefc0a,0xf589941b,0x24702c28,0x6b274439,0x834241f9,0xcc1529e8,0x1dec91db,0x52bbf9ca, | |||||
0xc9e787ec,0x86b0effd,0x574957ce,0x181e3fdf,0xf07b3a1f,0xbf2c520e,0x6ed5ea3d,0x2182822c, | |||||
0x2dd0ee65,0x62878674,0xb37e3e47,0xfc295656,0x144c5396,0x5b1b3b87,0x8ae283b4,0xc5b5eba5, | |||||
0x5ee99583,0x11befd92,0xc04745a1,0x8f102db0,0x67752870,0x28224061,0xf9dbf852,0xb68c9043, | |||||
0xcba219a9,0x84f571b8,0x550cc98b,0x1a5ba19a,0xf23ea45a,0xbd69cc4b,0x6c907478,0x23c71c69, | |||||
0xb89b624f,0xf7cc0a5e,0x2635b26d,0x6962da7c,0x8107dfbc,0xce50b7ad,0x1fa90f9e,0x50fe678f, | |||||
0xe5f41c4a,0xaaa3745b,0x7b5acc68,0x340da479,0xdc68a1b9,0x933fc9a8,0x42c6719b,0x0d91198a, | |||||
0x96cd67ac,0xd99a0fbd,0x0863b78e,0x4734df9f,0xaf51da5f,0xe006b24e,0x31ff0a7d,0x7ea8626c, | |||||
0x0386eb86,0x4cd18397,0x9d283ba4,0xd27f53b5,0x3a1a5675,0x754d3e64,0xa4b48657,0xebe3ee46, | |||||
0x70bf9060,0x3fe8f871,0xee114042,0xa1462853,0x49232d93,0x06744582,0xd78dfdb1,0x98da95a0, | |||||
0xb958178c,0xf60f7f9d,0x27f6c7ae,0x68a1afbf,0x80c4aa7f,0xcf93c26e,0x1e6a7a5d,0x513d124c, | |||||
0xca616c6a,0x8536047b,0x54cfbc48,0x1b98d459,0xf3fdd199,0xbcaab988,0x6d5301bb,0x220469aa, | |||||
0x5f2ae040,0x107d8851,0xc1843062,0x8ed35873,0x66b65db3,0x29e135a2,0xf8188d91,0xb74fe580, | |||||
0x2c139ba6,0x6344f3b7,0xb2bd4b84,0xfdea2395,0x158f2655,0x5ad84e44,0x8b21f677,0xc4769e66, | |||||
0x717ce5a3,0x3e2b8db2,0xefd23581,0xa0855d90,0x48e05850,0x07b73041,0xd64e8872,0x9919e063, | |||||
0x02459e45,0x4d12f654,0x9ceb4e67,0xd3bc2676,0x3bd923b6,0x748e4ba7,0xa577f394,0xea209b85, | |||||
0x970e126f,0xd8597a7e,0x09a0c24d,0x46f7aa5c,0xae92af9c,0xe1c5c78d,0x303c7fbe,0x7f6b17af, | |||||
0xe4376989,0xab600198,0x7a99b9ab,0x35ced1ba,0xddabd47a,0x92fcbc6b,0x43050458,0x0c526c49}, | |||||
{0x00000000,0x5ba1dcca,0xb743b994,0xece2655e,0x6a466e9f,0x31e7b255,0xdd05d70b,0x86a40bc1, | |||||
0xd48cdd3e,0x8f2d01f4,0x63cf64aa,0x386eb860,0xbecab3a1,0xe56b6f6b,0x09890a35,0x5228d6ff, | |||||
0xadd8a7cb,0xf6797b01,0x1a9b1e5f,0x413ac295,0xc79ec954,0x9c3f159e,0x70dd70c0,0x2b7cac0a, | |||||
0x79547af5,0x22f5a63f,0xce17c361,0x95b61fab,0x1312146a,0x48b3c8a0,0xa451adfe,0xfff07134, | |||||
0x5f705221,0x04d18eeb,0xe833ebb5,0xb392377f,0x35363cbe,0x6e97e074,0x8275852a,0xd9d459e0, | |||||
0x8bfc8f1f,0xd05d53d5,0x3cbf368b,0x671eea41,0xe1bae180,0xba1b3d4a,0x56f95814,0x0d5884de, | |||||
0xf2a8f5ea,0xa9092920,0x45eb4c7e,0x1e4a90b4,0x98ee9b75,0xc34f47bf,0x2fad22e1,0x740cfe2b, | |||||
0x262428d4,0x7d85f41e,0x91679140,0xcac64d8a,0x4c62464b,0x17c39a81,0xfb21ffdf,0xa0802315, | |||||
0xbee0a442,0xe5417888,0x09a31dd6,0x5202c11c,0xd4a6cadd,0x8f071617,0x63e57349,0x3844af83, | |||||
0x6a6c797c,0x31cda5b6,0xdd2fc0e8,0x868e1c22,0x002a17e3,0x5b8bcb29,0xb769ae77,0xecc872bd, | |||||
0x13380389,0x4899df43,0xa47bba1d,0xffda66d7,0x797e6d16,0x22dfb1dc,0xce3dd482,0x959c0848, | |||||
0xc7b4deb7,0x9c15027d,0x70f76723,0x2b56bbe9,0xadf2b028,0xf6536ce2,0x1ab109bc,0x4110d576, | |||||
0xe190f663,0xba312aa9,0x56d34ff7,0x0d72933d,0x8bd698fc,0xd0774436,0x3c952168,0x6734fda2, | |||||
0x351c2b5d,0x6ebdf797,0x825f92c9,0xd9fe4e03,0x5f5a45c2,0x04fb9908,0xe819fc56,0xb3b8209c, | |||||
0x4c4851a8,0x17e98d62,0xfb0be83c,0xa0aa34f6,0x260e3f37,0x7dafe3fd,0x914d86a3,0xcaec5a69, | |||||
0x98c48c96,0xc365505c,0x2f873502,0x7426e9c8,0xf282e209,0xa9233ec3,0x45c15b9d,0x1e608757, | |||||
0x79005533,0x22a189f9,0xce43eca7,0x95e2306d,0x13463bac,0x48e7e766,0xa4058238,0xffa45ef2, | |||||
0xad8c880d,0xf62d54c7,0x1acf3199,0x416eed53,0xc7cae692,0x9c6b3a58,0x70895f06,0x2b2883cc, | |||||
0xd4d8f2f8,0x8f792e32,0x639b4b6c,0x383a97a6,0xbe9e9c67,0xe53f40ad,0x09dd25f3,0x527cf939, | |||||
0x00542fc6,0x5bf5f30c,0xb7179652,0xecb64a98,0x6a124159,0x31b39d93,0xdd51f8cd,0x86f02407, | |||||
0x26700712,0x7dd1dbd8,0x9133be86,0xca92624c,0x4c36698d,0x1797b547,0xfb75d019,0xa0d40cd3, | |||||
0xf2fcda2c,0xa95d06e6,0x45bf63b8,0x1e1ebf72,0x98bab4b3,0xc31b6879,0x2ff90d27,0x7458d1ed, | |||||
0x8ba8a0d9,0xd0097c13,0x3ceb194d,0x674ac587,0xe1eece46,0xba4f128c,0x56ad77d2,0x0d0cab18, | |||||
0x5f247de7,0x0485a12d,0xe867c473,0xb3c618b9,0x35621378,0x6ec3cfb2,0x8221aaec,0xd9807626, | |||||
0xc7e0f171,0x9c412dbb,0x70a348e5,0x2b02942f,0xada69fee,0xf6074324,0x1ae5267a,0x4144fab0, | |||||
0x136c2c4f,0x48cdf085,0xa42f95db,0xff8e4911,0x792a42d0,0x228b9e1a,0xce69fb44,0x95c8278e, | |||||
0x6a3856ba,0x31998a70,0xdd7bef2e,0x86da33e4,0x007e3825,0x5bdfe4ef,0xb73d81b1,0xec9c5d7b, | |||||
0xbeb48b84,0xe515574e,0x09f73210,0x5256eeda,0xd4f2e51b,0x8f5339d1,0x63b15c8f,0x38108045, | |||||
0x9890a350,0xc3317f9a,0x2fd31ac4,0x7472c60e,0xf2d6cdcf,0xa9771105,0x4595745b,0x1e34a891, | |||||
0x4c1c7e6e,0x17bda2a4,0xfb5fc7fa,0xa0fe1b30,0x265a10f1,0x7dfbcc3b,0x9119a965,0xcab875af, | |||||
0x3548049b,0x6ee9d851,0x820bbd0f,0xd9aa61c5,0x5f0e6a04,0x04afb6ce,0xe84dd390,0xb3ec0f5a, | |||||
0xe1c4d9a5,0xba65056f,0x56876031,0x0d26bcfb,0x8b82b73a,0xd0236bf0,0x3cc10eae,0x6760d264}}; |
@@ -1,134 +0,0 @@ | |||||
******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.org Foundation, http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
Vorbis is a general purpose audio and music encoding format | |||||
contemporary to MPEG-4's AAC and TwinVQ, the next generation beyond | |||||
MPEG audio layer 3. Unlike the MPEG sponsored formats (and other | |||||
proprietary formats such as RealAudio G2 and Windows' flavor of the | |||||
month), the Vorbis CODEC specification belongs to the public domain. | |||||
All the technical details are published and documented, and any | |||||
software entity may make full use of the format without license | |||||
fee, royalty or patent concerns. | |||||
This package contains: | |||||
* libvorbis, a BSD-style license software implementation of | |||||
the Vorbis specification by the Xiph.Org Foundation | |||||
(http://www.xiph.org/) | |||||
* libvorbisfile, a BSD-style license convenience library | |||||
built on Vorbis designed to simplify common uses | |||||
* libvorbisenc, a BSD-style license library that provides a simple, | |||||
programmatic encoding setup interface | |||||
* example code making use of libogg, libvorbis, libvorbisfile and | |||||
libvorbisenc | |||||
WHAT'S HERE: | |||||
This source distribution includes libvorbis and an example | |||||
encoder/player to demonstrate use of libvorbis as well as | |||||
documentation on the Ogg Vorbis audio coding format. | |||||
You'll need libogg (distributed separately) to compile this library. | |||||
A more comprehensive set of utilities is available in the vorbis-tools | |||||
package. | |||||
Directory: | |||||
./lib The source for the libraries, a BSD-license implementation | |||||
of the public domain Ogg Vorbis audio encoding format. | |||||
./include Library API headers | |||||
./debian Rules/spec files for building Debian .deb packages | |||||
./doc Vorbis documentation | |||||
./examples Example code illustrating programmatic use of libvorbis, | |||||
libvorbisfile and libvorbisenc | |||||
./mac Codewarrior project files and build tweaks for MacOS. | |||||
./macosx Project files for MacOS X. | |||||
./win32 Win32 projects files and build automation | |||||
./vq Internal utilities for training/building new LSP/residue | |||||
and auxiliary codebooks. | |||||
CONTACT: | |||||
The Ogg homepage is located at 'http://www.xiph.org/ogg/'. | |||||
Vorbis's homepage is located at 'http://www.xiph.org/vorbis/'. | |||||
Up to date technical documents, contact information, source code and | |||||
pre-built utilities may be found there. | |||||
The user website for Ogg Vorbis software and audio is http://vorbis.com/ | |||||
BUILDING FROM TRUNK: | |||||
Development source is under subversion revision control at | |||||
https://svn.xiph.org/trunk/vorbis/. You will also need the | |||||
newest versions of autoconf, automake, libtool and pkg-config in | |||||
order to compile Vorbis from development source. A configure script | |||||
is provided for you in the source tarball distributions. | |||||
[update or checkout latest source] | |||||
./autogen.sh | |||||
make | |||||
and as root if desired: | |||||
make install | |||||
This will install the Vorbis libraries (static and shared) into | |||||
/usr/local/lib, includes into /usr/local/include and API manpages | |||||
(once we write some) into /usr/local/man. | |||||
Documentation building requires xsltproc and pdfxmltex. | |||||
BUILDING FROM TARBALL DISTRIBUTIONS: | |||||
./configure | |||||
make | |||||
and optionally (as root): | |||||
make install | |||||
BUILDING RPMS: | |||||
after normal configuring: | |||||
make dist | |||||
rpm -ta libvorbis-<version>.tar.gz | |||||
BUILDING ON MACOS 9: | |||||
Vorbis on MacOS 9 is built using Metroworks CodeWarrior. To build it, | |||||
first verify that the Ogg libraries are already built following the | |||||
instructions in the Ogg module README. Open vorbis/mac/libvorbis.mcp, | |||||
switch to the "Targets" pane, select everything, and make the project. | |||||
Do the same thing to build libvorbisenc.mcp, and libvorbisfile.mcp (in | |||||
that order). In vorbis/mac/Output you will now have both debug and final | |||||
versions of Vorbis shared libraries to link your projects against. | |||||
To build a project using Ogg Vorbis, add access paths to your | |||||
CodeWarrior project for the ogg/include, ogg/mac/Output, | |||||
vorbis/include, and vorbis/mac/Output folders. Be sure that | |||||
"interpret DOS and Unix paths" is turned on in your project; it can | |||||
be found in the "access paths" pane in your project settings. Now | |||||
simply add the shared libraries you need to your project (OggLib and | |||||
VorbisLib at least) and #include "ogg/ogg.h" and "vorbis/codec.h" | |||||
wherever you need to access Ogg and Vorbis functionality. | |||||
@@ -1,3 +1,61 @@ | |||||
libvorbis 1.3.7 (2020-07-04) -- "Xiph.Org libVorbis I 20200704 (Reducing Environment)" | |||||
* Fix CVE-2018-10393 - out-of-bounds read encoding very low sample rates. | |||||
* Fix CVE-2017-14160 - out-of-bounds read encoding very low sample rates. | |||||
* Fix handling invalid bytes per sample arguments. | |||||
* Fix handling invalid channel count arguments. | |||||
* Fix invalid free on seek failure. | |||||
* Fix negative shift reading blocksize. | |||||
* Fix accepting unreasonable float32 values. | |||||
* Fix tag comparison depending on locale. | |||||
* Fix unnecessarily linking libm. | |||||
* Fix memory leak in test_sharedbook. | |||||
* Update Visual Studio projects for ogg library filename change. | |||||
* Distribute CMake build files with the source package. | |||||
* Remove unnecessary configure --target switch. | |||||
* Add gitlab CI support. | |||||
* Add OSS-Fuzz support. | |||||
* Build system and integration updates. | |||||
libvorbis 1.3.6 (2018-03-16) -- "Xiph.Org libVorbis I 20180316 (Now 100% fewer shells)" | |||||
* Fix CVE-2018-5146 - out-of-bounds write on codebook decoding. | |||||
* Fix CVE-2017-14632 - free() on unitialized data | |||||
* Fix CVE-2017-14633 - out-of-bounds read | |||||
* Fix bitrate metadata parsing. | |||||
* Fix out-of-bounds read in codebook parsing. | |||||
* Fix residue vector size in Vorbis I spec. | |||||
* Appveyor support | |||||
* Travis CI support | |||||
* Add secondary CMake build system. | |||||
* Build system fixes | |||||
libvorbis 1.3.5 (2015-03-03) -- "Xiph.Org libVorbis I 20150105 (⛄⛄⛄⛄)" | |||||
* Tolerate single-entry codebooks. | |||||
* Fix decoder crash with invalid input. | |||||
* Fix encoder crash with non-positive sample rates. | |||||
# Fix issues in vorbisfile's seek bisection code. | |||||
* Spec errata. | |||||
* Reject multiple headers of the same type. | |||||
* Various build fixes and code cleanup. | |||||
libvorbis 1.3.4 (2014-01-22) -- "Xiph.Org libVorbis I 20140122 (Turpakäräjiin)" | |||||
* Reduce codebook footprint in library code. | |||||
* Various build and documentation fixes. | |||||
libvorbis 1.3.3 (2012-02-03) -- "Xiph.Org libVorbis I 20120203 (Omnipresent)" | |||||
* vorbis: additional proofing against invalid/malicious | |||||
streams in decode (see SVN for details). | |||||
* vorbis: fix a memory leak in vorbis_commentheader_out(). | |||||
* updates, corrections and clarifications in the Vorbis I specification | |||||
document | |||||
* win32: fixed project configuration which referenced two CRT versions | |||||
in output binaries. | |||||
* build warning fixes | |||||
libvorbis 1.3.2 (2010-11-01) -- "Xiph.Org libVorbis I 20101101 (Schaufenugget)" | libvorbis 1.3.2 (2010-11-01) -- "Xiph.Org libVorbis I 20101101 (Schaufenugget)" | ||||
* vorbis: additional proofing against invalid/malicious | * vorbis: additional proofing against invalid/malicious |
@@ -1,4 +1,4 @@ | |||||
Copyright (c) 2002-2008 Xiph.org Foundation | |||||
Copyright (c) 2002-2020 Xiph.org Foundation | |||||
Redistribution and use in source and binary forms, with or without | Redistribution and use in source and binary forms, with or without | ||||
modification, are permitted provided that the following conditions | modification, are permitted provided that the following conditions |
@@ -0,0 +1,147 @@ | |||||
# Vorbis | |||||
[](https://gitlab.xiph.org/xiph/vorbis/-/pipelines) | |||||
[](https://travis-ci.org/xiph/vorbis) | |||||
[](https://ci.appveyor.com/project/rillian/vorbis) | |||||
Vorbis is a general purpose audio and music encoding format | |||||
contemporary to MPEG-4's AAC and TwinVQ, the next generation beyond | |||||
MPEG audio layer 3. Unlike the MPEG sponsored formats (and other | |||||
proprietary formats such as RealAudio G2 and Windows' flavor of the | |||||
month), the Vorbis CODEC specification belongs to the public domain. | |||||
All the technical details are published and documented, and any | |||||
software entity may make full use of the format without license | |||||
fee, royalty or patent concerns. | |||||
This package contains: | |||||
- libvorbis, a BSD-style license software implementation of | |||||
the Vorbis specification by the Xiph.Org Foundation | |||||
(https://xiph.org/) | |||||
- libvorbisfile, a BSD-style license convenience library | |||||
built on Vorbis designed to simplify common uses | |||||
- libvorbisenc, a BSD-style license library that provides a simple, | |||||
programmatic encoding setup interface | |||||
- example code making use of libogg, libvorbis, libvorbisfile and | |||||
libvorbisenc | |||||
## What's here ## | |||||
This source distribution includes libvorbis and an example | |||||
encoder/player to demonstrate use of libvorbis as well as | |||||
documentation on the Ogg Vorbis audio coding format. | |||||
You'll need libogg (distributed separately) to compile this library. | |||||
A more comprehensive set of utilities is available in the vorbis-tools | |||||
package. | |||||
Directory: | |||||
- `lib` The source for the libraries, a BSD-license implementation of the public domain Ogg Vorbis audio encoding format. | |||||
- `include` Library API headers | |||||
- `debian` Rules/spec files for building Debian .deb packages | |||||
- `doc` Vorbis documentation | |||||
- `examples` Example code illustrating programmatic use of libvorbis, libvorbisfile and libvorbisenc | |||||
- `macosx` Project files for MacOS X. | |||||
- `win32` Win32 projects files and build automation | |||||
- `vq` Internal utilities for training/building new LSP/residue and auxiliary codebooks. | |||||
## Contact ## | |||||
The Ogg homepage is located at 'https://xiph.org/ogg/'. | |||||
Vorbis's homepage is located at 'https://xiph.org/vorbis/'. | |||||
Up to date technical documents, contact information, source code and | |||||
pre-built utilities may be found there. | |||||
## Building ## | |||||
#### Building from master #### | |||||
Development source is under git revision control at | |||||
https://gitlab.xiph.org/xiph/vorbis.git. You will also need the | |||||
newest versions of autoconf, automake, libtool and pkg-config in | |||||
order to compile Vorbis from development source. A configure script | |||||
is provided for you in the source tarball distributions. | |||||
./autogen.sh | |||||
./configure | |||||
make | |||||
and as root if desired: | |||||
make install | |||||
This will install the Vorbis libraries (static and shared) into | |||||
/usr/local/lib, includes into /usr/local/include and API manpages | |||||
(once we write some) into /usr/local/man. | |||||
Documentation building requires xsltproc and pdfxmltex. | |||||
#### Building from tarball distributions #### | |||||
./configure | |||||
make | |||||
and optionally (as root): | |||||
make install | |||||
#### Building RPM packages #### | |||||
after normal configuring: | |||||
make dist | |||||
rpm -ta libvorbis-<version>.tar.gz | |||||
## Building with CMake ## | |||||
Ogg supports building using [CMake](https://cmake.org/). CMake is a meta build system that generates native projects for each platform. | |||||
To generate projects just run cmake replacing `YOUR-PROJECT-GENERATOR` with a proper generator from a list [here](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html): | |||||
cmake -G YOUR-PROJECT-GENERATOR . | |||||
Note that by default cmake generates projects that will build static libraries. | |||||
To generate projects that will build dynamic library use `BUILD_SHARED_LIBS` option like this: | |||||
cmake -G YOUR-PROJECT-GENERATOR -DBUILD_SHARED_LIBS=1 . | |||||
After projects are generated use them as usual | |||||
#### Building on Windows #### | |||||
Use proper generator for your Visual Studio version like: | |||||
cmake -G "Visual Studio 12 2013" . | |||||
#### Building on Mac OS X #### | |||||
Use Xcode generator. To build framework run: | |||||
cmake -G Xcode -DBUILD_FRAMEWORK=1 . | |||||
#### Building on Linux #### | |||||
Use Makefile generator which is default one. | |||||
cmake . | |||||
make | |||||
## License ## | |||||
THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. | |||||
USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS | |||||
GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE | |||||
IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. | |||||
THE OggVorbis SOURCE CODE IS COPYRIGHT (C) 1994-2020 | |||||
by the Xiph.Org Foundation https://xiph.org/ |
@@ -1,109 +1,108 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: single-block PCM analysis mode dispatch | |||||
last mod: $Id: analysis.c 16226 2009-07-08 06:43:49Z xiphmont $ | |||||
********************************************************************/ | |||||
#include <stdio.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "registry.h" | |||||
#include "scales.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
/* decides between modes, dispatches to the appropriate mapping. */ | |||||
int vorbis_analysis(vorbis_block *vb, ogg_packet *op){ | |||||
int ret,i; | |||||
vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal; | |||||
vb->glue_bits=0; | |||||
vb->time_bits=0; | |||||
vb->floor_bits=0; | |||||
vb->res_bits=0; | |||||
/* first things first. Make sure encode is ready */ | |||||
for(i=0;i<PACKETBLOBS;i++) | |||||
oggpack_reset(vbi->packetblob[i]); | |||||
/* we only have one mapping type (0), and we let the mapping code | |||||
itself figure out what soft mode to use. This allows easier | |||||
bitrate management */ | |||||
if((ret=_mapping_P[0]->forward(vb))) | |||||
return(ret); | |||||
if(op){ | |||||
if(vorbis_bitrate_managed(vb)) | |||||
/* The app is using a bitmanaged mode... but not using the | |||||
bitrate management interface. */ | |||||
return(OV_EINVAL); | |||||
op->packet=oggpack_get_buffer(&vb->opb); | |||||
op->bytes=oggpack_bytes(&vb->opb); | |||||
op->b_o_s=0; | |||||
op->e_o_s=vb->eofflag; | |||||
op->granulepos=vb->granulepos; | |||||
op->packetno=vb->sequence; /* for sake of completeness */ | |||||
} | |||||
return(0); | |||||
} | |||||
#ifdef ANALYSIS | |||||
int analysis_noisy=1; | |||||
/* there was no great place to put this.... */ | |||||
void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){ | |||||
int j; | |||||
FILE *of; | |||||
char buffer[80]; | |||||
sprintf(buffer,"%s_%d.m",base,i); | |||||
of=fopen(buffer,"w"); | |||||
if(!of)perror("failed to open data dump file"); | |||||
for(j=0;j<n;j++){ | |||||
if(bark){ | |||||
float b=toBARK((4000.f*j/n)+.25); | |||||
fprintf(of,"%f ",b); | |||||
}else | |||||
if(off!=0) | |||||
fprintf(of,"%f ",(double)(j+off)/8000.); | |||||
else | |||||
fprintf(of,"%f ",(double)j); | |||||
if(dB){ | |||||
float val; | |||||
if(v[j]==0.) | |||||
val=-140.; | |||||
else | |||||
val=todB(v+j); | |||||
fprintf(of,"%f\n",val); | |||||
}else{ | |||||
fprintf(of,"%f\n",v[j]); | |||||
} | |||||
} | |||||
fclose(of); | |||||
} | |||||
void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, | |||||
ogg_int64_t off){ | |||||
if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off); | |||||
} | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: single-block PCM analysis mode dispatch | |||||
********************************************************************/ | |||||
#include <stdio.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "registry.h" | |||||
#include "scales.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
/* decides between modes, dispatches to the appropriate mapping. */ | |||||
int vorbis_analysis(vorbis_block *vb, ogg_packet *op){ | |||||
int ret,i; | |||||
vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal; | |||||
vb->glue_bits=0; | |||||
vb->time_bits=0; | |||||
vb->floor_bits=0; | |||||
vb->res_bits=0; | |||||
/* first things first. Make sure encode is ready */ | |||||
for(i=0;i<PACKETBLOBS;i++) | |||||
oggpack_reset(vbi->packetblob[i]); | |||||
/* we only have one mapping type (0), and we let the mapping code | |||||
itself figure out what soft mode to use. This allows easier | |||||
bitrate management */ | |||||
if((ret=_mapping_P[0]->forward(vb))) | |||||
return(ret); | |||||
if(op){ | |||||
if(vorbis_bitrate_managed(vb)) | |||||
/* The app is using a bitmanaged mode... but not using the | |||||
bitrate management interface. */ | |||||
return(OV_EINVAL); | |||||
op->packet=oggpack_get_buffer(&vb->opb); | |||||
op->bytes=oggpack_bytes(&vb->opb); | |||||
op->b_o_s=0; | |||||
op->e_o_s=vb->eofflag; | |||||
op->granulepos=vb->granulepos; | |||||
op->packetno=vb->sequence; /* for sake of completeness */ | |||||
} | |||||
return(0); | |||||
} | |||||
#ifdef ANALYSIS | |||||
int analysis_noisy=1; | |||||
/* there was no great place to put this.... */ | |||||
void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){ | |||||
int j; | |||||
FILE *of; | |||||
char buffer[80]; | |||||
sprintf(buffer,"%s_%d.m",base,i); | |||||
of=fopen(buffer,"w"); | |||||
if(!of)perror("failed to open data dump file"); | |||||
for(j=0;j<n;j++){ | |||||
if(bark){ | |||||
float b=toBARK((4000.f*j/n)+.25); | |||||
fprintf(of,"%f ",b); | |||||
}else | |||||
if(off!=0) | |||||
fprintf(of,"%f ",(double)(j+off)/8000.); | |||||
else | |||||
fprintf(of,"%f ",(double)j); | |||||
if(dB){ | |||||
float val; | |||||
if(v[j]==0.) | |||||
val=-140.; | |||||
else | |||||
val=todB(v+j); | |||||
fprintf(of,"%f\n",val); | |||||
}else{ | |||||
fprintf(of,"%f\n",v[j]); | |||||
} | |||||
} | |||||
fclose(of); | |||||
} | |||||
void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, | |||||
ogg_int64_t off){ | |||||
if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off); | |||||
} | |||||
#endif |
@@ -1,144 +1,143 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: libvorbis backend and mapping structures; needed for | |||||
static mode headers | |||||
last mod: $Id: backends.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||||
********************************************************************/ | |||||
/* this is exposed up here because we need it for static modes. | |||||
Lookups for each backend aren't exposed because there's no reason | |||||
to do so */ | |||||
#ifndef _vorbis_backend_h_ | |||||
#define _vorbis_backend_h_ | |||||
#include "codec_internal.h" | |||||
/* this would all be simpler/shorter with templates, but.... */ | |||||
/* Floor backend generic *****************************************/ | |||||
typedef struct{ | |||||
void (*pack) (vorbis_info_floor *,oggpack_buffer *); | |||||
vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); | |||||
vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_floor *); | |||||
void (*free_info) (vorbis_info_floor *); | |||||
void (*free_look) (vorbis_look_floor *); | |||||
void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); | |||||
int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, | |||||
void *buffer,float *); | |||||
} vorbis_func_floor; | |||||
typedef struct{ | |||||
int order; | |||||
long rate; | |||||
long barkmap; | |||||
int ampbits; | |||||
int ampdB; | |||||
int numbooks; /* <= 16 */ | |||||
int books[16]; | |||||
float lessthan; /* encode-only config setting hacks for libvorbis */ | |||||
float greaterthan; /* encode-only config setting hacks for libvorbis */ | |||||
} vorbis_info_floor0; | |||||
#define VIF_POSIT 63 | |||||
#define VIF_CLASS 16 | |||||
#define VIF_PARTS 31 | |||||
typedef struct{ | |||||
int partitions; /* 0 to 31 */ | |||||
int partitionclass[VIF_PARTS]; /* 0 to 15 */ | |||||
int class_dim[VIF_CLASS]; /* 1 to 8 */ | |||||
int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1<<n poss) */ | |||||
int class_book[VIF_CLASS]; /* subs ^ dim entries */ | |||||
int class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */ | |||||
int mult; /* 1 2 3 or 4 */ | |||||
int postlist[VIF_POSIT+2]; /* first two implicit */ | |||||
/* encode side analysis parameters */ | |||||
float maxover; | |||||
float maxunder; | |||||
float maxerr; | |||||
float twofitweight; | |||||
float twofitatten; | |||||
int n; | |||||
} vorbis_info_floor1; | |||||
/* Residue backend generic *****************************************/ | |||||
typedef struct{ | |||||
void (*pack) (vorbis_info_residue *,oggpack_buffer *); | |||||
vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *); | |||||
vorbis_look_residue *(*look) (vorbis_dsp_state *, | |||||
vorbis_info_residue *); | |||||
void (*free_info) (vorbis_info_residue *); | |||||
void (*free_look) (vorbis_look_residue *); | |||||
long **(*classx) (struct vorbis_block *,vorbis_look_residue *, | |||||
int **,int *,int); | |||||
int (*forward) (oggpack_buffer *,struct vorbis_block *, | |||||
vorbis_look_residue *, | |||||
int **,int *,int,long **,int); | |||||
int (*inverse) (struct vorbis_block *,vorbis_look_residue *, | |||||
float **,int *,int); | |||||
} vorbis_func_residue; | |||||
typedef struct vorbis_info_residue0{ | |||||
/* block-partitioned VQ coded straight residue */ | |||||
long begin; | |||||
long end; | |||||
/* first stage (lossless partitioning) */ | |||||
int grouping; /* group n vectors per partition */ | |||||
int partitions; /* possible codebooks for a partition */ | |||||
int partvals; /* partitions ^ groupbook dim */ | |||||
int groupbook; /* huffbook for partitioning */ | |||||
int secondstages[64]; /* expanded out to pointers in lookup */ | |||||
int booklist[512]; /* list of second stage books */ | |||||
/*const*/ int classmetric1[64]; | |||||
/*const*/ int classmetric2[64]; | |||||
} vorbis_info_residue0; | |||||
/* Mapping backend generic *****************************************/ | |||||
typedef struct{ | |||||
void (*pack) (vorbis_info *,vorbis_info_mapping *, | |||||
oggpack_buffer *); | |||||
vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *); | |||||
void (*free_info) (vorbis_info_mapping *); | |||||
int (*forward) (struct vorbis_block *vb); | |||||
int (*inverse) (struct vorbis_block *vb,vorbis_info_mapping *); | |||||
} vorbis_func_mapping; | |||||
typedef struct vorbis_info_mapping0{ | |||||
int submaps; /* <= 16 */ | |||||
int chmuxlist[256]; /* up to 256 channels in a Vorbis stream */ | |||||
int floorsubmap[16]; /* [mux] submap to floors */ | |||||
int residuesubmap[16]; /* [mux] submap to residue */ | |||||
int coupling_steps; | |||||
int coupling_mag[256]; | |||||
int coupling_ang[256]; | |||||
} vorbis_info_mapping0; | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: libvorbis backend and mapping structures; needed for | |||||
static mode headers | |||||
********************************************************************/ | |||||
/* this is exposed up here because we need it for static modes. | |||||
Lookups for each backend aren't exposed because there's no reason | |||||
to do so */ | |||||
#ifndef _vorbis_backend_h_ | |||||
#define _vorbis_backend_h_ | |||||
#include "codec_internal.h" | |||||
/* this would all be simpler/shorter with templates, but.... */ | |||||
/* Floor backend generic *****************************************/ | |||||
typedef struct{ | |||||
void (*pack) (vorbis_info_floor *,oggpack_buffer *); | |||||
vorbis_info_floor *(*unpack)(vorbis_info *,oggpack_buffer *); | |||||
vorbis_look_floor *(*look) (vorbis_dsp_state *,vorbis_info_floor *); | |||||
void (*free_info) (vorbis_info_floor *); | |||||
void (*free_look) (vorbis_look_floor *); | |||||
void *(*inverse1) (struct vorbis_block *,vorbis_look_floor *); | |||||
int (*inverse2) (struct vorbis_block *,vorbis_look_floor *, | |||||
void *buffer,float *); | |||||
} vorbis_func_floor; | |||||
typedef struct{ | |||||
int order; | |||||
long rate; | |||||
long barkmap; | |||||
int ampbits; | |||||
int ampdB; | |||||
int numbooks; /* <= 16 */ | |||||
int books[16]; | |||||
float lessthan; /* encode-only config setting hacks for libvorbis */ | |||||
float greaterthan; /* encode-only config setting hacks for libvorbis */ | |||||
} vorbis_info_floor0; | |||||
#define VIF_POSIT 63 | |||||
#define VIF_CLASS 16 | |||||
#define VIF_PARTS 31 | |||||
typedef struct{ | |||||
int partitions; /* 0 to 31 */ | |||||
int partitionclass[VIF_PARTS]; /* 0 to 15 */ | |||||
int class_dim[VIF_CLASS]; /* 1 to 8 */ | |||||
int class_subs[VIF_CLASS]; /* 0,1,2,3 (bits: 1<<n poss) */ | |||||
int class_book[VIF_CLASS]; /* subs ^ dim entries */ | |||||
int class_subbook[VIF_CLASS][8]; /* [VIF_CLASS][subs] */ | |||||
int mult; /* 1 2 3 or 4 */ | |||||
int postlist[VIF_POSIT+2]; /* first two implicit */ | |||||
/* encode side analysis parameters */ | |||||
float maxover; | |||||
float maxunder; | |||||
float maxerr; | |||||
float twofitweight; | |||||
float twofitatten; | |||||
int n; | |||||
} vorbis_info_floor1; | |||||
/* Residue backend generic *****************************************/ | |||||
typedef struct{ | |||||
void (*pack) (vorbis_info_residue *,oggpack_buffer *); | |||||
vorbis_info_residue *(*unpack)(vorbis_info *,oggpack_buffer *); | |||||
vorbis_look_residue *(*look) (vorbis_dsp_state *, | |||||
vorbis_info_residue *); | |||||
void (*free_info) (vorbis_info_residue *); | |||||
void (*free_look) (vorbis_look_residue *); | |||||
long **(*classx) (struct vorbis_block *,vorbis_look_residue *, | |||||
int **,int *,int); | |||||
int (*forward) (oggpack_buffer *,struct vorbis_block *, | |||||
vorbis_look_residue *, | |||||
int **,int *,int,long **,int); | |||||
int (*inverse) (struct vorbis_block *,vorbis_look_residue *, | |||||
float **,int *,int); | |||||
} vorbis_func_residue; | |||||
typedef struct vorbis_info_residue0{ | |||||
/* block-partitioned VQ coded straight residue */ | |||||
long begin; | |||||
long end; | |||||
/* first stage (lossless partitioning) */ | |||||
int grouping; /* group n vectors per partition */ | |||||
int partitions; /* possible codebooks for a partition */ | |||||
int partvals; /* partitions ^ groupbook dim */ | |||||
int groupbook; /* huffbook for partitioning */ | |||||
int secondstages[64]; /* expanded out to pointers in lookup */ | |||||
int booklist[512]; /* list of second stage books */ | |||||
/*const*/ int classmetric1[64]; | |||||
/*const*/ int classmetric2[64]; | |||||
} vorbis_info_residue0; | |||||
/* Mapping backend generic *****************************************/ | |||||
typedef struct{ | |||||
void (*pack) (vorbis_info *,vorbis_info_mapping *, | |||||
oggpack_buffer *); | |||||
vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *); | |||||
void (*free_info) (vorbis_info_mapping *); | |||||
int (*forward) (struct vorbis_block *vb); | |||||
int (*inverse) (struct vorbis_block *vb,vorbis_info_mapping *); | |||||
} vorbis_func_mapping; | |||||
typedef struct vorbis_info_mapping0{ | |||||
int submaps; /* <= 16 */ | |||||
int chmuxlist[256]; /* up to 256 channels in a Vorbis stream */ | |||||
int floorsubmap[16]; /* [mux] submap to floors */ | |||||
int residuesubmap[16]; /* [mux] submap to residue */ | |||||
int coupling_steps; | |||||
int coupling_mag[256]; | |||||
int coupling_ang[256]; | |||||
} vorbis_info_mapping0; | |||||
#endif |
@@ -1,253 +1,252 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: bitrate tracking and management | |||||
last mod: $Id: bitrate.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
#include "bitrate.h" | |||||
/* compute bitrate tracking setup */ | |||||
void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bm){ | |||||
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | |||||
bitrate_manager_info *bi=&ci->bi; | |||||
memset(bm,0,sizeof(*bm)); | |||||
if(bi && (bi->reservoir_bits>0)){ | |||||
long ratesamples=vi->rate; | |||||
int halfsamples=ci->blocksizes[0]>>1; | |||||
bm->short_per_long=ci->blocksizes[1]/ci->blocksizes[0]; | |||||
bm->managed=1; | |||||
bm->avg_bitsper= (int) rint(1.*bi->avg_rate*halfsamples/ratesamples); | |||||
bm->min_bitsper= (int) rint(1.*bi->min_rate*halfsamples/ratesamples); | |||||
bm->max_bitsper= (int) rint(1.*bi->max_rate*halfsamples/ratesamples); | |||||
bm->avgfloat=PACKETBLOBS/2; | |||||
/* not a necessary fix, but one that leads to a more balanced | |||||
typical initialization */ | |||||
{ | |||||
long desired_fill = (long) (bi->reservoir_bits*bi->reservoir_bias); | |||||
bm->minmax_reservoir=desired_fill; | |||||
bm->avg_reservoir=desired_fill; | |||||
} | |||||
} | |||||
} | |||||
void vorbis_bitrate_clear(bitrate_manager_state *bm){ | |||||
memset(bm,0,sizeof(*bm)); | |||||
return; | |||||
} | |||||
int vorbis_bitrate_managed(vorbis_block *vb){ | |||||
vorbis_dsp_state *vd=vb->vd; | |||||
private_state *b=(private_state*)vd->backend_state; | |||||
bitrate_manager_state *bm=&b->bms; | |||||
if(bm && bm->managed)return(1); | |||||
return(0); | |||||
} | |||||
/* finish taking in the block we just processed */ | |||||
int vorbis_bitrate_addblock(vorbis_block *vb){ | |||||
vorbis_block_internal *vbi=(vorbis_block_internal*)vb->internal; | |||||
vorbis_dsp_state *vd=vb->vd; | |||||
private_state *b=(private_state*)vd->backend_state; | |||||
bitrate_manager_state *bm=&b->bms; | |||||
vorbis_info *vi=vd->vi; | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
bitrate_manager_info *bi=&ci->bi; | |||||
int choice = (int) rint(bm->avgfloat); | |||||
long this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
long min_target_bits=(vb->W?bm->min_bitsper*bm->short_per_long:bm->min_bitsper); | |||||
long max_target_bits=(vb->W?bm->max_bitsper*bm->short_per_long:bm->max_bitsper); | |||||
int samples=ci->blocksizes[vb->W]>>1; | |||||
long desired_fill = (long) (bi->reservoir_bits*bi->reservoir_bias); | |||||
if(!bm->managed){ | |||||
/* not a bitrate managed stream, but for API simplicity, we'll | |||||
buffer the packet to keep the code path clean */ | |||||
if(bm->vb)return(-1); /* one has been submitted without | |||||
being claimed */ | |||||
bm->vb=vb; | |||||
return(0); | |||||
} | |||||
bm->vb=vb; | |||||
/* look ahead for avg floater */ | |||||
if(bm->avg_bitsper>0){ | |||||
double slew=0.; | |||||
long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper); | |||||
double slewlimit= 15./bi->slew_damp; | |||||
/* choosing a new floater: | |||||
if we're over target, we slew down | |||||
if we're under target, we slew up | |||||
choose slew as follows: look through packetblobs of this frame | |||||
and set slew as the first in the appropriate direction that | |||||
gives us the slew we want. This may mean no slew if delta is | |||||
already favorable. | |||||
Then limit slew to slew max */ | |||||
if(bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){ | |||||
while(choice>0 && this_bits>avg_target_bits && | |||||
bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){ | |||||
choice--; | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
}else if(bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){ | |||||
while(choice+1<PACKETBLOBS && this_bits<avg_target_bits && | |||||
bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){ | |||||
choice++; | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
} | |||||
slew=rint(choice-bm->avgfloat)/samples*vi->rate; | |||||
if(slew<-slewlimit)slew=-slewlimit; | |||||
if(slew>slewlimit)slew=slewlimit; | |||||
choice = (int) rint(bm->avgfloat+= slew/vi->rate*samples); | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
/* enforce min(if used) on the current floater (if used) */ | |||||
if(bm->min_bitsper>0){ | |||||
/* do we need to force the bitrate up? */ | |||||
if(this_bits<min_target_bits){ | |||||
while(bm->minmax_reservoir-(min_target_bits-this_bits)<0){ | |||||
choice++; | |||||
if(choice>=PACKETBLOBS)break; | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
} | |||||
} | |||||
/* enforce max (if used) on the current floater (if used) */ | |||||
if(bm->max_bitsper>0){ | |||||
/* do we need to force the bitrate down? */ | |||||
if(this_bits>max_target_bits){ | |||||
while(bm->minmax_reservoir+(this_bits-max_target_bits)>bi->reservoir_bits){ | |||||
choice--; | |||||
if(choice<0)break; | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
} | |||||
} | |||||
/* Choice of packetblobs now made based on floater, and min/max | |||||
requirements. Now boundary check extreme choices */ | |||||
if(choice<0){ | |||||
/* choosing a smaller packetblob is insufficient to trim bitrate. | |||||
frame will need to be truncated */ | |||||
long maxsize=(max_target_bits+(bi->reservoir_bits-bm->minmax_reservoir))/8; | |||||
bm->choice=choice=0; | |||||
if(oggpack_bytes(vbi->packetblob[choice])>maxsize){ | |||||
oggpack_writetrunc(vbi->packetblob[choice],maxsize*8); | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
}else{ | |||||
long minsize=(min_target_bits-bm->minmax_reservoir+7)/8; | |||||
if(choice>=PACKETBLOBS) | |||||
choice=PACKETBLOBS-1; | |||||
bm->choice=choice; | |||||
/* prop up bitrate according to demand. pad this frame out with zeroes */ | |||||
minsize-=oggpack_bytes(vbi->packetblob[choice]); | |||||
while(minsize-->0)oggpack_write(vbi->packetblob[choice],0,8); | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
/* now we have the final packet and the final packet size. Update statistics */ | |||||
/* min and max reservoir */ | |||||
if(bm->min_bitsper>0 || bm->max_bitsper>0){ | |||||
if(max_target_bits>0 && this_bits>max_target_bits){ | |||||
bm->minmax_reservoir+=(this_bits-max_target_bits); | |||||
}else if(min_target_bits>0 && this_bits<min_target_bits){ | |||||
bm->minmax_reservoir+=(this_bits-min_target_bits); | |||||
}else{ | |||||
/* inbetween; we want to take reservoir toward but not past desired_fill */ | |||||
if(bm->minmax_reservoir>desired_fill){ | |||||
if(max_target_bits>0){ /* logical bulletproofing against initialization state */ | |||||
bm->minmax_reservoir+=(this_bits-max_target_bits); | |||||
if(bm->minmax_reservoir<desired_fill)bm->minmax_reservoir=desired_fill; | |||||
}else{ | |||||
bm->minmax_reservoir=desired_fill; | |||||
} | |||||
}else{ | |||||
if(min_target_bits>0){ /* logical bulletproofing against initialization state */ | |||||
bm->minmax_reservoir+=(this_bits-min_target_bits); | |||||
if(bm->minmax_reservoir>desired_fill)bm->minmax_reservoir=desired_fill; | |||||
}else{ | |||||
bm->minmax_reservoir=desired_fill; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
/* avg reservoir */ | |||||
if(bm->avg_bitsper>0){ | |||||
long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper); | |||||
bm->avg_reservoir+=this_bits-avg_target_bits; | |||||
} | |||||
return(0); | |||||
} | |||||
int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,ogg_packet *op){ | |||||
private_state *b=(private_state*)vd->backend_state; | |||||
bitrate_manager_state *bm=&b->bms; | |||||
vorbis_block *vb=bm->vb; | |||||
int choice=PACKETBLOBS/2; | |||||
if(!vb)return 0; | |||||
if(op){ | |||||
vorbis_block_internal *vbi=(vorbis_block_internal*)vb->internal; | |||||
if(vorbis_bitrate_managed(vb)) | |||||
choice=bm->choice; | |||||
op->packet=oggpack_get_buffer(vbi->packetblob[choice]); | |||||
op->bytes=oggpack_bytes(vbi->packetblob[choice]); | |||||
op->b_o_s=0; | |||||
op->e_o_s=vb->eofflag; | |||||
op->granulepos=vb->granulepos; | |||||
op->packetno=vb->sequence; /* for sake of completeness */ | |||||
} | |||||
bm->vb=0; | |||||
return(1); | |||||
} | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: bitrate tracking and management | |||||
********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
#include "bitrate.h" | |||||
/* compute bitrate tracking setup */ | |||||
void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bm){ | |||||
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | |||||
bitrate_manager_info *bi=&ci->bi; | |||||
memset(bm,0,sizeof(*bm)); | |||||
if(bi && (bi->reservoir_bits>0)){ | |||||
long ratesamples=vi->rate; | |||||
int halfsamples=ci->blocksizes[0]>>1; | |||||
bm->short_per_long=ci->blocksizes[1]/ci->blocksizes[0]; | |||||
bm->managed=1; | |||||
bm->avg_bitsper= (int) rint(1.*bi->avg_rate*halfsamples/ratesamples); | |||||
bm->min_bitsper= (int) rint(1.*bi->min_rate*halfsamples/ratesamples); | |||||
bm->max_bitsper= (int) rint(1.*bi->max_rate*halfsamples/ratesamples); | |||||
bm->avgfloat=PACKETBLOBS/2; | |||||
/* not a necessary fix, but one that leads to a more balanced | |||||
typical initialization */ | |||||
{ | |||||
long desired_fill = (long) (bi->reservoir_bits*bi->reservoir_bias); | |||||
bm->minmax_reservoir=desired_fill; | |||||
bm->avg_reservoir=desired_fill; | |||||
} | |||||
} | |||||
} | |||||
void vorbis_bitrate_clear(bitrate_manager_state *bm){ | |||||
memset(bm,0,sizeof(*bm)); | |||||
return; | |||||
} | |||||
int vorbis_bitrate_managed(vorbis_block *vb){ | |||||
vorbis_dsp_state *vd=vb->vd; | |||||
private_state *b=(private_state*)vd->backend_state; | |||||
bitrate_manager_state *bm=&b->bms; | |||||
if(bm && bm->managed)return(1); | |||||
return(0); | |||||
} | |||||
/* finish taking in the block we just processed */ | |||||
int vorbis_bitrate_addblock(vorbis_block *vb){ | |||||
vorbis_block_internal *vbi=(vorbis_block_internal*)vb->internal; | |||||
vorbis_dsp_state *vd=vb->vd; | |||||
private_state *b=(private_state*)vd->backend_state; | |||||
bitrate_manager_state *bm=&b->bms; | |||||
vorbis_info *vi=vd->vi; | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
bitrate_manager_info *bi=&ci->bi; | |||||
int choice = (int) rint(bm->avgfloat); | |||||
long this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
long min_target_bits=(vb->W?bm->min_bitsper*bm->short_per_long:bm->min_bitsper); | |||||
long max_target_bits=(vb->W?bm->max_bitsper*bm->short_per_long:bm->max_bitsper); | |||||
int samples=ci->blocksizes[vb->W]>>1; | |||||
long desired_fill = (long) (bi->reservoir_bits*bi->reservoir_bias); | |||||
if(!bm->managed){ | |||||
/* not a bitrate managed stream, but for API simplicity, we'll | |||||
buffer the packet to keep the code path clean */ | |||||
if(bm->vb)return(-1); /* one has been submitted without | |||||
being claimed */ | |||||
bm->vb=vb; | |||||
return(0); | |||||
} | |||||
bm->vb=vb; | |||||
/* look ahead for avg floater */ | |||||
if(bm->avg_bitsper>0){ | |||||
double slew=0.; | |||||
long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper); | |||||
double slewlimit= 15./bi->slew_damp; | |||||
/* choosing a new floater: | |||||
if we're over target, we slew down | |||||
if we're under target, we slew up | |||||
choose slew as follows: look through packetblobs of this frame | |||||
and set slew as the first in the appropriate direction that | |||||
gives us the slew we want. This may mean no slew if delta is | |||||
already favorable. | |||||
Then limit slew to slew max */ | |||||
if(bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){ | |||||
while(choice>0 && this_bits>avg_target_bits && | |||||
bm->avg_reservoir+(this_bits-avg_target_bits)>desired_fill){ | |||||
choice--; | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
}else if(bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){ | |||||
while(choice+1<PACKETBLOBS && this_bits<avg_target_bits && | |||||
bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){ | |||||
choice++; | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
} | |||||
slew=rint(choice-bm->avgfloat)/samples*vi->rate; | |||||
if(slew<-slewlimit)slew=-slewlimit; | |||||
if(slew>slewlimit)slew=slewlimit; | |||||
choice = (int) rint(bm->avgfloat+= slew/vi->rate*samples); | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
/* enforce min(if used) on the current floater (if used) */ | |||||
if(bm->min_bitsper>0){ | |||||
/* do we need to force the bitrate up? */ | |||||
if(this_bits<min_target_bits){ | |||||
while(bm->minmax_reservoir-(min_target_bits-this_bits)<0){ | |||||
choice++; | |||||
if(choice>=PACKETBLOBS)break; | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
} | |||||
} | |||||
/* enforce max (if used) on the current floater (if used) */ | |||||
if(bm->max_bitsper>0){ | |||||
/* do we need to force the bitrate down? */ | |||||
if(this_bits>max_target_bits){ | |||||
while(bm->minmax_reservoir+(this_bits-max_target_bits)>bi->reservoir_bits){ | |||||
choice--; | |||||
if(choice<0)break; | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
} | |||||
} | |||||
/* Choice of packetblobs now made based on floater, and min/max | |||||
requirements. Now boundary check extreme choices */ | |||||
if(choice<0){ | |||||
/* choosing a smaller packetblob is insufficient to trim bitrate. | |||||
frame will need to be truncated */ | |||||
long maxsize=(max_target_bits+(bi->reservoir_bits-bm->minmax_reservoir))/8; | |||||
bm->choice=choice=0; | |||||
if(oggpack_bytes(vbi->packetblob[choice])>maxsize){ | |||||
oggpack_writetrunc(vbi->packetblob[choice],maxsize*8); | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
}else{ | |||||
long minsize=(min_target_bits-bm->minmax_reservoir+7)/8; | |||||
if(choice>=PACKETBLOBS) | |||||
choice=PACKETBLOBS-1; | |||||
bm->choice=choice; | |||||
/* prop up bitrate according to demand. pad this frame out with zeroes */ | |||||
minsize-=oggpack_bytes(vbi->packetblob[choice]); | |||||
while(minsize-->0)oggpack_write(vbi->packetblob[choice],0,8); | |||||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||||
} | |||||
/* now we have the final packet and the final packet size. Update statistics */ | |||||
/* min and max reservoir */ | |||||
if(bm->min_bitsper>0 || bm->max_bitsper>0){ | |||||
if(max_target_bits>0 && this_bits>max_target_bits){ | |||||
bm->minmax_reservoir+=(this_bits-max_target_bits); | |||||
}else if(min_target_bits>0 && this_bits<min_target_bits){ | |||||
bm->minmax_reservoir+=(this_bits-min_target_bits); | |||||
}else{ | |||||
/* inbetween; we want to take reservoir toward but not past desired_fill */ | |||||
if(bm->minmax_reservoir>desired_fill){ | |||||
if(max_target_bits>0){ /* logical bulletproofing against initialization state */ | |||||
bm->minmax_reservoir+=(this_bits-max_target_bits); | |||||
if(bm->minmax_reservoir<desired_fill)bm->minmax_reservoir=desired_fill; | |||||
}else{ | |||||
bm->minmax_reservoir=desired_fill; | |||||
} | |||||
}else{ | |||||
if(min_target_bits>0){ /* logical bulletproofing against initialization state */ | |||||
bm->minmax_reservoir+=(this_bits-min_target_bits); | |||||
if(bm->minmax_reservoir>desired_fill)bm->minmax_reservoir=desired_fill; | |||||
}else{ | |||||
bm->minmax_reservoir=desired_fill; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
/* avg reservoir */ | |||||
if(bm->avg_bitsper>0){ | |||||
long avg_target_bits=(vb->W?bm->avg_bitsper*bm->short_per_long:bm->avg_bitsper); | |||||
bm->avg_reservoir+=this_bits-avg_target_bits; | |||||
} | |||||
return(0); | |||||
} | |||||
int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,ogg_packet *op){ | |||||
private_state *b=(private_state*)vd->backend_state; | |||||
bitrate_manager_state *bm=&b->bms; | |||||
vorbis_block *vb=bm->vb; | |||||
int choice=PACKETBLOBS/2; | |||||
if(!vb)return 0; | |||||
if(op){ | |||||
vorbis_block_internal *vbi=(vorbis_block_internal*)vb->internal; | |||||
if(vorbis_bitrate_managed(vb)) | |||||
choice=bm->choice; | |||||
op->packet=oggpack_get_buffer(vbi->packetblob[choice]); | |||||
op->bytes=oggpack_bytes(vbi->packetblob[choice]); | |||||
op->b_o_s=0; | |||||
op->e_o_s=vb->eofflag; | |||||
op->granulepos=vb->granulepos; | |||||
op->packetno=vb->sequence; /* for sake of completeness */ | |||||
} | |||||
bm->vb=0; | |||||
return(1); | |||||
} |
@@ -1,59 +1,58 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: bitrate tracking and management | |||||
last mod: $Id: bitrate.h 13293 2007-07-24 00:09:47Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_BITRATE_H_ | |||||
#define _V_BITRATE_H_ | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "os.h" | |||||
/* encode side bitrate tracking */ | |||||
typedef struct bitrate_manager_state { | |||||
int managed; | |||||
long avg_reservoir; | |||||
long minmax_reservoir; | |||||
long avg_bitsper; | |||||
long min_bitsper; | |||||
long max_bitsper; | |||||
long short_per_long; | |||||
double avgfloat; | |||||
vorbis_block *vb; | |||||
int choice; | |||||
} bitrate_manager_state; | |||||
typedef struct bitrate_manager_info{ | |||||
long avg_rate; | |||||
long min_rate; | |||||
long max_rate; | |||||
long reservoir_bits; | |||||
double reservoir_bias; | |||||
double slew_damp; | |||||
} bitrate_manager_info; | |||||
extern void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bs); | |||||
extern void vorbis_bitrate_clear(bitrate_manager_state *bs); | |||||
extern int vorbis_bitrate_managed(vorbis_block *vb); | |||||
extern int vorbis_bitrate_addblock(vorbis_block *vb); | |||||
extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, ogg_packet *op); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: bitrate tracking and management | |||||
********************************************************************/ | |||||
#ifndef _V_BITRATE_H_ | |||||
#define _V_BITRATE_H_ | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "os.h" | |||||
/* encode side bitrate tracking */ | |||||
typedef struct bitrate_manager_state { | |||||
int managed; | |||||
long avg_reservoir; | |||||
long minmax_reservoir; | |||||
long avg_bitsper; | |||||
long min_bitsper; | |||||
long max_bitsper; | |||||
long short_per_long; | |||||
double avgfloat; | |||||
vorbis_block *vb; | |||||
int choice; | |||||
} bitrate_manager_state; | |||||
typedef struct bitrate_manager_info{ | |||||
long avg_rate; | |||||
long min_rate; | |||||
long max_rate; | |||||
long reservoir_bits; | |||||
double reservoir_bias; | |||||
double slew_damp; | |||||
} bitrate_manager_info; | |||||
extern void vorbis_bitrate_init(vorbis_info *vi,bitrate_manager_state *bs); | |||||
extern void vorbis_bitrate_clear(bitrate_manager_state *bs); | |||||
extern int vorbis_bitrate_managed(vorbis_block *vb); | |||||
extern int vorbis_bitrate_addblock(vorbis_block *vb); | |||||
extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, ogg_packet *op); | |||||
#endif |
@@ -1,451 +1,461 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: basic codebook pack/unpack/code/decode operations | |||||
last mod: $Id: codebook.c 17553 2010-10-21 17:54:26Z tterribe $ | |||||
********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codebook.h" | |||||
#include "scales.h" | |||||
#include "misc.h" | |||||
#include "os.h" | |||||
/* packs the given codebook into the bitstream **************************/ | |||||
int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){ | |||||
long i,j; | |||||
int ordered=0; | |||||
/* first the basic parameters */ | |||||
oggpack_write(opb,0x564342,24); | |||||
oggpack_write(opb,c->dim,16); | |||||
oggpack_write(opb,c->entries,24); | |||||
/* pack the codewords. There are two packings; length ordered and | |||||
length random. Decide between the two now. */ | |||||
for(i=1;i<c->entries;i++) | |||||
if(c->lengthlist[i-1]==0 || c->lengthlist[i]<c->lengthlist[i-1])break; | |||||
if(i==c->entries)ordered=1; | |||||
if(ordered){ | |||||
/* length ordered. We only need to say how many codewords of | |||||
each length. The actual codewords are generated | |||||
deterministically */ | |||||
long count=0; | |||||
oggpack_write(opb,1,1); /* ordered */ | |||||
oggpack_write(opb,c->lengthlist[0]-1,5); /* 1 to 32 */ | |||||
for(i=1;i<c->entries;i++){ | |||||
long thisx=c->lengthlist[i]; | |||||
long last=c->lengthlist[i-1]; | |||||
if(thisx>last){ | |||||
for(j=last;j<thisx;j++){ | |||||
oggpack_write(opb,i-count,_ilog(c->entries-count)); | |||||
count=i; | |||||
} | |||||
} | |||||
} | |||||
oggpack_write(opb,i-count,_ilog(c->entries-count)); | |||||
}else{ | |||||
/* length random. Again, we don't code the codeword itself, just | |||||
the length. This time, though, we have to encode each length */ | |||||
oggpack_write(opb,0,1); /* unordered */ | |||||
/* algortihmic mapping has use for 'unused entries', which we tag | |||||
here. The algorithmic mapping happens as usual, but the unused | |||||
entry has no codeword. */ | |||||
for(i=0;i<c->entries;i++) | |||||
if(c->lengthlist[i]==0)break; | |||||
if(i==c->entries){ | |||||
oggpack_write(opb,0,1); /* no unused entries */ | |||||
for(i=0;i<c->entries;i++) | |||||
oggpack_write(opb,c->lengthlist[i]-1,5); | |||||
}else{ | |||||
oggpack_write(opb,1,1); /* we have unused entries; thus we tag */ | |||||
for(i=0;i<c->entries;i++){ | |||||
if(c->lengthlist[i]==0){ | |||||
oggpack_write(opb,0,1); | |||||
}else{ | |||||
oggpack_write(opb,1,1); | |||||
oggpack_write(opb,c->lengthlist[i]-1,5); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
/* is the entry number the desired return value, or do we have a | |||||
mapping? If we have a mapping, what type? */ | |||||
oggpack_write(opb,c->maptype,4); | |||||
switch(c->maptype){ | |||||
case 0: | |||||
/* no mapping */ | |||||
break; | |||||
case 1:case 2: | |||||
/* implicitly populated value mapping */ | |||||
/* explicitly populated value mapping */ | |||||
if(!c->quantlist){ | |||||
/* no quantlist? error */ | |||||
return(-1); | |||||
} | |||||
/* values that define the dequantization */ | |||||
oggpack_write(opb,c->q_min,32); | |||||
oggpack_write(opb,c->q_delta,32); | |||||
oggpack_write(opb,c->q_quant-1,4); | |||||
oggpack_write(opb,c->q_sequencep,1); | |||||
{ | |||||
int quantvals; | |||||
switch(c->maptype){ | |||||
case 1: | |||||
/* a single column of (c->entries/c->dim) quantized values for | |||||
building a full value list algorithmically (square lattice) */ | |||||
quantvals=_book_maptype1_quantvals(c); | |||||
break; | |||||
case 2: | |||||
/* every value (c->entries*c->dim total) specified explicitly */ | |||||
quantvals=c->entries*c->dim; | |||||
break; | |||||
default: /* NOT_REACHABLE */ | |||||
quantvals=-1; | |||||
} | |||||
/* quantized values */ | |||||
for(i=0;i<quantvals;i++) | |||||
oggpack_write(opb,labs(c->quantlist[i]),c->q_quant); | |||||
} | |||||
break; | |||||
default: | |||||
/* error case; we don't have any other map types now */ | |||||
return(-1); | |||||
} | |||||
return(0); | |||||
} | |||||
/* unpacks a codebook from the packet buffer into the codebook struct, | |||||
readies the codebook auxiliary structures for decode *************/ | |||||
static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){ | |||||
long i,j; | |||||
static_codebook *s=(static_codebook*)_ogg_calloc(1,sizeof(*s)); | |||||
s->allocedp=1; | |||||
/* make sure alignment is correct */ | |||||
if(oggpack_read(opb,24)!=0x564342)goto _eofout; | |||||
/* first the basic parameters */ | |||||
s->dim=oggpack_read(opb,16); | |||||
s->entries=oggpack_read(opb,24); | |||||
if(s->entries==-1)goto _eofout; | |||||
if(_ilog(s->dim)+_ilog(s->entries)>24)goto _eofout; | |||||
/* codeword ordering.... length ordered or unordered? */ | |||||
switch((int)oggpack_read(opb,1)){ | |||||
case 0:{ | |||||
long unused; | |||||
/* allocated but unused entries? */ | |||||
unused=oggpack_read(opb,1); | |||||
if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb)) | |||||
goto _eofout; | |||||
/* unordered */ | |||||
s->lengthlist=(long*)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); | |||||
/* allocated but unused entries? */ | |||||
if(unused){ | |||||
/* yes, unused entries */ | |||||
for(i=0;i<s->entries;i++){ | |||||
if(oggpack_read(opb,1)){ | |||||
long num=oggpack_read(opb,5); | |||||
if(num==-1)goto _eofout; | |||||
s->lengthlist[i]=num+1; | |||||
}else | |||||
s->lengthlist[i]=0; | |||||
} | |||||
}else{ | |||||
/* all entries used; no tagging */ | |||||
for(i=0;i<s->entries;i++){ | |||||
long num=oggpack_read(opb,5); | |||||
if(num==-1)goto _eofout; | |||||
s->lengthlist[i]=num+1; | |||||
} | |||||
} | |||||
break; | |||||
} | |||||
case 1: | |||||
/* ordered */ | |||||
{ | |||||
long length=oggpack_read(opb,5)+1; | |||||
if(length==0)goto _eofout; | |||||
s->lengthlist=(long*)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); | |||||
for(i=0;i<s->entries;){ | |||||
long num=oggpack_read(opb,_ilog(s->entries-i)); | |||||
if(num==-1)goto _eofout; | |||||
if(length>32 || num>s->entries-i || | |||||
(num>0 && (num-1)>>(length-1)>1)){ | |||||
goto _errout; | |||||
} | |||||
if(length>32)goto _errout; | |||||
for(j=0;j<num;j++,i++) | |||||
s->lengthlist[i]=length; | |||||
length++; | |||||
} | |||||
} | |||||
break; | |||||
default: | |||||
/* EOF */ | |||||
goto _eofout; | |||||
} | |||||
/* Do we have a mapping to unpack? */ | |||||
switch((s->maptype=oggpack_read(opb,4))){ | |||||
case 0: | |||||
/* no mapping */ | |||||
break; | |||||
case 1: case 2: | |||||
/* implicitly populated value mapping */ | |||||
/* explicitly populated value mapping */ | |||||
s->q_min=oggpack_read(opb,32); | |||||
s->q_delta=oggpack_read(opb,32); | |||||
s->q_quant=oggpack_read(opb,4)+1; | |||||
s->q_sequencep=oggpack_read(opb,1); | |||||
if(s->q_sequencep==-1)goto _eofout; | |||||
{ | |||||
int quantvals=0; | |||||
switch(s->maptype){ | |||||
case 1: | |||||
quantvals=(s->dim==0?0:_book_maptype1_quantvals(s)); | |||||
break; | |||||
case 2: | |||||
quantvals=s->entries*s->dim; | |||||
break; | |||||
} | |||||
/* quantized values */ | |||||
if(((quantvals * s->q_quant + 7) >> 3) > opb->storage-oggpack_bytes(opb)) | |||||
goto _eofout; | |||||
s->quantlist=(long*)_ogg_malloc(sizeof(*s->quantlist)*quantvals); | |||||
for(i=0;i<quantvals;i++) | |||||
s->quantlist[i]=oggpack_read(opb,s->q_quant); | |||||
if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; | |||||
} | |||||
break; | |||||
default: | |||||
goto _errout; | |||||
} | |||||
/* all set */ | |||||
return(s); | |||||
_errout: | |||||
_eofout: | |||||
vorbis_staticbook_destroy(s); | |||||
return(NULL); | |||||
} | |||||
/* returns the number of bits ************************************************/ | |||||
int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){ | |||||
if(a<0 || a>=book->c->entries)return(0); | |||||
oggpack_write(b,book->codelist[a],book->c->lengthlist[a]); | |||||
return(book->c->lengthlist[a]); | |||||
} | |||||
/* the 'eliminate the decode tree' optimization actually requires the | |||||
codewords to be MSb first, not LSb. This is an annoying inelegancy | |||||
(and one of the first places where carefully thought out design | |||||
turned out to be wrong; Vorbis II and future Ogg codecs should go | |||||
to an MSb bitpacker), but not actually the huge hit it appears to | |||||
be. The first-stage decode table catches most words so that | |||||
bitreverse is not in the main execution path. */ | |||||
static ogg_uint32_t bitreverse(ogg_uint32_t x){ | |||||
x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000); | |||||
x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00); | |||||
x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0); | |||||
x= ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc); | |||||
return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa); | |||||
} | |||||
STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){ | |||||
int read=book->dec_maxlength; | |||||
long lo,hi; | |||||
long lok = oggpack_look(b,book->dec_firsttablen); | |||||
if (lok >= 0) { | |||||
long entry = book->dec_firsttable[lok]; | |||||
if(entry&0x80000000UL){ | |||||
lo=(entry>>15)&0x7fff; | |||||
hi=book->used_entries-(entry&0x7fff); | |||||
}else{ | |||||
oggpack_adv(b, book->dec_codelengths[entry-1]); | |||||
return(entry-1); | |||||
} | |||||
}else{ | |||||
lo=0; | |||||
hi=book->used_entries; | |||||
} | |||||
lok = oggpack_look(b, read); | |||||
while(lok<0 && read>1) | |||||
lok = oggpack_look(b, --read); | |||||
if(lok<0)return -1; | |||||
/* bisect search for the codeword in the ordered list */ | |||||
{ | |||||
ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok); | |||||
while(hi-lo>1){ | |||||
long p=(hi-lo)>>1; | |||||
long test=book->codelist[lo+p]>testword; | |||||
lo+=p&(test-1); | |||||
hi-=p&(-test); | |||||
} | |||||
if(book->dec_codelengths[lo]<=read){ | |||||
oggpack_adv(b, book->dec_codelengths[lo]); | |||||
return(lo); | |||||
} | |||||
} | |||||
oggpack_adv(b, read); | |||||
return(-1); | |||||
} | |||||
/* Decode side is specced and easier, because we don't need to find | |||||
matches using different criteria; we simply read and map. There are | |||||
two things we need to do 'depending': | |||||
We may need to support interleave. We don't really, but it's | |||||
convenient to do it here rather than rebuild the vector later. | |||||
Cascades may be additive or multiplicitive; this is not inherent in | |||||
the codebook, but set in the code using the codebook. Like | |||||
interleaving, it's easiest to do it here. | |||||
addmul==0 -> declarative (set the value) | |||||
addmul==1 -> additive | |||||
addmul==2 -> multiplicitive */ | |||||
/* returns the [original, not compacted] entry number or -1 on eof *********/ | |||||
long vorbis_book_decode(codebook *book, oggpack_buffer *b){ | |||||
if(book->used_entries>0){ | |||||
long packed_entry=decode_packed_entry_number(book,b); | |||||
if(packed_entry>=0) | |||||
return(book->dec_index[packed_entry]); | |||||
} | |||||
/* if there's no dec_index, the codebook unpacking isn't collapsed */ | |||||
return(-1); | |||||
} | |||||
/* returns 0 on OK or -1 on eof *************************************/ | |||||
long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){ | |||||
if(book->used_entries>0){ | |||||
int step=n/book->dim; | |||||
long *entry = (long*)alloca(sizeof(*entry)*step); | |||||
float **t = (float**)alloca(sizeof(*t)*step); | |||||
int i,j,o; | |||||
for (i = 0; i < step; i++) { | |||||
entry[i]=decode_packed_entry_number(book,b); | |||||
if(entry[i]==-1)return(-1); | |||||
t[i] = book->valuelist+entry[i]*book->dim; | |||||
} | |||||
for(i=0,o=0;i<book->dim;i++,o+=step) | |||||
for (j=0;o+j<n && j<step;j++) | |||||
a[o+j]+=t[j][i]; | |||||
} | |||||
return(0); | |||||
} | |||||
long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){ | |||||
if(book->used_entries>0){ | |||||
int i,j,entry; | |||||
float *t; | |||||
for(i=0;i<n;){ | |||||
entry = decode_packed_entry_number(book,b); | |||||
if(entry==-1)return(-1); | |||||
t = book->valuelist+entry*book->dim; | |||||
for(j=0;i<n && j<book->dim;) | |||||
a[i++]+=t[j++]; | |||||
} | |||||
} | |||||
return(0); | |||||
} | |||||
long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){ | |||||
if(book->used_entries>0){ | |||||
int i,j,entry; | |||||
float *t; | |||||
for(i=0;i<n;){ | |||||
entry = decode_packed_entry_number(book,b); | |||||
if(entry==-1)return(-1); | |||||
t = book->valuelist+entry*book->dim; | |||||
for (j=0;j<book->dim;) | |||||
a[i++]=t[j++]; | |||||
} | |||||
}else{ | |||||
int i,j; | |||||
for(i=0;i<n;){ | |||||
for (j=0;j<book->dim;) | |||||
a[i++]=0.f; | |||||
} | |||||
} | |||||
return(0); | |||||
} | |||||
long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch, | |||||
oggpack_buffer *b,int n){ | |||||
long i,j,entry; | |||||
int chptr=0; | |||||
if(book->used_entries>0){ | |||||
int m=(offset+n)/ch; | |||||
for(i=offset/ch;i<m;){ | |||||
entry = decode_packed_entry_number(book,b); | |||||
if(entry==-1)return(-1); | |||||
{ | |||||
const float *t = book->valuelist+entry*book->dim; | |||||
for (j=0;i<m && j<book->dim;j++){ | |||||
a[chptr++][i]+=t[j]; | |||||
if(chptr==ch){ | |||||
chptr=0; | |||||
i++; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return(0); | |||||
} | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: basic codebook pack/unpack/code/decode operations | |||||
********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codebook.h" | |||||
#include "scales.h" | |||||
#include "misc.h" | |||||
#include "os.h" | |||||
/* packs the given codebook into the bitstream **************************/ | |||||
int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){ | |||||
long i,j; | |||||
int ordered=0; | |||||
/* first the basic parameters */ | |||||
oggpack_write(opb,0x564342,24); | |||||
oggpack_write(opb,c->dim,16); | |||||
oggpack_write(opb,c->entries,24); | |||||
/* pack the codewords. There are two packings; length ordered and | |||||
length random. Decide between the two now. */ | |||||
for(i=1;i<c->entries;i++) | |||||
if(c->lengthlist[i-1]==0 || c->lengthlist[i]<c->lengthlist[i-1])break; | |||||
if(i==c->entries)ordered=1; | |||||
if(ordered){ | |||||
/* length ordered. We only need to say how many codewords of | |||||
each length. The actual codewords are generated | |||||
deterministically */ | |||||
long count=0; | |||||
oggpack_write(opb,1,1); /* ordered */ | |||||
oggpack_write(opb,c->lengthlist[0]-1,5); /* 1 to 32 */ | |||||
for(i=1;i<c->entries;i++){ | |||||
char thisx=c->lengthlist[i]; | |||||
char last=c->lengthlist[i-1]; | |||||
if(thisx>last){ | |||||
for(j=last;j<thisx;j++){ | |||||
oggpack_write(opb,i-count,ov_ilog(c->entries-count)); | |||||
count=i; | |||||
} | |||||
} | |||||
} | |||||
oggpack_write(opb,i-count,ov_ilog(c->entries-count)); | |||||
}else{ | |||||
/* length random. Again, we don't code the codeword itself, just | |||||
the length. This time, though, we have to encode each length */ | |||||
oggpack_write(opb,0,1); /* unordered */ | |||||
/* algortihmic mapping has use for 'unused entries', which we tag | |||||
here. The algorithmic mapping happens as usual, but the unused | |||||
entry has no codeword. */ | |||||
for(i=0;i<c->entries;i++) | |||||
if(c->lengthlist[i]==0)break; | |||||
if(i==c->entries){ | |||||
oggpack_write(opb,0,1); /* no unused entries */ | |||||
for(i=0;i<c->entries;i++) | |||||
oggpack_write(opb,c->lengthlist[i]-1,5); | |||||
}else{ | |||||
oggpack_write(opb,1,1); /* we have unused entries; thus we tag */ | |||||
for(i=0;i<c->entries;i++){ | |||||
if(c->lengthlist[i]==0){ | |||||
oggpack_write(opb,0,1); | |||||
}else{ | |||||
oggpack_write(opb,1,1); | |||||
oggpack_write(opb,c->lengthlist[i]-1,5); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
/* is the entry number the desired return value, or do we have a | |||||
mapping? If we have a mapping, what type? */ | |||||
oggpack_write(opb,c->maptype,4); | |||||
switch(c->maptype){ | |||||
case 0: | |||||
/* no mapping */ | |||||
break; | |||||
case 1:case 2: | |||||
/* implicitly populated value mapping */ | |||||
/* explicitly populated value mapping */ | |||||
if(!c->quantlist){ | |||||
/* no quantlist? error */ | |||||
return(-1); | |||||
} | |||||
/* values that define the dequantization */ | |||||
oggpack_write(opb,c->q_min,32); | |||||
oggpack_write(opb,c->q_delta,32); | |||||
oggpack_write(opb,c->q_quant-1,4); | |||||
oggpack_write(opb,c->q_sequencep,1); | |||||
{ | |||||
int quantvals; | |||||
switch(c->maptype){ | |||||
case 1: | |||||
/* a single column of (c->entries/c->dim) quantized values for | |||||
building a full value list algorithmically (square lattice) */ | |||||
quantvals=_book_maptype1_quantvals(c); | |||||
break; | |||||
case 2: | |||||
/* every value (c->entries*c->dim total) specified explicitly */ | |||||
quantvals=c->entries*c->dim; | |||||
break; | |||||
default: /* NOT_REACHABLE */ | |||||
quantvals=-1; | |||||
} | |||||
/* quantized values */ | |||||
for(i=0;i<quantvals;i++) | |||||
oggpack_write(opb,labs(c->quantlist[i]),c->q_quant); | |||||
} | |||||
break; | |||||
default: | |||||
/* error case; we don't have any other map types now */ | |||||
return(-1); | |||||
} | |||||
return(0); | |||||
} | |||||
/* unpacks a codebook from the packet buffer into the codebook struct, | |||||
readies the codebook auxiliary structures for decode *************/ | |||||
static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){ | |||||
long i,j; | |||||
static_codebook *s=(static_codebook*)_ogg_calloc(1,sizeof(*s)); | |||||
s->allocedp=1; | |||||
/* make sure alignment is correct */ | |||||
if(oggpack_read(opb,24)!=0x564342)goto _eofout; | |||||
/* first the basic parameters */ | |||||
s->dim=oggpack_read(opb,16); | |||||
s->entries=oggpack_read(opb,24); | |||||
if(s->entries==-1)goto _eofout; | |||||
if(ov_ilog(s->dim)+ov_ilog(s->entries)>24)goto _eofout; | |||||
/* codeword ordering.... length ordered or unordered? */ | |||||
switch((int)oggpack_read(opb,1)){ | |||||
case 0:{ | |||||
long unused; | |||||
/* allocated but unused entries? */ | |||||
unused=oggpack_read(opb,1); | |||||
if((s->entries*(unused?1:5)+7)>>3>opb->storage-oggpack_bytes(opb)) | |||||
goto _eofout; | |||||
/* unordered */ | |||||
s->lengthlist=(char*)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); | |||||
/* allocated but unused entries? */ | |||||
if(unused){ | |||||
/* yes, unused entries */ | |||||
for(i=0;i<s->entries;i++){ | |||||
if(oggpack_read(opb,1)){ | |||||
long num=oggpack_read(opb,5); | |||||
if(num==-1)goto _eofout; | |||||
s->lengthlist[i]=num+1; | |||||
}else | |||||
s->lengthlist[i]=0; | |||||
} | |||||
}else{ | |||||
/* all entries used; no tagging */ | |||||
for(i=0;i<s->entries;i++){ | |||||
long num=oggpack_read(opb,5); | |||||
if(num==-1)goto _eofout; | |||||
s->lengthlist[i]=num+1; | |||||
} | |||||
} | |||||
break; | |||||
} | |||||
case 1: | |||||
/* ordered */ | |||||
{ | |||||
long length=oggpack_read(opb,5)+1; | |||||
if(length==0)goto _eofout; | |||||
s->lengthlist=(char*)_ogg_malloc(sizeof(*s->lengthlist)*s->entries); | |||||
for(i=0;i<s->entries;){ | |||||
long num=oggpack_read(opb,ov_ilog(s->entries-i)); | |||||
if(num==-1)goto _eofout; | |||||
if(length>32 || num>s->entries-i || | |||||
(num>0 && (num-1)>>(length-1)>1)){ | |||||
goto _errout; | |||||
} | |||||
if(length>32)goto _errout; | |||||
for(j=0;j<num;j++,i++) | |||||
s->lengthlist[i]=length; | |||||
length++; | |||||
} | |||||
} | |||||
break; | |||||
default: | |||||
/* EOF */ | |||||
goto _eofout; | |||||
} | |||||
/* Do we have a mapping to unpack? */ | |||||
switch((s->maptype=oggpack_read(opb,4))){ | |||||
case 0: | |||||
/* no mapping */ | |||||
break; | |||||
case 1: case 2: | |||||
/* implicitly populated value mapping */ | |||||
/* explicitly populated value mapping */ | |||||
s->q_min=oggpack_read(opb,32); | |||||
s->q_delta=oggpack_read(opb,32); | |||||
s->q_quant=oggpack_read(opb,4)+1; | |||||
s->q_sequencep=oggpack_read(opb,1); | |||||
if(s->q_sequencep==-1)goto _eofout; | |||||
{ | |||||
int quantvals=0; | |||||
switch(s->maptype){ | |||||
case 1: | |||||
quantvals=(s->dim==0?0:_book_maptype1_quantvals(s)); | |||||
break; | |||||
case 2: | |||||
quantvals=s->entries*s->dim; | |||||
break; | |||||
} | |||||
/* quantized values */ | |||||
if(((quantvals*s->q_quant+7)>>3)>opb->storage-oggpack_bytes(opb)) | |||||
goto _eofout; | |||||
s->quantlist=(long*)_ogg_malloc(sizeof(*s->quantlist)*quantvals); | |||||
for(i=0;i<quantvals;i++) | |||||
s->quantlist[i]=oggpack_read(opb,s->q_quant); | |||||
if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; | |||||
} | |||||
break; | |||||
default: | |||||
goto _errout; | |||||
} | |||||
/* all set */ | |||||
return(s); | |||||
_errout: | |||||
_eofout: | |||||
vorbis_staticbook_destroy(s); | |||||
return(NULL); | |||||
} | |||||
/* returns the number of bits ************************************************/ | |||||
int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){ | |||||
if(a<0 || a>=book->c->entries)return(0); | |||||
oggpack_write(b,book->codelist[a],book->c->lengthlist[a]); | |||||
return(book->c->lengthlist[a]); | |||||
} | |||||
/* the 'eliminate the decode tree' optimization actually requires the | |||||
codewords to be MSb first, not LSb. This is an annoying inelegancy | |||||
(and one of the first places where carefully thought out design | |||||
turned out to be wrong; Vorbis II and future Ogg codecs should go | |||||
to an MSb bitpacker), but not actually the huge hit it appears to | |||||
be. The first-stage decode table catches most words so that | |||||
bitreverse is not in the main execution path. */ | |||||
static ogg_uint32_t bitreverse(ogg_uint32_t x){ | |||||
x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000); | |||||
x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00); | |||||
x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0); | |||||
x= ((x>> 2)&0x33333333) | ((x<< 2)&0xcccccccc); | |||||
return((x>> 1)&0x55555555) | ((x<< 1)&0xaaaaaaaa); | |||||
} | |||||
STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){ | |||||
int read=book->dec_maxlength; | |||||
long lo,hi; | |||||
long lok = oggpack_look(b,book->dec_firsttablen); | |||||
if (lok >= 0) { | |||||
long entry = book->dec_firsttable[lok]; | |||||
if(entry&0x80000000UL){ | |||||
lo=(entry>>15)&0x7fff; | |||||
hi=book->used_entries-(entry&0x7fff); | |||||
}else{ | |||||
oggpack_adv(b, book->dec_codelengths[entry-1]); | |||||
return(entry-1); | |||||
} | |||||
}else{ | |||||
lo=0; | |||||
hi=book->used_entries; | |||||
} | |||||
/* Single entry codebooks use a firsttablen of 1 and a | |||||
dec_maxlength of 1. If a single-entry codebook gets here (due to | |||||
failure to read one bit above), the next look attempt will also | |||||
fail and we'll correctly kick out instead of trying to walk the | |||||
underformed tree */ | |||||
lok = oggpack_look(b, read); | |||||
while(lok<0 && read>1) | |||||
lok = oggpack_look(b, --read); | |||||
if(lok<0)return -1; | |||||
/* bisect search for the codeword in the ordered list */ | |||||
{ | |||||
ogg_uint32_t testword=bitreverse((ogg_uint32_t)lok); | |||||
while(hi-lo>1){ | |||||
long p=(hi-lo)>>1; | |||||
long test=book->codelist[lo+p]>testword; | |||||
lo+=p&(test-1); | |||||
hi-=p&(-test); | |||||
} | |||||
if(book->dec_codelengths[lo]<=read){ | |||||
oggpack_adv(b, book->dec_codelengths[lo]); | |||||
return(lo); | |||||
} | |||||
} | |||||
oggpack_adv(b, read); | |||||
return(-1); | |||||
} | |||||
/* Decode side is specced and easier, because we don't need to find | |||||
matches using different criteria; we simply read and map. There are | |||||
two things we need to do 'depending': | |||||
We may need to support interleave. We don't really, but it's | |||||
convenient to do it here rather than rebuild the vector later. | |||||
Cascades may be additive or multiplicitive; this is not inherent in | |||||
the codebook, but set in the code using the codebook. Like | |||||
interleaving, it's easiest to do it here. | |||||
addmul==0 -> declarative (set the value) | |||||
addmul==1 -> additive | |||||
addmul==2 -> multiplicitive */ | |||||
/* returns the [original, not compacted] entry number or -1 on eof *********/ | |||||
long vorbis_book_decode(codebook *book, oggpack_buffer *b){ | |||||
if(book->used_entries>0){ | |||||
long packed_entry=decode_packed_entry_number(book,b); | |||||
if(packed_entry>=0) | |||||
return(book->dec_index[packed_entry]); | |||||
} | |||||
/* if there's no dec_index, the codebook unpacking isn't collapsed */ | |||||
return(-1); | |||||
} | |||||
/* returns 0 on OK or -1 on eof *************************************/ | |||||
/* decode vector / dim granularity gaurding is done in the upper layer */ | |||||
long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){ | |||||
if(book->used_entries>0){ | |||||
int step=n/book->dim; | |||||
long *entry = (long*)alloca(sizeof(*entry)*step); | |||||
float **t = (float**)alloca(sizeof(*t)*step); | |||||
int i,j,o; | |||||
for (i = 0; i < step; i++) { | |||||
entry[i]=decode_packed_entry_number(book,b); | |||||
if(entry[i]==-1)return(-1); | |||||
t[i] = book->valuelist+entry[i]*book->dim; | |||||
} | |||||
for(i=0,o=0;i<book->dim;i++,o+=step) | |||||
for (j=0;o+j<n && j<step;j++) | |||||
a[o+j]+=t[j][i]; | |||||
} | |||||
return(0); | |||||
} | |||||
/* decode vector / dim granularity gaurding is done in the upper layer */ | |||||
long vorbis_book_decodev_add(codebook *book,float *a,oggpack_buffer *b,int n){ | |||||
if(book->used_entries>0){ | |||||
int i,j,entry; | |||||
float *t; | |||||
for(i=0;i<n;){ | |||||
entry = decode_packed_entry_number(book,b); | |||||
if(entry==-1)return(-1); | |||||
t = book->valuelist+entry*book->dim; | |||||
for(j=0;i<n && j<book->dim;) | |||||
a[i++]+=t[j++]; | |||||
} | |||||
} | |||||
return(0); | |||||
} | |||||
/* unlike the others, we guard against n not being an integer number | |||||
of <dim> internally rather than in the upper layer (called only by | |||||
floor0) */ | |||||
long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){ | |||||
if(book->used_entries>0){ | |||||
int i,j,entry; | |||||
float *t; | |||||
for(i=0;i<n;){ | |||||
entry = decode_packed_entry_number(book,b); | |||||
if(entry==-1)return(-1); | |||||
t = book->valuelist+entry*book->dim; | |||||
for (j=0;i<n && j<book->dim;){ | |||||
a[i++]=t[j++]; | |||||
} | |||||
} | |||||
}else{ | |||||
int i; | |||||
for(i=0;i<n;){ | |||||
a[i++]=0.f; | |||||
} | |||||
} | |||||
return(0); | |||||
} | |||||
long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch, | |||||
oggpack_buffer *b,int n){ | |||||
long i,j,entry; | |||||
int chptr=0; | |||||
if(book->used_entries>0){ | |||||
int m=(offset+n)/ch; | |||||
for(i=offset/ch;i<m;){ | |||||
entry = decode_packed_entry_number(book,b); | |||||
if(entry==-1)return(-1); | |||||
{ | |||||
const float *t = book->valuelist+entry*book->dim; | |||||
for (j=0;i<m && j<book->dim;j++){ | |||||
a[chptr++][i]+=t[j]; | |||||
if(chptr==ch){ | |||||
chptr=0; | |||||
i++; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return(0); | |||||
} |
@@ -1,119 +1,117 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: basic shared codebook operations | |||||
last mod: $Id: codebook.h 17030 2010-03-25 06:52:55Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_CODEBOOK_H_ | |||||
#define _V_CODEBOOK_H_ | |||||
#include "../../ogg.h" | |||||
/* This structure encapsulates huffman and VQ style encoding books; it | |||||
doesn't do anything specific to either. | |||||
valuelist/quantlist are nonNULL (and q_* significant) only if | |||||
there's entry->value mapping to be done. | |||||
If encode-side mapping must be done (and thus the entry needs to be | |||||
hunted), the auxiliary encode pointer will point to a decision | |||||
tree. This is true of both VQ and huffman, but is mostly useful | |||||
with VQ. | |||||
*/ | |||||
typedef struct static_codebook{ | |||||
long dim; /* codebook dimensions (elements per vector) */ | |||||
long entries; /* codebook entries */ | |||||
long *lengthlist; /* codeword lengths in bits */ | |||||
/* mapping ***************************************************************/ | |||||
int maptype; /* 0=none | |||||
1=implicitly populated values from map column | |||||
2=listed arbitrary values */ | |||||
/* The below does a linear, single monotonic sequence mapping. */ | |||||
long q_min; /* packed 32 bit float; quant value 0 maps to minval */ | |||||
long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ | |||||
int q_quant; /* bits: 0 < quant <= 16 */ | |||||
int q_sequencep; /* bitflag */ | |||||
long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map | |||||
map == 2: list of dim*entries quantized entry vals | |||||
*/ | |||||
int allocedp; | |||||
} static_codebook; | |||||
typedef struct codebook{ | |||||
long dim; /* codebook dimensions (elements per vector) */ | |||||
long entries; /* codebook entries */ | |||||
long used_entries; /* populated codebook entries */ | |||||
const static_codebook *c; | |||||
/* for encode, the below are entry-ordered, fully populated */ | |||||
/* for decode, the below are ordered by bitreversed codeword and only | |||||
used entries are populated */ | |||||
float *valuelist; /* list of dim*entries actual entry values */ | |||||
ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ | |||||
int *dec_index; /* only used if sparseness collapsed */ | |||||
char *dec_codelengths; | |||||
ogg_uint32_t *dec_firsttable; | |||||
int dec_firsttablen; | |||||
int dec_maxlength; | |||||
/* The current encoder uses only centered, integer-only lattice books. */ | |||||
int quantvals; | |||||
int minval; | |||||
int delta; | |||||
} codebook; | |||||
extern void vorbis_staticbook_destroy(static_codebook *b); | |||||
extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source); | |||||
extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); | |||||
extern void vorbis_book_clear(codebook *b); | |||||
extern float *_book_unquantize(const static_codebook *b,int n,int *map); | |||||
extern float *_book_logdist(const static_codebook *b,float *vals); | |||||
extern float _float32_unpack(long val); | |||||
extern long _float32_pack(float val); | |||||
extern int _best(codebook *book, float *a, int step); | |||||
extern int _ilog(unsigned int v); | |||||
extern long _book_maptype1_quantvals(const static_codebook *b); | |||||
extern int vorbis_book_besterror(codebook *book,float *a,int step,int addmul); | |||||
extern long vorbis_book_codeword(codebook *book,int entry); | |||||
extern long vorbis_book_codelen(codebook *book,int entry); | |||||
extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b); | |||||
extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); | |||||
extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b); | |||||
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); | |||||
extern long vorbis_book_decodevs_add(codebook *book, float *a, | |||||
oggpack_buffer *b,int n); | |||||
extern long vorbis_book_decodev_set(codebook *book, float *a, | |||||
oggpack_buffer *b,int n); | |||||
extern long vorbis_book_decodev_add(codebook *book, float *a, | |||||
oggpack_buffer *b,int n); | |||||
extern long vorbis_book_decodevv_add(codebook *book, float **a, | |||||
long off,int ch, | |||||
oggpack_buffer *b,int n); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: basic shared codebook operations | |||||
********************************************************************/ | |||||
#ifndef _V_CODEBOOK_H_ | |||||
#define _V_CODEBOOK_H_ | |||||
#include "../../ogg.h" | |||||
/* This structure encapsulates huffman and VQ style encoding books; it | |||||
doesn't do anything specific to either. | |||||
valuelist/quantlist are nonNULL (and q_* significant) only if | |||||
there's entry->value mapping to be done. | |||||
If encode-side mapping must be done (and thus the entry needs to be | |||||
hunted), the auxiliary encode pointer will point to a decision | |||||
tree. This is true of both VQ and huffman, but is mostly useful | |||||
with VQ. | |||||
*/ | |||||
typedef struct static_codebook{ | |||||
long dim; /* codebook dimensions (elements per vector) */ | |||||
long entries; /* codebook entries */ | |||||
char *lengthlist; /* codeword lengths in bits */ | |||||
/* mapping ***************************************************************/ | |||||
int maptype; /* 0=none | |||||
1=implicitly populated values from map column | |||||
2=listed arbitrary values */ | |||||
/* The below does a linear, single monotonic sequence mapping. */ | |||||
long q_min; /* packed 32 bit float; quant value 0 maps to minval */ | |||||
long q_delta; /* packed 32 bit float; val 1 - val 0 == delta */ | |||||
int q_quant; /* bits: 0 < quant <= 16 */ | |||||
int q_sequencep; /* bitflag */ | |||||
long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map | |||||
map == 2: list of dim*entries quantized entry vals | |||||
*/ | |||||
int allocedp; | |||||
} static_codebook; | |||||
typedef struct codebook{ | |||||
long dim; /* codebook dimensions (elements per vector) */ | |||||
long entries; /* codebook entries */ | |||||
long used_entries; /* populated codebook entries */ | |||||
const static_codebook *c; | |||||
/* for encode, the below are entry-ordered, fully populated */ | |||||
/* for decode, the below are ordered by bitreversed codeword and only | |||||
used entries are populated */ | |||||
float *valuelist; /* list of dim*entries actual entry values */ | |||||
ogg_uint32_t *codelist; /* list of bitstream codewords for each entry */ | |||||
int *dec_index; /* only used if sparseness collapsed */ | |||||
char *dec_codelengths; | |||||
ogg_uint32_t *dec_firsttable; | |||||
int dec_firsttablen; | |||||
int dec_maxlength; | |||||
/* The current encoder uses only centered, integer-only lattice books. */ | |||||
int quantvals; | |||||
int minval; | |||||
int delta; | |||||
} codebook; | |||||
extern void vorbis_staticbook_destroy(static_codebook *b); | |||||
extern int vorbis_book_init_encode(codebook *dest,const static_codebook *source); | |||||
extern int vorbis_book_init_decode(codebook *dest,const static_codebook *source); | |||||
extern void vorbis_book_clear(codebook *b); | |||||
extern float *_book_unquantize(const static_codebook *b,int n,int *map); | |||||
extern float *_book_logdist(const static_codebook *b,float *vals); | |||||
extern float _float32_unpack(long val); | |||||
extern long _float32_pack(float val); | |||||
extern int _best(codebook *book, float *a, int step); | |||||
extern long _book_maptype1_quantvals(const static_codebook *b); | |||||
extern int vorbis_book_besterror(codebook *book,float *a,int step,int addmul); | |||||
extern long vorbis_book_codeword(codebook *book,int entry); | |||||
extern long vorbis_book_codelen(codebook *book,int entry); | |||||
extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b); | |||||
extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); | |||||
extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b); | |||||
extern long vorbis_book_decode(codebook *book, oggpack_buffer *b); | |||||
extern long vorbis_book_decodevs_add(codebook *book, float *a, | |||||
oggpack_buffer *b,int n); | |||||
extern long vorbis_book_decodev_set(codebook *book, float *a, | |||||
oggpack_buffer *b,int n); | |||||
extern long vorbis_book_decodev_add(codebook *book, float *a, | |||||
oggpack_buffer *b,int n); | |||||
extern long vorbis_book_decodevv_add(codebook *book, float **a, | |||||
long off,int ch, | |||||
oggpack_buffer *b,int n); | |||||
#endif |
@@ -1,187 +1,166 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: libvorbis codec headers | |||||
last mod: $Id: codec_internal.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_CODECI_H_ | |||||
#define _V_CODECI_H_ | |||||
#include "envelope.h" | |||||
#include "codebook.h" | |||||
#define BLOCKTYPE_IMPULSE 0 | |||||
#define BLOCKTYPE_PADDING 1 | |||||
#define BLOCKTYPE_TRANSITION 0 | |||||
#define BLOCKTYPE_LONG 1 | |||||
#define PACKETBLOBS 15 | |||||
typedef struct vorbis_block_internal{ | |||||
float **pcmdelay; /* this is a pointer into local storage */ | |||||
float ampmax; | |||||
int blocktype; | |||||
oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed; | |||||
blob [PACKETBLOBS/2] points to | |||||
the oggpack_buffer in the | |||||
main vorbis_block */ | |||||
} vorbis_block_internal; | |||||
typedef void vorbis_look_floor; | |||||
typedef void vorbis_look_residue; | |||||
typedef void vorbis_look_transform; | |||||
/* mode ************************************************************/ | |||||
typedef struct { | |||||
int blockflag; | |||||
int windowtype; | |||||
int transformtype; | |||||
int mapping; | |||||
} vorbis_info_mode; | |||||
typedef void vorbis_info_floor; | |||||
typedef void vorbis_info_residue; | |||||
typedef void vorbis_info_mapping; | |||||
#include "psy.h" | |||||
#include "bitrate.h" | |||||
static int ilog(unsigned int v){ | |||||
int ret=0; | |||||
while(v){ | |||||
ret++; | |||||
v>>=1; | |||||
} | |||||
return(ret); | |||||
} | |||||
static int ilog2(unsigned int v){ | |||||
int ret=0; | |||||
if(v)--v; | |||||
while(v){ | |||||
ret++; | |||||
v>>=1; | |||||
} | |||||
return(ret); | |||||
} | |||||
typedef struct private_state { | |||||
/* local lookup storage */ | |||||
envelope_lookup *ve; /* envelope lookup */ | |||||
int window[2]; | |||||
vorbis_look_transform **transform[2]; /* block, type */ | |||||
drft_lookup fft_look[2]; | |||||
int modebits; | |||||
vorbis_look_floor **flr; | |||||
vorbis_look_residue **residue; | |||||
vorbis_look_psy *psy; | |||||
vorbis_look_psy_global *psy_g_look; | |||||
/* local storage, only used on the encoding side. This way the | |||||
application does not need to worry about freeing some packets' | |||||
memory and not others'; packet storage is always tracked. | |||||
Cleared next call to a _dsp_ function */ | |||||
unsigned char *header; | |||||
unsigned char *header1; | |||||
unsigned char *header2; | |||||
bitrate_manager_state bms; | |||||
ogg_int64_t sample_count; | |||||
} private_state; | |||||
/* codec_setup_info contains all the setup information specific to the | |||||
specific compression/decompression mode in progress (eg, | |||||
psychoacoustic settings, channel setup, options, codebook | |||||
etc). | |||||
*********************************************************************/ | |||||
#include "highlevel.h" | |||||
typedef struct codec_setup_info { | |||||
/* Vorbis supports only short and long blocks, but allows the | |||||
encoder to choose the sizes */ | |||||
long blocksizes[2]; | |||||
/* modes are the primary means of supporting on-the-fly different | |||||
blocksizes, different channel mappings (LR or M/A), | |||||
different residue backends, etc. Each mode consists of a | |||||
blocksize flag and a mapping (along with the mapping setup */ | |||||
int modes; | |||||
int maps; | |||||
int floors; | |||||
int residues; | |||||
int books; | |||||
int psys; /* encode only */ | |||||
vorbis_info_mode *mode_param[64]; | |||||
int map_type[64]; | |||||
vorbis_info_mapping *map_param[64]; | |||||
int floor_type[64]; | |||||
vorbis_info_floor *floor_param[64]; | |||||
int residue_type[64]; | |||||
vorbis_info_residue *residue_param[64]; | |||||
static_codebook *book_param[256]; | |||||
codebook *fullbooks; | |||||
vorbis_info_psy *psy_param[4]; /* encode only */ | |||||
vorbis_info_psy_global psy_g_param; | |||||
bitrate_manager_info bi; | |||||
highlevel_encode_setup hi; /* used only by vorbisenc.c. It's a | |||||
highly redundant structure, but | |||||
improves clarity of program flow. */ | |||||
int halfrate_flag; /* painless downsample for decode */ | |||||
} codec_setup_info; | |||||
extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi); | |||||
extern void _vp_global_free(vorbis_look_psy_global *look); | |||||
typedef struct { | |||||
int sorted_index[VIF_POSIT+2]; | |||||
int forward_index[VIF_POSIT+2]; | |||||
int reverse_index[VIF_POSIT+2]; | |||||
int hineighbor[VIF_POSIT]; | |||||
int loneighbor[VIF_POSIT]; | |||||
int posts; | |||||
int n; | |||||
int quant_q; | |||||
vorbis_info_floor1 *vi; | |||||
long phrasebits; | |||||
long postbits; | |||||
long frames; | |||||
} vorbis_look_floor1; | |||||
extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look, | |||||
const float *logmdct, /* in */ | |||||
const float *logmask); | |||||
extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look, | |||||
int *A,int *B, | |||||
int del); | |||||
extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb, | |||||
vorbis_look_floor1 *look, | |||||
int *post,int *ilogmask); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: libvorbis codec headers | |||||
********************************************************************/ | |||||
#ifndef _V_CODECI_H_ | |||||
#define _V_CODECI_H_ | |||||
#include "envelope.h" | |||||
#include "codebook.h" | |||||
#define BLOCKTYPE_IMPULSE 0 | |||||
#define BLOCKTYPE_PADDING 1 | |||||
#define BLOCKTYPE_TRANSITION 0 | |||||
#define BLOCKTYPE_LONG 1 | |||||
#define PACKETBLOBS 15 | |||||
typedef struct vorbis_block_internal{ | |||||
float **pcmdelay; /* this is a pointer into local storage */ | |||||
float ampmax; | |||||
int blocktype; | |||||
oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed; | |||||
blob [PACKETBLOBS/2] points to | |||||
the oggpack_buffer in the | |||||
main vorbis_block */ | |||||
} vorbis_block_internal; | |||||
typedef void vorbis_look_floor; | |||||
typedef void vorbis_look_residue; | |||||
typedef void vorbis_look_transform; | |||||
/* mode ************************************************************/ | |||||
typedef struct { | |||||
int blockflag; | |||||
int windowtype; | |||||
int transformtype; | |||||
int mapping; | |||||
} vorbis_info_mode; | |||||
typedef void vorbis_info_floor; | |||||
typedef void vorbis_info_residue; | |||||
typedef void vorbis_info_mapping; | |||||
#include "psy.h" | |||||
#include "bitrate.h" | |||||
typedef struct private_state { | |||||
/* local lookup storage */ | |||||
envelope_lookup *ve; /* envelope lookup */ | |||||
int window[2]; | |||||
vorbis_look_transform **transform[2]; /* block, type */ | |||||
drft_lookup fft_look[2]; | |||||
int modebits; | |||||
vorbis_look_floor **flr; | |||||
vorbis_look_residue **residue; | |||||
vorbis_look_psy *psy; | |||||
vorbis_look_psy_global *psy_g_look; | |||||
/* local storage, only used on the encoding side. This way the | |||||
application does not need to worry about freeing some packets' | |||||
memory and not others'; packet storage is always tracked. | |||||
Cleared next call to a _dsp_ function */ | |||||
unsigned char *header; | |||||
unsigned char *header1; | |||||
unsigned char *header2; | |||||
bitrate_manager_state bms; | |||||
ogg_int64_t sample_count; | |||||
} private_state; | |||||
/* codec_setup_info contains all the setup information specific to the | |||||
specific compression/decompression mode in progress (eg, | |||||
psychoacoustic settings, channel setup, options, codebook | |||||
etc). | |||||
*********************************************************************/ | |||||
#include "highlevel.h" | |||||
typedef struct codec_setup_info { | |||||
/* Vorbis supports only short and long blocks, but allows the | |||||
encoder to choose the sizes */ | |||||
long blocksizes[2]; | |||||
/* modes are the primary means of supporting on-the-fly different | |||||
blocksizes, different channel mappings (LR or M/A), | |||||
different residue backends, etc. Each mode consists of a | |||||
blocksize flag and a mapping (along with the mapping setup */ | |||||
int modes; | |||||
int maps; | |||||
int floors; | |||||
int residues; | |||||
int books; | |||||
int psys; /* encode only */ | |||||
vorbis_info_mode *mode_param[64]; | |||||
int map_type[64]; | |||||
vorbis_info_mapping *map_param[64]; | |||||
int floor_type[64]; | |||||
vorbis_info_floor *floor_param[64]; | |||||
int residue_type[64]; | |||||
vorbis_info_residue *residue_param[64]; | |||||
static_codebook *book_param[256]; | |||||
codebook *fullbooks; | |||||
vorbis_info_psy *psy_param[4]; /* encode only */ | |||||
vorbis_info_psy_global psy_g_param; | |||||
bitrate_manager_info bi; | |||||
highlevel_encode_setup hi; /* used only by vorbisenc.c. It's a | |||||
highly redundant structure, but | |||||
improves clarity of program flow. */ | |||||
int halfrate_flag; /* painless downsample for decode */ | |||||
} codec_setup_info; | |||||
extern vorbis_look_psy_global *_vp_global_look(vorbis_info *vi); | |||||
extern void _vp_global_free(vorbis_look_psy_global *look); | |||||
typedef struct { | |||||
int sorted_index[VIF_POSIT+2]; | |||||
int forward_index[VIF_POSIT+2]; | |||||
int reverse_index[VIF_POSIT+2]; | |||||
int hineighbor[VIF_POSIT]; | |||||
int loneighbor[VIF_POSIT]; | |||||
int posts; | |||||
int n; | |||||
int quant_q; | |||||
vorbis_info_floor1 *vi; | |||||
long phrasebits; | |||||
long postbits; | |||||
long frames; | |||||
} vorbis_look_floor1; | |||||
extern int *floor1_fit(vorbis_block *vb,vorbis_look_floor1 *look, | |||||
const float *logmdct, /* in */ | |||||
const float *logmask); | |||||
extern int *floor1_interpolate_fit(vorbis_block *vb,vorbis_look_floor1 *look, | |||||
int *A,int *B, | |||||
int del); | |||||
extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb, | |||||
vorbis_look_floor1 *look, | |||||
int *post,int *ilogmask); | |||||
#endif |
@@ -1,375 +1,374 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: PCM data envelope analysis | |||||
last mod: $Id: envelope.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <stdio.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "os.h" | |||||
#include "scales.h" | |||||
#include "envelope.h" | |||||
#include "mdct.h" | |||||
#include "misc.h" | |||||
void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
vorbis_info_psy_global *gi=&ci->psy_g_param; | |||||
int ch=vi->channels; | |||||
int i,j; | |||||
int n=e->winlength=128; | |||||
e->searchstep=64; /* not random */ | |||||
e->minenergy=gi->preecho_minenergy; | |||||
e->ch=ch; | |||||
e->storage=128; | |||||
e->cursor=ci->blocksizes[1]/2; | |||||
e->mdct_win=(float*)_ogg_calloc(n,sizeof(*e->mdct_win)); | |||||
mdct_init(&e->mdct,n); | |||||
for(i=0;i<n;i++){ | |||||
e->mdct_win[i]=sin(i/(n-1.)*M_PI); | |||||
e->mdct_win[i]*=e->mdct_win[i]; | |||||
} | |||||
/* magic follows */ | |||||
e->band[0].begin=2; e->band[0].end=4; | |||||
e->band[1].begin=4; e->band[1].end=5; | |||||
e->band[2].begin=6; e->band[2].end=6; | |||||
e->band[3].begin=9; e->band[3].end=8; | |||||
e->band[4].begin=13; e->band[4].end=8; | |||||
e->band[5].begin=17; e->band[5].end=8; | |||||
e->band[6].begin=22; e->band[6].end=8; | |||||
for(j=0;j<VE_BANDS;j++){ | |||||
n=e->band[j].end; | |||||
e->band[j].window=(float*)_ogg_malloc(n*sizeof(*e->band[0].window)); | |||||
for(i=0;i<n;i++){ | |||||
e->band[j].window[i]=sin((i+.5)/n*M_PI); | |||||
e->band[j].total+=e->band[j].window[i]; | |||||
} | |||||
e->band[j].total=1./e->band[j].total; | |||||
} | |||||
e->filter=(envelope_filter_state*)_ogg_calloc(VE_BANDS*ch,sizeof(*e->filter)); | |||||
e->mark=(int*)_ogg_calloc(e->storage,sizeof(*e->mark)); | |||||
} | |||||
void _ve_envelope_clear(envelope_lookup *e){ | |||||
int i; | |||||
mdct_clear(&e->mdct); | |||||
for(i=0;i<VE_BANDS;i++) | |||||
_ogg_free(e->band[i].window); | |||||
_ogg_free(e->mdct_win); | |||||
_ogg_free(e->filter); | |||||
_ogg_free(e->mark); | |||||
memset(e,0,sizeof(*e)); | |||||
} | |||||
/* fairly straight threshhold-by-band based until we find something | |||||
that works better and isn't patented. */ | |||||
static int _ve_amp(envelope_lookup *ve, | |||||
vorbis_info_psy_global *gi, | |||||
float *data, | |||||
envelope_band *bands, | |||||
envelope_filter_state *filters){ | |||||
long n=ve->winlength; | |||||
int ret=0; | |||||
long i,j; | |||||
float decay; | |||||
/* we want to have a 'minimum bar' for energy, else we're just | |||||
basing blocks on quantization noise that outweighs the signal | |||||
itself (for low power signals) */ | |||||
float minV=ve->minenergy; | |||||
float *vec=(float*) alloca(n*sizeof(*vec)); | |||||
/* stretch is used to gradually lengthen the number of windows | |||||
considered prevoius-to-potential-trigger */ | |||||
int stretch=max(VE_MINSTRETCH,ve->stretch/2); | |||||
float penalty=gi->stretch_penalty-(ve->stretch/2-VE_MINSTRETCH); | |||||
if(penalty<0.f)penalty=0.f; | |||||
if(penalty>gi->stretch_penalty)penalty=gi->stretch_penalty; | |||||
/*_analysis_output_always("lpcm",seq2,data,n,0,0, | |||||
totalshift+pos*ve->searchstep);*/ | |||||
/* window and transform */ | |||||
for(i=0;i<n;i++) | |||||
vec[i]=data[i]*ve->mdct_win[i]; | |||||
mdct_forward(&ve->mdct,vec,vec); | |||||
/*_analysis_output_always("mdct",seq2,vec,n/2,0,1,0); */ | |||||
/* near-DC spreading function; this has nothing to do with | |||||
psychoacoustics, just sidelobe leakage and window size */ | |||||
{ | |||||
float temp=vec[0]*vec[0]+.7*vec[1]*vec[1]+.2*vec[2]*vec[2]; | |||||
int ptr=filters->nearptr; | |||||
/* the accumulation is regularly refreshed from scratch to avoid | |||||
floating point creep */ | |||||
if(ptr==0){ | |||||
decay=filters->nearDC_acc=filters->nearDC_partialacc+temp; | |||||
filters->nearDC_partialacc=temp; | |||||
}else{ | |||||
decay=filters->nearDC_acc+=temp; | |||||
filters->nearDC_partialacc+=temp; | |||||
} | |||||
filters->nearDC_acc-=filters->nearDC[ptr]; | |||||
filters->nearDC[ptr]=temp; | |||||
decay*=(1./(VE_NEARDC+1)); | |||||
filters->nearptr++; | |||||
if(filters->nearptr>=VE_NEARDC)filters->nearptr=0; | |||||
decay=todB(&decay)*.5-15.f; | |||||
} | |||||
/* perform spreading and limiting, also smooth the spectrum. yes, | |||||
the MDCT results in all real coefficients, but it still *behaves* | |||||
like real/imaginary pairs */ | |||||
for(i=0;i<n/2;i+=2){ | |||||
float val=vec[i]*vec[i]+vec[i+1]*vec[i+1]; | |||||
val=todB(&val)*.5f; | |||||
if(val<decay)val=decay; | |||||
if(val<minV)val=minV; | |||||
vec[i>>1]=val; | |||||
decay-=8.; | |||||
} | |||||
/*_analysis_output_always("spread",seq2++,vec,n/4,0,0,0);*/ | |||||
/* perform preecho/postecho triggering by band */ | |||||
for(j=0;j<VE_BANDS;j++){ | |||||
float acc=0.; | |||||
float valmax,valmin; | |||||
/* accumulate amplitude */ | |||||
for(i=0;i<bands[j].end;i++) | |||||
acc+=vec[i+bands[j].begin]*bands[j].window[i]; | |||||
acc*=bands[j].total; | |||||
/* convert amplitude to delta */ | |||||
{ | |||||
int p,thisx=filters[j].ampptr; | |||||
float postmax,postmin,premax=-99999.f,premin=99999.f; | |||||
p=thisx; | |||||
p--; | |||||
if(p<0)p+=VE_AMP; | |||||
postmax=max(acc,filters[j].ampbuf[p]); | |||||
postmin=min(acc,filters[j].ampbuf[p]); | |||||
for(i=0;i<stretch;i++){ | |||||
p--; | |||||
if(p<0)p+=VE_AMP; | |||||
premax=max(premax,filters[j].ampbuf[p]); | |||||
premin=min(premin,filters[j].ampbuf[p]); | |||||
} | |||||
valmin=postmin-premin; | |||||
valmax=postmax-premax; | |||||
/*filters[j].markers[pos]=valmax;*/ | |||||
filters[j].ampbuf[thisx]=acc; | |||||
filters[j].ampptr++; | |||||
if(filters[j].ampptr>=VE_AMP)filters[j].ampptr=0; | |||||
} | |||||
/* look at min/max, decide trigger */ | |||||
if(valmax>gi->preecho_thresh[j]+penalty){ | |||||
ret|=1; | |||||
ret|=4; | |||||
} | |||||
if(valmin<gi->postecho_thresh[j]-penalty)ret|=2; | |||||
} | |||||
return(ret); | |||||
} | |||||
#if 0 | |||||
static int seq=0; | |||||
static ogg_int64_t totalshift=-1024; | |||||
#endif | |||||
long _ve_envelope_search(vorbis_dsp_state *v){ | |||||
vorbis_info *vi=v->vi; | |||||
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | |||||
vorbis_info_psy_global *gi=&ci->psy_g_param; | |||||
envelope_lookup *ve=((private_state *)(v->backend_state))->ve; | |||||
long i,j; | |||||
int first=ve->current/ve->searchstep; | |||||
int last=v->pcm_current/ve->searchstep-VE_WIN; | |||||
if(first<0)first=0; | |||||
/* make sure we have enough storage to match the PCM */ | |||||
if(last+VE_WIN+VE_POST>ve->storage){ | |||||
ve->storage=last+VE_WIN+VE_POST; /* be sure */ | |||||
ve->mark=(int*)_ogg_realloc(ve->mark,ve->storage*sizeof(*ve->mark)); | |||||
} | |||||
for(j=first;j<last;j++){ | |||||
int ret=0; | |||||
ve->stretch++; | |||||
if(ve->stretch>VE_MAXSTRETCH*2) | |||||
ve->stretch=VE_MAXSTRETCH*2; | |||||
for(i=0;i<ve->ch;i++){ | |||||
float *pcm=v->pcm[i]+ve->searchstep*(j); | |||||
ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS); | |||||
} | |||||
ve->mark[j+VE_POST]=0; | |||||
if(ret&1){ | |||||
ve->mark[j]=1; | |||||
ve->mark[j+1]=1; | |||||
} | |||||
if(ret&2){ | |||||
ve->mark[j]=1; | |||||
if(j>0)ve->mark[j-1]=1; | |||||
} | |||||
if(ret&4)ve->stretch=-1; | |||||
} | |||||
ve->current=last*ve->searchstep; | |||||
{ | |||||
long centerW=v->centerW; | |||||
long testW= | |||||
centerW+ | |||||
ci->blocksizes[v->W]/4+ | |||||
ci->blocksizes[1]/2+ | |||||
ci->blocksizes[0]/4; | |||||
j=ve->cursor; | |||||
while(j<ve->current-(ve->searchstep)){/* account for postecho | |||||
working back one window */ | |||||
if(j>=testW)return(1); | |||||
ve->cursor=j; | |||||
if(ve->mark[j/ve->searchstep]){ | |||||
if(j>centerW){ | |||||
#if 0 | |||||
if(j>ve->curmark){ | |||||
float *marker=(float*)alloca(v->pcm_current*sizeof(*marker)); | |||||
int l,m; | |||||
memset(marker,0,sizeof(*marker)*v->pcm_current); | |||||
fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n", | |||||
seq, | |||||
(totalshift+ve->cursor)/44100., | |||||
(totalshift+j)/44100.); | |||||
_analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift); | |||||
_analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift); | |||||
_analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift); | |||||
_analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift); | |||||
for(m=0;m<VE_BANDS;m++){ | |||||
char buf[80]; | |||||
sprintf(buf,"delL%d",m); | |||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1; | |||||
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); | |||||
} | |||||
for(m=0;m<VE_BANDS;m++){ | |||||
char buf[80]; | |||||
sprintf(buf,"delR%d",m); | |||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1; | |||||
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); | |||||
} | |||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4; | |||||
_analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift); | |||||
seq++; | |||||
} | |||||
#endif | |||||
ve->curmark=j; | |||||
if(j>=testW)return(1); | |||||
return(0); | |||||
} | |||||
} | |||||
j+=ve->searchstep; | |||||
} | |||||
} | |||||
return(-1); | |||||
} | |||||
int _ve_envelope_mark(vorbis_dsp_state *v){ | |||||
envelope_lookup *ve=((private_state *)(v->backend_state))->ve; | |||||
vorbis_info *vi=v->vi; | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
long centerW=v->centerW; | |||||
long beginW=centerW-ci->blocksizes[v->W]/4; | |||||
long endW=centerW+ci->blocksizes[v->W]/4; | |||||
if(v->W){ | |||||
beginW-=ci->blocksizes[v->lW]/4; | |||||
endW+=ci->blocksizes[v->nW]/4; | |||||
}else{ | |||||
beginW-=ci->blocksizes[0]/4; | |||||
endW+=ci->blocksizes[0]/4; | |||||
} | |||||
if(ve->curmark>=beginW && ve->curmark<endW)return(1); | |||||
{ | |||||
long first=beginW/ve->searchstep; | |||||
long last=endW/ve->searchstep; | |||||
long i; | |||||
for(i=first;i<last;i++) | |||||
if(ve->mark[i])return(1); | |||||
} | |||||
return(0); | |||||
} | |||||
void _ve_envelope_shift(envelope_lookup *e,long shift){ | |||||
int smallsize=e->current/e->searchstep+VE_POST; /* adjust for placing marks | |||||
ahead of ve->current */ | |||||
int smallshift=shift/e->searchstep; | |||||
memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark)); | |||||
#if 0 | |||||
for(i=0;i<VE_BANDS*e->ch;i++) | |||||
memmove(e->filter[i].markers, | |||||
e->filter[i].markers+smallshift, | |||||
(1024-smallshift)*sizeof(*(*e->filter).markers)); | |||||
totalshift+=shift; | |||||
#endif | |||||
e->current-=shift; | |||||
if(e->curmark>=0) | |||||
e->curmark-=shift; | |||||
e->cursor-=shift; | |||||
} | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: PCM data envelope analysis | |||||
********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <stdio.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "os.h" | |||||
#include "scales.h" | |||||
#include "envelope.h" | |||||
#include "mdct.h" | |||||
#include "misc.h" | |||||
void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
vorbis_info_psy_global *gi=&ci->psy_g_param; | |||||
int ch=vi->channels; | |||||
int i,j; | |||||
int n=e->winlength=128; | |||||
e->searchstep=64; /* not random */ | |||||
e->minenergy=gi->preecho_minenergy; | |||||
e->ch=ch; | |||||
e->storage=128; | |||||
e->cursor=ci->blocksizes[1]/2; | |||||
e->mdct_win=(float*)_ogg_calloc(n,sizeof(*e->mdct_win)); | |||||
mdct_init(&e->mdct,n); | |||||
for(i=0;i<n;i++){ | |||||
e->mdct_win[i]=sin(i/(n-1.)*M_PI); | |||||
e->mdct_win[i]*=e->mdct_win[i]; | |||||
} | |||||
/* magic follows */ | |||||
e->band[0].begin=2; e->band[0].end=4; | |||||
e->band[1].begin=4; e->band[1].end=5; | |||||
e->band[2].begin=6; e->band[2].end=6; | |||||
e->band[3].begin=9; e->band[3].end=8; | |||||
e->band[4].begin=13; e->band[4].end=8; | |||||
e->band[5].begin=17; e->band[5].end=8; | |||||
e->band[6].begin=22; e->band[6].end=8; | |||||
for(j=0;j<VE_BANDS;j++){ | |||||
n=e->band[j].end; | |||||
e->band[j].window=(float*)_ogg_malloc(n*sizeof(*e->band[0].window)); | |||||
for(i=0;i<n;i++){ | |||||
e->band[j].window[i]=sin((i+.5)/n*M_PI); | |||||
e->band[j].total+=e->band[j].window[i]; | |||||
} | |||||
e->band[j].total=1./e->band[j].total; | |||||
} | |||||
e->filter=(envelope_filter_state*)_ogg_calloc(VE_BANDS*ch,sizeof(*e->filter)); | |||||
e->mark=(int*)_ogg_calloc(e->storage,sizeof(*e->mark)); | |||||
} | |||||
void _ve_envelope_clear(envelope_lookup *e){ | |||||
int i; | |||||
mdct_clear(&e->mdct); | |||||
for(i=0;i<VE_BANDS;i++) | |||||
_ogg_free(e->band[i].window); | |||||
_ogg_free(e->mdct_win); | |||||
_ogg_free(e->filter); | |||||
_ogg_free(e->mark); | |||||
memset(e,0,sizeof(*e)); | |||||
} | |||||
/* fairly straight threshhold-by-band based until we find something | |||||
that works better and isn't patented. */ | |||||
static int _ve_amp(envelope_lookup *ve, | |||||
vorbis_info_psy_global *gi, | |||||
float *data, | |||||
envelope_band *bands, | |||||
envelope_filter_state *filters){ | |||||
long n=ve->winlength; | |||||
int ret=0; | |||||
long i,j; | |||||
float decay; | |||||
/* we want to have a 'minimum bar' for energy, else we're just | |||||
basing blocks on quantization noise that outweighs the signal | |||||
itself (for low power signals) */ | |||||
float minV=ve->minenergy; | |||||
float *vec=(float*) alloca(n*sizeof(*vec)); | |||||
/* stretch is used to gradually lengthen the number of windows | |||||
considered prevoius-to-potential-trigger */ | |||||
int stretch=max(VE_MINSTRETCH,ve->stretch/2); | |||||
float penalty=gi->stretch_penalty-(ve->stretch/2-VE_MINSTRETCH); | |||||
if(penalty<0.f)penalty=0.f; | |||||
if(penalty>gi->stretch_penalty)penalty=gi->stretch_penalty; | |||||
/*_analysis_output_always("lpcm",seq2,data,n,0,0, | |||||
totalshift+pos*ve->searchstep);*/ | |||||
/* window and transform */ | |||||
for(i=0;i<n;i++) | |||||
vec[i]=data[i]*ve->mdct_win[i]; | |||||
mdct_forward(&ve->mdct,vec,vec); | |||||
/*_analysis_output_always("mdct",seq2,vec,n/2,0,1,0); */ | |||||
/* near-DC spreading function; this has nothing to do with | |||||
psychoacoustics, just sidelobe leakage and window size */ | |||||
{ | |||||
float temp=vec[0]*vec[0]+.7*vec[1]*vec[1]+.2*vec[2]*vec[2]; | |||||
int ptr=filters->nearptr; | |||||
/* the accumulation is regularly refreshed from scratch to avoid | |||||
floating point creep */ | |||||
if(ptr==0){ | |||||
decay=filters->nearDC_acc=filters->nearDC_partialacc+temp; | |||||
filters->nearDC_partialacc=temp; | |||||
}else{ | |||||
decay=filters->nearDC_acc+=temp; | |||||
filters->nearDC_partialacc+=temp; | |||||
} | |||||
filters->nearDC_acc-=filters->nearDC[ptr]; | |||||
filters->nearDC[ptr]=temp; | |||||
decay*=(1./(VE_NEARDC+1)); | |||||
filters->nearptr++; | |||||
if(filters->nearptr>=VE_NEARDC)filters->nearptr=0; | |||||
decay=todB(&decay)*.5-15.f; | |||||
} | |||||
/* perform spreading and limiting, also smooth the spectrum. yes, | |||||
the MDCT results in all real coefficients, but it still *behaves* | |||||
like real/imaginary pairs */ | |||||
for(i=0;i<n/2;i+=2){ | |||||
float val=vec[i]*vec[i]+vec[i+1]*vec[i+1]; | |||||
val=todB(&val)*.5f; | |||||
if(val<decay)val=decay; | |||||
if(val<minV)val=minV; | |||||
vec[i>>1]=val; | |||||
decay-=8.; | |||||
} | |||||
/*_analysis_output_always("spread",seq2++,vec,n/4,0,0,0);*/ | |||||
/* perform preecho/postecho triggering by band */ | |||||
for(j=0;j<VE_BANDS;j++){ | |||||
float acc=0.; | |||||
float valmax,valmin; | |||||
/* accumulate amplitude */ | |||||
for(i=0;i<bands[j].end;i++) | |||||
acc+=vec[i+bands[j].begin]*bands[j].window[i]; | |||||
acc*=bands[j].total; | |||||
/* convert amplitude to delta */ | |||||
{ | |||||
int p,thisx=filters[j].ampptr; | |||||
float postmax,postmin,premax=-99999.f,premin=99999.f; | |||||
p=thisx; | |||||
p--; | |||||
if(p<0)p+=VE_AMP; | |||||
postmax=max(acc,filters[j].ampbuf[p]); | |||||
postmin=min(acc,filters[j].ampbuf[p]); | |||||
for(i=0;i<stretch;i++){ | |||||
p--; | |||||
if(p<0)p+=VE_AMP; | |||||
premax=max(premax,filters[j].ampbuf[p]); | |||||
premin=min(premin,filters[j].ampbuf[p]); | |||||
} | |||||
valmin=postmin-premin; | |||||
valmax=postmax-premax; | |||||
/*filters[j].markers[pos]=valmax;*/ | |||||
filters[j].ampbuf[thisx]=acc; | |||||
filters[j].ampptr++; | |||||
if(filters[j].ampptr>=VE_AMP)filters[j].ampptr=0; | |||||
} | |||||
/* look at min/max, decide trigger */ | |||||
if(valmax>gi->preecho_thresh[j]+penalty){ | |||||
ret|=1; | |||||
ret|=4; | |||||
} | |||||
if(valmin<gi->postecho_thresh[j]-penalty)ret|=2; | |||||
} | |||||
return(ret); | |||||
} | |||||
#if 0 | |||||
static int seq=0; | |||||
static ogg_int64_t totalshift=-1024; | |||||
#endif | |||||
long _ve_envelope_search(vorbis_dsp_state *v){ | |||||
vorbis_info *vi=v->vi; | |||||
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup; | |||||
vorbis_info_psy_global *gi=&ci->psy_g_param; | |||||
envelope_lookup *ve=((private_state *)(v->backend_state))->ve; | |||||
long i,j; | |||||
int first=ve->current/ve->searchstep; | |||||
int last=v->pcm_current/ve->searchstep-VE_WIN; | |||||
if(first<0)first=0; | |||||
/* make sure we have enough storage to match the PCM */ | |||||
if(last+VE_WIN+VE_POST>ve->storage){ | |||||
ve->storage=last+VE_WIN+VE_POST; /* be sure */ | |||||
ve->mark=(int*)_ogg_realloc(ve->mark,ve->storage*sizeof(*ve->mark)); | |||||
} | |||||
for(j=first;j<last;j++){ | |||||
int ret=0; | |||||
ve->stretch++; | |||||
if(ve->stretch>VE_MAXSTRETCH*2) | |||||
ve->stretch=VE_MAXSTRETCH*2; | |||||
for(i=0;i<ve->ch;i++){ | |||||
float *pcm=v->pcm[i]+ve->searchstep*(j); | |||||
ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS); | |||||
} | |||||
ve->mark[j+VE_POST]=0; | |||||
if(ret&1){ | |||||
ve->mark[j]=1; | |||||
ve->mark[j+1]=1; | |||||
} | |||||
if(ret&2){ | |||||
ve->mark[j]=1; | |||||
if(j>0)ve->mark[j-1]=1; | |||||
} | |||||
if(ret&4)ve->stretch=-1; | |||||
} | |||||
ve->current=last*ve->searchstep; | |||||
{ | |||||
long centerW=v->centerW; | |||||
long testW= | |||||
centerW+ | |||||
ci->blocksizes[v->W]/4+ | |||||
ci->blocksizes[1]/2+ | |||||
ci->blocksizes[0]/4; | |||||
j=ve->cursor; | |||||
while(j<ve->current-(ve->searchstep)){/* account for postecho | |||||
working back one window */ | |||||
if(j>=testW)return(1); | |||||
ve->cursor=j; | |||||
if(ve->mark[j/ve->searchstep]){ | |||||
if(j>centerW){ | |||||
#if 0 | |||||
if(j>ve->curmark){ | |||||
float *marker=(float*)alloca(v->pcm_current*sizeof(*marker)); | |||||
int l,m; | |||||
memset(marker,0,sizeof(*marker)*v->pcm_current); | |||||
fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n", | |||||
seq, | |||||
(totalshift+ve->cursor)/44100., | |||||
(totalshift+j)/44100.); | |||||
_analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift); | |||||
_analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift); | |||||
_analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift); | |||||
_analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift); | |||||
for(m=0;m<VE_BANDS;m++){ | |||||
char buf[80]; | |||||
sprintf(buf,"delL%d",m); | |||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1; | |||||
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); | |||||
} | |||||
for(m=0;m<VE_BANDS;m++){ | |||||
char buf[80]; | |||||
sprintf(buf,"delR%d",m); | |||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1; | |||||
_analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); | |||||
} | |||||
for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4; | |||||
_analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift); | |||||
seq++; | |||||
} | |||||
#endif | |||||
ve->curmark=j; | |||||
if(j>=testW)return(1); | |||||
return(0); | |||||
} | |||||
} | |||||
j+=ve->searchstep; | |||||
} | |||||
} | |||||
return(-1); | |||||
} | |||||
int _ve_envelope_mark(vorbis_dsp_state *v){ | |||||
envelope_lookup *ve=((private_state *)(v->backend_state))->ve; | |||||
vorbis_info *vi=v->vi; | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
long centerW=v->centerW; | |||||
long beginW=centerW-ci->blocksizes[v->W]/4; | |||||
long endW=centerW+ci->blocksizes[v->W]/4; | |||||
if(v->W){ | |||||
beginW-=ci->blocksizes[v->lW]/4; | |||||
endW+=ci->blocksizes[v->nW]/4; | |||||
}else{ | |||||
beginW-=ci->blocksizes[0]/4; | |||||
endW+=ci->blocksizes[0]/4; | |||||
} | |||||
if(ve->curmark>=beginW && ve->curmark<endW)return(1); | |||||
{ | |||||
long first=beginW/ve->searchstep; | |||||
long last=endW/ve->searchstep; | |||||
long i; | |||||
for(i=first;i<last;i++) | |||||
if(ve->mark[i])return(1); | |||||
} | |||||
return(0); | |||||
} | |||||
void _ve_envelope_shift(envelope_lookup *e,long shift){ | |||||
int smallsize=e->current/e->searchstep+VE_POST; /* adjust for placing marks | |||||
ahead of ve->current */ | |||||
int smallshift=shift/e->searchstep; | |||||
memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark)); | |||||
#if 0 | |||||
for(i=0;i<VE_BANDS*e->ch;i++) | |||||
memmove(e->filter[i].markers, | |||||
e->filter[i].markers+smallshift, | |||||
(1024-smallshift)*sizeof(*(*e->filter).markers)); | |||||
totalshift+=shift; | |||||
#endif | |||||
e->current-=shift; | |||||
if(e->curmark>=0) | |||||
e->curmark-=shift; | |||||
e->cursor-=shift; | |||||
} |
@@ -1,80 +1,79 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: PCM data envelope analysis and manipulation | |||||
last mod: $Id: envelope.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_ENVELOPE_ | |||||
#define _V_ENVELOPE_ | |||||
#include "mdct.h" | |||||
#define VE_PRE 16 | |||||
#define VE_WIN 4 | |||||
#define VE_POST 2 | |||||
#define VE_AMP (VE_PRE+VE_POST-1) | |||||
#define VE_BANDS 7 | |||||
#define VE_NEARDC 15 | |||||
#define VE_MINSTRETCH 2 /* a bit less than short block */ | |||||
#define VE_MAXSTRETCH 12 /* one-third full block */ | |||||
typedef struct { | |||||
float ampbuf[VE_AMP]; | |||||
int ampptr; | |||||
float nearDC[VE_NEARDC]; | |||||
float nearDC_acc; | |||||
float nearDC_partialacc; | |||||
int nearptr; | |||||
} envelope_filter_state; | |||||
typedef struct { | |||||
int begin; | |||||
int end; | |||||
float *window; | |||||
float total; | |||||
} envelope_band; | |||||
typedef struct { | |||||
int ch; | |||||
int winlength; | |||||
int searchstep; | |||||
float minenergy; | |||||
mdct_lookup mdct; | |||||
float *mdct_win; | |||||
envelope_band band[VE_BANDS]; | |||||
envelope_filter_state *filter; | |||||
int stretch; | |||||
int *mark; | |||||
long storage; | |||||
long current; | |||||
long curmark; | |||||
long cursor; | |||||
} envelope_lookup; | |||||
extern void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi); | |||||
extern void _ve_envelope_clear(envelope_lookup *e); | |||||
extern long _ve_envelope_search(vorbis_dsp_state *v); | |||||
extern void _ve_envelope_shift(envelope_lookup *e,long shift); | |||||
extern int _ve_envelope_mark(vorbis_dsp_state *v); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: PCM data envelope analysis and manipulation | |||||
********************************************************************/ | |||||
#ifndef _V_ENVELOPE_ | |||||
#define _V_ENVELOPE_ | |||||
#include "mdct.h" | |||||
#define VE_PRE 16 | |||||
#define VE_WIN 4 | |||||
#define VE_POST 2 | |||||
#define VE_AMP (VE_PRE+VE_POST-1) | |||||
#define VE_BANDS 7 | |||||
#define VE_NEARDC 15 | |||||
#define VE_MINSTRETCH 2 /* a bit less than short block */ | |||||
#define VE_MAXSTRETCH 12 /* one-third full block */ | |||||
typedef struct { | |||||
float ampbuf[VE_AMP]; | |||||
int ampptr; | |||||
float nearDC[VE_NEARDC]; | |||||
float nearDC_acc; | |||||
float nearDC_partialacc; | |||||
int nearptr; | |||||
} envelope_filter_state; | |||||
typedef struct { | |||||
int begin; | |||||
int end; | |||||
float *window; | |||||
float total; | |||||
} envelope_band; | |||||
typedef struct { | |||||
int ch; | |||||
int winlength; | |||||
int searchstep; | |||||
float minenergy; | |||||
mdct_lookup mdct; | |||||
float *mdct_win; | |||||
envelope_band band[VE_BANDS]; | |||||
envelope_filter_state *filter; | |||||
int stretch; | |||||
int *mark; | |||||
long storage; | |||||
long current; | |||||
long curmark; | |||||
long cursor; | |||||
} envelope_lookup; | |||||
extern void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi); | |||||
extern void _ve_envelope_clear(envelope_lookup *e); | |||||
extern long _ve_envelope_search(vorbis_dsp_state *v); | |||||
extern void _ve_envelope_shift(envelope_lookup *e,long shift); | |||||
extern int _ve_envelope_mark(vorbis_dsp_state *v); | |||||
#endif |
@@ -1,223 +1,220 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: floor backend 0 implementation | |||||
last mod: $Id: floor0.c 17558 2010-10-22 00:24:41Z tterribe $ | |||||
********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "registry.h" | |||||
#include "lpc.h" | |||||
#include "lsp.h" | |||||
#include "codebook.h" | |||||
#include "scales.h" | |||||
#include "misc.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
#include <stdio.h> | |||||
typedef struct { | |||||
int ln; | |||||
int m; | |||||
int **linearmap; | |||||
int n[2]; | |||||
vorbis_info_floor0 *vi; | |||||
long bits; | |||||
long frames; | |||||
} vorbis_look_floor0; | |||||
/***********************************************/ | |||||
static void floor0_free_info(vorbis_info_floor *i){ | |||||
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; | |||||
if(info){ | |||||
memset(info,0,sizeof(*info)); | |||||
_ogg_free(info); | |||||
} | |||||
} | |||||
static void floor0_free_look(vorbis_look_floor *i){ | |||||
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; | |||||
if(look){ | |||||
if(look->linearmap){ | |||||
if(look->linearmap[0])_ogg_free(look->linearmap[0]); | |||||
if(look->linearmap[1])_ogg_free(look->linearmap[1]); | |||||
_ogg_free(look->linearmap); | |||||
} | |||||
memset(look,0,sizeof(*look)); | |||||
_ogg_free(look); | |||||
} | |||||
} | |||||
static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
int j; | |||||
vorbis_info_floor0 *info=(vorbis_info_floor0*)_ogg_malloc(sizeof(*info)); | |||||
info->order=oggpack_read(opb,8); | |||||
info->rate=oggpack_read(opb,16); | |||||
info->barkmap=oggpack_read(opb,16); | |||||
info->ampbits=oggpack_read(opb,6); | |||||
info->ampdB=oggpack_read(opb,8); | |||||
info->numbooks=oggpack_read(opb,4)+1; | |||||
if(info->order<1)goto err_out; | |||||
if(info->rate<1)goto err_out; | |||||
if(info->barkmap<1)goto err_out; | |||||
if(info->numbooks<1)goto err_out; | |||||
for(j=0;j<info->numbooks;j++){ | |||||
info->books[j]=oggpack_read(opb,8); | |||||
if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out; | |||||
if(ci->book_param[info->books[j]]->maptype==0)goto err_out; | |||||
if(ci->book_param[info->books[j]]->dim<1)goto err_out; | |||||
} | |||||
return(info); | |||||
err_out: | |||||
floor0_free_info(info); | |||||
return(NULL); | |||||
} | |||||
/* initialize Bark scale and normalization lookups. We could do this | |||||
with static tables, but Vorbis allows a number of possible | |||||
combinations, so it's best to do it computationally. | |||||
The below is authoritative in terms of defining scale mapping. | |||||
Note that the scale depends on the sampling rate as well as the | |||||
linear block and mapping sizes */ | |||||
static void floor0_map_lazy_init(vorbis_block *vb, | |||||
vorbis_info_floor *infoX, | |||||
vorbis_look_floor0 *look){ | |||||
if(!look->linearmap[vb->W]){ | |||||
vorbis_dsp_state *vd=vb->vd; | |||||
vorbis_info *vi=vd->vi; | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
vorbis_info_floor0 *info=(vorbis_info_floor0 *)infoX; | |||||
int W=vb->W; | |||||
int n=ci->blocksizes[W]/2,j; | |||||
/* we choose a scaling constant so that: | |||||
floor(bark(rate/2-1)*C)=mapped-1 | |||||
floor(bark(rate/2)*C)=mapped */ | |||||
float scale=look->ln/toBARK(info->rate/2.f); | |||||
/* the mapping from a linear scale to a smaller bark scale is | |||||
straightforward. We do *not* make sure that the linear mapping | |||||
does not skip bark-scale bins; the decoder simply skips them and | |||||
the encoder may do what it wishes in filling them. They're | |||||
necessary in some mapping combinations to keep the scale spacing | |||||
accurate */ | |||||
look->linearmap[W]=(int*)_ogg_malloc((n+1)*sizeof(**look->linearmap)); | |||||
for(j=0;j<n;j++){ | |||||
int val=floor( toBARK((info->rate/2.f)/n*j) | |||||
*scale); /* bark numbers represent band edges */ | |||||
if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ | |||||
look->linearmap[W][j]=val; | |||||
} | |||||
look->linearmap[W][j]=-1; | |||||
look->n[W]=n; | |||||
} | |||||
} | |||||
static vorbis_look_floor *floor0_look(vorbis_dsp_state* /* vd */, | |||||
vorbis_info_floor *i){ | |||||
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; | |||||
vorbis_look_floor0 *look=(vorbis_look_floor0*)_ogg_calloc(1,sizeof(*look)); | |||||
look->m=info->order; | |||||
look->ln=info->barkmap; | |||||
look->vi=info; | |||||
look->linearmap=(int**)_ogg_calloc(2,sizeof(*look->linearmap)); | |||||
return look; | |||||
} | |||||
static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){ | |||||
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; | |||||
vorbis_info_floor0 *info=look->vi; | |||||
int j,k; | |||||
int ampraw=oggpack_read(&vb->opb,info->ampbits); | |||||
if(ampraw>0){ /* also handles the -1 out of data case */ | |||||
long maxval=(1<<info->ampbits)-1; | |||||
float amp=(float)ampraw/maxval*info->ampdB; | |||||
int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks)); | |||||
if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */ | |||||
codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; | |||||
codebook *b=ci->fullbooks+info->books[booknum]; | |||||
float last=0.f; | |||||
/* the additional b->dim is a guard against any possible stack | |||||
smash; b->dim is provably more than we can overflow the | |||||
vector */ | |||||
float *lsp=(float*)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+b->dim+1)); | |||||
for(j=0;j<look->m;j+=b->dim) | |||||
if(vorbis_book_decodev_set(b,lsp+j,&vb->opb,b->dim)==-1)goto eop; | |||||
for(j=0;j<look->m;){ | |||||
for(k=0;k<b->dim;k++,j++)lsp[j]+=last; | |||||
last=lsp[j-1]; | |||||
} | |||||
lsp[look->m]=amp; | |||||
return(lsp); | |||||
} | |||||
} | |||||
eop: | |||||
return(NULL); | |||||
} | |||||
static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, | |||||
void *memo,float *out){ | |||||
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; | |||||
vorbis_info_floor0 *info=look->vi; | |||||
floor0_map_lazy_init(vb,info,look); | |||||
if(memo){ | |||||
float *lsp=(float *)memo; | |||||
float amp=lsp[look->m]; | |||||
/* take the coefficients back to a spectral envelope curve */ | |||||
vorbis_lsp_to_curve(out, | |||||
look->linearmap[vb->W], | |||||
look->n[vb->W], | |||||
look->ln, | |||||
lsp,look->m,amp,(float)info->ampdB); | |||||
return(1); | |||||
} | |||||
memset(out,0,sizeof(*out)*look->n[vb->W]); | |||||
return(0); | |||||
} | |||||
/* export hooks */ | |||||
const vorbis_func_floor floor0_exportbundle={ | |||||
NULL,&floor0_unpack,&floor0_look,&floor0_free_info, | |||||
&floor0_free_look,&floor0_inverse1,&floor0_inverse2 | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: floor backend 0 implementation | |||||
********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "registry.h" | |||||
#include "lpc.h" | |||||
#include "lsp.h" | |||||
#include "codebook.h" | |||||
#include "scales.h" | |||||
#include "misc.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
#include <stdio.h> | |||||
typedef struct { | |||||
int ln; | |||||
int m; | |||||
int **linearmap; | |||||
int n[2]; | |||||
vorbis_info_floor0 *vi; | |||||
long bits; | |||||
long frames; | |||||
} vorbis_look_floor0; | |||||
/***********************************************/ | |||||
static void floor0_free_info(vorbis_info_floor *i){ | |||||
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; | |||||
if(info){ | |||||
memset(info,0,sizeof(*info)); | |||||
_ogg_free(info); | |||||
} | |||||
} | |||||
static void floor0_free_look(vorbis_look_floor *i){ | |||||
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; | |||||
if(look){ | |||||
if(look->linearmap){ | |||||
if(look->linearmap[0])_ogg_free(look->linearmap[0]); | |||||
if(look->linearmap[1])_ogg_free(look->linearmap[1]); | |||||
_ogg_free(look->linearmap); | |||||
} | |||||
memset(look,0,sizeof(*look)); | |||||
_ogg_free(look); | |||||
} | |||||
} | |||||
static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
int j; | |||||
vorbis_info_floor0 *info=(vorbis_info_floor0*)_ogg_malloc(sizeof(*info)); | |||||
info->order=oggpack_read(opb,8); | |||||
info->rate=oggpack_read(opb,16); | |||||
info->barkmap=oggpack_read(opb,16); | |||||
info->ampbits=oggpack_read(opb,6); | |||||
info->ampdB=oggpack_read(opb,8); | |||||
info->numbooks=oggpack_read(opb,4)+1; | |||||
if(info->order<1)goto err_out; | |||||
if(info->rate<1)goto err_out; | |||||
if(info->barkmap<1)goto err_out; | |||||
if(info->numbooks<1)goto err_out; | |||||
for(j=0;j<info->numbooks;j++){ | |||||
info->books[j]=oggpack_read(opb,8); | |||||
if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out; | |||||
if(ci->book_param[info->books[j]]->maptype==0)goto err_out; | |||||
if(ci->book_param[info->books[j]]->dim<1)goto err_out; | |||||
} | |||||
return(info); | |||||
err_out: | |||||
floor0_free_info(info); | |||||
return(NULL); | |||||
} | |||||
/* initialize Bark scale and normalization lookups. We could do this | |||||
with static tables, but Vorbis allows a number of possible | |||||
combinations, so it's best to do it computationally. | |||||
The below is authoritative in terms of defining scale mapping. | |||||
Note that the scale depends on the sampling rate as well as the | |||||
linear block and mapping sizes */ | |||||
static void floor0_map_lazy_init(vorbis_block *vb, | |||||
vorbis_info_floor *infoX, | |||||
vorbis_look_floor0 *look){ | |||||
if(!look->linearmap[vb->W]){ | |||||
vorbis_dsp_state *vd=vb->vd; | |||||
vorbis_info *vi=vd->vi; | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
vorbis_info_floor0 *info=(vorbis_info_floor0 *)infoX; | |||||
int W=vb->W; | |||||
int n=ci->blocksizes[W]/2,j; | |||||
/* we choose a scaling constant so that: | |||||
floor(bark(rate/2-1)*C)=mapped-1 | |||||
floor(bark(rate/2)*C)=mapped */ | |||||
float scale=look->ln/toBARK(info->rate/2.f); | |||||
/* the mapping from a linear scale to a smaller bark scale is | |||||
straightforward. We do *not* make sure that the linear mapping | |||||
does not skip bark-scale bins; the decoder simply skips them and | |||||
the encoder may do what it wishes in filling them. They're | |||||
necessary in some mapping combinations to keep the scale spacing | |||||
accurate */ | |||||
look->linearmap[W]=(int*)_ogg_malloc((n+1)*sizeof(**look->linearmap)); | |||||
for(j=0;j<n;j++){ | |||||
int val=floor( toBARK((info->rate/2.f)/n*j) | |||||
*scale); /* bark numbers represent band edges */ | |||||
if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ | |||||
look->linearmap[W][j]=val; | |||||
} | |||||
look->linearmap[W][j]=-1; | |||||
look->n[W]=n; | |||||
} | |||||
} | |||||
static vorbis_look_floor *floor0_look(vorbis_dsp_state* /* vd */, | |||||
vorbis_info_floor *i){ | |||||
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i; | |||||
vorbis_look_floor0 *look=(vorbis_look_floor0*)_ogg_calloc(1,sizeof(*look)); | |||||
look->m=info->order; | |||||
look->ln=info->barkmap; | |||||
look->vi=info; | |||||
look->linearmap=(int**)_ogg_calloc(2,sizeof(*look->linearmap)); | |||||
return look; | |||||
} | |||||
static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){ | |||||
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; | |||||
vorbis_info_floor0 *info=look->vi; | |||||
int j,k; | |||||
int ampraw=oggpack_read(&vb->opb,info->ampbits); | |||||
if(ampraw>0){ /* also handles the -1 out of data case */ | |||||
long maxval=(1<<info->ampbits)-1; | |||||
float amp=(float)ampraw/maxval*info->ampdB; | |||||
int booknum=oggpack_read(&vb->opb,ov_ilog(info->numbooks)); | |||||
if(booknum!=-1 && booknum<info->numbooks){ /* be paranoid */ | |||||
codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; | |||||
codebook *b=ci->fullbooks+info->books[booknum]; | |||||
float last=0.f; | |||||
/* the additional b->dim is a guard against any possible stack | |||||
smash; b->dim is provably more than we can overflow the | |||||
vector */ | |||||
float *lsp=(float*)_vorbis_block_alloc(vb,sizeof(*lsp)*(look->m+b->dim+1)); | |||||
if(vorbis_book_decodev_set(b,lsp,&vb->opb,look->m)==-1)goto eop; | |||||
for(j=0;j<look->m;){ | |||||
for(k=0;j<look->m && k<b->dim;k++,j++)lsp[j]+=last; | |||||
last=lsp[j-1]; | |||||
} | |||||
lsp[look->m]=amp; | |||||
return(lsp); | |||||
} | |||||
} | |||||
eop: | |||||
return(NULL); | |||||
} | |||||
static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, | |||||
void *memo,float *out){ | |||||
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; | |||||
vorbis_info_floor0 *info=look->vi; | |||||
floor0_map_lazy_init(vb,info,look); | |||||
if(memo){ | |||||
float *lsp=(float *)memo; | |||||
float amp=lsp[look->m]; | |||||
/* take the coefficients back to a spectral envelope curve */ | |||||
vorbis_lsp_to_curve(out, | |||||
look->linearmap[vb->W], | |||||
look->n[vb->W], | |||||
look->ln, | |||||
lsp,look->m,amp,(float)info->ampdB); | |||||
return(1); | |||||
} | |||||
memset(out,0,sizeof(*out)*look->n[vb->W]); | |||||
return(0); | |||||
} | |||||
/* export hooks */ | |||||
const vorbis_func_floor floor0_exportbundle={ | |||||
NULL,&floor0_unpack,&floor0_look,&floor0_free_info, | |||||
&floor0_free_look,&floor0_inverse1,&floor0_inverse2 | |||||
}; |
@@ -1,58 +1,57 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: highlevel encoder setup struct separated out for vorbisenc clarity | |||||
last mod: $Id: highlevel.h 17195 2010-05-05 21:49:51Z giles $ | |||||
********************************************************************/ | |||||
typedef struct highlevel_byblocktype { | |||||
double tone_mask_setting; | |||||
double tone_peaklimit_setting; | |||||
double noise_bias_setting; | |||||
double noise_compand_setting; | |||||
} highlevel_byblocktype; | |||||
typedef struct highlevel_encode_setup { | |||||
int set_in_stone; | |||||
const void *setup; | |||||
double base_setting; | |||||
double impulse_noisetune; | |||||
/* bitrate management below all settable */ | |||||
float req; | |||||
int managed; | |||||
long bitrate_min; | |||||
long bitrate_av; | |||||
double bitrate_av_damp; | |||||
long bitrate_max; | |||||
long bitrate_reservoir; | |||||
double bitrate_reservoir_bias; | |||||
int impulse_block_p; | |||||
int noise_normalize_p; | |||||
int coupling_p; | |||||
double stereo_point_setting; | |||||
double lowpass_kHz; | |||||
int lowpass_altered; | |||||
double ath_floating_dB; | |||||
double ath_absolute_dB; | |||||
double amplitude_track_dBpersec; | |||||
double trigger_setting; | |||||
highlevel_byblocktype block[4]; /* padding, impulse, transition, long */ | |||||
} highlevel_encode_setup; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: highlevel encoder setup struct separated out for vorbisenc clarity | |||||
********************************************************************/ | |||||
typedef struct highlevel_byblocktype { | |||||
double tone_mask_setting; | |||||
double tone_peaklimit_setting; | |||||
double noise_bias_setting; | |||||
double noise_compand_setting; | |||||
} highlevel_byblocktype; | |||||
typedef struct highlevel_encode_setup { | |||||
int set_in_stone; | |||||
const void *setup; | |||||
double base_setting; | |||||
double impulse_noisetune; | |||||
/* bitrate management below all settable */ | |||||
float req; | |||||
int managed; | |||||
long bitrate_min; | |||||
long bitrate_av; | |||||
double bitrate_av_damp; | |||||
long bitrate_max; | |||||
long bitrate_reservoir; | |||||
double bitrate_reservoir_bias; | |||||
int impulse_block_p; | |||||
int noise_normalize_p; | |||||
int coupling_p; | |||||
double stereo_point_setting; | |||||
double lowpass_kHz; | |||||
int lowpass_altered; | |||||
double ath_floating_dB; | |||||
double ath_absolute_dB; | |||||
double amplitude_track_dBpersec; | |||||
double trigger_setting; | |||||
highlevel_byblocktype block[4]; /* padding, impulse, transition, long */ | |||||
} highlevel_encode_setup; |
@@ -1,94 +1,93 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: lookup based functions | |||||
last mod: $Id: lookup.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#include <math.h> | |||||
#include "lookup.h" | |||||
#include "lookup_data.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
#ifdef FLOAT_LOOKUP | |||||
/* interpolated lookup based cos function, domain 0 to PI only */ | |||||
float vorbis_coslook(float a){ | |||||
double d=a*(.31830989*(float)COS_LOOKUP_SZ); | |||||
int i=vorbis_ftoi(d-.5); | |||||
return COS_LOOKUP[i]+ (d-i)*(COS_LOOKUP[i+1]-COS_LOOKUP[i]); | |||||
} | |||||
/* interpolated 1./sqrt(p) where .5 <= p < 1. */ | |||||
float vorbis_invsqlook(float a){ | |||||
double d=a*(2.f*(float)INVSQ_LOOKUP_SZ)-(float)INVSQ_LOOKUP_SZ; | |||||
int i=vorbis_ftoi(d-.5f); | |||||
return INVSQ_LOOKUP[i]+ (d-i)*(INVSQ_LOOKUP[i+1]-INVSQ_LOOKUP[i]); | |||||
} | |||||
/* interpolated 1./sqrt(p) where .5 <= p < 1. */ | |||||
float vorbis_invsq2explook(int a){ | |||||
return INVSQ2EXP_LOOKUP[a-INVSQ2EXP_LOOKUP_MIN]; | |||||
} | |||||
#include <stdio.h> | |||||
/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ | |||||
float vorbis_fromdBlook(float a){ | |||||
int i=vorbis_ftoi(a*((float)(-(1<<FROMdB2_SHIFT)))-.5f); | |||||
return (i<0)?1.f: | |||||
((i>=(FROMdB_LOOKUP_SZ<<FROMdB_SHIFT))?0.f: | |||||
FROMdB_LOOKUP[i>>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]); | |||||
} | |||||
#endif | |||||
#ifdef INT_LOOKUP | |||||
/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in | |||||
16.16 format | |||||
returns in m.8 format */ | |||||
long vorbis_invsqlook_i(long a,long e){ | |||||
long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); | |||||
long d=(a&INVSQ_LOOKUP_I_MASK)<<(16-INVSQ_LOOKUP_I_SHIFT); /* 0.16 */ | |||||
long val=INVSQ_LOOKUP_I[i]- /* 1.16 */ | |||||
(((INVSQ_LOOKUP_I[i]-INVSQ_LOOKUP_I[i+1])* /* 0.16 */ | |||||
d)>>16); /* result 1.16 */ | |||||
e+=32; | |||||
if(e&1)val=(val*5792)>>13; /* multiply val by 1/sqrt(2) */ | |||||
e=(e>>1)-8; | |||||
return(val>>e); | |||||
} | |||||
/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ | |||||
/* a is in n.12 format */ | |||||
float vorbis_fromdBlook_i(long a){ | |||||
int i=(-a)>>(12-FROMdB2_SHIFT); | |||||
return (i<0)?1.f: | |||||
((i>=(FROMdB_LOOKUP_SZ<<FROMdB_SHIFT))?0.f: | |||||
FROMdB_LOOKUP[i>>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]); | |||||
} | |||||
/* interpolated lookup based cos function, domain 0 to PI only */ | |||||
/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */ | |||||
long vorbis_coslook_i(long a){ | |||||
int i=a>>COS_LOOKUP_I_SHIFT; | |||||
int d=a&COS_LOOKUP_I_MASK; | |||||
return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> | |||||
COS_LOOKUP_I_SHIFT); | |||||
} | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: lookup based functions | |||||
********************************************************************/ | |||||
#include <math.h> | |||||
#include "lookup.h" | |||||
#include "lookup_data.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
#ifdef FLOAT_LOOKUP | |||||
/* interpolated lookup based cos function, domain 0 to PI only */ | |||||
float vorbis_coslook(float a){ | |||||
double d=a*(.31830989*(float)COS_LOOKUP_SZ); | |||||
int i=vorbis_ftoi(d-.5); | |||||
return COS_LOOKUP[i]+ (d-i)*(COS_LOOKUP[i+1]-COS_LOOKUP[i]); | |||||
} | |||||
/* interpolated 1./sqrt(p) where .5 <= p < 1. */ | |||||
float vorbis_invsqlook(float a){ | |||||
double d=a*(2.f*(float)INVSQ_LOOKUP_SZ)-(float)INVSQ_LOOKUP_SZ; | |||||
int i=vorbis_ftoi(d-.5f); | |||||
return INVSQ_LOOKUP[i]+ (d-i)*(INVSQ_LOOKUP[i+1]-INVSQ_LOOKUP[i]); | |||||
} | |||||
/* interpolated 1./sqrt(p) where .5 <= p < 1. */ | |||||
float vorbis_invsq2explook(int a){ | |||||
return INVSQ2EXP_LOOKUP[a-INVSQ2EXP_LOOKUP_MIN]; | |||||
} | |||||
#include <stdio.h> | |||||
/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ | |||||
float vorbis_fromdBlook(float a){ | |||||
int i=vorbis_ftoi(a*((float)(-(1<<FROMdB2_SHIFT)))-.5f); | |||||
return (i<0)?1.f: | |||||
((i>=(FROMdB_LOOKUP_SZ<<FROMdB_SHIFT))?0.f: | |||||
FROMdB_LOOKUP[i>>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]); | |||||
} | |||||
#endif | |||||
#ifdef INT_LOOKUP | |||||
/* interpolated 1./sqrt(p) where .5 <= a < 1. (.100000... to .111111...) in | |||||
16.16 format | |||||
returns in m.8 format */ | |||||
long vorbis_invsqlook_i(long a,long e){ | |||||
long i=(a&0x7fff)>>(INVSQ_LOOKUP_I_SHIFT-1); | |||||
long d=(a&INVSQ_LOOKUP_I_MASK)<<(16-INVSQ_LOOKUP_I_SHIFT); /* 0.16 */ | |||||
long val=INVSQ_LOOKUP_I[i]- /* 1.16 */ | |||||
(((INVSQ_LOOKUP_I[i]-INVSQ_LOOKUP_I[i+1])* /* 0.16 */ | |||||
d)>>16); /* result 1.16 */ | |||||
e+=32; | |||||
if(e&1)val=(val*5792)>>13; /* multiply val by 1/sqrt(2) */ | |||||
e=(e>>1)-8; | |||||
return(val>>e); | |||||
} | |||||
/* interpolated lookup based fromdB function, domain -140dB to 0dB only */ | |||||
/* a is in n.12 format */ | |||||
float vorbis_fromdBlook_i(long a){ | |||||
int i=(-a)>>(12-FROMdB2_SHIFT); | |||||
return (i<0)?1.f: | |||||
((i>=(FROMdB_LOOKUP_SZ<<FROMdB_SHIFT))?0.f: | |||||
FROMdB_LOOKUP[i>>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]); | |||||
} | |||||
/* interpolated lookup based cos function, domain 0 to PI only */ | |||||
/* a is in 0.16 format, where 0==0, 2^^16-1==PI, return 0.14 */ | |||||
long vorbis_coslook_i(long a){ | |||||
int i=a>>COS_LOOKUP_I_SHIFT; | |||||
int d=a&COS_LOOKUP_I_MASK; | |||||
return COS_LOOKUP_I[i]- ((d*(COS_LOOKUP_I[i]-COS_LOOKUP_I[i+1]))>> | |||||
COS_LOOKUP_I_SHIFT); | |||||
} | |||||
#endif |
@@ -1,32 +1,31 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: lookup based functions | |||||
last mod: $Id: lookup.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_LOOKUP_H_ | |||||
#ifdef FLOAT_LOOKUP | |||||
extern float vorbis_coslook(float a); | |||||
extern float vorbis_invsqlook(float a); | |||||
extern float vorbis_invsq2explook(int a); | |||||
extern float vorbis_fromdBlook(float a); | |||||
#endif | |||||
#ifdef INT_LOOKUP | |||||
extern long vorbis_invsqlook_i(long a,long e); | |||||
extern long vorbis_coslook_i(long a); | |||||
extern float vorbis_fromdBlook_i(long a); | |||||
#endif | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: lookup based functions | |||||
********************************************************************/ | |||||
#ifndef _V_LOOKUP_H_ | |||||
#ifdef FLOAT_LOOKUP | |||||
extern float vorbis_coslook(float a); | |||||
extern float vorbis_invsqlook(float a); | |||||
extern float vorbis_invsq2explook(int a); | |||||
extern float vorbis_fromdBlook(float a); | |||||
#endif | |||||
#ifdef INT_LOOKUP | |||||
extern long vorbis_invsqlook_i(long a,long e); | |||||
extern long vorbis_coslook_i(long a); | |||||
extern float vorbis_fromdBlook_i(long a); | |||||
#endif | |||||
#endif |
@@ -1,192 +1,191 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: lookup data; generated by lookups.pl; edit there | |||||
last mod: $Id: lookup_data.h 16037 2009-05-26 21:10:58Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_LOOKUP_DATA_H_ | |||||
#ifdef FLOAT_LOOKUP | |||||
#define COS_LOOKUP_SZ 128 | |||||
static const float COS_LOOKUP[COS_LOOKUP_SZ+1]={ | |||||
+1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f, | |||||
+0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f, | |||||
+0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f, | |||||
+0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f, | |||||
+0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f, | |||||
+0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f, | |||||
+0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f, | |||||
+0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f, | |||||
+0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f, | |||||
+0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f, | |||||
+0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f, | |||||
+0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f, | |||||
+0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f, | |||||
+0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f, | |||||
+0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f, | |||||
+0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f, | |||||
+0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f, | |||||
-0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f, | |||||
-0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f, | |||||
-0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f, | |||||
-0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f, | |||||
-0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f, | |||||
-0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f, | |||||
-0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f, | |||||
-0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f, | |||||
-0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f, | |||||
-0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f, | |||||
-0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f, | |||||
-0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f, | |||||
-0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f, | |||||
-0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f, | |||||
-0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f, | |||||
-1.0000000000000f, | |||||
}; | |||||
#define INVSQ_LOOKUP_SZ 32 | |||||
static const float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={ | |||||
1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f, | |||||
1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f, | |||||
1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f, | |||||
1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f, | |||||
1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f, | |||||
1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f, | |||||
1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f, | |||||
1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f, | |||||
1.000000000000f, | |||||
}; | |||||
#define INVSQ2EXP_LOOKUP_MIN (-32) | |||||
#define INVSQ2EXP_LOOKUP_MAX 32 | |||||
static const float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\ | |||||
INVSQ2EXP_LOOKUP_MIN+1]={ | |||||
65536.f, 46340.95001f, 32768.f, 23170.47501f, | |||||
16384.f, 11585.2375f, 8192.f, 5792.618751f, | |||||
4096.f, 2896.309376f, 2048.f, 1448.154688f, | |||||
1024.f, 724.0773439f, 512.f, 362.038672f, | |||||
256.f, 181.019336f, 128.f, 90.50966799f, | |||||
64.f, 45.254834f, 32.f, 22.627417f, | |||||
16.f, 11.3137085f, 8.f, 5.656854249f, | |||||
4.f, 2.828427125f, 2.f, 1.414213562f, | |||||
1.f, 0.7071067812f, 0.5f, 0.3535533906f, | |||||
0.25f, 0.1767766953f, 0.125f, 0.08838834765f, | |||||
0.0625f, 0.04419417382f, 0.03125f, 0.02209708691f, | |||||
0.015625f, 0.01104854346f, 0.0078125f, 0.005524271728f, | |||||
0.00390625f, 0.002762135864f, 0.001953125f, 0.001381067932f, | |||||
0.0009765625f, 0.000690533966f, 0.00048828125f, 0.000345266983f, | |||||
0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f, | |||||
6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f, | |||||
1.525878906e-05f, | |||||
}; | |||||
#endif | |||||
#define FROMdB_LOOKUP_SZ 35 | |||||
#define FROMdB2_LOOKUP_SZ 32 | |||||
#define FROMdB_SHIFT 5 | |||||
#define FROMdB2_SHIFT 3 | |||||
#define FROMdB2_MASK 31 | |||||
#ifdef FLOAT_LOOKUP | |||||
static const float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={ | |||||
1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f, | |||||
0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f, | |||||
0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f, | |||||
0.003981071706f, 0.002511886432f, 0.001584893192f, 0.001f, | |||||
0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f, | |||||
0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f, | |||||
1.584893192e-05f, 1e-05f,6.309573445e-06f,3.981071706e-06f, | |||||
2.511886432e-06f,1.584893192e-06f, 1e-06f,6.309573445e-07f, | |||||
3.981071706e-07f,2.511886432e-07f,1.584893192e-07f, | |||||
}; | |||||
static const float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={ | |||||
0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f, | |||||
0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f, | |||||
0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f, | |||||
0.835362547f, 0.8234268041f, 0.8116616003f, 0.8000644989f, | |||||
0.7886330981f, 0.7773650302f, 0.7662579617f, 0.755309592f, | |||||
0.7445176537f, 0.7338799116f, 0.7233941627f, 0.7130582353f, | |||||
0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f, | |||||
0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f, | |||||
}; | |||||
#endif | |||||
#ifdef INT_LOOKUP | |||||
#define INVSQ_LOOKUP_I_SHIFT 10 | |||||
#define INVSQ_LOOKUP_I_MASK 1023 | |||||
static const long INVSQ_LOOKUP_I[64+1]={ | |||||
92682l, 91966l, 91267l, 90583l, | |||||
89915l, 89261l, 88621l, 87995l, | |||||
87381l, 86781l, 86192l, 85616l, | |||||
85051l, 84497l, 83953l, 83420l, | |||||
82897l, 82384l, 81880l, 81385l, | |||||
80899l, 80422l, 79953l, 79492l, | |||||
79039l, 78594l, 78156l, 77726l, | |||||
77302l, 76885l, 76475l, 76072l, | |||||
75674l, 75283l, 74898l, 74519l, | |||||
74146l, 73778l, 73415l, 73058l, | |||||
72706l, 72359l, 72016l, 71679l, | |||||
71347l, 71019l, 70695l, 70376l, | |||||
70061l, 69750l, 69444l, 69141l, | |||||
68842l, 68548l, 68256l, 67969l, | |||||
67685l, 67405l, 67128l, 66855l, | |||||
66585l, 66318l, 66054l, 65794l, | |||||
65536l, | |||||
}; | |||||
#define COS_LOOKUP_I_SHIFT 9 | |||||
#define COS_LOOKUP_I_MASK 511 | |||||
#define COS_LOOKUP_I_SZ 128 | |||||
static const long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={ | |||||
16384l, 16379l, 16364l, 16340l, | |||||
16305l, 16261l, 16207l, 16143l, | |||||
16069l, 15986l, 15893l, 15791l, | |||||
15679l, 15557l, 15426l, 15286l, | |||||
15137l, 14978l, 14811l, 14635l, | |||||
14449l, 14256l, 14053l, 13842l, | |||||
13623l, 13395l, 13160l, 12916l, | |||||
12665l, 12406l, 12140l, 11866l, | |||||
11585l, 11297l, 11003l, 10702l, | |||||
10394l, 10080l, 9760l, 9434l, | |||||
9102l, 8765l, 8423l, 8076l, | |||||
7723l, 7366l, 7005l, 6639l, | |||||
6270l, 5897l, 5520l, 5139l, | |||||
4756l, 4370l, 3981l, 3590l, | |||||
3196l, 2801l, 2404l, 2006l, | |||||
1606l, 1205l, 804l, 402l, | |||||
0l, -401l, -803l, -1204l, | |||||
-1605l, -2005l, -2403l, -2800l, | |||||
-3195l, -3589l, -3980l, -4369l, | |||||
-4755l, -5138l, -5519l, -5896l, | |||||
-6269l, -6638l, -7004l, -7365l, | |||||
-7722l, -8075l, -8422l, -8764l, | |||||
-9101l, -9433l, -9759l, -10079l, | |||||
-10393l, -10701l, -11002l, -11296l, | |||||
-11584l, -11865l, -12139l, -12405l, | |||||
-12664l, -12915l, -13159l, -13394l, | |||||
-13622l, -13841l, -14052l, -14255l, | |||||
-14448l, -14634l, -14810l, -14977l, | |||||
-15136l, -15285l, -15425l, -15556l, | |||||
-15678l, -15790l, -15892l, -15985l, | |||||
-16068l, -16142l, -16206l, -16260l, | |||||
-16304l, -16339l, -16363l, -16378l, | |||||
-16383l, | |||||
}; | |||||
#endif | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: lookup data; generated by lookups.pl; edit there | |||||
********************************************************************/ | |||||
#ifndef _V_LOOKUP_DATA_H_ | |||||
#ifdef FLOAT_LOOKUP | |||||
#define COS_LOOKUP_SZ 128 | |||||
static const float COS_LOOKUP[COS_LOOKUP_SZ+1]={ | |||||
+1.0000000000000f,+0.9996988186962f,+0.9987954562052f,+0.9972904566787f, | |||||
+0.9951847266722f,+0.9924795345987f,+0.9891765099648f,+0.9852776423889f, | |||||
+0.9807852804032f,+0.9757021300385f,+0.9700312531945f,+0.9637760657954f, | |||||
+0.9569403357322f,+0.9495281805930f,+0.9415440651830f,+0.9329927988347f, | |||||
+0.9238795325113f,+0.9142097557035f,+0.9039892931234f,+0.8932243011955f, | |||||
+0.8819212643484f,+0.8700869911087f,+0.8577286100003f,+0.8448535652497f, | |||||
+0.8314696123025f,+0.8175848131516f,+0.8032075314806f,+0.7883464276266f, | |||||
+0.7730104533627f,+0.7572088465065f,+0.7409511253550f,+0.7242470829515f, | |||||
+0.7071067811865f,+0.6895405447371f,+0.6715589548470f,+0.6531728429538f, | |||||
+0.6343932841636f,+0.6152315905806f,+0.5956993044924f,+0.5758081914178f, | |||||
+0.5555702330196f,+0.5349976198871f,+0.5141027441932f,+0.4928981922298f, | |||||
+0.4713967368260f,+0.4496113296546f,+0.4275550934303f,+0.4052413140050f, | |||||
+0.3826834323651f,+0.3598950365350f,+0.3368898533922f,+0.3136817403989f, | |||||
+0.2902846772545f,+0.2667127574749f,+0.2429801799033f,+0.2191012401569f, | |||||
+0.1950903220161f,+0.1709618887603f,+0.1467304744554f,+0.1224106751992f, | |||||
+0.0980171403296f,+0.0735645635997f,+0.0490676743274f,+0.0245412285229f, | |||||
+0.0000000000000f,-0.0245412285229f,-0.0490676743274f,-0.0735645635997f, | |||||
-0.0980171403296f,-0.1224106751992f,-0.1467304744554f,-0.1709618887603f, | |||||
-0.1950903220161f,-0.2191012401569f,-0.2429801799033f,-0.2667127574749f, | |||||
-0.2902846772545f,-0.3136817403989f,-0.3368898533922f,-0.3598950365350f, | |||||
-0.3826834323651f,-0.4052413140050f,-0.4275550934303f,-0.4496113296546f, | |||||
-0.4713967368260f,-0.4928981922298f,-0.5141027441932f,-0.5349976198871f, | |||||
-0.5555702330196f,-0.5758081914178f,-0.5956993044924f,-0.6152315905806f, | |||||
-0.6343932841636f,-0.6531728429538f,-0.6715589548470f,-0.6895405447371f, | |||||
-0.7071067811865f,-0.7242470829515f,-0.7409511253550f,-0.7572088465065f, | |||||
-0.7730104533627f,-0.7883464276266f,-0.8032075314806f,-0.8175848131516f, | |||||
-0.8314696123025f,-0.8448535652497f,-0.8577286100003f,-0.8700869911087f, | |||||
-0.8819212643484f,-0.8932243011955f,-0.9039892931234f,-0.9142097557035f, | |||||
-0.9238795325113f,-0.9329927988347f,-0.9415440651830f,-0.9495281805930f, | |||||
-0.9569403357322f,-0.9637760657954f,-0.9700312531945f,-0.9757021300385f, | |||||
-0.9807852804032f,-0.9852776423889f,-0.9891765099648f,-0.9924795345987f, | |||||
-0.9951847266722f,-0.9972904566787f,-0.9987954562052f,-0.9996988186962f, | |||||
-1.0000000000000f, | |||||
}; | |||||
#define INVSQ_LOOKUP_SZ 32 | |||||
static const float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={ | |||||
1.414213562373f,1.392621247646f,1.371988681140f,1.352246807566f, | |||||
1.333333333333f,1.315191898443f,1.297771369046f,1.281025230441f, | |||||
1.264911064067f,1.249390095109f,1.234426799697f,1.219988562661f, | |||||
1.206045378311f,1.192569588000f,1.179535649239f,1.166919931983f, | |||||
1.154700538379f,1.142857142857f,1.131370849898f,1.120224067222f, | |||||
1.109400392450f,1.098884511590f,1.088662107904f,1.078719779941f, | |||||
1.069044967650f,1.059625885652f,1.050451462878f,1.041511287847f, | |||||
1.032795558989f,1.024295039463f,1.016001016002f,1.007905261358f, | |||||
1.000000000000f, | |||||
}; | |||||
#define INVSQ2EXP_LOOKUP_MIN (-32) | |||||
#define INVSQ2EXP_LOOKUP_MAX 32 | |||||
static const float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\ | |||||
INVSQ2EXP_LOOKUP_MIN+1]={ | |||||
65536.f, 46340.95001f, 32768.f, 23170.47501f, | |||||
16384.f, 11585.2375f, 8192.f, 5792.618751f, | |||||
4096.f, 2896.309376f, 2048.f, 1448.154688f, | |||||
1024.f, 724.0773439f, 512.f, 362.038672f, | |||||
256.f, 181.019336f, 128.f, 90.50966799f, | |||||
64.f, 45.254834f, 32.f, 22.627417f, | |||||
16.f, 11.3137085f, 8.f, 5.656854249f, | |||||
4.f, 2.828427125f, 2.f, 1.414213562f, | |||||
1.f, 0.7071067812f, 0.5f, 0.3535533906f, | |||||
0.25f, 0.1767766953f, 0.125f, 0.08838834765f, | |||||
0.0625f, 0.04419417382f, 0.03125f, 0.02209708691f, | |||||
0.015625f, 0.01104854346f, 0.0078125f, 0.005524271728f, | |||||
0.00390625f, 0.002762135864f, 0.001953125f, 0.001381067932f, | |||||
0.0009765625f, 0.000690533966f, 0.00048828125f, 0.000345266983f, | |||||
0.000244140625f,0.0001726334915f,0.0001220703125f,8.631674575e-05f, | |||||
6.103515625e-05f,4.315837288e-05f,3.051757812e-05f,2.157918644e-05f, | |||||
1.525878906e-05f, | |||||
}; | |||||
#endif | |||||
#define FROMdB_LOOKUP_SZ 35 | |||||
#define FROMdB2_LOOKUP_SZ 32 | |||||
#define FROMdB_SHIFT 5 | |||||
#define FROMdB2_SHIFT 3 | |||||
#define FROMdB2_MASK 31 | |||||
#ifdef FLOAT_LOOKUP | |||||
static const float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={ | |||||
1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f, | |||||
0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f, | |||||
0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f, | |||||
0.003981071706f, 0.002511886432f, 0.001584893192f, 0.001f, | |||||
0.0006309573445f,0.0003981071706f,0.0002511886432f,0.0001584893192f, | |||||
0.0001f,6.309573445e-05f,3.981071706e-05f,2.511886432e-05f, | |||||
1.584893192e-05f, 1e-05f,6.309573445e-06f,3.981071706e-06f, | |||||
2.511886432e-06f,1.584893192e-06f, 1e-06f,6.309573445e-07f, | |||||
3.981071706e-07f,2.511886432e-07f,1.584893192e-07f, | |||||
}; | |||||
static const float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={ | |||||
0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f, | |||||
0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f, | |||||
0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f, | |||||
0.835362547f, 0.8234268041f, 0.8116616003f, 0.8000644989f, | |||||
0.7886330981f, 0.7773650302f, 0.7662579617f, 0.755309592f, | |||||
0.7445176537f, 0.7338799116f, 0.7233941627f, 0.7130582353f, | |||||
0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f, | |||||
0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f, | |||||
}; | |||||
#endif | |||||
#ifdef INT_LOOKUP | |||||
#define INVSQ_LOOKUP_I_SHIFT 10 | |||||
#define INVSQ_LOOKUP_I_MASK 1023 | |||||
static const long INVSQ_LOOKUP_I[64+1]={ | |||||
92682l, 91966l, 91267l, 90583l, | |||||
89915l, 89261l, 88621l, 87995l, | |||||
87381l, 86781l, 86192l, 85616l, | |||||
85051l, 84497l, 83953l, 83420l, | |||||
82897l, 82384l, 81880l, 81385l, | |||||
80899l, 80422l, 79953l, 79492l, | |||||
79039l, 78594l, 78156l, 77726l, | |||||
77302l, 76885l, 76475l, 76072l, | |||||
75674l, 75283l, 74898l, 74519l, | |||||
74146l, 73778l, 73415l, 73058l, | |||||
72706l, 72359l, 72016l, 71679l, | |||||
71347l, 71019l, 70695l, 70376l, | |||||
70061l, 69750l, 69444l, 69141l, | |||||
68842l, 68548l, 68256l, 67969l, | |||||
67685l, 67405l, 67128l, 66855l, | |||||
66585l, 66318l, 66054l, 65794l, | |||||
65536l, | |||||
}; | |||||
#define COS_LOOKUP_I_SHIFT 9 | |||||
#define COS_LOOKUP_I_MASK 511 | |||||
#define COS_LOOKUP_I_SZ 128 | |||||
static const long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={ | |||||
16384l, 16379l, 16364l, 16340l, | |||||
16305l, 16261l, 16207l, 16143l, | |||||
16069l, 15986l, 15893l, 15791l, | |||||
15679l, 15557l, 15426l, 15286l, | |||||
15137l, 14978l, 14811l, 14635l, | |||||
14449l, 14256l, 14053l, 13842l, | |||||
13623l, 13395l, 13160l, 12916l, | |||||
12665l, 12406l, 12140l, 11866l, | |||||
11585l, 11297l, 11003l, 10702l, | |||||
10394l, 10080l, 9760l, 9434l, | |||||
9102l, 8765l, 8423l, 8076l, | |||||
7723l, 7366l, 7005l, 6639l, | |||||
6270l, 5897l, 5520l, 5139l, | |||||
4756l, 4370l, 3981l, 3590l, | |||||
3196l, 2801l, 2404l, 2006l, | |||||
1606l, 1205l, 804l, 402l, | |||||
0l, -401l, -803l, -1204l, | |||||
-1605l, -2005l, -2403l, -2800l, | |||||
-3195l, -3589l, -3980l, -4369l, | |||||
-4755l, -5138l, -5519l, -5896l, | |||||
-6269l, -6638l, -7004l, -7365l, | |||||
-7722l, -8075l, -8422l, -8764l, | |||||
-9101l, -9433l, -9759l, -10079l, | |||||
-10393l, -10701l, -11002l, -11296l, | |||||
-11584l, -11865l, -12139l, -12405l, | |||||
-12664l, -12915l, -13159l, -13394l, | |||||
-13622l, -13841l, -14052l, -14255l, | |||||
-14448l, -14634l, -14810l, -14977l, | |||||
-15136l, -15285l, -15425l, -15556l, | |||||
-15678l, -15790l, -15892l, -15985l, | |||||
-16068l, -16142l, -16206l, -16260l, | |||||
-16304l, -16339l, -16363l, -16378l, | |||||
-16383l, | |||||
}; | |||||
#endif | |||||
#endif |
@@ -1,160 +1,159 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: LPC low level routines | |||||
last mod: $Id: lpc.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
/* Some of these routines (autocorrelator, LPC coefficient estimator) | |||||
are derived from code written by Jutta Degener and Carsten Bormann; | |||||
thus we include their copyright below. The entirety of this file | |||||
is freely redistributable on the condition that both of these | |||||
copyright notices are preserved without modification. */ | |||||
/* Preserved Copyright: *********************************************/ | |||||
/* Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, | |||||
Technische Universita"t Berlin | |||||
Any use of this software is permitted provided that this notice is not | |||||
removed and that neither the authors nor the Technische Universita"t | |||||
Berlin are deemed to have made any representations as to the | |||||
suitability of this software for any purpose nor are held responsible | |||||
for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR | |||||
THIS SOFTWARE. | |||||
As a matter of courtesy, the authors request to be informed about uses | |||||
this software has found, about bugs in this software, and about any | |||||
improvements that may be of general interest. | |||||
Berlin, 28.11.1994 | |||||
Jutta Degener | |||||
Carsten Bormann | |||||
*********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "os.h" | |||||
#include "smallft.h" | |||||
#include "lpc.h" | |||||
#include "scales.h" | |||||
#include "misc.h" | |||||
/* Autocorrelation LPC coeff generation algorithm invented by | |||||
N. Levinson in 1947, modified by J. Durbin in 1959. */ | |||||
/* Input : n elements of time doamin data | |||||
Output: m lpc coefficients, excitation energy */ | |||||
float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){ | |||||
double *aut=(double*)alloca(sizeof(*aut)*(m+1)); | |||||
double *lpc=(double*)alloca(sizeof(*lpc)*(m)); | |||||
double error; | |||||
double epsilon; | |||||
int i,j; | |||||
/* autocorrelation, p+1 lag coefficients */ | |||||
j=m+1; | |||||
while(j--){ | |||||
double d=0; /* double needed for accumulator depth */ | |||||
for(i=j;i<n;i++)d+=(double)data[i]*data[i-j]; | |||||
aut[j]=d; | |||||
} | |||||
/* Generate lpc coefficients from autocorr values */ | |||||
/* set our noise floor to about -100dB */ | |||||
error=aut[0] * (1. + 1e-10); | |||||
epsilon=1e-9*aut[0]+1e-10; | |||||
for(i=0;i<m;i++){ | |||||
double r= -aut[i+1]; | |||||
if(error<epsilon){ | |||||
memset(lpc+i,0,(m-i)*sizeof(*lpc)); | |||||
goto done; | |||||
} | |||||
/* Sum up this iteration's reflection coefficient; note that in | |||||
Vorbis we don't save it. If anyone wants to recycle this code | |||||
and needs reflection coefficients, save the results of 'r' from | |||||
each iteration. */ | |||||
for(j=0;j<i;j++)r-=lpc[j]*aut[i-j]; | |||||
r/=error; | |||||
/* Update LPC coefficients and total error */ | |||||
lpc[i]=r; | |||||
for(j=0;j<i/2;j++){ | |||||
double tmp=lpc[j]; | |||||
lpc[j]+=r*lpc[i-1-j]; | |||||
lpc[i-1-j]+=r*tmp; | |||||
} | |||||
if(i&1)lpc[j]+=lpc[j]*r; | |||||
error*=1.-r*r; | |||||
} | |||||
done: | |||||
/* slightly damp the filter */ | |||||
{ | |||||
double g = .99; | |||||
double damp = g; | |||||
for(j=0;j<m;j++){ | |||||
lpc[j]*=damp; | |||||
damp*=g; | |||||
} | |||||
} | |||||
for(j=0;j<m;j++)lpci[j]=(float)lpc[j]; | |||||
/* we need the error value to know how big an impulse to hit the | |||||
filter with later */ | |||||
return error; | |||||
} | |||||
void vorbis_lpc_predict(float *coeff,float *prime,int m, | |||||
float *data,long n){ | |||||
/* in: coeff[0...m-1] LPC coefficients | |||||
prime[0...m-1] initial values (allocated size of n+m-1) | |||||
out: data[0...n-1] data samples */ | |||||
long i,j,o,p; | |||||
float y; | |||||
float *work=(float*)alloca(sizeof(*work)*(m+n)); | |||||
if(!prime) | |||||
for(i=0;i<m;i++) | |||||
work[i]=0.f; | |||||
else | |||||
for(i=0;i<m;i++) | |||||
work[i]=prime[i]; | |||||
for(i=0;i<n;i++){ | |||||
y=0; | |||||
o=i; | |||||
p=m; | |||||
for(j=0;j<m;j++) | |||||
y-=work[o++]*coeff[--p]; | |||||
data[i]=work[o]=y; | |||||
} | |||||
} | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: LPC low level routines | |||||
********************************************************************/ | |||||
/* Some of these routines (autocorrelator, LPC coefficient estimator) | |||||
are derived from code written by Jutta Degener and Carsten Bormann; | |||||
thus we include their copyright below. The entirety of this file | |||||
is freely redistributable on the condition that both of these | |||||
copyright notices are preserved without modification. */ | |||||
/* Preserved Copyright: *********************************************/ | |||||
/* Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, | |||||
Technische Universita"t Berlin | |||||
Any use of this software is permitted provided that this notice is not | |||||
removed and that neither the authors nor the Technische Universita"t | |||||
Berlin are deemed to have made any representations as to the | |||||
suitability of this software for any purpose nor are held responsible | |||||
for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR | |||||
THIS SOFTWARE. | |||||
As a matter of courtesy, the authors request to be informed about uses | |||||
this software has found, about bugs in this software, and about any | |||||
improvements that may be of general interest. | |||||
Berlin, 28.11.1994 | |||||
Jutta Degener | |||||
Carsten Bormann | |||||
*********************************************************************/ | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <math.h> | |||||
#include "os.h" | |||||
#include "smallft.h" | |||||
#include "lpc.h" | |||||
#include "scales.h" | |||||
#include "misc.h" | |||||
/* Autocorrelation LPC coeff generation algorithm invented by | |||||
N. Levinson in 1947, modified by J. Durbin in 1959. */ | |||||
/* Input : n elements of time doamin data | |||||
Output: m lpc coefficients, excitation energy */ | |||||
float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){ | |||||
double *aut=(double*)alloca(sizeof(*aut)*(m+1)); | |||||
double *lpc=(double*)alloca(sizeof(*lpc)*(m)); | |||||
double error; | |||||
double epsilon; | |||||
int i,j; | |||||
/* autocorrelation, p+1 lag coefficients */ | |||||
j=m+1; | |||||
while(j--){ | |||||
double d=0; /* double needed for accumulator depth */ | |||||
for(i=j;i<n;i++)d+=(double)data[i]*data[i-j]; | |||||
aut[j]=d; | |||||
} | |||||
/* Generate lpc coefficients from autocorr values */ | |||||
/* set our noise floor to about -100dB */ | |||||
error=aut[0] * (1. + 1e-10); | |||||
epsilon=1e-9*aut[0]+1e-10; | |||||
for(i=0;i<m;i++){ | |||||
double r= -aut[i+1]; | |||||
if(error<epsilon){ | |||||
memset(lpc+i,0,(m-i)*sizeof(*lpc)); | |||||
goto done; | |||||
} | |||||
/* Sum up this iteration's reflection coefficient; note that in | |||||
Vorbis we don't save it. If anyone wants to recycle this code | |||||
and needs reflection coefficients, save the results of 'r' from | |||||
each iteration. */ | |||||
for(j=0;j<i;j++)r-=lpc[j]*aut[i-j]; | |||||
r/=error; | |||||
/* Update LPC coefficients and total error */ | |||||
lpc[i]=r; | |||||
for(j=0;j<i/2;j++){ | |||||
double tmp=lpc[j]; | |||||
lpc[j]+=r*lpc[i-1-j]; | |||||
lpc[i-1-j]+=r*tmp; | |||||
} | |||||
if(i&1)lpc[j]+=lpc[j]*r; | |||||
error*=1.-r*r; | |||||
} | |||||
done: | |||||
/* slightly damp the filter */ | |||||
{ | |||||
double g = .99; | |||||
double damp = g; | |||||
for(j=0;j<m;j++){ | |||||
lpc[j]*=damp; | |||||
damp*=g; | |||||
} | |||||
} | |||||
for(j=0;j<m;j++)lpci[j]=(float)lpc[j]; | |||||
/* we need the error value to know how big an impulse to hit the | |||||
filter with later */ | |||||
return error; | |||||
} | |||||
void vorbis_lpc_predict(float *coeff,float *prime,int m, | |||||
float *data,long n){ | |||||
/* in: coeff[0...m-1] LPC coefficients | |||||
prime[0...m-1] initial values (allocated size of n+m-1) | |||||
out: data[0...n-1] data samples */ | |||||
long i,j,o,p; | |||||
float y; | |||||
float *work=(float*)alloca(sizeof(*work)*(m+n)); | |||||
if(!prime) | |||||
for(i=0;i<m;i++) | |||||
work[i]=0.f; | |||||
else | |||||
for(i=0;i<m;i++) | |||||
work[i]=prime[i]; | |||||
for(i=0;i<n;i++){ | |||||
y=0; | |||||
o=i; | |||||
p=m; | |||||
for(j=0;j<m;j++) | |||||
y-=work[o++]*coeff[--p]; | |||||
data[i]=work[o]=y; | |||||
} | |||||
} |
@@ -1,29 +1,28 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: LPC low level routines | |||||
last mod: $Id: lpc.h 16037 2009-05-26 21:10:58Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_LPC_H_ | |||||
#define _V_LPC_H_ | |||||
#include "../../codec.h" | |||||
/* simple linear scale LPC code */ | |||||
extern float vorbis_lpc_from_data(float *data,float *lpc,int n,int m); | |||||
extern void vorbis_lpc_predict(float *coeff,float *prime,int m, | |||||
float *data,long n); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: LPC low level routines | |||||
********************************************************************/ | |||||
#ifndef _V_LPC_H_ | |||||
#define _V_LPC_H_ | |||||
#include "../../codec.h" | |||||
/* simple linear scale LPC code */ | |||||
extern float vorbis_lpc_from_data(float *data,float *lpc,int n,int m); | |||||
extern void vorbis_lpc_predict(float *coeff,float *prime,int m, | |||||
float *data,long n); | |||||
#endif |
@@ -1,454 +1,454 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: LSP (also called LSF) conversion routines | |||||
last mod: $Id: lsp.c 17538 2010-10-15 02:52:29Z tterribe $ | |||||
The LSP generation code is taken (with minimal modification and a | |||||
few bugfixes) from "On the Computation of the LSP Frequencies" by | |||||
Joseph Rothweiler (see http://www.rothweiler.us for contact info). | |||||
The paper is available at: | |||||
http://www.myown1.com/joe/lsf | |||||
********************************************************************/ | |||||
/* Note that the lpc-lsp conversion finds the roots of polynomial with | |||||
an iterative root polisher (CACM algorithm 283). It *is* possible | |||||
to confuse this algorithm into not converging; that should only | |||||
happen with absurdly closely spaced roots (very sharp peaks in the | |||||
LPC f response) which in turn should be impossible in our use of | |||||
the code. If this *does* happen anyway, it's a bug in the floor | |||||
finder; find the cause of the confusion (probably a single bin | |||||
spike or accidental near-float-limit resolution problems) and | |||||
correct it. */ | |||||
#include <math.h> | |||||
#include <string.h> | |||||
#include <stdlib.h> | |||||
#include "lsp.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
#include "lookup.h" | |||||
#include "scales.h" | |||||
/* three possible LSP to f curve functions; the exact computation | |||||
(float), a lookup based float implementation, and an integer | |||||
implementation. The float lookup is likely the optimal choice on | |||||
any machine with an FPU. The integer implementation is *not* fixed | |||||
point (due to the need for a large dynamic range and thus a | |||||
separately tracked exponent) and thus much more complex than the | |||||
relatively simple float implementations. It's mostly for future | |||||
work on a fully fixed point implementation for processors like the | |||||
ARM family. */ | |||||
/* define either of these (preferably FLOAT_LOOKUP) to have faster | |||||
but less precise implementation. */ | |||||
#undef FLOAT_LOOKUP | |||||
#undef INT_LOOKUP | |||||
#ifdef FLOAT_LOOKUP | |||||
#include "lookup.c" /* catch this in the build system; we #include for | |||||
compilers (like gcc) that can't inline across | |||||
modules */ | |||||
/* side effect: changes *lsp to cosines of lsp */ | |||||
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||||
float amp,float ampoffset){ | |||||
int i; | |||||
float wdel=M_PI/ln; | |||||
vorbis_fpu_control fpu; | |||||
vorbis_fpu_setround(&fpu); | |||||
for(i=0;i<m;i++)lsp[i]=vorbis_coslook(lsp[i]); | |||||
i=0; | |||||
while(i<n){ | |||||
int k=map[i]; | |||||
int qexp; | |||||
float p=.7071067812f; | |||||
float q=.7071067812f; | |||||
float w=vorbis_coslook(wdel*k); | |||||
float *ftmp=lsp; | |||||
int c=m>>1; | |||||
while(c--){ | |||||
q*=ftmp[0]-w; | |||||
p*=ftmp[1]-w; | |||||
ftmp+=2; | |||||
} | |||||
if(m&1){ | |||||
/* odd order filter; slightly assymetric */ | |||||
/* the last coefficient */ | |||||
q*=ftmp[0]-w; | |||||
q*=q; | |||||
p*=p*(1.f-w*w); | |||||
}else{ | |||||
/* even order filter; still symmetric */ | |||||
q*=q*(1.f+w); | |||||
p*=p*(1.f-w); | |||||
} | |||||
q=frexp(p+q,&qexp); | |||||
q=vorbis_fromdBlook(amp* | |||||
vorbis_invsqlook(q)* | |||||
vorbis_invsq2explook(qexp+m)- | |||||
ampoffset); | |||||
do{ | |||||
curve[i++]*=q; | |||||
}while(map[i]==k); | |||||
} | |||||
vorbis_fpu_restore(fpu); | |||||
} | |||||
#else | |||||
#ifdef INT_LOOKUP | |||||
#include "lookup.c" /* catch this in the build system; we #include for | |||||
compilers (like gcc) that can't inline across | |||||
modules */ | |||||
static const int MLOOP_1[64]={ | |||||
0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13, | |||||
14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, | |||||
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, | |||||
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, | |||||
}; | |||||
static const int MLOOP_2[64]={ | |||||
0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7, | |||||
8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, | |||||
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, | |||||
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, | |||||
}; | |||||
static const int MLOOP_3[8]={0,1,2,2,3,3,3,3}; | |||||
/* side effect: changes *lsp to cosines of lsp */ | |||||
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||||
float amp,float ampoffset){ | |||||
/* 0 <= m < 256 */ | |||||
/* set up for using all int later */ | |||||
int i; | |||||
int ampoffseti=rint(ampoffset*4096.f); | |||||
int ampi=rint(amp*16.f); | |||||
long *ilsp=(long*)alloca(m*sizeof(*ilsp)); | |||||
for(i=0;i<m;i++)ilsp[i]=vorbis_coslook_i(lsp[i]/M_PI*65536.f+.5f); | |||||
i=0; | |||||
while(i<n){ | |||||
int j,k=map[i]; | |||||
unsigned long pi=46341; /* 2**-.5 in 0.16 */ | |||||
unsigned long qi=46341; | |||||
int qexp=0,shift; | |||||
long wi=vorbis_coslook_i(k*65536/ln); | |||||
qi*=labs(ilsp[0]-wi); | |||||
pi*=labs(ilsp[1]-wi); | |||||
for(j=3;j<m;j+=2){ | |||||
if(!(shift=MLOOP_1[(pi|qi)>>25])) | |||||
if(!(shift=MLOOP_2[(pi|qi)>>19])) | |||||
shift=MLOOP_3[(pi|qi)>>16]; | |||||
qi=(qi>>shift)*labs(ilsp[j-1]-wi); | |||||
pi=(pi>>shift)*labs(ilsp[j]-wi); | |||||
qexp+=shift; | |||||
} | |||||
if(!(shift=MLOOP_1[(pi|qi)>>25])) | |||||
if(!(shift=MLOOP_2[(pi|qi)>>19])) | |||||
shift=MLOOP_3[(pi|qi)>>16]; | |||||
/* pi,qi normalized collectively, both tracked using qexp */ | |||||
if(m&1){ | |||||
/* odd order filter; slightly assymetric */ | |||||
/* the last coefficient */ | |||||
qi=(qi>>shift)*labs(ilsp[j-1]-wi); | |||||
pi=(pi>>shift)<<14; | |||||
qexp+=shift; | |||||
if(!(shift=MLOOP_1[(pi|qi)>>25])) | |||||
if(!(shift=MLOOP_2[(pi|qi)>>19])) | |||||
shift=MLOOP_3[(pi|qi)>>16]; | |||||
pi>>=shift; | |||||
qi>>=shift; | |||||
qexp+=shift-14*((m+1)>>1); | |||||
pi=((pi*pi)>>16); | |||||
qi=((qi*qi)>>16); | |||||
qexp=qexp*2+m; | |||||
pi*=(1<<14)-((wi*wi)>>14); | |||||
qi+=pi>>14; | |||||
}else{ | |||||
/* even order filter; still symmetric */ | |||||
/* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't | |||||
worth tracking step by step */ | |||||
pi>>=shift; | |||||
qi>>=shift; | |||||
qexp+=shift-7*m; | |||||
pi=((pi*pi)>>16); | |||||
qi=((qi*qi)>>16); | |||||
qexp=qexp*2+m; | |||||
pi*=(1<<14)-wi; | |||||
qi*=(1<<14)+wi; | |||||
qi=(qi+pi)>>14; | |||||
} | |||||
/* we've let the normalization drift because it wasn't important; | |||||
however, for the lookup, things must be normalized again. We | |||||
need at most one right shift or a number of left shifts */ | |||||
if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ | |||||
qi>>=1; qexp++; | |||||
}else | |||||
while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ | |||||
qi<<=1; qexp--; | |||||
} | |||||
amp=vorbis_fromdBlook_i(ampi* /* n.4 */ | |||||
vorbis_invsqlook_i(qi,qexp)- | |||||
/* m.8, m+n<=8 */ | |||||
ampoffseti); /* 8.12[0] */ | |||||
curve[i]*=amp; | |||||
while(map[++i]==k)curve[i]*=amp; | |||||
} | |||||
} | |||||
#else | |||||
/* old, nonoptimized but simple version for any poor sap who needs to | |||||
figure out what the hell this code does, or wants the other | |||||
fraction of a dB precision */ | |||||
/* side effect: changes *lsp to cosines of lsp */ | |||||
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||||
float amp,float ampoffset){ | |||||
int i; | |||||
float wdel=M_PI/ln; | |||||
for(i=0;i<m;i++)lsp[i]=2.f*cos(lsp[i]); | |||||
i=0; | |||||
while(i<n){ | |||||
int j,k=map[i]; | |||||
float p=.5f; | |||||
float q=.5f; | |||||
float w=2.f*cos(wdel*k); | |||||
for(j=1;j<m;j+=2){ | |||||
q *= w-lsp[j-1]; | |||||
p *= w-lsp[j]; | |||||
} | |||||
if(j==m){ | |||||
/* odd order filter; slightly assymetric */ | |||||
/* the last coefficient */ | |||||
q*=w-lsp[j-1]; | |||||
p*=p*(4.f-w*w); | |||||
q*=q; | |||||
}else{ | |||||
/* even order filter; still symmetric */ | |||||
p*=p*(2.f-w); | |||||
q*=q*(2.f+w); | |||||
} | |||||
q=fromdB(amp/sqrt(p+q)-ampoffset); | |||||
curve[i]*=q; | |||||
while(map[++i]==k)curve[i]*=q; | |||||
} | |||||
} | |||||
#endif | |||||
#endif | |||||
static void cheby(float *g, int ord) { | |||||
int i, j; | |||||
g[0] *= .5f; | |||||
for(i=2; i<= ord; i++) { | |||||
for(j=ord; j >= i; j--) { | |||||
g[j-2] -= g[j]; | |||||
g[j] += g[j]; | |||||
} | |||||
} | |||||
} | |||||
static int JUCE_CDECL comp(const void *a,const void *b){ | |||||
return (*(float *)a<*(float *)b)-(*(float *)a>*(float *)b); | |||||
} | |||||
/* Newton-Raphson-Maehly actually functioned as a decent root finder, | |||||
but there are root sets for which it gets into limit cycles | |||||
(exacerbated by zero suppression) and fails. We can't afford to | |||||
fail, even if the failure is 1 in 100,000,000, so we now use | |||||
Laguerre and later polish with Newton-Raphson (which can then | |||||
afford to fail) */ | |||||
#define EPSILON 10e-7 | |||||
static int Laguerre_With_Deflation(float *a,int ord,float *r){ | |||||
int i,m; | |||||
double *defl=(double*)alloca(sizeof(*defl)*(ord+1)); | |||||
for(i=0;i<=ord;i++)defl[i]=a[i]; | |||||
for(m=ord;m>0;m--){ | |||||
double newx=0.f,delta; | |||||
/* iterate a root */ | |||||
while(1){ | |||||
double p=defl[m],pp=0.f,ppp=0.f,denom; | |||||
/* eval the polynomial and its first two derivatives */ | |||||
for(i=m;i>0;i--){ | |||||
ppp = newx*ppp + pp; | |||||
pp = newx*pp + p; | |||||
p = newx*p + defl[i-1]; | |||||
} | |||||
/* Laguerre's method */ | |||||
denom=(m-1) * ((m-1)*pp*pp - m*p*ppp); | |||||
if(denom<0) | |||||
return(-1); /* complex root! The LPC generator handed us a bad filter */ | |||||
if(pp>0){ | |||||
denom = pp + sqrt(denom); | |||||
if(denom<EPSILON)denom=EPSILON; | |||||
}else{ | |||||
denom = pp - sqrt(denom); | |||||
if(denom>-(EPSILON))denom=-(EPSILON); | |||||
} | |||||
delta = m*p/denom; | |||||
newx -= delta; | |||||
if(delta<0.f)delta*=-1; | |||||
if(fabs(delta/newx)<10e-12)break; | |||||
} | |||||
r[m-1]=newx; | |||||
/* forward deflation */ | |||||
for(i=m;i>0;i--) | |||||
defl[i-1]+=newx*defl[i]; | |||||
defl++; | |||||
} | |||||
return(0); | |||||
} | |||||
/* for spit-and-polish only */ | |||||
static int Newton_Raphson(float *a,int ord,float *r){ | |||||
int i, k, count=0; | |||||
double error=1.f; | |||||
double *root=(double*)alloca(ord*sizeof(*root)); | |||||
for(i=0; i<ord;i++) root[i] = r[i]; | |||||
while(error>1e-20){ | |||||
error=0; | |||||
for(i=0; i<ord; i++) { /* Update each point. */ | |||||
double pp=0.,delta; | |||||
double rooti=root[i]; | |||||
double p=a[ord]; | |||||
for(k=ord-1; k>= 0; k--) { | |||||
pp= pp* rooti + p; | |||||
p = p * rooti + a[k]; | |||||
} | |||||
delta = p/pp; | |||||
root[i] -= delta; | |||||
error+= delta*delta; | |||||
} | |||||
if(count>40)return(-1); | |||||
count++; | |||||
} | |||||
/* Replaced the original bubble sort with a real sort. With your | |||||
help, we can eliminate the bubble sort in our lifetime. --Monty */ | |||||
for(i=0; i<ord;i++) r[i] = root[i]; | |||||
return(0); | |||||
} | |||||
/* Convert lpc coefficients to lsp coefficients */ | |||||
int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m){ | |||||
int order2=(m+1)>>1; | |||||
int g1_order,g2_order; | |||||
float *g1=(float*)alloca(sizeof(*g1)*(order2+1)); | |||||
float *g2=(float*)alloca(sizeof(*g2)*(order2+1)); | |||||
float *g1r=(float*)alloca(sizeof(*g1r)*(order2+1)); | |||||
float *g2r=(float*)alloca(sizeof(*g2r)*(order2+1)); | |||||
int i; | |||||
/* even and odd are slightly different base cases */ | |||||
g1_order=(m+1)>>1; | |||||
g2_order=(m) >>1; | |||||
/* Compute the lengths of the x polynomials. */ | |||||
/* Compute the first half of K & R F1 & F2 polynomials. */ | |||||
/* Compute half of the symmetric and antisymmetric polynomials. */ | |||||
/* Remove the roots at +1 and -1. */ | |||||
g1[g1_order] = 1.f; | |||||
for(i=1;i<=g1_order;i++) g1[g1_order-i] = lpc[i-1]+lpc[m-i]; | |||||
g2[g2_order] = 1.f; | |||||
for(i=1;i<=g2_order;i++) g2[g2_order-i] = lpc[i-1]-lpc[m-i]; | |||||
if(g1_order>g2_order){ | |||||
for(i=2; i<=g2_order;i++) g2[g2_order-i] += g2[g2_order-i+2]; | |||||
}else{ | |||||
for(i=1; i<=g1_order;i++) g1[g1_order-i] -= g1[g1_order-i+1]; | |||||
for(i=1; i<=g2_order;i++) g2[g2_order-i] += g2[g2_order-i+1]; | |||||
} | |||||
/* Convert into polynomials in cos(alpha) */ | |||||
cheby(g1,g1_order); | |||||
cheby(g2,g2_order); | |||||
/* Find the roots of the 2 even polynomials.*/ | |||||
if(Laguerre_With_Deflation(g1,g1_order,g1r) || | |||||
Laguerre_With_Deflation(g2,g2_order,g2r)) | |||||
return(-1); | |||||
Newton_Raphson(g1,g1_order,g1r); /* if it fails, it leaves g1r alone */ | |||||
Newton_Raphson(g2,g2_order,g2r); /* if it fails, it leaves g2r alone */ | |||||
qsort(g1r,g1_order,sizeof(*g1r),comp); | |||||
qsort(g2r,g2_order,sizeof(*g2r),comp); | |||||
for(i=0;i<g1_order;i++) | |||||
lsp[i*2] = acos(g1r[i]); | |||||
for(i=0;i<g2_order;i++) | |||||
lsp[i*2+1] = acos(g2r[i]); | |||||
return(0); | |||||
} | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: LSP (also called LSF) conversion routines | |||||
The LSP generation code is taken (with minimal modification and a | |||||
few bugfixes) from "On the Computation of the LSP Frequencies" by | |||||
Joseph Rothweiler (see http://www.rothweiler.us for contact info). | |||||
The paper is available at: | |||||
https://web.archive.org/web/20110810174000/http://home.myfairpoint.net/vzenxj75/myown1/joe/lsf/index.html | |||||
********************************************************************/ | |||||
/* Note that the lpc-lsp conversion finds the roots of polynomial with | |||||
an iterative root polisher (CACM algorithm 283). It *is* possible | |||||
to confuse this algorithm into not converging; that should only | |||||
happen with absurdly closely spaced roots (very sharp peaks in the | |||||
LPC f response) which in turn should be impossible in our use of | |||||
the code. If this *does* happen anyway, it's a bug in the floor | |||||
finder; find the cause of the confusion (probably a single bin | |||||
spike or accidental near-float-limit resolution problems) and | |||||
correct it. */ | |||||
#include <math.h> | |||||
#include <string.h> | |||||
#include <stdlib.h> | |||||
#include "lsp.h" | |||||
#include "os.h" | |||||
#include "misc.h" | |||||
#include "lookup.h" | |||||
#include "scales.h" | |||||
/* three possible LSP to f curve functions; the exact computation | |||||
(float), a lookup based float implementation, and an integer | |||||
implementation. The float lookup is likely the optimal choice on | |||||
any machine with an FPU. The integer implementation is *not* fixed | |||||
point (due to the need for a large dynamic range and thus a | |||||
separately tracked exponent) and thus much more complex than the | |||||
relatively simple float implementations. It's mostly for future | |||||
work on a fully fixed point implementation for processors like the | |||||
ARM family. */ | |||||
/* define either of these (preferably FLOAT_LOOKUP) to have faster | |||||
but less precise implementation. */ | |||||
#undef FLOAT_LOOKUP | |||||
#undef INT_LOOKUP | |||||
#ifdef FLOAT_LOOKUP | |||||
#include "lookup.c" /* catch this in the build system; we #include for | |||||
compilers (like gcc) that can't inline across | |||||
modules */ | |||||
/* side effect: changes *lsp to cosines of lsp */ | |||||
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||||
float amp,float ampoffset){ | |||||
int i; | |||||
float wdel=M_PI/ln; | |||||
vorbis_fpu_control fpu; | |||||
vorbis_fpu_setround(&fpu); | |||||
for(i=0;i<m;i++)lsp[i]=vorbis_coslook(lsp[i]); | |||||
i=0; | |||||
while(i<n){ | |||||
int k=map[i]; | |||||
int qexp; | |||||
float p=.7071067812f; | |||||
float q=.7071067812f; | |||||
float w=vorbis_coslook(wdel*k); | |||||
float *ftmp=lsp; | |||||
int c=m>>1; | |||||
while(c--){ | |||||
q*=ftmp[0]-w; | |||||
p*=ftmp[1]-w; | |||||
ftmp+=2; | |||||
} | |||||
if(m&1){ | |||||
/* odd order filter; slightly assymetric */ | |||||
/* the last coefficient */ | |||||
q*=ftmp[0]-w; | |||||
q*=q; | |||||
p*=p*(1.f-w*w); | |||||
}else{ | |||||
/* even order filter; still symmetric */ | |||||
q*=q*(1.f+w); | |||||
p*=p*(1.f-w); | |||||
} | |||||
q=frexp(p+q,&qexp); | |||||
q=vorbis_fromdBlook(amp* | |||||
vorbis_invsqlook(q)* | |||||
vorbis_invsq2explook(qexp+m)- | |||||
ampoffset); | |||||
do{ | |||||
curve[i++]*=q; | |||||
}while(map[i]==k); | |||||
} | |||||
vorbis_fpu_restore(fpu); | |||||
} | |||||
#else | |||||
#ifdef INT_LOOKUP | |||||
#include "lookup.c" /* catch this in the build system; we #include for | |||||
compilers (like gcc) that can't inline across | |||||
modules */ | |||||
static const int MLOOP_1[64]={ | |||||
0,10,11,11, 12,12,12,12, 13,13,13,13, 13,13,13,13, | |||||
14,14,14,14, 14,14,14,14, 14,14,14,14, 14,14,14,14, | |||||
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, | |||||
15,15,15,15, 15,15,15,15, 15,15,15,15, 15,15,15,15, | |||||
}; | |||||
static const int MLOOP_2[64]={ | |||||
0,4,5,5, 6,6,6,6, 7,7,7,7, 7,7,7,7, | |||||
8,8,8,8, 8,8,8,8, 8,8,8,8, 8,8,8,8, | |||||
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, | |||||
9,9,9,9, 9,9,9,9, 9,9,9,9, 9,9,9,9, | |||||
}; | |||||
static const int MLOOP_3[8]={0,1,2,2,3,3,3,3}; | |||||
/* side effect: changes *lsp to cosines of lsp */ | |||||
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||||
float amp,float ampoffset){ | |||||
/* 0 <= m < 256 */ | |||||
/* set up for using all int later */ | |||||
int i; | |||||
int ampoffseti=rint(ampoffset*4096.f); | |||||
int ampi=rint(amp*16.f); | |||||
long *ilsp=(long*)alloca(m*sizeof(*ilsp)); | |||||
for(i=0;i<m;i++)ilsp[i]=vorbis_coslook_i(lsp[i]/M_PI*65536.f+.5f); | |||||
i=0; | |||||
while(i<n){ | |||||
int j,k=map[i]; | |||||
unsigned long pi=46341; /* 2**-.5 in 0.16 */ | |||||
unsigned long qi=46341; | |||||
int qexp=0,shift; | |||||
long wi=vorbis_coslook_i(k*65536/ln); | |||||
qi*=labs(ilsp[0]-wi); | |||||
pi*=labs(ilsp[1]-wi); | |||||
for(j=3;j<m;j+=2){ | |||||
if(!(shift=MLOOP_1[(pi|qi)>>25])) | |||||
if(!(shift=MLOOP_2[(pi|qi)>>19])) | |||||
shift=MLOOP_3[(pi|qi)>>16]; | |||||
qi=(qi>>shift)*labs(ilsp[j-1]-wi); | |||||
pi=(pi>>shift)*labs(ilsp[j]-wi); | |||||
qexp+=shift; | |||||
} | |||||
if(!(shift=MLOOP_1[(pi|qi)>>25])) | |||||
if(!(shift=MLOOP_2[(pi|qi)>>19])) | |||||
shift=MLOOP_3[(pi|qi)>>16]; | |||||
/* pi,qi normalized collectively, both tracked using qexp */ | |||||
if(m&1){ | |||||
/* odd order filter; slightly assymetric */ | |||||
/* the last coefficient */ | |||||
qi=(qi>>shift)*labs(ilsp[j-1]-wi); | |||||
pi=(pi>>shift)<<14; | |||||
qexp+=shift; | |||||
if(!(shift=MLOOP_1[(pi|qi)>>25])) | |||||
if(!(shift=MLOOP_2[(pi|qi)>>19])) | |||||
shift=MLOOP_3[(pi|qi)>>16]; | |||||
pi>>=shift; | |||||
qi>>=shift; | |||||
qexp+=shift-14*((m+1)>>1); | |||||
pi=((pi*pi)>>16); | |||||
qi=((qi*qi)>>16); | |||||
qexp=qexp*2+m; | |||||
pi*=(1<<14)-((wi*wi)>>14); | |||||
qi+=pi>>14; | |||||
}else{ | |||||
/* even order filter; still symmetric */ | |||||
/* p*=p(1-w), q*=q(1+w), let normalization drift because it isn't | |||||
worth tracking step by step */ | |||||
pi>>=shift; | |||||
qi>>=shift; | |||||
qexp+=shift-7*m; | |||||
pi=((pi*pi)>>16); | |||||
qi=((qi*qi)>>16); | |||||
qexp=qexp*2+m; | |||||
pi*=(1<<14)-wi; | |||||
qi*=(1<<14)+wi; | |||||
qi=(qi+pi)>>14; | |||||
} | |||||
/* we've let the normalization drift because it wasn't important; | |||||
however, for the lookup, things must be normalized again. We | |||||
need at most one right shift or a number of left shifts */ | |||||
if(qi&0xffff0000){ /* checks for 1.xxxxxxxxxxxxxxxx */ | |||||
qi>>=1; qexp++; | |||||
}else | |||||
while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ | |||||
qi<<=1; qexp--; | |||||
} | |||||
amp=vorbis_fromdBlook_i(ampi* /* n.4 */ | |||||
vorbis_invsqlook_i(qi,qexp)- | |||||
/* m.8, m+n<=8 */ | |||||
ampoffseti); /* 8.12[0] */ | |||||
curve[i]*=amp; | |||||
while(map[++i]==k)curve[i]*=amp; | |||||
} | |||||
} | |||||
#else | |||||
/* old, nonoptimized but simple version for any poor sap who needs to | |||||
figure out what the hell this code does, or wants the other | |||||
fraction of a dB precision */ | |||||
/* side effect: changes *lsp to cosines of lsp */ | |||||
void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||||
float amp,float ampoffset){ | |||||
int i; | |||||
float wdel=M_PI/ln; | |||||
for(i=0;i<m;i++)lsp[i]=2.f*cos(lsp[i]); | |||||
i=0; | |||||
while(i<n){ | |||||
int j,k=map[i]; | |||||
float p=.5f; | |||||
float q=.5f; | |||||
float w=2.f*cos(wdel*k); | |||||
for(j=1;j<m;j+=2){ | |||||
q *= w-lsp[j-1]; | |||||
p *= w-lsp[j]; | |||||
} | |||||
if(j==m){ | |||||
/* odd order filter; slightly assymetric */ | |||||
/* the last coefficient */ | |||||
q*=w-lsp[j-1]; | |||||
p*=p*(4.f-w*w); | |||||
q*=q; | |||||
}else{ | |||||
/* even order filter; still symmetric */ | |||||
p*=p*(2.f-w); | |||||
q*=q*(2.f+w); | |||||
} | |||||
q=fromdB(amp/sqrt(p+q)-ampoffset); | |||||
curve[i]*=q; | |||||
while(map[++i]==k)curve[i]*=q; | |||||
} | |||||
} | |||||
#endif | |||||
#endif | |||||
static void cheby(float *g, int ord) { | |||||
int i, j; | |||||
g[0] *= .5f; | |||||
for(i=2; i<= ord; i++) { | |||||
for(j=ord; j >= i; j--) { | |||||
g[j-2] -= g[j]; | |||||
g[j] += g[j]; | |||||
} | |||||
} | |||||
} | |||||
static int JUCE_CDECL comp(const void *a,const void *b){ | |||||
return (*(float *)a<*(float *)b)-(*(float *)a>*(float *)b); | |||||
} | |||||
/* Newton-Raphson-Maehly actually functioned as a decent root finder, | |||||
but there are root sets for which it gets into limit cycles | |||||
(exacerbated by zero suppression) and fails. We can't afford to | |||||
fail, even if the failure is 1 in 100,000,000, so we now use | |||||
Laguerre and later polish with Newton-Raphson (which can then | |||||
afford to fail) */ | |||||
#define EPSILON 10e-7 | |||||
static int Laguerre_With_Deflation(float *a,int ord,float *r){ | |||||
int i,m; | |||||
double *defl=(double*)alloca(sizeof(*defl)*(ord+1)); | |||||
for(i=0;i<=ord;i++)defl[i]=a[i]; | |||||
for(m=ord;m>0;m--){ | |||||
double newx=0.f,delta; | |||||
/* iterate a root */ | |||||
while(1){ | |||||
double p=defl[m],pp=0.f,ppp=0.f,denom; | |||||
/* eval the polynomial and its first two derivatives */ | |||||
for(i=m;i>0;i--){ | |||||
ppp = newx*ppp + pp; | |||||
pp = newx*pp + p; | |||||
p = newx*p + defl[i-1]; | |||||
} | |||||
/* Laguerre's method */ | |||||
denom=(m-1) * ((m-1)*pp*pp - m*p*ppp); | |||||
if(denom<0) | |||||
return(-1); /* complex root! The LPC generator handed us a bad filter */ | |||||
if(pp>0){ | |||||
denom = pp + sqrt(denom); | |||||
if(denom<EPSILON)denom=EPSILON; | |||||
}else{ | |||||
denom = pp - sqrt(denom); | |||||
if(denom>-(EPSILON))denom=-(EPSILON); | |||||
} | |||||
delta = m*p/denom; | |||||
newx -= delta; | |||||
if(delta<0.f)delta*=-1; | |||||
if(fabs(delta/newx)<10e-12)break; | |||||
} | |||||
r[m-1]=newx; | |||||
/* forward deflation */ | |||||
for(i=m;i>0;i--) | |||||
defl[i-1]+=newx*defl[i]; | |||||
defl++; | |||||
} | |||||
return(0); | |||||
} | |||||
/* for spit-and-polish only */ | |||||
static int Newton_Raphson(float *a,int ord,float *r){ | |||||
int i, k, count=0; | |||||
double error=1.f; | |||||
double *root=(double*)alloca(ord*sizeof(*root)); | |||||
for(i=0; i<ord;i++) root[i] = r[i]; | |||||
while(error>1e-20){ | |||||
error=0; | |||||
for(i=0; i<ord; i++) { /* Update each point. */ | |||||
double pp=0.,delta; | |||||
double rooti=root[i]; | |||||
double p=a[ord]; | |||||
for(k=ord-1; k>= 0; k--) { | |||||
pp= pp* rooti + p; | |||||
p = p * rooti + a[k]; | |||||
} | |||||
delta = p/pp; | |||||
root[i] -= delta; | |||||
error+= delta*delta; | |||||
} | |||||
if(count>40)return(-1); | |||||
count++; | |||||
} | |||||
/* Replaced the original bubble sort with a real sort. With your | |||||
help, we can eliminate the bubble sort in our lifetime. --Monty */ | |||||
for(i=0; i<ord;i++) r[i] = root[i]; | |||||
return(0); | |||||
} | |||||
/* Convert lpc coefficients to lsp coefficients */ | |||||
int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m){ | |||||
int order2=(m+1)>>1; | |||||
int g1_order,g2_order; | |||||
float *g1=(float*)alloca(sizeof(*g1)*(order2+1)); | |||||
float *g2=(float*)alloca(sizeof(*g2)*(order2+1)); | |||||
float *g1r=(float*)alloca(sizeof(*g1r)*(order2+1)); | |||||
float *g2r=(float*)alloca(sizeof(*g2r)*(order2+1)); | |||||
int i; | |||||
/* even and odd are slightly different base cases */ | |||||
g1_order=(m+1)>>1; | |||||
g2_order=(m) >>1; | |||||
/* Compute the lengths of the x polynomials. */ | |||||
/* Compute the first half of K & R F1 & F2 polynomials. */ | |||||
/* Compute half of the symmetric and antisymmetric polynomials. */ | |||||
/* Remove the roots at +1 and -1. */ | |||||
g1[g1_order] = 1.f; | |||||
for(i=1;i<=g1_order;i++) g1[g1_order-i] = lpc[i-1]+lpc[m-i]; | |||||
g2[g2_order] = 1.f; | |||||
for(i=1;i<=g2_order;i++) g2[g2_order-i] = lpc[i-1]-lpc[m-i]; | |||||
if(g1_order>g2_order){ | |||||
for(i=2; i<=g2_order;i++) g2[g2_order-i] += g2[g2_order-i+2]; | |||||
}else{ | |||||
for(i=1; i<=g1_order;i++) g1[g1_order-i] -= g1[g1_order-i+1]; | |||||
for(i=1; i<=g2_order;i++) g2[g2_order-i] += g2[g2_order-i+1]; | |||||
} | |||||
/* Convert into polynomials in cos(alpha) */ | |||||
cheby(g1,g1_order); | |||||
cheby(g2,g2_order); | |||||
/* Find the roots of the 2 even polynomials.*/ | |||||
if(Laguerre_With_Deflation(g1,g1_order,g1r) || | |||||
Laguerre_With_Deflation(g2,g2_order,g2r)) | |||||
return(-1); | |||||
Newton_Raphson(g1,g1_order,g1r); /* if it fails, it leaves g1r alone */ | |||||
Newton_Raphson(g2,g2_order,g2r); /* if it fails, it leaves g2r alone */ | |||||
qsort(g1r,g1_order,sizeof(*g1r),comp); | |||||
qsort(g2r,g2_order,sizeof(*g2r),comp); | |||||
for(i=0;i<g1_order;i++) | |||||
lsp[i*2] = acos(g1r[i]); | |||||
for(i=0;i<g2_order;i++) | |||||
lsp[i*2+1] = acos(g2r[i]); | |||||
return(0); | |||||
} |
@@ -1,28 +1,27 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: LSP (also called LSF) conversion routines | |||||
last mod: $Id: lsp.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_LSP_H_ | |||||
#define _V_LSP_H_ | |||||
extern int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m); | |||||
extern void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln, | |||||
float *lsp,int m, | |||||
float amp,float ampoffset); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: LSP (also called LSF) conversion routines | |||||
********************************************************************/ | |||||
#ifndef _V_LSP_H_ | |||||
#define _V_LSP_H_ | |||||
extern int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m); | |||||
extern void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln, | |||||
float *lsp,int m, | |||||
float amp,float ampoffset); | |||||
#endif |
@@ -1,71 +1,70 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: modified discrete cosine transform prototypes | |||||
last mod: $Id: mdct.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _OGG_mdct_H_ | |||||
#define _OGG_mdct_H_ | |||||
#include "../../codec.h" | |||||
/*#define MDCT_INTEGERIZED <- be warned there could be some hurt left here*/ | |||||
#ifdef MDCT_INTEGERIZED | |||||
#define DATA_TYPE int | |||||
#define REG_TYPE int | |||||
#define TRIGBITS 14 | |||||
#define cPI3_8 6270 | |||||
#define cPI2_8 11585 | |||||
#define cPI1_8 15137 | |||||
#define FLOAT_CONV(x) ((int)((x)*(1<<TRIGBITS)+.5)) | |||||
#define MULT_NORM(x) ((x)>>TRIGBITS) | |||||
#define HALVE(x) ((x)>>1) | |||||
#else | |||||
#define DATA_TYPE float | |||||
#define REG_TYPE float | |||||
#define cPI3_8 .38268343236508977175F | |||||
#define cPI2_8 .70710678118654752441F | |||||
#define cPI1_8 .92387953251128675613F | |||||
#define FLOAT_CONV(x) (x) | |||||
#define MULT_NORM(x) (x) | |||||
#define HALVE(x) ((x)*.5f) | |||||
#endif | |||||
typedef struct { | |||||
int n; | |||||
int log2n; | |||||
DATA_TYPE *trig; | |||||
int *bitrev; | |||||
DATA_TYPE scale; | |||||
} mdct_lookup; | |||||
extern void mdct_init(mdct_lookup *lookup,int n); | |||||
extern void mdct_clear(mdct_lookup *l); | |||||
extern void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); | |||||
extern void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: modified discrete cosine transform prototypes | |||||
********************************************************************/ | |||||
#ifndef _OGG_mdct_H_ | |||||
#define _OGG_mdct_H_ | |||||
#include "../../codec.h" | |||||
/*#define MDCT_INTEGERIZED <- be warned there could be some hurt left here*/ | |||||
#ifdef MDCT_INTEGERIZED | |||||
#define DATA_TYPE int | |||||
#define REG_TYPE register int | |||||
#define TRIGBITS 14 | |||||
#define cPI3_8 6270 | |||||
#define cPI2_8 11585 | |||||
#define cPI1_8 15137 | |||||
#define FLOAT_CONV(x) ((int)((x)*(1<<TRIGBITS)+.5)) | |||||
#define MULT_NORM(x) ((x)>>TRIGBITS) | |||||
#define HALVE(x) ((x)>>1) | |||||
#else | |||||
#define DATA_TYPE float | |||||
#define REG_TYPE float | |||||
#define cPI3_8 .38268343236508977175F | |||||
#define cPI2_8 .70710678118654752441F | |||||
#define cPI1_8 .92387953251128675613F | |||||
#define FLOAT_CONV(x) (x) | |||||
#define MULT_NORM(x) (x) | |||||
#define HALVE(x) ((x)*.5f) | |||||
#endif | |||||
typedef struct { | |||||
int n; | |||||
int log2n; | |||||
DATA_TYPE *trig; | |||||
int *bitrev; | |||||
DATA_TYPE scale; | |||||
} mdct_lookup; | |||||
extern void mdct_init(mdct_lookup *lookup,int n); | |||||
extern void mdct_clear(mdct_lookup *l); | |||||
extern void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); | |||||
extern void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out); | |||||
#endif |
@@ -0,0 +1,216 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
********************************************************************/ | |||||
#define HEAD_ALIGN 32 | |||||
#include <pthread.h> | |||||
#include <stdlib.h> | |||||
#include <string.h> | |||||
#include <stdio.h> | |||||
#include "vorbis/codec.h" | |||||
#define MISC_C | |||||
#include "misc.h" | |||||
#include <sys/time.h> | |||||
static pthread_mutex_t memlock=PTHREAD_MUTEX_INITIALIZER; | |||||
static void **pointers=NULL; | |||||
static long *insertlist=NULL; /* We can't embed this in the pointer list; | |||||
a pointer can have any value... */ | |||||
static char **files=NULL; | |||||
static long *file_bytes=NULL; | |||||
static int filecount=0; | |||||
static int ptop=0; | |||||
static int palloced=0; | |||||
static int pinsert=0; | |||||
typedef struct { | |||||
char *file; | |||||
long line; | |||||
long ptr; | |||||
long bytes; | |||||
} head; | |||||
long global_bytes=0; | |||||
long start_time=-1; | |||||
static void *_insert(void *ptr,long bytes,char *file,long line){ | |||||
((head *)ptr)->file=file; | |||||
((head *)ptr)->line=line; | |||||
((head *)ptr)->ptr=pinsert; | |||||
((head *)ptr)->bytes=bytes-HEAD_ALIGN; | |||||
pthread_mutex_lock(&memlock); | |||||
if(pinsert>=palloced){ | |||||
palloced+=64; | |||||
if(pointers){ | |||||
pointers=(void **)realloc(pointers,sizeof(void **)*palloced); | |||||
insertlist=(long *)realloc(insertlist,sizeof(long *)*palloced); | |||||
}else{ | |||||
pointers=(void **)malloc(sizeof(void **)*palloced); | |||||
insertlist=(long *)malloc(sizeof(long *)*palloced); | |||||
} | |||||
} | |||||
pointers[pinsert]=ptr; | |||||
if(pinsert==ptop) | |||||
pinsert=++ptop; | |||||
else | |||||
pinsert=insertlist[pinsert]; | |||||
#ifdef _VDBG_GRAPHFILE | |||||
{ | |||||
FILE *out; | |||||
struct timeval tv; | |||||
static struct timezone tz; | |||||
int i; | |||||
char buffer[80]; | |||||
gettimeofday(&tv,&tz); | |||||
for(i=0;i<filecount;i++) | |||||
if(!strcmp(file,files[i]))break; | |||||
if(i==filecount){ | |||||
filecount++; | |||||
if(!files){ | |||||
files=malloc(filecount*sizeof(*files)); | |||||
file_bytes=malloc(filecount*sizeof(*file_bytes)); | |||||
}else{ | |||||
files=realloc(files,filecount*sizeof(*files)); | |||||
file_bytes=realloc(file_bytes,filecount*sizeof(*file_bytes)); | |||||
} | |||||
files[i]=strdup(file); | |||||
file_bytes[i]=0; | |||||
} | |||||
file_bytes[i]+=bytes-HEAD_ALIGN; | |||||
if(start_time==-1)start_time=(tv.tv_sec*1000)+(tv.tv_usec/1000); | |||||
snprintf(buffer,80,"%s%s",file,_VDBG_GRAPHFILE); | |||||
out=fopen(buffer,"a"); | |||||
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), | |||||
file_bytes[i]-(bytes-HEAD_ALIGN)); | |||||
fprintf(out,"%ld, %ld # FILE %s LINE %ld\n", | |||||
-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), | |||||
file_bytes[i],file,line); | |||||
fclose(out); | |||||
out=fopen(_VDBG_GRAPHFILE,"a"); | |||||
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), | |||||
global_bytes); | |||||
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), | |||||
global_bytes+(bytes-HEAD_ALIGN)); | |||||
fclose(out); | |||||
} | |||||
#endif | |||||
global_bytes+=(bytes-HEAD_ALIGN); | |||||
pthread_mutex_unlock(&memlock); | |||||
return(ptr+HEAD_ALIGN); | |||||
} | |||||
static void _ripremove(void *ptr){ | |||||
int insert; | |||||
pthread_mutex_lock(&memlock); | |||||
#ifdef _VDBG_GRAPHFILE | |||||
{ | |||||
FILE *out=fopen(_VDBG_GRAPHFILE,"a"); | |||||
struct timeval tv; | |||||
static struct timezone tz; | |||||
char buffer[80]; | |||||
char *file =((head *)ptr)->file; | |||||
long bytes =((head *)ptr)->bytes; | |||||
int i; | |||||
gettimeofday(&tv,&tz); | |||||
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), | |||||
global_bytes); | |||||
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), | |||||
global_bytes-((head *)ptr)->bytes); | |||||
fclose(out); | |||||
for(i=0;i<filecount;i++) | |||||
if(!strcmp(file,files[i]))break; | |||||
snprintf(buffer,80,"%s%s",file,_VDBG_GRAPHFILE); | |||||
out=fopen(buffer,"a"); | |||||
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), | |||||
file_bytes[i]); | |||||
fprintf(out,"%ld, %ld\n",-start_time+(tv.tv_sec*1000)+(tv.tv_usec/1000), | |||||
file_bytes[i]-bytes); | |||||
fclose(out); | |||||
file_bytes[i]-=bytes; | |||||
} | |||||
#endif | |||||
global_bytes-=((head *)ptr)->bytes; | |||||
insert=((head *)ptr)->ptr; | |||||
insertlist[insert]=pinsert; | |||||
pinsert=insert; | |||||
if(pointers[insert]==NULL){ | |||||
fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing previously freed memory\n"); | |||||
fprintf(stderr,"\t%s %ld\n",((head *)ptr)->file,((head *)ptr)->line); | |||||
} | |||||
if(global_bytes<0){ | |||||
fprintf(stderr,"DEBUGGING MALLOC ERROR: freeing unmalloced memory\n"); | |||||
} | |||||
pointers[insert]=NULL; | |||||
pthread_mutex_unlock(&memlock); | |||||
} | |||||
void _VDBG_dump(void){ | |||||
int i; | |||||
pthread_mutex_lock(&memlock); | |||||
for(i=0;i<ptop;i++){ | |||||
head *ptr=pointers[i]; | |||||
if(ptr) | |||||
fprintf(stderr,"unfreed bytes from %s:%ld\n", | |||||
ptr->file,ptr->line); | |||||
} | |||||
pthread_mutex_unlock(&memlock); | |||||
} | |||||
void *_VDBG_malloc(void *ptr,long bytes,char *file,long line){ | |||||
if(bytes<=0) | |||||
fprintf(stderr,"bad malloc request (%ld bytes) from %s:%ld\n",bytes,file,line); | |||||
bytes+=HEAD_ALIGN; | |||||
if(ptr){ | |||||
ptr-=HEAD_ALIGN; | |||||
_ripremove(ptr); | |||||
ptr=realloc(ptr,bytes); | |||||
}else{ | |||||
ptr=malloc(bytes); | |||||
memset(ptr,0,bytes); | |||||
} | |||||
return _insert(ptr,bytes,file,line); | |||||
} | |||||
void _VDBG_free(void *ptr,char *file,long line){ | |||||
if(ptr){ | |||||
ptr-=HEAD_ALIGN; | |||||
_ripremove(ptr); | |||||
free(ptr); | |||||
} | |||||
} | |||||
@@ -1,53 +1,53 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: miscellaneous prototypes | |||||
last mod: $Id: misc.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_RANDOM_H_ | |||||
#define _V_RANDOM_H_ | |||||
#include "../../codec.h" | |||||
extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); | |||||
extern void _vorbis_block_ripcord(vorbis_block *vb); | |||||
#ifdef ANALYSIS | |||||
extern int analysis_noisy; | |||||
extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, | |||||
ogg_int64_t off); | |||||
extern void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB, | |||||
ogg_int64_t off); | |||||
#endif | |||||
#ifdef DEBUG_MALLOC | |||||
#define _VDBG_GRAPHFILE "malloc.m" | |||||
#undef _VDBG_GRAPHFILE | |||||
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line); | |||||
extern void _VDBG_free(void *ptr,char *file,long line); | |||||
#ifndef MISC_C | |||||
#undef _ogg_malloc | |||||
#undef _ogg_calloc | |||||
#undef _ogg_realloc | |||||
#undef _ogg_free | |||||
#define _ogg_malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__) | |||||
#define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__) | |||||
#define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__) | |||||
#define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__) | |||||
#endif | |||||
#endif | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: miscellaneous prototypes | |||||
********************************************************************/ | |||||
#ifndef _V_RANDOM_H_ | |||||
#define _V_RANDOM_H_ | |||||
#include "../../codec.h" | |||||
extern void *_vorbis_block_alloc(vorbis_block *vb,long bytes); | |||||
extern void _vorbis_block_ripcord(vorbis_block *vb); | |||||
extern int ov_ilog(ogg_uint32_t v); | |||||
#ifdef ANALYSIS | |||||
extern int analysis_noisy; | |||||
extern void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, | |||||
ogg_int64_t off); | |||||
extern void _analysis_output_always(char *base,int i,float *v,int n,int bark,int dB, | |||||
ogg_int64_t off); | |||||
#endif | |||||
#ifdef DEBUG_MALLOC | |||||
#define _VDBG_GRAPHFILE "malloc.m" | |||||
#undef _VDBG_GRAPHFILE | |||||
extern void *_VDBG_malloc(void *ptr,long bytes,char *file,long line); | |||||
extern void _VDBG_free(void *ptr,char *file,long line); | |||||
#ifndef MISC_C | |||||
#undef _ogg_malloc | |||||
#undef _ogg_calloc | |||||
#undef _ogg_realloc | |||||
#undef _ogg_free | |||||
#define _ogg_malloc(x) _VDBG_malloc(NULL,(x),__FILE__,__LINE__) | |||||
#define _ogg_calloc(x,y) _VDBG_malloc(NULL,(x)*(y),__FILE__,__LINE__) | |||||
#define _ogg_realloc(x,y) _VDBG_malloc((x),(y),__FILE__,__LINE__) | |||||
#define _ogg_free(x) _VDBG_free((x),__FILE__,__LINE__) | |||||
#endif | |||||
#endif | |||||
#endif |
@@ -1,260 +1,259 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: key floor settings | |||||
last mod: $Id: floor_all.h 17050 2010-03-26 01:34:42Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
#include "../books/floor/floor_books.h" | |||||
static const static_codebook*const _floor_128x4_books[]={ | |||||
&_huff_book_line_128x4_class0, | |||||
&_huff_book_line_128x4_0sub0, | |||||
&_huff_book_line_128x4_0sub1, | |||||
&_huff_book_line_128x4_0sub2, | |||||
&_huff_book_line_128x4_0sub3, | |||||
}; | |||||
static const static_codebook*const _floor_256x4_books[]={ | |||||
&_huff_book_line_256x4_class0, | |||||
&_huff_book_line_256x4_0sub0, | |||||
&_huff_book_line_256x4_0sub1, | |||||
&_huff_book_line_256x4_0sub2, | |||||
&_huff_book_line_256x4_0sub3, | |||||
}; | |||||
static const static_codebook*const _floor_128x7_books[]={ | |||||
&_huff_book_line_128x7_class0, | |||||
&_huff_book_line_128x7_class1, | |||||
&_huff_book_line_128x7_0sub1, | |||||
&_huff_book_line_128x7_0sub2, | |||||
&_huff_book_line_128x7_0sub3, | |||||
&_huff_book_line_128x7_1sub1, | |||||
&_huff_book_line_128x7_1sub2, | |||||
&_huff_book_line_128x7_1sub3, | |||||
}; | |||||
static const static_codebook*const _floor_256x7_books[]={ | |||||
&_huff_book_line_256x7_class0, | |||||
&_huff_book_line_256x7_class1, | |||||
&_huff_book_line_256x7_0sub1, | |||||
&_huff_book_line_256x7_0sub2, | |||||
&_huff_book_line_256x7_0sub3, | |||||
&_huff_book_line_256x7_1sub1, | |||||
&_huff_book_line_256x7_1sub2, | |||||
&_huff_book_line_256x7_1sub3, | |||||
}; | |||||
static const static_codebook*const _floor_128x11_books[]={ | |||||
&_huff_book_line_128x11_class1, | |||||
&_huff_book_line_128x11_class2, | |||||
&_huff_book_line_128x11_class3, | |||||
&_huff_book_line_128x11_0sub0, | |||||
&_huff_book_line_128x11_1sub0, | |||||
&_huff_book_line_128x11_1sub1, | |||||
&_huff_book_line_128x11_2sub1, | |||||
&_huff_book_line_128x11_2sub2, | |||||
&_huff_book_line_128x11_2sub3, | |||||
&_huff_book_line_128x11_3sub1, | |||||
&_huff_book_line_128x11_3sub2, | |||||
&_huff_book_line_128x11_3sub3, | |||||
}; | |||||
static const static_codebook*const _floor_128x17_books[]={ | |||||
&_huff_book_line_128x17_class1, | |||||
&_huff_book_line_128x17_class2, | |||||
&_huff_book_line_128x17_class3, | |||||
&_huff_book_line_128x17_0sub0, | |||||
&_huff_book_line_128x17_1sub0, | |||||
&_huff_book_line_128x17_1sub1, | |||||
&_huff_book_line_128x17_2sub1, | |||||
&_huff_book_line_128x17_2sub2, | |||||
&_huff_book_line_128x17_2sub3, | |||||
&_huff_book_line_128x17_3sub1, | |||||
&_huff_book_line_128x17_3sub2, | |||||
&_huff_book_line_128x17_3sub3, | |||||
}; | |||||
static const static_codebook*const _floor_256x4low_books[]={ | |||||
&_huff_book_line_256x4low_class0, | |||||
&_huff_book_line_256x4low_0sub0, | |||||
&_huff_book_line_256x4low_0sub1, | |||||
&_huff_book_line_256x4low_0sub2, | |||||
&_huff_book_line_256x4low_0sub3, | |||||
}; | |||||
static const static_codebook*const _floor_1024x27_books[]={ | |||||
&_huff_book_line_1024x27_class1, | |||||
&_huff_book_line_1024x27_class2, | |||||
&_huff_book_line_1024x27_class3, | |||||
&_huff_book_line_1024x27_class4, | |||||
&_huff_book_line_1024x27_0sub0, | |||||
&_huff_book_line_1024x27_1sub0, | |||||
&_huff_book_line_1024x27_1sub1, | |||||
&_huff_book_line_1024x27_2sub0, | |||||
&_huff_book_line_1024x27_2sub1, | |||||
&_huff_book_line_1024x27_3sub1, | |||||
&_huff_book_line_1024x27_3sub2, | |||||
&_huff_book_line_1024x27_3sub3, | |||||
&_huff_book_line_1024x27_4sub1, | |||||
&_huff_book_line_1024x27_4sub2, | |||||
&_huff_book_line_1024x27_4sub3, | |||||
}; | |||||
static const static_codebook*const _floor_2048x27_books[]={ | |||||
&_huff_book_line_2048x27_class1, | |||||
&_huff_book_line_2048x27_class2, | |||||
&_huff_book_line_2048x27_class3, | |||||
&_huff_book_line_2048x27_class4, | |||||
&_huff_book_line_2048x27_0sub0, | |||||
&_huff_book_line_2048x27_1sub0, | |||||
&_huff_book_line_2048x27_1sub1, | |||||
&_huff_book_line_2048x27_2sub0, | |||||
&_huff_book_line_2048x27_2sub1, | |||||
&_huff_book_line_2048x27_3sub1, | |||||
&_huff_book_line_2048x27_3sub2, | |||||
&_huff_book_line_2048x27_3sub3, | |||||
&_huff_book_line_2048x27_4sub1, | |||||
&_huff_book_line_2048x27_4sub2, | |||||
&_huff_book_line_2048x27_4sub3, | |||||
}; | |||||
static const static_codebook*const _floor_512x17_books[]={ | |||||
&_huff_book_line_512x17_class1, | |||||
&_huff_book_line_512x17_class2, | |||||
&_huff_book_line_512x17_class3, | |||||
&_huff_book_line_512x17_0sub0, | |||||
&_huff_book_line_512x17_1sub0, | |||||
&_huff_book_line_512x17_1sub1, | |||||
&_huff_book_line_512x17_2sub1, | |||||
&_huff_book_line_512x17_2sub2, | |||||
&_huff_book_line_512x17_2sub3, | |||||
&_huff_book_line_512x17_3sub1, | |||||
&_huff_book_line_512x17_3sub2, | |||||
&_huff_book_line_512x17_3sub3, | |||||
}; | |||||
static const static_codebook*const _floor_Xx0_books[]={ | |||||
0 | |||||
}; | |||||
static const static_codebook*const *const _floor_books[11]={ | |||||
_floor_128x4_books, | |||||
_floor_256x4_books, | |||||
_floor_128x7_books, | |||||
_floor_256x7_books, | |||||
_floor_128x11_books, | |||||
_floor_128x17_books, | |||||
_floor_256x4low_books, | |||||
_floor_1024x27_books, | |||||
_floor_2048x27_books, | |||||
_floor_512x17_books, | |||||
_floor_Xx0_books, | |||||
}; | |||||
static const vorbis_info_floor1 _floor[11]={ | |||||
/* 0: 128 x 4 */ | |||||
{ | |||||
1,{0},{4},{2},{0}, | |||||
{{1,2,3,4}}, | |||||
4,{0,128, 33,8,16,70}, | |||||
60,30,500, 1.,18., 128 | |||||
}, | |||||
/* 1: 256 x 4 */ | |||||
{ | |||||
1,{0},{4},{2},{0}, | |||||
{{1,2,3,4}}, | |||||
4,{0,256, 66,16,32,140}, | |||||
60,30,500, 1.,18., 256 | |||||
}, | |||||
/* 2: 128 x 7 */ | |||||
{ | |||||
2,{0,1},{3,4},{2,2},{0,1}, | |||||
{{-1,2,3,4},{-1,5,6,7}}, | |||||
4,{0,128, 14,4,58, 2,8,28,90}, | |||||
60,30,500, 1.,18., 128 | |||||
}, | |||||
/* 3: 256 x 7 */ | |||||
{ | |||||
2,{0,1},{3,4},{2,2},{0,1}, | |||||
{{-1,2,3,4},{-1,5,6,7}}, | |||||
4,{0,256, 28,8,116, 4,16,56,180}, | |||||
60,30,500, 1.,18., 256 | |||||
}, | |||||
/* 4: 128 x 11 */ | |||||
{ | |||||
4,{0,1,2,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, | |||||
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, | |||||
2,{0,128, 8,33, 4,16,70, 2,6,12, 23,46,90}, | |||||
60,30,500, 1,18., 128 | |||||
}, | |||||
/* 5: 128 x 17 */ | |||||
{ | |||||
6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, | |||||
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, | |||||
2,{0,128, 12,46, 4,8,16, 23,33,70, 2,6,10, 14,19,28, 39,58,90}, | |||||
60,30,500, 1,18., 128 | |||||
}, | |||||
/* 6: 256 x 4 (low bitrate version) */ | |||||
{ | |||||
1,{0},{4},{2},{0}, | |||||
{{1,2,3,4}}, | |||||
4,{0,256, 66,16,32,140}, | |||||
60,30,500, 1.,18., 256 | |||||
}, | |||||
/* 7: 1024 x 27 */ | |||||
{ | |||||
8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3}, | |||||
{{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}}, | |||||
2,{0,1024, 93,23,372, 6,46,186,750, 14,33,65, 130,260,556, | |||||
3,10,18,28, 39,55,79,111, 158,220,312, 464,650,850}, | |||||
60,30,500, 3,18., 1024 | |||||
}, | |||||
/* 8: 2048 x 27 */ | |||||
{ | |||||
8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3}, | |||||
{{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}}, | |||||
2,{0,2048, 186,46,744, 12,92,372,1500, 28,66,130, 260,520,1112, | |||||
6,20,36,56, 78,110,158,222, 316,440,624, 928,1300,1700}, | |||||
60,30,500, 3,18., 2048 | |||||
}, | |||||
/* 9: 512 x 17 */ | |||||
{ | |||||
6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, | |||||
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, | |||||
2,{0,512, 46,186, 16,33,65, 93,130,278, | |||||
7,23,39, 55,79,110, 156,232,360}, | |||||
60,30,500, 1,18., 512 | |||||
}, | |||||
/* 10: X x 0 (LFE floor; edge posts only) */ | |||||
{ | |||||
0,{0}, {0},{0},{-1}, | |||||
{{-1}}, | |||||
2,{0,12}, | |||||
60,30,500, 1.,18., 10 | |||||
}, | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: key floor settings | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
#include "../books/floor/floor_books.h" | |||||
static const static_codebook*const _floor_128x4_books[]={ | |||||
&_huff_book_line_128x4_class0, | |||||
&_huff_book_line_128x4_0sub0, | |||||
&_huff_book_line_128x4_0sub1, | |||||
&_huff_book_line_128x4_0sub2, | |||||
&_huff_book_line_128x4_0sub3, | |||||
}; | |||||
static const static_codebook*const _floor_256x4_books[]={ | |||||
&_huff_book_line_256x4_class0, | |||||
&_huff_book_line_256x4_0sub0, | |||||
&_huff_book_line_256x4_0sub1, | |||||
&_huff_book_line_256x4_0sub2, | |||||
&_huff_book_line_256x4_0sub3, | |||||
}; | |||||
static const static_codebook*const _floor_128x7_books[]={ | |||||
&_huff_book_line_128x7_class0, | |||||
&_huff_book_line_128x7_class1, | |||||
&_huff_book_line_128x7_0sub1, | |||||
&_huff_book_line_128x7_0sub2, | |||||
&_huff_book_line_128x7_0sub3, | |||||
&_huff_book_line_128x7_1sub1, | |||||
&_huff_book_line_128x7_1sub2, | |||||
&_huff_book_line_128x7_1sub3, | |||||
}; | |||||
static const static_codebook*const _floor_256x7_books[]={ | |||||
&_huff_book_line_256x7_class0, | |||||
&_huff_book_line_256x7_class1, | |||||
&_huff_book_line_256x7_0sub1, | |||||
&_huff_book_line_256x7_0sub2, | |||||
&_huff_book_line_256x7_0sub3, | |||||
&_huff_book_line_256x7_1sub1, | |||||
&_huff_book_line_256x7_1sub2, | |||||
&_huff_book_line_256x7_1sub3, | |||||
}; | |||||
static const static_codebook*const _floor_128x11_books[]={ | |||||
&_huff_book_line_128x11_class1, | |||||
&_huff_book_line_128x11_class2, | |||||
&_huff_book_line_128x11_class3, | |||||
&_huff_book_line_128x11_0sub0, | |||||
&_huff_book_line_128x11_1sub0, | |||||
&_huff_book_line_128x11_1sub1, | |||||
&_huff_book_line_128x11_2sub1, | |||||
&_huff_book_line_128x11_2sub2, | |||||
&_huff_book_line_128x11_2sub3, | |||||
&_huff_book_line_128x11_3sub1, | |||||
&_huff_book_line_128x11_3sub2, | |||||
&_huff_book_line_128x11_3sub3, | |||||
}; | |||||
static const static_codebook*const _floor_128x17_books[]={ | |||||
&_huff_book_line_128x17_class1, | |||||
&_huff_book_line_128x17_class2, | |||||
&_huff_book_line_128x17_class3, | |||||
&_huff_book_line_128x17_0sub0, | |||||
&_huff_book_line_128x17_1sub0, | |||||
&_huff_book_line_128x17_1sub1, | |||||
&_huff_book_line_128x17_2sub1, | |||||
&_huff_book_line_128x17_2sub2, | |||||
&_huff_book_line_128x17_2sub3, | |||||
&_huff_book_line_128x17_3sub1, | |||||
&_huff_book_line_128x17_3sub2, | |||||
&_huff_book_line_128x17_3sub3, | |||||
}; | |||||
static const static_codebook*const _floor_256x4low_books[]={ | |||||
&_huff_book_line_256x4low_class0, | |||||
&_huff_book_line_256x4low_0sub0, | |||||
&_huff_book_line_256x4low_0sub1, | |||||
&_huff_book_line_256x4low_0sub2, | |||||
&_huff_book_line_256x4low_0sub3, | |||||
}; | |||||
static const static_codebook*const _floor_1024x27_books[]={ | |||||
&_huff_book_line_1024x27_class1, | |||||
&_huff_book_line_1024x27_class2, | |||||
&_huff_book_line_1024x27_class3, | |||||
&_huff_book_line_1024x27_class4, | |||||
&_huff_book_line_1024x27_0sub0, | |||||
&_huff_book_line_1024x27_1sub0, | |||||
&_huff_book_line_1024x27_1sub1, | |||||
&_huff_book_line_1024x27_2sub0, | |||||
&_huff_book_line_1024x27_2sub1, | |||||
&_huff_book_line_1024x27_3sub1, | |||||
&_huff_book_line_1024x27_3sub2, | |||||
&_huff_book_line_1024x27_3sub3, | |||||
&_huff_book_line_1024x27_4sub1, | |||||
&_huff_book_line_1024x27_4sub2, | |||||
&_huff_book_line_1024x27_4sub3, | |||||
}; | |||||
static const static_codebook*const _floor_2048x27_books[]={ | |||||
&_huff_book_line_2048x27_class1, | |||||
&_huff_book_line_2048x27_class2, | |||||
&_huff_book_line_2048x27_class3, | |||||
&_huff_book_line_2048x27_class4, | |||||
&_huff_book_line_2048x27_0sub0, | |||||
&_huff_book_line_2048x27_1sub0, | |||||
&_huff_book_line_2048x27_1sub1, | |||||
&_huff_book_line_2048x27_2sub0, | |||||
&_huff_book_line_2048x27_2sub1, | |||||
&_huff_book_line_2048x27_3sub1, | |||||
&_huff_book_line_2048x27_3sub2, | |||||
&_huff_book_line_2048x27_3sub3, | |||||
&_huff_book_line_2048x27_4sub1, | |||||
&_huff_book_line_2048x27_4sub2, | |||||
&_huff_book_line_2048x27_4sub3, | |||||
}; | |||||
static const static_codebook*const _floor_512x17_books[]={ | |||||
&_huff_book_line_512x17_class1, | |||||
&_huff_book_line_512x17_class2, | |||||
&_huff_book_line_512x17_class3, | |||||
&_huff_book_line_512x17_0sub0, | |||||
&_huff_book_line_512x17_1sub0, | |||||
&_huff_book_line_512x17_1sub1, | |||||
&_huff_book_line_512x17_2sub1, | |||||
&_huff_book_line_512x17_2sub2, | |||||
&_huff_book_line_512x17_2sub3, | |||||
&_huff_book_line_512x17_3sub1, | |||||
&_huff_book_line_512x17_3sub2, | |||||
&_huff_book_line_512x17_3sub3, | |||||
}; | |||||
static const static_codebook*const _floor_Xx0_books[]={ | |||||
0 | |||||
}; | |||||
static const static_codebook*const *const _floor_books[11]={ | |||||
_floor_128x4_books, | |||||
_floor_256x4_books, | |||||
_floor_128x7_books, | |||||
_floor_256x7_books, | |||||
_floor_128x11_books, | |||||
_floor_128x17_books, | |||||
_floor_256x4low_books, | |||||
_floor_1024x27_books, | |||||
_floor_2048x27_books, | |||||
_floor_512x17_books, | |||||
_floor_Xx0_books, | |||||
}; | |||||
static const vorbis_info_floor1 _floor[11]={ | |||||
/* 0: 128 x 4 */ | |||||
{ | |||||
1,{0},{4},{2},{0}, | |||||
{{1,2,3,4}}, | |||||
4,{0,128, 33,8,16,70}, | |||||
60,30,500, 1.,18., 128 | |||||
}, | |||||
/* 1: 256 x 4 */ | |||||
{ | |||||
1,{0},{4},{2},{0}, | |||||
{{1,2,3,4}}, | |||||
4,{0,256, 66,16,32,140}, | |||||
60,30,500, 1.,18., 256 | |||||
}, | |||||
/* 2: 128 x 7 */ | |||||
{ | |||||
2,{0,1},{3,4},{2,2},{0,1}, | |||||
{{-1,2,3,4},{-1,5,6,7}}, | |||||
4,{0,128, 14,4,58, 2,8,28,90}, | |||||
60,30,500, 1.,18., 128 | |||||
}, | |||||
/* 3: 256 x 7 */ | |||||
{ | |||||
2,{0,1},{3,4},{2,2},{0,1}, | |||||
{{-1,2,3,4},{-1,5,6,7}}, | |||||
4,{0,256, 28,8,116, 4,16,56,180}, | |||||
60,30,500, 1.,18., 256 | |||||
}, | |||||
/* 4: 128 x 11 */ | |||||
{ | |||||
4,{0,1,2,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, | |||||
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, | |||||
2,{0,128, 8,33, 4,16,70, 2,6,12, 23,46,90}, | |||||
60,30,500, 1,18., 128 | |||||
}, | |||||
/* 5: 128 x 17 */ | |||||
{ | |||||
6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, | |||||
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, | |||||
2,{0,128, 12,46, 4,8,16, 23,33,70, 2,6,10, 14,19,28, 39,58,90}, | |||||
60,30,500, 1,18., 128 | |||||
}, | |||||
/* 6: 256 x 4 (low bitrate version) */ | |||||
{ | |||||
1,{0},{4},{2},{0}, | |||||
{{1,2,3,4}}, | |||||
4,{0,256, 66,16,32,140}, | |||||
60,30,500, 1.,18., 256 | |||||
}, | |||||
/* 7: 1024 x 27 */ | |||||
{ | |||||
8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3}, | |||||
{{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}}, | |||||
2,{0,1024, 93,23,372, 6,46,186,750, 14,33,65, 130,260,556, | |||||
3,10,18,28, 39,55,79,111, 158,220,312, 464,650,850}, | |||||
60,30,500, 3,18., 1024 | |||||
}, | |||||
/* 8: 2048 x 27 */ | |||||
{ | |||||
8,{0,1,2,2,3,3,4,4},{3,4,3,4,3},{0,1,1,2,2},{-1,0,1,2,3}, | |||||
{{4},{5,6},{7,8},{-1,9,10,11},{-1,12,13,14}}, | |||||
2,{0,2048, 186,46,744, 12,92,372,1500, 28,66,130, 260,520,1112, | |||||
6,20,36,56, 78,110,158,222, 316,440,624, 928,1300,1700}, | |||||
60,30,500, 3,18., 2048 | |||||
}, | |||||
/* 9: 512 x 17 */ | |||||
{ | |||||
6,{0,1,1,2,3,3},{2,3,3,3},{0,1,2,2},{-1,0,1,2}, | |||||
{{3},{4,5},{-1,6,7,8},{-1,9,10,11}}, | |||||
2,{0,512, 46,186, 16,33,65, 93,130,278, | |||||
7,23,39, 55,79,110, 156,232,360}, | |||||
60,30,500, 1,18., 512 | |||||
}, | |||||
/* 10: X x 0 (LFE floor; edge posts only) */ | |||||
{ | |||||
0,{0}, {0},{0},{-1}, | |||||
{{-1}}, | |||||
2,{0,12}, | |||||
60,30,500, 1.,18., 10 | |||||
}, | |||||
}; |
@@ -1,50 +1,50 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 11kHz settings | |||||
last mod: $Id: psych_11.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
static const double _psy_lowpass_11[3]={4.5,5.5,30.,}; | |||||
static const att3 _psy_tone_masteratt_11[3]={ | |||||
{{ 30, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 30, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 20, 0, -14}, 0, 0}, /* 0 */ | |||||
}; | |||||
static const vp_adjblock _vp_tonemask_adj_11[3]={ | |||||
/* adjust for mode zero */ | |||||
/* 63 125 250 500 1 2 4 8 16 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 2, 0,99,99,99}}, /* 0 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 5, 0, 0,99,99,99}}, /* 1 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /* 2 */ | |||||
}; | |||||
static const noise3 _psy_noisebias_11[3]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99}, | |||||
{-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 4, 5, 5, 10, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99}, | |||||
{-15,-15,-15,-15,-10,-10, -5, -5, -5, 0, 0, 0, 0, 0, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}}, | |||||
}; | |||||
static const double _noise_thresh_11[3]={ .3,.5,.5 }; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 11kHz settings | |||||
********************************************************************/ | |||||
static const double _psy_lowpass_11[3]={4.5,5.5,30.,}; | |||||
static const att3 _psy_tone_masteratt_11[3]={ | |||||
{{ 30, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 30, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 20, 0, -14}, 0, 0}, /* 0 */ | |||||
}; | |||||
static const vp_adjblock _vp_tonemask_adj_11[3]={ | |||||
/* adjust for mode zero */ | |||||
/* 63 125 250 500 1 2 4 8 16 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 2, 0,99,99,99}}, /* 0 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 5, 0, 0,99,99,99}}, /* 1 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /* 2 */ | |||||
}; | |||||
static const noise3 _psy_noisebias_11[3]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99}, | |||||
{-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 4, 5, 5, 10, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 10, 10, 12, 12, 12, 99, 99, 99}, | |||||
{-15,-15,-15,-15,-10,-10, -5, -5, -5, 0, 0, 0, 0, 0, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}}, | |||||
}; | |||||
static const double _noise_thresh_11[3]={ .3,.5,.5 }; | |||||
@@ -1,133 +1,132 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 16kHz settings | |||||
last mod: $Id: psych_16.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
/* stereo mode by base quality level */ | |||||
static const adj_stereo _psy_stereo_modes_16[4]={ | |||||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ | |||||
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||||
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
}; | |||||
static const double _psy_lowpass_16[4]={6.5,8,30.,99.}; | |||||
static const att3 _psy_tone_masteratt_16[4]={ | |||||
{{ 30, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 25, 22, 12}, 0, 0}, /* 0 */ | |||||
{{ 20, 12, 0}, 0, 0}, /* 0 */ | |||||
{{ 15, 0, -14}, 0, 0}, /* 0 */ | |||||
}; | |||||
static const vp_adjblock _vp_tonemask_adj_16[4]={ | |||||
/* adjust for mode zero */ | |||||
/* 63 125 250 500 1 2 4 8 16 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 0 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 1 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 2 */ | |||||
{{-30,-30,-30,-30,-30,-26,-20,-10, -5, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 2 */ | |||||
}; | |||||
static const noise3 _psy_noisebias_16_short[4]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20}, | |||||
{-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, | |||||
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 6, 6, 6, 6, 8, 10, 12, 20}, | |||||
{-15,-15,-15,-15,-15,-15,-15,-10, -5, -5, -5, 4, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10,-10,-10,-10,-10,-10,-10,-10,-10}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 12}, | |||||
{-20,-20,-20,-20,-16,-12,-20,-14,-10,-10, -8, 0, 0, 0, 0, 2, 5}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10,-10,-10, -6}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
}; | |||||
static const noise3 _psy_noisebias_16_impulse[4]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20}, | |||||
{-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, | |||||
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 4, 4, 4, 5, 5, 6, 8, 15}, | |||||
{-15,-15,-15,-15,-15,-15,-15,-10, -5, -5, -5, 0, 0, 0, 0, 4, 10}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10,-10,-10,-10,-10,-10,-10,-10,-10}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 4, 10}, | |||||
{-20,-20,-20,-20,-16,-12,-20,-14,-10,-10,-10,-10,-10,-10,-10, -7, -5}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-18,-18,-18,-20,-20,-20,-20,-20,-20,-16}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
}; | |||||
static const noise3 _psy_noisebias_16[4]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 8, 8, 10, 10, 10, 14, 20}, | |||||
{-10,-10,-10,-10,-10, -5, -2, -2, 0, 0, 0, 4, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 6, 6, 6, 8, 10, 12, 20}, | |||||
{-15,-15,-15,-15,-15,-10, -5, -5, 0, 0, 0, 4, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 12}, | |||||
{-20,-20,-20,-20,-16,-12,-20,-10, -5, -5, 0, 0, 0, 0, 0, 2, 5}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10,-10,-10, -6}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
}; | |||||
static const noiseguard _psy_noiseguards_16[4]={ | |||||
{10,10,-1}, | |||||
{10,10,-1}, | |||||
{20,20,-1}, | |||||
{20,20,-1}, | |||||
}; | |||||
static const double _noise_thresh_16[4]={ .3,.5,.5,.5 }; | |||||
static const int _noise_start_16[3]={ 256,256,9999 }; | |||||
static const int _noise_part_16[4]={ 8,8,8,8 }; | |||||
static const int _psy_ath_floater_16[4]={ | |||||
-100,-100,-100,-105, | |||||
}; | |||||
static const int _psy_ath_abs_16[4]={ | |||||
-130,-130,-130,-140, | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 16kHz settings | |||||
********************************************************************/ | |||||
/* stereo mode by base quality level */ | |||||
static const adj_stereo _psy_stereo_modes_16[4]={ | |||||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ | |||||
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 4, 4, 4, 4}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||||
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
}; | |||||
static const double _psy_lowpass_16[4]={6.5,8,30.,99.}; | |||||
static const att3 _psy_tone_masteratt_16[4]={ | |||||
{{ 30, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 25, 22, 12}, 0, 0}, /* 0 */ | |||||
{{ 20, 12, 0}, 0, 0}, /* 0 */ | |||||
{{ 15, 0, -14}, 0, 0}, /* 0 */ | |||||
}; | |||||
static const vp_adjblock _vp_tonemask_adj_16[4]={ | |||||
/* adjust for mode zero */ | |||||
/* 63 125 250 500 1 2 4 8 16 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 0 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0,10, 0, 0, 0, 0, 0}}, /* 1 */ | |||||
{{-20,-20,-20,-20,-20,-16,-10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 2 */ | |||||
{{-30,-30,-30,-30,-30,-26,-20,-10, -5, 0, 0, 0, 0, 0, 0, 0, 0}}, /* 2 */ | |||||
}; | |||||
static const noise3 _psy_noisebias_16_short[4]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20}, | |||||
{-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, | |||||
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 6, 6, 6, 6, 8, 10, 12, 20}, | |||||
{-15,-15,-15,-15,-15,-15,-15,-10, -5, -5, -5, 4, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10,-10,-10,-10,-10,-10,-10,-10,-10}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 12}, | |||||
{-20,-20,-20,-20,-16,-12,-20,-14,-10,-10, -8, 0, 0, 0, 0, 2, 5}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10,-10,-10, -6}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
}; | |||||
static const noise3 _psy_noisebias_16_impulse[4]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 10, 10, 10, 10, 12, 12, 14, 20}, | |||||
{-15,-15,-15,-15,-15,-10,-10, -5, 0, 0, 4, 5, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, | |||||
{{{-15,-15,-15,-15,-15,-10,-10,-5, 4, 4, 4, 4, 5, 5, 6, 8, 15}, | |||||
{-15,-15,-15,-15,-15,-15,-15,-10, -5, -5, -5, 0, 0, 0, 0, 4, 10}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10,-10,-10,-10,-10,-10,-10,-10,-10}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 0, 0, 0, 0, 0, 0, 4, 10}, | |||||
{-20,-20,-20,-20,-16,-12,-20,-14,-10,-10,-10,-10,-10,-10,-10, -7, -5}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-18,-18,-18,-20,-20,-20,-20,-20,-20,-16}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
}; | |||||
static const noise3 _psy_noisebias_16[4]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 8, 8, 10, 10, 10, 14, 20}, | |||||
{-10,-10,-10,-10,-10, -5, -2, -2, 0, 0, 0, 4, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 6, 6, 6, 6, 8, 10, 12, 20}, | |||||
{-15,-15,-15,-15,-15,-10, -5, -5, 0, 0, 0, 4, 5, 6, 8, 8, 15}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, -6, -6, -6}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 5, 8, 12}, | |||||
{-20,-20,-20,-20,-16,-12,-20,-10, -5, -5, 0, 0, 0, 0, 0, 2, 5}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, -5, -5, -5, -5, -5, 0, 0, 0, 6}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10,-10,-10, -6}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||||
}; | |||||
static const noiseguard _psy_noiseguards_16[4]={ | |||||
{10,10,-1}, | |||||
{10,10,-1}, | |||||
{20,20,-1}, | |||||
{20,20,-1}, | |||||
}; | |||||
static const double _noise_thresh_16[4]={ .3,.5,.5,.5 }; | |||||
static const int _noise_start_16[3]={ 256,256,9999 }; | |||||
static const int _noise_part_16[4]={ 8,8,8,8 }; | |||||
static const int _psy_ath_floater_16[4]={ | |||||
-100,-100,-100,-105, | |||||
}; | |||||
static const int _psy_ath_abs_16[4]={ | |||||
-130,-130,-130,-140, | |||||
}; |
@@ -1,101 +1,100 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 8kHz psychoacoustic settings | |||||
last mod: $Id: psych_8.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
static const att3 _psy_tone_masteratt_8[3]={ | |||||
{{ 32, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 30, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 20, 0, -14}, 0, 0}, /* 0 */ | |||||
}; | |||||
static const vp_adjblock _vp_tonemask_adj_8[3]={ | |||||
/* adjust for mode zero */ | |||||
/* 63 125 250 500 1 2 4 8 16 */ | |||||
{{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */ | |||||
{{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */ | |||||
{{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /* 1 */ | |||||
}; | |||||
static const noise3 _psy_noisebias_8[3]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99}, | |||||
{-10,-10,-10,-10, -5, -5, -5, 0, 0, 4, 4, 4, 4, 4, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99}, | |||||
{-10,-10,-10,-10,-10,-10, -5, -5, -5, 0, 0, 0, 0, 0, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}}, | |||||
}; | |||||
/* stereo mode by base quality level */ | |||||
static const adj_stereo _psy_stereo_modes_8[3]={ | |||||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ | |||||
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
}; | |||||
static const noiseguard _psy_noiseguards_8[2]={ | |||||
{10,10,-1}, | |||||
{10,10,-1}, | |||||
}; | |||||
static const compandblock _psy_compand_8[2]={ | |||||
{{ | |||||
0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ | |||||
8, 8, 9, 9,10,10,11, 11, /* 15dB */ | |||||
12,12,13,13,14,14,15, 15, /* 23dB */ | |||||
16,16,17,17,17,18,18, 19, /* 31dB */ | |||||
19,19,20,21,22,23,24, 25, /* 39dB */ | |||||
}}, | |||||
{{ | |||||
0, 1, 2, 3, 4, 5, 6, 6, /* 7dB */ | |||||
7, 7, 6, 6, 5, 5, 4, 4, /* 15dB */ | |||||
3, 3, 3, 4, 5, 6, 7, 8, /* 23dB */ | |||||
9,10,11,12,13,14,15, 16, /* 31dB */ | |||||
17,18,19,20,21,22,23, 24, /* 39dB */ | |||||
}}, | |||||
}; | |||||
static const double _psy_lowpass_8[3]={3.,4.,4.}; | |||||
static const int _noise_start_8[2]={ | |||||
64,64, | |||||
}; | |||||
static const int _noise_part_8[2]={ | |||||
8,8, | |||||
}; | |||||
static const int _psy_ath_floater_8[3]={ | |||||
-100,-100,-105, | |||||
}; | |||||
static const int _psy_ath_abs_8[3]={ | |||||
-130,-130,-140, | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 8kHz psychoacoustic settings | |||||
********************************************************************/ | |||||
static const att3 _psy_tone_masteratt_8[3]={ | |||||
{{ 32, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 30, 25, 12}, 0, 0}, /* 0 */ | |||||
{{ 20, 0, -14}, 0, 0}, /* 0 */ | |||||
}; | |||||
static const vp_adjblock _vp_tonemask_adj_8[3]={ | |||||
/* adjust for mode zero */ | |||||
/* 63 125 250 500 1 2 4 8 16 */ | |||||
{{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */ | |||||
{{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0,10, 0, 0,99,99,99}}, /* 1 */ | |||||
{{-15,-15,-15,-15,-10,-10, -6, 0, 0, 0, 0, 0, 0, 0,99,99,99}}, /* 1 */ | |||||
}; | |||||
static const noise3 _psy_noisebias_8[3]={ | |||||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99}, | |||||
{-10,-10,-10,-10, -5, -5, -5, 0, 0, 4, 4, 4, 4, 4, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, | |||||
{{{-10,-10,-10,-10, -5, -5, -5, 0, 4, 8, 8, 8, 10, 10, 99, 99, 99}, | |||||
{-10,-10,-10,-10,-10,-10, -5, -5, -5, 0, 0, 0, 0, 0, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-30,-24,-20,-14,-10, -6, -8, -8, -6, -6, 99, 99, 99}}}, | |||||
{{{-15,-15,-15,-15,-15,-12,-10, -8, 0, 2, 4, 4, 5, 5, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-26,-22,-20,-14,-12,-12,-10,-10,-10,-10, 99, 99, 99}, | |||||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}}, | |||||
}; | |||||
/* stereo mode by base quality level */ | |||||
static const adj_stereo _psy_stereo_modes_8[3]={ | |||||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ | |||||
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
{{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, | |||||
{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}, | |||||
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, | |||||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||||
}; | |||||
static const noiseguard _psy_noiseguards_8[2]={ | |||||
{10,10,-1}, | |||||
{10,10,-1}, | |||||
}; | |||||
static const compandblock _psy_compand_8[2]={ | |||||
{{ | |||||
0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ | |||||
8, 8, 9, 9,10,10,11, 11, /* 15dB */ | |||||
12,12,13,13,14,14,15, 15, /* 23dB */ | |||||
16,16,17,17,17,18,18, 19, /* 31dB */ | |||||
19,19,20,21,22,23,24, 25, /* 39dB */ | |||||
}}, | |||||
{{ | |||||
0, 1, 2, 3, 4, 5, 6, 6, /* 7dB */ | |||||
7, 7, 6, 6, 5, 5, 4, 4, /* 15dB */ | |||||
3, 3, 3, 4, 5, 6, 7, 8, /* 23dB */ | |||||
9,10,11,12,13,14,15, 16, /* 31dB */ | |||||
17,18,19,20,21,22,23, 24, /* 39dB */ | |||||
}}, | |||||
}; | |||||
static const double _psy_lowpass_8[3]={3.,4.,4.}; | |||||
static const int _noise_start_8[2]={ | |||||
64,64, | |||||
}; | |||||
static const int _noise_part_8[2]={ | |||||
8,8, | |||||
}; | |||||
static const int _psy_ath_floater_8[3]={ | |||||
-100,-100,-105, | |||||
}; | |||||
static const int _psy_ath_abs_8[3]={ | |||||
-130,-130,-140, | |||||
}; |
@@ -1,163 +1,162 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* This FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates 16/22kHz | |||||
last mod: $Id: residue_16.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||||
********************************************************************/ | |||||
/***** residue backends *********************************************/ | |||||
static const static_bookblock _resbook_16s_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16c0_s_p1_0}, | |||||
{0}, | |||||
{0,0,&_16c0_s_p3_0}, | |||||
{0,0,&_16c0_s_p4_0}, | |||||
{0,0,&_16c0_s_p5_0}, | |||||
{0,0,&_16c0_s_p6_0}, | |||||
{&_16c0_s_p7_0,&_16c0_s_p7_1}, | |||||
{&_16c0_s_p8_0,&_16c0_s_p8_1}, | |||||
{&_16c0_s_p9_0,&_16c0_s_p9_1,&_16c0_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_16s_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16c1_s_p1_0}, | |||||
{0}, | |||||
{0,0,&_16c1_s_p3_0}, | |||||
{0,0,&_16c1_s_p4_0}, | |||||
{0,0,&_16c1_s_p5_0}, | |||||
{0,0,&_16c1_s_p6_0}, | |||||
{&_16c1_s_p7_0,&_16c1_s_p7_1}, | |||||
{&_16c1_s_p8_0,&_16c1_s_p8_1}, | |||||
{&_16c1_s_p9_0,&_16c1_s_p9_1,&_16c1_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_16s_2={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16c2_s_p1_0}, | |||||
{0,0,&_16c2_s_p2_0}, | |||||
{0,0,&_16c2_s_p3_0}, | |||||
{0,0,&_16c2_s_p4_0}, | |||||
{&_16c2_s_p5_0,&_16c2_s_p5_1}, | |||||
{&_16c2_s_p6_0,&_16c2_s_p6_1}, | |||||
{&_16c2_s_p7_0,&_16c2_s_p7_1}, | |||||
{&_16c2_s_p8_0,&_16c2_s_p8_1}, | |||||
{&_16c2_s_p9_0,&_16c2_s_p9_1,&_16c2_s_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_16s_0[]={ | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__16c0_s_single,&_huff_book__16c0_s_single, | |||||
&_resbook_16s_0,&_resbook_16s_0}, | |||||
}; | |||||
static const vorbis_residue_template _res_16s_1[]={ | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__16c1_s_short,&_huff_book__16c1_s_short, | |||||
&_resbook_16s_1,&_resbook_16s_1}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__16c1_s_long,&_huff_book__16c1_s_long, | |||||
&_resbook_16s_1,&_resbook_16s_1} | |||||
}; | |||||
static const vorbis_residue_template _res_16s_2[]={ | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__16c2_s_short,&_huff_book__16c2_s_short, | |||||
&_resbook_16s_2,&_resbook_16s_2}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__16c2_s_long,&_huff_book__16c2_s_long, | |||||
&_resbook_16s_2,&_resbook_16s_2} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_16_stereo[3]={ | |||||
{ _map_nominal, _res_16s_0 }, /* 0 */ | |||||
{ _map_nominal, _res_16s_1 }, /* 1 */ | |||||
{ _map_nominal, _res_16s_2 }, /* 2 */ | |||||
}; | |||||
static const static_bookblock _resbook_16u_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16u0__p1_0}, | |||||
{0,0,&_16u0__p2_0}, | |||||
{0,0,&_16u0__p3_0}, | |||||
{0,0,&_16u0__p4_0}, | |||||
{0,0,&_16u0__p5_0}, | |||||
{&_16u0__p6_0,&_16u0__p6_1}, | |||||
{&_16u0__p7_0,&_16u0__p7_1,&_16u0__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_16u_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16u1__p1_0}, | |||||
{0,0,&_16u1__p2_0}, | |||||
{0,0,&_16u1__p3_0}, | |||||
{0,0,&_16u1__p4_0}, | |||||
{0,0,&_16u1__p5_0}, | |||||
{0,0,&_16u1__p6_0}, | |||||
{&_16u1__p7_0,&_16u1__p7_1}, | |||||
{&_16u1__p8_0,&_16u1__p8_1}, | |||||
{&_16u1__p9_0,&_16u1__p9_1,&_16u1__p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_16u_2={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16u2_p1_0}, | |||||
{0,0,&_16u2_p2_0}, | |||||
{0,0,&_16u2_p3_0}, | |||||
{0,0,&_16u2_p4_0}, | |||||
{&_16u2_p5_0,&_16u2_p5_1}, | |||||
{&_16u2_p6_0,&_16u2_p6_1}, | |||||
{&_16u2_p7_0,&_16u2_p7_1}, | |||||
{&_16u2_p8_0,&_16u2_p8_1}, | |||||
{&_16u2_p9_0,&_16u2_p9_1,&_16u2_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_16u_0[]={ | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__16u0__single,&_huff_book__16u0__single, | |||||
&_resbook_16u_0,&_resbook_16u_0}, | |||||
}; | |||||
static const vorbis_residue_template _res_16u_1[]={ | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__16u1__short,&_huff_book__16u1__short, | |||||
&_resbook_16u_1,&_resbook_16u_1}, | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__16u1__long,&_huff_book__16u1__long, | |||||
&_resbook_16u_1,&_resbook_16u_1} | |||||
}; | |||||
static const vorbis_residue_template _res_16u_2[]={ | |||||
{1,0,32, &_residue_44_hi_un, | |||||
&_huff_book__16u2__short,&_huff_book__16u2__short, | |||||
&_resbook_16u_2,&_resbook_16u_2}, | |||||
{1,0,32, &_residue_44_hi_un, | |||||
&_huff_book__16u2__long,&_huff_book__16u2__long, | |||||
&_resbook_16u_2,&_resbook_16u_2} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_16_uncoupled[3]={ | |||||
{ _map_nominal_u, _res_16u_0 }, /* 0 */ | |||||
{ _map_nominal_u, _res_16u_1 }, /* 1 */ | |||||
{ _map_nominal_u, _res_16u_2 }, /* 2 */ | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* This FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates 16/22kHz | |||||
********************************************************************/ | |||||
/***** residue backends *********************************************/ | |||||
static const static_bookblock _resbook_16s_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16c0_s_p1_0}, | |||||
{0}, | |||||
{0,0,&_16c0_s_p3_0}, | |||||
{0,0,&_16c0_s_p4_0}, | |||||
{0,0,&_16c0_s_p5_0}, | |||||
{0,0,&_16c0_s_p6_0}, | |||||
{&_16c0_s_p7_0,&_16c0_s_p7_1}, | |||||
{&_16c0_s_p8_0,&_16c0_s_p8_1}, | |||||
{&_16c0_s_p9_0,&_16c0_s_p9_1,&_16c0_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_16s_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16c1_s_p1_0}, | |||||
{0}, | |||||
{0,0,&_16c1_s_p3_0}, | |||||
{0,0,&_16c1_s_p4_0}, | |||||
{0,0,&_16c1_s_p5_0}, | |||||
{0,0,&_16c1_s_p6_0}, | |||||
{&_16c1_s_p7_0,&_16c1_s_p7_1}, | |||||
{&_16c1_s_p8_0,&_16c1_s_p8_1}, | |||||
{&_16c1_s_p9_0,&_16c1_s_p9_1,&_16c1_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_16s_2={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16c2_s_p1_0}, | |||||
{0,0,&_16c2_s_p2_0}, | |||||
{0,0,&_16c2_s_p3_0}, | |||||
{0,0,&_16c2_s_p4_0}, | |||||
{&_16c2_s_p5_0,&_16c2_s_p5_1}, | |||||
{&_16c2_s_p6_0,&_16c2_s_p6_1}, | |||||
{&_16c2_s_p7_0,&_16c2_s_p7_1}, | |||||
{&_16c2_s_p8_0,&_16c2_s_p8_1}, | |||||
{&_16c2_s_p9_0,&_16c2_s_p9_1,&_16c2_s_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_16s_0[]={ | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__16c0_s_single,&_huff_book__16c0_s_single, | |||||
&_resbook_16s_0,&_resbook_16s_0}, | |||||
}; | |||||
static const vorbis_residue_template _res_16s_1[]={ | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__16c1_s_short,&_huff_book__16c1_s_short, | |||||
&_resbook_16s_1,&_resbook_16s_1}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__16c1_s_long,&_huff_book__16c1_s_long, | |||||
&_resbook_16s_1,&_resbook_16s_1} | |||||
}; | |||||
static const vorbis_residue_template _res_16s_2[]={ | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__16c2_s_short,&_huff_book__16c2_s_short, | |||||
&_resbook_16s_2,&_resbook_16s_2}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__16c2_s_long,&_huff_book__16c2_s_long, | |||||
&_resbook_16s_2,&_resbook_16s_2} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_16_stereo[3]={ | |||||
{ _map_nominal, _res_16s_0 }, /* 0 */ | |||||
{ _map_nominal, _res_16s_1 }, /* 1 */ | |||||
{ _map_nominal, _res_16s_2 }, /* 2 */ | |||||
}; | |||||
static const static_bookblock _resbook_16u_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16u0__p1_0}, | |||||
{0,0,&_16u0__p2_0}, | |||||
{0,0,&_16u0__p3_0}, | |||||
{0,0,&_16u0__p4_0}, | |||||
{0,0,&_16u0__p5_0}, | |||||
{&_16u0__p6_0,&_16u0__p6_1}, | |||||
{&_16u0__p7_0,&_16u0__p7_1,&_16u0__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_16u_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16u1__p1_0}, | |||||
{0,0,&_16u1__p2_0}, | |||||
{0,0,&_16u1__p3_0}, | |||||
{0,0,&_16u1__p4_0}, | |||||
{0,0,&_16u1__p5_0}, | |||||
{0,0,&_16u1__p6_0}, | |||||
{&_16u1__p7_0,&_16u1__p7_1}, | |||||
{&_16u1__p8_0,&_16u1__p8_1}, | |||||
{&_16u1__p9_0,&_16u1__p9_1,&_16u1__p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_16u_2={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_16u2_p1_0}, | |||||
{0,0,&_16u2_p2_0}, | |||||
{0,0,&_16u2_p3_0}, | |||||
{0,0,&_16u2_p4_0}, | |||||
{&_16u2_p5_0,&_16u2_p5_1}, | |||||
{&_16u2_p6_0,&_16u2_p6_1}, | |||||
{&_16u2_p7_0,&_16u2_p7_1}, | |||||
{&_16u2_p8_0,&_16u2_p8_1}, | |||||
{&_16u2_p9_0,&_16u2_p9_1,&_16u2_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_16u_0[]={ | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__16u0__single,&_huff_book__16u0__single, | |||||
&_resbook_16u_0,&_resbook_16u_0}, | |||||
}; | |||||
static const vorbis_residue_template _res_16u_1[]={ | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__16u1__short,&_huff_book__16u1__short, | |||||
&_resbook_16u_1,&_resbook_16u_1}, | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__16u1__long,&_huff_book__16u1__long, | |||||
&_resbook_16u_1,&_resbook_16u_1} | |||||
}; | |||||
static const vorbis_residue_template _res_16u_2[]={ | |||||
{1,0,32, &_residue_44_hi_un, | |||||
&_huff_book__16u2__short,&_huff_book__16u2__short, | |||||
&_resbook_16u_2,&_resbook_16u_2}, | |||||
{1,0,32, &_residue_44_hi_un, | |||||
&_huff_book__16u2__long,&_huff_book__16u2__long, | |||||
&_resbook_16u_2,&_resbook_16u_2} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_16_uncoupled[3]={ | |||||
{ _map_nominal_u, _res_16u_0 }, /* 0 */ | |||||
{ _map_nominal_u, _res_16u_1 }, /* 1 */ | |||||
{ _map_nominal_u, _res_16u_2 }, /* 2 */ | |||||
}; |
@@ -1,292 +1,291 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates for 32/44.1/48kHz | |||||
last mod: $Id: residue_44.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
#include "../books/coupled/res_books_stereo.h" | |||||
/***** residue backends *********************************************/ | |||||
static const vorbis_info_residue0 _residue_44_low={ | |||||
0,-1, -1, 9,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 2, 4, 8, 16, 32}, | |||||
{ 0, 0, 0,999, 4, 8, 16, 32}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44_mid={ | |||||
0,-1, -1, 10,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 1, 2, 2, 4, 8, 16, 32}, | |||||
{ 0, 0,999, 0,999, 4, 8, 16, 32}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44_high={ | |||||
0,-1, -1, 10,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 4, 8, 16, 32, 71,157}, | |||||
{ 0, 1, 2, 3, 4, 8, 16, 71,157}, | |||||
}; | |||||
static const static_bookblock _resbook_44s_n1={ | |||||
{ | |||||
{0},{0,0,&_44cn1_s_p1_0},{0,0,&_44cn1_s_p2_0}, | |||||
{0,0,&_44cn1_s_p3_0},{0,0,&_44cn1_s_p4_0},{0,0,&_44cn1_s_p5_0}, | |||||
{&_44cn1_s_p6_0,&_44cn1_s_p6_1},{&_44cn1_s_p7_0,&_44cn1_s_p7_1}, | |||||
{&_44cn1_s_p8_0,&_44cn1_s_p8_1,&_44cn1_s_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44sm_n1={ | |||||
{ | |||||
{0},{0,0,&_44cn1_sm_p1_0},{0,0,&_44cn1_sm_p2_0}, | |||||
{0,0,&_44cn1_sm_p3_0},{0,0,&_44cn1_sm_p4_0},{0,0,&_44cn1_sm_p5_0}, | |||||
{&_44cn1_sm_p6_0,&_44cn1_sm_p6_1},{&_44cn1_sm_p7_0,&_44cn1_sm_p7_1}, | |||||
{&_44cn1_sm_p8_0,&_44cn1_sm_p8_1,&_44cn1_sm_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_0={ | |||||
{ | |||||
{0},{0,0,&_44c0_s_p1_0},{0,0,&_44c0_s_p2_0}, | |||||
{0,0,&_44c0_s_p3_0},{0,0,&_44c0_s_p4_0},{0,0,&_44c0_s_p5_0}, | |||||
{&_44c0_s_p6_0,&_44c0_s_p6_1},{&_44c0_s_p7_0,&_44c0_s_p7_1}, | |||||
{&_44c0_s_p8_0,&_44c0_s_p8_1,&_44c0_s_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44sm_0={ | |||||
{ | |||||
{0},{0,0,&_44c0_sm_p1_0},{0,0,&_44c0_sm_p2_0}, | |||||
{0,0,&_44c0_sm_p3_0},{0,0,&_44c0_sm_p4_0},{0,0,&_44c0_sm_p5_0}, | |||||
{&_44c0_sm_p6_0,&_44c0_sm_p6_1},{&_44c0_sm_p7_0,&_44c0_sm_p7_1}, | |||||
{&_44c0_sm_p8_0,&_44c0_sm_p8_1,&_44c0_sm_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_1={ | |||||
{ | |||||
{0},{0,0,&_44c1_s_p1_0},{0,0,&_44c1_s_p2_0}, | |||||
{0,0,&_44c1_s_p3_0},{0,0,&_44c1_s_p4_0},{0,0,&_44c1_s_p5_0}, | |||||
{&_44c1_s_p6_0,&_44c1_s_p6_1},{&_44c1_s_p7_0,&_44c1_s_p7_1}, | |||||
{&_44c1_s_p8_0,&_44c1_s_p8_1,&_44c1_s_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44sm_1={ | |||||
{ | |||||
{0},{0,0,&_44c1_sm_p1_0},{0,0,&_44c1_sm_p2_0}, | |||||
{0,0,&_44c1_sm_p3_0},{0,0,&_44c1_sm_p4_0},{0,0,&_44c1_sm_p5_0}, | |||||
{&_44c1_sm_p6_0,&_44c1_sm_p6_1},{&_44c1_sm_p7_0,&_44c1_sm_p7_1}, | |||||
{&_44c1_sm_p8_0,&_44c1_sm_p8_1,&_44c1_sm_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_2={ | |||||
{ | |||||
{0},{0,0,&_44c2_s_p1_0},{0,0,&_44c2_s_p2_0},{0,0,&_44c2_s_p3_0}, | |||||
{0,0,&_44c2_s_p4_0},{0,0,&_44c2_s_p5_0},{0,0,&_44c2_s_p6_0}, | |||||
{&_44c2_s_p7_0,&_44c2_s_p7_1},{&_44c2_s_p8_0,&_44c2_s_p8_1}, | |||||
{&_44c2_s_p9_0,&_44c2_s_p9_1,&_44c2_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_3={ | |||||
{ | |||||
{0},{0,0,&_44c3_s_p1_0},{0,0,&_44c3_s_p2_0},{0,0,&_44c3_s_p3_0}, | |||||
{0,0,&_44c3_s_p4_0},{0,0,&_44c3_s_p5_0},{0,0,&_44c3_s_p6_0}, | |||||
{&_44c3_s_p7_0,&_44c3_s_p7_1},{&_44c3_s_p8_0,&_44c3_s_p8_1}, | |||||
{&_44c3_s_p9_0,&_44c3_s_p9_1,&_44c3_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_4={ | |||||
{ | |||||
{0},{0,0,&_44c4_s_p1_0},{0,0,&_44c4_s_p2_0},{0,0,&_44c4_s_p3_0}, | |||||
{0,0,&_44c4_s_p4_0},{0,0,&_44c4_s_p5_0},{0,0,&_44c4_s_p6_0}, | |||||
{&_44c4_s_p7_0,&_44c4_s_p7_1},{&_44c4_s_p8_0,&_44c4_s_p8_1}, | |||||
{&_44c4_s_p9_0,&_44c4_s_p9_1,&_44c4_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_5={ | |||||
{ | |||||
{0},{0,0,&_44c5_s_p1_0},{0,0,&_44c5_s_p2_0},{0,0,&_44c5_s_p3_0}, | |||||
{0,0,&_44c5_s_p4_0},{0,0,&_44c5_s_p5_0},{0,0,&_44c5_s_p6_0}, | |||||
{&_44c5_s_p7_0,&_44c5_s_p7_1},{&_44c5_s_p8_0,&_44c5_s_p8_1}, | |||||
{&_44c5_s_p9_0,&_44c5_s_p9_1,&_44c5_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_6={ | |||||
{ | |||||
{0},{0,0,&_44c6_s_p1_0},{0,0,&_44c6_s_p2_0},{0,0,&_44c6_s_p3_0}, | |||||
{0,0,&_44c6_s_p4_0}, | |||||
{&_44c6_s_p5_0,&_44c6_s_p5_1}, | |||||
{&_44c6_s_p6_0,&_44c6_s_p6_1}, | |||||
{&_44c6_s_p7_0,&_44c6_s_p7_1}, | |||||
{&_44c6_s_p8_0,&_44c6_s_p8_1}, | |||||
{&_44c6_s_p9_0,&_44c6_s_p9_1,&_44c6_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_7={ | |||||
{ | |||||
{0},{0,0,&_44c7_s_p1_0},{0,0,&_44c7_s_p2_0},{0,0,&_44c7_s_p3_0}, | |||||
{0,0,&_44c7_s_p4_0}, | |||||
{&_44c7_s_p5_0,&_44c7_s_p5_1}, | |||||
{&_44c7_s_p6_0,&_44c7_s_p6_1}, | |||||
{&_44c7_s_p7_0,&_44c7_s_p7_1}, | |||||
{&_44c7_s_p8_0,&_44c7_s_p8_1}, | |||||
{&_44c7_s_p9_0,&_44c7_s_p9_1,&_44c7_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_8={ | |||||
{ | |||||
{0},{0,0,&_44c8_s_p1_0},{0,0,&_44c8_s_p2_0},{0,0,&_44c8_s_p3_0}, | |||||
{0,0,&_44c8_s_p4_0}, | |||||
{&_44c8_s_p5_0,&_44c8_s_p5_1}, | |||||
{&_44c8_s_p6_0,&_44c8_s_p6_1}, | |||||
{&_44c8_s_p7_0,&_44c8_s_p7_1}, | |||||
{&_44c8_s_p8_0,&_44c8_s_p8_1}, | |||||
{&_44c8_s_p9_0,&_44c8_s_p9_1,&_44c8_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_9={ | |||||
{ | |||||
{0},{0,0,&_44c9_s_p1_0},{0,0,&_44c9_s_p2_0},{0,0,&_44c9_s_p3_0}, | |||||
{0,0,&_44c9_s_p4_0}, | |||||
{&_44c9_s_p5_0,&_44c9_s_p5_1}, | |||||
{&_44c9_s_p6_0,&_44c9_s_p6_1}, | |||||
{&_44c9_s_p7_0,&_44c9_s_p7_1}, | |||||
{&_44c9_s_p8_0,&_44c9_s_p8_1}, | |||||
{&_44c9_s_p9_0,&_44c9_s_p9_1,&_44c9_s_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_n1[]={ | |||||
{2,0,32, &_residue_44_low, | |||||
&_huff_book__44cn1_s_short,&_huff_book__44cn1_sm_short, | |||||
&_resbook_44s_n1,&_resbook_44sm_n1}, | |||||
{2,0,32, &_residue_44_low, | |||||
&_huff_book__44cn1_s_long,&_huff_book__44cn1_sm_long, | |||||
&_resbook_44s_n1,&_resbook_44sm_n1} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_0[]={ | |||||
{2,0,16, &_residue_44_low, | |||||
&_huff_book__44c0_s_short,&_huff_book__44c0_sm_short, | |||||
&_resbook_44s_0,&_resbook_44sm_0}, | |||||
{2,0,32, &_residue_44_low, | |||||
&_huff_book__44c0_s_long,&_huff_book__44c0_sm_long, | |||||
&_resbook_44s_0,&_resbook_44sm_0} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_1[]={ | |||||
{2,0,16, &_residue_44_low, | |||||
&_huff_book__44c1_s_short,&_huff_book__44c1_sm_short, | |||||
&_resbook_44s_1,&_resbook_44sm_1}, | |||||
{2,0,32, &_residue_44_low, | |||||
&_huff_book__44c1_s_long,&_huff_book__44c1_sm_long, | |||||
&_resbook_44s_1,&_resbook_44sm_1} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_2[]={ | |||||
{2,0,16, &_residue_44_mid, | |||||
&_huff_book__44c2_s_short,&_huff_book__44c2_s_short, | |||||
&_resbook_44s_2,&_resbook_44s_2}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__44c2_s_long,&_huff_book__44c2_s_long, | |||||
&_resbook_44s_2,&_resbook_44s_2} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_3[]={ | |||||
{2,0,16, &_residue_44_mid, | |||||
&_huff_book__44c3_s_short,&_huff_book__44c3_s_short, | |||||
&_resbook_44s_3,&_resbook_44s_3}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__44c3_s_long,&_huff_book__44c3_s_long, | |||||
&_resbook_44s_3,&_resbook_44s_3} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_4[]={ | |||||
{2,0,16, &_residue_44_mid, | |||||
&_huff_book__44c4_s_short,&_huff_book__44c4_s_short, | |||||
&_resbook_44s_4,&_resbook_44s_4}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__44c4_s_long,&_huff_book__44c4_s_long, | |||||
&_resbook_44s_4,&_resbook_44s_4} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_5[]={ | |||||
{2,0,16, &_residue_44_mid, | |||||
&_huff_book__44c5_s_short,&_huff_book__44c5_s_short, | |||||
&_resbook_44s_5,&_resbook_44s_5}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__44c5_s_long,&_huff_book__44c5_s_long, | |||||
&_resbook_44s_5,&_resbook_44s_5} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_6[]={ | |||||
{2,0,16, &_residue_44_high, | |||||
&_huff_book__44c6_s_short,&_huff_book__44c6_s_short, | |||||
&_resbook_44s_6,&_resbook_44s_6}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__44c6_s_long,&_huff_book__44c6_s_long, | |||||
&_resbook_44s_6,&_resbook_44s_6} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_7[]={ | |||||
{2,0,16, &_residue_44_high, | |||||
&_huff_book__44c7_s_short,&_huff_book__44c7_s_short, | |||||
&_resbook_44s_7,&_resbook_44s_7}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__44c7_s_long,&_huff_book__44c7_s_long, | |||||
&_resbook_44s_7,&_resbook_44s_7} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_8[]={ | |||||
{2,0,16, &_residue_44_high, | |||||
&_huff_book__44c8_s_short,&_huff_book__44c8_s_short, | |||||
&_resbook_44s_8,&_resbook_44s_8}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__44c8_s_long,&_huff_book__44c8_s_long, | |||||
&_resbook_44s_8,&_resbook_44s_8} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_9[]={ | |||||
{2,0,16, &_residue_44_high, | |||||
&_huff_book__44c9_s_short,&_huff_book__44c9_s_short, | |||||
&_resbook_44s_9,&_resbook_44s_9}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__44c9_s_long,&_huff_book__44c9_s_long, | |||||
&_resbook_44s_9,&_resbook_44s_9} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_44_stereo[]={ | |||||
{ _map_nominal, _res_44s_n1 }, /* -1 */ | |||||
{ _map_nominal, _res_44s_0 }, /* 0 */ | |||||
{ _map_nominal, _res_44s_1 }, /* 1 */ | |||||
{ _map_nominal, _res_44s_2 }, /* 2 */ | |||||
{ _map_nominal, _res_44s_3 }, /* 3 */ | |||||
{ _map_nominal, _res_44s_4 }, /* 4 */ | |||||
{ _map_nominal, _res_44s_5 }, /* 5 */ | |||||
{ _map_nominal, _res_44s_6 }, /* 6 */ | |||||
{ _map_nominal, _res_44s_7 }, /* 7 */ | |||||
{ _map_nominal, _res_44s_8 }, /* 8 */ | |||||
{ _map_nominal, _res_44s_9 }, /* 9 */ | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates for 32/44.1/48kHz | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
#include "../books/coupled/res_books_stereo.h" | |||||
/***** residue backends *********************************************/ | |||||
static const vorbis_info_residue0 _residue_44_low={ | |||||
0,-1, -1, 9,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 2, 4, 8, 16, 32}, | |||||
{ 0, 0, 0,999, 4, 8, 16, 32}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44_mid={ | |||||
0,-1, -1, 10,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 1, 2, 2, 4, 8, 16, 32}, | |||||
{ 0, 0,999, 0,999, 4, 8, 16, 32}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44_high={ | |||||
0,-1, -1, 10,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 4, 8, 16, 32, 71,157}, | |||||
{ 0, 1, 2, 3, 4, 8, 16, 71,157}, | |||||
}; | |||||
static const static_bookblock _resbook_44s_n1={ | |||||
{ | |||||
{0},{0,0,&_44cn1_s_p1_0},{0,0,&_44cn1_s_p2_0}, | |||||
{0,0,&_44cn1_s_p3_0},{0,0,&_44cn1_s_p4_0},{0,0,&_44cn1_s_p5_0}, | |||||
{&_44cn1_s_p6_0,&_44cn1_s_p6_1},{&_44cn1_s_p7_0,&_44cn1_s_p7_1}, | |||||
{&_44cn1_s_p8_0,&_44cn1_s_p8_1,&_44cn1_s_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44sm_n1={ | |||||
{ | |||||
{0},{0,0,&_44cn1_sm_p1_0},{0,0,&_44cn1_sm_p2_0}, | |||||
{0,0,&_44cn1_sm_p3_0},{0,0,&_44cn1_sm_p4_0},{0,0,&_44cn1_sm_p5_0}, | |||||
{&_44cn1_sm_p6_0,&_44cn1_sm_p6_1},{&_44cn1_sm_p7_0,&_44cn1_sm_p7_1}, | |||||
{&_44cn1_sm_p8_0,&_44cn1_sm_p8_1,&_44cn1_sm_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_0={ | |||||
{ | |||||
{0},{0,0,&_44c0_s_p1_0},{0,0,&_44c0_s_p2_0}, | |||||
{0,0,&_44c0_s_p3_0},{0,0,&_44c0_s_p4_0},{0,0,&_44c0_s_p5_0}, | |||||
{&_44c0_s_p6_0,&_44c0_s_p6_1},{&_44c0_s_p7_0,&_44c0_s_p7_1}, | |||||
{&_44c0_s_p8_0,&_44c0_s_p8_1,&_44c0_s_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44sm_0={ | |||||
{ | |||||
{0},{0,0,&_44c0_sm_p1_0},{0,0,&_44c0_sm_p2_0}, | |||||
{0,0,&_44c0_sm_p3_0},{0,0,&_44c0_sm_p4_0},{0,0,&_44c0_sm_p5_0}, | |||||
{&_44c0_sm_p6_0,&_44c0_sm_p6_1},{&_44c0_sm_p7_0,&_44c0_sm_p7_1}, | |||||
{&_44c0_sm_p8_0,&_44c0_sm_p8_1,&_44c0_sm_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_1={ | |||||
{ | |||||
{0},{0,0,&_44c1_s_p1_0},{0,0,&_44c1_s_p2_0}, | |||||
{0,0,&_44c1_s_p3_0},{0,0,&_44c1_s_p4_0},{0,0,&_44c1_s_p5_0}, | |||||
{&_44c1_s_p6_0,&_44c1_s_p6_1},{&_44c1_s_p7_0,&_44c1_s_p7_1}, | |||||
{&_44c1_s_p8_0,&_44c1_s_p8_1,&_44c1_s_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44sm_1={ | |||||
{ | |||||
{0},{0,0,&_44c1_sm_p1_0},{0,0,&_44c1_sm_p2_0}, | |||||
{0,0,&_44c1_sm_p3_0},{0,0,&_44c1_sm_p4_0},{0,0,&_44c1_sm_p5_0}, | |||||
{&_44c1_sm_p6_0,&_44c1_sm_p6_1},{&_44c1_sm_p7_0,&_44c1_sm_p7_1}, | |||||
{&_44c1_sm_p8_0,&_44c1_sm_p8_1,&_44c1_sm_p8_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_2={ | |||||
{ | |||||
{0},{0,0,&_44c2_s_p1_0},{0,0,&_44c2_s_p2_0},{0,0,&_44c2_s_p3_0}, | |||||
{0,0,&_44c2_s_p4_0},{0,0,&_44c2_s_p5_0},{0,0,&_44c2_s_p6_0}, | |||||
{&_44c2_s_p7_0,&_44c2_s_p7_1},{&_44c2_s_p8_0,&_44c2_s_p8_1}, | |||||
{&_44c2_s_p9_0,&_44c2_s_p9_1,&_44c2_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_3={ | |||||
{ | |||||
{0},{0,0,&_44c3_s_p1_0},{0,0,&_44c3_s_p2_0},{0,0,&_44c3_s_p3_0}, | |||||
{0,0,&_44c3_s_p4_0},{0,0,&_44c3_s_p5_0},{0,0,&_44c3_s_p6_0}, | |||||
{&_44c3_s_p7_0,&_44c3_s_p7_1},{&_44c3_s_p8_0,&_44c3_s_p8_1}, | |||||
{&_44c3_s_p9_0,&_44c3_s_p9_1,&_44c3_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_4={ | |||||
{ | |||||
{0},{0,0,&_44c4_s_p1_0},{0,0,&_44c4_s_p2_0},{0,0,&_44c4_s_p3_0}, | |||||
{0,0,&_44c4_s_p4_0},{0,0,&_44c4_s_p5_0},{0,0,&_44c4_s_p6_0}, | |||||
{&_44c4_s_p7_0,&_44c4_s_p7_1},{&_44c4_s_p8_0,&_44c4_s_p8_1}, | |||||
{&_44c4_s_p9_0,&_44c4_s_p9_1,&_44c4_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_5={ | |||||
{ | |||||
{0},{0,0,&_44c5_s_p1_0},{0,0,&_44c5_s_p2_0},{0,0,&_44c5_s_p3_0}, | |||||
{0,0,&_44c5_s_p4_0},{0,0,&_44c5_s_p5_0},{0,0,&_44c5_s_p6_0}, | |||||
{&_44c5_s_p7_0,&_44c5_s_p7_1},{&_44c5_s_p8_0,&_44c5_s_p8_1}, | |||||
{&_44c5_s_p9_0,&_44c5_s_p9_1,&_44c5_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_6={ | |||||
{ | |||||
{0},{0,0,&_44c6_s_p1_0},{0,0,&_44c6_s_p2_0},{0,0,&_44c6_s_p3_0}, | |||||
{0,0,&_44c6_s_p4_0}, | |||||
{&_44c6_s_p5_0,&_44c6_s_p5_1}, | |||||
{&_44c6_s_p6_0,&_44c6_s_p6_1}, | |||||
{&_44c6_s_p7_0,&_44c6_s_p7_1}, | |||||
{&_44c6_s_p8_0,&_44c6_s_p8_1}, | |||||
{&_44c6_s_p9_0,&_44c6_s_p9_1,&_44c6_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_7={ | |||||
{ | |||||
{0},{0,0,&_44c7_s_p1_0},{0,0,&_44c7_s_p2_0},{0,0,&_44c7_s_p3_0}, | |||||
{0,0,&_44c7_s_p4_0}, | |||||
{&_44c7_s_p5_0,&_44c7_s_p5_1}, | |||||
{&_44c7_s_p6_0,&_44c7_s_p6_1}, | |||||
{&_44c7_s_p7_0,&_44c7_s_p7_1}, | |||||
{&_44c7_s_p8_0,&_44c7_s_p8_1}, | |||||
{&_44c7_s_p9_0,&_44c7_s_p9_1,&_44c7_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_8={ | |||||
{ | |||||
{0},{0,0,&_44c8_s_p1_0},{0,0,&_44c8_s_p2_0},{0,0,&_44c8_s_p3_0}, | |||||
{0,0,&_44c8_s_p4_0}, | |||||
{&_44c8_s_p5_0,&_44c8_s_p5_1}, | |||||
{&_44c8_s_p6_0,&_44c8_s_p6_1}, | |||||
{&_44c8_s_p7_0,&_44c8_s_p7_1}, | |||||
{&_44c8_s_p8_0,&_44c8_s_p8_1}, | |||||
{&_44c8_s_p9_0,&_44c8_s_p9_1,&_44c8_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44s_9={ | |||||
{ | |||||
{0},{0,0,&_44c9_s_p1_0},{0,0,&_44c9_s_p2_0},{0,0,&_44c9_s_p3_0}, | |||||
{0,0,&_44c9_s_p4_0}, | |||||
{&_44c9_s_p5_0,&_44c9_s_p5_1}, | |||||
{&_44c9_s_p6_0,&_44c9_s_p6_1}, | |||||
{&_44c9_s_p7_0,&_44c9_s_p7_1}, | |||||
{&_44c9_s_p8_0,&_44c9_s_p8_1}, | |||||
{&_44c9_s_p9_0,&_44c9_s_p9_1,&_44c9_s_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_n1[]={ | |||||
{2,0,32, &_residue_44_low, | |||||
&_huff_book__44cn1_s_short,&_huff_book__44cn1_sm_short, | |||||
&_resbook_44s_n1,&_resbook_44sm_n1}, | |||||
{2,0,32, &_residue_44_low, | |||||
&_huff_book__44cn1_s_long,&_huff_book__44cn1_sm_long, | |||||
&_resbook_44s_n1,&_resbook_44sm_n1} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_0[]={ | |||||
{2,0,16, &_residue_44_low, | |||||
&_huff_book__44c0_s_short,&_huff_book__44c0_sm_short, | |||||
&_resbook_44s_0,&_resbook_44sm_0}, | |||||
{2,0,32, &_residue_44_low, | |||||
&_huff_book__44c0_s_long,&_huff_book__44c0_sm_long, | |||||
&_resbook_44s_0,&_resbook_44sm_0} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_1[]={ | |||||
{2,0,16, &_residue_44_low, | |||||
&_huff_book__44c1_s_short,&_huff_book__44c1_sm_short, | |||||
&_resbook_44s_1,&_resbook_44sm_1}, | |||||
{2,0,32, &_residue_44_low, | |||||
&_huff_book__44c1_s_long,&_huff_book__44c1_sm_long, | |||||
&_resbook_44s_1,&_resbook_44sm_1} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_2[]={ | |||||
{2,0,16, &_residue_44_mid, | |||||
&_huff_book__44c2_s_short,&_huff_book__44c2_s_short, | |||||
&_resbook_44s_2,&_resbook_44s_2}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__44c2_s_long,&_huff_book__44c2_s_long, | |||||
&_resbook_44s_2,&_resbook_44s_2} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_3[]={ | |||||
{2,0,16, &_residue_44_mid, | |||||
&_huff_book__44c3_s_short,&_huff_book__44c3_s_short, | |||||
&_resbook_44s_3,&_resbook_44s_3}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__44c3_s_long,&_huff_book__44c3_s_long, | |||||
&_resbook_44s_3,&_resbook_44s_3} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_4[]={ | |||||
{2,0,16, &_residue_44_mid, | |||||
&_huff_book__44c4_s_short,&_huff_book__44c4_s_short, | |||||
&_resbook_44s_4,&_resbook_44s_4}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__44c4_s_long,&_huff_book__44c4_s_long, | |||||
&_resbook_44s_4,&_resbook_44s_4} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_5[]={ | |||||
{2,0,16, &_residue_44_mid, | |||||
&_huff_book__44c5_s_short,&_huff_book__44c5_s_short, | |||||
&_resbook_44s_5,&_resbook_44s_5}, | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__44c5_s_long,&_huff_book__44c5_s_long, | |||||
&_resbook_44s_5,&_resbook_44s_5} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_6[]={ | |||||
{2,0,16, &_residue_44_high, | |||||
&_huff_book__44c6_s_short,&_huff_book__44c6_s_short, | |||||
&_resbook_44s_6,&_resbook_44s_6}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__44c6_s_long,&_huff_book__44c6_s_long, | |||||
&_resbook_44s_6,&_resbook_44s_6} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_7[]={ | |||||
{2,0,16, &_residue_44_high, | |||||
&_huff_book__44c7_s_short,&_huff_book__44c7_s_short, | |||||
&_resbook_44s_7,&_resbook_44s_7}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__44c7_s_long,&_huff_book__44c7_s_long, | |||||
&_resbook_44s_7,&_resbook_44s_7} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_8[]={ | |||||
{2,0,16, &_residue_44_high, | |||||
&_huff_book__44c8_s_short,&_huff_book__44c8_s_short, | |||||
&_resbook_44s_8,&_resbook_44s_8}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__44c8_s_long,&_huff_book__44c8_s_long, | |||||
&_resbook_44s_8,&_resbook_44s_8} | |||||
}; | |||||
static const vorbis_residue_template _res_44s_9[]={ | |||||
{2,0,16, &_residue_44_high, | |||||
&_huff_book__44c9_s_short,&_huff_book__44c9_s_short, | |||||
&_resbook_44s_9,&_resbook_44s_9}, | |||||
{2,0,32, &_residue_44_high, | |||||
&_huff_book__44c9_s_long,&_huff_book__44c9_s_long, | |||||
&_resbook_44s_9,&_resbook_44s_9} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_44_stereo[]={ | |||||
{ _map_nominal, _res_44s_n1 }, /* -1 */ | |||||
{ _map_nominal, _res_44s_0 }, /* 0 */ | |||||
{ _map_nominal, _res_44s_1 }, /* 1 */ | |||||
{ _map_nominal, _res_44s_2 }, /* 2 */ | |||||
{ _map_nominal, _res_44s_3 }, /* 3 */ | |||||
{ _map_nominal, _res_44s_4 }, /* 4 */ | |||||
{ _map_nominal, _res_44s_5 }, /* 5 */ | |||||
{ _map_nominal, _res_44s_6 }, /* 6 */ | |||||
{ _map_nominal, _res_44s_7 }, /* 7 */ | |||||
{ _map_nominal, _res_44s_8 }, /* 8 */ | |||||
{ _map_nominal, _res_44s_9 }, /* 9 */ | |||||
}; |
@@ -1,451 +1,450 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates for 32/44.1/48kHz uncoupled | |||||
last mod: $Id$ | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
#include "../books/coupled/res_books_51.h" | |||||
/***** residue backends *********************************************/ | |||||
static const vorbis_info_residue0 _residue_44p_lo={ | |||||
0,-1, -1, 7,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 7, 17, 31}, | |||||
{ 0, 0, 99, 7, 17, 31}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44p={ | |||||
0,-1, -1, 8,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 1, 2, 7, 17, 31}, | |||||
{ 0, 0, 99, 99, 7, 17, 31}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44p_hi={ | |||||
0,-1, -1, 8,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 4, 7, 17, 31}, | |||||
{ 0, 1, 2, 4, 7, 17, 31}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44p_lfe={ | |||||
0,-1, -1, 2,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 32}, | |||||
{ -1} | |||||
}; | |||||
static const static_bookblock _resbook_44p_n1={ | |||||
{ | |||||
{0}, | |||||
{0,&_44pn1_p1_0}, | |||||
{&_44pn1_p2_0,&_44pn1_p2_1,0}, | |||||
{&_44pn1_p3_0,&_44pn1_p3_1,0}, | |||||
{&_44pn1_p4_0,&_44pn1_p4_1,0}, | |||||
{&_44pn1_p5_0,&_44pn1_p5_1,&_44pn1_p4_1}, | |||||
{&_44pn1_p6_0,&_44pn1_p6_1,&_44pn1_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_0={ | |||||
{ | |||||
{0}, | |||||
{0,&_44p0_p1_0}, | |||||
{&_44p0_p2_0,&_44p0_p2_1,0}, | |||||
{&_44p0_p3_0,&_44p0_p3_1,0}, | |||||
{&_44p0_p4_0,&_44p0_p4_1,0}, | |||||
{&_44p0_p5_0,&_44p0_p5_1,&_44p0_p4_1}, | |||||
{&_44p0_p6_0,&_44p0_p6_1,&_44p0_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_1={ | |||||
{ | |||||
{0}, | |||||
{0,&_44p1_p1_0}, | |||||
{&_44p1_p2_0,&_44p1_p2_1,0}, | |||||
{&_44p1_p3_0,&_44p1_p3_1,0}, | |||||
{&_44p1_p4_0,&_44p1_p4_1,0}, | |||||
{&_44p1_p5_0,&_44p1_p5_1,&_44p1_p4_1}, | |||||
{&_44p1_p6_0,&_44p1_p6_1,&_44p1_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_2={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p2_p1_0}, | |||||
{0,&_44p2_p2_0,0}, | |||||
{&_44p2_p3_0,&_44p2_p3_1,0}, | |||||
{&_44p2_p4_0,&_44p2_p4_1,0}, | |||||
{&_44p2_p5_0,&_44p2_p5_1,0}, | |||||
{&_44p2_p6_0,&_44p2_p6_1,&_44p2_p5_1}, | |||||
{&_44p2_p7_0,&_44p2_p7_1,&_44p2_p7_2,&_44p2_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_3={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p3_p1_0}, | |||||
{0,&_44p3_p2_0,0}, | |||||
{&_44p3_p3_0,&_44p3_p3_1,0}, | |||||
{&_44p3_p4_0,&_44p3_p4_1,0}, | |||||
{&_44p3_p5_0,&_44p3_p5_1,0}, | |||||
{&_44p3_p6_0,&_44p3_p6_1,&_44p3_p5_1}, | |||||
{&_44p3_p7_0,&_44p3_p7_1,&_44p3_p7_2,&_44p3_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_4={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p4_p1_0}, | |||||
{0,&_44p4_p2_0,0}, | |||||
{&_44p4_p3_0,&_44p4_p3_1,0}, | |||||
{&_44p4_p4_0,&_44p4_p4_1,0}, | |||||
{&_44p4_p5_0,&_44p4_p5_1,0}, | |||||
{&_44p4_p6_0,&_44p4_p6_1,&_44p4_p5_1}, | |||||
{&_44p4_p7_0,&_44p4_p7_1,&_44p4_p7_2,&_44p4_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_5={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p5_p1_0}, | |||||
{0,&_44p5_p2_0,0}, | |||||
{&_44p5_p3_0,&_44p5_p3_1,0}, | |||||
{&_44p5_p4_0,&_44p5_p4_1,0}, | |||||
{&_44p5_p5_0,&_44p5_p5_1,0}, | |||||
{&_44p5_p6_0,&_44p5_p6_1,&_44p5_p5_1}, | |||||
{&_44p5_p7_0,&_44p5_p7_1,&_44p5_p7_2,&_44p5_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_6={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p6_p1_0}, | |||||
{0,&_44p6_p2_0,0}, | |||||
{&_44p6_p3_0,&_44p6_p3_1,0}, | |||||
{&_44p6_p4_0,&_44p6_p4_1,0}, | |||||
{&_44p6_p5_0,&_44p6_p5_1,0}, | |||||
{&_44p6_p6_0,&_44p6_p6_1,&_44p6_p5_1}, | |||||
{&_44p6_p7_0,&_44p6_p7_1,&_44p6_p7_2,&_44p6_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_7={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p7_p1_0}, | |||||
{0,&_44p7_p2_0,0}, | |||||
{&_44p7_p3_0,&_44p7_p3_1,0}, | |||||
{&_44p7_p4_0,&_44p7_p4_1,0}, | |||||
{&_44p7_p5_0,&_44p7_p5_1,0}, | |||||
{&_44p7_p6_0,&_44p7_p6_1,&_44p7_p5_1}, | |||||
{&_44p7_p7_0,&_44p7_p7_1,&_44p7_p7_2,&_44p7_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_8={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p8_p1_0}, | |||||
{0,&_44p8_p2_0,0}, | |||||
{&_44p8_p3_0,&_44p8_p3_1,0}, | |||||
{&_44p8_p4_0,&_44p8_p4_1,0}, | |||||
{&_44p8_p5_0,&_44p8_p5_1,0}, | |||||
{&_44p8_p6_0,&_44p8_p6_1,&_44p8_p5_1}, | |||||
{&_44p8_p7_0,&_44p8_p7_1,&_44p8_p7_2,&_44p8_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_9={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p9_p1_0}, | |||||
{0,&_44p9_p2_0,0}, | |||||
{&_44p9_p3_0,&_44p9_p3_1,0}, | |||||
{&_44p9_p4_0,&_44p9_p4_1,0}, | |||||
{&_44p9_p5_0,&_44p9_p5_1,0}, | |||||
{&_44p9_p6_0,&_44p9_p6_1,&_44p9_p5_1}, | |||||
{&_44p9_p7_0,&_44p9_p7_1,&_44p9_p7_2,&_44p9_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_ln1={ | |||||
{ | |||||
{&_44pn1_l0_0,&_44pn1_l0_1,0}, | |||||
{&_44pn1_l1_0,&_44pn1_p6_1,&_44pn1_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l0={ | |||||
{ | |||||
{&_44p0_l0_0,&_44p0_l0_1,0}, | |||||
{&_44p0_l1_0,&_44p0_p6_1,&_44p0_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l1={ | |||||
{ | |||||
{&_44p1_l0_0,&_44p1_l0_1,0}, | |||||
{&_44p1_l1_0,&_44p1_p6_1,&_44p1_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l2={ | |||||
{ | |||||
{&_44p2_l0_0,&_44p2_l0_1,0}, | |||||
{&_44p2_l1_0,&_44p2_p7_2,&_44p2_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l3={ | |||||
{ | |||||
{&_44p3_l0_0,&_44p3_l0_1,0}, | |||||
{&_44p3_l1_0,&_44p3_p7_2,&_44p3_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l4={ | |||||
{ | |||||
{&_44p4_l0_0,&_44p4_l0_1,0}, | |||||
{&_44p4_l1_0,&_44p4_p7_2,&_44p4_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l5={ | |||||
{ | |||||
{&_44p5_l0_0,&_44p5_l0_1,0}, | |||||
{&_44p5_l1_0,&_44p5_p7_2,&_44p5_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l6={ | |||||
{ | |||||
{&_44p6_l0_0,&_44p6_l0_1,0}, | |||||
{&_44p6_l1_0,&_44p6_p7_2,&_44p6_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l7={ | |||||
{ | |||||
{&_44p7_l0_0,&_44p7_l0_1,0}, | |||||
{&_44p7_l1_0,&_44p7_p7_2,&_44p7_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l8={ | |||||
{ | |||||
{&_44p8_l0_0,&_44p8_l0_1,0}, | |||||
{&_44p8_l1_0,&_44p8_p7_2,&_44p8_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l9={ | |||||
{ | |||||
{&_44p9_l0_0,&_44p9_l0_1,0}, | |||||
{&_44p9_l1_0,&_44p9_p7_2,&_44p9_p7_3}, | |||||
} | |||||
}; | |||||
static const vorbis_info_mapping0 _map_nominal_51[2]={ | |||||
{2, {0,0,0,0,0,1}, {0,2}, {0,2}, 4,{0,3,0,0},{2,4,1,3}}, | |||||
{2, {0,0,0,0,0,1}, {1,2}, {1,2}, 4,{0,3,0,0},{2,4,1,3}} | |||||
}; | |||||
static const vorbis_info_mapping0 _map_nominal_51u[2]={ | |||||
{2, {0,0,0,0,0,1}, {0,2}, {0,2}, 0,{0},{0}}, | |||||
{2, {0,0,0,0,0,1}, {1,2}, {1,2}, 0,{0},{0}} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_n1[]={ | |||||
{2,0,30, &_residue_44p_lo, | |||||
&_huff_book__44pn1_short,&_huff_book__44pn1_short, | |||||
&_resbook_44p_n1,&_resbook_44p_n1}, | |||||
{2,0,30, &_residue_44p_lo, | |||||
&_huff_book__44pn1_long,&_huff_book__44pn1_long, | |||||
&_resbook_44p_n1,&_resbook_44p_n1}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44pn1_lfe,&_huff_book__44pn1_lfe, | |||||
&_resbook_44p_ln1,&_resbook_44p_ln1} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_0[]={ | |||||
{2,0,15, &_residue_44p_lo, | |||||
&_huff_book__44p0_short,&_huff_book__44p0_short, | |||||
&_resbook_44p_0,&_resbook_44p_0}, | |||||
{2,0,30, &_residue_44p_lo, | |||||
&_huff_book__44p0_long,&_huff_book__44p0_long, | |||||
&_resbook_44p_0,&_resbook_44p_0}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p0_lfe,&_huff_book__44p0_lfe, | |||||
&_resbook_44p_l0,&_resbook_44p_l0} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_1[]={ | |||||
{2,0,15, &_residue_44p_lo, | |||||
&_huff_book__44p1_short,&_huff_book__44p1_short, | |||||
&_resbook_44p_1,&_resbook_44p_1}, | |||||
{2,0,30, &_residue_44p_lo, | |||||
&_huff_book__44p1_long,&_huff_book__44p1_long, | |||||
&_resbook_44p_1,&_resbook_44p_1}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p1_lfe,&_huff_book__44p1_lfe, | |||||
&_resbook_44p_l1,&_resbook_44p_l1} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_2[]={ | |||||
{2,0,15, &_residue_44p, | |||||
&_huff_book__44p2_short,&_huff_book__44p2_short, | |||||
&_resbook_44p_2,&_resbook_44p_2}, | |||||
{2,0,30, &_residue_44p, | |||||
&_huff_book__44p2_long,&_huff_book__44p2_long, | |||||
&_resbook_44p_2,&_resbook_44p_2}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p2_lfe,&_huff_book__44p2_lfe, | |||||
&_resbook_44p_l2,&_resbook_44p_l2} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_3[]={ | |||||
{2,0,15, &_residue_44p, | |||||
&_huff_book__44p3_short,&_huff_book__44p3_short, | |||||
&_resbook_44p_3,&_resbook_44p_3}, | |||||
{2,0,30, &_residue_44p, | |||||
&_huff_book__44p3_long,&_huff_book__44p3_long, | |||||
&_resbook_44p_3,&_resbook_44p_3}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p3_lfe,&_huff_book__44p3_lfe, | |||||
&_resbook_44p_l3,&_resbook_44p_l3} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_4[]={ | |||||
{2,0,15, &_residue_44p, | |||||
&_huff_book__44p4_short,&_huff_book__44p4_short, | |||||
&_resbook_44p_4,&_resbook_44p_4}, | |||||
{2,0,30, &_residue_44p, | |||||
&_huff_book__44p4_long,&_huff_book__44p4_long, | |||||
&_resbook_44p_4,&_resbook_44p_4}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p4_lfe,&_huff_book__44p4_lfe, | |||||
&_resbook_44p_l4,&_resbook_44p_l4} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_5[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p5_short,&_huff_book__44p5_short, | |||||
&_resbook_44p_5,&_resbook_44p_5}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p5_long,&_huff_book__44p5_long, | |||||
&_resbook_44p_5,&_resbook_44p_5}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p5_lfe,&_huff_book__44p5_lfe, | |||||
&_resbook_44p_l5,&_resbook_44p_l5} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_6[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p6_short,&_huff_book__44p6_short, | |||||
&_resbook_44p_6,&_resbook_44p_6}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p6_long,&_huff_book__44p6_long, | |||||
&_resbook_44p_6,&_resbook_44p_6}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p6_lfe,&_huff_book__44p6_lfe, | |||||
&_resbook_44p_l6,&_resbook_44p_l6} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_7[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p7_short,&_huff_book__44p7_short, | |||||
&_resbook_44p_7,&_resbook_44p_7}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p7_long,&_huff_book__44p7_long, | |||||
&_resbook_44p_7,&_resbook_44p_7}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p6_lfe,&_huff_book__44p6_lfe, | |||||
&_resbook_44p_l6,&_resbook_44p_l6} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_8[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p8_short,&_huff_book__44p8_short, | |||||
&_resbook_44p_8,&_resbook_44p_8}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p8_long,&_huff_book__44p8_long, | |||||
&_resbook_44p_8,&_resbook_44p_8}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p6_lfe,&_huff_book__44p6_lfe, | |||||
&_resbook_44p_l6,&_resbook_44p_l6} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_9[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p9_short,&_huff_book__44p9_short, | |||||
&_resbook_44p_9,&_resbook_44p_9}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p9_long,&_huff_book__44p9_long, | |||||
&_resbook_44p_9,&_resbook_44p_9}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p6_lfe,&_huff_book__44p6_lfe, | |||||
&_resbook_44p_l6,&_resbook_44p_l6} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_44_51[]={ | |||||
{ _map_nominal_51, _res_44p51_n1 }, /* -1 */ | |||||
{ _map_nominal_51, _res_44p51_0 }, /* 0 */ | |||||
{ _map_nominal_51, _res_44p51_1 }, /* 1 */ | |||||
{ _map_nominal_51, _res_44p51_2 }, /* 2 */ | |||||
{ _map_nominal_51, _res_44p51_3 }, /* 3 */ | |||||
{ _map_nominal_51, _res_44p51_4 }, /* 4 */ | |||||
{ _map_nominal_51u, _res_44p51_5 }, /* 5 */ | |||||
{ _map_nominal_51u, _res_44p51_6 }, /* 6 */ | |||||
{ _map_nominal_51u, _res_44p51_7 }, /* 7 */ | |||||
{ _map_nominal_51u, _res_44p51_8 }, /* 8 */ | |||||
{ _map_nominal_51u, _res_44p51_9 }, /* 9 */ | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates for 32/44.1/48kHz uncoupled | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
#include "../books/coupled/res_books_51.h" | |||||
/***** residue backends *********************************************/ | |||||
static const vorbis_info_residue0 _residue_44p_lo={ | |||||
0,-1, -1, 7,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 7, 17, 31}, | |||||
{ 0, 0, 99, 7, 17, 31}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44p={ | |||||
0,-1, -1, 8,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 1, 2, 7, 17, 31}, | |||||
{ 0, 0, 99, 99, 7, 17, 31}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44p_hi={ | |||||
0,-1, -1, 8,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 4, 7, 17, 31}, | |||||
{ 0, 1, 2, 4, 7, 17, 31}, | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44p_lfe={ | |||||
0,-1, -1, 2,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 32}, | |||||
{ -1} | |||||
}; | |||||
static const static_bookblock _resbook_44p_n1={ | |||||
{ | |||||
{0}, | |||||
{0,&_44pn1_p1_0}, | |||||
{&_44pn1_p2_0,&_44pn1_p2_1,0}, | |||||
{&_44pn1_p3_0,&_44pn1_p3_1,0}, | |||||
{&_44pn1_p4_0,&_44pn1_p4_1,0}, | |||||
{&_44pn1_p5_0,&_44pn1_p5_1,&_44pn1_p4_1}, | |||||
{&_44pn1_p6_0,&_44pn1_p6_1,&_44pn1_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_0={ | |||||
{ | |||||
{0}, | |||||
{0,&_44p0_p1_0}, | |||||
{&_44p0_p2_0,&_44p0_p2_1,0}, | |||||
{&_44p0_p3_0,&_44p0_p3_1,0}, | |||||
{&_44p0_p4_0,&_44p0_p4_1,0}, | |||||
{&_44p0_p5_0,&_44p0_p5_1,&_44p0_p4_1}, | |||||
{&_44p0_p6_0,&_44p0_p6_1,&_44p0_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_1={ | |||||
{ | |||||
{0}, | |||||
{0,&_44p1_p1_0}, | |||||
{&_44p1_p2_0,&_44p1_p2_1,0}, | |||||
{&_44p1_p3_0,&_44p1_p3_1,0}, | |||||
{&_44p1_p4_0,&_44p1_p4_1,0}, | |||||
{&_44p1_p5_0,&_44p1_p5_1,&_44p1_p4_1}, | |||||
{&_44p1_p6_0,&_44p1_p6_1,&_44p1_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_2={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p2_p1_0}, | |||||
{0,&_44p2_p2_0,0}, | |||||
{&_44p2_p3_0,&_44p2_p3_1,0}, | |||||
{&_44p2_p4_0,&_44p2_p4_1,0}, | |||||
{&_44p2_p5_0,&_44p2_p5_1,0}, | |||||
{&_44p2_p6_0,&_44p2_p6_1,&_44p2_p5_1}, | |||||
{&_44p2_p7_0,&_44p2_p7_1,&_44p2_p7_2,&_44p2_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_3={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p3_p1_0}, | |||||
{0,&_44p3_p2_0,0}, | |||||
{&_44p3_p3_0,&_44p3_p3_1,0}, | |||||
{&_44p3_p4_0,&_44p3_p4_1,0}, | |||||
{&_44p3_p5_0,&_44p3_p5_1,0}, | |||||
{&_44p3_p6_0,&_44p3_p6_1,&_44p3_p5_1}, | |||||
{&_44p3_p7_0,&_44p3_p7_1,&_44p3_p7_2,&_44p3_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_4={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p4_p1_0}, | |||||
{0,&_44p4_p2_0,0}, | |||||
{&_44p4_p3_0,&_44p4_p3_1,0}, | |||||
{&_44p4_p4_0,&_44p4_p4_1,0}, | |||||
{&_44p4_p5_0,&_44p4_p5_1,0}, | |||||
{&_44p4_p6_0,&_44p4_p6_1,&_44p4_p5_1}, | |||||
{&_44p4_p7_0,&_44p4_p7_1,&_44p4_p7_2,&_44p4_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_5={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p5_p1_0}, | |||||
{0,&_44p5_p2_0,0}, | |||||
{&_44p5_p3_0,&_44p5_p3_1,0}, | |||||
{&_44p5_p4_0,&_44p5_p4_1,0}, | |||||
{&_44p5_p5_0,&_44p5_p5_1,0}, | |||||
{&_44p5_p6_0,&_44p5_p6_1,&_44p5_p5_1}, | |||||
{&_44p5_p7_0,&_44p5_p7_1,&_44p5_p7_2,&_44p5_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_6={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p6_p1_0}, | |||||
{0,&_44p6_p2_0,0}, | |||||
{&_44p6_p3_0,&_44p6_p3_1,0}, | |||||
{&_44p6_p4_0,&_44p6_p4_1,0}, | |||||
{&_44p6_p5_0,&_44p6_p5_1,0}, | |||||
{&_44p6_p6_0,&_44p6_p6_1,&_44p6_p5_1}, | |||||
{&_44p6_p7_0,&_44p6_p7_1,&_44p6_p7_2,&_44p6_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_7={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p7_p1_0}, | |||||
{0,&_44p7_p2_0,0}, | |||||
{&_44p7_p3_0,&_44p7_p3_1,0}, | |||||
{&_44p7_p4_0,&_44p7_p4_1,0}, | |||||
{&_44p7_p5_0,&_44p7_p5_1,0}, | |||||
{&_44p7_p6_0,&_44p7_p6_1,&_44p7_p5_1}, | |||||
{&_44p7_p7_0,&_44p7_p7_1,&_44p7_p7_2,&_44p7_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_8={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p8_p1_0}, | |||||
{0,&_44p8_p2_0,0}, | |||||
{&_44p8_p3_0,&_44p8_p3_1,0}, | |||||
{&_44p8_p4_0,&_44p8_p4_1,0}, | |||||
{&_44p8_p5_0,&_44p8_p5_1,0}, | |||||
{&_44p8_p6_0,&_44p8_p6_1,&_44p8_p5_1}, | |||||
{&_44p8_p7_0,&_44p8_p7_1,&_44p8_p7_2,&_44p8_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_9={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44p9_p1_0}, | |||||
{0,&_44p9_p2_0,0}, | |||||
{&_44p9_p3_0,&_44p9_p3_1,0}, | |||||
{&_44p9_p4_0,&_44p9_p4_1,0}, | |||||
{&_44p9_p5_0,&_44p9_p5_1,0}, | |||||
{&_44p9_p6_0,&_44p9_p6_1,&_44p9_p5_1}, | |||||
{&_44p9_p7_0,&_44p9_p7_1,&_44p9_p7_2,&_44p9_p7_3} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_ln1={ | |||||
{ | |||||
{&_44pn1_l0_0,&_44pn1_l0_1,0}, | |||||
{&_44pn1_l1_0,&_44pn1_p6_1,&_44pn1_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l0={ | |||||
{ | |||||
{&_44p0_l0_0,&_44p0_l0_1,0}, | |||||
{&_44p0_l1_0,&_44p0_p6_1,&_44p0_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l1={ | |||||
{ | |||||
{&_44p1_l0_0,&_44p1_l0_1,0}, | |||||
{&_44p1_l1_0,&_44p1_p6_1,&_44p1_p6_2}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l2={ | |||||
{ | |||||
{&_44p2_l0_0,&_44p2_l0_1,0}, | |||||
{&_44p2_l1_0,&_44p2_p7_2,&_44p2_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l3={ | |||||
{ | |||||
{&_44p3_l0_0,&_44p3_l0_1,0}, | |||||
{&_44p3_l1_0,&_44p3_p7_2,&_44p3_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l4={ | |||||
{ | |||||
{&_44p4_l0_0,&_44p4_l0_1,0}, | |||||
{&_44p4_l1_0,&_44p4_p7_2,&_44p4_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l5={ | |||||
{ | |||||
{&_44p5_l0_0,&_44p5_l0_1,0}, | |||||
{&_44p5_l1_0,&_44p5_p7_2,&_44p5_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l6={ | |||||
{ | |||||
{&_44p6_l0_0,&_44p6_l0_1,0}, | |||||
{&_44p6_l1_0,&_44p6_p7_2,&_44p6_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l7={ | |||||
{ | |||||
{&_44p7_l0_0,&_44p7_l0_1,0}, | |||||
{&_44p7_l1_0,&_44p7_p7_2,&_44p7_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l8={ | |||||
{ | |||||
{&_44p8_l0_0,&_44p8_l0_1,0}, | |||||
{&_44p8_l1_0,&_44p8_p7_2,&_44p8_p7_3}, | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44p_l9={ | |||||
{ | |||||
{&_44p9_l0_0,&_44p9_l0_1,0}, | |||||
{&_44p9_l1_0,&_44p9_p7_2,&_44p9_p7_3}, | |||||
} | |||||
}; | |||||
static const vorbis_info_mapping0 _map_nominal_51[2]={ | |||||
{2, {0,0,0,0,0,1}, {0,2}, {0,2}, 4,{0,3,0,0},{2,4,1,3}}, | |||||
{2, {0,0,0,0,0,1}, {1,2}, {1,2}, 4,{0,3,0,0},{2,4,1,3}} | |||||
}; | |||||
static const vorbis_info_mapping0 _map_nominal_51u[2]={ | |||||
{2, {0,0,0,0,0,1}, {0,2}, {0,2}, 0,{0},{0}}, | |||||
{2, {0,0,0,0,0,1}, {1,2}, {1,2}, 0,{0},{0}} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_n1[]={ | |||||
{2,0,30, &_residue_44p_lo, | |||||
&_huff_book__44pn1_short,&_huff_book__44pn1_short, | |||||
&_resbook_44p_n1,&_resbook_44p_n1}, | |||||
{2,0,30, &_residue_44p_lo, | |||||
&_huff_book__44pn1_long,&_huff_book__44pn1_long, | |||||
&_resbook_44p_n1,&_resbook_44p_n1}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44pn1_lfe,&_huff_book__44pn1_lfe, | |||||
&_resbook_44p_ln1,&_resbook_44p_ln1} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_0[]={ | |||||
{2,0,15, &_residue_44p_lo, | |||||
&_huff_book__44p0_short,&_huff_book__44p0_short, | |||||
&_resbook_44p_0,&_resbook_44p_0}, | |||||
{2,0,30, &_residue_44p_lo, | |||||
&_huff_book__44p0_long,&_huff_book__44p0_long, | |||||
&_resbook_44p_0,&_resbook_44p_0}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p0_lfe,&_huff_book__44p0_lfe, | |||||
&_resbook_44p_l0,&_resbook_44p_l0} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_1[]={ | |||||
{2,0,15, &_residue_44p_lo, | |||||
&_huff_book__44p1_short,&_huff_book__44p1_short, | |||||
&_resbook_44p_1,&_resbook_44p_1}, | |||||
{2,0,30, &_residue_44p_lo, | |||||
&_huff_book__44p1_long,&_huff_book__44p1_long, | |||||
&_resbook_44p_1,&_resbook_44p_1}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p1_lfe,&_huff_book__44p1_lfe, | |||||
&_resbook_44p_l1,&_resbook_44p_l1} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_2[]={ | |||||
{2,0,15, &_residue_44p, | |||||
&_huff_book__44p2_short,&_huff_book__44p2_short, | |||||
&_resbook_44p_2,&_resbook_44p_2}, | |||||
{2,0,30, &_residue_44p, | |||||
&_huff_book__44p2_long,&_huff_book__44p2_long, | |||||
&_resbook_44p_2,&_resbook_44p_2}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p2_lfe,&_huff_book__44p2_lfe, | |||||
&_resbook_44p_l2,&_resbook_44p_l2} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_3[]={ | |||||
{2,0,15, &_residue_44p, | |||||
&_huff_book__44p3_short,&_huff_book__44p3_short, | |||||
&_resbook_44p_3,&_resbook_44p_3}, | |||||
{2,0,30, &_residue_44p, | |||||
&_huff_book__44p3_long,&_huff_book__44p3_long, | |||||
&_resbook_44p_3,&_resbook_44p_3}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p3_lfe,&_huff_book__44p3_lfe, | |||||
&_resbook_44p_l3,&_resbook_44p_l3} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_4[]={ | |||||
{2,0,15, &_residue_44p, | |||||
&_huff_book__44p4_short,&_huff_book__44p4_short, | |||||
&_resbook_44p_4,&_resbook_44p_4}, | |||||
{2,0,30, &_residue_44p, | |||||
&_huff_book__44p4_long,&_huff_book__44p4_long, | |||||
&_resbook_44p_4,&_resbook_44p_4}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p4_lfe,&_huff_book__44p4_lfe, | |||||
&_resbook_44p_l4,&_resbook_44p_l4} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_5[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p5_short,&_huff_book__44p5_short, | |||||
&_resbook_44p_5,&_resbook_44p_5}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p5_long,&_huff_book__44p5_long, | |||||
&_resbook_44p_5,&_resbook_44p_5}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p5_lfe,&_huff_book__44p5_lfe, | |||||
&_resbook_44p_l5,&_resbook_44p_l5} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_6[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p6_short,&_huff_book__44p6_short, | |||||
&_resbook_44p_6,&_resbook_44p_6}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p6_long,&_huff_book__44p6_long, | |||||
&_resbook_44p_6,&_resbook_44p_6}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p6_lfe,&_huff_book__44p6_lfe, | |||||
&_resbook_44p_l6,&_resbook_44p_l6} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_7[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p7_short,&_huff_book__44p7_short, | |||||
&_resbook_44p_7,&_resbook_44p_7}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p7_long,&_huff_book__44p7_long, | |||||
&_resbook_44p_7,&_resbook_44p_7}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p6_lfe,&_huff_book__44p6_lfe, | |||||
&_resbook_44p_l6,&_resbook_44p_l6} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_8[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p8_short,&_huff_book__44p8_short, | |||||
&_resbook_44p_8,&_resbook_44p_8}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p8_long,&_huff_book__44p8_long, | |||||
&_resbook_44p_8,&_resbook_44p_8}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p6_lfe,&_huff_book__44p6_lfe, | |||||
&_resbook_44p_l6,&_resbook_44p_l6} | |||||
}; | |||||
static const vorbis_residue_template _res_44p51_9[]={ | |||||
{2,0,15, &_residue_44p_hi, | |||||
&_huff_book__44p9_short,&_huff_book__44p9_short, | |||||
&_resbook_44p_9,&_resbook_44p_9}, | |||||
{2,0,30, &_residue_44p_hi, | |||||
&_huff_book__44p9_long,&_huff_book__44p9_long, | |||||
&_resbook_44p_9,&_resbook_44p_9}, | |||||
{1,2,6, &_residue_44p_lfe, | |||||
&_huff_book__44p6_lfe,&_huff_book__44p6_lfe, | |||||
&_resbook_44p_l6,&_resbook_44p_l6} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_44_51[]={ | |||||
{ _map_nominal_51, _res_44p51_n1 }, /* -1 */ | |||||
{ _map_nominal_51, _res_44p51_0 }, /* 0 */ | |||||
{ _map_nominal_51, _res_44p51_1 }, /* 1 */ | |||||
{ _map_nominal_51, _res_44p51_2 }, /* 2 */ | |||||
{ _map_nominal_51, _res_44p51_3 }, /* 3 */ | |||||
{ _map_nominal_51, _res_44p51_4 }, /* 4 */ | |||||
{ _map_nominal_51u, _res_44p51_5 }, /* 5 */ | |||||
{ _map_nominal_51u, _res_44p51_6 }, /* 6 */ | |||||
{ _map_nominal_51u, _res_44p51_7 }, /* 7 */ | |||||
{ _map_nominal_51u, _res_44p51_8 }, /* 8 */ | |||||
{ _map_nominal_51u, _res_44p51_9 }, /* 9 */ | |||||
}; |
@@ -1,318 +1,317 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates for 32/44.1/48kHz uncoupled | |||||
last mod: $Id: residue_44u.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
#include "../books/uncoupled/res_books_uncoupled.h" | |||||
/***** residue backends *********************************************/ | |||||
static const vorbis_info_residue0 _residue_44_low_un={ | |||||
0,-1, -1, 8,-1,-1, | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 1, 2, 2, 4, 28}, | |||||
{ -1, 25, -1, 45, -1, -1, -1} | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44_mid_un={ | |||||
0,-1, -1, 10,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 9 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 1, 2, 2, 4, 4, 16, 60}, | |||||
{ -1, 30, -1, 50, -1, 80, -1, -1, -1} | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44_hi_un={ | |||||
0,-1, -1, 10,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 9 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 4, 8, 16, 32, 71,157}, | |||||
{ -1, -1, -1, -1, -1, -1, -1, -1, -1} | |||||
}; | |||||
/* mapping conventions: | |||||
only one submap (this would change for efficient 5.1 support for example)*/ | |||||
/* Four psychoacoustic profiles are used, one for each blocktype */ | |||||
static const vorbis_info_mapping0 _map_nominal_u[2]={ | |||||
{1, {0,0,0,0,0,0}, {0}, {0}, 0,{0},{0}}, | |||||
{1, {0,0,0,0,0,0}, {1}, {1}, 0,{0},{0}} | |||||
}; | |||||
static const static_bookblock _resbook_44u_n1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44un1__p1_0}, | |||||
{0,0,&_44un1__p2_0}, | |||||
{0,0,&_44un1__p3_0}, | |||||
{0,0,&_44un1__p4_0}, | |||||
{0,0,&_44un1__p5_0}, | |||||
{&_44un1__p6_0,&_44un1__p6_1}, | |||||
{&_44un1__p7_0,&_44un1__p7_1,&_44un1__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u0__p1_0}, | |||||
{0,0,&_44u0__p2_0}, | |||||
{0,0,&_44u0__p3_0}, | |||||
{0,0,&_44u0__p4_0}, | |||||
{0,0,&_44u0__p5_0}, | |||||
{&_44u0__p6_0,&_44u0__p6_1}, | |||||
{&_44u0__p7_0,&_44u0__p7_1,&_44u0__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u1__p1_0}, | |||||
{0,0,&_44u1__p2_0}, | |||||
{0,0,&_44u1__p3_0}, | |||||
{0,0,&_44u1__p4_0}, | |||||
{0,0,&_44u1__p5_0}, | |||||
{&_44u1__p6_0,&_44u1__p6_1}, | |||||
{&_44u1__p7_0,&_44u1__p7_1,&_44u1__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_2={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u2__p1_0}, | |||||
{0,0,&_44u2__p2_0}, | |||||
{0,0,&_44u2__p3_0}, | |||||
{0,0,&_44u2__p4_0}, | |||||
{0,0,&_44u2__p5_0}, | |||||
{&_44u2__p6_0,&_44u2__p6_1}, | |||||
{&_44u2__p7_0,&_44u2__p7_1,&_44u2__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_3={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u3__p1_0}, | |||||
{0,0,&_44u3__p2_0}, | |||||
{0,0,&_44u3__p3_0}, | |||||
{0,0,&_44u3__p4_0}, | |||||
{0,0,&_44u3__p5_0}, | |||||
{&_44u3__p6_0,&_44u3__p6_1}, | |||||
{&_44u3__p7_0,&_44u3__p7_1,&_44u3__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_4={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u4__p1_0}, | |||||
{0,0,&_44u4__p2_0}, | |||||
{0,0,&_44u4__p3_0}, | |||||
{0,0,&_44u4__p4_0}, | |||||
{0,0,&_44u4__p5_0}, | |||||
{&_44u4__p6_0,&_44u4__p6_1}, | |||||
{&_44u4__p7_0,&_44u4__p7_1,&_44u4__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_5={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u5__p1_0}, | |||||
{0,0,&_44u5__p2_0}, | |||||
{0,0,&_44u5__p3_0}, | |||||
{0,0,&_44u5__p4_0}, | |||||
{0,0,&_44u5__p5_0}, | |||||
{0,0,&_44u5__p6_0}, | |||||
{&_44u5__p7_0,&_44u5__p7_1}, | |||||
{&_44u5__p8_0,&_44u5__p8_1}, | |||||
{&_44u5__p9_0,&_44u5__p9_1,&_44u5__p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_6={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u6__p1_0}, | |||||
{0,0,&_44u6__p2_0}, | |||||
{0,0,&_44u6__p3_0}, | |||||
{0,0,&_44u6__p4_0}, | |||||
{0,0,&_44u6__p5_0}, | |||||
{0,0,&_44u6__p6_0}, | |||||
{&_44u6__p7_0,&_44u6__p7_1}, | |||||
{&_44u6__p8_0,&_44u6__p8_1}, | |||||
{&_44u6__p9_0,&_44u6__p9_1,&_44u6__p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_7={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u7__p1_0}, | |||||
{0,0,&_44u7__p2_0}, | |||||
{0,0,&_44u7__p3_0}, | |||||
{0,0,&_44u7__p4_0}, | |||||
{0,0,&_44u7__p5_0}, | |||||
{0,0,&_44u7__p6_0}, | |||||
{&_44u7__p7_0,&_44u7__p7_1}, | |||||
{&_44u7__p8_0,&_44u7__p8_1}, | |||||
{&_44u7__p9_0,&_44u7__p9_1,&_44u7__p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_8={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u8_p1_0}, | |||||
{0,0,&_44u8_p2_0}, | |||||
{0,0,&_44u8_p3_0}, | |||||
{0,0,&_44u8_p4_0}, | |||||
{&_44u8_p5_0,&_44u8_p5_1}, | |||||
{&_44u8_p6_0,&_44u8_p6_1}, | |||||
{&_44u8_p7_0,&_44u8_p7_1}, | |||||
{&_44u8_p8_0,&_44u8_p8_1}, | |||||
{&_44u8_p9_0,&_44u8_p9_1,&_44u8_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_9={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u9_p1_0}, | |||||
{0,0,&_44u9_p2_0}, | |||||
{0,0,&_44u9_p3_0}, | |||||
{0,0,&_44u9_p4_0}, | |||||
{&_44u9_p5_0,&_44u9_p5_1}, | |||||
{&_44u9_p6_0,&_44u9_p6_1}, | |||||
{&_44u9_p7_0,&_44u9_p7_1}, | |||||
{&_44u9_p8_0,&_44u9_p8_1}, | |||||
{&_44u9_p9_0,&_44u9_p9_1,&_44u9_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_n1[]={ | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44un1__short,&_huff_book__44un1__short, | |||||
&_resbook_44u_n1,&_resbook_44u_n1}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44un1__long,&_huff_book__44un1__long, | |||||
&_resbook_44u_n1,&_resbook_44u_n1} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_0[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u0__short,&_huff_book__44u0__short, | |||||
&_resbook_44u_0,&_resbook_44u_0}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u0__long,&_huff_book__44u0__long, | |||||
&_resbook_44u_0,&_resbook_44u_0} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_1[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u1__short,&_huff_book__44u1__short, | |||||
&_resbook_44u_1,&_resbook_44u_1}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u1__long,&_huff_book__44u1__long, | |||||
&_resbook_44u_1,&_resbook_44u_1} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_2[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u2__short,&_huff_book__44u2__short, | |||||
&_resbook_44u_2,&_resbook_44u_2}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u2__long,&_huff_book__44u2__long, | |||||
&_resbook_44u_2,&_resbook_44u_2} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_3[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u3__short,&_huff_book__44u3__short, | |||||
&_resbook_44u_3,&_resbook_44u_3}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u3__long,&_huff_book__44u3__long, | |||||
&_resbook_44u_3,&_resbook_44u_3} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_4[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u4__short,&_huff_book__44u4__short, | |||||
&_resbook_44u_4,&_resbook_44u_4}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u4__long,&_huff_book__44u4__long, | |||||
&_resbook_44u_4,&_resbook_44u_4} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_5[]={ | |||||
{1,0,16, &_residue_44_mid_un, | |||||
&_huff_book__44u5__short,&_huff_book__44u5__short, | |||||
&_resbook_44u_5,&_resbook_44u_5}, | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__44u5__long,&_huff_book__44u5__long, | |||||
&_resbook_44u_5,&_resbook_44u_5} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_6[]={ | |||||
{1,0,16, &_residue_44_mid_un, | |||||
&_huff_book__44u6__short,&_huff_book__44u6__short, | |||||
&_resbook_44u_6,&_resbook_44u_6}, | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__44u6__long,&_huff_book__44u6__long, | |||||
&_resbook_44u_6,&_resbook_44u_6} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_7[]={ | |||||
{1,0,16, &_residue_44_mid_un, | |||||
&_huff_book__44u7__short,&_huff_book__44u7__short, | |||||
&_resbook_44u_7,&_resbook_44u_7}, | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__44u7__long,&_huff_book__44u7__long, | |||||
&_resbook_44u_7,&_resbook_44u_7} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_8[]={ | |||||
{1,0,16, &_residue_44_hi_un, | |||||
&_huff_book__44u8__short,&_huff_book__44u8__short, | |||||
&_resbook_44u_8,&_resbook_44u_8}, | |||||
{1,0,32, &_residue_44_hi_un, | |||||
&_huff_book__44u8__long,&_huff_book__44u8__long, | |||||
&_resbook_44u_8,&_resbook_44u_8} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_9[]={ | |||||
{1,0,16, &_residue_44_hi_un, | |||||
&_huff_book__44u9__short,&_huff_book__44u9__short, | |||||
&_resbook_44u_9,&_resbook_44u_9}, | |||||
{1,0,32, &_residue_44_hi_un, | |||||
&_huff_book__44u9__long,&_huff_book__44u9__long, | |||||
&_resbook_44u_9,&_resbook_44u_9} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_44_uncoupled[]={ | |||||
{ _map_nominal_u, _res_44u_n1 }, /* -1 */ | |||||
{ _map_nominal_u, _res_44u_0 }, /* 0 */ | |||||
{ _map_nominal_u, _res_44u_1 }, /* 1 */ | |||||
{ _map_nominal_u, _res_44u_2 }, /* 2 */ | |||||
{ _map_nominal_u, _res_44u_3 }, /* 3 */ | |||||
{ _map_nominal_u, _res_44u_4 }, /* 4 */ | |||||
{ _map_nominal_u, _res_44u_5 }, /* 5 */ | |||||
{ _map_nominal_u, _res_44u_6 }, /* 6 */ | |||||
{ _map_nominal_u, _res_44u_7 }, /* 7 */ | |||||
{ _map_nominal_u, _res_44u_8 }, /* 8 */ | |||||
{ _map_nominal_u, _res_44u_9 }, /* 9 */ | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates for 32/44.1/48kHz uncoupled | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
#include "../books/uncoupled/res_books_uncoupled.h" | |||||
/***** residue backends *********************************************/ | |||||
static const vorbis_info_residue0 _residue_44_low_un={ | |||||
0,-1, -1, 8,-1,-1, | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 1, 2, 2, 4, 28}, | |||||
{ -1, 25, -1, 45, -1, -1, -1} | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44_mid_un={ | |||||
0,-1, -1, 10,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 9 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 1, 2, 2, 4, 4, 16, 60}, | |||||
{ -1, 30, -1, 50, -1, 80, -1, -1, -1} | |||||
}; | |||||
static const vorbis_info_residue0 _residue_44_hi_un={ | |||||
0,-1, -1, 10,-1,-1, | |||||
/* 0 1 2 3 4 5 6 7 8 9 */ | |||||
{0}, | |||||
{-1}, | |||||
{ 0, 1, 2, 4, 8, 16, 32, 71,157}, | |||||
{ -1, -1, -1, -1, -1, -1, -1, -1, -1} | |||||
}; | |||||
/* mapping conventions: | |||||
only one submap (this would change for efficient 5.1 support for example)*/ | |||||
/* Four psychoacoustic profiles are used, one for each blocktype */ | |||||
static const vorbis_info_mapping0 _map_nominal_u[2]={ | |||||
{1, {0,0,0,0,0,0}, {0}, {0}, 0,{0},{0}}, | |||||
{1, {0,0,0,0,0,0}, {1}, {1}, 0,{0},{0}} | |||||
}; | |||||
static const static_bookblock _resbook_44u_n1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44un1__p1_0}, | |||||
{0,0,&_44un1__p2_0}, | |||||
{0,0,&_44un1__p3_0}, | |||||
{0,0,&_44un1__p4_0}, | |||||
{0,0,&_44un1__p5_0}, | |||||
{&_44un1__p6_0,&_44un1__p6_1}, | |||||
{&_44un1__p7_0,&_44un1__p7_1,&_44un1__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u0__p1_0}, | |||||
{0,0,&_44u0__p2_0}, | |||||
{0,0,&_44u0__p3_0}, | |||||
{0,0,&_44u0__p4_0}, | |||||
{0,0,&_44u0__p5_0}, | |||||
{&_44u0__p6_0,&_44u0__p6_1}, | |||||
{&_44u0__p7_0,&_44u0__p7_1,&_44u0__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u1__p1_0}, | |||||
{0,0,&_44u1__p2_0}, | |||||
{0,0,&_44u1__p3_0}, | |||||
{0,0,&_44u1__p4_0}, | |||||
{0,0,&_44u1__p5_0}, | |||||
{&_44u1__p6_0,&_44u1__p6_1}, | |||||
{&_44u1__p7_0,&_44u1__p7_1,&_44u1__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_2={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u2__p1_0}, | |||||
{0,0,&_44u2__p2_0}, | |||||
{0,0,&_44u2__p3_0}, | |||||
{0,0,&_44u2__p4_0}, | |||||
{0,0,&_44u2__p5_0}, | |||||
{&_44u2__p6_0,&_44u2__p6_1}, | |||||
{&_44u2__p7_0,&_44u2__p7_1,&_44u2__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_3={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u3__p1_0}, | |||||
{0,0,&_44u3__p2_0}, | |||||
{0,0,&_44u3__p3_0}, | |||||
{0,0,&_44u3__p4_0}, | |||||
{0,0,&_44u3__p5_0}, | |||||
{&_44u3__p6_0,&_44u3__p6_1}, | |||||
{&_44u3__p7_0,&_44u3__p7_1,&_44u3__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_4={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u4__p1_0}, | |||||
{0,0,&_44u4__p2_0}, | |||||
{0,0,&_44u4__p3_0}, | |||||
{0,0,&_44u4__p4_0}, | |||||
{0,0,&_44u4__p5_0}, | |||||
{&_44u4__p6_0,&_44u4__p6_1}, | |||||
{&_44u4__p7_0,&_44u4__p7_1,&_44u4__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_5={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u5__p1_0}, | |||||
{0,0,&_44u5__p2_0}, | |||||
{0,0,&_44u5__p3_0}, | |||||
{0,0,&_44u5__p4_0}, | |||||
{0,0,&_44u5__p5_0}, | |||||
{0,0,&_44u5__p6_0}, | |||||
{&_44u5__p7_0,&_44u5__p7_1}, | |||||
{&_44u5__p8_0,&_44u5__p8_1}, | |||||
{&_44u5__p9_0,&_44u5__p9_1,&_44u5__p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_6={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u6__p1_0}, | |||||
{0,0,&_44u6__p2_0}, | |||||
{0,0,&_44u6__p3_0}, | |||||
{0,0,&_44u6__p4_0}, | |||||
{0,0,&_44u6__p5_0}, | |||||
{0,0,&_44u6__p6_0}, | |||||
{&_44u6__p7_0,&_44u6__p7_1}, | |||||
{&_44u6__p8_0,&_44u6__p8_1}, | |||||
{&_44u6__p9_0,&_44u6__p9_1,&_44u6__p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_7={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u7__p1_0}, | |||||
{0,0,&_44u7__p2_0}, | |||||
{0,0,&_44u7__p3_0}, | |||||
{0,0,&_44u7__p4_0}, | |||||
{0,0,&_44u7__p5_0}, | |||||
{0,0,&_44u7__p6_0}, | |||||
{&_44u7__p7_0,&_44u7__p7_1}, | |||||
{&_44u7__p8_0,&_44u7__p8_1}, | |||||
{&_44u7__p9_0,&_44u7__p9_1,&_44u7__p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_8={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u8_p1_0}, | |||||
{0,0,&_44u8_p2_0}, | |||||
{0,0,&_44u8_p3_0}, | |||||
{0,0,&_44u8_p4_0}, | |||||
{&_44u8_p5_0,&_44u8_p5_1}, | |||||
{&_44u8_p6_0,&_44u8_p6_1}, | |||||
{&_44u8_p7_0,&_44u8_p7_1}, | |||||
{&_44u8_p8_0,&_44u8_p8_1}, | |||||
{&_44u8_p9_0,&_44u8_p9_1,&_44u8_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_44u_9={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_44u9_p1_0}, | |||||
{0,0,&_44u9_p2_0}, | |||||
{0,0,&_44u9_p3_0}, | |||||
{0,0,&_44u9_p4_0}, | |||||
{&_44u9_p5_0,&_44u9_p5_1}, | |||||
{&_44u9_p6_0,&_44u9_p6_1}, | |||||
{&_44u9_p7_0,&_44u9_p7_1}, | |||||
{&_44u9_p8_0,&_44u9_p8_1}, | |||||
{&_44u9_p9_0,&_44u9_p9_1,&_44u9_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_n1[]={ | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44un1__short,&_huff_book__44un1__short, | |||||
&_resbook_44u_n1,&_resbook_44u_n1}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44un1__long,&_huff_book__44un1__long, | |||||
&_resbook_44u_n1,&_resbook_44u_n1} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_0[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u0__short,&_huff_book__44u0__short, | |||||
&_resbook_44u_0,&_resbook_44u_0}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u0__long,&_huff_book__44u0__long, | |||||
&_resbook_44u_0,&_resbook_44u_0} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_1[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u1__short,&_huff_book__44u1__short, | |||||
&_resbook_44u_1,&_resbook_44u_1}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u1__long,&_huff_book__44u1__long, | |||||
&_resbook_44u_1,&_resbook_44u_1} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_2[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u2__short,&_huff_book__44u2__short, | |||||
&_resbook_44u_2,&_resbook_44u_2}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u2__long,&_huff_book__44u2__long, | |||||
&_resbook_44u_2,&_resbook_44u_2} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_3[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u3__short,&_huff_book__44u3__short, | |||||
&_resbook_44u_3,&_resbook_44u_3}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u3__long,&_huff_book__44u3__long, | |||||
&_resbook_44u_3,&_resbook_44u_3} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_4[]={ | |||||
{1,0,16, &_residue_44_low_un, | |||||
&_huff_book__44u4__short,&_huff_book__44u4__short, | |||||
&_resbook_44u_4,&_resbook_44u_4}, | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__44u4__long,&_huff_book__44u4__long, | |||||
&_resbook_44u_4,&_resbook_44u_4} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_5[]={ | |||||
{1,0,16, &_residue_44_mid_un, | |||||
&_huff_book__44u5__short,&_huff_book__44u5__short, | |||||
&_resbook_44u_5,&_resbook_44u_5}, | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__44u5__long,&_huff_book__44u5__long, | |||||
&_resbook_44u_5,&_resbook_44u_5} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_6[]={ | |||||
{1,0,16, &_residue_44_mid_un, | |||||
&_huff_book__44u6__short,&_huff_book__44u6__short, | |||||
&_resbook_44u_6,&_resbook_44u_6}, | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__44u6__long,&_huff_book__44u6__long, | |||||
&_resbook_44u_6,&_resbook_44u_6} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_7[]={ | |||||
{1,0,16, &_residue_44_mid_un, | |||||
&_huff_book__44u7__short,&_huff_book__44u7__short, | |||||
&_resbook_44u_7,&_resbook_44u_7}, | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__44u7__long,&_huff_book__44u7__long, | |||||
&_resbook_44u_7,&_resbook_44u_7} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_8[]={ | |||||
{1,0,16, &_residue_44_hi_un, | |||||
&_huff_book__44u8__short,&_huff_book__44u8__short, | |||||
&_resbook_44u_8,&_resbook_44u_8}, | |||||
{1,0,32, &_residue_44_hi_un, | |||||
&_huff_book__44u8__long,&_huff_book__44u8__long, | |||||
&_resbook_44u_8,&_resbook_44u_8} | |||||
}; | |||||
static const vorbis_residue_template _res_44u_9[]={ | |||||
{1,0,16, &_residue_44_hi_un, | |||||
&_huff_book__44u9__short,&_huff_book__44u9__short, | |||||
&_resbook_44u_9,&_resbook_44u_9}, | |||||
{1,0,32, &_residue_44_hi_un, | |||||
&_huff_book__44u9__long,&_huff_book__44u9__long, | |||||
&_resbook_44u_9,&_resbook_44u_9} | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_44_uncoupled[]={ | |||||
{ _map_nominal_u, _res_44u_n1 }, /* -1 */ | |||||
{ _map_nominal_u, _res_44u_0 }, /* 0 */ | |||||
{ _map_nominal_u, _res_44u_1 }, /* 1 */ | |||||
{ _map_nominal_u, _res_44u_2 }, /* 2 */ | |||||
{ _map_nominal_u, _res_44u_3 }, /* 3 */ | |||||
{ _map_nominal_u, _res_44u_4 }, /* 4 */ | |||||
{ _map_nominal_u, _res_44u_5 }, /* 5 */ | |||||
{ _map_nominal_u, _res_44u_6 }, /* 6 */ | |||||
{ _map_nominal_u, _res_44u_7 }, /* 7 */ | |||||
{ _map_nominal_u, _res_44u_8 }, /* 8 */ | |||||
{ _map_nominal_u, _res_44u_9 }, /* 9 */ | |||||
}; |
@@ -1,109 +1,108 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates 8/11kHz | |||||
last mod: $Id: residue_8.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
/***** residue backends *********************************************/ | |||||
static const static_bookblock _resbook_8s_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_8c0_s_p1_0}, | |||||
{0}, | |||||
{0,0,&_8c0_s_p3_0}, | |||||
{0,0,&_8c0_s_p4_0}, | |||||
{0,0,&_8c0_s_p5_0}, | |||||
{0,0,&_8c0_s_p6_0}, | |||||
{&_8c0_s_p7_0,&_8c0_s_p7_1}, | |||||
{&_8c0_s_p8_0,&_8c0_s_p8_1}, | |||||
{&_8c0_s_p9_0,&_8c0_s_p9_1,&_8c0_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_8s_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_8c1_s_p1_0}, | |||||
{0}, | |||||
{0,0,&_8c1_s_p3_0}, | |||||
{0,0,&_8c1_s_p4_0}, | |||||
{0,0,&_8c1_s_p5_0}, | |||||
{0,0,&_8c1_s_p6_0}, | |||||
{&_8c1_s_p7_0,&_8c1_s_p7_1}, | |||||
{&_8c1_s_p8_0,&_8c1_s_p8_1}, | |||||
{&_8c1_s_p9_0,&_8c1_s_p9_1,&_8c1_s_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_8s_0[]={ | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__8c0_s_single,&_huff_book__8c0_s_single, | |||||
&_resbook_8s_0,&_resbook_8s_0}, | |||||
}; | |||||
static const vorbis_residue_template _res_8s_1[]={ | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__8c1_s_single,&_huff_book__8c1_s_single, | |||||
&_resbook_8s_1,&_resbook_8s_1}, | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_8_stereo[2]={ | |||||
{ _map_nominal, _res_8s_0 }, /* 0 */ | |||||
{ _map_nominal, _res_8s_1 }, /* 1 */ | |||||
}; | |||||
static const static_bookblock _resbook_8u_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_8u0__p1_0}, | |||||
{0,0,&_8u0__p2_0}, | |||||
{0,0,&_8u0__p3_0}, | |||||
{0,0,&_8u0__p4_0}, | |||||
{0,0,&_8u0__p5_0}, | |||||
{&_8u0__p6_0,&_8u0__p6_1}, | |||||
{&_8u0__p7_0,&_8u0__p7_1,&_8u0__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_8u_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_8u1__p1_0}, | |||||
{0,0,&_8u1__p2_0}, | |||||
{0,0,&_8u1__p3_0}, | |||||
{0,0,&_8u1__p4_0}, | |||||
{0,0,&_8u1__p5_0}, | |||||
{0,0,&_8u1__p6_0}, | |||||
{&_8u1__p7_0,&_8u1__p7_1}, | |||||
{&_8u1__p8_0,&_8u1__p8_1}, | |||||
{&_8u1__p9_0,&_8u1__p9_1,&_8u1__p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_8u_0[]={ | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__8u0__single,&_huff_book__8u0__single, | |||||
&_resbook_8u_0,&_resbook_8u_0}, | |||||
}; | |||||
static const vorbis_residue_template _res_8u_1[]={ | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__8u1__single,&_huff_book__8u1__single, | |||||
&_resbook_8u_1,&_resbook_8u_1}, | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_8_uncoupled[2]={ | |||||
{ _map_nominal_u, _res_8u_0 }, /* 0 */ | |||||
{ _map_nominal_u, _res_8u_1 }, /* 1 */ | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel residue templates 8/11kHz | |||||
********************************************************************/ | |||||
#include "../../../codec.h" | |||||
#include "../backends.h" | |||||
/***** residue backends *********************************************/ | |||||
static const static_bookblock _resbook_8s_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_8c0_s_p1_0}, | |||||
{0}, | |||||
{0,0,&_8c0_s_p3_0}, | |||||
{0,0,&_8c0_s_p4_0}, | |||||
{0,0,&_8c0_s_p5_0}, | |||||
{0,0,&_8c0_s_p6_0}, | |||||
{&_8c0_s_p7_0,&_8c0_s_p7_1}, | |||||
{&_8c0_s_p8_0,&_8c0_s_p8_1}, | |||||
{&_8c0_s_p9_0,&_8c0_s_p9_1,&_8c0_s_p9_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_8s_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_8c1_s_p1_0}, | |||||
{0}, | |||||
{0,0,&_8c1_s_p3_0}, | |||||
{0,0,&_8c1_s_p4_0}, | |||||
{0,0,&_8c1_s_p5_0}, | |||||
{0,0,&_8c1_s_p6_0}, | |||||
{&_8c1_s_p7_0,&_8c1_s_p7_1}, | |||||
{&_8c1_s_p8_0,&_8c1_s_p8_1}, | |||||
{&_8c1_s_p9_0,&_8c1_s_p9_1,&_8c1_s_p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_8s_0[]={ | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__8c0_s_single,&_huff_book__8c0_s_single, | |||||
&_resbook_8s_0,&_resbook_8s_0}, | |||||
}; | |||||
static const vorbis_residue_template _res_8s_1[]={ | |||||
{2,0,32, &_residue_44_mid, | |||||
&_huff_book__8c1_s_single,&_huff_book__8c1_s_single, | |||||
&_resbook_8s_1,&_resbook_8s_1}, | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_8_stereo[2]={ | |||||
{ _map_nominal, _res_8s_0 }, /* 0 */ | |||||
{ _map_nominal, _res_8s_1 }, /* 1 */ | |||||
}; | |||||
static const static_bookblock _resbook_8u_0={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_8u0__p1_0}, | |||||
{0,0,&_8u0__p2_0}, | |||||
{0,0,&_8u0__p3_0}, | |||||
{0,0,&_8u0__p4_0}, | |||||
{0,0,&_8u0__p5_0}, | |||||
{&_8u0__p6_0,&_8u0__p6_1}, | |||||
{&_8u0__p7_0,&_8u0__p7_1,&_8u0__p7_2} | |||||
} | |||||
}; | |||||
static const static_bookblock _resbook_8u_1={ | |||||
{ | |||||
{0}, | |||||
{0,0,&_8u1__p1_0}, | |||||
{0,0,&_8u1__p2_0}, | |||||
{0,0,&_8u1__p3_0}, | |||||
{0,0,&_8u1__p4_0}, | |||||
{0,0,&_8u1__p5_0}, | |||||
{0,0,&_8u1__p6_0}, | |||||
{&_8u1__p7_0,&_8u1__p7_1}, | |||||
{&_8u1__p8_0,&_8u1__p8_1}, | |||||
{&_8u1__p9_0,&_8u1__p9_1,&_8u1__p9_2} | |||||
} | |||||
}; | |||||
static const vorbis_residue_template _res_8u_0[]={ | |||||
{1,0,32, &_residue_44_low_un, | |||||
&_huff_book__8u0__single,&_huff_book__8u0__single, | |||||
&_resbook_8u_0,&_resbook_8u_0}, | |||||
}; | |||||
static const vorbis_residue_template _res_8u_1[]={ | |||||
{1,0,32, &_residue_44_mid_un, | |||||
&_huff_book__8u1__single,&_huff_book__8u1__single, | |||||
&_resbook_8u_1,&_resbook_8u_1}, | |||||
}; | |||||
static const vorbis_mapping_template _mapres_template_8_uncoupled[2]={ | |||||
{ _map_nominal_u, _res_8u_0 }, /* 0 */ | |||||
{ _map_nominal_u, _res_8u_1 }, /* 1 */ | |||||
}; |
@@ -1,143 +1,142 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 11kHz settings | |||||
last mod: $Id: setup_11.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "psych_11.h" | |||||
static const int blocksize_11[2]={ | |||||
512,512 | |||||
}; | |||||
static const int _floor_mapping_11a[]={ | |||||
6,6 | |||||
}; | |||||
static const int *_floor_mapping_11[]={ | |||||
_floor_mapping_11a | |||||
}; | |||||
static const double rate_mapping_11[3]={ | |||||
8000.,13000.,44000., | |||||
}; | |||||
static const double rate_mapping_11_uncoupled[3]={ | |||||
12000.,20000.,50000., | |||||
}; | |||||
static const double quality_mapping_11[3]={ | |||||
-.1,.0,1. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_11_stereo={ | |||||
2, | |||||
rate_mapping_11, | |||||
quality_mapping_11, | |||||
2, | |||||
9000, | |||||
15000, | |||||
blocksize_11, | |||||
blocksize_11, | |||||
_psy_tone_masteratt_11, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_11, | |||||
NULL, | |||||
_vp_tonemask_adj_11, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_11, | |||||
_psy_noisebias_11, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_11, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_11, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_11, | |||||
_mapres_template_8_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_11_uncoupled={ | |||||
2, | |||||
rate_mapping_11_uncoupled, | |||||
quality_mapping_11, | |||||
-1, | |||||
9000, | |||||
15000, | |||||
blocksize_11, | |||||
blocksize_11, | |||||
_psy_tone_masteratt_11, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_11, | |||||
NULL, | |||||
_vp_tonemask_adj_11, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_11, | |||||
_psy_noisebias_11, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_11, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_11, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_11, | |||||
_mapres_template_8_uncoupled | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 11kHz settings | |||||
********************************************************************/ | |||||
#include "psych_11.h" | |||||
static const int blocksize_11[2]={ | |||||
512,512 | |||||
}; | |||||
static const int _floor_mapping_11a[]={ | |||||
6,6 | |||||
}; | |||||
static const int *_floor_mapping_11[]={ | |||||
_floor_mapping_11a | |||||
}; | |||||
static const double rate_mapping_11[3]={ | |||||
8000.,13000.,44000., | |||||
}; | |||||
static const double rate_mapping_11_uncoupled[3]={ | |||||
12000.,20000.,50000., | |||||
}; | |||||
static const double quality_mapping_11[3]={ | |||||
-.1,.0,1. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_11_stereo={ | |||||
2, | |||||
rate_mapping_11, | |||||
quality_mapping_11, | |||||
2, | |||||
9000, | |||||
15000, | |||||
blocksize_11, | |||||
blocksize_11, | |||||
_psy_tone_masteratt_11, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_11, | |||||
NULL, | |||||
_vp_tonemask_adj_11, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_11, | |||||
_psy_noisebias_11, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_11, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_11, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_11, | |||||
_mapres_template_8_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_11_uncoupled={ | |||||
2, | |||||
rate_mapping_11_uncoupled, | |||||
quality_mapping_11, | |||||
-1, | |||||
9000, | |||||
15000, | |||||
blocksize_11, | |||||
blocksize_11, | |||||
_psy_tone_masteratt_11, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_11, | |||||
NULL, | |||||
_vp_tonemask_adj_11, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_11, | |||||
_psy_noisebias_11, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_11, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_11, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_11, | |||||
_mapres_template_8_uncoupled | |||||
}; |
@@ -1,153 +1,152 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 16kHz settings | |||||
last mod: $Id: setup_16.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "psych_16.h" | |||||
#include "residue_16.h" | |||||
static const int blocksize_16_short[3]={ | |||||
1024,512,512 | |||||
}; | |||||
static const int blocksize_16_long[3]={ | |||||
1024,1024,1024 | |||||
}; | |||||
static const int _floor_mapping_16a[]={ | |||||
9,3,3 | |||||
}; | |||||
static const int _floor_mapping_16b[]={ | |||||
9,9,9 | |||||
}; | |||||
static const int *_floor_mapping_16[]={ | |||||
_floor_mapping_16a, | |||||
_floor_mapping_16b | |||||
}; | |||||
static const double rate_mapping_16[4]={ | |||||
12000.,20000.,44000.,86000. | |||||
}; | |||||
static const double rate_mapping_16_uncoupled[4]={ | |||||
16000.,28000.,64000.,100000. | |||||
}; | |||||
static const double _global_mapping_16[4]={ 1., 2., 3., 4. }; | |||||
static const double quality_mapping_16[4]={ -.1,.05,.5,1. }; | |||||
static const double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.}; | |||||
static const ve_setup_data_template ve_setup_16_stereo={ | |||||
3, | |||||
rate_mapping_16, | |||||
quality_mapping_16, | |||||
2, | |||||
15000, | |||||
19000, | |||||
blocksize_16_short, | |||||
blocksize_16_long, | |||||
_psy_tone_masteratt_16, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_psy_noiseguards_16, | |||||
_psy_noisebias_16_impulse, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_16_mapping, | |||||
_psy_compand_16_mapping, | |||||
{_noise_start_16,_noise_start_16}, | |||||
{ _noise_part_16, _noise_part_16}, | |||||
_noise_thresh_16, | |||||
_psy_ath_floater_16, | |||||
_psy_ath_abs_16, | |||||
_psy_lowpass_16, | |||||
_psy_global_44, | |||||
_global_mapping_16, | |||||
_psy_stereo_modes_16, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_16, | |||||
_mapres_template_16_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_16_uncoupled={ | |||||
3, | |||||
rate_mapping_16_uncoupled, | |||||
quality_mapping_16, | |||||
-1, | |||||
15000, | |||||
19000, | |||||
blocksize_16_short, | |||||
blocksize_16_long, | |||||
_psy_tone_masteratt_16, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_psy_noiseguards_16, | |||||
_psy_noisebias_16_impulse, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_16_mapping, | |||||
_psy_compand_16_mapping, | |||||
{_noise_start_16,_noise_start_16}, | |||||
{ _noise_part_16, _noise_part_16}, | |||||
_noise_thresh_16, | |||||
_psy_ath_floater_16, | |||||
_psy_ath_abs_16, | |||||
_psy_lowpass_16, | |||||
_psy_global_44, | |||||
_global_mapping_16, | |||||
_psy_stereo_modes_16, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_16, | |||||
_mapres_template_16_uncoupled | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 16kHz settings | |||||
********************************************************************/ | |||||
#include "psych_16.h" | |||||
#include "residue_16.h" | |||||
static const int blocksize_16_short[3]={ | |||||
1024,512,512 | |||||
}; | |||||
static const int blocksize_16_long[3]={ | |||||
1024,1024,1024 | |||||
}; | |||||
static const int _floor_mapping_16a[]={ | |||||
9,3,3 | |||||
}; | |||||
static const int _floor_mapping_16b[]={ | |||||
9,9,9 | |||||
}; | |||||
static const int *_floor_mapping_16[]={ | |||||
_floor_mapping_16a, | |||||
_floor_mapping_16b | |||||
}; | |||||
static const double rate_mapping_16[4]={ | |||||
12000.,20000.,44000.,86000. | |||||
}; | |||||
static const double rate_mapping_16_uncoupled[4]={ | |||||
16000.,28000.,64000.,100000. | |||||
}; | |||||
static const double _global_mapping_16[4]={ 1., 2., 3., 4. }; | |||||
static const double quality_mapping_16[4]={ -.1,.05,.5,1. }; | |||||
static const double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.}; | |||||
static const ve_setup_data_template ve_setup_16_stereo={ | |||||
3, | |||||
rate_mapping_16, | |||||
quality_mapping_16, | |||||
2, | |||||
15000, | |||||
19000, | |||||
blocksize_16_short, | |||||
blocksize_16_long, | |||||
_psy_tone_masteratt_16, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_psy_noiseguards_16, | |||||
_psy_noisebias_16_impulse, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_16_mapping, | |||||
_psy_compand_16_mapping, | |||||
{_noise_start_16,_noise_start_16}, | |||||
{ _noise_part_16, _noise_part_16}, | |||||
_noise_thresh_16, | |||||
_psy_ath_floater_16, | |||||
_psy_ath_abs_16, | |||||
_psy_lowpass_16, | |||||
_psy_global_44, | |||||
_global_mapping_16, | |||||
_psy_stereo_modes_16, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_16, | |||||
_mapres_template_16_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_16_uncoupled={ | |||||
3, | |||||
rate_mapping_16_uncoupled, | |||||
quality_mapping_16, | |||||
-1, | |||||
15000, | |||||
19000, | |||||
blocksize_16_short, | |||||
blocksize_16_long, | |||||
_psy_tone_masteratt_16, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_psy_noiseguards_16, | |||||
_psy_noisebias_16_impulse, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_16_mapping, | |||||
_psy_compand_16_mapping, | |||||
{_noise_start_16,_noise_start_16}, | |||||
{ _noise_part_16, _noise_part_16}, | |||||
_noise_thresh_16, | |||||
_psy_ath_floater_16, | |||||
_psy_ath_abs_16, | |||||
_psy_lowpass_16, | |||||
_psy_global_44, | |||||
_global_mapping_16, | |||||
_psy_stereo_modes_16, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_16, | |||||
_mapres_template_16_uncoupled | |||||
}; |
@@ -1,128 +1,127 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 22kHz settings | |||||
last mod: $Id: setup_22.h 17026 2010-03-25 05:00:27Z xiphmont $ | |||||
********************************************************************/ | |||||
static const double rate_mapping_22[4]={ | |||||
15000.,20000.,44000.,86000. | |||||
}; | |||||
static const double rate_mapping_22_uncoupled[4]={ | |||||
16000.,28000.,50000.,90000. | |||||
}; | |||||
static const double _psy_lowpass_22[4]={9.5,11.,30.,99.}; | |||||
static const ve_setup_data_template ve_setup_22_stereo={ | |||||
3, | |||||
rate_mapping_22, | |||||
quality_mapping_16, | |||||
2, | |||||
19000, | |||||
26000, | |||||
blocksize_16_short, | |||||
blocksize_16_long, | |||||
_psy_tone_masteratt_16, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_psy_noiseguards_16, | |||||
_psy_noisebias_16_impulse, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_16_mapping, | |||||
_psy_compand_16_mapping, | |||||
{_noise_start_16,_noise_start_16}, | |||||
{ _noise_part_16, _noise_part_16}, | |||||
_noise_thresh_16, | |||||
_psy_ath_floater_16, | |||||
_psy_ath_abs_16, | |||||
_psy_lowpass_22, | |||||
_psy_global_44, | |||||
_global_mapping_16, | |||||
_psy_stereo_modes_16, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_16, | |||||
_mapres_template_16_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_22_uncoupled={ | |||||
3, | |||||
rate_mapping_22_uncoupled, | |||||
quality_mapping_16, | |||||
-1, | |||||
19000, | |||||
26000, | |||||
blocksize_16_short, | |||||
blocksize_16_long, | |||||
_psy_tone_masteratt_16, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_psy_noiseguards_16, | |||||
_psy_noisebias_16_impulse, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_16_mapping, | |||||
_psy_compand_16_mapping, | |||||
{_noise_start_16,_noise_start_16}, | |||||
{ _noise_part_16, _noise_part_16}, | |||||
_noise_thresh_16, | |||||
_psy_ath_floater_16, | |||||
_psy_ath_abs_16, | |||||
_psy_lowpass_22, | |||||
_psy_global_44, | |||||
_global_mapping_16, | |||||
_psy_stereo_modes_16, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_16, | |||||
_mapres_template_16_uncoupled | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 22kHz settings | |||||
********************************************************************/ | |||||
static const double rate_mapping_22[4]={ | |||||
15000.,20000.,44000.,86000. | |||||
}; | |||||
static const double rate_mapping_22_uncoupled[4]={ | |||||
16000.,28000.,50000.,90000. | |||||
}; | |||||
static const double _psy_lowpass_22[4]={9.5,11.,30.,99.}; | |||||
static const ve_setup_data_template ve_setup_22_stereo={ | |||||
3, | |||||
rate_mapping_22, | |||||
quality_mapping_16, | |||||
2, | |||||
19000, | |||||
26000, | |||||
blocksize_16_short, | |||||
blocksize_16_long, | |||||
_psy_tone_masteratt_16, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_psy_noiseguards_16, | |||||
_psy_noisebias_16_impulse, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_16_mapping, | |||||
_psy_compand_16_mapping, | |||||
{_noise_start_16,_noise_start_16}, | |||||
{ _noise_part_16, _noise_part_16}, | |||||
_noise_thresh_16, | |||||
_psy_ath_floater_16, | |||||
_psy_ath_abs_16, | |||||
_psy_lowpass_22, | |||||
_psy_global_44, | |||||
_global_mapping_16, | |||||
_psy_stereo_modes_16, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_16, | |||||
_mapres_template_16_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_22_uncoupled={ | |||||
3, | |||||
rate_mapping_22_uncoupled, | |||||
quality_mapping_16, | |||||
-1, | |||||
19000, | |||||
26000, | |||||
blocksize_16_short, | |||||
blocksize_16_long, | |||||
_psy_tone_masteratt_16, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_vp_tonemask_adj_16, | |||||
_psy_noiseguards_16, | |||||
_psy_noisebias_16_impulse, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16_short, | |||||
_psy_noisebias_16, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_16_mapping, | |||||
_psy_compand_16_mapping, | |||||
{_noise_start_16,_noise_start_16}, | |||||
{ _noise_part_16, _noise_part_16}, | |||||
_noise_thresh_16, | |||||
_psy_ath_floater_16, | |||||
_psy_ath_abs_16, | |||||
_psy_lowpass_22, | |||||
_psy_global_44, | |||||
_global_mapping_16, | |||||
_psy_stereo_modes_16, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_16, | |||||
_mapres_template_16_uncoupled | |||||
}; |
@@ -1,132 +1,131 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel settings for 32kHz | |||||
last mod: $Id: setup_32.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||||
********************************************************************/ | |||||
static const double rate_mapping_32[12]={ | |||||
18000.,28000.,35000.,45000.,56000.,60000., | |||||
75000.,90000.,100000.,115000.,150000.,190000., | |||||
}; | |||||
static const double rate_mapping_32_un[12]={ | |||||
30000.,42000.,52000.,64000.,72000.,78000., | |||||
86000.,92000.,110000.,120000.,140000.,190000., | |||||
}; | |||||
static const double _psy_lowpass_32[12]={ | |||||
12.3,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_32_stereo={ | |||||
11, | |||||
rate_mapping_32, | |||||
quality_mapping_44, | |||||
2, | |||||
26000, | |||||
40000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_32, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_32_uncoupled={ | |||||
11, | |||||
rate_mapping_32_un, | |||||
quality_mapping_44, | |||||
-1, | |||||
26000, | |||||
40000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_32, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
NULL, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_uncoupled | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel settings for 32kHz | |||||
********************************************************************/ | |||||
static const double rate_mapping_32[12]={ | |||||
18000.,28000.,35000.,45000.,56000.,60000., | |||||
75000.,90000.,100000.,115000.,150000.,190000., | |||||
}; | |||||
static const double rate_mapping_32_un[12]={ | |||||
30000.,42000.,52000.,64000.,72000.,78000., | |||||
86000.,92000.,110000.,120000.,140000.,190000., | |||||
}; | |||||
static const double _psy_lowpass_32[12]={ | |||||
12.3,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_32_stereo={ | |||||
11, | |||||
rate_mapping_32, | |||||
quality_mapping_44, | |||||
2, | |||||
26000, | |||||
40000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_32, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_32_uncoupled={ | |||||
11, | |||||
rate_mapping_32_un, | |||||
quality_mapping_44, | |||||
-1, | |||||
26000, | |||||
40000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_32, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
NULL, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_uncoupled | |||||
}; |
@@ -1,117 +1,116 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel settings for 44.1/48kHz | |||||
last mod: $Id: setup_44.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "floor_all.h" | |||||
#include "residue_44.h" | |||||
#include "psych_44.h" | |||||
static const double rate_mapping_44_stereo[12]={ | |||||
22500.,32000.,40000.,48000.,56000.,64000., | |||||
80000.,96000.,112000.,128000.,160000.,250001. | |||||
}; | |||||
static const double quality_mapping_44[12]={ | |||||
-.1,.0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0 | |||||
}; | |||||
static const int blocksize_short_44[11]={ | |||||
512,256,256,256,256,256,256,256,256,256,256 | |||||
}; | |||||
static const int blocksize_long_44[11]={ | |||||
4096,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048 | |||||
}; | |||||
static const double _psy_compand_short_mapping[12]={ | |||||
0.5, 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2. | |||||
}; | |||||
static const double _psy_compand_long_mapping[12]={ | |||||
3.5, 4., 4., 4.3, 4.6, 5., 5., 5., 5., 5., 5., 5. | |||||
}; | |||||
static const double _global_mapping_44[12]={ | |||||
/* 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.5, 4., 4. */ | |||||
0., 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.7, 4., 4. | |||||
}; | |||||
static const int _floor_mapping_44a[11]={ | |||||
1,0,0,2,2,4,5,5,5,5,5 | |||||
}; | |||||
static const int _floor_mapping_44b[11]={ | |||||
8,7,7,7,7,7,7,7,7,7,7 | |||||
}; | |||||
static const int _floor_mapping_44c[11]={ | |||||
10,10,10,10,10,10,10,10,10,10,10 | |||||
}; | |||||
static const int *_floor_mapping_44[]={ | |||||
_floor_mapping_44a, | |||||
_floor_mapping_44b, | |||||
_floor_mapping_44c, | |||||
}; | |||||
static const ve_setup_data_template ve_setup_44_stereo={ | |||||
11, | |||||
rate_mapping_44_stereo, | |||||
quality_mapping_44, | |||||
2, | |||||
40000, | |||||
50000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_stereo | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel settings for 44.1/48kHz | |||||
********************************************************************/ | |||||
#include "floor_all.h" | |||||
#include "residue_44.h" | |||||
#include "psych_44.h" | |||||
static const double rate_mapping_44_stereo[12]={ | |||||
22500.,32000.,40000.,48000.,56000.,64000., | |||||
80000.,96000.,112000.,128000.,160000.,250001. | |||||
}; | |||||
static const double quality_mapping_44[12]={ | |||||
-.1,.0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0 | |||||
}; | |||||
static const int blocksize_short_44[11]={ | |||||
512,256,256,256,256,256,256,256,256,256,256 | |||||
}; | |||||
static const int blocksize_long_44[11]={ | |||||
4096,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048 | |||||
}; | |||||
static const double _psy_compand_short_mapping[12]={ | |||||
0.5, 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2. | |||||
}; | |||||
static const double _psy_compand_long_mapping[12]={ | |||||
3.5, 4., 4., 4.3, 4.6, 5., 5., 5., 5., 5., 5., 5. | |||||
}; | |||||
static const double _global_mapping_44[12]={ | |||||
/* 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.5, 4., 4. */ | |||||
0., 1., 1., 1.5, 2., 2., 2.5, 2.7, 3.0, 3.7, 4., 4. | |||||
}; | |||||
static const int _floor_mapping_44a[11]={ | |||||
1,0,0,2,2,4,5,5,5,5,5 | |||||
}; | |||||
static const int _floor_mapping_44b[11]={ | |||||
8,7,7,7,7,7,7,7,7,7,7 | |||||
}; | |||||
static const int _floor_mapping_44c[11]={ | |||||
10,10,10,10,10,10,10,10,10,10,10 | |||||
}; | |||||
static const int *_floor_mapping_44[]={ | |||||
_floor_mapping_44a, | |||||
_floor_mapping_44b, | |||||
_floor_mapping_44c, | |||||
}; | |||||
static const ve_setup_data_template ve_setup_44_stereo={ | |||||
11, | |||||
rate_mapping_44_stereo, | |||||
quality_mapping_44, | |||||
2, | |||||
40000, | |||||
50000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_stereo | |||||
}; |
@@ -1,74 +1,73 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel settings for 44.1/48kHz 5.1 surround modes | |||||
last mod: $Id$ | |||||
********************************************************************/ | |||||
#include "residue_44p51.h" | |||||
static const double rate_mapping_44p51[12]={ | |||||
14000.,20000.,28000.,38000.,46000.,54000., | |||||
75000.,96000.,120000.,140000.,180000.,240001. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_44_51={ | |||||
11, | |||||
rate_mapping_44p51, | |||||
quality_mapping_44, | |||||
6, | |||||
40000, | |||||
70000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
3, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_51 | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel settings for 44.1/48kHz 5.1 surround modes | |||||
********************************************************************/ | |||||
#include "residue_44p51.h" | |||||
static const double rate_mapping_44p51[12]={ | |||||
14000.,20000.,28000.,38000.,46000.,54000., | |||||
75000.,96000.,120000.,140000.,180000.,240001. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_44_51={ | |||||
11, | |||||
rate_mapping_44p51, | |||||
quality_mapping_44, | |||||
6, | |||||
40000, | |||||
70000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
3, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_51 | |||||
}; |
@@ -1,74 +1,73 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel settings for 44.1/48kHz uncoupled modes | |||||
last mod: $Id: setup_44u.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "residue_44u.h" | |||||
static const double rate_mapping_44_un[12]={ | |||||
32000.,48000.,60000.,70000.,80000.,86000., | |||||
96000.,110000.,120000.,140000.,160000.,240001. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_44_uncoupled={ | |||||
11, | |||||
rate_mapping_44_un, | |||||
quality_mapping_44, | |||||
-1, | |||||
40000, | |||||
50000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_uncoupled | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: toplevel settings for 44.1/48kHz uncoupled modes | |||||
********************************************************************/ | |||||
#include "residue_44u.h" | |||||
static const double rate_mapping_44_un[12]={ | |||||
32000.,48000.,60000.,70000.,80000.,86000., | |||||
96000.,110000.,120000.,140000.,160000.,240001. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_44_uncoupled={ | |||||
11, | |||||
rate_mapping_44_un, | |||||
quality_mapping_44, | |||||
-1, | |||||
40000, | |||||
50000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_uncoupled | |||||
}; |
@@ -1,149 +1,148 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 8kHz settings | |||||
last mod: $Id: setup_8.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "psych_8.h" | |||||
#include "residue_8.h" | |||||
static const int blocksize_8[2]={ | |||||
512,512 | |||||
}; | |||||
static const int _floor_mapping_8a[]={ | |||||
6,6 | |||||
}; | |||||
static const int *_floor_mapping_8[]={ | |||||
_floor_mapping_8a | |||||
}; | |||||
static const double rate_mapping_8[3]={ | |||||
6000.,9000.,32000., | |||||
}; | |||||
static const double rate_mapping_8_uncoupled[3]={ | |||||
8000.,14000.,42000., | |||||
}; | |||||
static const double quality_mapping_8[3]={ | |||||
-.1,.0,1. | |||||
}; | |||||
static const double _psy_compand_8_mapping[3]={ 0., 1., 1.}; | |||||
static const double _global_mapping_8[3]={ 1., 2., 3. }; | |||||
static const ve_setup_data_template ve_setup_8_stereo={ | |||||
2, | |||||
rate_mapping_8, | |||||
quality_mapping_8, | |||||
2, | |||||
8000, | |||||
9000, | |||||
blocksize_8, | |||||
blocksize_8, | |||||
_psy_tone_masteratt_8, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_8, | |||||
NULL, | |||||
_vp_tonemask_adj_8, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_8, | |||||
_psy_noisebias_8, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_5only, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_8, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_8, | |||||
_mapres_template_8_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_8_uncoupled={ | |||||
2, | |||||
rate_mapping_8_uncoupled, | |||||
quality_mapping_8, | |||||
-1, | |||||
8000, | |||||
9000, | |||||
blocksize_8, | |||||
blocksize_8, | |||||
_psy_tone_masteratt_8, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_8, | |||||
NULL, | |||||
_vp_tonemask_adj_8, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_8, | |||||
_psy_noisebias_8, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_5only, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_8, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_8, | |||||
_mapres_template_8_uncoupled | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: 8kHz settings | |||||
********************************************************************/ | |||||
#include "psych_8.h" | |||||
#include "residue_8.h" | |||||
static const int blocksize_8[2]={ | |||||
512,512 | |||||
}; | |||||
static const int _floor_mapping_8a[]={ | |||||
6,6 | |||||
}; | |||||
static const int *_floor_mapping_8[]={ | |||||
_floor_mapping_8a | |||||
}; | |||||
static const double rate_mapping_8[3]={ | |||||
6000.,9000.,32000., | |||||
}; | |||||
static const double rate_mapping_8_uncoupled[3]={ | |||||
8000.,14000.,42000., | |||||
}; | |||||
static const double quality_mapping_8[3]={ | |||||
-.1,.0,1. | |||||
}; | |||||
static const double _psy_compand_8_mapping[3]={ 0., 1., 1.}; | |||||
static const double _global_mapping_8[3]={ 1., 2., 3. }; | |||||
static const ve_setup_data_template ve_setup_8_stereo={ | |||||
2, | |||||
rate_mapping_8, | |||||
quality_mapping_8, | |||||
2, | |||||
8000, | |||||
9000, | |||||
blocksize_8, | |||||
blocksize_8, | |||||
_psy_tone_masteratt_8, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_8, | |||||
NULL, | |||||
_vp_tonemask_adj_8, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_8, | |||||
_psy_noisebias_8, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_5only, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_8, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_8, | |||||
_mapres_template_8_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_8_uncoupled={ | |||||
2, | |||||
rate_mapping_8_uncoupled, | |||||
quality_mapping_8, | |||||
-1, | |||||
8000, | |||||
9000, | |||||
blocksize_8, | |||||
blocksize_8, | |||||
_psy_tone_masteratt_8, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_8, | |||||
NULL, | |||||
_vp_tonemask_adj_8, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_8, | |||||
_psy_noisebias_8, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_5only, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_8, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_8, | |||||
_mapres_template_8_uncoupled | |||||
}; |
@@ -1,225 +1,224 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: catch-all toplevel settings for q modes only | |||||
last mod: $Id: setup_X.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||||
********************************************************************/ | |||||
static const double rate_mapping_X[12]={ | |||||
-1.,-1.,-1.,-1.,-1.,-1., | |||||
-1.,-1.,-1.,-1.,-1.,-1. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_X_stereo={ | |||||
11, | |||||
rate_mapping_X, | |||||
quality_mapping_44, | |||||
2, | |||||
50000, | |||||
200000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_X_uncoupled={ | |||||
11, | |||||
rate_mapping_X, | |||||
quality_mapping_44, | |||||
-1, | |||||
50000, | |||||
200000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
NULL, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_uncoupled | |||||
}; | |||||
static const ve_setup_data_template ve_setup_XX_stereo={ | |||||
2, | |||||
rate_mapping_X, | |||||
quality_mapping_8, | |||||
2, | |||||
0, | |||||
8000, | |||||
blocksize_8, | |||||
blocksize_8, | |||||
_psy_tone_masteratt_8, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_8, | |||||
NULL, | |||||
_vp_tonemask_adj_8, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_8, | |||||
_psy_noisebias_8, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_5only, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_8, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_8, | |||||
_mapres_template_8_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_XX_uncoupled={ | |||||
2, | |||||
rate_mapping_X, | |||||
quality_mapping_8, | |||||
-1, | |||||
0, | |||||
8000, | |||||
blocksize_8, | |||||
blocksize_8, | |||||
_psy_tone_masteratt_8, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_8, | |||||
NULL, | |||||
_vp_tonemask_adj_8, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_8, | |||||
_psy_noisebias_8, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_5only, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_8, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_8, | |||||
_mapres_template_8_uncoupled | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: catch-all toplevel settings for q modes only | |||||
********************************************************************/ | |||||
static const double rate_mapping_X[12]={ | |||||
-1.,-1.,-1.,-1.,-1.,-1., | |||||
-1.,-1.,-1.,-1.,-1.,-1. | |||||
}; | |||||
static const ve_setup_data_template ve_setup_X_stereo={ | |||||
11, | |||||
rate_mapping_X, | |||||
quality_mapping_44, | |||||
2, | |||||
50000, | |||||
200000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
_psy_stereo_modes_44, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_X_uncoupled={ | |||||
11, | |||||
rate_mapping_X, | |||||
quality_mapping_44, | |||||
-1, | |||||
50000, | |||||
200000, | |||||
blocksize_short_44, | |||||
blocksize_long_44, | |||||
_psy_tone_masteratt_44, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_otherblock, | |||||
_vp_tonemask_adj_longblock, | |||||
_vp_tonemask_adj_otherblock, | |||||
_psy_noiseguards_44, | |||||
_psy_noisebias_impulse, | |||||
_psy_noisebias_padding, | |||||
_psy_noisebias_trans, | |||||
_psy_noisebias_long, | |||||
_psy_noise_suppress, | |||||
_psy_compand_44, | |||||
_psy_compand_short_mapping, | |||||
_psy_compand_long_mapping, | |||||
{_noise_start_short_44,_noise_start_long_44}, | |||||
{_noise_part_short_44,_noise_part_long_44}, | |||||
_noise_thresh_44, | |||||
_psy_ath_floater, | |||||
_psy_ath_abs, | |||||
_psy_lowpass_44, | |||||
_psy_global_44, | |||||
_global_mapping_44, | |||||
NULL, | |||||
_floor_books, | |||||
_floor, | |||||
2, | |||||
_floor_mapping_44, | |||||
_mapres_template_44_uncoupled | |||||
}; | |||||
static const ve_setup_data_template ve_setup_XX_stereo={ | |||||
2, | |||||
rate_mapping_X, | |||||
quality_mapping_8, | |||||
2, | |||||
0, | |||||
8000, | |||||
blocksize_8, | |||||
blocksize_8, | |||||
_psy_tone_masteratt_8, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_8, | |||||
NULL, | |||||
_vp_tonemask_adj_8, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_8, | |||||
_psy_noisebias_8, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_5only, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_8, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_8, | |||||
_mapres_template_8_stereo | |||||
}; | |||||
static const ve_setup_data_template ve_setup_XX_uncoupled={ | |||||
2, | |||||
rate_mapping_X, | |||||
quality_mapping_8, | |||||
-1, | |||||
0, | |||||
8000, | |||||
blocksize_8, | |||||
blocksize_8, | |||||
_psy_tone_masteratt_8, | |||||
_psy_tone_0dB, | |||||
_psy_tone_suppress, | |||||
_vp_tonemask_adj_8, | |||||
NULL, | |||||
_vp_tonemask_adj_8, | |||||
_psy_noiseguards_8, | |||||
_psy_noisebias_8, | |||||
_psy_noisebias_8, | |||||
NULL, | |||||
NULL, | |||||
_psy_noise_suppress, | |||||
_psy_compand_8, | |||||
_psy_compand_8_mapping, | |||||
NULL, | |||||
{_noise_start_8,_noise_start_8}, | |||||
{_noise_part_8,_noise_part_8}, | |||||
_noise_thresh_5only, | |||||
_psy_ath_floater_8, | |||||
_psy_ath_abs_8, | |||||
_psy_lowpass_8, | |||||
_psy_global_44, | |||||
_global_mapping_8, | |||||
_psy_stereo_modes_8, | |||||
_floor_books, | |||||
_floor, | |||||
1, | |||||
_floor_mapping_8, | |||||
_mapres_template_8_uncoupled | |||||
}; |
@@ -1,186 +1,189 @@ | |||||
#ifndef _OS_H | |||||
#define _OS_H | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: #ifdef jail to whip a few platforms into the UNIX ideal. | |||||
last mod: $Id: os.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifdef HAVE_CONFIG_H | |||||
#include "config.h" | |||||
#endif | |||||
#include <math.h> | |||||
#include "../../os_types.h" | |||||
#include "misc.h" | |||||
#ifndef _V_IFDEFJAIL_H_ | |||||
# define _V_IFDEFJAIL_H_ | |||||
# ifdef __GNUC__ | |||||
# define STIN static __inline__ | |||||
# elif _WIN32 | |||||
# define STIN static __inline | |||||
# else | |||||
# define STIN static | |||||
# endif | |||||
#ifdef DJGPP | |||||
# define rint(x) (floor((x)+0.5f)) | |||||
#endif | |||||
#ifndef M_PI | |||||
# define M_PI (3.1415926536f) | |||||
#endif | |||||
#if defined(_WIN32) && !defined(__SYMBIAN32__) | |||||
# include <malloc.h> | |||||
# define rint(x) (floor((x)+0.5f)) | |||||
# define NO_FLOAT_MATH_LIB | |||||
# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b)) | |||||
#endif | |||||
#if defined(__SYMBIAN32__) && defined(__WINS__) | |||||
void *_alloca(size_t size); | |||||
# define alloca _alloca | |||||
#endif | |||||
#ifndef FAST_HYPOT | |||||
# define FAST_HYPOT hypot | |||||
#endif | |||||
#endif | |||||
#ifdef HAVE_ALLOCA_H | |||||
# include <alloca.h> | |||||
#endif | |||||
#ifdef USE_MEMORY_H | |||||
# include <memory.h> | |||||
#endif | |||||
#ifndef min | |||||
# define min(x,y) ((x)>(y)?(y):(x)) | |||||
#endif | |||||
#ifndef max | |||||
# define max(x,y) ((x)<(y)?(y):(x)) | |||||
#endif | |||||
/* Special i386 GCC implementation */ | |||||
#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__) | |||||
# define VORBIS_FPU_CONTROL | |||||
/* both GCC and MSVC are kinda stupid about rounding/casting to int. | |||||
Because of encapsulation constraints (GCC can't see inside the asm | |||||
block and so we end up doing stupid things like a store/load that | |||||
is collectively a noop), we do it this way */ | |||||
/* we must set up the fpu before this works!! */ | |||||
typedef ogg_int16_t vorbis_fpu_control; | |||||
static inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ | |||||
ogg_int16_t ret; | |||||
ogg_int16_t temp = 0; | |||||
__asm__ __volatile__("fnstcw %0\n\t" | |||||
"movw %0,%%dx\n\t" | |||||
"andw $62463,%%dx\n\t" | |||||
"movw %%dx,%1\n\t" | |||||
"fldcw %1\n\t":"=m"(ret):"m"(temp): "dx"); | |||||
*fpu=ret; | |||||
} | |||||
static inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ | |||||
__asm__ __volatile__("fldcw %0":: "m"(fpu)); | |||||
} | |||||
/* assumes the FPU is in round mode! */ | |||||
static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise, | |||||
we get extra fst/fld to | |||||
truncate precision */ | |||||
int i; | |||||
__asm__("fistl %0": "=m"(i) : "t"(f)); | |||||
return(i); | |||||
} | |||||
#endif /* Special i386 GCC implementation */ | |||||
/* MSVC inline assembly. 32 bit only; inline ASM isn't implemented in the | |||||
* 64 bit compiler */ | |||||
#if defined(_MSC_VER) && !defined(_WIN64) && !defined(_WIN32_WCE) | |||||
# define VORBIS_FPU_CONTROL | |||||
typedef ogg_int16_t vorbis_fpu_control; | |||||
static __inline int vorbis_ftoi(double f){ | |||||
int i; | |||||
__asm{ | |||||
fld f | |||||
fistp i | |||||
} | |||||
return i; | |||||
} | |||||
static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ | |||||
} | |||||
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ | |||||
} | |||||
#endif /* Special MSVC 32 bit implementation */ | |||||
/* Optimized code path for x86_64 builds. Uses SSE2 intrinsics. This can be | |||||
done safely because all x86_64 CPUs supports SSE2. */ | |||||
#if ! JUCE_PROJUCER_LIVE_BUILD && ((JUCE_MSVC && JUCE_64BIT) || (JUCE_GCC && defined (__x86_64__))) | |||||
# define VORBIS_FPU_CONTROL | |||||
typedef ogg_int16_t vorbis_fpu_control; | |||||
#include <emmintrin.h> | |||||
static __inline int vorbis_ftoi(double f){ | |||||
return _mm_cvtsd_si32(_mm_load_sd(&f)); | |||||
} | |||||
static __inline void vorbis_fpu_setround(vorbis_fpu_control*){ | |||||
} | |||||
static __inline void vorbis_fpu_restore(vorbis_fpu_control){ | |||||
} | |||||
#endif /* Special MSVC x64 implementation */ | |||||
/* If no special implementation was found for the current compiler / platform, | |||||
use the default implementation here: */ | |||||
#ifndef VORBIS_FPU_CONTROL | |||||
typedef int vorbis_fpu_control; | |||||
static int vorbis_ftoi(double f){ | |||||
/* Note: MSVC and GCC (at least on some systems) round towards zero, thus, | |||||
the floor() call is required to ensure correct roudning of | |||||
negative numbers */ | |||||
return (int)floor(f+.5); | |||||
} | |||||
/* We don't have special code for this compiler/arch, so do it the slow way */ | |||||
# define vorbis_fpu_setround(vorbis_fpu_control) {} | |||||
# define vorbis_fpu_restore(vorbis_fpu_control) {} | |||||
#endif /* default implementation */ | |||||
#endif /* _OS_H */ | |||||
#ifndef _OS_H | |||||
#define _OS_H | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: #ifdef jail to whip a few platforms into the UNIX ideal. | |||||
********************************************************************/ | |||||
#ifdef HAVE_CONFIG_H | |||||
#include "config.h" | |||||
#endif | |||||
#include <math.h> | |||||
#include "../../os_types.h" | |||||
#include "misc.h" | |||||
#ifndef _V_IFDEFJAIL_H_ | |||||
# define _V_IFDEFJAIL_H_ | |||||
# ifdef __GNUC__ | |||||
# define STIN static __inline__ | |||||
# elif _WIN32 | |||||
# define STIN static __inline | |||||
# else | |||||
# define STIN static | |||||
# endif | |||||
#ifdef DJGPP | |||||
# define rint(x) (floor((x)+0.5f)) | |||||
#endif | |||||
#ifndef M_PI | |||||
# define M_PI (3.1415926536f) | |||||
#endif | |||||
#if defined(_WIN32) && !defined(__SYMBIAN32__) | |||||
# include <malloc.h> | |||||
# define rint(x) (floor((x)+0.5f)) | |||||
# define NO_FLOAT_MATH_LIB | |||||
# define FAST_HYPOT(a, b) sqrt((a)*(a) + (b)*(b)) | |||||
#endif | |||||
#if defined(__SYMBIAN32__) && defined(__WINS__) | |||||
void *_alloca(size_t size); | |||||
# define alloca _alloca | |||||
#endif | |||||
#ifndef FAST_HYPOT | |||||
# define FAST_HYPOT hypot | |||||
#endif | |||||
#endif /* _V_IFDEFJAIL_H_ */ | |||||
#ifdef HAVE_ALLOCA_H | |||||
# include <alloca.h> | |||||
#endif | |||||
#ifdef USE_MEMORY_H | |||||
# include <memory.h> | |||||
#endif | |||||
#ifndef min | |||||
# define min(x,y) ((x)>(y)?(y):(x)) | |||||
#endif | |||||
#ifndef max | |||||
# define max(x,y) ((x)<(y)?(y):(x)) | |||||
#endif | |||||
/* Special i386 GCC implementation */ | |||||
#if defined(__i386__) && defined(__GNUC__) && !defined(__BEOS__) | |||||
# define VORBIS_FPU_CONTROL | |||||
/* both GCC and MSVC are kinda stupid about rounding/casting to int. | |||||
Because of encapsulation constraints (GCC can't see inside the asm | |||||
block and so we end up doing stupid things like a store/load that | |||||
is collectively a noop), we do it this way */ | |||||
/* we must set up the fpu before this works!! */ | |||||
typedef ogg_int16_t vorbis_fpu_control; | |||||
static inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ | |||||
ogg_int16_t ret; | |||||
ogg_int16_t temp = 0; | |||||
__asm__ __volatile__("fnstcw %0\n\t" | |||||
"movw %0,%%dx\n\t" | |||||
"andw $62463,%%dx\n\t" | |||||
"movw %%dx,%1\n\t" | |||||
"fldcw %1\n\t":"=m"(ret):"m"(temp): "dx"); | |||||
*fpu=ret; | |||||
} | |||||
static inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ | |||||
__asm__ __volatile__("fldcw %0":: "m"(fpu)); | |||||
} | |||||
/* assumes the FPU is in round mode! */ | |||||
static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise, | |||||
we get extra fst/fld to | |||||
truncate precision */ | |||||
int i; | |||||
__asm__("fistl %0": "=m"(i) : "t"(f)); | |||||
return(i); | |||||
} | |||||
#endif /* Special i386 GCC implementation */ | |||||
/* MSVC inline assembly. 32 bit only; inline ASM isn't implemented in the | |||||
* 64 bit compiler and doesn't work on arm. */ | |||||
#if defined(_MSC_VER) && defined(_M_IX86) && !defined(_WIN32_WCE) | |||||
# define VORBIS_FPU_CONTROL | |||||
typedef ogg_int16_t vorbis_fpu_control; | |||||
static __inline int vorbis_ftoi(double f){ | |||||
int i; | |||||
__asm{ | |||||
fld f | |||||
fistp i | |||||
} | |||||
return i; | |||||
} | |||||
static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ | |||||
(void)fpu; | |||||
} | |||||
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ | |||||
(void)fpu; | |||||
} | |||||
#endif /* Special MSVC 32 bit implementation */ | |||||
/* Optimized code path for x86_64 builds. Uses SSE2 intrinsics. This can be | |||||
done safely because all x86_64 CPUs supports SSE2. */ | |||||
#if ! JUCE_PROJUCER_LIVE_BUILD && ((JUCE_MSVC && JUCE_64BIT) || (JUCE_GCC && defined (__x86_64__))) | |||||
# define VORBIS_FPU_CONTROL | |||||
typedef ogg_int16_t vorbis_fpu_control; | |||||
#include <emmintrin.h> | |||||
static __inline int vorbis_ftoi(double f){ | |||||
return _mm_cvtsd_si32(_mm_load_sd(&f)); | |||||
} | |||||
static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ | |||||
(void)fpu; | |||||
} | |||||
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ | |||||
(void)fpu; | |||||
} | |||||
#endif /* Special MSVC x64 implementation */ | |||||
/* If no special implementation was found for the current compiler / platform, | |||||
use the default implementation here: */ | |||||
#ifndef VORBIS_FPU_CONTROL | |||||
typedef int vorbis_fpu_control; | |||||
static int vorbis_ftoi(double f){ | |||||
/* Note: MSVC and GCC (at least on some systems) round towards zero, thus, | |||||
the floor() call is required to ensure correct roudning of | |||||
negative numbers */ | |||||
return (int)floor(f+.5); | |||||
} | |||||
/* We don't have special code for this compiler/arch, so do it the slow way */ | |||||
# define vorbis_fpu_setround(vorbis_fpu_control) {} | |||||
# define vorbis_fpu_restore(vorbis_fpu_control) {} | |||||
#endif /* default implementation */ | |||||
#endif /* _OS_H */ |
@@ -1,154 +1,153 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: random psychoacoustics (not including preecho) | |||||
last mod: $Id: psy.h 16946 2010-03-03 16:12:40Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_PSY_H_ | |||||
#define _V_PSY_H_ | |||||
#include "smallft.h" | |||||
#include "backends.h" | |||||
#include "envelope.h" | |||||
#ifndef EHMER_MAX | |||||
#define EHMER_MAX 56 | |||||
#endif | |||||
/* psychoacoustic setup ********************************************/ | |||||
#define P_BANDS 17 /* 62Hz to 16kHz */ | |||||
#define P_LEVELS 8 /* 30dB to 100dB */ | |||||
#define P_LEVEL_0 30. /* 30 dB */ | |||||
#define P_NOISECURVES 3 | |||||
#define NOISE_COMPAND_LEVELS 40 | |||||
typedef struct vorbis_info_psy{ | |||||
int blockflag; | |||||
float ath_adjatt; | |||||
float ath_maxatt; | |||||
float tone_masteratt[P_NOISECURVES]; | |||||
float tone_centerboost; | |||||
float tone_decay; | |||||
float tone_abs_limit; | |||||
float toneatt[P_BANDS]; | |||||
int noisemaskp; | |||||
float noisemaxsupp; | |||||
float noisewindowlo; | |||||
float noisewindowhi; | |||||
int noisewindowlomin; | |||||
int noisewindowhimin; | |||||
int noisewindowfixed; | |||||
float noiseoff[P_NOISECURVES][P_BANDS]; | |||||
float noisecompand[NOISE_COMPAND_LEVELS]; | |||||
float max_curve_dB; | |||||
int normal_p; | |||||
int normal_start; | |||||
int normal_partition; | |||||
double normal_thresh; | |||||
} vorbis_info_psy; | |||||
typedef struct{ | |||||
int eighth_octave_lines; | |||||
/* for block long/short tuning; encode only */ | |||||
float preecho_thresh[VE_BANDS]; | |||||
float postecho_thresh[VE_BANDS]; | |||||
float stretch_penalty; | |||||
float preecho_minenergy; | |||||
float ampmax_att_per_sec; | |||||
/* channel coupling config */ | |||||
int coupling_pkHz[PACKETBLOBS]; | |||||
int coupling_pointlimit[2][PACKETBLOBS]; | |||||
int coupling_prepointamp[PACKETBLOBS]; | |||||
int coupling_postpointamp[PACKETBLOBS]; | |||||
int sliding_lowpass[2][PACKETBLOBS]; | |||||
} vorbis_info_psy_global; | |||||
typedef struct { | |||||
float ampmax; | |||||
int channels; | |||||
vorbis_info_psy_global *gi; | |||||
int coupling_pointlimit[2][P_NOISECURVES]; | |||||
} vorbis_look_psy_global; | |||||
typedef struct { | |||||
int n; | |||||
struct vorbis_info_psy *vi; | |||||
float ***tonecurves; | |||||
float **noiseoffset; | |||||
float *ath; | |||||
long *octave; /* in n.ocshift format */ | |||||
long *bark; | |||||
long firstoc; | |||||
long shiftoc; | |||||
int eighth_octave_lines; /* power of two, please */ | |||||
int total_octave_lines; | |||||
long rate; /* cache it */ | |||||
float m_val; /* Masking compensation value */ | |||||
} vorbis_look_psy; | |||||
extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, | |||||
vorbis_info_psy_global *gi,int n,long rate); | |||||
extern void _vp_psy_clear(vorbis_look_psy *p); | |||||
extern void *_vi_psy_dup(void *source); | |||||
extern void _vi_psy_free(vorbis_info_psy *i); | |||||
extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i); | |||||
extern void _vp_noisemask(vorbis_look_psy *p, | |||||
float *logmdct, | |||||
float *logmask); | |||||
extern void _vp_tonemask(vorbis_look_psy *p, | |||||
float *logfft, | |||||
float *logmask, | |||||
float global_specmax, | |||||
float local_specmax); | |||||
extern void _vp_offset_and_mix(vorbis_look_psy *p, | |||||
float *noise, | |||||
float *tone, | |||||
int offset_select, | |||||
float *logmask, | |||||
float *mdct, | |||||
float *logmdct); | |||||
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd); | |||||
extern void _vp_couple_quantize_normalize(int blobno, | |||||
vorbis_info_psy_global *g, | |||||
vorbis_look_psy *p, | |||||
vorbis_info_mapping0 *vi, | |||||
float **mdct, | |||||
int **iwork, | |||||
int *nonzero, | |||||
int sliding_lowpass, | |||||
int ch); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: random psychoacoustics (not including preecho) | |||||
********************************************************************/ | |||||
#ifndef _V_PSY_H_ | |||||
#define _V_PSY_H_ | |||||
#include "smallft.h" | |||||
#include "backends.h" | |||||
#include "envelope.h" | |||||
#ifndef EHMER_MAX | |||||
#define EHMER_MAX 56 | |||||
#endif | |||||
/* psychoacoustic setup ********************************************/ | |||||
#define P_BANDS 17 /* 62Hz to 16kHz */ | |||||
#define P_LEVELS 8 /* 30dB to 100dB */ | |||||
#define P_LEVEL_0 30. /* 30 dB */ | |||||
#define P_NOISECURVES 3 | |||||
#define NOISE_COMPAND_LEVELS 40 | |||||
typedef struct vorbis_info_psy{ | |||||
int blockflag; | |||||
float ath_adjatt; | |||||
float ath_maxatt; | |||||
float tone_masteratt[P_NOISECURVES]; | |||||
float tone_centerboost; | |||||
float tone_decay; | |||||
float tone_abs_limit; | |||||
float toneatt[P_BANDS]; | |||||
int noisemaskp; | |||||
float noisemaxsupp; | |||||
float noisewindowlo; | |||||
float noisewindowhi; | |||||
int noisewindowlomin; | |||||
int noisewindowhimin; | |||||
int noisewindowfixed; | |||||
float noiseoff[P_NOISECURVES][P_BANDS]; | |||||
float noisecompand[NOISE_COMPAND_LEVELS]; | |||||
float max_curve_dB; | |||||
int normal_p; | |||||
int normal_start; | |||||
int normal_partition; | |||||
double normal_thresh; | |||||
} vorbis_info_psy; | |||||
typedef struct{ | |||||
int eighth_octave_lines; | |||||
/* for block long/short tuning; encode only */ | |||||
float preecho_thresh[VE_BANDS]; | |||||
float postecho_thresh[VE_BANDS]; | |||||
float stretch_penalty; | |||||
float preecho_minenergy; | |||||
float ampmax_att_per_sec; | |||||
/* channel coupling config */ | |||||
int coupling_pkHz[PACKETBLOBS]; | |||||
int coupling_pointlimit[2][PACKETBLOBS]; | |||||
int coupling_prepointamp[PACKETBLOBS]; | |||||
int coupling_postpointamp[PACKETBLOBS]; | |||||
int sliding_lowpass[2][PACKETBLOBS]; | |||||
} vorbis_info_psy_global; | |||||
typedef struct { | |||||
float ampmax; | |||||
int channels; | |||||
vorbis_info_psy_global *gi; | |||||
int coupling_pointlimit[2][P_NOISECURVES]; | |||||
} vorbis_look_psy_global; | |||||
typedef struct { | |||||
int n; | |||||
struct vorbis_info_psy *vi; | |||||
float ***tonecurves; | |||||
float **noiseoffset; | |||||
float *ath; | |||||
long *octave; /* in n.ocshift format */ | |||||
long *bark; | |||||
long firstoc; | |||||
long shiftoc; | |||||
int eighth_octave_lines; /* power of two, please */ | |||||
int total_octave_lines; | |||||
long rate; /* cache it */ | |||||
float m_val; /* Masking compensation value */ | |||||
} vorbis_look_psy; | |||||
extern void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, | |||||
vorbis_info_psy_global *gi,int n,long rate); | |||||
extern void _vp_psy_clear(vorbis_look_psy *p); | |||||
extern void *_vi_psy_dup(void *source); | |||||
extern void _vi_psy_free(vorbis_info_psy *i); | |||||
extern vorbis_info_psy *_vi_psy_copy(vorbis_info_psy *i); | |||||
extern void _vp_noisemask(vorbis_look_psy *p, | |||||
float *logmdct, | |||||
float *logmask); | |||||
extern void _vp_tonemask(vorbis_look_psy *p, | |||||
float *logfft, | |||||
float *logmask, | |||||
float global_specmax, | |||||
float local_specmax); | |||||
extern void _vp_offset_and_mix(vorbis_look_psy *p, | |||||
float *noise, | |||||
float *tone, | |||||
int offset_select, | |||||
float *logmask, | |||||
float *mdct, | |||||
float *logmdct); | |||||
extern float _vp_ampmax_decay(float amp,vorbis_dsp_state *vd); | |||||
extern void _vp_couple_quantize_normalize(int blobno, | |||||
vorbis_info_psy_global *g, | |||||
vorbis_look_psy *p, | |||||
vorbis_info_mapping0 *vi, | |||||
float **mdct, | |||||
int **iwork, | |||||
int *nonzero, | |||||
int sliding_lowpass, | |||||
int ch); | |||||
#endif |
@@ -1,45 +1,44 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: registry for time, floor, res backends and channel mappings | |||||
last mod: $Id: registry.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "registry.h" | |||||
#include "misc.h" | |||||
/* seems like major overkill now; the backend numbers will grow into | |||||
the infrastructure soon enough */ | |||||
extern const vorbis_func_floor floor0_exportbundle; | |||||
extern const vorbis_func_floor floor1_exportbundle; | |||||
extern const vorbis_func_residue residue0_exportbundle; | |||||
extern const vorbis_func_residue residue1_exportbundle; | |||||
extern const vorbis_func_residue residue2_exportbundle; | |||||
extern const vorbis_func_mapping mapping0_exportbundle; | |||||
const vorbis_func_floor *const _floor_P[]={ | |||||
&floor0_exportbundle, | |||||
&floor1_exportbundle, | |||||
}; | |||||
const vorbis_func_residue *const _residue_P[]={ | |||||
&residue0_exportbundle, | |||||
&residue1_exportbundle, | |||||
&residue2_exportbundle, | |||||
}; | |||||
const vorbis_func_mapping *const _mapping_P[]={ | |||||
&mapping0_exportbundle, | |||||
}; | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: registry for time, floor, res backends and channel mappings | |||||
********************************************************************/ | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "registry.h" | |||||
#include "misc.h" | |||||
/* seems like major overkill now; the backend numbers will grow into | |||||
the infrastructure soon enough */ | |||||
extern const vorbis_func_floor floor0_exportbundle; | |||||
extern const vorbis_func_floor floor1_exportbundle; | |||||
extern const vorbis_func_residue residue0_exportbundle; | |||||
extern const vorbis_func_residue residue1_exportbundle; | |||||
extern const vorbis_func_residue residue2_exportbundle; | |||||
extern const vorbis_func_mapping mapping0_exportbundle; | |||||
const vorbis_func_floor *const _floor_P[]={ | |||||
&floor0_exportbundle, | |||||
&floor1_exportbundle, | |||||
}; | |||||
const vorbis_func_residue *const _residue_P[]={ | |||||
&residue0_exportbundle, | |||||
&residue1_exportbundle, | |||||
&residue2_exportbundle, | |||||
}; | |||||
const vorbis_func_mapping *const _mapping_P[]={ | |||||
&mapping0_exportbundle, | |||||
}; |
@@ -1,32 +1,31 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: registry for time, floor, res backends and channel mappings | |||||
last mod: $Id: registry.h 15531 2008-11-24 23:50:06Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_REG_H_ | |||||
#define _V_REG_H_ | |||||
#define VI_TRANSFORMB 1 | |||||
#define VI_WINDOWB 1 | |||||
#define VI_TIMEB 1 | |||||
#define VI_FLOORB 2 | |||||
#define VI_RESB 3 | |||||
#define VI_MAPB 1 | |||||
extern const vorbis_func_floor *const _floor_P[]; | |||||
extern const vorbis_func_residue *const _residue_P[]; | |||||
extern const vorbis_func_mapping *const _mapping_P[]; | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: registry for time, floor, res backends and channel mappings | |||||
********************************************************************/ | |||||
#ifndef _V_REG_H_ | |||||
#define _V_REG_H_ | |||||
#define VI_TRANSFORMB 1 | |||||
#define VI_WINDOWB 1 | |||||
#define VI_TIMEB 1 | |||||
#define VI_FLOORB 2 | |||||
#define VI_RESB 3 | |||||
#define VI_MAPB 1 | |||||
extern const vorbis_func_floor *const _floor_P[]; | |||||
extern const vorbis_func_residue *const _residue_P[]; | |||||
extern const vorbis_func_mapping *const _mapping_P[]; | |||||
#endif |
@@ -1,90 +1,89 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: linear scale -> dB, Bark and Mel scales | |||||
last mod: $Id: scales.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_SCALES_H_ | |||||
#define _V_SCALES_H_ | |||||
#include <math.h> | |||||
#include "os.h" | |||||
#ifdef _MSC_VER | |||||
/* MS Visual Studio doesn't have C99 inline keyword. */ | |||||
#define inline __inline | |||||
#endif | |||||
/* 20log10(x) */ | |||||
#define VORBIS_IEEE_FLOAT32 1 | |||||
#ifdef VORBIS_IEEE_FLOAT32 | |||||
static inline float unitnorm(float x){ | |||||
union { | |||||
ogg_uint32_t i; | |||||
float f; | |||||
} ix; | |||||
ix.f = x; | |||||
ix.i = (ix.i & 0x80000000U) | (0x3f800000U); | |||||
return ix.f; | |||||
} | |||||
/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */ | |||||
static inline float todB(const float *x){ | |||||
union { | |||||
ogg_uint32_t i; | |||||
float f; | |||||
} ix; | |||||
ix.f = *x; | |||||
ix.i = ix.i&0x7fffffff; | |||||
return (float)(ix.i * 7.17711438e-7f -764.6161886f); | |||||
} | |||||
#define todB_nn(x) todB(x) | |||||
#else | |||||
static float unitnorm(float x){ | |||||
if(x<0)return(-1.f); | |||||
return(1.f); | |||||
} | |||||
#define todB(x) (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f) | |||||
#define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f) | |||||
#endif | |||||
#define fromdB(x) (exp((x)*.11512925f)) | |||||
/* The bark scale equations are approximations, since the original | |||||
table was somewhat hand rolled. The below are chosen to have the | |||||
best possible fit to the rolled tables, thus their somewhat odd | |||||
appearance (these are more accurate and over a longer range than | |||||
the oft-quoted bark equations found in the texts I have). The | |||||
approximations are valid from 0 - 30kHz (nyquist) or so. | |||||
all f in Hz, z in Bark */ | |||||
#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) | |||||
#define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f) | |||||
#define toMEL(n) (log(1.f+(n)*.001f)*1442.695f) | |||||
#define fromMEL(m) (1000.f*exp((m)/1442.695f)-1000.f) | |||||
/* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave | |||||
0.0 */ | |||||
#define toOC(n) (log(n)*1.442695f-5.965784f) | |||||
#define fromOC(o) (exp(((o)+5.965784f)*.693147f)) | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: linear scale -> dB, Bark and Mel scales | |||||
********************************************************************/ | |||||
#ifndef _V_SCALES_H_ | |||||
#define _V_SCALES_H_ | |||||
#include <math.h> | |||||
#include "os.h" | |||||
#ifdef _MSC_VER | |||||
/* MS Visual Studio doesn't have C99 inline keyword. */ | |||||
#define inline __inline | |||||
#endif | |||||
/* 20log10(x) */ | |||||
#define VORBIS_IEEE_FLOAT32 1 | |||||
#ifdef VORBIS_IEEE_FLOAT32 | |||||
static inline float unitnorm(float x){ | |||||
union { | |||||
ogg_uint32_t i; | |||||
float f; | |||||
} ix; | |||||
ix.f = x; | |||||
ix.i = (ix.i & 0x80000000U) | (0x3f800000U); | |||||
return ix.f; | |||||
} | |||||
/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */ | |||||
static inline float todB(const float *x){ | |||||
union { | |||||
ogg_uint32_t i; | |||||
float f; | |||||
} ix; | |||||
ix.f = *x; | |||||
ix.i = ix.i&0x7fffffff; | |||||
return (float)(ix.i * 7.17711438e-7f -764.6161886f); | |||||
} | |||||
#define todB_nn(x) todB(x) | |||||
#else | |||||
static float unitnorm(float x){ | |||||
if(x<0)return(-1.f); | |||||
return(1.f); | |||||
} | |||||
#define todB(x) (*(x)==0?-400.f:log(*(x)**(x))*4.34294480f) | |||||
#define todB_nn(x) (*(x)==0.f?-400.f:log(*(x))*8.6858896f) | |||||
#endif | |||||
#define fromdB(x) (exp((x)*.11512925f)) | |||||
/* The bark scale equations are approximations, since the original | |||||
table was somewhat hand rolled. The below are chosen to have the | |||||
best possible fit to the rolled tables, thus their somewhat odd | |||||
appearance (these are more accurate and over a longer range than | |||||
the oft-quoted bark equations found in the texts I have). The | |||||
approximations are valid from 0 - 30kHz (nyquist) or so. | |||||
all f in Hz, z in Bark */ | |||||
#define toBARK(n) (13.1f*atan(.00074f*(n))+2.24f*atan((n)*(n)*1.85e-8f)+1e-4f*(n)) | |||||
#define fromBARK(z) (102.f*(z)-2.f*pow(z,2.f)+.4f*pow(z,3.f)+pow(1.46f,z)-1.f) | |||||
#define toMEL(n) (log(1.f+(n)*.001f)*1442.695f) | |||||
#define fromMEL(m) (1000.f*exp((m)/1442.695f)-1000.f) | |||||
/* Frequency to octave. We arbitrarily declare 63.5 Hz to be octave | |||||
0.0 */ | |||||
#define toOC(n) (log(n)*1.442695f-5.965784f) | |||||
#define fromOC(o) (exp(((o)+5.965784f)*.693147f)) | |||||
#endif |
@@ -1,34 +1,33 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: fft transform | |||||
last mod: $Id: smallft.h 13293 2007-07-24 00:09:47Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_SMFT_H_ | |||||
#define _V_SMFT_H_ | |||||
#include "../../codec.h" | |||||
typedef struct { | |||||
int n; | |||||
float *trigcache; | |||||
int *splitcache; | |||||
} drft_lookup; | |||||
extern void drft_forward(drft_lookup *l,float *data); | |||||
extern void drft_backward(drft_lookup *l,float *data); | |||||
extern void drft_init(drft_lookup *l,int n); | |||||
extern void drft_clear(drft_lookup *l); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: fft transform | |||||
********************************************************************/ | |||||
#ifndef _V_SMFT_H_ | |||||
#define _V_SMFT_H_ | |||||
#include "../../codec.h" | |||||
typedef struct { | |||||
int n; | |||||
float *trigcache; | |||||
int *splitcache; | |||||
} drft_lookup; | |||||
extern void drft_forward(drft_lookup *l,float *data); | |||||
extern void drft_backward(drft_lookup *l,float *data); | |||||
extern void drft_init(drft_lookup *l,int n); | |||||
extern void drft_clear(drft_lookup *l); | |||||
#endif |
@@ -1,184 +1,179 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: single-block PCM synthesis | |||||
last mod: $Id: synthesis.c 17474 2010-09-30 03:41:41Z gmaxwell $ | |||||
********************************************************************/ | |||||
#include <stdio.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "registry.h" | |||||
#include "misc.h" | |||||
#include "os.h" | |||||
int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ | |||||
vorbis_dsp_state *vd= vb ? vb->vd : 0; | |||||
private_state *b= vd ? (private_state*)vd->backend_state : 0; | |||||
vorbis_info *vi= vd ? vd->vi : 0; | |||||
codec_setup_info *ci= vi ? (codec_setup_info*)vi->codec_setup : 0; | |||||
oggpack_buffer *opb=vb ? &vb->opb : 0; | |||||
int type,mode,i; | |||||
if (!vd || !b || !vi || !ci || !opb) { | |||||
return OV_EBADPACKET; | |||||
} | |||||
/* first things first. Make sure decode is ready */ | |||||
_vorbis_block_ripcord(vb); | |||||
oggpack_readinit(opb,op->packet,op->bytes); | |||||
/* Check the packet type */ | |||||
if(oggpack_read(opb,1)!=0){ | |||||
/* Oops. This is not an audio data packet */ | |||||
return(OV_ENOTAUDIO); | |||||
} | |||||
/* read our mode and pre/post windowsize */ | |||||
mode=oggpack_read(opb,b->modebits); | |||||
if(mode==-1){ | |||||
return(OV_EBADPACKET); | |||||
} | |||||
vb->mode=mode; | |||||
if(!ci->mode_param[mode]){ | |||||
return(OV_EBADPACKET); | |||||
} | |||||
vb->W=ci->mode_param[mode]->blockflag; | |||||
if(vb->W){ | |||||
/* this doesn;t get mapped through mode selection as it's used | |||||
only for window selection */ | |||||
vb->lW=oggpack_read(opb,1); | |||||
vb->nW=oggpack_read(opb,1); | |||||
if(vb->nW==-1){ | |||||
return(OV_EBADPACKET); | |||||
} | |||||
}else{ | |||||
vb->lW=0; | |||||
vb->nW=0; | |||||
} | |||||
/* more setup */ | |||||
vb->granulepos=op->granulepos; | |||||
vb->sequence=op->packetno; | |||||
vb->eofflag=op->e_o_s; | |||||
/* alloc pcm passback storage */ | |||||
vb->pcmend=ci->blocksizes[vb->W]; | |||||
vb->pcm=(float**)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); | |||||
for(i=0;i<vi->channels;i++) | |||||
vb->pcm[i]=(float*)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); | |||||
/* unpack_header enforces range checking */ | |||||
type=ci->map_type[ci->mode_param[mode]->mapping]; | |||||
return(_mapping_P[type]->inverse(vb,ci->map_param[ci->mode_param[mode]-> | |||||
mapping])); | |||||
} | |||||
/* used to track pcm position without actually performing decode. | |||||
Useful for sequential 'fast forward' */ | |||||
int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){ | |||||
vorbis_dsp_state *vd=vb->vd; | |||||
private_state *b=(private_state*)vd->backend_state; | |||||
vorbis_info *vi=vd->vi; | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
oggpack_buffer *opb=&vb->opb; | |||||
int mode; | |||||
/* first things first. Make sure decode is ready */ | |||||
_vorbis_block_ripcord(vb); | |||||
oggpack_readinit(opb,op->packet,op->bytes); | |||||
/* Check the packet type */ | |||||
if(oggpack_read(opb,1)!=0){ | |||||
/* Oops. This is not an audio data packet */ | |||||
return(OV_ENOTAUDIO); | |||||
} | |||||
/* read our mode and pre/post windowsize */ | |||||
mode=oggpack_read(opb,b->modebits); | |||||
if(mode==-1)return(OV_EBADPACKET); | |||||
vb->mode=mode; | |||||
if(!ci->mode_param[mode]){ | |||||
return(OV_EBADPACKET); | |||||
} | |||||
vb->W=ci->mode_param[mode]->blockflag; | |||||
if(vb->W){ | |||||
vb->lW=oggpack_read(opb,1); | |||||
vb->nW=oggpack_read(opb,1); | |||||
if(vb->nW==-1) return(OV_EBADPACKET); | |||||
}else{ | |||||
vb->lW=0; | |||||
vb->nW=0; | |||||
} | |||||
/* more setup */ | |||||
vb->granulepos=op->granulepos; | |||||
vb->sequence=op->packetno; | |||||
vb->eofflag=op->e_o_s; | |||||
/* no pcm */ | |||||
vb->pcmend=0; | |||||
vb->pcm=NULL; | |||||
return(0); | |||||
} | |||||
long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
oggpack_buffer opb; | |||||
int mode; | |||||
oggpack_readinit(&opb,op->packet,op->bytes); | |||||
/* Check the packet type */ | |||||
if(oggpack_read(&opb,1)!=0){ | |||||
/* Oops. This is not an audio data packet */ | |||||
return(OV_ENOTAUDIO); | |||||
} | |||||
{ | |||||
int modebits=0; | |||||
int v=ci->modes; | |||||
while(v>1){ | |||||
modebits++; | |||||
v>>=1; | |||||
} | |||||
/* read our mode and pre/post windowsize */ | |||||
mode=oggpack_read(&opb,modebits); | |||||
} | |||||
if(mode==-1)return(OV_EBADPACKET); | |||||
return(ci->blocksizes[ci->mode_param[mode]->blockflag]); | |||||
} | |||||
int vorbis_synthesis_halfrate(vorbis_info *vi,int flag){ | |||||
/* set / clear half-sample-rate mode */ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
/* right now, our MDCT can't handle < 64 sample windows. */ | |||||
if(ci->blocksizes[0]<=64 && flag)return -1; | |||||
ci->halfrate_flag=(flag?1:0); | |||||
return 0; | |||||
} | |||||
int vorbis_synthesis_halfrate_p(vorbis_info *vi){ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
return ci->halfrate_flag; | |||||
} | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2015 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: single-block PCM synthesis | |||||
********************************************************************/ | |||||
#include <stdio.h> | |||||
#include "../../ogg.h" | |||||
#include "../../codec.h" | |||||
#include "codec_internal.h" | |||||
#include "registry.h" | |||||
#include "misc.h" | |||||
#include "os.h" | |||||
int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ | |||||
vorbis_dsp_state *vd= vb ? vb->vd : 0; | |||||
private_state *b= vd ? (private_state*)vd->backend_state : 0; | |||||
vorbis_info *vi= vd ? vd->vi : 0; | |||||
codec_setup_info *ci= vi ? (codec_setup_info*)vi->codec_setup : 0; | |||||
oggpack_buffer *opb=vb ? &vb->opb : 0; | |||||
int type,mode,i; | |||||
if (!vd || !b || !vi || !ci || !opb) { | |||||
return OV_EBADPACKET; | |||||
} | |||||
/* first things first. Make sure decode is ready */ | |||||
_vorbis_block_ripcord(vb); | |||||
oggpack_readinit(opb,op->packet,op->bytes); | |||||
/* Check the packet type */ | |||||
if(oggpack_read(opb,1)!=0){ | |||||
/* Oops. This is not an audio data packet */ | |||||
return(OV_ENOTAUDIO); | |||||
} | |||||
/* read our mode and pre/post windowsize */ | |||||
mode=oggpack_read(opb,b->modebits); | |||||
if(mode==-1){ | |||||
return(OV_EBADPACKET); | |||||
} | |||||
vb->mode=mode; | |||||
if(!ci->mode_param[mode]){ | |||||
return(OV_EBADPACKET); | |||||
} | |||||
vb->W=ci->mode_param[mode]->blockflag; | |||||
if(vb->W){ | |||||
/* this doesn;t get mapped through mode selection as it's used | |||||
only for window selection */ | |||||
vb->lW=oggpack_read(opb,1); | |||||
vb->nW=oggpack_read(opb,1); | |||||
if(vb->nW==-1){ | |||||
return(OV_EBADPACKET); | |||||
} | |||||
}else{ | |||||
vb->lW=0; | |||||
vb->nW=0; | |||||
} | |||||
/* more setup */ | |||||
vb->granulepos=op->granulepos; | |||||
vb->sequence=op->packetno; | |||||
vb->eofflag=op->e_o_s; | |||||
/* alloc pcm passback storage */ | |||||
vb->pcmend=ci->blocksizes[vb->W]; | |||||
vb->pcm=(float**)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); | |||||
for(i=0;i<vi->channels;i++) | |||||
vb->pcm[i]=(float*)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); | |||||
/* unpack_header enforces range checking */ | |||||
type=ci->map_type[ci->mode_param[mode]->mapping]; | |||||
return(_mapping_P[type]->inverse(vb,ci->map_param[ci->mode_param[mode]-> | |||||
mapping])); | |||||
} | |||||
/* used to track pcm position without actually performing decode. | |||||
Useful for sequential 'fast forward' */ | |||||
int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){ | |||||
vorbis_dsp_state *vd=vb->vd; | |||||
private_state *b=(private_state*)vd->backend_state; | |||||
vorbis_info *vi=vd->vi; | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
oggpack_buffer *opb=&vb->opb; | |||||
int mode; | |||||
/* first things first. Make sure decode is ready */ | |||||
_vorbis_block_ripcord(vb); | |||||
oggpack_readinit(opb,op->packet,op->bytes); | |||||
/* Check the packet type */ | |||||
if(oggpack_read(opb,1)!=0){ | |||||
/* Oops. This is not an audio data packet */ | |||||
return(OV_ENOTAUDIO); | |||||
} | |||||
/* read our mode and pre/post windowsize */ | |||||
mode=oggpack_read(opb,b->modebits); | |||||
if(mode==-1)return(OV_EBADPACKET); | |||||
vb->mode=mode; | |||||
if(!ci->mode_param[mode]){ | |||||
return(OV_EBADPACKET); | |||||
} | |||||
vb->W=ci->mode_param[mode]->blockflag; | |||||
if(vb->W){ | |||||
vb->lW=oggpack_read(opb,1); | |||||
vb->nW=oggpack_read(opb,1); | |||||
if(vb->nW==-1) return(OV_EBADPACKET); | |||||
}else{ | |||||
vb->lW=0; | |||||
vb->nW=0; | |||||
} | |||||
/* more setup */ | |||||
vb->granulepos=op->granulepos; | |||||
vb->sequence=op->packetno; | |||||
vb->eofflag=op->e_o_s; | |||||
/* no pcm */ | |||||
vb->pcmend=0; | |||||
vb->pcm=NULL; | |||||
return(0); | |||||
} | |||||
long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
oggpack_buffer opb; | |||||
int mode; | |||||
if(ci==NULL || ci->modes<=0){ | |||||
/* codec setup not properly intialized */ | |||||
return(OV_EFAULT); | |||||
} | |||||
oggpack_readinit(&opb,op->packet,op->bytes); | |||||
/* Check the packet type */ | |||||
if(oggpack_read(&opb,1)!=0){ | |||||
/* Oops. This is not an audio data packet */ | |||||
return(OV_ENOTAUDIO); | |||||
} | |||||
/* read our mode and pre/post windowsize */ | |||||
mode=oggpack_read(&opb,ov_ilog(ci->modes-1)); | |||||
if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET); | |||||
return(ci->blocksizes[ci->mode_param[mode]->blockflag]); | |||||
} | |||||
int vorbis_synthesis_halfrate(vorbis_info *vi,int flag){ | |||||
/* set / clear half-sample-rate mode */ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
/* right now, our MDCT can't handle < 64 sample windows. */ | |||||
if(ci->blocksizes[0]<=64 && flag)return -1; | |||||
ci->halfrate_flag=(flag?1:0); | |||||
return 0; | |||||
} | |||||
int vorbis_synthesis_halfrate_p(vorbis_info *vi){ | |||||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||||
return ci->halfrate_flag; | |||||
} |
@@ -1,26 +1,25 @@ | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: window functions | |||||
last mod: $Id: window.h 13293 2007-07-24 00:09:47Z xiphmont $ | |||||
********************************************************************/ | |||||
#ifndef _V_WINDOW_ | |||||
#define _V_WINDOW_ | |||||
extern float *_vorbis_window_get(int n); | |||||
extern void _vorbis_apply_window(float *d,int *winno,long *blocksizes, | |||||
int lW,int W,int nW); | |||||
#endif | |||||
/******************************************************************** | |||||
* * | |||||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||||
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | |||||
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | |||||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||||
* * | |||||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||||
* by the Xiph.Org Foundation https://xiph.org/ * | |||||
* * | |||||
******************************************************************** | |||||
function: window functions | |||||
********************************************************************/ | |||||
#ifndef _V_WINDOW_ | |||||
#define _V_WINDOW_ | |||||
extern const float *_vorbis_window_get(int n); | |||||
extern void _vorbis_apply_window(float *d,int *winno,long *blocksizes, | |||||
int lW,int W,int nW); | |||||
#endif |