@@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} | |||
*/ | |||
#define JUCE_MAJOR_VERSION 1 | |||
#define JUCE_MINOR_VERSION 53 | |||
#define JUCE_BUILDNUMBER 35 | |||
#define JUCE_BUILDNUMBER 36 | |||
/** Current Juce version number. | |||
@@ -1880,9 +1880,6 @@ public: | |||
return isNeg ? -v : v; | |||
} | |||
static int ftime (char* dest, int maxChars, const char* format, const struct tm* tm) throw(); | |||
static int ftime (juce_wchar* dest, int maxChars, const juce_wchar* format, const struct tm* tm) throw(); | |||
template <typename CharPointerType> | |||
static size_t lengthUpTo (CharPointerType text, const size_t maxCharsToCount) throw() | |||
{ | |||
@@ -2053,6 +2050,24 @@ public: | |||
} | |||
} | |||
template <typename CharPointerType1, typename CharPointerType2> | |||
static int indexOfIgnoreCase (CharPointerType1 haystack, const CharPointerType2& needle) throw() | |||
{ | |||
int index = 0; | |||
const int needleLength = (int) needle.length(); | |||
for (;;) | |||
{ | |||
if (haystack.compareIgnoreCaseUpTo (needle, needleLength) == 0) | |||
return index; | |||
if (haystack.getAndAdvance() == 0) | |||
return -1; | |||
++index; | |||
} | |||
} | |||
template <typename Type> | |||
static int indexOfChar (Type text, const juce_wchar charToFind) throw() | |||
{ | |||
@@ -2105,6 +2120,10 @@ private: | |||
#endif // __JUCE_CHARACTERFUNCTIONS_JUCEHEADER__ | |||
/*** End of inlined file: juce_CharacterFunctions.h ***/ | |||
#ifndef JUCE_STRING_UTF_TYPE | |||
#define JUCE_STRING_UTF_TYPE 8 | |||
#endif | |||
#if JUCE_MSVC | |||
#pragma warning (push) | |||
#pragma warning (disable: 4514 4996) | |||
@@ -2579,6 +2598,25 @@ public: | |||
return *this; | |||
} | |||
/** Moves this pointer back to the previous character in the string. */ | |||
CharPointer_UTF8& operator--() throw() | |||
{ | |||
const char n = *--data; | |||
if ((n & 0xc0) == 0xc0) | |||
{ | |||
int count = 3; | |||
do | |||
{ | |||
--data; | |||
} | |||
while ((*data & 0xc0) == 0xc0 && --count >= 0); | |||
} | |||
return *this; | |||
} | |||
/** Returns the character that this pointer is currently pointing to, and then | |||
advances the pointer to point to the next character. */ | |||
juce_wchar getAndAdvance() throw() | |||
@@ -2627,10 +2665,22 @@ public: | |||
/** Moves this pointer forwards by the specified number of characters. */ | |||
void operator+= (int numToSkip) throw() | |||
{ | |||
jassert (numToSkip >= 0); | |||
if (numToSkip < 0) | |||
{ | |||
while (++numToSkip <= 0) | |||
--*this; | |||
} | |||
else | |||
{ | |||
while (--numToSkip >= 0) | |||
++*this; | |||
} | |||
} | |||
while (--numToSkip >= 0) | |||
++*this; | |||
/** Moves this pointer backwards by the specified number of characters. */ | |||
void operator-= (int numToSkip) throw() | |||
{ | |||
operator+= (-numToSkip); | |||
} | |||
/** Returns the character at a given character index from the start of the string. */ | |||
@@ -2649,6 +2699,14 @@ public: | |||
return p; | |||
} | |||
/** Returns a pointer which is moved backwards from this one by the specified number of characters. */ | |||
CharPointer_UTF8 operator- (int numToSkip) const throw() | |||
{ | |||
CharPointer_UTF8 p (*this); | |||
p += -numToSkip; | |||
return p; | |||
} | |||
/** Returns the number of characters in this string. */ | |||
size_t length() const throw() | |||
{ | |||
@@ -2968,6 +3026,12 @@ public: | |||
return true; | |||
} | |||
/** Atomically swaps this pointer for a new value, returning the previous value. */ | |||
CharPointer_UTF8 atomicSwap (const CharPointer_UTF8& newValue) | |||
{ | |||
return CharPointer_UTF8 (reinterpret_cast <Atomic<CharType*>&> (data).exchange (newValue.data)); | |||
} | |||
/** These values are the byte-order-mark (BOM) values for a UTF-8 stream. */ | |||
enum | |||
{ | |||
@@ -3063,6 +3127,17 @@ public: | |||
return *this; | |||
} | |||
/** Moves this pointer back to the previous character in the string. */ | |||
CharPointer_UTF16& operator--() throw() | |||
{ | |||
const juce_wchar n = *--data; | |||
if (n >= 0xdc00 && n <= 0xdfff) | |||
--data; | |||
return *this; | |||
} | |||
/** Returns the character that this pointer is currently pointing to, and then | |||
advances the pointer to point to the next character. */ | |||
juce_wchar getAndAdvance() throw() | |||
@@ -3086,10 +3161,22 @@ public: | |||
/** Moves this pointer forwards by the specified number of characters. */ | |||
void operator+= (int numToSkip) throw() | |||
{ | |||
jassert (numToSkip >= 0); | |||
if (numToSkip < 0) | |||
{ | |||
while (++numToSkip <= 0) | |||
--*this; | |||
} | |||
else | |||
{ | |||
while (--numToSkip >= 0) | |||
++*this; | |||
} | |||
} | |||
while (--numToSkip >= 0) | |||
++*this; | |||
/** Moves this pointer backwards by the specified number of characters. */ | |||
void operator-= (int numToSkip) throw() | |||
{ | |||
operator+= (-numToSkip); | |||
} | |||
/** Returns the character at a given character index from the start of the string. */ | |||
@@ -3108,6 +3195,14 @@ public: | |||
return p; | |||
} | |||
/** Returns a pointer which is moved backwards from this one by the specified number of characters. */ | |||
CharPointer_UTF16 operator- (const int numToSkip) const throw() | |||
{ | |||
CharPointer_UTF16 p (*this); | |||
p += -numToSkip; | |||
return p; | |||
} | |||
/** Writes a unicode character to this string, and advances this pointer to point to the next position. */ | |||
void write (juce_wchar charToWrite) throw() | |||
{ | |||
@@ -3394,6 +3489,12 @@ public: | |||
return true; | |||
} | |||
/** Atomically swaps this pointer for a new value, returning the previous value. */ | |||
CharPointer_UTF16 atomicSwap (const CharPointer_UTF16& newValue) | |||
{ | |||
return CharPointer_UTF16 (reinterpret_cast <Atomic<CharType*>&> (data).exchange (newValue.data)); | |||
} | |||
/** These values are the byte-order-mark (BOM) values for a UTF-16 stream. */ | |||
enum | |||
{ | |||
@@ -4201,12 +4302,32 @@ public: | |||
*/ | |||
String (const juce_wchar* unicodeText, size_t maxChars); | |||
#if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
/** Creates a string from a UTF-16 character string */ | |||
String (const wchar_t* text); | |||
/** Creates a string from a UTF-16 character string */ | |||
String (const wchar_t* text, size_t maxChars); | |||
#endif | |||
/** Creates a string from a UTF-8 character string */ | |||
String (const CharPointer_UTF8& text); | |||
/** Creates a string from a UTF-8 character string */ | |||
String (const CharPointer_UTF8& text, size_t maxChars); | |||
/** Creates a string from a UTF-8 character string */ | |||
String (const CharPointer_UTF8& start, const CharPointer_UTF8& end); | |||
/** Creates a string from a UTF-16 character string */ | |||
String (const CharPointer_UTF16& text); | |||
/** Creates a string from a UTF-16 character string */ | |||
String (const CharPointer_UTF16& text, size_t maxChars); | |||
/** Creates a string from a UTF-16 character string */ | |||
String (const CharPointer_UTF16& start, const CharPointer_UTF16& end); | |||
/** Creates a string from a UTF-32 character string */ | |||
String (const CharPointer_UTF32& text); | |||
@@ -4219,14 +4340,6 @@ public: | |||
/** Creates a string from an ASCII character string */ | |||
String (const CharPointer_ASCII& text); | |||
#if ! JUCE_NATIVE_WCHAR_IS_UTF32 | |||
/** Creates a string from a UTF-16 character string */ | |||
String (const wchar_t* text); | |||
/** Creates a string from a UTF-16 character string */ | |||
String (const wchar_t* text, size_t maxChars); | |||
#endif | |||
/** Creates a string from a single character. */ | |||
static const String charToString (juce_wchar character); | |||
@@ -4240,8 +4353,27 @@ public: | |||
*/ | |||
static const String empty; | |||
/** This is the character encoding type used internally to store the string. */ | |||
/** This is the character encoding type used internally to store the string. | |||
By setting the value of JUCE_STRING_UTF_TYPE to 8, 16, or 32, you can change the | |||
internal storage format of the String class. UTF-8 uses the least space (if your strings | |||
contain few extended characters), but call operator[] involves iterating the string to find | |||
the required index. UTF-32 provides instant random access to its characters, but uses 4 bytes | |||
per character to store them. UTF-16 uses more space than UTF-8 and is also slow to index, | |||
but is the native wchar_t format used in Windows. | |||
It doesn't matter too much which format you pick, because the toUTF8(), toUTF16() and | |||
toUTF32() methods let you access the string's content in any of the other formats. | |||
*/ | |||
#if (JUCE_STRING_UTF_TYPE == 32) | |||
typedef CharPointer_UTF32 CharPointerType; | |||
#elif (JUCE_STRING_UTF_TYPE == 16) | |||
typedef CharPointer_UTF16 CharPointerType; | |||
#elif (JUCE_STRING_UTF_TYPE == 8) | |||
typedef CharPointer_UTF8 CharPointerType; | |||
#else | |||
#error "You must set the value of JUCE_STRING_UTF_TYPE to be either 8, 16, or 32!" | |||
#endif | |||
/** Generates a probably-unique 32-bit hashcode from this string. */ | |||
int hashCode() const throw(); | |||
@@ -4291,13 +4423,21 @@ public: | |||
{ | |||
if (textToAppend.getAddress() != 0) | |||
{ | |||
const size_t numExtraChars = textToAppend.lengthUpTo (maxCharsToTake); | |||
size_t extraBytesNeeded = 0; | |||
size_t numChars = 0; | |||
for (CharPointer t (textToAppend); numChars < maxCharsToTake && ! t.isEmpty();) | |||
{ | |||
extraBytesNeeded += CharPointerType::getBytesRequiredFor (t.getAndAdvance()); | |||
++numChars; | |||
} | |||
if (numExtraChars > 0) | |||
if (numChars > 0) | |||
{ | |||
const int oldLen = length(); | |||
preallocateStorage (oldLen + numExtraChars); | |||
CharPointerType (text + oldLen).writeWithCharLimit (textToAppend, (int) (numExtraChars + 1)); | |||
const size_t byteOffsetOfNull = getByteOffsetOfEnd(); | |||
preallocateBytes (byteOffsetOfNull + extraBytesNeeded); | |||
CharPointerType (addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull)).writeWithCharLimit (textToAppend, (int) (numChars + 1)); | |||
} | |||
} | |||
} | |||
@@ -4312,13 +4452,17 @@ public: | |||
{ | |||
if (textToAppend.getAddress() != 0) | |||
{ | |||
const size_t numExtraChars = textToAppend.length(); | |||
size_t extraBytesNeeded = 0; | |||
if (numExtraChars > 0) | |||
for (CharPointer t (textToAppend); ! t.isEmpty();) | |||
extraBytesNeeded += CharPointerType::getBytesRequiredFor (t.getAndAdvance()); | |||
if (extraBytesNeeded > 0) | |||
{ | |||
const int oldLen = length(); | |||
preallocateStorage (oldLen + numExtraChars); | |||
CharPointerType (text + oldLen).writeAll (textToAppend); | |||
const size_t byteOffsetOfNull = getByteOffsetOfEnd(); | |||
preallocateBytes (byteOffsetOfNull + extraBytesNeeded); | |||
CharPointerType (addBytesToPointer (text.getAddress(), (int) byteOffsetOfNull)).writeAll (textToAppend); | |||
} | |||
} | |||
} | |||
@@ -4515,18 +4659,14 @@ public: | |||
// Substring location methods.. | |||
/** Searches for a character inside this string. | |||
Uses a case-sensitive comparison. | |||
@returns the index of the first occurrence of the character in this | |||
string, or -1 if it's not found. | |||
*/ | |||
int indexOfChar (juce_wchar characterToLookFor) const throw(); | |||
/** Searches for a character inside this string. | |||
Uses a case-sensitive comparison. | |||
@param startIndex the index from which the search should proceed | |||
@param characterToLookFor the character to look for | |||
@returns the index of the first occurrence of the character in this | |||
@@ -4551,67 +4691,54 @@ public: | |||
bool ignoreCase = false) const throw(); | |||
/** Searches for a substring within this string. | |||
Uses a case-sensitive comparison. | |||
@returns the index of the first occurrence of this substring, or -1 if it's not found. | |||
If textToLookFor is an empty string, this will always return 0. | |||
*/ | |||
int indexOf (const String& text) const throw(); | |||
int indexOf (const String& textToLookFor) const throw(); | |||
/** Searches for a substring within this string. | |||
Uses a case-sensitive comparison. | |||
@param startIndex the index from which the search should proceed | |||
@param textToLookFor the string to search for | |||
@returns the index of the first occurrence of this substring, or -1 if it's not found. | |||
If textToLookFor is an empty string, this will always return -1. | |||
*/ | |||
int indexOf (int startIndex, | |||
const String& textToLookFor) const throw(); | |||
int indexOf (int startIndex, const String& textToLookFor) const throw(); | |||
/** Searches for a substring within this string. | |||
Uses a case-insensitive comparison. | |||
@returns the index of the first occurrence of this substring, or -1 if it's not found. | |||
If textToLookFor is an empty string, this will always return 0. | |||
*/ | |||
int indexOfIgnoreCase (const String& textToLookFor) const throw(); | |||
/** Searches for a substring within this string. | |||
Uses a case-insensitive comparison. | |||
@param startIndex the index from which the search should proceed | |||
@param textToLookFor the string to search for | |||
@returns the index of the first occurrence of this substring, or -1 if it's not found. | |||
If textToLookFor is an empty string, this will always return -1. | |||
*/ | |||
int indexOfIgnoreCase (int startIndex, | |||
const String& textToLookFor) const throw(); | |||
int indexOfIgnoreCase (int startIndex, const String& textToLookFor) const throw(); | |||
/** Searches for a character inside this string (working backwards from the end of the string). | |||
Uses a case-sensitive comparison. | |||
@returns the index of the last occurrence of the character in this | |||
string, or -1 if it's not found. | |||
@returns the index of the last occurrence of the character in this string, or -1 if it's not found. | |||
*/ | |||
int lastIndexOfChar (juce_wchar character) const throw(); | |||
/** Searches for a substring inside this string (working backwards from the end of the string). | |||
Uses a case-sensitive comparison. | |||
@returns the index of the start of the last occurrence of the | |||
substring within this string, or -1 if it's not found. | |||
@returns the index of the start of the last occurrence of the substring within this string, | |||
or -1 if it's not found. If textToLookFor is an empty string, this will always return -1. | |||
*/ | |||
int lastIndexOf (const String& textToLookFor) const throw(); | |||
/** Searches for a substring inside this string (working backwards from the end of the string). | |||
Uses a case-insensitive comparison. | |||
@returns the index of the start of the last occurrence of the | |||
substring within this string, or -1 if it's not found. | |||
@returns the index of the start of the last occurrence of the substring within this string, or -1 | |||
if it's not found. If textToLookFor is an empty string, this will always return -1. | |||
*/ | |||
int lastIndexOfIgnoreCase (const String& textToLookFor) const throw(); | |||
@@ -4633,8 +4760,15 @@ public: | |||
// Substring extraction and manipulation methods.. | |||
/** Returns the character at this index in the string. | |||
In a release build, no checks are made to see if the index is within a valid range, so be | |||
careful! In a debug build, the index is checked and an assertion fires if it's out-of-range. | |||
No checks are made to see if the index is within a valid range, so be careful! | |||
Also beware that depending on the encoding format that the string is using internally, this | |||
method may execute in either O(1) or O(n) time, so be careful when using it in your algorithms. | |||
If you're scanning through a string to inspect its characters, you should never use this operator | |||
for random access, it's far more efficient to call getCharPointer() to return a pointer, and | |||
then to use that to iterate the string. | |||
@see getCharPointer | |||
*/ | |||
const juce_wchar operator[] (int index) const throw(); | |||
@@ -5073,14 +5207,6 @@ public: | |||
int size, | |||
int groupSize = 1); | |||
/** Returns a unicode version of this string. | |||
Because it returns a reference to the string's internal data, the pointer | |||
that is returned must not be stored anywhere, as it can become invalid whenever | |||
any string methods (even some const ones!) are called. | |||
*/ | |||
inline operator const juce_wchar*() const throw() { return toUTF32().getAddress(); } | |||
/** Returns the character pointer currently being used to store this string. | |||
Because it returns a reference to the string's internal data, the pointer | |||
@@ -5123,7 +5249,7 @@ public: | |||
@see getCharPointer, toUTF8, toUTF16 | |||
*/ | |||
inline CharPointer_UTF32 toUTF32() const throw() { return text; } | |||
CharPointer_UTF32 toUTF32() const; | |||
/** Creates a String from a UTF-8 encoded buffer. | |||
If the size is < 0, it'll keep reading until it hits a zero. | |||
@@ -5170,33 +5296,22 @@ public: | |||
*/ | |||
int copyToUTF16 (CharPointer_UTF16::CharType* destBuffer, int maxBufferSizeBytes) const throw(); | |||
/** Returns a version of this string using the default 8-bit multi-byte system encoding. | |||
Because it returns a reference to the string's internal data, the pointer | |||
that is returned must not be stored anywhere, as it can be deleted whenever the | |||
string changes. | |||
@see getNumBytesAsCString, copyToCString, toUTF8 | |||
*/ | |||
const char* toCString() const; | |||
/** Copies the string to a buffer as UTF-16 characters. | |||
/** Returns the number of bytes required to represent this string as C-string. | |||
The number returned does NOT include the trailing zero. | |||
Note that you can also get this value by using CharPointer_UTF8::getBytesRequiredFor (myString.getCharPointer()) | |||
*/ | |||
int getNumBytesAsCString() const throw(); | |||
Returns the number of bytes copied to the buffer, including the terminating null | |||
character. | |||
/** Copies the string to a buffer. | |||
To find out how many bytes you need to store this string as UTF-32, you can call | |||
CharPointer_UTF32::getBytesRequiredFor (myString.getCharPointer()) | |||
@param destBuffer the place to copy it to; if this is a null pointer, | |||
the method just returns the number of bytes required | |||
(including the terminating null character). | |||
@param maxBufferSizeBytes the size of the destination buffer, in bytes. If the | |||
string won't fit, it'll put in as many as it can while | |||
still allowing for a terminating null char at the end, and | |||
will return the number of bytes that were actually used. | |||
@param destBuffer the place to copy it to; if this is a null pointer, the method just | |||
returns the number of bytes required (including the terminating null character). | |||
@param maxBufferSizeBytes the size of the destination buffer, in bytes. If the string won't fit, it'll | |||
put in as many as it can while still allowing for a terminating null char at the | |||
end, and will return the number of bytes that were actually used. | |||
@see CharPointer_UTF32::writeWithDestByteLimit | |||
*/ | |||
int copyToCString (char* destBuffer, int maxBufferSizeBytes) const throw(); | |||
int copyToUTF32 (CharPointer_UTF32::CharType* destBuffer, int maxBufferSizeBytes) const throw(); | |||
/** Increases the string's internally allocated storage. | |||
@@ -5208,11 +5323,11 @@ public: | |||
beforehand, so that these methods won't have to keep resizing the string | |||
to append the extra characters. | |||
@param numCharsNeeded the number of characters to allocate storage for. If this | |||
@param numBytesNeeded the number of bytes to allocate storage for. If this | |||
value is less than the currently allocated size, it will | |||
have no effect. | |||
*/ | |||
void preallocateStorage (size_t numCharsNeeded); | |||
void preallocateBytes (size_t numBytesNeeded); | |||
/** Swaps the contents of this string with another one. | |||
This is a very fast operation, as no allocation or copying needs to be done. | |||
@@ -5247,20 +5362,18 @@ private: | |||
CharPointerType text; | |||
struct Preallocation | |||
struct PreallocationBytes | |||
{ | |||
explicit Preallocation (size_t); | |||
size_t numChars; | |||
explicit PreallocationBytes (size_t); | |||
size_t numBytes; | |||
}; | |||
// This constructor preallocates a certain amount of memory | |||
explicit String (const Preallocation&); | |||
String (const String& stringToCopy, size_t charsToAllocate); | |||
void appendFixedLength (const juce_wchar* text, int numExtraChars); | |||
explicit String (const PreallocationBytes&); | |||
JUCE_DEPRECATED (String (const String& stringToCopy, size_t charsToAllocate)); | |||
void enlarge (size_t newTotalNumChars); | |||
void* createSpaceAtEndOfBuffer (size_t numExtraBytes) const; | |||
void appendFixedLength (const char* text, int numExtraChars); | |||
size_t getByteOffsetOfEnd() const throw(); | |||
// This private cast operator should prevent strings being accidentally cast | |||
// to bools (this is possible because the compiler can add an implicit cast | |||
@@ -7467,7 +7580,7 @@ public: | |||
int size() const throw(); | |||
/** Returns one of the strings in the pool, by index. */ | |||
const juce_wchar* operator[] (int index) const throw(); | |||
const String::CharPointerType operator[] (int index) const throw(); | |||
private: | |||
Array <String> strings; | |||
@@ -7522,11 +7635,11 @@ public: | |||
const String toString() const { return name; } | |||
/** Returns this identifier's raw string pointer. */ | |||
operator const juce_wchar*() const throw() { return name; } | |||
operator const String::CharPointerType() const throw() { return name; } | |||
private: | |||
const juce_wchar* name; | |||
String::CharPointerType name; | |||
static StringPool& getPool(); | |||
}; | |||
@@ -24983,7 +25096,7 @@ public: | |||
const String toString() const | |||
{ | |||
String s; | |||
s.preallocateStorage (16); | |||
s.preallocateBytes (32); | |||
s << x << ' ' << y << ' ' << w << ' ' << h; | |||
return s; | |||
} | |||
@@ -42861,8 +42974,7 @@ public: | |||
@see addMidiInputCallback, isMidiInputEnabled | |||
*/ | |||
void setMidiInputEnabled (const String& midiInputDeviceName, | |||
bool enabled); | |||
void setMidiInputEnabled (const String& midiInputDeviceName, bool enabled); | |||
/** Returns true if a given midi input device is being used. | |||
@@ -43006,33 +43118,22 @@ private: | |||
public MidiInputCallback | |||
{ | |||
public: | |||
AudioDeviceManager* owner; | |||
void audioDeviceIOCallback (const float** inputChannelData, | |||
int totalNumInputChannels, | |||
float** outputChannelData, | |||
int totalNumOutputChannels, | |||
int numSamples); | |||
void audioDeviceIOCallback (const float**, int, float**, int, int); | |||
void audioDeviceAboutToStart (AudioIODevice*); | |||
void audioDeviceStopped(); | |||
void handleIncomingMidiMessage (MidiInput*, const MidiMessage&); | |||
void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message); | |||
AudioDeviceManager* owner; | |||
}; | |||
CallbackHandler callbackHandler; | |||
friend class CallbackHandler; | |||
void audioDeviceIOCallbackInt (const float** inputChannelData, | |||
int totalNumInputChannels, | |||
float** outputChannelData, | |||
int totalNumOutputChannels, | |||
int numSamples); | |||
void audioDeviceAboutToStartInt (AudioIODevice* device); | |||
void audioDeviceIOCallbackInt (const float** inputChannelData, int totalNumInputChannels, | |||
float** outputChannelData, int totalNumOutputChannels, int numSamples); | |||
void audioDeviceAboutToStartInt (AudioIODevice*); | |||
void audioDeviceStoppedInt(); | |||
void handleIncomingMidiMessageInt (MidiInput* source, const MidiMessage& message); | |||
void handleIncomingMidiMessageInt (MidiInput*, const MidiMessage&); | |||
const String restartDevice (int blockSizeToUse, double sampleRateToUse, | |||
const BigInteger& ins, const BigInteger& outs); | |||
@@ -44,27 +44,27 @@ namespace OggVorbisNamespace | |||
#include "oggvorbis/bitwise.c" | |||
#include "oggvorbis/framing.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/analysis.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/bitrate.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/block.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/codebook.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/envelope.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/floor0.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/floor1.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/info.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/lpc.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/lsp.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/mapping0.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/mdct.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/psy.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/registry.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/res0.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/sharedbook.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/smallft.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/synthesis.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/vorbisenc.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/vorbisfile.c" | |||
#include "oggvorbis/libvorbis-1.1.2/lib/window.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" | |||
#else | |||
#include <vorbis/vorbisenc.h> | |||
#include <vorbis/codec.h> | |||
@@ -265,20 +265,15 @@ public: | |||
const int numChannels, | |||
const int bitsPerSample, | |||
const int qualityIndex) | |||
: AudioFormatWriter (out, TRANS (oggFormatName), | |||
sampleRate, | |||
numChannels, | |||
bitsPerSample) | |||
: AudioFormatWriter (out, TRANS (oggFormatName), sampleRate, numChannels, bitsPerSample) | |||
{ | |||
using namespace OggVorbisNamespace; | |||
ok = false; | |||
vorbis_info_init (&vi); | |||
if (vorbis_encode_init_vbr (&vi, | |||
numChannels, | |||
(int) sampleRate, | |||
jlimit (0.0f, 1.0f, qualityIndex * 0.5f)) == 0) | |||
if (vorbis_encode_init_vbr (&vi, numChannels, (int) sampleRate, | |||
jlimit (0.0f, 1.0f, qualityIndex * 0.1f)) == 0) | |||
{ | |||
vorbis_comment_init (&vc); | |||
@@ -407,7 +402,7 @@ OggVorbisAudioFormat::~OggVorbisAudioFormat() | |||
const Array <int> OggVorbisAudioFormat::getPossibleSampleRates() | |||
{ | |||
const int rates[] = { 22050, 32000, 44100, 48000, 0 }; | |||
const int rates[] = { 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 0 }; | |||
return Array <int> (rates); | |||
} | |||
@@ -453,11 +448,9 @@ AudioFormatWriter* OggVorbisAudioFormat::createWriterFor (OutputStream* out, | |||
const StringArray OggVorbisAudioFormat::getQualityOptions() | |||
{ | |||
StringArray s; | |||
s.add ("Low Quality"); | |||
s.add ("Medium Quality"); | |||
s.add ("High Quality"); | |||
return s; | |||
const char* options[] = { "64 kbps", "80 kbps", "96 kbps", "112 kbps", "128 kbps", "160 kbps", | |||
"192 kbps", "224 kbps", "256 kbps", "320 kbps", "500 kbps", 0 }; | |||
return StringArray (options); | |||
} | |||
int OggVorbisAudioFormat::estimateOggFileQuality (const File& source) | |||
@@ -596,6 +596,7 @@ private: | |||
int64 audioDataSize = bytesPerFrame * lengthInSamples; | |||
const bool isRF64 = (bytesWritten >= literal64bit (0x100000000)); | |||
const bool isWaveFmtEx = isRF64 || (numChannels > 2); | |||
int64 riffChunkSize = 4 /* 'RIFF' */ + 8 + 40 /* WAVEFORMATEX */ | |||
+ 8 + audioDataSize + (audioDataSize & 1) | |||
@@ -612,8 +613,8 @@ private: | |||
if (! isRF64) | |||
{ | |||
output->writeInt (chunkName ("JUNK")); | |||
output->writeInt (28 + 24); | |||
output->writeRepeatedByte (0, 28 /* ds64 */ + 24 /* extra waveformatex */); | |||
output->writeInt (28 + (isWaveFmtEx? 0 : 24)); | |||
output->writeRepeatedByte (0, 28 /* ds64 */ + (isWaveFmtEx? 0 : 24)); | |||
} | |||
else | |||
{ | |||
@@ -627,7 +628,7 @@ private: | |||
output->writeInt (chunkName ("fmt ")); | |||
if (isRF64) | |||
if (isWaveFmtEx) | |||
{ | |||
output->writeInt (40); // chunk size | |||
output->writeShort ((short) (uint16) 0xfffe); // WAVE_FORMAT_EXTENSIBLE | |||
@@ -645,7 +646,7 @@ private: | |||
output->writeShort ((short) bytesPerFrame); // nBlockAlign | |||
output->writeShort ((short) bitsPerSample); // wBitsPerSample | |||
if (isRF64) | |||
if (isWaveFmtEx) | |||
{ | |||
output->writeShort (22); // cbSize (size of the extension) | |||
output->writeShort ((short) bitsPerSample); // wValidBitsPerSample | |||
@@ -6,12 +6,12 @@ | |||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||
* * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
******************************************************************** | |||
function: libvorbis codec headers | |||
last mod: $Id: codec.h,v 1.1 2007/06/07 17:48:18 jules_rms Exp $ | |||
last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $ | |||
********************************************************************/ | |||
@@ -121,7 +121,7 @@ typedef struct 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 independant from other vorbis_blocks belonging to | |||
bitstream, but is independent from other vorbis_blocks belonging to | |||
that logical bitstream. *************************************************/ | |||
struct alloc_chain{ | |||
@@ -166,28 +166,30 @@ 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, char *comment); | |||
extern void vorbis_comment_add(vorbis_comment *vc, const char *comment); | |||
extern void vorbis_comment_add_tag(vorbis_comment *vc, | |||
const char *tag, char *contents); | |||
extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count); | |||
extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag); | |||
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); | |||
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); | |||
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); | |||
@@ -195,11 +197,12 @@ 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); | |||
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); | |||
ogg_packet *op); | |||
extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); | |||
extern int vorbis_synthesis_restart(vorbis_dsp_state *v); | |||
@@ -1,189 +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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: lookup data; generated by lookups.pl; edit there | |||
last mod: $Id: lookup_data.h,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
********************************************************************/ | |||
#ifndef _V_LOOKUP_DATA_H_ | |||
#ifdef FLOAT_LOOKUP | |||
#define COS_LOOKUP_SZ 128 | |||
static 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 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 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 | |||
static 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 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, | |||
}; | |||
#ifdef INT_LOOKUP | |||
#define INVSQ_LOOKUP_I_SHIFT 10 | |||
#define INVSQ_LOOKUP_I_MASK 1023 | |||
static 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 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,142 +0,0 @@ | |||
#!/usr/bin/perl | |||
print <<'EOD'; | |||
/******************************************************************** | |||
* * | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: lookup data; generated by lookups.pl; edit there | |||
last mod: $Id: lookups.pl,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
********************************************************************/ | |||
#ifndef _V_LOOKUP_DATA_H_ | |||
#ifdef FLOAT_LOOKUP | |||
EOD | |||
$cos_sz=128; | |||
$invsq_sz=32; | |||
$invsq2exp_min=-32; | |||
$invsq2exp_max=32; | |||
$fromdB_sz=35; | |||
$fromdB_shift=5; | |||
$fromdB2_shift=3; | |||
$invsq_i_shift=10; | |||
$cos_i_shift=9; | |||
$delta_shift=6; | |||
print "#define COS_LOOKUP_SZ $cos_sz\n"; | |||
print "static float COS_LOOKUP[COS_LOOKUP_SZ+1]={\n"; | |||
for($i=0;$i<=$cos_sz;){ | |||
print "\t"; | |||
for($j=0;$j<4 && $i<=$cos_sz;$j++){ | |||
printf "%+.13f,", cos(3.14159265358979323846*($i++)/$cos_sz) ; | |||
} | |||
print "\n"; | |||
} | |||
print "};\n\n"; | |||
print "#define INVSQ_LOOKUP_SZ $invsq_sz\n"; | |||
print "static float INVSQ_LOOKUP[INVSQ_LOOKUP_SZ+1]={\n"; | |||
for($i=0;$i<=$invsq_sz;){ | |||
print "\t"; | |||
for($j=0;$j<4 && $i<=$invsq_sz;$j++){ | |||
my$indexmap=$i++/$invsq_sz*.5+.5; | |||
printf "%.12f,", 1./sqrt($indexmap); | |||
} | |||
print "\n"; | |||
} | |||
print "};\n\n"; | |||
print "#define INVSQ2EXP_LOOKUP_MIN $invsq2exp_min\n"; | |||
print "#define INVSQ2EXP_LOOKUP_MAX $invsq2exp_max\n"; | |||
print "static float INVSQ2EXP_LOOKUP[INVSQ2EXP_LOOKUP_MAX-\\\n". | |||
" INVSQ2EXP_LOOKUP_MIN+1]={\n"; | |||
for($i=$invsq2exp_min;$i<=$invsq2exp_max;){ | |||
print "\t"; | |||
for($j=0;$j<4 && $i<=$invsq2exp_max;$j++){ | |||
printf "%15.10g,", 2**($i++*-.5); | |||
} | |||
print "\n"; | |||
} | |||
print "};\n\n#endif\n\n"; | |||
# 0 to -140 dB | |||
$fromdB2_sz=1<<$fromdB_shift; | |||
$fromdB_gran=1<<($fromdB_shift-$fromdB2_shift); | |||
print "#define FROMdB_LOOKUP_SZ $fromdB_sz\n"; | |||
print "#define FROMdB2_LOOKUP_SZ $fromdB2_sz\n"; | |||
print "#define FROMdB_SHIFT $fromdB_shift\n"; | |||
print "#define FROMdB2_SHIFT $fromdB2_shift\n"; | |||
print "#define FROMdB2_MASK ".((1<<$fromdB_shift)-1)."\n"; | |||
print "static float FROMdB_LOOKUP[FROMdB_LOOKUP_SZ]={\n"; | |||
for($i=0;$i<$fromdB_sz;){ | |||
print "\t"; | |||
for($j=0;$j<4 && $i<$fromdB_sz;$j++){ | |||
printf "%15.10g,", 10**(.05*(-$fromdB_gran*$i++)); | |||
} | |||
print "\n"; | |||
} | |||
print "};\n\n"; | |||
print "static float FROMdB2_LOOKUP[FROMdB2_LOOKUP_SZ]={\n"; | |||
for($i=0;$i<$fromdB2_sz;){ | |||
print "\t"; | |||
for($j=0;$j<4 && $i<$fromdB_sz;$j++){ | |||
printf "%15.10g,", 10**(.05*(-$fromdB_gran/$fromdB2_sz*(.5+$i++))); | |||
} | |||
print "\n"; | |||
} | |||
print "};\n\n#ifdef INT_LOOKUP\n\n"; | |||
$iisz=0x10000>>$invsq_i_shift; | |||
print "#define INVSQ_LOOKUP_I_SHIFT $invsq_i_shift\n"; | |||
print "#define INVSQ_LOOKUP_I_MASK ".(0x0ffff>>(16-$invsq_i_shift))."\n"; | |||
print "static long INVSQ_LOOKUP_I[$iisz+1]={\n"; | |||
for($i=0;$i<=$iisz;){ | |||
print "\t"; | |||
for($j=0;$j<4 && $i<=$iisz;$j++){ | |||
my$indexmap=$i++/$iisz*.5+.5; | |||
printf "%8d,", int(1./sqrt($indexmap)*65536.+.5); | |||
} | |||
print "\n"; | |||
} | |||
print "};\n\n"; | |||
$cisz=0x10000>>$cos_i_shift; | |||
print "#define COS_LOOKUP_I_SHIFT $cos_i_shift\n"; | |||
print "#define COS_LOOKUP_I_MASK ".(0x0ffff>>(16-$cos_i_shift))."\n"; | |||
print "#define COS_LOOKUP_I_SZ $cisz\n"; | |||
print "static long COS_LOOKUP_I[COS_LOOKUP_I_SZ+1]={\n"; | |||
for($i=0;$i<=$cisz;){ | |||
print "\t"; | |||
for($j=0;$j<4 && $i<=$cisz;$j++){ | |||
printf "%8d,", int(cos(3.14159265358979323846*($i++)/$cos_sz)*16384.+.5) ; | |||
} | |||
print "\n"; | |||
} | |||
print "};\n\n"; | |||
print "#endif\n\n#endif\n"; | |||
@@ -0,0 +1,126 @@ | |||
libvorbis 1.3.2 (2010-11-01) -- "Xiph.Org libVorbis I 20101101 (Schaufenugget)" | |||
* vorbis: additional proofing against invalid/malicious | |||
streams in floor, residue, and bos/eos packet trimming | |||
code (see SVN for details). | |||
* vorbis: Added programming documentation tree for the | |||
low-level calls | |||
* vorbisfile: Correct handling of serial numbers array | |||
element [0] on non-seekable streams | |||
* vorbisenc: Back out an [old] AoTuV HF weighting that was | |||
first enabled in 1.3.0; there are a few samples where I | |||
really don't like the effect it causes. | |||
* vorbis: return correct timestamp for granule positions | |||
with high bit set. | |||
* vorbisfile: the [undocumented] half-rate decode api made no | |||
attempt to keep the pcm offset tracking consistent in seeks. | |||
Fix and add a testing mode to seeking_example.c to torture | |||
test seeking in halfrate mode. Also remove requirement that | |||
halfrate mode only work with seekable files. | |||
* vorbisfile: Fix a chaining bug in raw_seeks where seeking | |||
out of the current link would fail due to not | |||
reinitializing the decode machinery. | |||
* vorbisfile: improve seeking strategy. Reduces the | |||
necessary number of seek callbacks in an open or seek | |||
operation by well over 2/3. | |||
libvorbis 1.3.1 (2010-02-26) -- "Xiph.Org libVorbis I 20100325 (Everywhere)" | |||
* tweak + minor arithmetic fix in floor1 fit | |||
* revert noise norm to conservative 1.2.3 behavior pending | |||
more listening testing | |||
libvorbis 1.3.0 (2010-02-25) -- unreleased staging snapshot | |||
* Optimized surround support for 5.1 encoding at 44.1/48kHz | |||
* Added encoder control call to disable channel coupling | |||
* Correct an overflow bug in very low-bitrate encoding on 32 bit | |||
machines that caused inflated bitrates | |||
* Numerous API hardening, leak and build fixes | |||
* Correct bug in 22kHz compand setup that could cause a crash | |||
* Correct bug in 16kHz codebooks that could cause unstable pure | |||
tones at high bitrates | |||
libvorbis 1.2.3 (2009-07-09) -- "Xiph.Org libVorbis I 20090709" | |||
* correct a vorbisfile bug that prevented proper playback of | |||
Vorbis files where all audio in a logical stream is in a | |||
single page | |||
* Additional decode setup hardening against malicious streams | |||
* Add 'OV_EXCLUDE_STATIC_CALLBACKS' define for developers who | |||
wish to avoid unused symbol warnings from the static callbacks | |||
defined in vorbisfile.h | |||
libvorbis 1.2.2 (2009-06-24) -- "Xiph.Org libVorbis I 20090624" | |||
* define VENDOR and ENCODER strings | |||
* seek correctly in files bigger than 2 GB (Windows) | |||
* fix regression from CVE-2008-1420; 1.0b1 files work again | |||
* mark all tables as constant to reduce memory occupation | |||
* additional decoder hardening against malicious streams | |||
* substantially reduce amount of seeking performed by Vorbisfile | |||
* Multichannel decode bugfix | |||
* build system updates | |||
* minor specification clarifications/fixes | |||
libvorbis 1.2.1 (unreleased) -- "Xiph.Org libVorbis I 20080501" | |||
* Improved robustness with corrupt streams. | |||
* New ov_read_filter() vorbisfile call allows filtering decoded | |||
audio as floats before converting to integer samples. | |||
* Fix an encoder bug with multichannel streams. | |||
* Replaced RTP payload format draft with RFC 5215. | |||
* Bare bones self test under 'make check'. | |||
* Fix a problem encoding some streams between 14 and 28 kHz. | |||
* Fix a numerical instability in the edge extrapolation filter. | |||
* Build system improvements. | |||
* Specification correction. | |||
libvorbis 1.2.0 (2007-07-25) -- "Xiph.Org libVorbis I 20070622" | |||
* new ov_fopen() convenience call that avoids the common | |||
stdio conflicts with ov_open() and MSVC runtimes. | |||
* libvorbisfile now handles multiplexed streams | |||
* improve robustness to corrupt input streams | |||
* fix a minor encoder bug | |||
* updated RTP draft | |||
* build system updates | |||
* minor corrections to the specification | |||
libvorbis 1.1.2 (2005-11-27) -- "Xiph.Org libVorbis I 20050304" | |||
* fix a serious encoder bug with gcc 4 optimized builds | |||
* documentation and spec fixes | |||
* updated VS2003 and XCode builds | |||
* new draft RTP encapsulation spec | |||
libvorbis 1.1.1 (2005-06-27) -- "Xiph.Org libVorbis I 20050304" | |||
* bug fix to the bitrate management encoder interface | |||
* bug fix to properly set packetno field in the encoder | |||
* new draft RTP encapsulation spec | |||
* library API documentation improvements | |||
libvorbis 1.1.0 (2004-09-22) -- "Xiph.Org libVorbis I 20040629" | |||
* merges tuning improvements from Aoyumi's aoTuV with fixups | |||
* new managed bitrate (CBR) mode support | |||
* new vorbis_encoder_ctl() interface | |||
* extensive documentation updates | |||
* application/ogg mimetype is now official | |||
* autotools cleanup from Thomas Vander Stichele | |||
* SymbianOS build support from Colin Ward at CSIRO | |||
* various bugfixes | |||
* various packaging improvements | |||
libvorbis 1.0.1 (2003-11-17) -- "Xiph.Org libVorbis I 20030909" | |||
* numerous bug fixes | |||
* specification corrections | |||
* new crosslap and halfrate APIs for game use | |||
* packaging and build updates | |||
libvorbis 1.0.0 (2002-07-19) -- "Xiph.Org libVorbis I 20020717" | |||
* first stable release | |||
@@ -1,4 +1,4 @@ | |||
Copyright (c) 2002-2004 Xiph.org Foundation | |||
Copyright (c) 2002-2008 Xiph.org Foundation | |||
Redistribution and use in source and binary forms, with or without | |||
modification, are permitted provided that the following conditions |
@@ -5,7 +5,7 @@ | |||
* 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-2004 * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||
* by the Xiph.org Foundation, http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
@@ -79,23 +79,25 @@ The user website for Ogg Vorbis software and audio is http://vorbis.com/ | |||
BUILDING FROM TRUNK: | |||
Development source is under subversion revision control at | |||
http://svn.xiph.org/trunk/vorbis/. You will also need the | |||
newest versions of autoconf, automake, and libtool in order | |||
to compile vorbis from development source. A configure script | |||
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 | |||
make | |||
and as root if desired: | |||
make install | |||
This will install the vorbis libraries (static and shared) into | |||
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 |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: analysis.c 16226 2009-07-08 06:43:49Z xiphmont $ | |||
********************************************************************/ | |||
@@ -29,8 +29,6 @@ | |||
#include "os.h" | |||
#include "misc.h" | |||
int analysis_noisy=1; | |||
/* decides between modes, dispatches to the appropriate mapping. */ | |||
int vorbis_analysis(vorbis_block *vb, ogg_packet *op){ | |||
int ret,i; | |||
@@ -68,46 +66,48 @@ int vorbis_analysis(vorbis_block *vb, ogg_packet *op){ | |||
return(0); | |||
} | |||
#ifdef ANALYSIS | |||
int analysis_noisy=1; | |||
/* there was no great place to put this.... */ | |||
void _analysis_output_always(const char *base,int i,float *v,int n,int bark,int dB,ogg_int64_t off){ | |||
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]; | |||
/* if(i==5870){*/ | |||
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]); | |||
} | |||
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); | |||
/* } */ | |||
} | |||
fclose(of); | |||
} | |||
void _analysis_output(char *base,int i,float *v,int n,int bark,int dB, | |||
ogg_int64_t off){ | |||
ogg_int64_t off){ | |||
if(analysis_noisy)_analysis_output_always(base,i,v,n,bark,dB,off); | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,14 +5,14 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: backends.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||
********************************************************************/ | |||
@@ -35,7 +35,7 @@ typedef struct{ | |||
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 *); | |||
void *buffer,float *); | |||
} vorbis_func_floor; | |||
typedef struct{ | |||
@@ -89,16 +89,16 @@ 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 *); | |||
vorbis_info_residue *); | |||
void (*free_info) (vorbis_info_residue *); | |||
void (*free_look) (vorbis_look_residue *); | |||
long **(*classx) (struct vorbis_block *,vorbis_look_residue *, | |||
float **,int *,int); | |||
int **,int *,int); | |||
int (*forward) (oggpack_buffer *,struct vorbis_block *, | |||
vorbis_look_residue *, | |||
float **,float **,int *,int,long **); | |||
vorbis_look_residue *, | |||
int **,int *,int,long **,int); | |||
int (*inverse) (struct vorbis_block *,vorbis_look_residue *, | |||
float **,int *,int); | |||
float **,int *,int); | |||
} vorbis_func_residue; | |||
typedef struct vorbis_info_residue0{ | |||
@@ -109,19 +109,19 @@ typedef struct vorbis_info_residue0{ | |||
/* 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[256]; /* list of second stage books */ | |||
float classmetric1[64]; | |||
float classmetric2[64]; | |||
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 *); | |||
oggpack_buffer *); | |||
vorbis_info_mapping *(*unpack)(vorbis_info *,oggpack_buffer *); | |||
void (*free_info) (vorbis_info_mapping *); | |||
int (*forward) (struct vorbis_block *vb); |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: bitrate.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -95,7 +95,7 @@ int vorbis_bitrate_addblock(vorbis_block *vb){ | |||
buffer the packet to keep the code path clean */ | |||
if(bm->vb)return(-1); /* one has been submitted without | |||
being claimed */ | |||
being claimed */ | |||
bm->vb=vb; | |||
return(0); | |||
} | |||
@@ -121,15 +121,15 @@ int vorbis_bitrate_addblock(vorbis_block *vb){ | |||
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; | |||
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; | |||
bm->avg_reservoir+(this_bits-avg_target_bits)<desired_fill){ | |||
choice++; | |||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||
} | |||
} | |||
@@ -147,9 +147,9 @@ int vorbis_bitrate_addblock(vorbis_block *vb){ | |||
/* 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; | |||
choice++; | |||
if(choice>=PACKETBLOBS)break; | |||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||
} | |||
} | |||
} | |||
@@ -159,9 +159,9 @@ int vorbis_bitrate_addblock(vorbis_block *vb){ | |||
/* 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--; | |||
if(choice<0)break; | |||
this_bits=oggpack_bytes(vbi->packetblob[choice])*8; | |||
} | |||
} | |||
} | |||
@@ -205,19 +205,19 @@ int vorbis_bitrate_addblock(vorbis_block *vb){ | |||
}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; | |||
} | |||
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; | |||
} | |||
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; | |||
} | |||
} | |||
} | |||
} | |||
@@ -256,4 +256,4 @@ int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,ogg_packet *op){ | |||
return(1); | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: bitrate.h 13293 2007-07-24 00:09:47Z xiphmont $ | |||
********************************************************************/ | |||
@@ -5,13 +5,13 @@ | |||
* 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-2003 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: PCM data vector blocking, windowing and dis/reassembly | |||
last mod: $Id: block.c,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: block.c 17561 2010-10-23 10:34:24Z xiphmont $ | |||
Handle windowing, overlap-add, etc of the PCM vectors. This is made | |||
more amusing by Vorbis' current two allowed block sizes. | |||
@@ -68,8 +68,8 @@ | |||
| | |endSr | |||
| |beginSr | |||
| |endSl | |||
|beginSl | |||
|beginW | |||
|beginSl | |||
|beginW | |||
*/ | |||
/* block abstraction setup *********************************************/ | |||
@@ -91,9 +91,9 @@ int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ | |||
for(i=0;i<PACKETBLOBS;i++){ | |||
if(i==PACKETBLOBS/2){ | |||
vbi->packetblob[i]=&vb->opb; | |||
vbi->packetblob[i]=&vb->opb; | |||
}else{ | |||
vbi->packetblob[i]= | |||
vbi->packetblob[i]= | |||
(oggpack_buffer*) _ogg_calloc(1,sizeof(oggpack_buffer)); | |||
} | |||
oggpack_writeinit(vbi->packetblob[i]); | |||
@@ -210,16 +210,16 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ | |||
if(!ci->fullbooks){ | |||
ci->fullbooks=(codebook*) _ogg_calloc(ci->books,sizeof(*ci->fullbooks)); | |||
for(i=0;i<ci->books;i++) | |||
vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]); | |||
vorbis_book_init_encode(ci->fullbooks+i,ci->book_param[i]); | |||
} | |||
b->psy=(vorbis_look_psy*)_ogg_calloc(ci->psys,sizeof(*b->psy)); | |||
for(i=0;i<ci->psys;i++){ | |||
_vp_psy_init(b->psy+i, | |||
ci->psy_param[i], | |||
&ci->psy_g_param, | |||
ci->blocksizes[ci->psy_param[i]->blockflag]/2, | |||
vi->rate); | |||
ci->psy_param[i], | |||
&ci->psy_g_param, | |||
ci->blocksizes[ci->psy_param[i]->blockflag]/2, | |||
vi->rate); | |||
} | |||
v->analysisp=1; | |||
@@ -228,10 +228,13 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ | |||
if(!ci->fullbooks){ | |||
ci->fullbooks=(codebook*) _ogg_calloc(ci->books,sizeof(*ci->fullbooks)); | |||
for(i=0;i<ci->books;i++){ | |||
vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]); | |||
/* decode codebooks are now standalone after init */ | |||
vorbis_staticbook_destroy(ci->book_param[i]); | |||
ci->book_param[i]=NULL; | |||
if(ci->book_param[i]==NULL) | |||
goto abort_books; | |||
if(vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i])) | |||
goto abort_books; | |||
/* decode codebooks are now standalone after init */ | |||
vorbis_staticbook_destroy(ci->book_param[i]); | |||
ci->book_param[i]=NULL; | |||
} | |||
} | |||
} | |||
@@ -270,6 +273,15 @@ static int _vds_shared_init(vorbis_dsp_state *v,vorbis_info *vi,int encp){ | |||
look(v,ci->residue_param[i]); | |||
return 0; | |||
abort_books: | |||
for(i=0;i<ci->books;i++){ | |||
if(ci->book_param[i]!=NULL){ | |||
vorbis_staticbook_destroy(ci->book_param[i]); | |||
ci->book_param[i]=NULL; | |||
} | |||
} | |||
vorbis_dsp_clear(v); | |||
return -1; | |||
} | |||
/* arbitrary settings and spec-mandated numbers get filled in here */ | |||
@@ -303,37 +315,40 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){ | |||
if(b){ | |||
if(b->ve){ | |||
_ve_envelope_clear(b->ve); | |||
_ogg_free(b->ve); | |||
_ve_envelope_clear(b->ve); | |||
_ogg_free(b->ve); | |||
} | |||
if(b->transform[0]){ | |||
mdct_clear((mdct_lookup*) b->transform[0][0]); | |||
_ogg_free(b->transform[0][0]); | |||
_ogg_free(b->transform[0]); | |||
_ogg_free(b->transform[0][0]); | |||
_ogg_free(b->transform[0]); | |||
} | |||
if(b->transform[1]){ | |||
mdct_clear((mdct_lookup*) b->transform[1][0]); | |||
_ogg_free(b->transform[1][0]); | |||
_ogg_free(b->transform[1]); | |||
_ogg_free(b->transform[1][0]); | |||
_ogg_free(b->transform[1]); | |||
} | |||
if(b->flr){ | |||
for(i=0;i<ci->floors;i++) | |||
_floor_P[ci->floor_type[i]]-> | |||
free_look(b->flr[i]); | |||
_ogg_free(b->flr); | |||
if(ci) | |||
for(i=0;i<ci->floors;i++) | |||
_floor_P[ci->floor_type[i]]-> | |||
free_look(b->flr[i]); | |||
_ogg_free(b->flr); | |||
} | |||
if(b->residue){ | |||
for(i=0;i<ci->residues;i++) | |||
_residue_P[ci->residue_type[i]]-> | |||
free_look(b->residue[i]); | |||
_ogg_free(b->residue); | |||
if(ci) | |||
for(i=0;i<ci->residues;i++) | |||
_residue_P[ci->residue_type[i]]-> | |||
free_look(b->residue[i]); | |||
_ogg_free(b->residue); | |||
} | |||
if(b->psy){ | |||
for(i=0;i<ci->psys;i++) | |||
_vp_psy_clear(b->psy+i); | |||
_ogg_free(b->psy); | |||
if(ci) | |||
for(i=0;i<ci->psys;i++) | |||
_vp_psy_clear(b->psy+i); | |||
_ogg_free(b->psy); | |||
} | |||
if(b->psy_g_look)_vp_global_free(b->psy_g_look); | |||
@@ -345,8 +360,9 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){ | |||
} | |||
if(v->pcm){ | |||
for(i=0;i<vi->channels;i++) | |||
if(v->pcm[i])_ogg_free(v->pcm[i]); | |||
if(vi) | |||
for(i=0;i<vi->channels;i++) | |||
if(v->pcm[i])_ogg_free(v->pcm[i]); | |||
_ogg_free(v->pcm); | |||
if(v->pcmret)_ogg_free(v->pcmret); | |||
} | |||
@@ -402,19 +418,30 @@ static void _preextrapolate_helper(vorbis_dsp_state *v){ | |||
for(i=0;i<v->vi->channels;i++){ | |||
/* need to run the extrapolation in reverse! */ | |||
for(j=0;j<v->pcm_current;j++) | |||
work[j]=v->pcm[i][v->pcm_current-j-1]; | |||
work[j]=v->pcm[i][v->pcm_current-j-1]; | |||
/* prime as above */ | |||
vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order); | |||
#if 0 | |||
if(v->vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0); | |||
else | |||
_analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0); | |||
}else{ | |||
_analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0); | |||
} | |||
#endif | |||
/* run the predictor filter */ | |||
vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order, | |||
order, | |||
work+v->pcm_current-v->centerW, | |||
v->centerW); | |||
order, | |||
work+v->pcm_current-v->centerW, | |||
v->centerW); | |||
for(j=0;j<v->pcm_current;j++) | |||
v->pcm[i][v->pcm_current-j-1]=work[j]; | |||
v->pcm[i][v->pcm_current-j-1]=work[j]; | |||
} | |||
} | |||
@@ -448,23 +475,23 @@ int vorbis_analysis_wrote(vorbis_dsp_state *v, int vals){ | |||
for(i=0;i<vi->channels;i++){ | |||
if(v->eofflag>order*2){ | |||
/* extrapolate with LPC to fill in */ | |||
long n; | |||
/* extrapolate with LPC to fill in */ | |||
long n; | |||
/* make a predictor filter */ | |||
n=v->eofflag; | |||
if(n>ci->blocksizes[1])n=ci->blocksizes[1]; | |||
vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order); | |||
/* make a predictor filter */ | |||
n=v->eofflag; | |||
if(n>ci->blocksizes[1])n=ci->blocksizes[1]; | |||
vorbis_lpc_from_data(v->pcm[i]+v->eofflag-n,lpc,n,order); | |||
/* run the predictor filter */ | |||
vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order, | |||
v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag); | |||
/* run the predictor filter */ | |||
vorbis_lpc_predict(lpc,v->pcm[i]+v->eofflag-order,order, | |||
v->pcm[i]+v->eofflag,v->pcm_current-v->eofflag); | |||
}else{ | |||
/* not enough data to extrapolate (unlikely to happen due to | |||
/* not enough data to extrapolate (unlikely to happen due to | |||
guarding the overlap, but bulletproof in case that | |||
assumtion goes away). zeroes will do. */ | |||
memset(v->pcm[i]+v->eofflag,0, | |||
(v->pcm_current-v->eofflag)*sizeof(*v->pcm[i])); | |||
memset(v->pcm[i]+v->eofflag,0, | |||
(v->pcm_current-v->eofflag)*sizeof(*v->pcm[i])); | |||
} | |||
} | |||
@@ -514,14 +541,14 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){ | |||
if(bp==-1){ | |||
if(v->eofflag==0)return(0); /* not enough data currently to search for a | |||
full long block */ | |||
full long block */ | |||
v->nW=0; | |||
}else{ | |||
if(ci->blocksizes[0]==ci->blocksizes[1]) | |||
v->nW=0; | |||
v->nW=0; | |||
else | |||
v->nW=bp; | |||
v->nW=bp; | |||
} | |||
} | |||
@@ -621,8 +648,8 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){ | |||
v->pcm_current-=movementW; | |||
for(i=0;i<vi->channels;i++) | |||
memmove(v->pcm[i],v->pcm[i]+movementW, | |||
v->pcm_current*sizeof(*v->pcm[i])); | |||
memmove(v->pcm[i],v->pcm[i]+movementW, | |||
v->pcm_current*sizeof(*v->pcm[i])); | |||
v->lW=v->W; | |||
@@ -630,16 +657,16 @@ int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb){ | |||
v->centerW=new_centerNext; | |||
if(v->eofflag){ | |||
v->eofflag-=movementW; | |||
if(v->eofflag<=0)v->eofflag=-1; | |||
/* do not add padding to end of stream! */ | |||
if(v->centerW>=v->eofflag){ | |||
v->granulepos+=movementW-(v->centerW-v->eofflag); | |||
}else{ | |||
v->granulepos+=movementW; | |||
} | |||
v->eofflag-=movementW; | |||
if(v->eofflag<=0)v->eofflag=-1; | |||
/* do not add padding to end of stream! */ | |||
if(v->centerW>=v->eofflag){ | |||
v->granulepos+=movementW-(v->centerW-v->eofflag); | |||
}else{ | |||
v->granulepos+=movementW; | |||
} | |||
}else{ | |||
v->granulepos+=movementW; | |||
v->granulepos+=movementW; | |||
} | |||
} | |||
} | |||
@@ -672,9 +699,11 @@ int vorbis_synthesis_restart(vorbis_dsp_state *v){ | |||
} | |||
int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ | |||
if(_vds_shared_init(v,vi,0)) return 1; | |||
if(_vds_shared_init(v,vi,0)){ | |||
vorbis_dsp_clear(v); | |||
return 1; | |||
} | |||
vorbis_synthesis_restart(v); | |||
return 0; | |||
} | |||
@@ -705,7 +734,7 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
v->sequence=vb->sequence; | |||
if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly | |||
was called on block */ | |||
was called on block */ | |||
int n=ci->blocksizes[v->W]>>(hs+1); | |||
int n0=ci->blocksizes[0]>>(hs+1); | |||
int n1=ci->blocksizes[1]>>(hs+1); | |||
@@ -733,47 +762,47 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
for(j=0;j<vi->channels;j++){ | |||
/* the overlap/add section */ | |||
if(v->lW){ | |||
if(v->W){ | |||
/* large/large */ | |||
float *w=_vorbis_window_get(b->window[1]-hs); | |||
float *pcm=v->pcm[j]+prevCenter; | |||
float *p=vb->pcm[j]; | |||
for(i=0;i<n1;i++) | |||
pcm[i]=pcm[i]*w[n1-i-1] + p[i]*w[i]; | |||
}else{ | |||
/* large/small */ | |||
float *w=_vorbis_window_get(b->window[0]-hs); | |||
float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; | |||
float *p=vb->pcm[j]; | |||
for(i=0;i<n0;i++) | |||
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i]; | |||
} | |||
if(v->W){ | |||
/* large/large */ | |||
const float *w=_vorbis_window_get(b->window[1]-hs); | |||
float *pcm=v->pcm[j]+prevCenter; | |||
float *p=vb->pcm[j]; | |||
for(i=0;i<n1;i++) | |||
pcm[i]=pcm[i]*w[n1-i-1] + p[i]*w[i]; | |||
}else{ | |||
/* large/small */ | |||
const float *w=_vorbis_window_get(b->window[0]-hs); | |||
float *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; | |||
float *p=vb->pcm[j]; | |||
for(i=0;i<n0;i++) | |||
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i]; | |||
} | |||
}else{ | |||
if(v->W){ | |||
/* small/large */ | |||
float *w=_vorbis_window_get(b->window[0]-hs); | |||
float *pcm=v->pcm[j]+prevCenter; | |||
float *p=vb->pcm[j]+n1/2-n0/2; | |||
for(i=0;i<n0;i++) | |||
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i]; | |||
for(;i<n1/2+n0/2;i++) | |||
pcm[i]=p[i]; | |||
}else{ | |||
/* small/small */ | |||
float *w=_vorbis_window_get(b->window[0]-hs); | |||
float *pcm=v->pcm[j]+prevCenter; | |||
float *p=vb->pcm[j]; | |||
for(i=0;i<n0;i++) | |||
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i]; | |||
} | |||
if(v->W){ | |||
/* small/large */ | |||
const float *w=_vorbis_window_get(b->window[0]-hs); | |||
float *pcm=v->pcm[j]+prevCenter; | |||
float *p=vb->pcm[j]+n1/2-n0/2; | |||
for(i=0;i<n0;i++) | |||
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i]; | |||
for(;i<n1/2+n0/2;i++) | |||
pcm[i]=p[i]; | |||
}else{ | |||
/* small/small */ | |||
const float *w=_vorbis_window_get(b->window[0]-hs); | |||
float *pcm=v->pcm[j]+prevCenter; | |||
float *p=vb->pcm[j]; | |||
for(i=0;i<n0;i++) | |||
pcm[i]=pcm[i]*w[n0-i-1] +p[i]*w[i]; | |||
} | |||
} | |||
/* the copy section */ | |||
{ | |||
float *pcm=v->pcm[j]+thisCenter; | |||
float *p=vb->pcm[j]+n; | |||
for(i=0;i<n;i++) | |||
pcm[i]=p[i]; | |||
float *pcm=v->pcm[j]+thisCenter; | |||
float *p=vb->pcm[j]+n; | |||
for(i=0;i<n;i++) | |||
pcm[i]=p[i]; | |||
} | |||
} | |||
@@ -792,8 +821,8 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
}else{ | |||
v->pcm_returned=prevCenter; | |||
v->pcm_current=prevCenter+ | |||
((ci->blocksizes[v->lW]/4+ | |||
ci->blocksizes[v->W]/4)>>hs); | |||
((ci->blocksizes[v->lW]/4+ | |||
ci->blocksizes[v->W]/4)>>hs); | |||
} | |||
} | |||
@@ -822,22 +851,37 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
/* is this a short page? */ | |||
if(b->sample_count>v->granulepos){ | |||
/* corner case; if this is both the first and last audio page, | |||
then spec says the end is cut, not beginning */ | |||
if(vb->eofflag){ | |||
/* trim the end */ | |||
/* no preceeding granulepos; assume we started at zero (we'd | |||
have to in a short single-page stream) */ | |||
/* granulepos could be -1 due to a seek, but that would result | |||
in a long count, not short count */ | |||
v->pcm_current-=(b->sample_count-v->granulepos)>>hs; | |||
}else{ | |||
/* trim the beginning */ | |||
v->pcm_returned+=(b->sample_count-v->granulepos)>>hs; | |||
if(v->pcm_returned>v->pcm_current) | |||
v->pcm_returned=v->pcm_current; | |||
} | |||
/* corner case; if this is both the first and last audio page, | |||
then spec says the end is cut, not beginning */ | |||
long extra=b->sample_count-vb->granulepos; | |||
/* we use ogg_int64_t for granule positions because a | |||
uint64 isn't universally available. Unfortunately, | |||
that means granposes can be 'negative' and result in | |||
extra being negative */ | |||
if(extra<0) | |||
extra=0; | |||
if(vb->eofflag){ | |||
/* trim the end */ | |||
/* no preceding granulepos; assume we started at zero (we'd | |||
have to in a short single-page stream) */ | |||
/* granulepos could be -1 due to a seek, but that would result | |||
in a long count, not short count */ | |||
/* Guard against corrupt/malicious frames that set EOP and | |||
a backdated granpos; don't rewind more samples than we | |||
actually have */ | |||
if(extra > (v->pcm_current - v->pcm_returned)<<hs) | |||
extra = (v->pcm_current - v->pcm_returned)<<hs; | |||
v->pcm_current-=extra>>hs; | |||
}else{ | |||
/* trim the beginning */ | |||
v->pcm_returned+=extra>>hs; | |||
if(v->pcm_returned>v->pcm_current) | |||
v->pcm_returned=v->pcm_current; | |||
} | |||
} | |||
@@ -847,16 +891,30 @@ int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ | |||
if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ | |||
if(v->granulepos>vb->granulepos){ | |||
long extra=v->granulepos-vb->granulepos; | |||
if(extra) | |||
if(vb->eofflag){ | |||
/* partial last frame. Strip the extra samples off */ | |||
v->pcm_current-=extra>>hs; | |||
} /* else {Shouldn't happen *unless* the bitstream is out of | |||
spec. Either way, believe the bitstream } */ | |||
long extra=v->granulepos-vb->granulepos; | |||
if(extra) | |||
if(vb->eofflag){ | |||
/* partial last frame. Strip the extra samples off */ | |||
/* Guard against corrupt/malicious frames that set EOP and | |||
a backdated granpos; don't rewind more samples than we | |||
actually have */ | |||
if(extra > (v->pcm_current - v->pcm_returned)<<hs) | |||
extra = (v->pcm_current - v->pcm_returned)<<hs; | |||
/* we use ogg_int64_t for granule positions because a | |||
uint64 isn't universally available. Unfortunately, | |||
that means granposes can be 'negative' and result in | |||
extra being negative */ | |||
if(extra<0) | |||
extra=0; | |||
v->pcm_current-=extra>>hs; | |||
} /* else {Shouldn't happen *unless* the bitstream is out of | |||
spec. Either way, believe the bitstream } */ | |||
} /* else {Shouldn't happen *unless* the bitstream is out of | |||
spec. Either way, believe the bitstream } */ | |||
spec. Either way, believe the bitstream } */ | |||
v->granulepos=vb->granulepos; | |||
} | |||
} | |||
@@ -876,7 +934,7 @@ int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm){ | |||
if(pcm){ | |||
int i; | |||
for(i=0;i<vi->channels;i++) | |||
v->pcmret[i]=v->pcm[i]+v->pcm_returned; | |||
v->pcmret[i]=v->pcm[i]+v->pcm_returned; | |||
*pcm=v->pcmret; | |||
} | |||
return(v->pcm_current-v->pcm_returned); | |||
@@ -923,9 +981,9 @@ int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){ | |||
for(j=0;j<vi->channels;j++){ | |||
float *p=v->pcm[j]; | |||
for(i=0;i<n1;i++){ | |||
float temp=p[i]; | |||
p[i]=p[i+n1]; | |||
p[i+n1]=temp; | |||
float temp=p[i]; | |||
p[i]=p[i+n1]; | |||
p[i+n1]=temp; | |||
} | |||
} | |||
@@ -941,7 +999,7 @@ int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){ | |||
float *s=v->pcm[j]; | |||
float *d=v->pcm[j]+(n1-n0)/2; | |||
for(i=(n1+n0)/2-1;i>=0;--i) | |||
d[i]=s[i]; | |||
d[i]=s[i]; | |||
} | |||
v->pcm_returned+=(n1-n0)/2; | |||
v->pcm_current+=(n1-n0)/2; | |||
@@ -949,10 +1007,10 @@ int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm){ | |||
if(v->lW==0){ | |||
/* short/short */ | |||
for(j=0;j<vi->channels;j++){ | |||
float *s=v->pcm[j]; | |||
float *d=v->pcm[j]+n1-n0; | |||
for(i=n0-1;i>=0;--i) | |||
d[i]=s[i]; | |||
float *s=v->pcm[j]; | |||
float *d=v->pcm[j]+n1-n0; | |||
for(i=n0-1;i>=0;--i) | |||
d[i]=s[i]; | |||
} | |||
v->pcm_returned+=n1-n0; | |||
v->pcm_current+=n1-n0; | |||
@@ -980,4 +1038,4 @@ float *vorbis_window(vorbis_dsp_state *v,int W){ | |||
return _vorbis_window_get(b->window[W]-hs); | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: codebook.c 17553 2010-10-21 17:54:26Z tterribe $ | |||
********************************************************************/ | |||
@@ -61,9 +61,9 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){ | |||
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)); | |||
count=i; | |||
} | |||
} | |||
} | |||
oggpack_write(opb,i-count,_ilog(c->entries-count)); | |||
@@ -82,16 +82,16 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){ | |||
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); | |||
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); | |||
} | |||
if(c->lengthlist[i]==0){ | |||
oggpack_write(opb,0,1); | |||
}else{ | |||
oggpack_write(opb,1,1); | |||
oggpack_write(opb,c->lengthlist[i]-1,5); | |||
} | |||
} | |||
} | |||
} | |||
@@ -122,21 +122,21 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){ | |||
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; | |||
/* 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; | |||
/* every value (c->entries*c->dim total) specified explicitly */ | |||
quantvals=c->entries*c->dim; | |||
break; | |||
default: /* NOT_REACHABLE */ | |||
quantvals=-1; | |||
quantvals=-1; | |||
} | |||
/* quantized values */ | |||
for(i=0;i<quantvals;i++) | |||
oggpack_write(opb,labs(c->quantlist[i]),c->q_quant); | |||
oggpack_write(opb,labs(c->quantlist[i]),c->q_quant); | |||
} | |||
break; | |||
@@ -150,9 +150,9 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){ | |||
/* unpacks a codebook from the packet buffer into the codebook struct, | |||
readies the codebook auxiliary structures for decode *************/ | |||
int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ | |||
static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){ | |||
long i,j; | |||
memset(s,0,sizeof(*s)); | |||
static_codebook *s=(static_codebook*)_ogg_calloc(1,sizeof(*s)); | |||
s->allocedp=1; | |||
/* make sure alignment is correct */ | |||
@@ -163,52 +163,66 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ | |||
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: | |||
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(oggpack_read(opb,1)){ | |||
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; | |||
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; | |||
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; | |||
for(j=0;j<num && i<s->entries;j++,i++) | |||
s->lengthlist[i]=length; | |||
length++; | |||
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 */ | |||
return(-1); | |||
goto _eofout; | |||
} | |||
/* Do we have a mapping to unpack? */ | |||
@@ -224,22 +238,25 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ | |||
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=_book_maptype1_quantvals(s); | |||
break; | |||
quantvals=(s->dim==0?0:_book_maptype1_quantvals(s)); | |||
break; | |||
case 2: | |||
quantvals=s->entries*s->dim; | |||
break; | |||
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); | |||
s->quantlist[i]=oggpack_read(opb,s->q_quant); | |||
if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout; | |||
} | |||
@@ -249,51 +266,21 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){ | |||
} | |||
/* all set */ | |||
return(0); | |||
return(s); | |||
_errout: | |||
_eofout: | |||
vorbis_staticbook_clear(s); | |||
return(-1); | |||
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]); | |||
} | |||
/* One the encode side, our vector writers are each designed for a | |||
specific purpose, and the encoder is not flexible without modification: | |||
The LSP vector coder uses a single stage nearest-match with no | |||
interleave, so no step and no error return. This is specced by floor0 | |||
and doesn't change. | |||
Residue0 encoding interleaves, uses multiple stages, and each stage | |||
peels of a specific amount of resolution from a lattice (thus we want | |||
to match by threshold, not nearest match). Residue doesn't *have* to | |||
be encoded that way, but to change it, one will need to add more | |||
infrastructure on the encode side (decode side is specced and simpler) */ | |||
/* floor0 LSP (single stage, non interleaved, nearest match) */ | |||
/* returns entry number and *modifies a* to the quantization value *****/ | |||
int vorbis_book_errorv(codebook *book,float *a){ | |||
int dim=book->dim,k; | |||
int best=_best(book,a,1); | |||
for(k=0;k<dim;k++) | |||
a[k]=(book->valuelist+best*dim)[k]; | |||
return(best); | |||
} | |||
/* returns the number of bits and *modifies a* to the quantization value *****/ | |||
int vorbis_book_encodev(codebook *book,int best,float *a,oggpack_buffer *b){ | |||
int k,dim=book->dim; | |||
for(k=0;k<dim;k++) | |||
a[k]=(book->valuelist+best*dim)[k]; | |||
return(vorbis_book_encode(book,best,b)); | |||
} | |||
/* 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 | |||
@@ -302,6 +289,13 @@ int vorbis_book_encodev(codebook *book,int best,float *a,oggpack_buffer *b){ | |||
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; | |||
@@ -330,14 +324,14 @@ STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){ | |||
/* bisect search for the codeword in the ordered list */ | |||
{ | |||
ogg_uint32_t testword=ogg_bitreverse((ogg_uint32_t)lok); | |||
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]); | |||
@@ -346,6 +340,7 @@ STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){ | |||
} | |||
oggpack_adv(b, read); | |||
return(-1); | |||
} | |||
@@ -365,250 +360,126 @@ STIN long decode_packed_entry_number(codebook *book, oggpack_buffer *b){ | |||
/* returns the [original, not compacted] entry number or -1 on eof *********/ | |||
long vorbis_book_decode(codebook *book, oggpack_buffer *b){ | |||
long packed_entry=decode_packed_entry_number(book,b); | |||
if(packed_entry>=0) | |||
return(book->dec_index[packed_entry]); | |||
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(packed_entry); | |||
return(-1); | |||
} | |||
/* returns 0 on OK or -1 on eof *************************************/ | |||
long vorbis_book_decodevs_add(codebook *book,float *a,oggpack_buffer *b,int n){ | |||
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; | |||
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;j<step;j++) | |||
a[o+j]+=t[j][i]; | |||
} | |||
for(i=0,o=0;i<book->dim;i++,o+=step) | |||
for (j=0;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){ | |||
int i,j,entry; | |||
float *t; | |||
if(book->used_entries>0){ | |||
int i,j,entry; | |||
float *t; | |||
if(book->dim>8){ | |||
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{ | |||
for(i=0;i<n;){ | |||
entry = decode_packed_entry_number(book,b); | |||
if(entry==-1)return(-1); | |||
t = book->valuelist+entry*book->dim; | |||
j=0; | |||
switch((int)book->dim){ | |||
case 8: | |||
a[i++]+=t[j++]; | |||
case 7: | |||
a[i++]+=t[j++]; | |||
case 6: | |||
a[i++]+=t[j++]; | |||
case 5: | |||
a[i++]+=t[j++]; | |||
case 4: | |||
a[i++]+=t[j++]; | |||
case 3: | |||
a[i++]+=t[j++]; | |||
case 2: | |||
a[i++]+=t[j++]; | |||
case 1: | |||
a[i++]+=t[j++]; | |||
case 0: | |||
break; | |||
} | |||
} | |||
} | |||
} | |||
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; | |||
if(book->dim>8){ | |||
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++]; | |||
a[i++]=t[j++]; | |||
} | |||
}else{ | |||
int i,j; | |||
for(i=0;i<n;){ | |||
entry = decode_packed_entry_number(book,b); | |||
if(entry==-1)return(-1); | |||
t = book->valuelist+entry*book->dim; | |||
j=0; | |||
switch((int)book->dim){ | |||
case 8: | |||
a[i++]+=t[j++]; | |||
case 7: | |||
a[i++]+=t[j++]; | |||
case 6: | |||
a[i++]+=t[j++]; | |||
case 5: | |||
a[i++]+=t[j++]; | |||
case 4: | |||
a[i++]+=t[j++]; | |||
case 3: | |||
a[i++]+=t[j++]; | |||
case 2: | |||
a[i++]+=t[j++]; | |||
case 1: | |||
a[i++]+=t[j++]; | |||
case 0: | |||
break; | |||
} | |||
for (j=0;j<book->dim;) | |||
a[i++]=0.f; | |||
} | |||
} | |||
return(0); | |||
} | |||
long vorbis_book_decodev_set(codebook *book,float *a,oggpack_buffer *b,int n){ | |||
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++]; | |||
} | |||
return(0); | |||
} | |||
long vorbis_book_decodevv_add(codebook *book,float **a,long offset,int ch, | |||
oggpack_buffer *b,int n){ | |||
oggpack_buffer *b,int n){ | |||
long i,j,entry; | |||
int chptr=0; | |||
for(i=offset/ch;i<(offset+n)/ch;){ | |||
entry = decode_packed_entry_number(book,b); | |||
if(entry==-1)return(-1); | |||
{ | |||
const float *t = book->valuelist+entry*book->dim; | |||
for (j=0;j<book->dim;j++){ | |||
a[chptr++][i]+=t[j]; | |||
if(chptr==ch){ | |||
chptr=0; | |||
i++; | |||
} | |||
if(book->used_entries>0){ | |||
for(i=offset/ch;i<(offset+n)/ch;){ | |||
entry = decode_packed_entry_number(book,b); | |||
if(entry==-1)return(-1); | |||
{ | |||
const float *t = book->valuelist+entry*book->dim; | |||
for (j=0;j<book->dim;j++){ | |||
a[chptr++][i]+=t[j]; | |||
if(chptr==ch){ | |||
chptr=0; | |||
i++; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
return(0); | |||
} | |||
#ifdef _V_SELFTEST | |||
/* Simple enough; pack a few candidate codebooks, unpack them. Code a | |||
number of vectors through (keeping track of the quantized values), | |||
and decode using the unpacked book. quantized version of in should | |||
exactly equal out */ | |||
#include <stdio.h> | |||
#include "vorbis/book/lsp20_0.vqh" | |||
#include "vorbis/book/res0a_13.vqh" | |||
#define TESTSIZE 40 | |||
float test1[TESTSIZE]={ | |||
0.105939f, | |||
0.215373f, | |||
0.429117f, | |||
0.587974f, | |||
0.181173f, | |||
0.296583f, | |||
0.515707f, | |||
0.715261f, | |||
0.162327f, | |||
0.263834f, | |||
0.342876f, | |||
0.406025f, | |||
0.103571f, | |||
0.223561f, | |||
0.368513f, | |||
0.540313f, | |||
0.136672f, | |||
0.395882f, | |||
0.587183f, | |||
0.652476f, | |||
0.114338f, | |||
0.417300f, | |||
0.525486f, | |||
0.698679f, | |||
0.147492f, | |||
0.324481f, | |||
0.643089f, | |||
0.757582f, | |||
0.139556f, | |||
0.215795f, | |||
0.324559f, | |||
0.399387f, | |||
0.120236f, | |||
0.267420f, | |||
0.446940f, | |||
0.608760f, | |||
0.115587f, | |||
0.287234f, | |||
0.571081f, | |||
0.708603f, | |||
}; | |||
float test3[TESTSIZE]={ | |||
0,1,-2,3,4,-5,6,7,8,9, | |||
8,-2,7,-1,4,6,8,3,1,-9, | |||
10,11,12,13,14,15,26,17,18,19, | |||
30,-25,-30,-1,-5,-32,4,3,-2,0}; | |||
static_codebook *testlist[]={&_vq_book_lsp20_0, | |||
&_vq_book_res0a_13,NULL}; | |||
float *testvec[]={test1,test3}; | |||
int main(){ | |||
oggpack_buffer write; | |||
oggpack_buffer read; | |||
long ptr=0,i; | |||
oggpack_writeinit(&write); | |||
fprintf(stderr,"Testing codebook abstraction...:\n"); | |||
while(testlist[ptr]){ | |||
codebook c; | |||
static_codebook s; | |||
float *qv=alloca(sizeof(*qv)*TESTSIZE); | |||
float *iv=alloca(sizeof(*iv)*TESTSIZE); | |||
memcpy(qv,testvec[ptr],sizeof(*qv)*TESTSIZE); | |||
memset(iv,0,sizeof(*iv)*TESTSIZE); | |||
fprintf(stderr,"\tpacking/coding %ld... ",ptr); | |||
/* pack the codebook, write the testvector */ | |||
oggpack_reset(&write); | |||
vorbis_book_init_encode(&c,testlist[ptr]); /* get it into memory | |||
we can write */ | |||
vorbis_staticbook_pack(testlist[ptr],&write); | |||
fprintf(stderr,"Codebook size %ld bytes... ",oggpack_bytes(&write)); | |||
for(i=0;i<TESTSIZE;i+=c.dim){ | |||
int best=_best(&c,qv+i,1); | |||
vorbis_book_encodev(&c,best,qv+i,&write); | |||
} | |||
vorbis_book_clear(&c); | |||
fprintf(stderr,"OK.\n"); | |||
fprintf(stderr,"\tunpacking/decoding %ld... ",ptr); | |||
/* transfer the write data to a read buffer and unpack/read */ | |||
oggpack_readinit(&read,oggpack_get_buffer(&write),oggpack_bytes(&write)); | |||
if(vorbis_staticbook_unpack(&read,&s)){ | |||
fprintf(stderr,"Error unpacking codebook.\n"); | |||
exit(1); | |||
} | |||
if(vorbis_book_init_decode(&c,&s)){ | |||
fprintf(stderr,"Error initializing codebook.\n"); | |||
exit(1); | |||
} | |||
for(i=0;i<TESTSIZE;i+=c.dim) | |||
if(vorbis_book_decodev_set(&c,iv+i,&read,c.dim)==-1){ | |||
fprintf(stderr,"Error reading codebook test data (EOP).\n"); | |||
exit(1); | |||
} | |||
for(i=0;i<TESTSIZE;i++) | |||
if(fabs(qv[i]-iv[i])>.000001){ | |||
fprintf(stderr,"read (%g) != written (%g) at position (%ld)\n", | |||
iv[i],qv[i],i); | |||
exit(1); | |||
} | |||
fprintf(stderr,"OK\n"); | |||
ptr++; | |||
} | |||
/* The above is the trivial stuff; now try unquantizing a log scale codebook */ | |||
exit(0); | |||
} | |||
#endif | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: codebook.h 17030 2010-03-25 06:52:55Z xiphmont $ | |||
********************************************************************/ | |||
@@ -40,8 +40,8 @@ typedef struct static_codebook{ | |||
/* mapping ***************************************************************/ | |||
int maptype; /* 0=none | |||
1=implicitly populated values from map column | |||
2=listed arbitrary values */ | |||
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 */ | |||
@@ -50,52 +50,11 @@ typedef struct static_codebook{ | |||
int q_sequencep; /* bitflag */ | |||
long *quantlist; /* map == 1: (int)(entries^(1/dim)) element column map | |||
map == 2: list of dim*entries quantized entry vals | |||
*/ | |||
/* encode helpers ********************************************************/ | |||
struct encode_aux_nearestmatch *nearest_tree; | |||
struct encode_aux_threshmatch *thresh_tree; | |||
struct encode_aux_pigeonhole *pigeon_tree; | |||
map == 2: list of dim*entries quantized entry vals | |||
*/ | |||
int allocedp; | |||
} static_codebook; | |||
/* this structures an arbitrary trained book to quickly find the | |||
nearest cell match */ | |||
typedef struct encode_aux_nearestmatch{ | |||
/* pre-calculated partitioning tree */ | |||
long *ptr0; | |||
long *ptr1; | |||
long *p; /* decision points (each is an entry) */ | |||
long *q; /* decision points (each is an entry) */ | |||
long aux; /* number of tree entries */ | |||
long alloc; | |||
} encode_aux_nearestmatch; | |||
/* assumes a maptype of 1; encode side only, so that's OK */ | |||
typedef struct encode_aux_threshmatch{ | |||
float *quantthresh; | |||
long *quantmap; | |||
int quantvals; | |||
int threshvals; | |||
} encode_aux_threshmatch; | |||
typedef struct encode_aux_pigeonhole{ | |||
float min; | |||
float del; | |||
int mapentries; | |||
int quantvals; | |||
long *pigeonmap; | |||
long fittotal; | |||
long *fitlist; | |||
long *fitmap; | |||
long *fitlength; | |||
} encode_aux_pigeonhole; | |||
typedef struct codebook{ | |||
long dim; /* codebook dimensions (elements per vector) */ | |||
long entries; /* codebook entries */ | |||
@@ -114,9 +73,12 @@ typedef struct codebook{ | |||
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_clear(static_codebook *b); | |||
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); | |||
@@ -137,23 +99,20 @@ extern long vorbis_book_codelen(codebook *book,int entry); | |||
extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b); | |||
extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c); | |||
extern static_codebook *vorbis_staticbook_unpack(oggpack_buffer *b); | |||
extern int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b); | |||
extern int vorbis_book_errorv(codebook *book, float *a); | |||
extern int vorbis_book_encodev(codebook *book, int best,float *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); | |||
oggpack_buffer *b,int n); | |||
extern long vorbis_book_decodev_set(codebook *book, float *a, | |||
oggpack_buffer *b,int n); | |||
oggpack_buffer *b,int n); | |||
extern long vorbis_book_decodev_add(codebook *book, float *a, | |||
oggpack_buffer *b,int n); | |||
oggpack_buffer *b,int n); | |||
extern long vorbis_book_decodevv_add(codebook *book, float **a, | |||
long off,int ch, | |||
oggpack_buffer *b,int n); | |||
long off,int ch, | |||
oggpack_buffer *b,int n); | |||
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: codec_internal.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -34,9 +34,9 @@ typedef struct vorbis_block_internal{ | |||
int blocktype; | |||
oggpack_buffer *packetblob[PACKETBLOBS]; /* initialized, must be freed; | |||
blob [PACKETBLOBS/2] points to | |||
the oggpack_buffer in the | |||
main vorbis_block */ | |||
blob [PACKETBLOBS/2] points to | |||
the oggpack_buffer in the | |||
main vorbis_block */ | |||
} vorbis_block_internal; | |||
typedef void vorbis_look_floor; | |||
@@ -153,4 +153,35 @@ typedef struct 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 |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: envelope.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -92,11 +92,10 @@ void _ve_envelope_clear(envelope_lookup *e){ | |||
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 pos){ | |||
vorbis_info_psy_global *gi, | |||
float *data, | |||
envelope_band *bands, | |||
envelope_filter_state *filters){ | |||
long n=ve->winlength; | |||
int ret=0; | |||
long i,j; | |||
@@ -187,10 +186,10 @@ static int _ve_amp(envelope_lookup *ve, | |||
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]); | |||
p--; | |||
if(p<0)p+=VE_AMP; | |||
premax=max(premax,filters[j].ampbuf[p]); | |||
premin=min(premin,filters[j].ampbuf[p]); | |||
} | |||
valmin=postmin-premin; | |||
@@ -244,7 +243,7 @@ long _ve_envelope_search(vorbis_dsp_state *v){ | |||
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,j); | |||
ret|=_ve_amp(ve,gi,pcm,ve->band,ve->filter+i*VE_BANDS); | |||
} | |||
ve->mark[j+VE_POST]=0; | |||
@@ -280,50 +279,50 @@ long _ve_envelope_search(vorbis_dsp_state *v){ | |||
ve->cursor=j; | |||
if(ve->mark[j/ve->searchstep]){ | |||
if(j>centerW){ | |||
if(j>centerW){ | |||
#if 0 | |||
if(j>ve->curmark){ | |||
float *marker=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++; | |||
} | |||
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); | |||
} | |||
ve->curmark=j; | |||
if(j>=testW)return(1); | |||
return(0); | |||
} | |||
} | |||
j+=ve->searchstep; | |||
} | |||
@@ -360,7 +359,7 @@ int _ve_envelope_mark(vorbis_dsp_state *v){ | |||
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 */ | |||
ahead of ve->current */ | |||
int smallshift=shift/e->searchstep; | |||
memmove(e->mark,e->mark+smallshift,(smallsize-smallshift)*sizeof(*e->mark)); | |||
@@ -368,8 +367,8 @@ void _ve_envelope_shift(envelope_lookup *e,long shift){ | |||
#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)); | |||
e->filter[i].markers+smallshift, | |||
(1024-smallshift)*sizeof(*(*e->filter).markers)); | |||
totalshift+=shift; | |||
#endif | |||
@@ -380,4 +379,4 @@ void _ve_envelope_shift(envelope_lookup *e,long shift){ | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: envelope.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: floor0.c 17558 2010-10-22 00:24:41Z tterribe $ | |||
********************************************************************/ | |||
@@ -95,6 +95,8 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ | |||
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); | |||
@@ -112,8 +114,8 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){ | |||
linear block and mapping sizes */ | |||
static void floor0_map_lazy_init(vorbis_block *vb, | |||
vorbis_info_floor *infoX, | |||
vorbis_look_floor0 *look){ | |||
vorbis_info_floor *infoX, | |||
vorbis_look_floor0 *look){ | |||
if(!look->linearmap[vb->W]){ | |||
vorbis_dsp_state *vd=vb->vd; | |||
vorbis_info *vi=vd->vi; | |||
@@ -136,7 +138,7 @@ static void floor0_map_lazy_init(vorbis_block *vb, | |||
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 */ | |||
*scale); /* bark numbers represent band edges */ | |||
if(val>=look->ln)val=look->ln-1; /* guard against the approximation */ | |||
look->linearmap[W][j]=val; | |||
} | |||
@@ -146,8 +148,8 @@ static void floor0_map_lazy_init(vorbis_block *vb, | |||
} | |||
static vorbis_look_floor *floor0_look(vorbis_dsp_state *vd, | |||
vorbis_info_floor *i){ | |||
vorbis_info_floor0 *info=(vorbis_info_floor0*)i; | |||
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; | |||
@@ -180,10 +182,10 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){ | |||
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; | |||
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]; | |||
for(k=0;k<b->dim;k++,j++)lsp[j]+=last; | |||
last=lsp[j-1]; | |||
} | |||
lsp[look->m]=amp; | |||
@@ -195,7 +197,7 @@ static void *floor0_inverse1(vorbis_block *vb,vorbis_look_floor *i){ | |||
} | |||
static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, | |||
void *memo,float *out){ | |||
void *memo,float *out){ | |||
vorbis_look_floor0 *look=(vorbis_look_floor0 *)i; | |||
vorbis_info_floor0 *info=look->vi; | |||
@@ -207,10 +209,10 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, | |||
/* 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); | |||
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]); | |||
@@ -218,10 +220,10 @@ static int floor0_inverse2(vorbis_block *vb,vorbis_look_floor *i, | |||
} | |||
/* export hooks */ | |||
vorbis_func_floor floor0_exportbundle={ | |||
const vorbis_func_floor floor0_exportbundle={ | |||
NULL,&floor0_unpack,&floor0_look,&floor0_free_info, | |||
&floor0_free_look,&floor0_inverse1,&floor0_inverse2 | |||
}; | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: highlevel encoder setup struct seperated out for vorbisenc clarity | |||
last mod: $Id: highlevel.h,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
function: highlevel encoder setup struct separated out for vorbisenc clarity | |||
last mod: $Id: highlevel.h 17195 2010-05-05 21:49:51Z giles $ | |||
********************************************************************/ | |||
@@ -23,14 +23,14 @@ typedef struct highlevel_byblocktype { | |||
} highlevel_byblocktype; | |||
typedef struct highlevel_encode_setup { | |||
void *setup; | |||
int set_in_stone; | |||
const void *setup; | |||
double base_setting; | |||
double long_setting; | |||
double short_setting; | |||
double impulse_noisetune; | |||
/* bitrate management below all settable */ | |||
float req; | |||
int managed; | |||
long bitrate_min; | |||
long bitrate_av; | |||
@@ -41,9 +41,11 @@ typedef struct highlevel_encode_setup { | |||
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; |
@@ -5,13 +5,13 @@ | |||
* 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-2003 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: maintain the info structure, info <-> header packets | |||
last mod: $Id: info.c,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: info.c 17584 2010-11-01 19:26:16Z xiphmont $ | |||
********************************************************************/ | |||
@@ -34,8 +34,12 @@ | |||
#include "misc.h" | |||
#include "os.h" | |||
#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.2" | |||
#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20101101 (Schaufenugget)" | |||
static void _v_writestring(oggpack_buffer *o, const char *s, int bytes){ | |||
/* helpers */ | |||
static void _v_writestring(oggpack_buffer *o,const char *s, int bytes){ | |||
while(bytes--){ | |||
oggpack_write(o,*s++,8); | |||
@@ -52,11 +56,11 @@ void vorbis_comment_init(vorbis_comment *vc){ | |||
memset(vc,0,sizeof(*vc)); | |||
} | |||
void vorbis_comment_add(vorbis_comment *vc,char *comment){ | |||
void vorbis_comment_add(vorbis_comment *vc,const char *comment){ | |||
vc->user_comments=(char**)_ogg_realloc(vc->user_comments, | |||
(vc->comments+2)*sizeof(*vc->user_comments)); | |||
(vc->comments+2)*sizeof(*vc->user_comments)); | |||
vc->comment_lengths=(int*)_ogg_realloc(vc->comment_lengths, | |||
(vc->comments+2)*sizeof(*vc->comment_lengths)); | |||
(vc->comments+2)*sizeof(*vc->comment_lengths)); | |||
vc->comment_lengths[vc->comments]=strlen(comment); | |||
vc->user_comments[vc->comments]=(char*)_ogg_malloc(vc->comment_lengths[vc->comments]+1); | |||
strcpy(vc->user_comments[vc->comments], comment); | |||
@@ -64,7 +68,7 @@ void vorbis_comment_add(vorbis_comment *vc,char *comment){ | |||
vc->user_comments[vc->comments]=NULL; | |||
} | |||
void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, char *contents){ | |||
void vorbis_comment_add_tag(vorbis_comment *vc, const char *tag, const char *contents){ | |||
char *comment=(char*)alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */ | |||
strcpy(comment, tag); | |||
strcat(comment, "="); | |||
@@ -84,7 +88,7 @@ static int tagcompare(const char *s1, const char *s2, int n){ | |||
return 0; | |||
} | |||
char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ | |||
char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count){ | |||
long i; | |||
int found = 0; | |||
int taglen = strlen(tag)+1; /* +1 for the = we append */ | |||
@@ -96,16 +100,16 @@ char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){ | |||
for(i=0;i<vc->comments;i++){ | |||
if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ | |||
if(count == found) | |||
/* We return a pointer to the data, not a copy */ | |||
return vc->user_comments[i] + taglen; | |||
/* We return a pointer to the data, not a copy */ | |||
return vc->user_comments[i] + taglen; | |||
else | |||
found++; | |||
found++; | |||
} | |||
} | |||
return NULL; /* didn't find anything */ | |||
} | |||
int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ | |||
int vorbis_comment_query_count(vorbis_comment *vc, const char *tag){ | |||
int i,count=0; | |||
int taglen = strlen(tag)+1; /* +1 for the = we append */ | |||
char *fulltag = (char*)alloca(taglen+1); | |||
@@ -123,16 +127,18 @@ int vorbis_comment_query_count(vorbis_comment *vc, char *tag){ | |||
void vorbis_comment_clear(vorbis_comment *vc){ | |||
if(vc){ | |||
long i; | |||
for(i=0;i<vc->comments;i++) | |||
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); | |||
if(vc->user_comments)_ogg_free(vc->user_comments); | |||
if(vc->comment_lengths)_ogg_free(vc->comment_lengths); | |||
if(vc->user_comments){ | |||
for(i=0;i<vc->comments;i++) | |||
if(vc->user_comments[i])_ogg_free(vc->user_comments[i]); | |||
_ogg_free(vc->user_comments); | |||
} | |||
if(vc->comment_lengths)_ogg_free(vc->comment_lengths); | |||
if(vc->vendor)_ogg_free(vc->vendor); | |||
memset(vc,0,sizeof(*vc)); | |||
} | |||
memset(vc,0,sizeof(*vc)); | |||
} | |||
/* blocksize 0 is guaranteed to be short, 1 is guarantted to be long. | |||
/* blocksize 0 is guaranteed to be short, 1 is guaranteed to be long. | |||
They may be equal, but short will never ge greater than long */ | |||
int vorbis_info_blocksize(vorbis_info *vi,int zo){ | |||
codec_setup_info *ci = (codec_setup_info*)vi->codec_setup; | |||
@@ -155,24 +161,33 @@ void vorbis_info_clear(vorbis_info *vi){ | |||
if(ci->mode_param[i])_ogg_free(ci->mode_param[i]); | |||
for(i=0;i<ci->maps;i++) /* unpack does the range checking */ | |||
_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); | |||
if(ci->map_param[i]) /* this may be cleaning up an aborted | |||
unpack, in which case the below type | |||
cannot be trusted */ | |||
_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]); | |||
for(i=0;i<ci->floors;i++) /* unpack does the range checking */ | |||
_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); | |||
if(ci->floor_param[i]) /* this may be cleaning up an aborted | |||
unpack, in which case the below type | |||
cannot be trusted */ | |||
_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]); | |||
for(i=0;i<ci->residues;i++) /* unpack does the range checking */ | |||
_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); | |||
if(ci->residue_param[i]) /* this may be cleaning up an aborted | |||
unpack, in which case the below type | |||
cannot be trusted */ | |||
_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]); | |||
for(i=0;i<ci->books;i++){ | |||
if(ci->book_param[i]){ | |||
/* knows if the book was not alloced */ | |||
vorbis_staticbook_destroy(ci->book_param[i]); | |||
/* knows if the book was not alloced */ | |||
vorbis_staticbook_destroy(ci->book_param[i]); | |||
} | |||
if(ci->fullbooks) | |||
vorbis_book_clear(ci->fullbooks+i); | |||
vorbis_book_clear(ci->fullbooks+i); | |||
} | |||
if(ci->fullbooks) | |||
_ogg_free(ci->fullbooks); | |||
_ogg_free(ci->fullbooks); | |||
for(i=0;i<ci->psys;i++) | |||
_vi_psy_free(ci->psy_param[i]); | |||
@@ -204,8 +219,9 @@ static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){ | |||
if(vi->rate<1)goto err_out; | |||
if(vi->channels<1)goto err_out; | |||
if(ci->blocksizes[0]<8)goto err_out; | |||
if(ci->blocksizes[0]<64)goto err_out; | |||
if(ci->blocksizes[1]<ci->blocksizes[0])goto err_out; | |||
if(ci->blocksizes[1]>8192)goto err_out; | |||
if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */ | |||
@@ -219,17 +235,21 @@ static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){ | |||
int i; | |||
int vendorlen=oggpack_read(opb,32); | |||
if(vendorlen<0)goto err_out; | |||
if(vendorlen>opb->storage-8)goto err_out; | |||
vc->vendor=(char*)_ogg_calloc(vendorlen+1,1); | |||
_v_readstring(opb,vc->vendor,vendorlen); | |||
vc->comments=oggpack_read(opb,32); | |||
if(vc->comments<0)goto err_out; | |||
i=oggpack_read(opb,32); | |||
if(i<0)goto err_out; | |||
if(i>((opb->storage-oggpack_bytes(opb))>>2))goto err_out; | |||
vc->comments=i; | |||
vc->user_comments=(char**)_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments)); | |||
vc->comment_lengths=(int*)_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths)); | |||
for(i=0;i<vc->comments;i++){ | |||
int len=oggpack_read(opb,32); | |||
if(len<0)goto err_out; | |||
vc->comment_lengths[i]=len; | |||
if(len>opb->storage-oggpack_bytes(opb))goto err_out; | |||
vc->comment_lengths[i]=len; | |||
vc->user_comments[i]=(char*)_ogg_calloc(len+1,1); | |||
_v_readstring(opb,vc->user_comments[i],len); | |||
} | |||
@@ -250,15 +270,16 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ | |||
/* codebooks */ | |||
ci->books=oggpack_read(opb,8)+1; | |||
/*ci->book_param=_ogg_calloc(ci->books,sizeof(*ci->book_param));*/ | |||
if(ci->books<=0)goto err_out; | |||
for(i=0;i<ci->books;i++){ | |||
ci->book_param[i]=(static_codebook*)_ogg_calloc(1,sizeof(*ci->book_param[i])); | |||
if(vorbis_staticbook_unpack(opb,ci->book_param[i]))goto err_out; | |||
ci->book_param[i]=vorbis_staticbook_unpack(opb); | |||
if(!ci->book_param[i])goto err_out; | |||
} | |||
/* time backend settings; hooks are unused */ | |||
{ | |||
int times=oggpack_read(opb,6)+1; | |||
if(times<=0)goto err_out; | |||
for(i=0;i<times;i++){ | |||
int test=oggpack_read(opb,16); | |||
if(test<0 || test>=VI_TIMEB)goto err_out; | |||
@@ -267,8 +288,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ | |||
/* floor backend settings */ | |||
ci->floors=oggpack_read(opb,6)+1; | |||
/*ci->floor_type=_ogg_malloc(ci->floors*sizeof(*ci->floor_type));*/ | |||
/*ci->floor_param=_ogg_calloc(ci->floors,sizeof(void *));*/ | |||
if(ci->floors<=0)goto err_out; | |||
for(i=0;i<ci->floors;i++){ | |||
ci->floor_type[i]=oggpack_read(opb,16); | |||
if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB)goto err_out; | |||
@@ -278,8 +298,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ | |||
/* residue backend settings */ | |||
ci->residues=oggpack_read(opb,6)+1; | |||
/*ci->residue_type=_ogg_malloc(ci->residues*sizeof(*ci->residue_type));*/ | |||
/*ci->residue_param=_ogg_calloc(ci->residues,sizeof(void *));*/ | |||
if(ci->residues<=0)goto err_out; | |||
for(i=0;i<ci->residues;i++){ | |||
ci->residue_type[i]=oggpack_read(opb,16); | |||
if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB)goto err_out; | |||
@@ -289,8 +308,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ | |||
/* map backend settings */ | |||
ci->maps=oggpack_read(opb,6)+1; | |||
/*ci->map_type=_ogg_malloc(ci->maps*sizeof(*ci->map_type));*/ | |||
/*ci->map_param=_ogg_calloc(ci->maps,sizeof(void *));*/ | |||
if(ci->maps<=0)goto err_out; | |||
for(i=0;i<ci->maps;i++){ | |||
ci->map_type[i]=oggpack_read(opb,16); | |||
if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out; | |||
@@ -300,7 +318,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ | |||
/* mode settings */ | |||
ci->modes=oggpack_read(opb,6)+1; | |||
/*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/ | |||
if(ci->modes<=0)goto err_out; | |||
for(i=0;i<ci->modes;i++){ | |||
ci->mode_param[i]=(vorbis_info_mode*)_ogg_calloc(1,sizeof(*ci->mode_param[i])); | |||
ci->mode_param[i]->blockflag=oggpack_read(opb,1); | |||
@@ -311,6 +329,7 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ | |||
if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out; | |||
if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out; | |||
if(ci->mode_param[i]->mapping>=ci->maps)goto err_out; | |||
if(ci->mode_param[i]->mapping<0)goto err_out; | |||
} | |||
if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */ | |||
@@ -321,6 +340,31 @@ static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){ | |||
return(OV_EBADHEADER); | |||
} | |||
/* Is this packet a vorbis ID header? */ | |||
int vorbis_synthesis_idheader(ogg_packet *op){ | |||
oggpack_buffer opb; | |||
char buffer[6]; | |||
if(op){ | |||
oggpack_readinit(&opb,op->packet,op->bytes); | |||
if(!op->b_o_s) | |||
return(0); /* Not the initial packet */ | |||
if(oggpack_read(&opb,8) != 1) | |||
return 0; /* not an ID header */ | |||
memset(buffer,0,6); | |||
_v_readstring(&opb,buffer,6); | |||
if(memcmp(buffer,"vorbis",6)) | |||
return 0; /* not vorbis */ | |||
return 1; | |||
} | |||
return 0; | |||
} | |||
/* The Vorbis header is in three packets; the initial small packet in | |||
the first page that identifies basic parameters, a second packet | |||
with bitstream comments and a third packet that holds the | |||
@@ -340,42 +384,42 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op) | |||
memset(buffer,0,6); | |||
_v_readstring(&opb,buffer,6); | |||
if(memcmp(buffer,"vorbis",6)){ | |||
/* not a vorbis header */ | |||
return(OV_ENOTVORBIS); | |||
/* not a vorbis header */ | |||
return(OV_ENOTVORBIS); | |||
} | |||
switch(packtype){ | |||
case 0x01: /* least significant *bit* is read first */ | |||
if(!op->b_o_s){ | |||
/* Not the initial packet */ | |||
return(OV_EBADHEADER); | |||
} | |||
if(vi->rate!=0){ | |||
/* previously initialized info header */ | |||
return(OV_EBADHEADER); | |||
} | |||
if(!op->b_o_s){ | |||
/* Not the initial packet */ | |||
return(OV_EBADHEADER); | |||
} | |||
if(vi->rate!=0){ | |||
/* previously initialized info header */ | |||
return(OV_EBADHEADER); | |||
} | |||
return(_vorbis_unpack_info(vi,&opb)); | |||
return(_vorbis_unpack_info(vi,&opb)); | |||
case 0x03: /* least significant *bit* is read first */ | |||
if(vi->rate==0){ | |||
/* um... we didn't get the initial header */ | |||
return(OV_EBADHEADER); | |||
} | |||
if(vi->rate==0){ | |||
/* um... we didn't get the initial header */ | |||
return(OV_EBADHEADER); | |||
} | |||
return(_vorbis_unpack_comment(vc,&opb)); | |||
return(_vorbis_unpack_comment(vc,&opb)); | |||
case 0x05: /* least significant *bit* is read first */ | |||
if(vi->rate==0 || vc->vendor==NULL){ | |||
/* um... we didn;t get the initial header or comments yet */ | |||
return(OV_EBADHEADER); | |||
} | |||
if(vi->rate==0 || vc->vendor==NULL){ | |||
/* um... we didn;t get the initial header or comments yet */ | |||
return(OV_EBADHEADER); | |||
} | |||
return(_vorbis_unpack_books(vi,&opb)); | |||
return(_vorbis_unpack_books(vi,&opb)); | |||
default: | |||
/* Not a valid vorbis header type */ | |||
return(OV_EBADHEADER); | |||
break; | |||
/* Not a valid vorbis header type */ | |||
return(OV_EBADHEADER); | |||
break; | |||
} | |||
} | |||
} | |||
@@ -409,8 +453,7 @@ static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){ | |||
} | |||
static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){ | |||
char temp[]="Xiph.Org libVorbis I 20050304"; | |||
int bytes = strlen(temp); | |||
int bytes = strlen(ENCODE_VENDOR_STRING); | |||
/* preamble */ | |||
oggpack_write(opb,0x03,8); | |||
@@ -418,7 +461,7 @@ static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){ | |||
/* vendor */ | |||
oggpack_write(opb,bytes,32); | |||
_v_writestring(opb,temp, bytes); | |||
_v_writestring(opb,ENCODE_VENDOR_STRING, bytes); | |||
/* comments */ | |||
@@ -427,10 +470,10 @@ static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){ | |||
int i; | |||
for(i=0;i<vc->comments;i++){ | |||
if(vc->user_comments[i]){ | |||
oggpack_write(opb,vc->comment_lengths[i],32); | |||
_v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]); | |||
oggpack_write(opb,vc->comment_lengths[i],32); | |||
_v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]); | |||
}else{ | |||
oggpack_write(opb,0,32); | |||
oggpack_write(opb,0,32); | |||
} | |||
} | |||
} | |||
@@ -496,7 +539,7 @@ err_out: | |||
} | |||
int vorbis_commentheader_out(vorbis_comment *vc, | |||
ogg_packet *op){ | |||
ogg_packet *op){ | |||
oggpack_buffer opb; | |||
@@ -516,10 +559,10 @@ int vorbis_commentheader_out(vorbis_comment *vc, | |||
} | |||
int vorbis_analysis_headerout(vorbis_dsp_state *v, | |||
vorbis_comment *vc, | |||
ogg_packet *op, | |||
ogg_packet *op_comm, | |||
ogg_packet *op_code){ | |||
vorbis_comment *vc, | |||
ogg_packet *op, | |||
ogg_packet *op_comm, | |||
ogg_packet *op_code){ | |||
int ret=OV_EIMPL; | |||
vorbis_info *vi=v->vi; | |||
oggpack_buffer opb; | |||
@@ -579,24 +622,44 @@ int vorbis_analysis_headerout(vorbis_dsp_state *v, | |||
oggpack_writeclear(&opb); | |||
return(0); | |||
err_out: | |||
oggpack_writeclear(&opb); | |||
memset(op,0,sizeof(*op)); | |||
memset(op_comm,0,sizeof(*op_comm)); | |||
memset(op_code,0,sizeof(*op_code)); | |||
if(b->header)_ogg_free(b->header); | |||
if(b->header1)_ogg_free(b->header1); | |||
if(b->header2)_ogg_free(b->header2); | |||
b->header=NULL; | |||
b->header1=NULL; | |||
b->header2=NULL; | |||
if(b){ | |||
oggpack_writeclear(&opb); | |||
if(b->header)_ogg_free(b->header); | |||
if(b->header1)_ogg_free(b->header1); | |||
if(b->header2)_ogg_free(b->header2); | |||
b->header=NULL; | |||
b->header1=NULL; | |||
b->header2=NULL; | |||
} | |||
return(ret); | |||
} | |||
double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){ | |||
if(granulepos>=0) | |||
if(granulepos == -1) return -1; | |||
/* We're not guaranteed a 64 bit unsigned type everywhere, so we | |||
have to put the unsigned granpo in a signed type. */ | |||
if(granulepos>=0){ | |||
return((double)granulepos/v->vi->rate); | |||
return(-1); | |||
}else{ | |||
ogg_int64_t granuleoff=0xffffffff; | |||
granuleoff<<=31; | |||
#ifdef __GNUC__ | |||
granuleoff |= 0x7ffffffffLL; | |||
#else | |||
granuleoff |= 0x7ffffffff; | |||
#endif | |||
return(((double)granulepos+2+granuleoff+granuleoff)/v->vi->rate); | |||
} | |||
} | |||
#endif | |||
const char *vorbis_version_string(void){ | |||
return GENERAL_VENDOR_STRING; | |||
} | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: lookup.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -91,9 +91,9 @@ 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); | |||
COS_LOOKUP_I_SHIFT); | |||
} | |||
#endif | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: lookup.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -0,0 +1,192 @@ | |||
/******************************************************************** | |||
* * | |||
* 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 |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: lpc.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -65,6 +65,7 @@ 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 */ | |||
@@ -77,14 +78,16 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){ | |||
/* Generate lpc coefficients from autocorr values */ | |||
error=aut[0]; | |||
/* 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==0){ | |||
memset(lpci,0,m*sizeof(*lpci)); | |||
return 0; | |||
if(error<epsilon){ | |||
memset(lpc+i,0,(m-i)*sizeof(*lpc)); | |||
goto done; | |||
} | |||
/* Sum up this iteration's reflection coefficient; note that in | |||
@@ -104,9 +107,22 @@ float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){ | |||
lpc[j]+=r*lpc[i-1-j]; | |||
lpc[i-1-j]+=r*tmp; | |||
} | |||
if(i%2)lpc[j]+=lpc[j]*r; | |||
if(i&1)lpc[j]+=lpc[j]*r; | |||
error*=1.f-r*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]; | |||
@@ -147,4 +163,4 @@ void vorbis_lpc_predict(float *coeff,float *prime,int m, | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:17 jules_rms Exp $ | |||
last mod: $Id: lpc.h 16037 2009-05-26 21:10:58Z xiphmont $ | |||
********************************************************************/ | |||
@@ -24,6 +24,6 @@ | |||
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); | |||
float *data,long n); | |||
#endif |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
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 | |||
@@ -49,14 +49,15 @@ | |||
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 | |||
seperately tracked exponent) and thus much more complex than the | |||
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. */ | |||
/* undefine both for the 'old' but more precise implementation */ | |||
#define FLOAT_LOOKUP | |||
#undef INT_LOOKUP | |||
/* 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 | |||
@@ -65,11 +66,10 @@ | |||
/* 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){ | |||
float amp,float ampoffset){ | |||
int i; | |||
float wdel=M_PI/ln; | |||
vorbis_fpu_control fpu; | |||
(void) fpu; // to avoid an unused variable warning | |||
vorbis_fpu_setround(&fpu); | |||
for(i=0;i<m;i++)lsp[i]=vorbis_coslook(lsp[i]); | |||
@@ -84,11 +84,11 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
float *ftmp=lsp; | |||
int c=m>>1; | |||
do{ | |||
while(c--){ | |||
q*=ftmp[0]-w; | |||
p*=ftmp[1]-w; | |||
ftmp+=2; | |||
}while(--c); | |||
} | |||
if(m&1){ | |||
/* odd order filter; slightly assymetric */ | |||
@@ -104,9 +104,9 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
q=frexp(p+q,&qexp); | |||
q=vorbis_fromdBlook(amp* | |||
vorbis_invsqlook(q)* | |||
vorbis_invsq2explook(qexp+m)- | |||
ampoffset); | |||
vorbis_invsqlook(q)* | |||
vorbis_invsq2explook(qexp+m)- | |||
ampoffset); | |||
do{ | |||
curve[i++]*=q; | |||
@@ -122,26 +122,26 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
compilers (like gcc) that can't inline across | |||
modules */ | |||
static int MLOOP_1[64]={ | |||
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 int MLOOP_2[64]={ | |||
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 int MLOOP_3[8]={0,1,2,2,3,3,3,3}; | |||
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){ | |||
float amp,float ampoffset){ | |||
/* 0 <= m < 256 */ | |||
@@ -149,7 +149,7 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
int i; | |||
int ampoffseti=rint(ampoffset*4096.f); | |||
int ampi=rint(amp*16.f); | |||
long *ilsp=alloca(m*sizeof(*ilsp)); | |||
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; | |||
@@ -165,15 +165,15 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
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]; | |||
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]; | |||
shift=MLOOP_3[(pi|qi)>>16]; | |||
/* pi,qi normalized collectively, both tracked using qexp */ | |||
@@ -185,8 +185,8 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
qexp+=shift; | |||
if(!(shift=MLOOP_1[(pi|qi)>>25])) | |||
if(!(shift=MLOOP_2[(pi|qi)>>19])) | |||
shift=MLOOP_3[(pi|qi)>>16]; | |||
if(!(shift=MLOOP_2[(pi|qi)>>19])) | |||
shift=MLOOP_3[(pi|qi)>>16]; | |||
pi>>=shift; | |||
qi>>=shift; | |||
@@ -203,7 +203,7 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
/* 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 */ | |||
worth tracking step by step */ | |||
pi>>=shift; | |||
qi>>=shift; | |||
@@ -228,13 +228,13 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
qi>>=1; qexp++; | |||
}else | |||
while(qi && !(qi&0x8000)){ /* checks for 0.0xxxxxxxxxxxxxxx or less*/ | |||
qi<<=1; qexp--; | |||
qi<<=1; qexp--; | |||
} | |||
amp=vorbis_fromdBlook_i(ampi* /* n.4 */ | |||
vorbis_invsqlook_i(qi,qexp)- | |||
/* m.8, m+n<=8 */ | |||
ampoffseti); /* 8.12[0] */ | |||
vorbis_invsqlook_i(qi,qexp)- | |||
/* m.8, m+n<=8 */ | |||
ampoffseti); /* 8.12[0] */ | |||
curve[i]*=amp; | |||
while(map[++i]==k)curve[i]*=amp; | |||
@@ -249,7 +249,7 @@ void vorbis_lsp_to_curve(float *curve,int *map,int n,int ln,float *lsp,int m, | |||
/* 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){ | |||
float amp,float ampoffset){ | |||
int i; | |||
float wdel=M_PI/ln; | |||
for(i=0;i<m;i++)lsp[i]=2.f*cos(lsp[i]); | |||
@@ -333,14 +333,14 @@ static int Laguerre_With_Deflation(float *a,int ord,float *r){ | |||
/* 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 */ | |||
return(-1); /* complex root! The LPC generator handed us a bad filter */ | |||
if(pp>0){ | |||
denom = pp + sqrt(denom); | |||
if(denom<EPSILON)denom=EPSILON; | |||
denom = pp + sqrt(denom); | |||
if(denom<EPSILON)denom=EPSILON; | |||
}else{ | |||
denom = pp - sqrt(denom); | |||
if(denom>-(EPSILON))denom=-(EPSILON); | |||
denom = pp - sqrt(denom); | |||
if(denom>-(EPSILON))denom=-(EPSILON); | |||
} | |||
delta = m*p/denom; | |||
@@ -382,8 +382,8 @@ static int Newton_Raphson(float *a,int ord,float *r){ | |||
double p=a[ord]; | |||
for(k=ord-1; k>= 0; k--) { | |||
pp= pp* rooti + p; | |||
p = p * rooti + a[k]; | |||
pp= pp* rooti + p; | |||
p = p * rooti + a[k]; | |||
} | |||
delta = p/pp; | |||
@@ -458,4 +458,4 @@ int vorbis_lpc_to_lsp(float *lpc,float *lsp,int m){ | |||
return(0); | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: lsp.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -22,7 +22,7 @@ | |||
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); | |||
float *lsp,int m, | |||
float amp,float ampoffset); | |||
#endif |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: channel mapping 0 implementation | |||
last mod: $Id: mapping0.c,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: mapping0.c 17022 2010-03-25 03:45:42Z xiphmont $ | |||
********************************************************************/ | |||
@@ -59,7 +59,7 @@ static int ilog3(unsigned int v){ | |||
} | |||
static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm, | |||
oggpack_buffer *opb){ | |||
oggpack_buffer *opb){ | |||
int i; | |||
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm; | |||
@@ -103,46 +103,51 @@ static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm, | |||
/* also responsible for range checking */ | |||
static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){ | |||
int i; | |||
int i,b; | |||
vorbis_info_mapping0 *info=(vorbis_info_mapping0*)_ogg_calloc(1,sizeof(*info)); | |||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||
memset(info,0,sizeof(*info)); | |||
if(oggpack_read(opb,1)) | |||
b=oggpack_read(opb,1); | |||
if(b<0)goto err_out; | |||
if(b){ | |||
info->submaps=oggpack_read(opb,4)+1; | |||
else | |||
if(info->submaps<=0)goto err_out; | |||
}else | |||
info->submaps=1; | |||
if(oggpack_read(opb,1)){ | |||
b=oggpack_read(opb,1); | |||
if(b<0)goto err_out; | |||
if(b){ | |||
info->coupling_steps=oggpack_read(opb,8)+1; | |||
if(info->coupling_steps<=0)goto err_out; | |||
for(i=0;i<info->coupling_steps;i++){ | |||
int testM=info->coupling_mag[i]=oggpack_read(opb,ilog3(vi->channels)); | |||
int testA=info->coupling_ang[i]=oggpack_read(opb,ilog3(vi->channels)); | |||
if(testM<0 || | |||
testA<0 || | |||
testM==testA || | |||
testM>=vi->channels || | |||
testA>=vi->channels) goto err_out; | |||
testA<0 || | |||
testM==testA || | |||
testM>=vi->channels || | |||
testA>=vi->channels) goto err_out; | |||
} | |||
} | |||
if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */ | |||
if(oggpack_read(opb,2)!=0)goto err_out; /* 2,3:reserved */ | |||
if(info->submaps>1){ | |||
for(i=0;i<vi->channels;i++){ | |||
info->chmuxlist[i]=oggpack_read(opb,4); | |||
if(info->chmuxlist[i]>=info->submaps)goto err_out; | |||
if(info->chmuxlist[i]>=info->submaps || info->chmuxlist[i]<0)goto err_out; | |||
} | |||
} | |||
for(i=0;i<info->submaps;i++){ | |||
oggpack_read(opb,8); /* time submap unused */ | |||
info->floorsubmap[i]=oggpack_read(opb,8); | |||
if(info->floorsubmap[i]>=ci->floors)goto err_out; | |||
if(info->floorsubmap[i]>=ci->floors || info->floorsubmap[i]<0)goto err_out; | |||
info->residuesubmap[i]=oggpack_read(opb,8); | |||
if(info->residuesubmap[i]>=ci->residues)goto err_out; | |||
if(info->residuesubmap[i]>=ci->residues || info->residuesubmap[i]<0)goto err_out; | |||
} | |||
return info; | |||
@@ -232,16 +237,6 @@ static float FLOOR1_fromdB_LOOKUP[256]={ | |||
#endif | |||
extern int *floor1_fit(vorbis_block *vb,void *look, | |||
const float *logmdct, /* in */ | |||
const float *logmask); | |||
extern int *floor1_interpolate_fit(vorbis_block *vb,void *look, | |||
int *A,int *B, | |||
int del); | |||
extern int floor1_encode(oggpack_buffer *opb,vorbis_block *vb, | |||
void*look, | |||
int *post,int *ilogmask); | |||
static int mapping0_forward(vorbis_block *vb){ | |||
vorbis_dsp_state *vd=vb->vd; | |||
@@ -252,10 +247,10 @@ static int mapping0_forward(vorbis_block *vb){ | |||
int n=vb->pcmend; | |||
int i,j,k; | |||
int *nonzero = (int*) alloca(sizeof(*nonzero)*vi->channels); | |||
float **gmdct = (float**) _vorbis_block_alloc(vb,vi->channels*sizeof(*gmdct)); | |||
int **ilogmaskch= (int**) _vorbis_block_alloc(vb,vi->channels*sizeof(*ilogmaskch)); | |||
int ***floor_posts = (int***) _vorbis_block_alloc(vb,vi->channels*sizeof(*floor_posts)); | |||
int *nonzero = (int*)alloca(sizeof(*nonzero)*vi->channels); | |||
float **gmdct = (float**)_vorbis_block_alloc(vb,vi->channels*sizeof(*gmdct)); | |||
int **iwork = (int**)_vorbis_block_alloc(vb,vi->channels*sizeof(*iwork)); | |||
int ***floor_posts = (int***)_vorbis_block_alloc(vb,vi->channels*sizeof(*floor_posts)); | |||
float global_ampmax=vbi->ampmax; | |||
float *local_ampmax=(float*)alloca(sizeof(*local_ampmax)*vi->channels); | |||
@@ -263,8 +258,7 @@ static int mapping0_forward(vorbis_block *vb){ | |||
int modenumber=vb->W; | |||
vorbis_info_mapping0 *info=(vorbis_info_mapping0*)ci->map_param[modenumber]; | |||
vorbis_look_psy *psy_look= | |||
b->psy+blocktype+(vb->W?2:0); | |||
vorbis_look_psy *psy_look=b->psy+blocktype+(vb->W?2:0); | |||
vb->mode=modenumber; | |||
@@ -275,6 +269,7 @@ static int mapping0_forward(vorbis_block *vb){ | |||
float *pcm =vb->pcm[i]; | |||
float *logfft =pcm; | |||
iwork[i]=(int*)_vorbis_block_alloc(vb,n/2*sizeof(**iwork)); | |||
gmdct[i]=(float*)_vorbis_block_alloc(vb,n/2*sizeof(**gmdct)); | |||
scale_dB=todB(&scale) + .345; /* + .345 is a hack; the original | |||
@@ -293,22 +288,28 @@ static int mapping0_forward(vorbis_block *vb){ | |||
next major model upgrade. */ | |||
#if 0 | |||
if(vi->channels==2) | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("pcmL",seq,pcm,n,0,0,total-n/2); | |||
_analysis_output("pcmL",seq,pcm,n,0,0,total-n/2); | |||
else | |||
_analysis_output("pcmR",seq,pcm,n,0,0,total-n/2); | |||
_analysis_output("pcmR",seq,pcm,n,0,0,total-n/2); | |||
}else{ | |||
_analysis_output("pcm",seq,pcm,n,0,0,total-n/2); | |||
} | |||
#endif | |||
/* window the PCM data */ | |||
_vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW); | |||
#if 0 | |||
if(vi->channels==2) | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("windowedL",seq,pcm,n,0,0,total-n/2); | |||
_analysis_output("windowedL",seq,pcm,n,0,0,total-n/2); | |||
else | |||
_analysis_output("windowedR",seq,pcm,n,0,0,total-n/2); | |||
_analysis_output("windowedR",seq,pcm,n,0,0,total-n/2); | |||
}else{ | |||
_analysis_output("windowed",seq,pcm,n,0,0,total-n/2); | |||
} | |||
#endif | |||
/* transform the PCM data */ | |||
@@ -358,22 +359,24 @@ static int mapping0_forward(vorbis_block *vb){ | |||
#if 0 | |||
if(vi->channels==2){ | |||
if(i==0){ | |||
_analysis_output("fftL",seq,logfft,n/2,1,0,0); | |||
_analysis_output("fftL",seq,logfft,n/2,1,0,0); | |||
}else{ | |||
_analysis_output("fftR",seq,logfft,n/2,1,0,0); | |||
_analysis_output("fftR",seq,logfft,n/2,1,0,0); | |||
} | |||
}else{ | |||
_analysis_output("fft",seq,logfft,n/2,1,0,0); | |||
} | |||
#endif | |||
} | |||
{ | |||
float *noise = (float*) _vorbis_block_alloc(vb,n/2*sizeof(*noise)); | |||
float *tone = (float*) _vorbis_block_alloc(vb,n/2*sizeof(*tone)); | |||
float *noise = (float*)_vorbis_block_alloc(vb,n/2*sizeof(*noise)); | |||
float *tone = (float*)_vorbis_block_alloc(vb,n/2*sizeof(*tone)); | |||
for(i=0;i<vi->channels;i++){ | |||
/* the encoder setup assumes that all the modes used by any | |||
specific bitrate tweaking use the same floor */ | |||
specific bitrate tweaking use the same floor */ | |||
int submap=info->chmuxlist[i]; | |||
@@ -386,11 +389,11 @@ static int mapping0_forward(vorbis_block *vb){ | |||
vb->mode=modenumber; | |||
floor_posts[i]=(int**) _vorbis_block_alloc(vb,PACKETBLOBS*sizeof(**floor_posts)); | |||
floor_posts[i]=(int**)_vorbis_block_alloc(vb,PACKETBLOBS*sizeof(**floor_posts)); | |||
memset(floor_posts[i],0,sizeof(**floor_posts)*PACKETBLOBS); | |||
for(j=0;j<n/2;j++) | |||
logmdct[j]=todB(mdct+j) + .345; /* + .345 is a hack; the original | |||
logmdct[j]=todB(mdct+j) + .345; /* + .345 is a hack; the original | |||
todB estimation used on IEEE 754 | |||
compliant machines had a bug that | |||
returned dB values about a third | |||
@@ -407,12 +410,12 @@ static int mapping0_forward(vorbis_block *vb){ | |||
#if 0 | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("mdctL",seq,logmdct,n/2,1,0,0); | |||
else | |||
_analysis_output("mdctR",seq,logmdct,n/2,1,0,0); | |||
if(i==0) | |||
_analysis_output("mdctL",seq,logmdct,n/2,1,0,0); | |||
else | |||
_analysis_output("mdctR",seq,logmdct,n/2,1,0,0); | |||
}else{ | |||
_analysis_output("mdct",seq,logmdct,n/2,1,0,0); | |||
_analysis_output("mdct",seq,logmdct,n/2,1,0,0); | |||
} | |||
#endif | |||
@@ -423,15 +426,17 @@ static int mapping0_forward(vorbis_block *vb){ | |||
'noise_depth' vector, the more tonal that area is) */ | |||
_vp_noisemask(psy_look, | |||
logmdct, | |||
noise); /* noise does not have by-frequency offset | |||
logmdct, | |||
noise); /* noise does not have by-frequency offset | |||
bias applied yet */ | |||
#if 0 | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("noiseL",seq,noise,n/2,1,0,0); | |||
else | |||
_analysis_output("noiseR",seq,noise,n/2,1,0,0); | |||
if(i==0) | |||
_analysis_output("noiseL",seq,noise,n/2,1,0,0); | |||
else | |||
_analysis_output("noiseR",seq,noise,n/2,1,0,0); | |||
}else{ | |||
_analysis_output("noise",seq,noise,n/2,1,0,0); | |||
} | |||
#endif | |||
@@ -440,55 +445,61 @@ static int mapping0_forward(vorbis_block *vb){ | |||
vector. This includes tone masking, peak limiting and ATH */ | |||
_vp_tonemask(psy_look, | |||
logfft, | |||
tone, | |||
global_ampmax, | |||
local_ampmax[i]); | |||
logfft, | |||
tone, | |||
global_ampmax, | |||
local_ampmax[i]); | |||
#if 0 | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("toneL",seq,tone,n/2,1,0,0); | |||
else | |||
_analysis_output("toneR",seq,tone,n/2,1,0,0); | |||
if(i==0) | |||
_analysis_output("toneL",seq,tone,n/2,1,0,0); | |||
else | |||
_analysis_output("toneR",seq,tone,n/2,1,0,0); | |||
}else{ | |||
_analysis_output("tone",seq,tone,n/2,1,0,0); | |||
} | |||
#endif | |||
/* third step; we offset the noise vectors, overlay tone | |||
masking. We then do a floor1-specific line fit. If we're | |||
performing bitrate management, the line fit is performed | |||
multiple times for up/down tweakage on demand. */ | |||
masking. We then do a floor1-specific line fit. If we're | |||
performing bitrate management, the line fit is performed | |||
multiple times for up/down tweakage on demand. */ | |||
#if 0 | |||
{ | |||
float aotuv[psy_look->n]; | |||
#endif | |||
_vp_offset_and_mix(psy_look, | |||
noise, | |||
tone, | |||
1, | |||
logmask, | |||
mdct, | |||
logmdct); | |||
_vp_offset_and_mix(psy_look, | |||
noise, | |||
tone, | |||
1, | |||
logmask, | |||
mdct, | |||
logmdct); | |||
#if 0 | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0); | |||
else | |||
_analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0); | |||
} | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("aotuvM1_L",seq,aotuv,psy_look->n,1,1,0); | |||
else | |||
_analysis_output("aotuvM1_R",seq,aotuv,psy_look->n,1,1,0); | |||
}else{ | |||
_analysis_output("aotuvM1",seq,aotuv,psy_look->n,1,1,0); | |||
} | |||
} | |||
#endif | |||
#if 0 | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("mask1L",seq,logmask,n/2,1,0,0); | |||
else | |||
_analysis_output("mask1R",seq,logmask,n/2,1,0,0); | |||
if(i==0) | |||
_analysis_output("mask1L",seq,logmask,n/2,1,0,0); | |||
else | |||
_analysis_output("mask1R",seq,logmask,n/2,1,0,0); | |||
}else{ | |||
_analysis_output("mask1",seq,logmask,n/2,1,0,0); | |||
} | |||
#endif | |||
@@ -498,73 +509,78 @@ static int mapping0_forward(vorbis_block *vb){ | |||
if(ci->floor_type[info->floorsubmap[submap]]!=1)return(-1); | |||
floor_posts[i][PACKETBLOBS/2]= | |||
floor1_fit(vb,b->flr[info->floorsubmap[submap]], | |||
logmdct, | |||
logmask); | |||
floor1_fit(vb,(vorbis_look_floor1*)(b->flr[info->floorsubmap[submap]]), | |||
logmdct, | |||
logmask); | |||
/* are we managing bitrate? If so, perform two more fits for | |||
later rate tweaking (fits represent hi/lo) */ | |||
if(vorbis_bitrate_managed(vb) && floor_posts[i][PACKETBLOBS/2]){ | |||
/* higher rate by way of lower noise curve */ | |||
/* higher rate by way of lower noise curve */ | |||
_vp_offset_and_mix(psy_look, | |||
noise, | |||
tone, | |||
2, | |||
logmask, | |||
mdct, | |||
logmdct); | |||
_vp_offset_and_mix(psy_look, | |||
noise, | |||
tone, | |||
2, | |||
logmask, | |||
mdct, | |||
logmdct); | |||
#if 0 | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("mask2L",seq,logmask,n/2,1,0,0); | |||
else | |||
_analysis_output("mask2R",seq,logmask,n/2,1,0,0); | |||
} | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("mask2L",seq,logmask,n/2,1,0,0); | |||
else | |||
_analysis_output("mask2R",seq,logmask,n/2,1,0,0); | |||
}else{ | |||
_analysis_output("mask2",seq,logmask,n/2,1,0,0); | |||
} | |||
#endif | |||
floor_posts[i][PACKETBLOBS-1]= | |||
floor1_fit(vb,b->flr[info->floorsubmap[submap]], | |||
logmdct, | |||
logmask); | |||
floor_posts[i][PACKETBLOBS-1]= | |||
floor1_fit(vb,(vorbis_look_floor1*)(b->flr[info->floorsubmap[submap]]), | |||
logmdct, | |||
logmask); | |||
/* lower rate by way of higher noise curve */ | |||
_vp_offset_and_mix(psy_look, | |||
noise, | |||
tone, | |||
0, | |||
logmask, | |||
mdct, | |||
logmdct); | |||
/* lower rate by way of higher noise curve */ | |||
_vp_offset_and_mix(psy_look, | |||
noise, | |||
tone, | |||
0, | |||
logmask, | |||
mdct, | |||
logmdct); | |||
#if 0 | |||
if(vi->channels==2) | |||
if(i==0) | |||
_analysis_output("mask0L",seq,logmask,n/2,1,0,0); | |||
else | |||
_analysis_output("mask0R",seq,logmask,n/2,1,0,0); | |||
if(vi->channels==2){ | |||
if(i==0) | |||
_analysis_output("mask0L",seq,logmask,n/2,1,0,0); | |||
else | |||
_analysis_output("mask0R",seq,logmask,n/2,1,0,0); | |||
}else{ | |||
_analysis_output("mask0",seq,logmask,n/2,1,0,0); | |||
} | |||
#endif | |||
floor_posts[i][0]= | |||
floor1_fit(vb,b->flr[info->floorsubmap[submap]], | |||
logmdct, | |||
logmask); | |||
floor_posts[i][0]= | |||
floor1_fit(vb,(vorbis_look_floor1*)(b->flr[info->floorsubmap[submap]]), | |||
logmdct, | |||
logmask); | |||
/* we also interpolate a range of intermediate curves for | |||
/* we also interpolate a range of intermediate curves for | |||
intermediate rates */ | |||
for(k=1;k<PACKETBLOBS/2;k++) | |||
floor_posts[i][k]= | |||
floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]], | |||
floor_posts[i][0], | |||
floor_posts[i][PACKETBLOBS/2], | |||
k*65536/(PACKETBLOBS/2)); | |||
for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++) | |||
floor_posts[i][k]= | |||
floor1_interpolate_fit(vb,b->flr[info->floorsubmap[submap]], | |||
floor_posts[i][PACKETBLOBS/2], | |||
floor_posts[i][PACKETBLOBS-1], | |||
(k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2)); | |||
for(k=1;k<PACKETBLOBS/2;k++) | |||
floor_posts[i][k]= | |||
floor1_interpolate_fit(vb,(vorbis_look_floor1*)(b->flr[info->floorsubmap[submap]]), | |||
floor_posts[i][0], | |||
floor_posts[i][PACKETBLOBS/2], | |||
k*65536/(PACKETBLOBS/2)); | |||
for(k=PACKETBLOBS/2+1;k<PACKETBLOBS-1;k++) | |||
floor_posts[i][k]= | |||
floor1_interpolate_fit(vb,(vorbis_look_floor1*)(b->flr[info->floorsubmap[submap]]), | |||
floor_posts[i][PACKETBLOBS/2], | |||
floor_posts[i][PACKETBLOBS-1], | |||
(k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2)); | |||
} | |||
} | |||
} | |||
@@ -585,43 +601,12 @@ static int mapping0_forward(vorbis_block *vb){ | |||
/* iterate over the many masking curve fits we've created */ | |||
{ | |||
float **res_bundle=(float**) alloca(sizeof(*res_bundle)*vi->channels); | |||
float **couple_bundle=(float**) alloca(sizeof(*couple_bundle)*vi->channels); | |||
int *zerobundle=(int*) alloca(sizeof(*zerobundle)*vi->channels); | |||
int **sortindex=(int**) alloca(sizeof(*sortindex)*vi->channels); | |||
float **mag_memo; | |||
int **mag_sort; | |||
if(info->coupling_steps){ | |||
mag_memo=_vp_quantize_couple_memo(vb, | |||
&ci->psy_g_param, | |||
psy_look, | |||
info, | |||
gmdct); | |||
mag_sort=_vp_quantize_couple_sort(vb, | |||
psy_look, | |||
info, | |||
mag_memo); | |||
hf_reduction(&ci->psy_g_param, | |||
psy_look, | |||
info, | |||
mag_memo); | |||
} | |||
memset(sortindex,0,sizeof(*sortindex)*vi->channels); | |||
if(psy_look->vi->normal_channel_p){ | |||
for(i=0;i<vi->channels;i++){ | |||
float *mdct =gmdct[i]; | |||
sortindex[i]=(int*) alloca(sizeof(**sortindex)*n/2); | |||
_vp_noise_normalize_sort(psy_look,mdct,sortindex[i]); | |||
} | |||
} | |||
int **couple_bundle=(int**)alloca(sizeof(*couple_bundle)*vi->channels); | |||
int *zerobundle=(int*)alloca(sizeof(*zerobundle)*vi->channels); | |||
for(k=(vorbis_bitrate_managed(vb)?0:PACKETBLOBS/2); | |||
k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2); | |||
k++){ | |||
k<=(vorbis_bitrate_managed(vb)?PACKETBLOBS-1:PACKETBLOBS/2); | |||
k++){ | |||
oggpack_buffer *opb=vbi->packetblob[k]; | |||
/* start out our new packet blob with packet type and mode */ | |||
@@ -631,93 +616,82 @@ static int mapping0_forward(vorbis_block *vb){ | |||
/* Encode frame mode, pre,post windowsize, then dispatch */ | |||
oggpack_write(opb,modenumber,b->modebits); | |||
if(vb->W){ | |||
oggpack_write(opb,vb->lW,1); | |||
oggpack_write(opb,vb->nW,1); | |||
oggpack_write(opb,vb->lW,1); | |||
oggpack_write(opb,vb->nW,1); | |||
} | |||
/* encode floor, compute masking curve, sep out residue */ | |||
for(i=0;i<vi->channels;i++){ | |||
int submap=info->chmuxlist[i]; | |||
float *mdct =gmdct[i]; | |||
float *res =vb->pcm[i]; | |||
int *ilogmask=ilogmaskch[i]= | |||
(int*) _vorbis_block_alloc(vb,n/2*sizeof(**gmdct)); | |||
nonzero[i]=floor1_encode(opb,vb,b->flr[info->floorsubmap[submap]], | |||
floor_posts[i][k], | |||
ilogmask); | |||
#if 0 | |||
{ | |||
char buf[80]; | |||
sprintf(buf,"maskI%c%d",i?'R':'L',k); | |||
float work[n/2]; | |||
for(j=0;j<n/2;j++) | |||
work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]]; | |||
_analysis_output(buf,seq,work,n/2,1,1,0); | |||
} | |||
#endif | |||
_vp_remove_floor(psy_look, | |||
mdct, | |||
ilogmask, | |||
res, | |||
ci->psy_g_param.sliding_lowpass[vb->W][k]); | |||
_vp_noise_normalize(psy_look,res,res+n/2,sortindex[i]); | |||
int submap=info->chmuxlist[i]; | |||
int *ilogmask=iwork[i]; | |||
nonzero[i]=floor1_encode(opb,vb,(vorbis_look_floor1*)(b->flr[info->floorsubmap[submap]]), | |||
floor_posts[i][k], | |||
ilogmask); | |||
#if 0 | |||
{ | |||
char buf[80]; | |||
float work[n/2]; | |||
for(j=0;j<n/2;j++) | |||
work[j]=FLOOR1_fromdB_LOOKUP[ilogmask[j]]*(res+n/2)[j]; | |||
sprintf(buf,"resI%c%d",i?'R':'L',k); | |||
_analysis_output(buf,seq,work,n/2,1,1,0); | |||
} | |||
{ | |||
char buf[80]; | |||
sprintf(buf,"maskI%c%d",i?'R':'L',k); | |||
float work[n/2]; | |||
for(j=0;j<n/2;j++) | |||
work[j]=FLOOR1_fromdB_LOOKUP[iwork[i][j]]; | |||
_analysis_output(buf,seq,work,n/2,1,1,0); | |||
} | |||
#endif | |||
} | |||
/* our iteration is now based on masking curve, not prequant and | |||
coupling. Only one prequant/coupling step */ | |||
coupling. Only one prequant/coupling step */ | |||
/* quantize/couple */ | |||
/* incomplete implementation that assumes the tree is all depth | |||
one, or no tree at all */ | |||
if(info->coupling_steps){ | |||
_vp_couple(k, | |||
&ci->psy_g_param, | |||
psy_look, | |||
info, | |||
vb->pcm, | |||
mag_memo, | |||
mag_sort, | |||
ilogmaskch, | |||
nonzero, | |||
ci->psy_g_param.sliding_lowpass[vb->W][k]); | |||
_vp_couple_quantize_normalize(k, | |||
&ci->psy_g_param, | |||
psy_look, | |||
info, | |||
gmdct, | |||
iwork, | |||
nonzero, | |||
ci->psy_g_param.sliding_lowpass[vb->W][k], | |||
vi->channels); | |||
#if 0 | |||
for(i=0;i<vi->channels;i++){ | |||
char buf[80]; | |||
sprintf(buf,"res%c%d",i?'R':'L',k); | |||
float work[n/2]; | |||
for(j=0;j<n/2;j++) | |||
work[j]=iwork[i][j]; | |||
_analysis_output(buf,seq,work,n/2,1,0,0); | |||
} | |||
#endif | |||
/* classify and encode by submap */ | |||
for(i=0;i<info->submaps;i++){ | |||
int ch_in_bundle=0; | |||
long **classifications; | |||
int resnum=info->residuesubmap[i]; | |||
for(j=0;j<vi->channels;j++){ | |||
if(info->chmuxlist[j]==i){ | |||
zerobundle[ch_in_bundle]=0; | |||
if(nonzero[j])zerobundle[ch_in_bundle]=1; | |||
res_bundle[ch_in_bundle]=vb->pcm[j]; | |||
couple_bundle[ch_in_bundle++]=vb->pcm[j]+n/2; | |||
} | |||
} | |||
classifications=_residue_P[ci->residue_type[resnum]]-> | |||
classx(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle); | |||
_residue_P[ci->residue_type[resnum]]-> | |||
forward(opb,vb,b->residue[resnum], | |||
couple_bundle,NULL,zerobundle,ch_in_bundle,classifications); | |||
int ch_in_bundle=0; | |||
long **classifications; | |||
int resnum=info->residuesubmap[i]; | |||
for(j=0;j<vi->channels;j++){ | |||
if(info->chmuxlist[j]==i){ | |||
zerobundle[ch_in_bundle]=0; | |||
if(nonzero[j])zerobundle[ch_in_bundle]=1; | |||
couple_bundle[ch_in_bundle++]=iwork[j]; | |||
} | |||
} | |||
classifications=_residue_P[ci->residue_type[resnum]]-> | |||
classx(vb,b->residue[resnum],couple_bundle,zerobundle,ch_in_bundle); | |||
ch_in_bundle=0; | |||
for(j=0;j<vi->channels;j++) | |||
if(info->chmuxlist[j]==i) | |||
couple_bundle[ch_in_bundle++]=iwork[j]; | |||
_residue_P[ci->residue_type[resnum]]-> | |||
forward(opb,vb,b->residue[resnum], | |||
couple_bundle,zerobundle,ch_in_bundle,classifications,i); | |||
} | |||
/* ok, done encoding. Next protopacket. */ | |||
@@ -735,7 +709,7 @@ static int mapping0_forward(vorbis_block *vb){ | |||
static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){ | |||
vorbis_dsp_state *vd=vb->vd; | |||
vorbis_info *vi=vd->vi; | |||
codec_setup_info *ci=(codec_setup_info*) vi->codec_setup; | |||
codec_setup_info *ci=(codec_setup_info*)vi->codec_setup; | |||
private_state *b=(private_state*)vd->backend_state; | |||
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)l; | |||
@@ -774,17 +748,17 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){ | |||
int ch_in_bundle=0; | |||
for(j=0;j<vi->channels;j++){ | |||
if(info->chmuxlist[j]==i){ | |||
if(nonzero[j]) | |||
zerobundle[ch_in_bundle]=1; | |||
else | |||
zerobundle[ch_in_bundle]=0; | |||
pcmbundle[ch_in_bundle++]=vb->pcm[j]; | |||
if(nonzero[j]) | |||
zerobundle[ch_in_bundle]=1; | |||
else | |||
zerobundle[ch_in_bundle]=0; | |||
pcmbundle[ch_in_bundle++]=vb->pcm[j]; | |||
} | |||
} | |||
_residue_P[ci->residue_type[info->residuesubmap[i]]]-> | |||
inverse(vb,b->residue[info->residuesubmap[i]], | |||
pcmbundle,zerobundle,ch_in_bundle); | |||
pcmbundle,zerobundle,ch_in_bundle); | |||
} | |||
/* channel coupling */ | |||
@@ -797,21 +771,21 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){ | |||
float ang=pcmA[j]; | |||
if(mag>0) | |||
if(ang>0){ | |||
pcmM[j]=mag; | |||
pcmA[j]=mag-ang; | |||
}else{ | |||
pcmA[j]=mag; | |||
pcmM[j]=mag+ang; | |||
} | |||
if(ang>0){ | |||
pcmM[j]=mag; | |||
pcmA[j]=mag-ang; | |||
}else{ | |||
pcmA[j]=mag; | |||
pcmM[j]=mag+ang; | |||
} | |||
else | |||
if(ang>0){ | |||
pcmM[j]=mag; | |||
pcmA[j]=mag+ang; | |||
}else{ | |||
pcmA[j]=mag; | |||
pcmM[j]=mag-ang; | |||
} | |||
if(ang>0){ | |||
pcmM[j]=mag; | |||
pcmA[j]=mag+ang; | |||
}else{ | |||
pcmA[j]=mag; | |||
pcmM[j]=mag-ang; | |||
} | |||
} | |||
} | |||
@@ -821,7 +795,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){ | |||
int submap=info->chmuxlist[i]; | |||
_floor_P[ci->floor_type[info->floorsubmap[submap]]]-> | |||
inverse2(vb,b->flr[info->floorsubmap[submap]], | |||
floormemo[i],pcm); | |||
floormemo[i],pcm); | |||
} | |||
/* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ | |||
@@ -836,7 +810,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){ | |||
} | |||
/* export hooks */ | |||
vorbis_func_mapping mapping0_exportbundle={ | |||
const vorbis_func_mapping mapping0_exportbundle={ | |||
&mapping0_pack, | |||
&mapping0_unpack, | |||
&mapping0_free_info, | |||
@@ -845,4 +819,4 @@ vorbis_func_mapping mapping0_exportbundle={ | |||
}; | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: masking curve data for psychoacoustics | |||
last mod: $Id: masking.h,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: masking.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -22,7 +22,7 @@ | |||
overly for only a bin or two of savings. */ | |||
#define MAX_ATH 88 | |||
static float ATH[]={ | |||
static const float ATH[]={ | |||
/*15*/ -51, -52, -53, -54, -55, -56, -57, -58, | |||
/*31*/ -59, -60, -61, -62, -63, -64, -65, -66, | |||
/*63*/ -67, -68, -69, -70, -71, -72, -73, -74, | |||
@@ -48,7 +48,7 @@ static float ATH[]={ | |||
/* (Vorbis 0dB, the loudest possible tone, is assumed to be ~100dB SPL | |||
for collection of these curves) */ | |||
static float tonemasks[P_BANDS][6][EHMER_MAX]={ | |||
static const float tonemasks[P_BANDS][6][EHMER_MAX]={ | |||
/* 62.5 Hz */ | |||
{{ -60, -60, -60, -60, -60, -60, -60, -60, | |||
-60, -60, -60, -60, -62, -62, -65, -73, |
@@ -5,14 +5,14 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: normalized modified discrete cosine transform | |||
power of two length transform only [64 <= n ] | |||
last mod: $Id: mdct.c,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: mdct.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||
Original algorithm adapted long ago from _The use of multirate filter | |||
banks for coding of high quality digital audio_, by T. Sporer, | |||
@@ -84,7 +84,7 @@ void mdct_init(mdct_lookup *lookup,int n){ | |||
for(i=0;i<n/8;i++){ | |||
int acc=0; | |||
for(j=0;msb>>j;j++) | |||
if((msb>>j)&i)acc|=1<<j; | |||
if((msb>>j)&i)acc|=1<<j; | |||
bitrev[i*2]=((~acc)&mask)-1; | |||
bitrev[i*2+1]=acc; | |||
@@ -100,20 +100,20 @@ STIN void mdct_butterfly_8(DATA_TYPE *x){ | |||
REG_TYPE r2 = x[4] + x[0]; | |||
REG_TYPE r3 = x[4] - x[0]; | |||
x[6] = r0 + r2; | |||
x[4] = r0 - r2; | |||
x[6] = r0 + r2; | |||
x[4] = r0 - r2; | |||
r0 = x[5] - x[1]; | |||
r2 = x[7] - x[3]; | |||
x[0] = r1 + r0; | |||
x[2] = r1 - r0; | |||
r0 = x[5] - x[1]; | |||
r2 = x[7] - x[3]; | |||
x[0] = r1 + r0; | |||
x[2] = r1 - r0; | |||
r0 = x[5] + x[1]; | |||
r1 = x[7] + x[3]; | |||
x[3] = r2 + r3; | |||
x[1] = r2 - r3; | |||
x[7] = r1 + r0; | |||
x[5] = r1 - r0; | |||
r0 = x[5] + x[1]; | |||
r1 = x[7] + x[3]; | |||
x[3] = r2 + r3; | |||
x[1] = r2 - r3; | |||
x[7] = r1 + r0; | |||
x[5] = r1 - r0; | |||
} | |||
@@ -148,8 +148,8 @@ STIN void mdct_butterfly_16(DATA_TYPE *x){ | |||
x[6] = r0; | |||
x[7] = r1; | |||
mdct_butterfly_8(x); | |||
mdct_butterfly_8(x+8); | |||
mdct_butterfly_8(x); | |||
mdct_butterfly_8(x+8); | |||
} | |||
/* 32 point butterfly (in place, 4 register) */ | |||
@@ -158,68 +158,68 @@ STIN void mdct_butterfly_32(DATA_TYPE *x){ | |||
REG_TYPE r1 = x[31] - x[15]; | |||
x[30] += x[14]; | |||
x[31] += x[15]; | |||
x[31] += x[15]; | |||
x[14] = r0; | |||
x[15] = r1; | |||
x[15] = r1; | |||
r0 = x[28] - x[12]; | |||
r1 = x[29] - x[13]; | |||
r1 = x[29] - x[13]; | |||
x[28] += x[12]; | |||
x[29] += x[13]; | |||
x[29] += x[13]; | |||
x[12] = MULT_NORM( r0 * cPI1_8 - r1 * cPI3_8 ); | |||
x[13] = MULT_NORM( r0 * cPI3_8 + r1 * cPI1_8 ); | |||
x[13] = MULT_NORM( r0 * cPI3_8 + r1 * cPI1_8 ); | |||
r0 = x[26] - x[10]; | |||
r1 = x[27] - x[11]; | |||
x[26] += x[10]; | |||
x[27] += x[11]; | |||
x[10] = MULT_NORM(( r0 - r1 ) * cPI2_8); | |||
x[11] = MULT_NORM(( r0 + r1 ) * cPI2_8); | |||
r0 = x[24] - x[8]; | |||
r1 = x[25] - x[9]; | |||
x[24] += x[8]; | |||
x[25] += x[9]; | |||
x[8] = MULT_NORM( r0 * cPI3_8 - r1 * cPI1_8 ); | |||
x[9] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 ); | |||
r0 = x[22] - x[6]; | |||
r1 = x[7] - x[23]; | |||
x[22] += x[6]; | |||
x[23] += x[7]; | |||
x[6] = r1; | |||
x[7] = r0; | |||
r0 = x[4] - x[20]; | |||
r1 = x[5] - x[21]; | |||
x[20] += x[4]; | |||
x[21] += x[5]; | |||
x[4] = MULT_NORM( r1 * cPI1_8 + r0 * cPI3_8 ); | |||
x[5] = MULT_NORM( r1 * cPI3_8 - r0 * cPI1_8 ); | |||
r0 = x[2] - x[18]; | |||
r1 = x[3] - x[19]; | |||
x[18] += x[2]; | |||
x[19] += x[3]; | |||
x[2] = MULT_NORM(( r1 + r0 ) * cPI2_8); | |||
x[3] = MULT_NORM(( r1 - r0 ) * cPI2_8); | |||
r0 = x[0] - x[16]; | |||
r1 = x[1] - x[17]; | |||
x[16] += x[0]; | |||
x[17] += x[1]; | |||
x[0] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 ); | |||
x[1] = MULT_NORM( r1 * cPI1_8 - r0 * cPI3_8 ); | |||
mdct_butterfly_16(x); | |||
mdct_butterfly_16(x+16); | |||
r1 = x[27] - x[11]; | |||
x[26] += x[10]; | |||
x[27] += x[11]; | |||
x[10] = MULT_NORM(( r0 - r1 ) * cPI2_8); | |||
x[11] = MULT_NORM(( r0 + r1 ) * cPI2_8); | |||
r0 = x[24] - x[8]; | |||
r1 = x[25] - x[9]; | |||
x[24] += x[8]; | |||
x[25] += x[9]; | |||
x[8] = MULT_NORM( r0 * cPI3_8 - r1 * cPI1_8 ); | |||
x[9] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 ); | |||
r0 = x[22] - x[6]; | |||
r1 = x[7] - x[23]; | |||
x[22] += x[6]; | |||
x[23] += x[7]; | |||
x[6] = r1; | |||
x[7] = r0; | |||
r0 = x[4] - x[20]; | |||
r1 = x[5] - x[21]; | |||
x[20] += x[4]; | |||
x[21] += x[5]; | |||
x[4] = MULT_NORM( r1 * cPI1_8 + r0 * cPI3_8 ); | |||
x[5] = MULT_NORM( r1 * cPI3_8 - r0 * cPI1_8 ); | |||
r0 = x[2] - x[18]; | |||
r1 = x[3] - x[19]; | |||
x[18] += x[2]; | |||
x[19] += x[3]; | |||
x[2] = MULT_NORM(( r1 + r0 ) * cPI2_8); | |||
x[3] = MULT_NORM(( r1 - r0 ) * cPI2_8); | |||
r0 = x[0] - x[16]; | |||
r1 = x[1] - x[17]; | |||
x[16] += x[0]; | |||
x[17] += x[1]; | |||
x[0] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 ); | |||
x[1] = MULT_NORM( r1 * cPI1_8 - r0 * cPI3_8 ); | |||
mdct_butterfly_16(x); | |||
mdct_butterfly_16(x+16); | |||
} | |||
/* N point first stage butterfly (in place, 2 register) */ | |||
STIN void mdct_butterfly_first(DATA_TYPE *T, | |||
DATA_TYPE *x, | |||
int points){ | |||
DATA_TYPE *x, | |||
int points){ | |||
DATA_TYPE *x1 = x + points - 8; | |||
DATA_TYPE *x2 = x + (points>>1) - 8; | |||
@@ -229,32 +229,32 @@ STIN void mdct_butterfly_first(DATA_TYPE *T, | |||
do{ | |||
r0 = x1[6] - x2[6]; | |||
r1 = x1[7] - x2[7]; | |||
x1[6] += x2[6]; | |||
x1[7] += x2[7]; | |||
x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
r0 = x1[4] - x2[4]; | |||
r1 = x1[5] - x2[5]; | |||
x1[4] += x2[4]; | |||
x1[5] += x2[5]; | |||
x2[4] = MULT_NORM(r1 * T[5] + r0 * T[4]); | |||
x2[5] = MULT_NORM(r1 * T[4] - r0 * T[5]); | |||
r0 = x1[2] - x2[2]; | |||
r1 = x1[3] - x2[3]; | |||
x1[2] += x2[2]; | |||
x1[3] += x2[3]; | |||
x2[2] = MULT_NORM(r1 * T[9] + r0 * T[8]); | |||
x2[3] = MULT_NORM(r1 * T[8] - r0 * T[9]); | |||
r0 = x1[0] - x2[0]; | |||
r1 = x1[1] - x2[1]; | |||
x1[0] += x2[0]; | |||
x1[1] += x2[1]; | |||
x2[0] = MULT_NORM(r1 * T[13] + r0 * T[12]); | |||
x2[1] = MULT_NORM(r1 * T[12] - r0 * T[13]); | |||
r1 = x1[7] - x2[7]; | |||
x1[6] += x2[6]; | |||
x1[7] += x2[7]; | |||
x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
r0 = x1[4] - x2[4]; | |||
r1 = x1[5] - x2[5]; | |||
x1[4] += x2[4]; | |||
x1[5] += x2[5]; | |||
x2[4] = MULT_NORM(r1 * T[5] + r0 * T[4]); | |||
x2[5] = MULT_NORM(r1 * T[4] - r0 * T[5]); | |||
r0 = x1[2] - x2[2]; | |||
r1 = x1[3] - x2[3]; | |||
x1[2] += x2[2]; | |||
x1[3] += x2[3]; | |||
x2[2] = MULT_NORM(r1 * T[9] + r0 * T[8]); | |||
x2[3] = MULT_NORM(r1 * T[8] - r0 * T[9]); | |||
r0 = x1[0] - x2[0]; | |||
r1 = x1[1] - x2[1]; | |||
x1[0] += x2[0]; | |||
x1[1] += x2[1]; | |||
x2[0] = MULT_NORM(r1 * T[13] + r0 * T[12]); | |||
x2[1] = MULT_NORM(r1 * T[12] - r0 * T[13]); | |||
x1-=8; | |||
x2-=8; | |||
@@ -265,9 +265,9 @@ STIN void mdct_butterfly_first(DATA_TYPE *T, | |||
/* N/stage point generic N stage butterfly (in place, 2 register) */ | |||
STIN void mdct_butterfly_generic(DATA_TYPE *T, | |||
DATA_TYPE *x, | |||
int points, | |||
int trigint){ | |||
DATA_TYPE *x, | |||
int points, | |||
int trigint){ | |||
DATA_TYPE *x1 = x + points - 8; | |||
DATA_TYPE *x2 = x + (points>>1) - 8; | |||
@@ -277,40 +277,40 @@ STIN void mdct_butterfly_generic(DATA_TYPE *T, | |||
do{ | |||
r0 = x1[6] - x2[6]; | |||
r1 = x1[7] - x2[7]; | |||
x1[6] += x2[6]; | |||
x1[7] += x2[7]; | |||
x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
T+=trigint; | |||
r0 = x1[4] - x2[4]; | |||
r1 = x1[5] - x2[5]; | |||
x1[4] += x2[4]; | |||
x1[5] += x2[5]; | |||
x2[4] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[5] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
T+=trigint; | |||
r0 = x1[2] - x2[2]; | |||
r1 = x1[3] - x2[3]; | |||
x1[2] += x2[2]; | |||
x1[3] += x2[3]; | |||
x2[2] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[3] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
T+=trigint; | |||
r0 = x1[0] - x2[0]; | |||
r1 = x1[1] - x2[1]; | |||
x1[0] += x2[0]; | |||
x1[1] += x2[1]; | |||
x2[0] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[1] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
T+=trigint; | |||
r1 = x1[7] - x2[7]; | |||
x1[6] += x2[6]; | |||
x1[7] += x2[7]; | |||
x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
T+=trigint; | |||
r0 = x1[4] - x2[4]; | |||
r1 = x1[5] - x2[5]; | |||
x1[4] += x2[4]; | |||
x1[5] += x2[5]; | |||
x2[4] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[5] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
T+=trigint; | |||
r0 = x1[2] - x2[2]; | |||
r1 = x1[3] - x2[3]; | |||
x1[2] += x2[2]; | |||
x1[3] += x2[3]; | |||
x2[2] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[3] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
T+=trigint; | |||
r0 = x1[0] - x2[0]; | |||
r1 = x1[1] - x2[1]; | |||
x1[0] += x2[0]; | |||
x1[1] += x2[1]; | |||
x2[0] = MULT_NORM(r1 * T[1] + r0 * T[0]); | |||
x2[1] = MULT_NORM(r1 * T[0] - r0 * T[1]); | |||
T+=trigint; | |||
x1-=8; | |||
x2-=8; | |||
@@ -318,8 +318,8 @@ STIN void mdct_butterfly_generic(DATA_TYPE *T, | |||
} | |||
STIN void mdct_butterflies(mdct_lookup *init, | |||
DATA_TYPE *x, | |||
int points){ | |||
DATA_TYPE *x, | |||
int points){ | |||
DATA_TYPE *T=init->trig; | |||
int stages=init->log2n-5; | |||
@@ -348,7 +348,7 @@ void mdct_clear(mdct_lookup *l){ | |||
} | |||
STIN void mdct_bitreverse(mdct_lookup *init, | |||
DATA_TYPE *x){ | |||
DATA_TYPE *x){ | |||
int n = init->n; | |||
int *bit = init->bitrev; | |||
DATA_TYPE *w0 = x; | |||
@@ -364,15 +364,15 @@ STIN void mdct_bitreverse(mdct_lookup *init, | |||
REG_TYPE r2 = MULT_NORM(r1 * T[0] + r0 * T[1]); | |||
REG_TYPE r3 = MULT_NORM(r1 * T[1] - r0 * T[0]); | |||
w1 -= 4; | |||
w1 -= 4; | |||
r0 = HALVE(x0[1] + x1[1]); | |||
r1 = HALVE(x0[0] - x1[0]); | |||
w0[0] = r0 + r2; | |||
w1[2] = r0 - r2; | |||
w0[1] = r1 + r3; | |||
w1[3] = r3 - r1; | |||
w0[0] = r0 + r2; | |||
w1[2] = r0 - r2; | |||
w0[1] = r1 + r3; | |||
w1[3] = r3 - r1; | |||
x0 = x+bit[2]; | |||
x1 = x+bit[3]; | |||
@@ -385,14 +385,14 @@ STIN void mdct_bitreverse(mdct_lookup *init, | |||
r0 = HALVE(x0[1] + x1[1]); | |||
r1 = HALVE(x0[0] - x1[0]); | |||
w0[2] = r0 + r2; | |||
w1[0] = r0 - r2; | |||
w0[3] = r1 + r3; | |||
w1[1] = r3 - r1; | |||
w0[2] = r0 + r2; | |||
w1[0] = r0 - r2; | |||
w0[3] = r1 + r3; | |||
w1[1] = r3 - r1; | |||
T += 4; | |||
bit += 4; | |||
w0 += 4; | |||
T += 4; | |||
bit += 4; | |||
w0 += 4; | |||
}while(w0<w1); | |||
} | |||
@@ -564,5 +564,4 @@ void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out){ | |||
T+=2; | |||
} | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: mdct.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: misc.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -19,16 +19,21 @@ | |||
#define _V_RANDOM_H_ | |||
#include "../../codec.h" | |||
extern int analysis_noisy; | |||
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); | |||
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); | |||
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: floor_all.h 17050 2010-03-26 01:34:42Z xiphmont $ | |||
********************************************************************/ | |||
@@ -19,21 +19,21 @@ | |||
#include "../backends.h" | |||
#include "../books/floor/floor_books.h" | |||
static static_codebook *_floor_128x4_books[]={ | |||
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 static_codebook *_floor_256x4_books[]={ | |||
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 static_codebook *_floor_128x7_books[]={ | |||
static const static_codebook*const _floor_128x7_books[]={ | |||
&_huff_book_line_128x7_class0, | |||
&_huff_book_line_128x7_class1, | |||
@@ -44,7 +44,7 @@ static static_codebook *_floor_128x7_books[]={ | |||
&_huff_book_line_128x7_1sub2, | |||
&_huff_book_line_128x7_1sub3, | |||
}; | |||
static static_codebook *_floor_256x7_books[]={ | |||
static const static_codebook*const _floor_256x7_books[]={ | |||
&_huff_book_line_256x7_class0, | |||
&_huff_book_line_256x7_class1, | |||
@@ -55,7 +55,7 @@ static static_codebook *_floor_256x7_books[]={ | |||
&_huff_book_line_256x7_1sub2, | |||
&_huff_book_line_256x7_1sub3, | |||
}; | |||
static static_codebook *_floor_128x11_books[]={ | |||
static const static_codebook*const _floor_128x11_books[]={ | |||
&_huff_book_line_128x11_class1, | |||
&_huff_book_line_128x11_class2, | |||
&_huff_book_line_128x11_class3, | |||
@@ -70,7 +70,7 @@ static static_codebook *_floor_128x11_books[]={ | |||
&_huff_book_line_128x11_3sub2, | |||
&_huff_book_line_128x11_3sub3, | |||
}; | |||
static static_codebook *_floor_128x17_books[]={ | |||
static const static_codebook*const _floor_128x17_books[]={ | |||
&_huff_book_line_128x17_class1, | |||
&_huff_book_line_128x17_class2, | |||
&_huff_book_line_128x17_class3, | |||
@@ -85,14 +85,14 @@ static static_codebook *_floor_128x17_books[]={ | |||
&_huff_book_line_128x17_3sub2, | |||
&_huff_book_line_128x17_3sub3, | |||
}; | |||
static static_codebook *_floor_256x4low_books[]={ | |||
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 static_codebook *_floor_1024x27_books[]={ | |||
static const static_codebook*const _floor_1024x27_books[]={ | |||
&_huff_book_line_1024x27_class1, | |||
&_huff_book_line_1024x27_class2, | |||
&_huff_book_line_1024x27_class3, | |||
@@ -110,7 +110,7 @@ static static_codebook *_floor_1024x27_books[]={ | |||
&_huff_book_line_1024x27_4sub2, | |||
&_huff_book_line_1024x27_4sub3, | |||
}; | |||
static static_codebook *_floor_2048x27_books[]={ | |||
static const static_codebook*const _floor_2048x27_books[]={ | |||
&_huff_book_line_2048x27_class1, | |||
&_huff_book_line_2048x27_class2, | |||
&_huff_book_line_2048x27_class3, | |||
@@ -129,7 +129,7 @@ static static_codebook *_floor_2048x27_books[]={ | |||
&_huff_book_line_2048x27_4sub3, | |||
}; | |||
static static_codebook *_floor_512x17_books[]={ | |||
static const static_codebook*const _floor_512x17_books[]={ | |||
&_huff_book_line_512x17_class1, | |||
&_huff_book_line_512x17_class2, | |||
&_huff_book_line_512x17_class3, | |||
@@ -145,7 +145,11 @@ static static_codebook *_floor_512x17_books[]={ | |||
&_huff_book_line_512x17_3sub3, | |||
}; | |||
static static_codebook **_floor_books[10]={ | |||
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, | |||
@@ -156,92 +160,101 @@ static static_codebook **_floor_books[10]={ | |||
_floor_1024x27_books, | |||
_floor_2048x27_books, | |||
_floor_512x17_books, | |||
_floor_Xx0_books, | |||
}; | |||
static vorbis_info_floor1 _floor[10]={ | |||
/* 128 x 4 */ | |||
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., -1 | |||
60,30,500, 1.,18., 128 | |||
}, | |||
/* 256 x 4 */ | |||
/* 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., -1 | |||
60,30,500, 1.,18., 256 | |||
}, | |||
/* 128 x 7 */ | |||
/* 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., -1 | |||
60,30,500, 1.,18., 128 | |||
}, | |||
/* 256 x 7 */ | |||
/* 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., -1 | |||
60,30,500, 1.,18., 256 | |||
}, | |||
/* 128 x 11 */ | |||
/* 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., -1 | |||
60,30,500, 1,18., 128 | |||
}, | |||
/* 128 x 17 */ | |||
/* 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., -1 | |||
60,30,500, 1,18., 128 | |||
}, | |||
/* 256 x 4 (low bitrate version) */ | |||
/* 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., -1 | |||
60,30,500, 1.,18., 256 | |||
}, | |||
/* 1024 x 27 */ | |||
/* 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., -1 /* lowpass */ | |||
60,30,500, 3,18., 1024 | |||
}, | |||
/* 2048 x 27 */ | |||
/* 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., -1 /* lowpass */ | |||
60,30,500, 3,18., 2048 | |||
}, | |||
/* 512 x 17 */ | |||
/* 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., -1 /* lowpass! */ | |||
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 | |||
}, | |||
}; |
@@ -5,25 +5,25 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: psych_11.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
static double _psy_lowpass_11[3]={4.5,5.5,30.,}; | |||
static const double _psy_lowpass_11[3]={4.5,5.5,30.,}; | |||
static att3 _psy_tone_masteratt_11[3]={ | |||
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 vp_adjblock _vp_tonemask_adj_11[3]={ | |||
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 */ | |||
@@ -32,7 +32,7 @@ static vp_adjblock _vp_tonemask_adj_11[3]={ | |||
}; | |||
static noise3 _psy_noisebias_11[3]={ | |||
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}, | |||
@@ -47,4 +47,4 @@ static noise3 _psy_noisebias_11[3]={ | |||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24, 99, 99, 99}}}, | |||
}; | |||
static double _noise_thresh_11[3]={ .3,.5,.5 }; | |||
static const double _noise_thresh_11[3]={ .3,.5,.5 }; |
@@ -5,18 +5,18 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: psych_16.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
/* stereo mode by base quality level */ | |||
static adj_stereo _psy_stereo_modes_16[4]={ | |||
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}, | |||
@@ -36,16 +36,16 @@ static adj_stereo _psy_stereo_modes_16[4]={ | |||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||
}; | |||
static double _psy_lowpass_16[4]={6.5,8,30.,99.}; | |||
static const double _psy_lowpass_16[4]={6.5,8,30.,99.}; | |||
static att3 _psy_tone_masteratt_16[4]={ | |||
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 vp_adjblock _vp_tonemask_adj_16[4]={ | |||
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 */ | |||
@@ -55,7 +55,7 @@ static vp_adjblock _vp_tonemask_adj_16[4]={ | |||
}; | |||
static noise3 _psy_noisebias_16_short[4]={ | |||
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}, | |||
@@ -74,7 +74,7 @@ static noise3 _psy_noisebias_16_short[4]={ | |||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||
}; | |||
static noise3 _psy_noisebias_16_impulse[4]={ | |||
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}, | |||
@@ -93,7 +93,7 @@ static noise3 _psy_noisebias_16_impulse[4]={ | |||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||
}; | |||
static noise3 _psy_noisebias_16[4]={ | |||
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}, | |||
@@ -112,15 +112,22 @@ static noise3 _psy_noisebias_16[4]={ | |||
{-30,-30,-30,-30,-26,-26,-26,-26,-26,-26,-26,-26,-26,-24,-20,-20,-20}}}, | |||
}; | |||
static double _noise_thresh_16[4]={ .3,.5,.5,.5 }; | |||
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 int _noise_start_16[3]={ 256,256,9999 }; | |||
static int _noise_part_16[4]={ 8,8,8,8 }; | |||
static const int _noise_start_16[3]={ 256,256,9999 }; | |||
static const int _noise_part_16[4]={ 8,8,8,8 }; | |||
static int _psy_ath_floater_16[4]={ | |||
static const int _psy_ath_floater_16[4]={ | |||
-100,-100,-100,-105, | |||
}; | |||
static int _psy_ath_abs_16[4]={ | |||
static const int _psy_ath_abs_16[4]={ | |||
-130,-130,-130,-140, | |||
}; |
@@ -5,20 +5,20 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: key psychoacoustic settings for 44.1/48kHz | |||
last mod: $Id: psych_44.h,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: psych_44.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||
********************************************************************/ | |||
/* preecho trigger settings *****************************************/ | |||
static vorbis_info_psy_global _psy_global_44[5]={ | |||
static const vorbis_info_psy_global _psy_global_44[5]={ | |||
{8, /* lines per eighth octave */ | |||
{20.f,14.f,12.f,12.f,12.f,12.f,12.f}, | |||
@@ -53,7 +53,7 @@ static vorbis_info_psy_global _psy_global_44[5]={ | |||
}; | |||
/* noise compander lookups * low, mid, high quality ****************/ | |||
static compandblock _psy_compand_44[6]={ | |||
static const compandblock _psy_compand_44[6]={ | |||
/* sub-mode Z short */ | |||
{{ | |||
0, 1, 2, 3, 4, 5, 6, 7, /* 7dB */ | |||
@@ -106,7 +106,7 @@ static compandblock _psy_compand_44[6]={ | |||
/* tonal masking curve level adjustments *************************/ | |||
static vp_adjblock _vp_tonemask_adj_longblock[12]={ | |||
static const vp_adjblock _vp_tonemask_adj_longblock[12]={ | |||
/* 63 125 250 500 1 2 4 8 16 */ | |||
@@ -146,7 +146,7 @@ static vp_adjblock _vp_tonemask_adj_longblock[12]={ | |||
{{-16,-16,-16,-16,-16,-16,-16,-15,-14,-14,-14,-12, -9, -4, -2, -2, 0}}, /* 10 */ | |||
}; | |||
static vp_adjblock _vp_tonemask_adj_otherblock[12]={ | |||
static const vp_adjblock _vp_tonemask_adj_otherblock[12]={ | |||
/* 63 125 250 500 1 2 4 8 16 */ | |||
{{ -3, -8,-13,-15,-10,-10, -9, -9, -9, -9, -9, 1, 1, 1, 1, 1, 1}}, /* -1 */ | |||
@@ -186,7 +186,7 @@ static vp_adjblock _vp_tonemask_adj_otherblock[12]={ | |||
}; | |||
/* noise bias (transition block) */ | |||
static noise3 _psy_noisebias_trans[12]={ | |||
static const noise3 _psy_noisebias_trans[12]={ | |||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||
/* -1 */ | |||
{{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20}, | |||
@@ -269,7 +269,7 @@ static noise3 _psy_noisebias_trans[12]={ | |||
}; | |||
/* noise bias (long block) */ | |||
static noise3 _psy_noisebias_long[12]={ | |||
static const noise3 _psy_noisebias_long[12]={ | |||
/*63 125 250 500 1k 2k 4k 8k 16k*/ | |||
/* -1 */ | |||
{{{-10,-10,-10,-10,-10, -4, 0, 0, 0, 6, 6, 6, 6, 10, 10, 12, 20}, | |||
@@ -344,7 +344,7 @@ static noise3 _psy_noisebias_long[12]={ | |||
}; | |||
/* noise bias (impulse block) */ | |||
static noise3 _psy_noisebias_impulse[12]={ | |||
static const noise3 _psy_noisebias_impulse[12]={ | |||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||
/* -1 */ | |||
{{{-10,-10,-10,-10,-10, -4, 0, 0, 4, 8, 8, 8, 8, 10, 12, 14, 20}, | |||
@@ -413,7 +413,7 @@ static noise3 _psy_noisebias_impulse[12]={ | |||
}; | |||
/* noise bias (padding block) */ | |||
static noise3 _psy_noisebias_padding[12]={ | |||
static const noise3 _psy_noisebias_padding[12]={ | |||
/* 63 125 250 500 1k 2k 4k 8k 16k*/ | |||
/* -1 */ | |||
@@ -471,24 +471,24 @@ static noise3 _psy_noisebias_padding[12]={ | |||
}; | |||
static noiseguard _psy_noiseguards_44[4]={ | |||
static const noiseguard _psy_noiseguards_44[4]={ | |||
{3,3,15}, | |||
{3,3,15}, | |||
{10,10,100}, | |||
{10,10,100}, | |||
}; | |||
static int _psy_tone_suppress[12]={ | |||
static const int _psy_tone_suppress[12]={ | |||
-20,-20,-20,-20,-20,-24,-30,-40,-40,-45,-45,-45, | |||
}; | |||
static int _psy_tone_0dB[12]={ | |||
static const int _psy_tone_0dB[12]={ | |||
90,90,95,95,95,95,105,105,105,105,105,105, | |||
}; | |||
static int _psy_noise_suppress[12]={ | |||
static const int _psy_noise_suppress[12]={ | |||
-20,-20,-24,-24,-24,-24,-30,-40,-40,-45,-45,-45, | |||
}; | |||
static vorbis_info_psy _psy_info_template={ | |||
static const vorbis_info_psy _psy_info_template={ | |||
/* blockflag */ | |||
-1, | |||
/* ath_adjatt, ath_maxatt */ | |||
@@ -500,16 +500,16 @@ static vorbis_info_psy _psy_info_template={ | |||
1, -0.f, .5f, .5f, 0,0,0, | |||
/* noiseoffset*3, noisecompand, max_curve_dB */ | |||
{{-1},{-1},{-1}},{-1},105.f, | |||
/* noise normalization - channel_p, point_p, start, partition, thresh. */ | |||
0,0,-1,-1,0., | |||
/* noise normalization - noise_p, start, partition, thresh. */ | |||
0,-1,-1,0., | |||
}; | |||
/* ath ****************/ | |||
static int _psy_ath_floater[12]={ | |||
static const int _psy_ath_floater[12]={ | |||
-100,-100,-100,-100,-100,-100,-105,-105,-105,-105,-110,-120, | |||
}; | |||
static int _psy_ath_abs[12]={ | |||
static const int _psy_ath_abs[12]={ | |||
-130,-130,-130,-130,-140,-140,-140,-140,-140,-140,-140,-150, | |||
}; | |||
@@ -522,7 +522,7 @@ static int _psy_ath_abs[12]={ | |||
/* various stereo possibilities */ | |||
/* stereo mode by base quality level */ | |||
static adj_stereo _psy_stereo_modes_44[12]={ | |||
static const adj_stereo _psy_stereo_modes_44[12]={ | |||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 -1 */ | |||
{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1, 0, 0, 0, 0}, | |||
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 4, 3}, | |||
@@ -530,10 +530,6 @@ static adj_stereo _psy_stereo_modes_44[12]={ | |||
{ 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 */ | |||
/*{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 2, 1, 0, 0, 0, 0}, | |||
{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 4, 3}, | |||
{ 1, 2, 3, 4, 5, 5, 6, 6, 6, 6, 6, 7, 8, 8, 8}, | |||
{ 12,12.5, 13,13.5, 14,14.5, 15, 99, 99, 99, 99, 99, 99, 99, 99}},*/ | |||
{{ 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0, 0, 0, 0, 0}, | |||
{ 8, 8, 8, 8, 6, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3}, | |||
{ 1, 2, 3, 4, 4, 5, 6, 6, 6, 6, 6, 8, 8, 8, 8}, | |||
@@ -548,10 +544,6 @@ static adj_stereo _psy_stereo_modes_44[12]={ | |||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 */ | |||
/* {{ 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 0, 0, 0, 0, 0}, | |||
{ 8, 8, 8, 6, 5, 5, 5, 5, 5, 5, 5, 4, 3, 2, 1}, | |||
{ 3, 4, 4, 4, 5, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8}, | |||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, */ | |||
{{ 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 0, 0, 0, 0, 0}, | |||
{ 8, 8, 6, 6, 5, 5, 4, 4, 4, 4, 4, 4, 3, 2, 1}, | |||
{ 3, 4, 4, 5, 5, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8}, | |||
@@ -567,37 +559,21 @@ static adj_stereo _psy_stereo_modes_44[12]={ | |||
{ 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10}, | |||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 5 */ | |||
/* {{ 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0}, | |||
{ 6, 6, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10}, | |||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}},*/ | |||
{{ 2, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0}, | |||
{ 6, 7, 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12}, | |||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 6 */ | |||
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, | |||
{ 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}, | |||
{ 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 8, 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, | |||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 7 */ | |||
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, | |||
{ 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}, | |||
{ 3, 3, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 8, 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, | |||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||
/* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 8 */ | |||
/* {{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, | |||
{ 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}, | |||
{ 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, | |||
{ 8, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12}, | |||
@@ -615,7 +591,7 @@ static adj_stereo _psy_stereo_modes_44[12]={ | |||
}; | |||
/* tone master attenuation by base quality mode and bitrate tweak */ | |||
static att3 _psy_tone_masteratt_44[12]={ | |||
static const att3 _psy_tone_masteratt_44[12]={ | |||
{{ 35, 21, 9}, 0, 0}, /* -1 */ | |||
{{ 30, 20, 8}, -2, 1.25}, /* 0 */ | |||
/* {{ 25, 14, 4}, 0, 0}, *//* 1 */ | |||
@@ -633,34 +609,34 @@ static att3 _psy_tone_masteratt_44[12]={ | |||
}; | |||
/* lowpass by mode **************/ | |||
static double _psy_lowpass_44[12]={ | |||
static const double _psy_lowpass_44[12]={ | |||
/* 15.1,15.8,16.5,17.9,20.5,48.,999.,999.,999.,999.,999. */ | |||
13.9,15.1,15.8,16.5,17.2,18.9,20.1,48.,999.,999.,999.,999. | |||
}; | |||
/* noise normalization **********/ | |||
static int _noise_start_short_44[11]={ | |||
static const int _noise_start_short_44[11]={ | |||
/* 16,16,16,16,32,32,9999,9999,9999,9999 */ | |||
32,16,16,16,32,9999,9999,9999,9999,9999,9999 | |||
}; | |||
static int _noise_start_long_44[11]={ | |||
static const int _noise_start_long_44[11]={ | |||
/* 128,128,128,256,512,512,9999,9999,9999,9999 */ | |||
256,128,128,256,512,9999,9999,9999,9999,9999,9999 | |||
}; | |||
static int _noise_part_short_44[11]={ | |||
static const int _noise_part_short_44[11]={ | |||
8,8,8,8,8,8,8,8,8,8,8 | |||
}; | |||
static int _noise_part_long_44[11]={ | |||
static const int _noise_part_long_44[11]={ | |||
32,32,32,32,32,32,32,32,32,32,32 | |||
}; | |||
static double _noise_thresh_44[11]={ | |||
static const double _noise_thresh_44[11]={ | |||
/* .2,.2,.3,.4,.5,.5,9999.,9999.,9999.,9999., */ | |||
.2,.2,.2,.4,.6,9999.,9999.,9999.,9999.,9999.,9999., | |||
}; | |||
static double _noise_thresh_5only[2]={ | |||
static const double _noise_thresh_5only[2]={ | |||
.5,.5, | |||
}; |
@@ -5,23 +5,23 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: psych_8.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
static att3 _psy_tone_masteratt_8[3]={ | |||
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 vp_adjblock _vp_tonemask_adj_8[3]={ | |||
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 */ | |||
@@ -30,7 +30,7 @@ static vp_adjblock _vp_tonemask_adj_8[3]={ | |||
}; | |||
static noise3 _psy_noisebias_8[3]={ | |||
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}, | |||
@@ -46,7 +46,7 @@ static noise3 _psy_noisebias_8[3]={ | |||
}; | |||
/* stereo mode by base quality level */ | |||
static adj_stereo _psy_stereo_modes_8[3]={ | |||
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}, | |||
@@ -62,12 +62,12 @@ static adj_stereo _psy_stereo_modes_8[3]={ | |||
{ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99}}, | |||
}; | |||
static noiseguard _psy_noiseguards_8[2]={ | |||
static const noiseguard _psy_noiseguards_8[2]={ | |||
{10,10,-1}, | |||
{10,10,-1}, | |||
}; | |||
static compandblock _psy_compand_8[2]={ | |||
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 */ | |||
@@ -84,18 +84,18 @@ static compandblock _psy_compand_8[2]={ | |||
}}, | |||
}; | |||
static double _psy_lowpass_8[3]={3.,4.,4.}; | |||
static int _noise_start_8[2]={ | |||
static const double _psy_lowpass_8[3]={3.,4.,4.}; | |||
static const int _noise_start_8[2]={ | |||
64,64, | |||
}; | |||
static int _noise_part_8[2]={ | |||
static const int _noise_part_8[2]={ | |||
8,8, | |||
}; | |||
static int _psy_ath_floater_8[3]={ | |||
static const int _psy_ath_floater_8[3]={ | |||
-100,-100,-105, | |||
}; | |||
static int _psy_ath_abs_8[3]={ | |||
static const int _psy_ath_abs_8[3]={ | |||
-130,-130,-140, | |||
}; |
@@ -1,27 +1,27 @@ | |||
/******************************************************************** | |||
* * | |||
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: residue_16.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||
********************************************************************/ | |||
/***** residue backends *********************************************/ | |||
static static_bookblock _resbook_16s_0={ | |||
static const static_bookblock _resbook_16s_0={ | |||
{ | |||
{0}, | |||
{0,0,&_16c0_s_p1_0}, | |||
{0,0,&_16c0_s_p2_0}, | |||
{0}, | |||
{0,0,&_16c0_s_p3_0}, | |||
{0,0,&_16c0_s_p4_0}, | |||
{0,0,&_16c0_s_p5_0}, | |||
@@ -31,11 +31,11 @@ static static_bookblock _resbook_16s_0={ | |||
{&_16c0_s_p9_0,&_16c0_s_p9_1,&_16c0_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_16s_1={ | |||
static const static_bookblock _resbook_16s_1={ | |||
{ | |||
{0}, | |||
{0,0,&_16c1_s_p1_0}, | |||
{0,0,&_16c1_s_p2_0}, | |||
{0}, | |||
{0,0,&_16c1_s_p3_0}, | |||
{0,0,&_16c1_s_p4_0}, | |||
{0,0,&_16c1_s_p5_0}, | |||
@@ -45,7 +45,7 @@ static static_bookblock _resbook_16s_1={ | |||
{&_16c1_s_p9_0,&_16c1_s_p9_1,&_16c1_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_16s_2={ | |||
static const static_bookblock _resbook_16s_2={ | |||
{ | |||
{0}, | |||
{0,0,&_16c2_s_p1_0}, | |||
@@ -60,37 +60,37 @@ static static_bookblock _resbook_16s_2={ | |||
} | |||
}; | |||
static vorbis_residue_template _res_16s_0[]={ | |||
{2,0, &_residue_44_mid, | |||
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 vorbis_residue_template _res_16s_1[]={ | |||
{2,0, &_residue_44_mid, | |||
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, &_residue_44_mid, | |||
{2,0,32, &_residue_44_mid, | |||
&_huff_book__16c1_s_long,&_huff_book__16c1_s_long, | |||
&_resbook_16s_1,&_resbook_16s_1} | |||
}; | |||
static vorbis_residue_template _res_16s_2[]={ | |||
{2,0, &_residue_44_high, | |||
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, &_residue_44_high, | |||
{2,0,32, &_residue_44_high, | |||
&_huff_book__16c2_s_long,&_huff_book__16c2_s_long, | |||
&_resbook_16s_2,&_resbook_16s_2} | |||
}; | |||
static vorbis_mapping_template _mapres_template_16_stereo[3]={ | |||
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 static_bookblock _resbook_16u_0={ | |||
static const static_bookblock _resbook_16u_0={ | |||
{ | |||
{0}, | |||
{0,0,&_16u0__p1_0}, | |||
@@ -102,7 +102,7 @@ static static_bookblock _resbook_16u_0={ | |||
{&_16u0__p7_0,&_16u0__p7_1,&_16u0__p7_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_16u_1={ | |||
static const static_bookblock _resbook_16u_1={ | |||
{ | |||
{0}, | |||
{0,0,&_16u1__p1_0}, | |||
@@ -116,7 +116,7 @@ static static_bookblock _resbook_16u_1={ | |||
{&_16u1__p9_0,&_16u1__p9_1,&_16u1__p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_16u_2={ | |||
static const static_bookblock _resbook_16u_2={ | |||
{ | |||
{0}, | |||
{0,0,&_16u2_p1_0}, | |||
@@ -131,32 +131,32 @@ static static_bookblock _resbook_16u_2={ | |||
} | |||
}; | |||
static vorbis_residue_template _res_16u_0[]={ | |||
{1,0, &_residue_44_low_un, | |||
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 vorbis_residue_template _res_16u_1[]={ | |||
{1,0, &_residue_44_mid_un, | |||
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, &_residue_44_mid_un, | |||
{1,0,32, &_residue_44_mid_un, | |||
&_huff_book__16u1__long,&_huff_book__16u1__long, | |||
&_resbook_16u_1,&_resbook_16u_1} | |||
}; | |||
static vorbis_residue_template _res_16u_2[]={ | |||
{1,0, &_residue_44_hi_un, | |||
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, &_residue_44_hi_un, | |||
{1,0,32, &_residue_44_hi_un, | |||
&_huff_book__16u2__long,&_huff_book__16u2__long, | |||
&_resbook_16u_2,&_resbook_16u_2} | |||
}; | |||
static vorbis_mapping_template _mapres_template_16_uncoupled[3]={ | |||
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 */ |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: residue_44.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||
********************************************************************/ | |||
@@ -21,34 +21,34 @@ | |||
/***** residue backends *********************************************/ | |||
static vorbis_info_residue0 _residue_44_low={ | |||
0,-1, -1, 9,-1, | |||
/* 0 1 2 3 4 5 6 7 */ | |||
static const vorbis_info_residue0 _residue_44_low={ | |||
0,-1, -1, 9,-1,-1, | |||
/* 0 1 2 3 4 5 6 7 */ | |||
{0}, | |||
{-1}, | |||
{ .5, 1.5, 2.5, 2.5, 4.5, 8.5, 16.5, 32.5}, | |||
{ .5, .5, .5, 999., 4.5, 8.5, 16.5, 32.5}, | |||
{ 0, 1, 2, 2, 4, 8, 16, 32}, | |||
{ 0, 0, 0,999, 4, 8, 16, 32}, | |||
}; | |||
static vorbis_info_residue0 _residue_44_mid={ | |||
0,-1, -1, 10,-1, | |||
/* 0 1 2 3 4 5 6 7 8 */ | |||
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}, | |||
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 8.5, 16.5, 32.5}, | |||
{ .5, .5, 999., .5, 999., 4.5, 8.5, 16.5, 32.5}, | |||
{ 0, 1, 1, 2, 2, 4, 8, 16, 32}, | |||
{ 0, 0,999, 0,999, 4, 8, 16, 32}, | |||
}; | |||
static vorbis_info_residue0 _residue_44_high={ | |||
0,-1, -1, 10,-1, | |||
/* 0 1 2 3 4 5 6 7 8 */ | |||
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}, | |||
{ .5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 71.5,157.5}, | |||
{ .5, 1.5, 2.5, 3.5, 4.5, 8.5, 16.5, 71.5,157.5}, | |||
{ 0, 1, 2, 4, 8, 16, 32, 71,157}, | |||
{ 0, 1, 2, 3, 4, 8, 16, 71,157}, | |||
}; | |||
static static_bookblock _resbook_44s_n1={ | |||
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}, | |||
@@ -56,7 +56,7 @@ static static_bookblock _resbook_44s_n1={ | |||
{&_44cn1_s_p8_0,&_44cn1_s_p8_1,&_44cn1_s_p8_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44sm_n1={ | |||
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}, | |||
@@ -65,7 +65,7 @@ static static_bookblock _resbook_44sm_n1={ | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_0={ | |||
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}, | |||
@@ -73,7 +73,7 @@ static static_bookblock _resbook_44s_0={ | |||
{&_44c0_s_p8_0,&_44c0_s_p8_1,&_44c0_s_p8_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44sm_0={ | |||
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}, | |||
@@ -82,7 +82,7 @@ static static_bookblock _resbook_44sm_0={ | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_1={ | |||
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}, | |||
@@ -90,7 +90,7 @@ static static_bookblock _resbook_44s_1={ | |||
{&_44c1_s_p8_0,&_44c1_s_p8_1,&_44c1_s_p8_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44sm_1={ | |||
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}, | |||
@@ -99,7 +99,7 @@ static static_bookblock _resbook_44sm_1={ | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_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}, | |||
@@ -107,7 +107,7 @@ static static_bookblock _resbook_44s_2={ | |||
{&_44c2_s_p9_0,&_44c2_s_p9_1,&_44c2_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_3={ | |||
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}, | |||
@@ -115,7 +115,7 @@ static static_bookblock _resbook_44s_3={ | |||
{&_44c3_s_p9_0,&_44c3_s_p9_1,&_44c3_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_4={ | |||
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}, | |||
@@ -123,7 +123,7 @@ static static_bookblock _resbook_44s_4={ | |||
{&_44c4_s_p9_0,&_44c4_s_p9_1,&_44c4_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_5={ | |||
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}, | |||
@@ -131,7 +131,7 @@ static static_bookblock _resbook_44s_5={ | |||
{&_44c5_s_p9_0,&_44c5_s_p9_1,&_44c5_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_6={ | |||
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}, | |||
@@ -142,7 +142,7 @@ static static_bookblock _resbook_44s_6={ | |||
{&_44c6_s_p9_0,&_44c6_s_p9_1,&_44c6_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_7={ | |||
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}, | |||
@@ -153,7 +153,7 @@ static static_bookblock _resbook_44s_7={ | |||
{&_44c7_s_p9_0,&_44c7_s_p9_1,&_44c7_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_8={ | |||
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}, | |||
@@ -164,7 +164,7 @@ static static_bookblock _resbook_44s_8={ | |||
{&_44c8_s_p9_0,&_44c8_s_p9_1,&_44c8_s_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44s_9={ | |||
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}, | |||
@@ -176,108 +176,108 @@ static static_bookblock _resbook_44s_9={ | |||
} | |||
}; | |||
static vorbis_residue_template _res_44s_n1[]={ | |||
{2,0, &_residue_44_low, | |||
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, &_residue_44_low, | |||
{2,0,32, &_residue_44_low, | |||
&_huff_book__44cn1_s_long,&_huff_book__44cn1_sm_long, | |||
&_resbook_44s_n1,&_resbook_44sm_n1} | |||
}; | |||
static vorbis_residue_template _res_44s_0[]={ | |||
{2,0, &_residue_44_low, | |||
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, &_residue_44_low, | |||
{2,0,32, &_residue_44_low, | |||
&_huff_book__44c0_s_long,&_huff_book__44c0_sm_long, | |||
&_resbook_44s_0,&_resbook_44sm_0} | |||
}; | |||
static vorbis_residue_template _res_44s_1[]={ | |||
{2,0, &_residue_44_low, | |||
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, &_residue_44_low, | |||
{2,0,32, &_residue_44_low, | |||
&_huff_book__44c1_s_long,&_huff_book__44c1_sm_long, | |||
&_resbook_44s_1,&_resbook_44sm_1} | |||
}; | |||
static vorbis_residue_template _res_44s_2[]={ | |||
{2,0, &_residue_44_mid, | |||
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, &_residue_44_mid, | |||
{2,0,32, &_residue_44_mid, | |||
&_huff_book__44c2_s_long,&_huff_book__44c2_s_long, | |||
&_resbook_44s_2,&_resbook_44s_2} | |||
}; | |||
static vorbis_residue_template _res_44s_3[]={ | |||
{2,0, &_residue_44_mid, | |||
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, &_residue_44_mid, | |||
{2,0,32, &_residue_44_mid, | |||
&_huff_book__44c3_s_long,&_huff_book__44c3_s_long, | |||
&_resbook_44s_3,&_resbook_44s_3} | |||
}; | |||
static vorbis_residue_template _res_44s_4[]={ | |||
{2,0, &_residue_44_mid, | |||
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, &_residue_44_mid, | |||
{2,0,32, &_residue_44_mid, | |||
&_huff_book__44c4_s_long,&_huff_book__44c4_s_long, | |||
&_resbook_44s_4,&_resbook_44s_4} | |||
}; | |||
static vorbis_residue_template _res_44s_5[]={ | |||
{2,0, &_residue_44_mid, | |||
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, &_residue_44_mid, | |||
{2,0,32, &_residue_44_mid, | |||
&_huff_book__44c5_s_long,&_huff_book__44c5_s_long, | |||
&_resbook_44s_5,&_resbook_44s_5} | |||
}; | |||
static vorbis_residue_template _res_44s_6[]={ | |||
{2,0, &_residue_44_high, | |||
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, &_residue_44_high, | |||
{2,0,32, &_residue_44_high, | |||
&_huff_book__44c6_s_long,&_huff_book__44c6_s_long, | |||
&_resbook_44s_6,&_resbook_44s_6} | |||
}; | |||
static vorbis_residue_template _res_44s_7[]={ | |||
{2,0, &_residue_44_high, | |||
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, &_residue_44_high, | |||
{2,0,32, &_residue_44_high, | |||
&_huff_book__44c7_s_long,&_huff_book__44c7_s_long, | |||
&_resbook_44s_7,&_resbook_44s_7} | |||
}; | |||
static vorbis_residue_template _res_44s_8[]={ | |||
{2,0, &_residue_44_high, | |||
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, &_residue_44_high, | |||
{2,0,32, &_residue_44_high, | |||
&_huff_book__44c8_s_long,&_huff_book__44c8_s_long, | |||
&_resbook_44s_8,&_resbook_44s_8} | |||
}; | |||
static vorbis_residue_template _res_44s_9[]={ | |||
{2,0, &_residue_44_high, | |||
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, &_residue_44_high, | |||
{2,0,32, &_residue_44_high, | |||
&_huff_book__44c9_s_long,&_huff_book__44c9_s_long, | |||
&_resbook_44s_9,&_resbook_44s_9} | |||
}; | |||
static vorbis_mapping_template _mapres_template_44_stereo[]={ | |||
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 */ |
@@ -0,0 +1,451 @@ | |||
/******************************************************************** | |||
* * | |||
* 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 */ | |||
}; |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: residue_44u.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||
********************************************************************/ | |||
@@ -22,41 +22,41 @@ | |||
/***** residue backends *********************************************/ | |||
static vorbis_info_residue0 _residue_44_low_un={ | |||
0,-1, -1, 8,-1, | |||
static const vorbis_info_residue0 _residue_44_low_un={ | |||
0,-1, -1, 8,-1,-1, | |||
{0}, | |||
{-1}, | |||
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 28.5}, | |||
{ -1, 25, -1, 45, -1, -1, -1} | |||
{ 0, 1, 1, 2, 2, 4, 28}, | |||
{ -1, 25, -1, 45, -1, -1, -1} | |||
}; | |||
static vorbis_info_residue0 _residue_44_mid_un={ | |||
0,-1, -1, 10,-1, | |||
/* 0 1 2 3 4 5 6 7 8 9 */ | |||
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}, | |||
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 4.5, 16.5, 60.5}, | |||
{ -1, 30, -1, 50, -1, 80, -1, -1, -1} | |||
{ 0, 1, 1, 2, 2, 4, 4, 16, 60}, | |||
{ -1, 30, -1, 50, -1, 80, -1, -1, -1} | |||
}; | |||
static vorbis_info_residue0 _residue_44_hi_un={ | |||
0,-1, -1, 10,-1, | |||
/* 0 1 2 3 4 5 6 7 8 9 */ | |||
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}, | |||
{ .5, 1.5, 2.5, 4.5, 8.5, 16.5, 32.5, 71.5,157.5}, | |||
{ -1, -1, -1, -1, -1, -1, -1, -1, -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 vorbis_info_mapping0 _map_nominal_u[2]={ | |||
{1, {0,0}, {0}, {0}, 0,{0},{0}}, | |||
{1, {0,0}, {1}, {1}, 0,{0},{0}} | |||
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 static_bookblock _resbook_44u_n1={ | |||
static const static_bookblock _resbook_44u_n1={ | |||
{ | |||
{0}, | |||
{0,0,&_44un1__p1_0}, | |||
@@ -68,7 +68,7 @@ static static_bookblock _resbook_44u_n1={ | |||
{&_44un1__p7_0,&_44un1__p7_1,&_44un1__p7_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_0={ | |||
static const static_bookblock _resbook_44u_0={ | |||
{ | |||
{0}, | |||
{0,0,&_44u0__p1_0}, | |||
@@ -80,7 +80,7 @@ static static_bookblock _resbook_44u_0={ | |||
{&_44u0__p7_0,&_44u0__p7_1,&_44u0__p7_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_1={ | |||
static const static_bookblock _resbook_44u_1={ | |||
{ | |||
{0}, | |||
{0,0,&_44u1__p1_0}, | |||
@@ -92,7 +92,7 @@ static static_bookblock _resbook_44u_1={ | |||
{&_44u1__p7_0,&_44u1__p7_1,&_44u1__p7_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_2={ | |||
static const static_bookblock _resbook_44u_2={ | |||
{ | |||
{0}, | |||
{0,0,&_44u2__p1_0}, | |||
@@ -104,7 +104,7 @@ static static_bookblock _resbook_44u_2={ | |||
{&_44u2__p7_0,&_44u2__p7_1,&_44u2__p7_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_3={ | |||
static const static_bookblock _resbook_44u_3={ | |||
{ | |||
{0}, | |||
{0,0,&_44u3__p1_0}, | |||
@@ -116,7 +116,7 @@ static static_bookblock _resbook_44u_3={ | |||
{&_44u3__p7_0,&_44u3__p7_1,&_44u3__p7_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_4={ | |||
static const static_bookblock _resbook_44u_4={ | |||
{ | |||
{0}, | |||
{0,0,&_44u4__p1_0}, | |||
@@ -128,7 +128,7 @@ static static_bookblock _resbook_44u_4={ | |||
{&_44u4__p7_0,&_44u4__p7_1,&_44u4__p7_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_5={ | |||
static const static_bookblock _resbook_44u_5={ | |||
{ | |||
{0}, | |||
{0,0,&_44u5__p1_0}, | |||
@@ -142,7 +142,7 @@ static static_bookblock _resbook_44u_5={ | |||
{&_44u5__p9_0,&_44u5__p9_1,&_44u5__p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_6={ | |||
static const static_bookblock _resbook_44u_6={ | |||
{ | |||
{0}, | |||
{0,0,&_44u6__p1_0}, | |||
@@ -156,7 +156,7 @@ static static_bookblock _resbook_44u_6={ | |||
{&_44u6__p9_0,&_44u6__p9_1,&_44u6__p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_7={ | |||
static const static_bookblock _resbook_44u_7={ | |||
{ | |||
{0}, | |||
{0,0,&_44u7__p1_0}, | |||
@@ -170,7 +170,7 @@ static static_bookblock _resbook_44u_7={ | |||
{&_44u7__p9_0,&_44u7__p9_1,&_44u7__p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_8={ | |||
static const static_bookblock _resbook_44u_8={ | |||
{ | |||
{0}, | |||
{0,0,&_44u8_p1_0}, | |||
@@ -184,7 +184,7 @@ static static_bookblock _resbook_44u_8={ | |||
{&_44u8_p9_0,&_44u8_p9_1,&_44u8_p9_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_44u_9={ | |||
static const static_bookblock _resbook_44u_9={ | |||
{ | |||
{0}, | |||
{0,0,&_44u9_p1_0}, | |||
@@ -199,111 +199,111 @@ static static_bookblock _resbook_44u_9={ | |||
} | |||
}; | |||
static vorbis_residue_template _res_44u_n1[]={ | |||
{1,0, &_residue_44_low_un, | |||
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, &_residue_44_low_un, | |||
{1,0,32, &_residue_44_low_un, | |||
&_huff_book__44un1__long,&_huff_book__44un1__long, | |||
&_resbook_44u_n1,&_resbook_44u_n1} | |||
}; | |||
static vorbis_residue_template _res_44u_0[]={ | |||
{1,0, &_residue_44_low_un, | |||
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, &_residue_44_low_un, | |||
{1,0,32, &_residue_44_low_un, | |||
&_huff_book__44u0__long,&_huff_book__44u0__long, | |||
&_resbook_44u_0,&_resbook_44u_0} | |||
}; | |||
static vorbis_residue_template _res_44u_1[]={ | |||
{1,0, &_residue_44_low_un, | |||
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, &_residue_44_low_un, | |||
{1,0,32, &_residue_44_low_un, | |||
&_huff_book__44u1__long,&_huff_book__44u1__long, | |||
&_resbook_44u_1,&_resbook_44u_1} | |||
}; | |||
static vorbis_residue_template _res_44u_2[]={ | |||
{1,0, &_residue_44_low_un, | |||
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, &_residue_44_low_un, | |||
{1,0,32, &_residue_44_low_un, | |||
&_huff_book__44u2__long,&_huff_book__44u2__long, | |||
&_resbook_44u_2,&_resbook_44u_2} | |||
}; | |||
static vorbis_residue_template _res_44u_3[]={ | |||
{1,0, &_residue_44_low_un, | |||
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, &_residue_44_low_un, | |||
{1,0,32, &_residue_44_low_un, | |||
&_huff_book__44u3__long,&_huff_book__44u3__long, | |||
&_resbook_44u_3,&_resbook_44u_3} | |||
}; | |||
static vorbis_residue_template _res_44u_4[]={ | |||
{1,0, &_residue_44_low_un, | |||
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, &_residue_44_low_un, | |||
{1,0,32, &_residue_44_low_un, | |||
&_huff_book__44u4__long,&_huff_book__44u4__long, | |||
&_resbook_44u_4,&_resbook_44u_4} | |||
}; | |||
static vorbis_residue_template _res_44u_5[]={ | |||
{1,0, &_residue_44_mid_un, | |||
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, &_residue_44_mid_un, | |||
{1,0,32, &_residue_44_mid_un, | |||
&_huff_book__44u5__long,&_huff_book__44u5__long, | |||
&_resbook_44u_5,&_resbook_44u_5} | |||
}; | |||
static vorbis_residue_template _res_44u_6[]={ | |||
{1,0, &_residue_44_mid_un, | |||
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, &_residue_44_mid_un, | |||
{1,0,32, &_residue_44_mid_un, | |||
&_huff_book__44u6__long,&_huff_book__44u6__long, | |||
&_resbook_44u_6,&_resbook_44u_6} | |||
}; | |||
static vorbis_residue_template _res_44u_7[]={ | |||
{1,0, &_residue_44_mid_un, | |||
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, &_residue_44_mid_un, | |||
{1,0,32, &_residue_44_mid_un, | |||
&_huff_book__44u7__long,&_huff_book__44u7__long, | |||
&_resbook_44u_7,&_resbook_44u_7} | |||
}; | |||
static vorbis_residue_template _res_44u_8[]={ | |||
{1,0, &_residue_44_hi_un, | |||
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, &_residue_44_hi_un, | |||
{1,0,32, &_residue_44_hi_un, | |||
&_huff_book__44u8__long,&_huff_book__44u8__long, | |||
&_resbook_44u_8,&_resbook_44u_8} | |||
}; | |||
static vorbis_residue_template _res_44u_9[]={ | |||
{1,0, &_residue_44_hi_un, | |||
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, &_residue_44_hi_un, | |||
{1,0,32, &_residue_44_hi_un, | |||
&_huff_book__44u9__long,&_huff_book__44u9__long, | |||
&_resbook_44u_9,&_resbook_44u_9} | |||
}; | |||
static vorbis_mapping_template _mapres_template_44_uncoupled[]={ | |||
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 */ |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: residue_8.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||
********************************************************************/ | |||
@@ -20,40 +20,52 @@ | |||
/***** residue backends *********************************************/ | |||
static static_bookblock _resbook_8s_0={ | |||
static const static_bookblock _resbook_8s_0={ | |||
{ | |||
{0},{0,0,&_8c0_s_p1_0},{0,0,&_8c0_s_p2_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}, | |||
{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 static_bookblock _resbook_8s_1={ | |||
static const static_bookblock _resbook_8s_1={ | |||
{ | |||
{0},{0,0,&_8c1_s_p1_0},{0,0,&_8c1_s_p2_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}, | |||
{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 vorbis_residue_template _res_8s_0[]={ | |||
{2,0, &_residue_44_mid, | |||
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 vorbis_residue_template _res_8s_1[]={ | |||
{2,0, &_residue_44_mid, | |||
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 vorbis_mapping_template _mapres_template_8_stereo[2]={ | |||
static const vorbis_mapping_template _mapres_template_8_stereo[2]={ | |||
{ _map_nominal, _res_8s_0 }, /* 0 */ | |||
{ _map_nominal, _res_8s_1 }, /* 1 */ | |||
}; | |||
static static_bookblock _resbook_8u_0={ | |||
static const static_bookblock _resbook_8u_0={ | |||
{ | |||
{0}, | |||
{0,0,&_8u0__p1_0}, | |||
@@ -65,7 +77,7 @@ static static_bookblock _resbook_8u_0={ | |||
{&_8u0__p7_0,&_8u0__p7_1,&_8u0__p7_2} | |||
} | |||
}; | |||
static static_bookblock _resbook_8u_1={ | |||
static const static_bookblock _resbook_8u_1={ | |||
{ | |||
{0}, | |||
{0,0,&_8u1__p1_0}, | |||
@@ -80,18 +92,18 @@ static static_bookblock _resbook_8u_1={ | |||
} | |||
}; | |||
static vorbis_residue_template _res_8u_0[]={ | |||
{1,0, &_residue_44_low_un, | |||
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 vorbis_residue_template _res_8u_1[]={ | |||
{1,0, &_residue_44_mid_un, | |||
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 vorbis_mapping_template _mapres_template_8_uncoupled[2]={ | |||
static const vorbis_mapping_template _mapres_template_8_uncoupled[2]={ | |||
{ _map_nominal_u, _res_8u_0 }, /* 0 */ | |||
{ _map_nominal_u, _res_8u_1 }, /* 1 */ | |||
}; |
@@ -5,39 +5,42 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: setup_11.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||
********************************************************************/ | |||
#include "psych_11.h" | |||
static int blocksize_11[2]={ | |||
static const int blocksize_11[2]={ | |||
512,512 | |||
}; | |||
static int _floor_mapping_11[2]={ | |||
6,6, | |||
static const int _floor_mapping_11a[]={ | |||
6,6 | |||
}; | |||
static const int *_floor_mapping_11[]={ | |||
_floor_mapping_11a | |||
}; | |||
static double rate_mapping_11[3]={ | |||
static const double rate_mapping_11[3]={ | |||
8000.,13000.,44000., | |||
}; | |||
static double rate_mapping_11_uncoupled[3]={ | |||
static const double rate_mapping_11_uncoupled[3]={ | |||
12000.,20000.,50000., | |||
}; | |||
static double quality_mapping_11[3]={ | |||
static const double quality_mapping_11[3]={ | |||
-.1,.0,1. | |||
}; | |||
ve_setup_data_template ve_setup_11_stereo={ | |||
static const ve_setup_data_template ve_setup_11_stereo={ | |||
2, | |||
rate_mapping_11, | |||
quality_mapping_11, | |||
@@ -82,13 +85,13 @@ ve_setup_data_template ve_setup_11_stereo={ | |||
_floor_books, | |||
_floor, | |||
1, | |||
_floor_mapping_11, | |||
NULL, | |||
_mapres_template_8_stereo | |||
}; | |||
ve_setup_data_template ve_setup_11_uncoupled={ | |||
static const ve_setup_data_template ve_setup_11_uncoupled={ | |||
2, | |||
rate_mapping_11_uncoupled, | |||
quality_mapping_11, | |||
@@ -133,8 +136,8 @@ ve_setup_data_template ve_setup_11_uncoupled={ | |||
_floor_books, | |||
_floor, | |||
1, | |||
_floor_mapping_11, | |||
NULL, | |||
_mapres_template_8_uncoupled | |||
}; |
@@ -5,48 +5,52 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: setup_16.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||
********************************************************************/ | |||
#include "psych_16.h" | |||
#include "residue_16.h" | |||
static int blocksize_16_short[3]={ | |||
static const int blocksize_16_short[3]={ | |||
1024,512,512 | |||
}; | |||
static int blocksize_16_long[3]={ | |||
static const int blocksize_16_long[3]={ | |||
1024,1024,1024 | |||
}; | |||
static int _floor_mapping_16_short[3]={ | |||
static const int _floor_mapping_16a[]={ | |||
9,3,3 | |||
}; | |||
static int _floor_mapping_16[3]={ | |||
static const int _floor_mapping_16b[]={ | |||
9,9,9 | |||
}; | |||
static const int *_floor_mapping_16[]={ | |||
_floor_mapping_16a, | |||
_floor_mapping_16b | |||
}; | |||
static double rate_mapping_16[4]={ | |||
static const double rate_mapping_16[4]={ | |||
12000.,20000.,44000.,86000. | |||
}; | |||
static double rate_mapping_16_uncoupled[4]={ | |||
static const double rate_mapping_16_uncoupled[4]={ | |||
16000.,28000.,64000.,100000. | |||
}; | |||
static double _global_mapping_16[4]={ 1., 2., 3., 4. }; | |||
static const double _global_mapping_16[4]={ 1., 2., 3., 4. }; | |||
static double quality_mapping_16[4]={ -.1,.05,.5,1. }; | |||
static const double quality_mapping_16[4]={ -.1,.05,.5,1. }; | |||
static double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.}; | |||
static const double _psy_compand_16_mapping[4]={ 0., .8, 1., 1.}; | |||
ve_setup_data_template ve_setup_16_stereo={ | |||
static const ve_setup_data_template ve_setup_16_stereo={ | |||
3, | |||
rate_mapping_16, | |||
quality_mapping_16, | |||
@@ -65,7 +69,7 @@ ve_setup_data_template ve_setup_16_stereo={ | |||
_vp_tonemask_adj_16, | |||
_vp_tonemask_adj_16, | |||
_psy_noiseguards_8, | |||
_psy_noiseguards_16, | |||
_psy_noisebias_16_impulse, | |||
_psy_noisebias_16_short, | |||
_psy_noisebias_16_short, | |||
@@ -91,13 +95,13 @@ ve_setup_data_template ve_setup_16_stereo={ | |||
_floor_books, | |||
_floor, | |||
_floor_mapping_16_short, | |||
2, | |||
_floor_mapping_16, | |||
_mapres_template_16_stereo | |||
}; | |||
ve_setup_data_template ve_setup_16_uncoupled={ | |||
static const ve_setup_data_template ve_setup_16_uncoupled={ | |||
3, | |||
rate_mapping_16_uncoupled, | |||
quality_mapping_16, | |||
@@ -116,7 +120,7 @@ ve_setup_data_template ve_setup_16_uncoupled={ | |||
_vp_tonemask_adj_16, | |||
_vp_tonemask_adj_16, | |||
_psy_noiseguards_8, | |||
_psy_noiseguards_16, | |||
_psy_noisebias_16_impulse, | |||
_psy_noisebias_16_short, | |||
_psy_noisebias_16_short, | |||
@@ -142,7 +146,7 @@ ve_setup_data_template ve_setup_16_uncoupled={ | |||
_floor_books, | |||
_floor, | |||
_floor_mapping_16_short, | |||
2, | |||
_floor_mapping_16, | |||
_mapres_template_16_uncoupled |
@@ -5,27 +5,27 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: setup_22.h 17026 2010-03-25 05:00:27Z xiphmont $ | |||
********************************************************************/ | |||
static double rate_mapping_22[4]={ | |||
static const double rate_mapping_22[4]={ | |||
15000.,20000.,44000.,86000. | |||
}; | |||
static double rate_mapping_22_uncoupled[4]={ | |||
static const double rate_mapping_22_uncoupled[4]={ | |||
16000.,28000.,50000.,90000. | |||
}; | |||
static double _psy_lowpass_22[4]={9.5,11.,30.,99.}; | |||
static const double _psy_lowpass_22[4]={9.5,11.,30.,99.}; | |||
ve_setup_data_template ve_setup_22_stereo={ | |||
static const ve_setup_data_template ve_setup_22_stereo={ | |||
3, | |||
rate_mapping_22, | |||
quality_mapping_16, | |||
@@ -44,7 +44,7 @@ ve_setup_data_template ve_setup_22_stereo={ | |||
_vp_tonemask_adj_16, | |||
_vp_tonemask_adj_16, | |||
_psy_noiseguards_8, | |||
_psy_noiseguards_16, | |||
_psy_noisebias_16_impulse, | |||
_psy_noisebias_16_short, | |||
_psy_noisebias_16_short, | |||
@@ -52,8 +52,8 @@ ve_setup_data_template ve_setup_22_stereo={ | |||
_psy_noise_suppress, | |||
_psy_compand_8, | |||
_psy_compand_8_mapping, | |||
_psy_compand_8_mapping, | |||
_psy_compand_16_mapping, | |||
_psy_compand_16_mapping, | |||
{_noise_start_16,_noise_start_16}, | |||
{ _noise_part_16, _noise_part_16}, | |||
@@ -70,13 +70,13 @@ ve_setup_data_template ve_setup_22_stereo={ | |||
_floor_books, | |||
_floor, | |||
_floor_mapping_16_short, | |||
2, | |||
_floor_mapping_16, | |||
_mapres_template_16_stereo | |||
}; | |||
ve_setup_data_template ve_setup_22_uncoupled={ | |||
static const ve_setup_data_template ve_setup_22_uncoupled={ | |||
3, | |||
rate_mapping_22_uncoupled, | |||
quality_mapping_16, | |||
@@ -95,7 +95,7 @@ ve_setup_data_template ve_setup_22_uncoupled={ | |||
_vp_tonemask_adj_16, | |||
_vp_tonemask_adj_16, | |||
_psy_noiseguards_8, | |||
_psy_noiseguards_16, | |||
_psy_noisebias_16_impulse, | |||
_psy_noisebias_16_short, | |||
_psy_noisebias_16_short, | |||
@@ -103,8 +103,8 @@ ve_setup_data_template ve_setup_22_uncoupled={ | |||
_psy_noise_suppress, | |||
_psy_compand_8, | |||
_psy_compand_8_mapping, | |||
_psy_compand_8_mapping, | |||
_psy_compand_16_mapping, | |||
_psy_compand_16_mapping, | |||
{_noise_start_16,_noise_start_16}, | |||
{ _noise_part_16, _noise_part_16}, | |||
@@ -121,7 +121,7 @@ ve_setup_data_template ve_setup_22_uncoupled={ | |||
_floor_books, | |||
_floor, | |||
_floor_mapping_16_short, | |||
2, | |||
_floor_mapping_16, | |||
_mapres_template_16_uncoupled |
@@ -5,31 +5,31 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: setup_32.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||
********************************************************************/ | |||
static double rate_mapping_32[12]={ | |||
static const double rate_mapping_32[12]={ | |||
18000.,28000.,35000.,45000.,56000.,60000., | |||
75000.,90000.,100000.,115000.,150000.,190000., | |||
}; | |||
static double rate_mapping_32_un[12]={ | |||
static const double rate_mapping_32_un[12]={ | |||
30000.,42000.,52000.,64000.,72000.,78000., | |||
86000.,92000.,110000.,120000.,140000.,190000., | |||
}; | |||
static double _psy_lowpass_32[12]={ | |||
static const double _psy_lowpass_32[12]={ | |||
12.3,13.,13.,14.,15.,99.,99.,99.,99.,99.,99.,99. | |||
}; | |||
ve_setup_data_template ve_setup_32_stereo={ | |||
static const ve_setup_data_template ve_setup_32_stereo={ | |||
11, | |||
rate_mapping_32, | |||
quality_mapping_44, | |||
@@ -74,13 +74,13 @@ ve_setup_data_template ve_setup_32_stereo={ | |||
_floor_books, | |||
_floor, | |||
_floor_short_mapping_44, | |||
_floor_long_mapping_44, | |||
2, | |||
_floor_mapping_44, | |||
_mapres_template_44_stereo | |||
}; | |||
ve_setup_data_template ve_setup_32_uncoupled={ | |||
static const ve_setup_data_template ve_setup_32_uncoupled={ | |||
11, | |||
rate_mapping_32_un, | |||
quality_mapping_44, | |||
@@ -125,8 +125,8 @@ ve_setup_data_template ve_setup_32_uncoupled={ | |||
_floor_books, | |||
_floor, | |||
_floor_short_mapping_44, | |||
_floor_long_mapping_44, | |||
2, | |||
_floor_mapping_44, | |||
_mapres_template_44_uncoupled | |||
}; |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: setup_44.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||
********************************************************************/ | |||
@@ -19,42 +19,53 @@ | |||
#include "residue_44.h" | |||
#include "psych_44.h" | |||
static double rate_mapping_44_stereo[12]={ | |||
static const double rate_mapping_44_stereo[12]={ | |||
22500.,32000.,40000.,48000.,56000.,64000., | |||
80000.,96000.,112000.,128000.,160000.,250001. | |||
}; | |||
static double quality_mapping_44[12]={ | |||
static const double quality_mapping_44[12]={ | |||
-.1,.0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1.0 | |||
}; | |||
static int blocksize_short_44[11]={ | |||
static const int blocksize_short_44[11]={ | |||
512,256,256,256,256,256,256,256,256,256,256 | |||
}; | |||
static int blocksize_long_44[11]={ | |||
static const int blocksize_long_44[11]={ | |||
4096,2048,2048,2048,2048,2048,2048,2048,2048,2048,2048 | |||
}; | |||
static double _psy_compand_short_mapping[12]={ | |||
static const double _psy_compand_short_mapping[12]={ | |||
0.5, 1., 1., 1.3, 1.6, 2., 2., 2., 2., 2., 2., 2. | |||
}; | |||
static double _psy_compand_long_mapping[12]={ | |||
static const double _psy_compand_long_mapping[12]={ | |||
3.5, 4., 4., 4.3, 4.6, 5., 5., 5., 5., 5., 5., 5. | |||
}; | |||
static double _global_mapping_44[12]={ | |||
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 int _floor_short_mapping_44[11]={ | |||
static const int _floor_mapping_44a[11]={ | |||
1,0,0,2,2,4,5,5,5,5,5 | |||
}; | |||
static int _floor_long_mapping_44[11]={ | |||
static const int _floor_mapping_44b[11]={ | |||
8,7,7,7,7,7,7,7,7,7,7 | |||
}; | |||
ve_setup_data_template ve_setup_44_stereo={ | |||
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, | |||
@@ -99,8 +110,8 @@ ve_setup_data_template ve_setup_44_stereo={ | |||
_floor_books, | |||
_floor, | |||
_floor_short_mapping_44, | |||
_floor_long_mapping_44, | |||
2, | |||
_floor_mapping_44, | |||
_mapres_template_44_stereo | |||
}; |
@@ -0,0 +1,74 @@ | |||
/******************************************************************** | |||
* * | |||
* 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 | |||
}; |
@@ -5,24 +5,24 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: setup_44u.h 16962 2010-03-11 07:30:34Z xiphmont $ | |||
********************************************************************/ | |||
#include "residue_44u.h" | |||
static double rate_mapping_44_un[12]={ | |||
static const double rate_mapping_44_un[12]={ | |||
32000.,48000.,60000.,70000.,80000.,86000., | |||
96000.,110000.,120000.,140000.,160000.,240001. | |||
}; | |||
ve_setup_data_template ve_setup_44_uncoupled={ | |||
static const ve_setup_data_template ve_setup_44_uncoupled={ | |||
11, | |||
rate_mapping_44_un, | |||
quality_mapping_44, | |||
@@ -63,12 +63,12 @@ ve_setup_data_template ve_setup_44_uncoupled={ | |||
_psy_global_44, | |||
_global_mapping_44, | |||
NULL, | |||
_psy_stereo_modes_44, | |||
_floor_books, | |||
_floor, | |||
_floor_short_mapping_44, | |||
_floor_long_mapping_44, | |||
2, | |||
_floor_mapping_44, | |||
_mapres_template_44_uncoupled | |||
}; |
@@ -5,44 +5,48 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:19 jules_rms Exp $ | |||
last mod: $Id: setup_8.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||
********************************************************************/ | |||
#include "psych_8.h" | |||
#include "residue_8.h" | |||
static int blocksize_8[2]={ | |||
static const int blocksize_8[2]={ | |||
512,512 | |||
}; | |||
static int _floor_mapping_8[2]={ | |||
6,6, | |||
static const int _floor_mapping_8a[]={ | |||
6,6 | |||
}; | |||
static double rate_mapping_8[3]={ | |||
static const int *_floor_mapping_8[]={ | |||
_floor_mapping_8a | |||
}; | |||
static const double rate_mapping_8[3]={ | |||
6000.,9000.,32000., | |||
}; | |||
static double rate_mapping_8_uncoupled[3]={ | |||
static const double rate_mapping_8_uncoupled[3]={ | |||
8000.,14000.,42000., | |||
}; | |||
static double quality_mapping_8[3]={ | |||
static const double quality_mapping_8[3]={ | |||
-.1,.0,1. | |||
}; | |||
static double _psy_compand_8_mapping[3]={ 0., 1., 1.}; | |||
static const double _psy_compand_8_mapping[3]={ 0., 1., 1.}; | |||
static double _global_mapping_8[3]={ 1., 2., 3. }; | |||
static const double _global_mapping_8[3]={ 1., 2., 3. }; | |||
ve_setup_data_template ve_setup_8_stereo={ | |||
static const ve_setup_data_template ve_setup_8_stereo={ | |||
2, | |||
rate_mapping_8, | |||
quality_mapping_8, | |||
@@ -87,13 +91,13 @@ ve_setup_data_template ve_setup_8_stereo={ | |||
_floor_books, | |||
_floor, | |||
1, | |||
_floor_mapping_8, | |||
NULL, | |||
_mapres_template_8_stereo | |||
}; | |||
ve_setup_data_template ve_setup_8_uncoupled={ | |||
static const ve_setup_data_template ve_setup_8_uncoupled={ | |||
2, | |||
rate_mapping_8_uncoupled, | |||
quality_mapping_8, | |||
@@ -138,8 +142,8 @@ ve_setup_data_template ve_setup_8_uncoupled={ | |||
_floor_books, | |||
_floor, | |||
1, | |||
_floor_mapping_8, | |||
NULL, | |||
_mapres_template_8_uncoupled | |||
}; |
@@ -5,22 +5,22 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:20 jules_rms Exp $ | |||
last mod: $Id: setup_X.h 16894 2010-02-12 20:32:12Z xiphmont $ | |||
********************************************************************/ | |||
static double rate_mapping_X[12]={ | |||
static const double rate_mapping_X[12]={ | |||
-1.,-1.,-1.,-1.,-1.,-1., | |||
-1.,-1.,-1.,-1.,-1.,-1. | |||
}; | |||
ve_setup_data_template ve_setup_X_stereo={ | |||
static const ve_setup_data_template ve_setup_X_stereo={ | |||
11, | |||
rate_mapping_X, | |||
quality_mapping_44, | |||
@@ -65,13 +65,13 @@ ve_setup_data_template ve_setup_X_stereo={ | |||
_floor_books, | |||
_floor, | |||
_floor_short_mapping_44, | |||
_floor_long_mapping_44, | |||
2, | |||
_floor_mapping_44, | |||
_mapres_template_44_stereo | |||
}; | |||
ve_setup_data_template ve_setup_X_uncoupled={ | |||
static const ve_setup_data_template ve_setup_X_uncoupled={ | |||
11, | |||
rate_mapping_X, | |||
quality_mapping_44, | |||
@@ -116,13 +116,13 @@ ve_setup_data_template ve_setup_X_uncoupled={ | |||
_floor_books, | |||
_floor, | |||
_floor_short_mapping_44, | |||
_floor_long_mapping_44, | |||
2, | |||
_floor_mapping_44, | |||
_mapres_template_44_uncoupled | |||
}; | |||
ve_setup_data_template ve_setup_XX_stereo={ | |||
static const ve_setup_data_template ve_setup_XX_stereo={ | |||
2, | |||
rate_mapping_X, | |||
quality_mapping_8, | |||
@@ -167,13 +167,13 @@ ve_setup_data_template ve_setup_XX_stereo={ | |||
_floor_books, | |||
_floor, | |||
1, | |||
_floor_mapping_8, | |||
NULL, | |||
_mapres_template_8_stereo | |||
}; | |||
ve_setup_data_template ve_setup_XX_uncoupled={ | |||
static const ve_setup_data_template ve_setup_XX_uncoupled={ | |||
2, | |||
rate_mapping_X, | |||
quality_mapping_8, | |||
@@ -218,8 +218,8 @@ ve_setup_data_template ve_setup_XX_uncoupled={ | |||
_floor_books, | |||
_floor, | |||
1, | |||
_floor_mapping_8, | |||
NULL, | |||
_mapres_template_8_uncoupled | |||
}; |
@@ -7,13 +7,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: os.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -79,6 +79,8 @@ void *_alloca(size_t size); | |||
# 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. | |||
@@ -94,10 +96,10 @@ static inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ | |||
ogg_int16_t ret; | |||
ogg_int16_t temp; | |||
__asm__ __volatile__("fnstcw %0\n\t" | |||
"movw %0,%%dx\n\t" | |||
"orw $62463,%%dx\n\t" | |||
"movw %%dx,%1\n\t" | |||
"fldcw %1\n\t":"=m"(ret):"m"(temp): "dx"); | |||
"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; | |||
} | |||
@@ -113,21 +115,23 @@ static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise, | |||
__asm__("fistl %0": "=m"(i) : "t"(f)); | |||
return(i); | |||
} | |||
#endif | |||
#endif /* Special i386 GCC implementation */ | |||
#if defined(_WIN32) && defined(_X86_) && !defined(__GNUC__) && !defined(__BORLANDC__) | |||
/* 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; | |||
int i; | |||
__asm{ | |||
fld f | |||
fistp i | |||
} | |||
return i; | |||
} | |||
static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ | |||
@@ -136,21 +140,47 @@ static __inline void vorbis_fpu_setround(vorbis_fpu_control *fpu){ | |||
static __inline void vorbis_fpu_restore(vorbis_fpu_control fpu){ | |||
} | |||
#endif | |||
#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 (defined(_MSC_VER) && defined(_WIN64)) || (defined(__GNUC__) && 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){ | |||
} | |||
static __inline void vorbis_fpu_restore(vorbis_fpu_control 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){ | |||
return (int)(f+.5); | |||
/* 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 | |||
#endif /* default implementation */ | |||
#endif /* _OS_H */ |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: psy.h 16946 2010-03-03 16:12:40Z xiphmont $ | |||
********************************************************************/ | |||
@@ -57,8 +57,7 @@ typedef struct vorbis_info_psy{ | |||
float max_curve_dB; | |||
int normal_channel_p; | |||
int normal_point_p; | |||
int normal_p; | |||
int normal_start; | |||
int normal_partition; | |||
double normal_thresh; | |||
@@ -115,71 +114,41 @@ typedef struct { | |||
} 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); | |||
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_remove_floor(vorbis_look_psy *p, | |||
float *mdct, | |||
int *icodedflr, | |||
float *residue, | |||
int sliding_lowpass); | |||
extern void _vp_noisemask(vorbis_look_psy *p, | |||
float *logmdct, | |||
float *logmask); | |||
float *logmdct, | |||
float *logmask); | |||
extern void _vp_tonemask(vorbis_look_psy *p, | |||
float *logfft, | |||
float *logmask, | |||
float global_specmax, | |||
float local_specmax); | |||
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); | |||
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 float **_vp_quantize_couple_memo(vorbis_block *vb, | |||
vorbis_info_psy_global *g, | |||
vorbis_look_psy *p, | |||
vorbis_info_mapping0 *vi, | |||
float **mdct); | |||
extern void _vp_couple(int blobno, | |||
vorbis_info_psy_global *g, | |||
vorbis_look_psy *p, | |||
vorbis_info_mapping0 *vi, | |||
float **res, | |||
float **mag_memo, | |||
int **mag_sort, | |||
int **ifloor, | |||
int *nonzero, | |||
int sliding_lowpass); | |||
extern void _vp_noise_normalize(vorbis_look_psy *p, | |||
float *in,float *out,int *sortedindex); | |||
extern void _vp_noise_normalize_sort(vorbis_look_psy *p, | |||
float *magnitudes,int *sortedindex); | |||
extern int **_vp_quantize_couple_sort(vorbis_block *vb, | |||
vorbis_look_psy *p, | |||
vorbis_info_mapping0 *vi, | |||
float **mags); | |||
extern void hf_reduction(vorbis_info_psy_global *g, | |||
vorbis_look_psy *p, | |||
vorbis_info_mapping0 *vi, | |||
float **mdct); | |||
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 |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: registry.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -25,26 +25,26 @@ | |||
/* seems like major overkill now; the backend numbers will grow into | |||
the infrastructure soon enough */ | |||
extern vorbis_func_floor floor0_exportbundle; | |||
extern vorbis_func_floor floor1_exportbundle; | |||
extern vorbis_func_residue residue0_exportbundle; | |||
extern vorbis_func_residue residue1_exportbundle; | |||
extern vorbis_func_residue residue2_exportbundle; | |||
extern vorbis_func_mapping mapping0_exportbundle; | |||
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; | |||
vorbis_func_floor *_floor_P[]={ | |||
const vorbis_func_floor *const _floor_P[]={ | |||
&floor0_exportbundle, | |||
&floor1_exportbundle, | |||
}; | |||
vorbis_func_residue *_residue_P[]={ | |||
const vorbis_func_residue *const _residue_P[]={ | |||
&residue0_exportbundle, | |||
&residue1_exportbundle, | |||
&residue2_exportbundle, | |||
}; | |||
vorbis_func_mapping *_mapping_P[]={ | |||
const vorbis_func_mapping *const _mapping_P[]={ | |||
&mapping0_exportbundle, | |||
}; | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: registry.h 15531 2008-11-24 23:50:06Z xiphmont $ | |||
********************************************************************/ | |||
@@ -25,8 +25,8 @@ | |||
#define VI_RESB 3 | |||
#define VI_MAPB 1 | |||
extern vorbis_func_floor *_floor_P[]; | |||
extern vorbis_func_residue *_residue_P[]; | |||
extern vorbis_func_mapping *_mapping_P[]; | |||
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 |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: residue backend 0, 1 and 2 implementation | |||
last mod: $Id: res0.c,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: res0.c 17556 2010-10-21 18:25:19Z tterribe $ | |||
********************************************************************/ | |||
@@ -34,6 +34,9 @@ | |||
#include "misc.h" | |||
#include "os.h" | |||
//#define TRAIN_RES 1 | |||
//#define TRAIN_RESAUX 1 | |||
#if defined(TRAIN_RES) || defined (TRAIN_RESAUX) | |||
#include <stdio.h> | |||
#endif | |||
@@ -61,6 +64,7 @@ typedef struct { | |||
float training_min[8][64]; | |||
float tmin; | |||
float tmax; | |||
int submap; | |||
#endif | |||
} vorbis_look_residue0; | |||
@@ -83,59 +87,59 @@ void res0_free_look(vorbis_look_residue *i){ | |||
{ | |||
int j,k,l; | |||
for(j=0;j<look->parts;j++){ | |||
/*fprintf(stderr,"partition %d: ",j);*/ | |||
for(k=0;k<8;k++) | |||
if(look->training_data[k][j]){ | |||
char buffer[80]; | |||
FILE *of; | |||
codebook *statebook=look->partbooks[j][k]; | |||
/*fprintf(stderr,"partition %d: ",j);*/ | |||
for(k=0;k<8;k++) | |||
if(look->training_data[k][j]){ | |||
char buffer[80]; | |||
FILE *of; | |||
codebook *statebook=look->partbooks[j][k]; | |||
/* long and short into the same bucket by current convention */ | |||
sprintf(buffer,"res_part%d_pass%d.vqd",j,k); | |||
of=fopen(buffer,"a"); | |||
/* long and short into the same bucket by current convention */ | |||
sprintf(buffer,"res_sub%d_part%d_pass%d.vqd",look->submap,j,k); | |||
of=fopen(buffer,"a"); | |||
for(l=0;l<statebook->entries;l++) | |||
fprintf(of,"%d:%ld\n",l,look->training_data[k][j][l]); | |||
for(l=0;l<statebook->entries;l++) | |||
fprintf(of,"%d:%ld\n",l,look->training_data[k][j][l]); | |||
fclose(of); | |||
fclose(of); | |||
/*fprintf(stderr,"%d(%.2f|%.2f) ",k, | |||
look->training_min[k][j],look->training_max[k][j]);*/ | |||
/*fprintf(stderr,"%d(%.2f|%.2f) ",k, | |||
look->training_min[k][j],look->training_max[k][j]);*/ | |||
_ogg_free(look->training_data[k][j]); | |||
look->training_data[k][j]=NULL; | |||
} | |||
/*fprintf(stderr,"\n");*/ | |||
_ogg_free(look->training_data[k][j]); | |||
look->training_data[k][j]=NULL; | |||
} | |||
/*fprintf(stderr,"\n");*/ | |||
} | |||
} | |||
fprintf(stderr,"min/max residue: %g::%g\n",look->tmin,look->tmax); | |||
/*fprintf(stderr,"residue bit usage %f:%f (%f total)\n", | |||
(float)look->phrasebits/look->frames, | |||
(float)look->postbits/look->frames, | |||
(float)(look->postbits+look->phrasebits)/look->frames);*/ | |||
(float)look->phrasebits/look->frames, | |||
(float)look->postbits/look->frames, | |||
(float)(look->postbits+look->phrasebits)/look->frames);*/ | |||
#endif | |||
/*vorbis_info_residue0 *info=look->info; | |||
fprintf(stderr, | |||
"%ld frames encoded in %ld phrasebits and %ld residue bits " | |||
"(%g/frame) \n",look->frames,look->phrasebits, | |||
look->resbitsflat, | |||
(look->phrasebits+look->resbitsflat)/(float)look->frames); | |||
"%ld frames encoded in %ld phrasebits and %ld residue bits " | |||
"(%g/frame) \n",look->frames,look->phrasebits, | |||
look->resbitsflat, | |||
(look->phrasebits+look->resbitsflat)/(float)look->frames); | |||
for(j=0;j<look->parts;j++){ | |||
long acc=0; | |||
fprintf(stderr,"\t[%d] == ",j); | |||
for(k=0;k<look->stages;k++) | |||
if((info->secondstages[j]>>k)&1){ | |||
fprintf(stderr,"%ld,",look->resbits[j][k]); | |||
acc+=look->resbits[j][k]; | |||
} | |||
if((info->secondstages[j]>>k)&1){ | |||
fprintf(stderr,"%ld,",look->resbits[j][k]); | |||
acc+=look->resbits[j][k]; | |||
} | |||
fprintf(stderr,":: (%ld vals) %1.2fbits/sample\n",look->resvals[j], | |||
acc?(float)acc/(look->resvals[j]*info->grouping):0); | |||
acc?(float)acc/(look->resvals[j]*info->grouping):0); | |||
} | |||
fprintf(stderr,"\n");*/ | |||
@@ -151,6 +155,17 @@ void res0_free_look(vorbis_look_residue *i){ | |||
} | |||
} | |||
#if 0 | |||
static int ilog(unsigned int v){ | |||
int ret=0; | |||
while(v){ | |||
ret++; | |||
v>>=1; | |||
} | |||
return(ret); | |||
} | |||
#endif | |||
static int icount(unsigned int v){ | |||
int ret=0; | |||
while(v){ | |||
@@ -168,7 +183,7 @@ void res0_pack(vorbis_info_residue *vr,oggpack_buffer *opb){ | |||
oggpack_write(opb,info->end,24); | |||
oggpack_write(opb,info->grouping-1,24); /* residue vectors to group and | |||
code with a partitioned book */ | |||
code with a partitioned book */ | |||
oggpack_write(opb,info->partitions-1,6); /* possible partition choices */ | |||
oggpack_write(opb,info->groupbook,8); /* group huffman book */ | |||
@@ -202,20 +217,52 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){ | |||
info->partitions=oggpack_read(opb,6)+1; | |||
info->groupbook=oggpack_read(opb,8); | |||
/* check for premature EOP */ | |||
if(info->groupbook<0)goto errout; | |||
for(j=0;j<info->partitions;j++){ | |||
int cascade=oggpack_read(opb,3); | |||
if(oggpack_read(opb,1)) | |||
cascade|=(oggpack_read(opb,5)<<3); | |||
int cflag=oggpack_read(opb,1); | |||
if(cflag<0) goto errout; | |||
if(cflag){ | |||
int c=oggpack_read(opb,5); | |||
if(c<0) goto errout; | |||
cascade|=(c<<3); | |||
} | |||
info->secondstages[j]=cascade; | |||
acc+=icount(cascade); | |||
} | |||
for(j=0;j<acc;j++) | |||
info->booklist[j]=oggpack_read(opb,8); | |||
for(j=0;j<acc;j++){ | |||
int book=oggpack_read(opb,8); | |||
if(book<0) goto errout; | |||
info->booklist[j]=book; | |||
} | |||
if(info->groupbook>=ci->books)goto errout; | |||
for(j=0;j<acc;j++) | |||
for(j=0;j<acc;j++){ | |||
if(info->booklist[j]>=ci->books)goto errout; | |||
if(ci->book_param[info->booklist[j]]->maptype==0)goto errout; | |||
} | |||
/* verify the phrasebook is not specifying an impossible or | |||
inconsistent partitioning scheme. */ | |||
/* modify the phrasebook ranging check from r16327; an early beta | |||
encoder had a bug where it used an oversized phrasebook by | |||
accident. These files should continue to be playable, but don't | |||
allow an exploit */ | |||
{ | |||
int entries = ci->book_param[info->groupbook]->entries; | |||
int dim = ci->book_param[info->groupbook]->dim; | |||
int partvals = 1; | |||
if (dim<1) goto errout; | |||
while(dim>0){ | |||
partvals *= info->partitions; | |||
if(partvals > entries) goto errout; | |||
dim--; | |||
} | |||
info->partvals = partvals; | |||
} | |||
return(info); | |||
errout: | |||
@@ -224,7 +271,7 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){ | |||
} | |||
vorbis_look_residue *res0_look(vorbis_dsp_state *vd, | |||
vorbis_info_residue *vr){ | |||
vorbis_info_residue *vr){ | |||
vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr; | |||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)_ogg_calloc(1,sizeof(*look)); | |||
codec_setup_info *ci=(codec_setup_info*)vd->vi->codec_setup; | |||
@@ -247,17 +294,20 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd, | |||
if(stages>maxstage)maxstage=stages; | |||
look->partbooks[j]=(codebook**) _ogg_calloc(stages,sizeof(*look->partbooks[j])); | |||
for(k=0;k<stages;k++) | |||
if(info->secondstages[j]&(1<<k)){ | |||
look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++]; | |||
if(info->secondstages[j]&(1<<k)){ | |||
look->partbooks[j][k]=ci->fullbooks+info->booklist[acc++]; | |||
#ifdef TRAIN_RES | |||
look->training_data[k][j]=_ogg_calloc(look->partbooks[j][k]->entries, | |||
sizeof(***look->training_data)); | |||
look->training_data[k][j]=_ogg_calloc(look->partbooks[j][k]->entries, | |||
sizeof(***look->training_data)); | |||
#endif | |||
} | |||
} | |||
} | |||
} | |||
look->partvals=rint(pow((float)look->parts,(float)dim)); | |||
look->partvals=1; | |||
for(j=0;j<dim;j++) | |||
look->partvals*=look->parts; | |||
look->stages=maxstage; | |||
look->decodemap=(int**)_ogg_malloc(look->partvals*sizeof(*look->decodemap)); | |||
for(j=0;j<look->partvals;j++){ | |||
@@ -281,66 +331,72 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd, | |||
} | |||
/* break an abstraction and copy some code for performance purposes */ | |||
static int local_book_besterror(codebook *book,float *a){ | |||
int dim=book->dim,i,k,o; | |||
int best=0; | |||
encode_aux_threshmatch *tt=book->c->thresh_tree; | |||
/* find the quant val of each scalar */ | |||
for(k=0,o=dim;k<dim;++k){ | |||
float val=a[--o]; | |||
i=tt->threshvals>>1; | |||
if(val<tt->quantthresh[i]){ | |||
if(val<tt->quantthresh[i-1]){ | |||
for(--i;i>0;--i) | |||
if(val>=tt->quantthresh[i-1]) | |||
break; | |||
} | |||
}else{ | |||
for(++i;i<tt->threshvals-1;++i) | |||
if(val<tt->quantthresh[i])break; | |||
static int local_book_besterror(codebook *book,int *a){ | |||
int dim=book->dim; | |||
int i,j,o; | |||
int minval=book->minval; | |||
int del=book->delta; | |||
int qv=book->quantvals; | |||
int ze=(qv>>1); | |||
int index=0; | |||
/* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */ | |||
int p[8]={0,0,0,0,0,0,0,0}; | |||
if(del!=1){ | |||
for(i=0,o=dim;i<dim;i++){ | |||
int v = (a[--o]-minval+(del>>1))/del; | |||
int m = (v<ze ? ((ze-v)<<1)-1 : ((v-ze)<<1)); | |||
index = index*qv+ (m<0?0:(m>=qv?qv-1:m)); | |||
p[o]=v*del+minval; | |||
} | |||
}else{ | |||
for(i=0,o=dim;i<dim;i++){ | |||
int v = a[--o]-minval; | |||
int m = (v<ze ? ((ze-v)<<1)-1 : ((v-ze)<<1)); | |||
index = index*qv+ (m<0?0:(m>=qv?qv-1:m)); | |||
p[o]=v*del+minval; | |||
} | |||
best=(best*tt->quantvals)+tt->quantmap[i]; | |||
} | |||
/* regular lattices are easy :-) */ | |||
if(book->c->lengthlist[best]<=0){ | |||
if(book->c->lengthlist[index]<=0){ | |||
const static_codebook *c=book->c; | |||
int i,j; | |||
float bestf=0.f; | |||
float *e=book->valuelist; | |||
best=-1; | |||
int best=-1; | |||
/* assumes integer/centered encoder codebook maptype 1 no more than dim 8 */ | |||
int e[8]={0,0,0,0,0,0,0,0}; | |||
int maxval = book->minval + book->delta*(book->quantvals-1); | |||
for(i=0;i<book->entries;i++){ | |||
if(c->lengthlist[i]>0){ | |||
float thisx=0.f; | |||
for(j=0;j<dim;j++){ | |||
float val=(e[j]-a[j]); | |||
thisx+=val*val; | |||
} | |||
if(best==-1 || thisx<bestf){ | |||
bestf=thisx; | |||
best=i; | |||
} | |||
int thisx=0; | |||
for(j=0;j<dim;j++){ | |||
int val=(e[j]-a[j]); | |||
thisx+=val*val; | |||
} | |||
if(best==-1 || thisx<best){ | |||
memcpy(p,e,sizeof(p)); | |||
best=thisx; | |||
index=i; | |||
} | |||
} | |||
e+=dim; | |||
/* assumes the value patterning created by the tools in vq/ */ | |||
j=0; | |||
while(e[j]>=maxval) | |||
e[j++]=0; | |||
if(e[j]>=0) | |||
e[j]+=book->delta; | |||
e[j]= -e[j]; | |||
} | |||
} | |||
{ | |||
float *ptr=book->valuelist+best*dim; | |||
if(index>-1){ | |||
for(i=0;i<dim;i++) | |||
*a++ -= *ptr++; | |||
*a++ -= p[i]; | |||
} | |||
return(best); | |||
return(index); | |||
} | |||
static int _encodepart(oggpack_buffer *opb,float *vec, int n, | |||
codebook *book,long *acc){ | |||
static int _encodepart(oggpack_buffer *opb,int *vec, int n, | |||
codebook *book,long *acc){ | |||
int i,bits=0; | |||
int dim=book->dim; | |||
int step=n/dim; | |||
@@ -349,17 +405,19 @@ static int _encodepart(oggpack_buffer *opb,float *vec, int n, | |||
int entry=local_book_besterror(book,vec+i*dim); | |||
#ifdef TRAIN_RES | |||
acc[entry]++; | |||
if(entry>=0) | |||
acc[entry]++; | |||
#endif | |||
bits+=vorbis_book_encode(book,entry,opb); | |||
} | |||
return(bits); | |||
} | |||
static long **_01class(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int ch){ | |||
int **in,int ch){ | |||
long i,j,k; | |||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; | |||
vorbis_info_residue0 *info=look->info; | |||
@@ -385,18 +443,18 @@ static long **_01class(vorbis_block *vb,vorbis_look_residue *vl, | |||
for(i=0;i<partvals;i++){ | |||
int offset=i*samples_per_partition+info->begin; | |||
for(j=0;j<ch;j++){ | |||
float max=0.; | |||
float ent=0.; | |||
int max=0; | |||
int ent=0; | |||
for(k=0;k<samples_per_partition;k++){ | |||
if(fabs(in[j][offset+k])>max)max=fabs(in[j][offset+k]); | |||
ent+=fabs(rint(in[j][offset+k])); | |||
if(abs(in[j][offset+k])>max)max=abs(in[j][offset+k]); | |||
ent+=abs(in[j][offset+k]); | |||
} | |||
ent*=scale; | |||
for(k=0;k<possible_partitions-1;k++) | |||
if(max<=info->classmetric1[k] && | |||
(info->classmetric2[k]<0 || (int)ent<info->classmetric2[k])) | |||
break; | |||
if(max<=info->classmetric1[k] && | |||
(info->classmetric2[k]<0 || ent<info->classmetric2[k])) | |||
break; | |||
partword[j][i]=k; | |||
} | |||
@@ -411,7 +469,7 @@ static long **_01class(vorbis_block *vb,vorbis_look_residue *vl, | |||
sprintf(buffer,"resaux_%d.vqd",look->train_seq); | |||
of=fopen(buffer,"a"); | |||
for(j=0;j<partvals;j++) | |||
fprintf(of,"%ld, ",partword[i][j]); | |||
fprintf(of,"%ld, ",partword[i][j]); | |||
fprintf(of,"\n"); | |||
fclose(of); | |||
} | |||
@@ -425,8 +483,8 @@ static long **_01class(vorbis_block *vb,vorbis_look_residue *vl, | |||
/* designed for stereo or other modes where the partition size is an | |||
integer multiple of the number of channels encoded in the current | |||
submap */ | |||
static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,float **in, | |||
int ch){ | |||
static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,int **in, | |||
int ch){ | |||
long i,j,k,l; | |||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; | |||
vorbis_info_residue0 *info=look->info; | |||
@@ -444,23 +502,23 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,float **in, | |||
char buffer[80]; | |||
#endif | |||
partword[0]=(long*)_vorbis_block_alloc(vb,n*ch/samples_per_partition*sizeof(*partword[0])); | |||
memset(partword[0],0,n*ch/samples_per_partition*sizeof(*partword[0])); | |||
partword[0]=(long*)_vorbis_block_alloc(vb,partvals*sizeof(*partword[0])); | |||
memset(partword[0],0,partvals*sizeof(*partword[0])); | |||
for(i=0,l=info->begin/ch;i<partvals;i++){ | |||
float magmax=0.f; | |||
float angmax=0.f; | |||
int magmax=0; | |||
int angmax=0; | |||
for(j=0;j<samples_per_partition;j+=ch){ | |||
if(fabs(in[0][l])>magmax)magmax=fabs(in[0][l]); | |||
if(abs(in[0][l])>magmax)magmax=abs(in[0][l]); | |||
for(k=1;k<ch;k++) | |||
if(fabs(in[k][l])>angmax)angmax=fabs(in[k][l]); | |||
if(abs(in[k][l])>angmax)angmax=abs(in[k][l]); | |||
l++; | |||
} | |||
for(j=0;j<possible_partitions-1;j++) | |||
if(magmax<=info->classmetric1[j] && | |||
angmax<=info->classmetric2[j]) | |||
break; | |||
angmax<=info->classmetric2[j]) | |||
break; | |||
partword[0][i]=j; | |||
@@ -481,15 +539,20 @@ static long **_2class(vorbis_block *vb,vorbis_look_residue *vl,float **in, | |||
} | |||
static int _01forward(oggpack_buffer *opb, | |||
vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int ch, | |||
long **partword, | |||
int (*encode)(oggpack_buffer *,float *,int, | |||
codebook *,long *)){ | |||
vorbis_block *vb,vorbis_look_residue *vl, | |||
int **in,int ch, | |||
long **partword, | |||
int (*encode)(oggpack_buffer *,int *,int, | |||
codebook *,long *), | |||
int submap){ | |||
long i,j,k,s; | |||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; | |||
vorbis_info_residue0 *info=look->info; | |||
#ifdef TRAIN_RES | |||
look->submap=submap; | |||
#endif | |||
/* move all this setup out later */ | |||
int samples_per_partition=info->grouping; | |||
int possible_partitions=info->partitions; | |||
@@ -522,59 +585,59 @@ static int _01forward(oggpack_buffer *opb, | |||
/* first we encode a partition codeword for each channel */ | |||
if(s==0){ | |||
for(j=0;j<ch;j++){ | |||
long val=partword[j][i]; | |||
for(k=1;k<partitions_per_word;k++){ | |||
val*=possible_partitions; | |||
if(i+k<partvals) | |||
val+=partword[j][i+k]; | |||
} | |||
/* training hack */ | |||
if(val<look->phrasebook->entries) | |||
look->phrasebits+=vorbis_book_encode(look->phrasebook,val,opb); | |||
for(j=0;j<ch;j++){ | |||
long val=partword[j][i]; | |||
for(k=1;k<partitions_per_word;k++){ | |||
val*=possible_partitions; | |||
if(i+k<partvals) | |||
val+=partword[j][i+k]; | |||
} | |||
/* training hack */ | |||
if(val<look->phrasebook->entries) | |||
look->phrasebits+=vorbis_book_encode(look->phrasebook,val,opb); | |||
#if 0 /*def TRAIN_RES*/ | |||
else | |||
fprintf(stderr,"!"); | |||
else | |||
fprintf(stderr,"!"); | |||
#endif | |||
} | |||
} | |||
} | |||
/* now we encode interleaved residual values for the partitions */ | |||
for(k=0;k<partitions_per_word && i<partvals;k++,i++){ | |||
long offset=i*samples_per_partition+info->begin; | |||
long offset=i*samples_per_partition+info->begin; | |||
for(j=0;j<ch;j++){ | |||
if(s==0)resvals[partword[j][i]]+=samples_per_partition; | |||
if(info->secondstages[partword[j][i]]&(1<<s)){ | |||
codebook *statebook=look->partbooks[partword[j][i]][s]; | |||
if(statebook){ | |||
int ret; | |||
long *accumulator=NULL; | |||
for(j=0;j<ch;j++){ | |||
if(s==0)resvals[partword[j][i]]+=samples_per_partition; | |||
if(info->secondstages[partword[j][i]]&(1<<s)){ | |||
codebook *statebook=look->partbooks[partword[j][i]][s]; | |||
if(statebook){ | |||
int ret; | |||
long *accumulator=NULL; | |||
#ifdef TRAIN_RES | |||
accumulator=look->training_data[s][partword[j][i]]; | |||
{ | |||
int l; | |||
float *samples=in[j]+offset; | |||
for(l=0;l<samples_per_partition;l++){ | |||
if(samples[l]<look->training_min[s][partword[j][i]]) | |||
look->training_min[s][partword[j][i]]=samples[l]; | |||
if(samples[l]>look->training_max[s][partword[j][i]]) | |||
look->training_max[s][partword[j][i]]=samples[l]; | |||
} | |||
} | |||
accumulator=look->training_data[s][partword[j][i]]; | |||
{ | |||
int l; | |||
int *samples=in[j]+offset; | |||
for(l=0;l<samples_per_partition;l++){ | |||
if(samples[l]<look->training_min[s][partword[j][i]]) | |||
look->training_min[s][partword[j][i]]=samples[l]; | |||
if(samples[l]>look->training_max[s][partword[j][i]]) | |||
look->training_max[s][partword[j][i]]=samples[l]; | |||
} | |||
} | |||
#endif | |||
ret=encode(opb,in[j]+offset,samples_per_partition, | |||
statebook,accumulator); | |||
ret=encode(opb,in[j]+offset,samples_per_partition, | |||
statebook,accumulator); | |||
look->postbits+=ret; | |||
resbits[partword[j][i]]+=ret; | |||
} | |||
} | |||
} | |||
look->postbits+=ret; | |||
resbits[partword[j][i]]+=ret; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
@@ -584,21 +647,22 @@ static int _01forward(oggpack_buffer *opb, | |||
long totalbits=0; | |||
fprintf(stderr,"%d :: ",vb->mode); | |||
for(k=0;k<possible_partitions;k++){ | |||
fprintf(stderr,"%ld/%1.2g, ",resvals[k],(float)resbits[k]/resvals[k]); | |||
total+=resvals[k]; | |||
totalbits+=resbits[k]; | |||
} | |||
fprintf(stderr,"%ld/%1.2g, ",resvals[k],(float)resbits[k]/resvals[k]); | |||
total+=resvals[k]; | |||
totalbits+=resbits[k]; | |||
} | |||
fprintf(stderr,":: %ld:%1.2g\n",total,(double)totalbits/total); | |||
}*/ | |||
return(0); | |||
} | |||
/* a truncated packet here just means 'stop working'; it's not an error */ | |||
static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int ch, | |||
long (*decodepart)(codebook *, float *, | |||
oggpack_buffer *,int)){ | |||
float **in,int ch, | |||
long (*decodepart)(codebook *, float *, | |||
oggpack_buffer *,int)){ | |||
long i,j,k,l,s; | |||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; | |||
@@ -607,100 +671,56 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl, | |||
/* move all this setup out later */ | |||
int samples_per_partition=info->grouping; | |||
int partitions_per_word=look->phrasebook->dim; | |||
int n=info->end-info->begin; | |||
int max=vb->pcmend>>1; | |||
int end=(info->end<max?info->end:max); | |||
int n=end-info->begin; | |||
int partvals=n/samples_per_partition; | |||
int partwords=(partvals+partitions_per_word-1)/partitions_per_word; | |||
if(n>0){ | |||
int partvals=n/samples_per_partition; | |||
int partwords=(partvals+partitions_per_word-1)/partitions_per_word; | |||
int ***partword=(int***)alloca(ch*sizeof(*partword)); | |||
for(j=0;j<ch;j++) | |||
for(j=0;j<ch;j++) | |||
partword[j]=(int**)_vorbis_block_alloc(vb,partwords*sizeof(*partword[j])); | |||
for(s=0;s<look->stages;s++){ | |||
/* each loop decodes on partition codeword containing | |||
partitions_pre_word partitions */ | |||
for(i=0,l=0;i<partvals;l++){ | |||
if(s==0){ | |||
/* fetch the partition word for each channel */ | |||
for(j=0;j<ch;j++){ | |||
int temp=vorbis_book_decode(look->phrasebook,&vb->opb); | |||
if(temp==-1)goto eopbreak; | |||
partword[j][l]=look->decodemap[temp]; | |||
if(partword[j][l]==NULL)goto errout; | |||
} | |||
for(s=0;s<look->stages;s++){ | |||
/* each loop decodes on partition codeword containing | |||
partitions_per_word partitions */ | |||
for(i=0,l=0;i<partvals;l++){ | |||
if(s==0){ | |||
/* fetch the partition word for each channel */ | |||
for(j=0;j<ch;j++){ | |||
int temp=vorbis_book_decode(look->phrasebook,&vb->opb); | |||
if(temp==-1 || temp>=info->partvals)goto eopbreak; | |||
partword[j][l]=look->decodemap[temp]; | |||
if(partword[j][l]==NULL)goto errout; | |||
} | |||
} | |||
/* now we decode residual values for the partitions */ | |||
for(k=0;k<partitions_per_word && i<partvals;k++,i++) | |||
for(j=0;j<ch;j++){ | |||
long offset=info->begin+i*samples_per_partition; | |||
if(info->secondstages[partword[j][l][k]]&(1<<s)){ | |||
codebook *stagebook=look->partbooks[partword[j][l][k]][s]; | |||
if(stagebook){ | |||
if(decodepart(stagebook,in[j]+offset,&vb->opb, | |||
samples_per_partition)==-1)goto eopbreak; | |||
} | |||
} | |||
} | |||
} | |||
/* now we decode residual values for the partitions */ | |||
for(k=0;k<partitions_per_word && i<partvals;k++,i++) | |||
for(j=0;j<ch;j++){ | |||
long offset=info->begin+i*samples_per_partition; | |||
if(info->secondstages[partword[j][l][k]]&(1<<s)){ | |||
codebook *stagebook=look->partbooks[partword[j][l][k]][s]; | |||
if(stagebook){ | |||
if(decodepart(stagebook,in[j]+offset,&vb->opb, | |||
samples_per_partition)==-1)goto eopbreak; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
errout: | |||
eopbreak: | |||
return(0); | |||
} | |||
#if 0 | |||
/* residue 0 and 1 are just slight variants of one another. 0 is | |||
interleaved, 1 is not */ | |||
long **res0_class(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int *nonzero,int ch){ | |||
/* we encode only the nonzero parts of a bundle */ | |||
int i,used=0; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i]) | |||
in[used++]=in[i]; | |||
if(used) | |||
/*return(_01class(vb,vl,in,used,_interleaved_testhack));*/ | |||
return(_01class(vb,vl,in,used)); | |||
else | |||
return(0); | |||
} | |||
int res0_forward(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,float **out,int *nonzero,int ch, | |||
long **partword){ | |||
/* we encode only the nonzero parts of a bundle */ | |||
int i,j,used=0,n=vb->pcmend/2; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i]){ | |||
if(out) | |||
for(j=0;j<n;j++) | |||
out[i][j]+=in[i][j]; | |||
in[used++]=in[i]; | |||
} | |||
if(used){ | |||
int ret=_01forward(vb,vl,in,used,partword, | |||
_interleaved_encodepart); | |||
if(out){ | |||
used=0; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i]){ | |||
for(j=0;j<n;j++) | |||
out[i][j]-=in[used][j]; | |||
used++; | |||
} | |||
} | |||
return(ret); | |||
}else{ | |||
return(0); | |||
} | |||
} | |||
#endif | |||
int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int *nonzero,int ch){ | |||
float **in,int *nonzero,int ch){ | |||
int i,used=0; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i]) | |||
@@ -712,36 +732,21 @@ int res0_inverse(vorbis_block *vb,vorbis_look_residue *vl, | |||
} | |||
int res1_forward(oggpack_buffer *opb,vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,float **out,int *nonzero,int ch, | |||
long **partword){ | |||
int i,j,used=0,n=vb->pcmend/2; | |||
int **in,int *nonzero,int ch, long **partword, int submap){ | |||
int i,used=0; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i]){ | |||
if(out) | |||
for(j=0;j<n;j++) | |||
out[i][j]+=in[i][j]; | |||
if(nonzero[i]) | |||
in[used++]=in[i]; | |||
} | |||
if(used){ | |||
int ret=_01forward(opb,vb,vl,in,used,partword,_encodepart); | |||
if(out){ | |||
used=0; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i]){ | |||
for(j=0;j<n;j++) | |||
out[i][j]-=in[used][j]; | |||
used++; | |||
} | |||
} | |||
return(ret); | |||
return _01forward(opb,vb,vl,in,used,partword,_encodepart,submap); | |||
}else{ | |||
return(0); | |||
} | |||
} | |||
long **res1_class(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int *nonzero,int ch){ | |||
int **in,int *nonzero,int ch){ | |||
int i,used=0; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i]) | |||
@@ -753,7 +758,7 @@ long **res1_class(vorbis_block *vb,vorbis_look_residue *vl, | |||
} | |||
int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int *nonzero,int ch){ | |||
float **in,int *nonzero,int ch){ | |||
int i,used=0; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i]) | |||
@@ -765,7 +770,7 @@ int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl, | |||
} | |||
long **res2_class(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int *nonzero,int ch){ | |||
int **in,int *nonzero,int ch){ | |||
int i,used=0; | |||
for(i=0;i<ch;i++) | |||
if(nonzero[i])used++; | |||
@@ -779,35 +784,23 @@ long **res2_class(vorbis_block *vb,vorbis_look_residue *vl, | |||
into a single vector and encoded. */ | |||
int res2_forward(oggpack_buffer *opb, | |||
vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,float **out,int *nonzero,int ch, | |||
long **partword){ | |||
vorbis_block *vb,vorbis_look_residue *vl, | |||
int **in,int *nonzero,int ch, long **partword,int submap){ | |||
long i,j,k,n=vb->pcmend/2,used=0; | |||
/* don't duplicate the code; use a working vector hack for now and | |||
reshape ourselves into a single channel res1 */ | |||
/* ugly; reallocs for each coupling pass :-( */ | |||
float *work=(float*)_vorbis_block_alloc(vb,ch*n*sizeof(*work)); | |||
int *work=(int*)_vorbis_block_alloc(vb,ch*n*sizeof(*work)); | |||
for(i=0;i<ch;i++){ | |||
float *pcm=in[i]; | |||
int *pcm=in[i]; | |||
if(nonzero[i])used++; | |||
for(j=0,k=i;j<n;j++,k+=ch) | |||
work[k]=pcm[j]; | |||
} | |||
if(used){ | |||
int ret=_01forward(opb,vb,vl,&work,1,partword,_encodepart); | |||
/* update the sofar vector */ | |||
if(out){ | |||
for(i=0;i<ch;i++){ | |||
float *pcm=in[i]; | |||
float *sofar=out[i]; | |||
for(j=0,k=i;j<n;j++,k+=ch) | |||
sofar[j]+=pcm[j]-work[k]; | |||
} | |||
} | |||
return(ret); | |||
return _01forward(opb,vb,vl,&work,1,partword,_encodepart,submap); | |||
}else{ | |||
return(0); | |||
} | |||
@@ -815,7 +808,7 @@ int res2_forward(oggpack_buffer *opb, | |||
/* duplicate code here as speed is somewhat more important */ | |||
int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl, | |||
float **in,int *nonzero,int ch){ | |||
float **in,int *nonzero,int ch){ | |||
long i,k,l,s; | |||
vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl; | |||
vorbis_info_residue0 *info=look->info; | |||
@@ -823,48 +816,51 @@ int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl, | |||
/* move all this setup out later */ | |||
int samples_per_partition=info->grouping; | |||
int partitions_per_word=look->phrasebook->dim; | |||
int n=info->end-info->begin; | |||
int max=(vb->pcmend*ch)>>1; | |||
int end=(info->end<max?info->end:max); | |||
int n=end-info->begin; | |||
int partvals=n/samples_per_partition; | |||
int partwords=(partvals+partitions_per_word-1)/partitions_per_word; | |||
if(n>0){ | |||
int partvals=n/samples_per_partition; | |||
int partwords=(partvals+partitions_per_word-1)/partitions_per_word; | |||
int **partword=(int**)_vorbis_block_alloc(vb,partwords*sizeof(*partword)); | |||
for(i=0;i<ch;i++)if(nonzero[i])break; | |||
if(i==ch)return(0); /* no nonzero vectors */ | |||
for(s=0;s<look->stages;s++){ | |||
for(i=0,l=0;i<partvals;l++){ | |||
if(s==0){ | |||
/* fetch the partition word */ | |||
int temp=vorbis_book_decode(look->phrasebook,&vb->opb); | |||
if(temp==-1)goto eopbreak; | |||
partword[l]=look->decodemap[temp]; | |||
if(partword[l]==NULL)goto errout; | |||
for(i=0;i<ch;i++)if(nonzero[i])break; | |||
if(i==ch)return(0); /* no nonzero vectors */ | |||
for(s=0;s<look->stages;s++){ | |||
for(i=0,l=0;i<partvals;l++){ | |||
if(s==0){ | |||
/* fetch the partition word */ | |||
int temp=vorbis_book_decode(look->phrasebook,&vb->opb); | |||
if(temp==-1 || temp>=info->partvals)goto eopbreak; | |||
partword[l]=look->decodemap[temp]; | |||
if(partword[l]==NULL)goto errout; | |||
} | |||
/* now we decode residual values for the partitions */ | |||
for(k=0;k<partitions_per_word && i<partvals;k++,i++) | |||
if(info->secondstages[partword[l][k]]&(1<<s)){ | |||
codebook *stagebook=look->partbooks[partword[l][k]][s]; | |||
if(stagebook){ | |||
if(vorbis_book_decodevv_add(stagebook,in, | |||
i*samples_per_partition+info->begin,ch, | |||
&vb->opb,samples_per_partition)==-1) | |||
goto eopbreak; | |||
} | |||
} | |||
} | |||
/* now we decode residual values for the partitions */ | |||
for(k=0;k<partitions_per_word && i<partvals;k++,i++) | |||
if(info->secondstages[partword[l][k]]&(1<<s)){ | |||
codebook *stagebook=look->partbooks[partword[l][k]][s]; | |||
if(stagebook){ | |||
if(vorbis_book_decodevv_add(stagebook,in, | |||
i*samples_per_partition+info->begin,ch, | |||
&vb->opb,samples_per_partition)==-1) | |||
goto eopbreak; | |||
} | |||
} | |||
} | |||
} | |||
errout: | |||
eopbreak: | |||
return(0); | |||
} | |||
vorbis_func_residue residue0_exportbundle={ | |||
const vorbis_func_residue residue0_exportbundle={ | |||
NULL, | |||
&res0_unpack, | |||
&res0_look, | |||
@@ -875,7 +871,7 @@ vorbis_func_residue residue0_exportbundle={ | |||
&res0_inverse | |||
}; | |||
vorbis_func_residue residue1_exportbundle={ | |||
const vorbis_func_residue residue1_exportbundle={ | |||
&res0_pack, | |||
&res0_unpack, | |||
&res0_look, | |||
@@ -886,7 +882,7 @@ vorbis_func_residue residue1_exportbundle={ | |||
&res1_inverse | |||
}; | |||
vorbis_func_residue residue2_exportbundle={ | |||
const vorbis_func_residue residue2_exportbundle={ | |||
&res0_pack, | |||
&res0_unpack, | |||
&res0_look, | |||
@@ -897,4 +893,4 @@ vorbis_func_residue residue2_exportbundle={ | |||
&res2_inverse | |||
}; | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: scales.h 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -21,11 +21,16 @@ | |||
#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 float unitnorm(float x){ | |||
static inline float unitnorm(float x){ | |||
union { | |||
ogg_uint32_t i; | |||
float f; | |||
@@ -36,7 +41,7 @@ static float unitnorm(float x){ | |||
} | |||
/* Segher was off (too high) by ~ .3 decibel. Center the conversion correctly. */ | |||
static float todB(const float *x){ | |||
static inline float todB(const float *x){ | |||
union { | |||
ogg_uint32_t i; | |||
float f; |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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: sharedbook.c,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: sharedbook.c 17030 2010-03-25 06:52:55Z xiphmont $ | |||
********************************************************************/ | |||
@@ -55,7 +55,7 @@ long _float32_pack(float val){ | |||
sign=0x80000000; | |||
val= -val; | |||
} | |||
exp= floor(log(val)/log(2.f)); | |||
exp= floor(log(val)/log(2.f)+.001); //+epsilon | |||
mant=rint(ldexp(val,(VQ_FMAN-1)-exp)); | |||
exp=(exp+VQ_FEXP_BIAS)<<VQ_FMAN; | |||
@@ -85,49 +85,62 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){ | |||
ogg_uint32_t entry=marker[length]; | |||
/* when we claim a node for an entry, we also claim the nodes | |||
below it (pruning off the imagined tree that may have dangled | |||
from it) as well as blocking the use of any nodes directly | |||
above for leaves */ | |||
below it (pruning off the imagined tree that may have dangled | |||
from it) as well as blocking the use of any nodes directly | |||
above for leaves */ | |||
/* update ourself */ | |||
if(length<32 && (entry>>length)){ | |||
/* error condition; the lengths must specify an overpopulated tree */ | |||
_ogg_free(r); | |||
return(NULL); | |||
/* error condition; the lengths must specify an overpopulated tree */ | |||
_ogg_free(r); | |||
return(NULL); | |||
} | |||
r[count++]=entry; | |||
/* Look to see if the next shorter marker points to the node | |||
above. if so, update it and repeat. */ | |||
above. if so, update it and repeat. */ | |||
{ | |||
for(j=length;j>0;j--){ | |||
if(marker[j]&1){ | |||
/* have to jump branches */ | |||
if(j==1) | |||
marker[1]++; | |||
else | |||
marker[j]=marker[j-1]<<1; | |||
break; /* invariant says next upper marker would already | |||
have been moved if it was on the same path */ | |||
} | |||
marker[j]++; | |||
} | |||
for(j=length;j>0;j--){ | |||
if(marker[j]&1){ | |||
/* have to jump branches */ | |||
if(j==1) | |||
marker[1]++; | |||
else | |||
marker[j]=marker[j-1]<<1; | |||
break; /* invariant says next upper marker would already | |||
have been moved if it was on the same path */ | |||
} | |||
marker[j]++; | |||
} | |||
} | |||
/* prune the tree; the implicit invariant says all the longer | |||
markers were dangling from our just-taken node. Dangle them | |||
from our *new* node. */ | |||
markers were dangling from our just-taken node. Dangle them | |||
from our *new* node. */ | |||
for(j=length+1;j<33;j++) | |||
if((marker[j]>>1) == entry){ | |||
entry=marker[j]; | |||
marker[j]=marker[j-1]<<1; | |||
}else | |||
break; | |||
if((marker[j]>>1) == entry){ | |||
entry=marker[j]; | |||
marker[j]=marker[j-1]<<1; | |||
}else | |||
break; | |||
}else | |||
if(sparsecount==0)count++; | |||
} | |||
/* sanity check the huffman tree; an underpopulated tree must be | |||
rejected. The only exception is the one-node pseudo-nil tree, | |||
which appears to be underpopulated because the tree doesn't | |||
really exist; there's only one possible 'codeword' or zero bits, | |||
but the above tree-gen code doesn't mark that. */ | |||
if(sparsecount != 1){ | |||
for(i=1;i<33;i++) | |||
if(marker[i] & (0xffffffffUL>>(32-i))){ | |||
_ogg_free(r); | |||
return(NULL); | |||
} | |||
} | |||
/* bitreverse the words because our bitwise packer/unpacker is LSb | |||
endian */ | |||
for(i=0,count=0;i<n;i++){ | |||
@@ -139,7 +152,7 @@ ogg_uint32_t *_make_words(long *l,long n,long sparsecount){ | |||
if(sparsecount){ | |||
if(l[i]) | |||
r[count++]=temp; | |||
r[count++]=temp; | |||
}else | |||
r[count++]=temp; | |||
} | |||
@@ -170,9 +183,9 @@ long _book_maptype1_quantvals(const static_codebook *b){ | |||
return(vals); | |||
}else{ | |||
if(acc>b->entries){ | |||
vals--; | |||
vals--; | |||
}else{ | |||
vals++; | |||
vals++; | |||
} | |||
} | |||
} | |||
@@ -196,49 +209,49 @@ float *_book_unquantize(const static_codebook *b,int n,int *sparsemap){ | |||
switch(b->maptype){ | |||
case 1: | |||
/* most of the time, entries%dimensions == 0, but we need to be | |||
well defined. We define that the possible vales at each | |||
scalar is values == entries/dim. If entries%dim != 0, we'll | |||
have 'too few' values (values*dim<entries), which means that | |||
we'll have 'left over' entries; left over entries use zeroed | |||
values (and are wasted). So don't generate codebooks like | |||
that */ | |||
well defined. We define that the possible vales at each | |||
scalar is values == entries/dim. If entries%dim != 0, we'll | |||
have 'too few' values (values*dim<entries), which means that | |||
we'll have 'left over' entries; left over entries use zeroed | |||
values (and are wasted). So don't generate codebooks like | |||
that */ | |||
quantvals=_book_maptype1_quantvals(b); | |||
for(j=0;j<b->entries;j++){ | |||
if((sparsemap && b->lengthlist[j]) || !sparsemap){ | |||
float last=0.f; | |||
int indexdiv=1; | |||
for(k=0;k<b->dim;k++){ | |||
int index= (j/indexdiv)%quantvals; | |||
float val=b->quantlist[index]; | |||
val=fabs(val)*delta+mindel+last; | |||
if(b->q_sequencep)last=val; | |||
if(sparsemap) | |||
r[sparsemap[count]*b->dim+k]=val; | |||
else | |||
r[count*b->dim+k]=val; | |||
indexdiv*=quantvals; | |||
} | |||
count++; | |||
} | |||
if((sparsemap && b->lengthlist[j]) || !sparsemap){ | |||
float last=0.f; | |||
int indexdiv=1; | |||
for(k=0;k<b->dim;k++){ | |||
int index= (j/indexdiv)%quantvals; | |||
float val=b->quantlist[index]; | |||
val=fabs(val)*delta+mindel+last; | |||
if(b->q_sequencep)last=val; | |||
if(sparsemap) | |||
r[sparsemap[count]*b->dim+k]=val; | |||
else | |||
r[count*b->dim+k]=val; | |||
indexdiv*=quantvals; | |||
} | |||
count++; | |||
} | |||
} | |||
break; | |||
case 2: | |||
for(j=0;j<b->entries;j++){ | |||
if((sparsemap && b->lengthlist[j]) || !sparsemap){ | |||
float last=0.f; | |||
for(k=0;k<b->dim;k++){ | |||
float val=b->quantlist[j*b->dim+k]; | |||
val=fabs(val)*delta+mindel+last; | |||
if(b->q_sequencep)last=val; | |||
if(sparsemap) | |||
r[sparsemap[count]*b->dim+k]=val; | |||
else | |||
r[count*b->dim+k]=val; | |||
} | |||
count++; | |||
} | |||
if((sparsemap && b->lengthlist[j]) || !sparsemap){ | |||
float last=0.f; | |||
for(k=0;k<b->dim;k++){ | |||
float val=b->quantlist[j*b->dim+k]; | |||
val=fabs(val)*delta+mindel+last; | |||
if(b->q_sequencep)last=val; | |||
if(sparsemap) | |||
r[sparsemap[count]*b->dim+k]=val; | |||
else | |||
r[count*b->dim+k]=val; | |||
} | |||
count++; | |||
} | |||
} | |||
break; | |||
} | |||
@@ -248,34 +261,13 @@ float *_book_unquantize(const static_codebook *b,int n,int *sparsemap){ | |||
return(NULL); | |||
} | |||
void vorbis_staticbook_clear(static_codebook *b){ | |||
void vorbis_staticbook_destroy(static_codebook *b){ | |||
if(b->allocedp){ | |||
if(b->quantlist)_ogg_free(b->quantlist); | |||
if(b->lengthlist)_ogg_free(b->lengthlist); | |||
if(b->nearest_tree){ | |||
_ogg_free(b->nearest_tree->ptr0); | |||
_ogg_free(b->nearest_tree->ptr1); | |||
_ogg_free(b->nearest_tree->p); | |||
_ogg_free(b->nearest_tree->q); | |||
memset(b->nearest_tree,0,sizeof(*b->nearest_tree)); | |||
_ogg_free(b->nearest_tree); | |||
} | |||
if(b->thresh_tree){ | |||
_ogg_free(b->thresh_tree->quantthresh); | |||
_ogg_free(b->thresh_tree->quantmap); | |||
memset(b->thresh_tree,0,sizeof(*b->thresh_tree)); | |||
_ogg_free(b->thresh_tree); | |||
} | |||
memset(b,0,sizeof(*b)); | |||
} | |||
} | |||
void vorbis_staticbook_destroy(static_codebook *b){ | |||
if(b->allocedp){ | |||
vorbis_staticbook_clear(b); | |||
_ogg_free(b); | |||
} | |||
} /* otherwise, it is in static memory */ | |||
} | |||
void vorbis_book_clear(codebook *b){ | |||
@@ -299,11 +291,24 @@ int vorbis_book_init_encode(codebook *c,const static_codebook *s){ | |||
c->used_entries=s->entries; | |||
c->dim=s->dim; | |||
c->codelist=_make_words(s->lengthlist,s->entries,0); | |||
c->valuelist=_book_unquantize(s,s->entries,NULL); | |||
//c->valuelist=_book_unquantize(s,s->entries,NULL); | |||
c->quantvals=_book_maptype1_quantvals(s); | |||
c->minval=(int)rint(_float32_unpack(s->q_min)); | |||
c->delta=(int)rint(_float32_unpack(s->q_delta)); | |||
return(0); | |||
} | |||
#if 0 | |||
static ogg_uint32_t bitreverse(ogg_uint32_t x){ | |||
x= ((x>>16)&0x0000ffffUL) | ((x<<16)&0xffff0000UL); | |||
x= ((x>> 8)&0x00ff00ffUL) | ((x<< 8)&0xff00ff00UL); | |||
x= ((x>> 4)&0x0f0f0f0fUL) | ((x<< 4)&0xf0f0f0f0UL); | |||
x= ((x>> 2)&0x33333333UL) | ((x<< 2)&0xccccccccUL); | |||
return((x>> 1)&0x55555555UL) | ((x<< 1)&0xaaaaaaaaUL); | |||
} | |||
#endif | |||
static int JUCE_CDECL sort32a(const void *a,const void *b){ | |||
return ( **(ogg_uint32_t **)a>**(ogg_uint32_t **)b)- | |||
( **(ogg_uint32_t **)a<**(ogg_uint32_t **)b); | |||
@@ -324,17 +329,18 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){ | |||
c->used_entries=n; | |||
c->dim=s->dim; | |||
/* two different remappings go on here. | |||
if(n>0){ | |||
First, we collapse the likely sparse codebook down only to | |||
actually represented values/words. This collapsing needs to be | |||
indexed as map-valueless books are used to encode original entry | |||
positions as integers. | |||
/* two different remappings go on here. | |||
Second, we reorder all vectors, including the entry index above, | |||
by sorted bitreversed codeword to allow treeless decode. */ | |||
First, we collapse the likely sparse codebook down only to | |||
actually represented values/words. This collapsing needs to be | |||
indexed as map-valueless books are used to encode original entry | |||
positions as integers. | |||
Second, we reorder all vectors, including the entry index above, | |||
by sorted bitreversed codeword to allow treeless decode. */ | |||
{ | |||
/* perform sort */ | |||
ogg_uint32_t *codes=_make_words(s->lengthlist,s->entries,c->used_entries); | |||
ogg_uint32_t **codep=(ogg_uint32_t**)alloca(sizeof(*codep)*n); | |||
@@ -342,7 +348,7 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){ | |||
if(codes==NULL)goto err_out; | |||
for(i=0;i<n;i++){ | |||
codes[i]=ogg_bitreverse(codes[i]); | |||
codes[i]=bitreverse(codes[i]); | |||
codep[i]=codes+i; | |||
} | |||
@@ -359,224 +365,73 @@ int vorbis_book_init_decode(codebook *c,const static_codebook *s){ | |||
for(i=0;i<n;i++) | |||
c->codelist[sortindex[i]]=codes[i]; | |||
_ogg_free(codes); | |||
} | |||
c->valuelist=_book_unquantize(s,n,sortindex); | |||
c->valuelist=_book_unquantize(s,n,sortindex); | |||
c->dec_index=(int*)_ogg_malloc(n*sizeof(*c->dec_index)); | |||
for(n=0,i=0;i<s->entries;i++) | |||
if(s->lengthlist[i]>0) | |||
c->dec_index[sortindex[n++]]=i; | |||
for(n=0,i=0;i<s->entries;i++) | |||
if(s->lengthlist[i]>0) | |||
c->dec_index[sortindex[n++]]=i; | |||
c->dec_codelengths=(char*)_ogg_malloc(n*sizeof(*c->dec_codelengths)); | |||
for(n=0,i=0;i<s->entries;i++) | |||
if(s->lengthlist[i]>0) | |||
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; | |||
for(n=0,i=0;i<s->entries;i++) | |||
if(s->lengthlist[i]>0) | |||
c->dec_codelengths[sortindex[n++]]=s->lengthlist[i]; | |||
c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ | |||
if(c->dec_firsttablen<5)c->dec_firsttablen=5; | |||
if(c->dec_firsttablen>8)c->dec_firsttablen=8; | |||
c->dec_firsttablen=_ilog(c->used_entries)-4; /* this is magic */ | |||
if(c->dec_firsttablen<5)c->dec_firsttablen=5; | |||
if(c->dec_firsttablen>8)c->dec_firsttablen=8; | |||
tabn=1<<c->dec_firsttablen; | |||
tabn=1<<c->dec_firsttablen; | |||
c->dec_firsttable=(ogg_uint32_t*)_ogg_calloc(tabn,sizeof(*c->dec_firsttable)); | |||
c->dec_maxlength=0; | |||
c->dec_maxlength=0; | |||
for(i=0;i<n;i++){ | |||
if(c->dec_maxlength<c->dec_codelengths[i]) | |||
c->dec_maxlength=c->dec_codelengths[i]; | |||
if(c->dec_codelengths[i]<=c->dec_firsttablen){ | |||
ogg_uint32_t orig=ogg_bitreverse(c->codelist[i]); | |||
for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) | |||
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1; | |||
for(i=0;i<n;i++){ | |||
if(c->dec_maxlength<c->dec_codelengths[i]) | |||
c->dec_maxlength=c->dec_codelengths[i]; | |||
if(c->dec_codelengths[i]<=c->dec_firsttablen){ | |||
ogg_uint32_t orig=bitreverse(c->codelist[i]); | |||
for(j=0;j<(1<<(c->dec_firsttablen-c->dec_codelengths[i]));j++) | |||
c->dec_firsttable[orig|(j<<c->dec_codelengths[i])]=i+1; | |||
} | |||
} | |||
} | |||
/* now fill in 'unused' entries in the firsttable with hi/lo search | |||
hints for the non-direct-hits */ | |||
{ | |||
ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen); | |||
long lo=0,hi=0; | |||
for(i=0;i<tabn;i++){ | |||
ogg_uint32_t word=i<<(32-c->dec_firsttablen); | |||
if(c->dec_firsttable[ogg_bitreverse(word)]==0){ | |||
while((lo+1)<n && c->codelist[lo+1]<=word)lo++; | |||
while( hi<n && word>=(c->codelist[hi]&mask))hi++; | |||
/* we only actually have 15 bits per hint to play with here. | |||
In order to overflow gracefully (nothing breaks, efficiency | |||
just drops), encode as the difference from the extremes. */ | |||
{ | |||
unsigned long loval=lo; | |||
unsigned long hival=n-hi; | |||
if(loval>0x7fff)loval=0x7fff; | |||
if(hival>0x7fff)hival=0x7fff; | |||
c->dec_firsttable[ogg_bitreverse(word)]= | |||
0x80000000UL | (loval<<15) | hival; | |||
} | |||
/* now fill in 'unused' entries in the firsttable with hi/lo search | |||
hints for the non-direct-hits */ | |||
{ | |||
ogg_uint32_t mask=0xfffffffeUL<<(31-c->dec_firsttablen); | |||
long lo=0,hi=0; | |||
for(i=0;i<tabn;i++){ | |||
ogg_uint32_t word=i<<(32-c->dec_firsttablen); | |||
if(c->dec_firsttable[bitreverse(word)]==0){ | |||
while((lo+1)<n && c->codelist[lo+1]<=word)lo++; | |||
while( hi<n && word>=(c->codelist[hi]&mask))hi++; | |||
/* we only actually have 15 bits per hint to play with here. | |||
In order to overflow gracefully (nothing breaks, efficiency | |||
just drops), encode as the difference from the extremes. */ | |||
{ | |||
unsigned long loval=lo; | |||
unsigned long hival=n-hi; | |||
if(loval>0x7fff)loval=0x7fff; | |||
if(hival>0x7fff)hival=0x7fff; | |||
c->dec_firsttable[bitreverse(word)]= | |||
0x80000000UL | (loval<<15) | hival; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
return(0); | |||
err_out: | |||
vorbis_book_clear(c); | |||
return(-1); | |||
} | |||
static float _dist(int el,float *ref, float *b,int step){ | |||
int i; | |||
float acc=0.f; | |||
for(i=0;i<el;i++){ | |||
float val=(ref[i]-b[i*step]); | |||
acc+=val*val; | |||
} | |||
return(acc); | |||
} | |||
int _best(codebook *book, float *a, int step){ | |||
encode_aux_threshmatch *tt=book->c->thresh_tree; | |||
#if 0 | |||
encode_aux_nearestmatch *nt=book->c->nearest_tree; | |||
encode_aux_pigeonhole *pt=book->c->pigeon_tree; | |||
#endif | |||
int dim=book->dim; | |||
int k,o; | |||
/*int savebest=-1; | |||
float saverr;*/ | |||
/* do we have a threshhold encode hint? */ | |||
if(tt){ | |||
int index=0,i; | |||
/* find the quant val of each scalar */ | |||
for(k=0,o=step*(dim-1);k<dim;k++,o-=step){ | |||
i=tt->threshvals>>1; | |||
if(a[o]<tt->quantthresh[i]){ | |||
for(;i>0;i--) | |||
if(a[o]>=tt->quantthresh[i-1]) | |||
break; | |||
}else{ | |||
for(i++;i<tt->threshvals-1;i++) | |||
if(a[o]<tt->quantthresh[i])break; | |||
} | |||
index=(index*tt->quantvals)+tt->quantmap[i]; | |||
} | |||
/* regular lattices are easy :-) */ | |||
if(book->c->lengthlist[index]>0) /* is this unused? If so, we'll | |||
use a decision tree after all | |||
and fall through*/ | |||
return(index); | |||
} | |||
#if 0 | |||
/* do we have a pigeonhole encode hint? */ | |||
if(pt){ | |||
const static_codebook *c=book->c; | |||
int i,besti=-1; | |||
float best=0.f; | |||
int entry=0; | |||
/* dealing with sequentialness is a pain in the ass */ | |||
if(c->q_sequencep){ | |||
int pv; | |||
long mul=1; | |||
float qlast=0; | |||
for(k=0,o=0;k<dim;k++,o+=step){ | |||
pv=(int)((a[o]-qlast-pt->min)/pt->del); | |||
if(pv<0 || pv>=pt->mapentries)break; | |||
entry+=pt->pigeonmap[pv]*mul; | |||
mul*=pt->quantvals; | |||
qlast+=pv*pt->del+pt->min; | |||
} | |||
}else{ | |||
for(k=0,o=step*(dim-1);k<dim;k++,o-=step){ | |||
int pv=(int)((a[o]-pt->min)/pt->del); | |||
if(pv<0 || pv>=pt->mapentries)break; | |||
entry=entry*pt->quantvals+pt->pigeonmap[pv]; | |||
} | |||
} | |||
/* must be within the pigeonholable range; if we quant outside (or | |||
in an entry that we define no list for), brute force it */ | |||
if(k==dim && pt->fitlength[entry]){ | |||
/* search the abbreviated list */ | |||
long *list=pt->fitlist+pt->fitmap[entry]; | |||
for(i=0;i<pt->fitlength[entry];i++){ | |||
float this=_dist(dim,book->valuelist+list[i]*dim,a,step); | |||
if(besti==-1 || this<best){ | |||
best=this; | |||
besti=list[i]; | |||
} | |||
} | |||
return(besti); | |||
} | |||
} | |||
if(nt){ | |||
/* optimized using the decision tree */ | |||
while(1){ | |||
float c=0.f; | |||
float *p=book->valuelist+nt->p[ptr]; | |||
float *q=book->valuelist+nt->q[ptr]; | |||
for(k=0,o=0;k<dim;k++,o+=step) | |||
c+=(p[k]-q[k])*(a[o]-(p[k]+q[k])*.5); | |||
if(c>0.f) /* in A */ | |||
ptr= -nt->ptr0[ptr]; | |||
else /* in B */ | |||
ptr= -nt->ptr1[ptr]; | |||
if(ptr<=0)break; | |||
} | |||
return(-ptr); | |||
} | |||
#endif | |||
/* brute force it! */ | |||
{ | |||
const static_codebook *c=book->c; | |||
int i,besti=-1; | |||
float best=0.f; | |||
float *e=book->valuelist; | |||
for(i=0;i<book->entries;i++){ | |||
if(c->lengthlist[i]>0){ | |||
float thisx=_dist(dim,e,a,step); | |||
if(besti==-1 || thisx<best){ | |||
best=thisx; | |||
besti=i; | |||
} | |||
} | |||
e+=dim; | |||
} | |||
/*if(savebest!=-1 && savebest!=besti){ | |||
fprintf(stderr,"brute force/pigeonhole disagreement:\n" | |||
"original:"); | |||
for(i=0;i<dim*step;i+=step)fprintf(stderr,"%g,",a[i]); | |||
fprintf(stderr,"\n" | |||
"pigeonhole (entry %d, err %g):",savebest,saverr); | |||
for(i=0;i<dim;i++)fprintf(stderr,"%g,", | |||
(book->valuelist+savebest*dim)[i]); | |||
fprintf(stderr,"\n" | |||
"bruteforce (entry %d, err %g):",besti,best); | |||
for(i=0;i<dim;i++)fprintf(stderr,"%g,", | |||
(book->valuelist+besti*dim)[i]); | |||
fprintf(stderr,"\n"); | |||
}*/ | |||
return(besti); | |||
} | |||
} | |||
long vorbis_book_codeword(codebook *book,int entry){ | |||
if(book->c) /* only use with encode; decode optimizations are | |||
allowed to break this */ | |||
@@ -619,7 +474,7 @@ static_codebook test1={ | |||
0, | |||
0,0,0,0, | |||
NULL, | |||
NULL,NULL | |||
0 | |||
}; | |||
static float *test1_result=NULL; | |||
@@ -630,7 +485,7 @@ static_codebook test2={ | |||
2, | |||
-533200896,1611661312,4,0, | |||
full_quantlist1, | |||
NULL,NULL | |||
0 | |||
}; | |||
static float test2_result[]={-3,-2,-1,0, 1,2,3,4, 5,0,3,-2}; | |||
@@ -641,7 +496,7 @@ static_codebook test3={ | |||
2, | |||
-533200896,1611661312,4,1, | |||
full_quantlist1, | |||
NULL,NULL | |||
0 | |||
}; | |||
static float test3_result[]={-3,-5,-6,-6, 1,3,6,10, 5,5,8,6}; | |||
@@ -652,17 +507,17 @@ static_codebook test4={ | |||
1, | |||
-533200896,1611661312,4,0, | |||
partial_quantlist1, | |||
NULL,NULL | |||
0 | |||
}; | |||
static float test4_result[]={-3,-3,-3, 4,-3,-3, -1,-3,-3, | |||
-3, 4,-3, 4, 4,-3, -1, 4,-3, | |||
-3,-1,-3, 4,-1,-3, -1,-1,-3, | |||
-3,-3, 4, 4,-3, 4, -1,-3, 4, | |||
-3, 4, 4, 4, 4, 4, -1, 4, 4, | |||
-3,-1, 4, 4,-1, 4, -1,-1, 4, | |||
-3,-3,-1, 4,-3,-1, -1,-3,-1, | |||
-3, 4,-1, 4, 4,-1, -1, 4,-1, | |||
-3,-1,-1, 4,-1,-1, -1,-1,-1}; | |||
-3, 4,-3, 4, 4,-3, -1, 4,-3, | |||
-3,-1,-3, 4,-1,-3, -1,-1,-3, | |||
-3,-3, 4, 4,-3, 4, -1,-3, 4, | |||
-3, 4, 4, 4, 4, 4, -1, 4, 4, | |||
-3,-1, 4, 4,-1, 4, -1,-1, 4, | |||
-3,-3,-1, 4,-3,-1, -1,-3,-1, | |||
-3, 4,-1, 4, 4,-1, -1, 4,-1, | |||
-3,-1,-1, 4,-1,-1, -1,-1,-1}; | |||
/* linear, algorithmic mapping, sequential */ | |||
static_codebook test5={ | |||
@@ -671,17 +526,17 @@ static_codebook test5={ | |||
1, | |||
-533200896,1611661312,4,1, | |||
partial_quantlist1, | |||
NULL,NULL | |||
0 | |||
}; | |||
static float test5_result[]={-3,-6,-9, 4, 1,-2, -1,-4,-7, | |||
-3, 1,-2, 4, 8, 5, -1, 3, 0, | |||
-3,-4,-7, 4, 3, 0, -1,-2,-5, | |||
-3,-6,-2, 4, 1, 5, -1,-4, 0, | |||
-3, 1, 5, 4, 8,12, -1, 3, 7, | |||
-3,-4, 0, 4, 3, 7, -1,-2, 2, | |||
-3,-6,-7, 4, 1, 0, -1,-4,-5, | |||
-3, 1, 0, 4, 8, 7, -1, 3, 2, | |||
-3,-4,-5, 4, 3, 2, -1,-2,-3}; | |||
-3, 1,-2, 4, 8, 5, -1, 3, 0, | |||
-3,-4,-7, 4, 3, 0, -1,-2,-5, | |||
-3,-6,-2, 4, 1, 5, -1,-4, 0, | |||
-3, 1, 5, 4, 8,12, -1, 3, 7, | |||
-3,-4, 0, 4, 3, 7, -1,-2, 2, | |||
-3,-6,-7, 4, 1, 0, -1,-4,-5, | |||
-3, 1, 0, 4, 8, 7, -1, 3, 2, | |||
-3,-4,-5, 4, 3, 2, -1,-2,-3}; | |||
void run_test(static_codebook *b,float *comp){ | |||
float *out=_book_unquantize(b,b->entries,NULL); | |||
@@ -695,15 +550,15 @@ void run_test(static_codebook *b,float *comp){ | |||
for(i=0;i<b->entries*b->dim;i++) | |||
if(fabs(out[i]-comp[i])>.0001){ | |||
fprintf(stderr,"disagreement in unquantized and reference data:\n" | |||
"position %d, %g != %g\n",i,out[i],comp[i]); | |||
exit(1); | |||
fprintf(stderr,"disagreement in unquantized and reference data:\n" | |||
"position %d, %g != %g\n",i,out[i],comp[i]); | |||
exit(1); | |||
} | |||
}else{ | |||
if(out){ | |||
fprintf(stderr,"_book_unquantize returned a value array: \n" | |||
" correct result should have been NULL\n"); | |||
" correct result should have been NULL\n"); | |||
exit(1); | |||
} | |||
} | |||
@@ -728,4 +583,4 @@ int main(){ | |||
#endif | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: *unnormalized* fft transform | |||
last mod: $Id: smallft.c,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: smallft.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -97,10 +97,10 @@ static void drfti1(int n, float *wa, int *ifac){ | |||
argld=(float)ld*argh; | |||
fi=0.f; | |||
for (ii=2;ii<ido;ii+=2){ | |||
fi+=1.f; | |||
arg=fi*argld; | |||
wa[i++]=cos(arg); | |||
wa[i++]=sin(arg); | |||
fi+=1.f; | |||
arg=fi*argld; | |||
wa[i++]=cos(arg); | |||
wa[i++]=sin(arg); | |||
} | |||
is+=ido; | |||
} | |||
@@ -170,7 +170,7 @@ static void dradf2(int ido,int l1,float *cc,float *ch,float *wa1){ | |||
} | |||
static void dradf4(int ido,int l1,float *cc,float *ch,float *wa1, | |||
float *wa2,float *wa3){ | |||
float *wa2,float *wa3){ | |||
static float hsqt2 = .70710678118654752f; | |||
int i,k,t0,t1,t2,t3,t4,t5,t6; | |||
float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4; | |||
@@ -750,7 +750,7 @@ static void dradb3(int ido,int l1,float *cc,float *ch,float *wa1, | |||
} | |||
static void dradb4(int ido,int l1,float *cc,float *ch,float *wa1, | |||
float *wa2,float *wa3){ | |||
float *wa2,float *wa3){ | |||
static float sqrt2=1.414213562373095f; | |||
int i,k,t0,t1,t2,t3,t4,t5,t6,t7,t8; | |||
float ci2,ci3,ci4,cr2,cr3,cr4,ti1,ti2,ti3,ti4,tr1,tr2,tr3,tr4; | |||
@@ -1257,4 +1257,4 @@ void drft_clear(drft_lookup *l){ | |||
} | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: smallft.h 13293 2007-07-24 00:09:47Z xiphmont $ | |||
********************************************************************/ | |||
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: synthesis.c 17474 2010-09-30 03:41:41Z gmaxwell $ | |||
********************************************************************/ | |||
@@ -27,13 +27,17 @@ | |||
#include "os.h" | |||
int vorbis_synthesis(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; | |||
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); | |||
@@ -46,9 +50,15 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ | |||
/* read our mode and pre/post windowsize */ | |||
mode=oggpack_read(opb,b->modebits); | |||
if(mode==-1)return(OV_EBADPACKET); | |||
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){ | |||
@@ -56,7 +66,9 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ | |||
only for window selection */ | |||
vb->lW=oggpack_read(opb,1); | |||
vb->nW=oggpack_read(opb,1); | |||
if(vb->nW==-1) return(OV_EBADPACKET); | |||
if(vb->nW==-1){ | |||
return(OV_EBADPACKET); | |||
} | |||
}else{ | |||
vb->lW=0; | |||
vb->nW=0; | |||
@@ -77,7 +89,7 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ | |||
type=ci->map_type[ci->mode_param[mode]->mapping]; | |||
return(_mapping_P[type]->inverse(vb,ci->map_param[ci->mode_param[mode]-> | |||
mapping])); | |||
mapping])); | |||
} | |||
/* used to track pcm position without actually performing decode. | |||
@@ -105,6 +117,10 @@ int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op){ | |||
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); | |||
@@ -171,4 +187,4 @@ int vorbis_synthesis_halfrate_p(vorbis_info *vi){ | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: window functions | |||
last mod: $Id: window.c,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: window.c 16227 2009-07-08 06:58:46Z xiphmont $ | |||
********************************************************************/ | |||
@@ -2103,7 +2103,7 @@ float *_vorbis_window_get(int n){ | |||
} | |||
void _vorbis_apply_window(float *d,int *winno,long *blocksizes, | |||
int lW,int W,int nW){ | |||
int lW,int W,int nW){ | |||
lW=(W?lW:0); | |||
nW=(W?nW:0); | |||
@@ -2137,4 +2137,4 @@ void _vorbis_apply_window(float *d,int *winno,long *blocksizes, | |||
} | |||
} | |||
#endif | |||
#endif // JUCE_USE_OGGVORBIS |
@@ -5,13 +5,13 @@ | |||
* 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-2002 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* 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,v 1.1 2007/06/07 17:49:18 jules_rms Exp $ | |||
last mod: $Id: window.h 13293 2007-07-24 00:09:47Z xiphmont $ | |||
********************************************************************/ | |||
@@ -6,15 +6,21 @@ | |||
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | |||
* * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * | |||
* by the XIPHOPHORUS Company http://www.xiph.org/ * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: vorbis encode-engine setup | |||
last mod: $Id: vorbisenc.h,v 1.1 2007/06/07 17:48:18 jules_rms Exp $ | |||
last mod: $Id: vorbisenc.h 17021 2010-03-24 09:29:41Z xiphmont $ | |||
********************************************************************/ | |||
/** \file | |||
* Libvorbisenc is a convenient API for setting up an encoding | |||
* environment using libvorbis. Libvorbisenc encapsulates the | |||
* actions needed to set up the encoder properly. | |||
*/ | |||
#ifndef _OV_ENC_H_ | |||
#define _OV_ENC_H_ | |||
@@ -25,84 +31,404 @@ extern "C" | |||
#include "codec.h" | |||
/** | |||
* This is the primary function within libvorbisenc for setting up managed | |||
* bitrate modes. | |||
* | |||
* Before this function is called, the \ref vorbis_info | |||
* struct should be initialized by using vorbis_info_init() from the libvorbis | |||
* API. After encoding, vorbis_info_clear() should be called. | |||
* | |||
* The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set | |||
* constraints for the encoded file. This function uses these settings to | |||
* select the appropriate encoding mode and set it up. | |||
* | |||
* \param vi Pointer to an initialized \ref vorbis_info struct. | |||
* \param channels The number of channels to be encoded. | |||
* \param rate The sampling rate of the source audio. | |||
* \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. | |||
* \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. | |||
* \param min_bitrate Desired minimum bitrate. -1 indicates unset. | |||
* | |||
* \return Zero for success, and negative values for failure. | |||
* | |||
* \retval 0 Success. | |||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. | |||
* \retval OV_EINVAL Invalid setup request, eg, out of range argument. | |||
* \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. | |||
*/ | |||
extern int vorbis_encode_init(vorbis_info *vi, | |||
long channels, | |||
long rate, | |||
long channels, | |||
long rate, | |||
long max_bitrate, | |||
long nominal_bitrate, | |||
long min_bitrate); | |||
long max_bitrate, | |||
long nominal_bitrate, | |||
long min_bitrate); | |||
/** | |||
* This function performs step-one of a three-step bitrate-managed encode | |||
* setup. It functions similarly to the one-step setup performed by \ref | |||
* vorbis_encode_init but allows an application to make further encode setup | |||
* tweaks using \ref vorbis_encode_ctl before finally calling \ref | |||
* vorbis_encode_setup_init to complete the setup process. | |||
* | |||
* Before this function is called, the \ref vorbis_info struct should be | |||
* initialized by using vorbis_info_init() from the libvorbis API. After | |||
* encoding, vorbis_info_clear() should be called. | |||
* | |||
* The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set | |||
* constraints for the encoded file. This function uses these settings to | |||
* select the appropriate encoding mode and set it up. | |||
* | |||
* \param vi Pointer to an initialized vorbis_info struct. | |||
* \param channels The number of channels to be encoded. | |||
* \param rate The sampling rate of the source audio. | |||
* \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. | |||
* \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. | |||
* \param min_bitrate Desired minimum bitrate. -1 indicates unset. | |||
* | |||
* \return Zero for success, and negative for failure. | |||
* | |||
* \retval 0 Success | |||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. | |||
* \retval OV_EINVAL Invalid setup request, eg, out of range argument. | |||
* \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. | |||
*/ | |||
extern int vorbis_encode_setup_managed(vorbis_info *vi, | |||
long channels, | |||
long rate, | |||
long channels, | |||
long rate, | |||
long max_bitrate, | |||
long nominal_bitrate, | |||
long min_bitrate); | |||
long max_bitrate, | |||
long nominal_bitrate, | |||
long min_bitrate); | |||
/** | |||
* This function performs step-one of a three-step variable bitrate | |||
* (quality-based) encode setup. It functions similarly to the one-step setup | |||
* performed by \ref vorbis_encode_init_vbr() but allows an application to | |||
* make further encode setup tweaks using \ref vorbis_encode_ctl() before | |||
* finally calling \ref vorbis_encode_setup_init to complete the setup | |||
* process. | |||
* | |||
* Before this function is called, the \ref vorbis_info struct should be | |||
* initialized by using \ref vorbis_info_init() from the libvorbis API. After | |||
* encoding, vorbis_info_clear() should be called. | |||
* | |||
* \param vi Pointer to an initialized vorbis_info struct. | |||
* \param channels The number of channels to be encoded. | |||
* \param rate The sampling rate of the source audio. | |||
* \param quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). | |||
* | |||
* \return Zero for success, and negative values for failure. | |||
* | |||
* \retval 0 Success | |||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. | |||
* \retval OV_EINVAL Invalid setup request, eg, out of range argument. | |||
* \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. | |||
*/ | |||
extern int vorbis_encode_setup_vbr(vorbis_info *vi, | |||
long channels, | |||
long rate, | |||
long channels, | |||
long rate, | |||
float quality /* quality level from 0. (lo) to 1. (hi) */ | |||
); | |||
float quality | |||
); | |||
/** | |||
* This is the primary function within libvorbisenc for setting up variable | |||
* bitrate ("quality" based) modes. | |||
* | |||
* | |||
* Before this function is called, the vorbis_info struct should be | |||
* initialized by using vorbis_info_init() from the libvorbis API. After | |||
* encoding, vorbis_info_clear() should be called. | |||
* | |||
* \param vi Pointer to an initialized vorbis_info struct. | |||
* \param channels The number of channels to be encoded. | |||
* \param rate The sampling rate of the source audio. | |||
* \param base_quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). | |||
* | |||
* | |||
* \return Zero for success, or a negative number for failure. | |||
* | |||
* \retval 0 Success | |||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. | |||
* \retval OV_EINVAL Invalid setup request, eg, out of range argument. | |||
* \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. | |||
*/ | |||
extern int vorbis_encode_init_vbr(vorbis_info *vi, | |||
long channels, | |||
long rate, | |||
long channels, | |||
long rate, | |||
float base_quality /* quality level from 0. (lo) to 1. (hi) */ | |||
); | |||
float base_quality | |||
); | |||
/** | |||
* This function performs the last stage of three-step encoding setup, as | |||
* described in the API overview under managed bitrate modes. | |||
* | |||
* Before this function is called, the \ref vorbis_info struct should be | |||
* initialized by using vorbis_info_init() from the libvorbis API, one of | |||
* \ref vorbis_encode_setup_managed() or \ref vorbis_encode_setup_vbr() called to | |||
* initialize the high-level encoding setup, and \ref vorbis_encode_ctl() | |||
* called if necessary to make encoding setup changes. | |||
* vorbis_encode_setup_init() finalizes the highlevel encoding structure into | |||
* a complete encoding setup after which the application may make no further | |||
* setup changes. | |||
* | |||
* After encoding, vorbis_info_clear() should be called. | |||
* | |||
* \param vi Pointer to an initialized \ref vorbis_info struct. | |||
* | |||
* \return Zero for success, and negative values for failure. | |||
* | |||
* \retval 0 Success. | |||
* \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. | |||
* | |||
* \retval OV_EINVAL Attempt to use vorbis_encode_setup_init() without first | |||
* calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to | |||
* initialize the high-level encoding setup | |||
* | |||
*/ | |||
extern int vorbis_encode_setup_init(vorbis_info *vi); | |||
/** | |||
* This function implements a generic interface to miscellaneous encoder | |||
* settings similar to the classic UNIX 'ioctl()' system call. Applications | |||
* may use vorbis_encode_ctl() to query or set bitrate management or quality | |||
* mode details by using one of several \e request arguments detailed below. | |||
* vorbis_encode_ctl() must be called after one of | |||
* vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used | |||
* to modify settings, \ref vorbis_encode_ctl() must be called before \ref | |||
* vorbis_encode_setup_init(). | |||
* | |||
* \param vi Pointer to an initialized vorbis_info struct. | |||
* | |||
* \param number Specifies the desired action; See \ref encctlcodes "the list | |||
* of available requests". | |||
* | |||
* \param arg void * pointing to a data structure matching the request | |||
* argument. | |||
* | |||
* \retval 0 Success. Any further return information (such as the result of a | |||
* query) is placed into the storage pointed to by *arg. | |||
* | |||
* \retval OV_EINVAL Invalid argument, or an attempt to modify a setting after | |||
* calling vorbis_encode_setup_init(). | |||
* | |||
* \retval OV_EIMPL Unimplemented or unknown request | |||
*/ | |||
extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); | |||
/* deprecated rate management supported only for compatability */ | |||
#define OV_ECTL_RATEMANAGE_GET 0x10 | |||
#define OV_ECTL_RATEMANAGE_SET 0x11 | |||
#define OV_ECTL_RATEMANAGE_AVG 0x12 | |||
#define OV_ECTL_RATEMANAGE_HARD 0x13 | |||
/** | |||
* \deprecated This is a deprecated interface. Please use vorbis_encode_ctl() | |||
* with the \ref ovectl_ratemanage2_arg struct and \ref | |||
* OV_ECTL_RATEMANAGE2_GET and \ref OV_ECTL_RATEMANAGE2_SET calls in new code. | |||
* | |||
* The \ref ovectl_ratemanage_arg structure is used with vorbis_encode_ctl() | |||
* and the \ref OV_ECTL_RATEMANAGE_GET, \ref OV_ECTL_RATEMANAGE_SET, \ref | |||
* OV_ECTL_RATEMANAGE_AVG, \ref OV_ECTL_RATEMANAGE_HARD calls in order to | |||
* query and modify specifics of the encoder's bitrate management | |||
* configuration. | |||
*/ | |||
struct ovectl_ratemanage_arg { | |||
int management_active; | |||
int management_active; /**< nonzero if bitrate management is active*/ | |||
/** hard lower limit (in kilobits per second) below which the stream bitrate | |||
will never be allowed for any given bitrate_hard_window seconds of time.*/ | |||
long bitrate_hard_min; | |||
/** hard upper limit (in kilobits per second) above which the stream bitrate | |||
will never be allowed for any given bitrate_hard_window seconds of time.*/ | |||
long bitrate_hard_max; | |||
/** the window period (in seconds) used to regulate the hard bitrate minimum | |||
and maximum*/ | |||
double bitrate_hard_window; | |||
/** soft lower limit (in kilobits per second) below which the average bitrate | |||
tracker will start nudging the bitrate higher.*/ | |||
long bitrate_av_lo; | |||
/** soft upper limit (in kilobits per second) above which the average bitrate | |||
tracker will start nudging the bitrate lower.*/ | |||
long bitrate_av_hi; | |||
/** the window period (in seconds) used to regulate the average bitrate | |||
minimum and maximum.*/ | |||
double bitrate_av_window; | |||
/** Regulates the relative centering of the average and hard windows; in | |||
libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but | |||
followed the average window regulation. In libvorbis 1.1 a bit-reservoir | |||
interface replaces the old windowing interface; the older windowing | |||
interface is simulated and this field has no effect.*/ | |||
double bitrate_av_window_center; | |||
}; | |||
/* new rate setup */ | |||
#define OV_ECTL_RATEMANAGE2_GET 0x14 | |||
#define OV_ECTL_RATEMANAGE2_SET 0x15 | |||
/** | |||
* \name struct ovectl_ratemanage2_arg | |||
* | |||
* The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and | |||
* the OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in order to | |||
* query and modify specifics of the encoder's bitrate management | |||
* configuration. | |||
* | |||
*/ | |||
struct ovectl_ratemanage2_arg { | |||
int management_active; | |||
int management_active; /**< nonzero if bitrate management is active */ | |||
/** Lower allowed bitrate limit in kilobits per second */ | |||
long bitrate_limit_min_kbps; | |||
/** Upper allowed bitrate limit in kilobits per second */ | |||
long bitrate_limit_max_kbps; | |||
long bitrate_limit_reservoir_bits; | |||
long bitrate_limit_reservoir_bits; /**<Size of the bitrate reservoir in bits */ | |||
/** Regulates the bitrate reservoir's preferred fill level in a range from 0.0 | |||
* to 1.0; 0.0 tries to bank bits to buffer against future bitrate spikes, 1.0 | |||
* buffers against future sudden drops in instantaneous bitrate. Default is | |||
* 0.1 | |||
*/ | |||
double bitrate_limit_reservoir_bias; | |||
/** Average bitrate setting in kilobits per second */ | |||
long bitrate_average_kbps; | |||
/** Slew rate limit setting for average bitrate adjustment; sets the minimum | |||
* time in seconds the bitrate tracker may swing from one extreme to the | |||
* other when boosting or damping average bitrate. | |||
*/ | |||
double bitrate_average_damping; | |||
}; | |||
/** | |||
* \name vorbis_encode_ctl() codes | |||
* | |||
* \anchor encctlcodes | |||
* | |||
* These values are passed as the \c number parameter of vorbis_encode_ctl(). | |||
* The type of the referent of that function's \c arg pointer depends on these | |||
* codes. | |||
*/ | |||
/*@{*/ | |||
/** | |||
* Query the current encoder bitrate management setting. | |||
* | |||
*Argument: <tt>struct ovectl_ratemanage2_arg *</tt> | |||
* | |||
* Used to query the current encoder bitrate management setting. Also used to | |||
* initialize fields of an ovectl_ratemanage2_arg structure for use with | |||
* \ref OV_ECTL_RATEMANAGE2_SET. | |||
*/ | |||
#define OV_ECTL_RATEMANAGE2_GET 0x14 | |||
/** | |||
* Set the current encoder bitrate management settings. | |||
* | |||
* Argument: <tt>struct ovectl_ratemanage2_arg *</tt> | |||
* | |||
* Used to set the current encoder bitrate management settings to the values | |||
* listed in the ovectl_ratemanage2_arg. Passing a NULL pointer will disable | |||
* bitrate management. | |||
*/ | |||
#define OV_ECTL_RATEMANAGE2_SET 0x15 | |||
/** | |||
* Returns the current encoder hard-lowpass setting (kHz) in the double | |||
* pointed to by arg. | |||
* | |||
* Argument: <tt>double *</tt> | |||
*/ | |||
#define OV_ECTL_LOWPASS_GET 0x20 | |||
/** | |||
* Sets the encoder hard-lowpass to the value (kHz) pointed to by arg. Valid | |||
* lowpass settings range from 2 to 99. | |||
* | |||
* Argument: <tt>double *</tt> | |||
*/ | |||
#define OV_ECTL_LOWPASS_SET 0x21 | |||
/** | |||
* Returns the current encoder impulse block setting in the double pointed | |||
* to by arg. | |||
* | |||
* Argument: <tt>double *</tt> | |||
*/ | |||
#define OV_ECTL_IBLOCK_GET 0x30 | |||
/** | |||
* Sets the impulse block bias to the the value pointed to by arg. | |||
* | |||
* Argument: <tt>double *</tt> | |||
* | |||
* Valid range is -15.0 to 0.0 [default]. A negative impulse block bias will | |||
* direct to encoder to use more bits when incoding short blocks that contain | |||
* strong impulses, thus improving the accuracy of impulse encoding. | |||
*/ | |||
#define OV_ECTL_IBLOCK_SET 0x31 | |||
/** | |||
* Returns the current encoder coupling setting in the int pointed | |||
* to by arg. | |||
* | |||
* Argument: <tt>int *</tt> | |||
*/ | |||
#define OV_ECTL_COUPLING_GET 0x40 | |||
/** | |||
* Enables/disables channel coupling in multichannel encoding according to arg. | |||
* | |||
* Argument: <tt>int *</tt> | |||
* | |||
* Zero disables channel coupling for multichannel inputs, nonzer enables | |||
* channel coupling. Setting has no effect on monophonic encoding or | |||
* multichannel counts that do not offer coupling. At present, coupling is | |||
* available for stereo and 5.1 encoding. | |||
*/ | |||
#define OV_ECTL_COUPLING_SET 0x41 | |||
/* deprecated rate management supported only for compatibility */ | |||
/** | |||
* Old interface to querying bitrate management settings. | |||
* | |||
* Deprecated after move to bit-reservoir style management in 1.1 rendered | |||
* this interface partially obsolete. | |||
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_GET instead. | |||
* | |||
* Argument: <tt>struct ovectl_ratemanage_arg *</tt> | |||
*/ | |||
#define OV_ECTL_RATEMANAGE_GET 0x10 | |||
/** | |||
* Old interface to modifying bitrate management settings. | |||
* | |||
* deprecated after move to bit-reservoir style management in 1.1 rendered | |||
* this interface partially obsolete. | |||
* | |||
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. | |||
* | |||
* Argument: <tt>struct ovectl_ratemanage_arg *</tt> | |||
*/ | |||
#define OV_ECTL_RATEMANAGE_SET 0x11 | |||
/** | |||
* Old interface to setting average-bitrate encoding mode. | |||
* | |||
* Deprecated after move to bit-reservoir style management in 1.1 rendered | |||
* this interface partially obsolete. | |||
* | |||
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. | |||
* | |||
* Argument: <tt>struct ovectl_ratemanage_arg *</tt> | |||
*/ | |||
#define OV_ECTL_RATEMANAGE_AVG 0x12 | |||
/** | |||
* Old interface to setting bounded-bitrate encoding modes. | |||
* | |||
* deprecated after move to bit-reservoir style management in 1.1 rendered | |||
* this interface partially obsolete. | |||
* | |||
* \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. | |||
* | |||
* Argument: <tt>struct ovectl_ratemanage_arg *</tt> | |||
*/ | |||
#define OV_ECTL_RATEMANAGE_HARD 0x13 | |||
/*@}*/ | |||
#ifdef __cplusplus | |||
} | |||
#endif /* __cplusplus */ | |||
@@ -5,13 +5,13 @@ | |||
* 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 XIPHOPHORUS Company http://www.xiph.org/ * | |||
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * | |||
* by the Xiph.Org Foundation http://www.xiph.org/ * | |||
* * | |||
******************************************************************** | |||
function: stdio-based convenience library for opening/seeking/decoding | |||
last mod: $Id: vorbisfile.h,v 1.1 2007/06/07 17:48:18 jules_rms Exp $ | |||
last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $ | |||
********************************************************************/ | |||
@@ -43,6 +43,65 @@ typedef struct { | |||
long (*tell_func) (void *datasource); | |||
} ov_callbacks; | |||
#ifndef OV_EXCLUDE_STATIC_CALLBACKS | |||
/* a few sets of convenient callbacks, especially for use under | |||
* Windows where ov_open_callbacks() should always be used instead of | |||
* ov_open() to avoid problems with incompatible crt.o version linking | |||
* issues. */ | |||
static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ | |||
if(f==NULL)return(-1); | |||
#ifdef __MINGW32__ | |||
return fseeko64(f,off,whence); | |||
#elif defined (_WIN32) | |||
return _fseeki64(f,off,whence); | |||
#else | |||
return fseek(f,off,whence); | |||
#endif | |||
} | |||
/* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as | |||
* static data. That means that every file which includes this header | |||
* will get its own copy of these structs whether it uses them or | |||
* not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS. | |||
* These static symbols are essential on platforms such as Windows on | |||
* which several different versions of stdio support may be linked to | |||
* by different DLLs, and we need to be certain we know which one | |||
* we're using (the same one as the main application). | |||
*/ | |||
/*static ov_callbacks OV_CALLBACKS_DEFAULT = { | |||
(size_t (*)(void *, size_t, size_t, void *)) fread, | |||
(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, | |||
(int (*)(void *)) fclose, | |||
(long (*)(void *)) ftell | |||
}; | |||
static ov_callbacks OV_CALLBACKS_NOCLOSE = { | |||
(size_t (*)(void *, size_t, size_t, void *)) fread, | |||
(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, | |||
(int (*)(void *)) NULL, | |||
(long (*)(void *)) ftell | |||
}; | |||
static ov_callbacks OV_CALLBACKS_STREAMONLY = { | |||
(size_t (*)(void *, size_t, size_t, void *)) fread, | |||
(int (*)(void *, ogg_int64_t, int)) NULL, | |||
(int (*)(void *)) fclose, | |||
(long (*)(void *)) NULL | |||
}; | |||
static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = { | |||
(size_t (*)(void *, size_t, size_t, void *)) fread, | |||
(int (*)(void *, ogg_int64_t, int)) NULL, | |||
(int (*)(void *)) NULL, | |||
(long (*)(void *)) NULL | |||
};*/ | |||
#endif | |||
#define NOTOPEN 0 | |||
#define PARTOPEN 1 | |||
#define OPENED 2 | |||
@@ -63,8 +122,8 @@ typedef struct OggVorbis_File { | |||
ogg_int64_t *dataoffsets; | |||
long *serialnos; | |||
ogg_int64_t *pcmlengths; /* overloaded to maintain binary | |||
compatability; x2 size, stores both | |||
beginning and end values */ | |||
compatibility; x2 size, stores both | |||
beginning and end values */ | |||
vorbis_info *vi; | |||
vorbis_comment *vc; | |||
@@ -86,14 +145,16 @@ typedef struct OggVorbis_File { | |||
} OggVorbis_File; | |||
extern int ov_clear(OggVorbis_File *vf); | |||
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); | |||
extern int ov_fopen(const char *path,OggVorbis_File *vf); | |||
extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); | |||
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, | |||
char *initial, long ibytes, ov_callbacks callbacks); | |||
const char *initial, long ibytes, ov_callbacks callbacks); | |||
extern int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); | |||
extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); | |||
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, | |||
char *initial, long ibytes, ov_callbacks callbacks); | |||
const char *initial, long ibytes, ov_callbacks callbacks); | |||
extern int ov_test_open(OggVorbis_File *vf); | |||
extern long ov_bitrate(OggVorbis_File *vf,int i); | |||
@@ -126,9 +187,12 @@ extern vorbis_info *ov_info(OggVorbis_File *vf,int link); | |||
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); | |||
extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, | |||
int *bitstream); | |||
int *bitstream); | |||
extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, | |||
int bigendianp,int word,int sgned,int *bitstream, | |||
void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param); | |||
extern long ov_read(OggVorbis_File *vf,char *buffer,int length, | |||
int bigendianp,int word,int sgned,int *bitstream); | |||
int bigendianp,int word,int sgned,int *bitstream); | |||
extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); | |||
extern int ov_halfrate(OggVorbis_File *vf,int flag); | |||
@@ -327,8 +327,7 @@ public: | |||
@see addMidiInputCallback, isMidiInputEnabled | |||
*/ | |||
void setMidiInputEnabled (const String& midiInputDeviceName, | |||
bool enabled); | |||
void setMidiInputEnabled (const String& midiInputDeviceName, bool enabled); | |||
/** Returns true if a given midi input device is being used. | |||
@@ -476,33 +475,22 @@ private: | |||
public MidiInputCallback | |||
{ | |||
public: | |||
AudioDeviceManager* owner; | |||
void audioDeviceIOCallback (const float** inputChannelData, | |||
int totalNumInputChannels, | |||
float** outputChannelData, | |||
int totalNumOutputChannels, | |||
int numSamples); | |||
void audioDeviceIOCallback (const float**, int, float**, int, int); | |||
void audioDeviceAboutToStart (AudioIODevice*); | |||
void audioDeviceStopped(); | |||
void handleIncomingMidiMessage (MidiInput*, const MidiMessage&); | |||
void handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message); | |||
AudioDeviceManager* owner; | |||
}; | |||
CallbackHandler callbackHandler; | |||
friend class CallbackHandler; | |||
void audioDeviceIOCallbackInt (const float** inputChannelData, | |||
int totalNumInputChannels, | |||
float** outputChannelData, | |||
int totalNumOutputChannels, | |||
int numSamples); | |||
void audioDeviceAboutToStartInt (AudioIODevice* device); | |||
void audioDeviceIOCallbackInt (const float** inputChannelData, int totalNumInputChannels, | |||
float** outputChannelData, int totalNumOutputChannels, int numSamples); | |||
void audioDeviceAboutToStartInt (AudioIODevice*); | |||
void audioDeviceStoppedInt(); | |||
void handleIncomingMidiMessageInt (MidiInput* source, const MidiMessage& message); | |||
void handleIncomingMidiMessageInt (MidiInput*, const MidiMessage&); | |||
const String restartDevice (int blockSizeToUse, double sampleRateToUse, | |||
const BigInteger& ins, const BigInteger& outs); | |||
@@ -166,8 +166,7 @@ public: | |||
: context (context_), | |||
flipHeight (flipHeight_), | |||
lastClipRectIsValid (false), | |||
state (new SavedState()), | |||
numGradientLookupEntries (0) | |||
state (new SavedState()) | |||
{ | |||
CGContextRetain (context); | |||
CGContextSaveGState(context); | |||
@@ -177,7 +176,7 @@ public: | |||
rgbColourSpace = CGColorSpaceCreateDeviceRGB(); | |||
greyColourSpace = CGColorSpaceCreateDeviceGray(); | |||
gradientCallbacks.version = 0; | |||
gradientCallbacks.evaluate = gradientCallback; | |||
gradientCallbacks.evaluate = SavedState::gradientCallback; | |||
gradientCallbacks.releaseInfo = 0; | |||
setFont (Font()); | |||
} | |||
@@ -368,7 +367,7 @@ public: | |||
//============================================================================== | |||
void setFill (const FillType& fillType) | |||
{ | |||
state->fillType = fillType; | |||
state->setFill (fillType); | |||
if (fillType.isColour()) | |||
{ | |||
@@ -663,65 +662,93 @@ private: | |||
struct SavedState | |||
{ | |||
SavedState() | |||
: font (1.0f), fontRef (0), fontTransform (CGAffineTransformIdentity) | |||
: font (1.0f), fontRef (0), fontTransform (CGAffineTransformIdentity), | |||
shading (0), numGradientLookupEntries (0) | |||
{ | |||
} | |||
SavedState (const SavedState& other) | |||
: fillType (other.fillType), font (other.font), fontRef (other.fontRef), | |||
fontTransform (other.fontTransform) | |||
fontTransform (other.fontTransform), shading (0), | |||
gradientLookupTable (other.numGradientLookupEntries), | |||
numGradientLookupEntries (other.numGradientLookupEntries) | |||
{ | |||
memcpy (gradientLookupTable, other.gradientLookupTable, sizeof (PixelARGB) * numGradientLookupEntries); | |||
} | |||
FillType fillType; | |||
Font font; | |||
CGFontRef fontRef; | |||
CGAffineTransform fontTransform; | |||
}; | |||
~SavedState() | |||
{ | |||
if (shading != 0) | |||
CGShadingRelease (shading); | |||
} | |||
ScopedPointer <SavedState> state; | |||
OwnedArray <SavedState> stateStack; | |||
HeapBlock <PixelARGB> gradientLookupTable; | |||
int numGradientLookupEntries; | |||
void setFill (const FillType& newFill) | |||
{ | |||
fillType = newFill; | |||
static void gradientCallback (void* info, const CGFloat* inData, CGFloat* outData) | |||
{ | |||
const CoreGraphicsContext* const g = static_cast <const CoreGraphicsContext*> (info); | |||
if (fillType.isGradient() && shading != 0) | |||
{ | |||
CGShadingRelease (shading); | |||
shading = 0; | |||
} | |||
} | |||
const int index = roundToInt (g->numGradientLookupEntries * inData[0]); | |||
PixelARGB colour (g->gradientLookupTable [jlimit (0, g->numGradientLookupEntries, index)]); | |||
colour.unpremultiply(); | |||
CGShadingRef getShading (CoreGraphicsContext& owner) | |||
{ | |||
if (shading == 0) | |||
{ | |||
ColourGradient& g = *(fillType.gradient); | |||
numGradientLookupEntries = g.createLookupTable (fillType.transform, gradientLookupTable) - 1; | |||
outData[0] = colour.getRed() / 255.0f; | |||
outData[1] = colour.getGreen() / 255.0f; | |||
outData[2] = colour.getBlue() / 255.0f; | |||
outData[3] = colour.getAlpha() / 255.0f; | |||
} | |||
CGFunctionRef function = CGFunctionCreate (this, 1, 0, 4, 0, &(owner.gradientCallbacks)); | |||
CGPoint p1 (CGPointMake (g.point1.getX(), g.point1.getY())); | |||
CGShadingRef createGradient (const AffineTransform& transform, ColourGradient gradient) | |||
{ | |||
numGradientLookupEntries = gradient.createLookupTable (transform, gradientLookupTable) - 1; | |||
if (g.isRadial) | |||
{ | |||
shading = CGShadingCreateRadial (owner.rgbColourSpace, p1, 0, | |||
p1, g.point1.getDistanceFrom (g.point2), | |||
function, true, true); | |||
} | |||
else | |||
{ | |||
shading = CGShadingCreateAxial (owner.rgbColourSpace, p1, | |||
CGPointMake (g.point2.getX(), g.point2.getY()), | |||
function, true, true); | |||
} | |||
CGShadingRef result = 0; | |||
CGFunctionRef function = CGFunctionCreate (this, 1, 0, 4, 0, &gradientCallbacks); | |||
CGPoint p1 (CGPointMake (gradient.point1.getX(), gradient.point1.getY())); | |||
CGFunctionRelease (function); | |||
} | |||
if (gradient.isRadial) | |||
{ | |||
result = CGShadingCreateRadial (rgbColourSpace, p1, 0, | |||
p1, gradient.point1.getDistanceFrom (gradient.point2), | |||
function, true, true); | |||
return shading; | |||
} | |||
else | |||
static void gradientCallback (void* info, const CGFloat* inData, CGFloat* outData) | |||
{ | |||
result = CGShadingCreateAxial (rgbColourSpace, p1, | |||
CGPointMake (gradient.point2.getX(), gradient.point2.getY()), | |||
function, true, true); | |||
const SavedState* const s = static_cast <const SavedState*> (info); | |||
const int index = roundToInt (s->numGradientLookupEntries * inData[0]); | |||
PixelARGB colour (s->gradientLookupTable [jlimit (0, s->numGradientLookupEntries, index)]); | |||
colour.unpremultiply(); | |||
outData[0] = colour.getRed() / 255.0f; | |||
outData[1] = colour.getGreen() / 255.0f; | |||
outData[2] = colour.getBlue() / 255.0f; | |||
outData[3] = colour.getAlpha() / 255.0f; | |||
} | |||
CGFunctionRelease (function); | |||
return result; | |||
} | |||
FillType fillType; | |||
Font font; | |||
CGFontRef fontRef; | |||
CGAffineTransform fontTransform; | |||
private: | |||
CGShadingRef shading; | |||
HeapBlock <PixelARGB> gradientLookupTable; | |||
int numGradientLookupEntries; | |||
}; | |||
ScopedPointer <SavedState> state; | |||
OwnedArray <SavedState> stateStack; | |||
void drawGradient() | |||
{ | |||
@@ -730,10 +757,8 @@ private: | |||
CGContextSetInterpolationQuality (context, kCGInterpolationDefault); // (This is required for 10.4, where there's a crash if | |||
// you draw a gradient with high quality interp enabled). | |||
CGShadingRef shading = createGradient (state->fillType.transform, *(state->fillType.gradient)); | |||
CGContextSetAlpha (context, state->fillType.getOpacity()); | |||
CGContextDrawShading (context, shading); | |||
CGShadingRelease (shading); | |||
CGContextDrawShading (context, state->getShading (*this)); | |||
} | |||
void createPath (const Path& path) const | |||