[xiph-commits] r10575 - in trunk/xiph-qt: CASpeex/src CAVorbis/src
OggImport/src build-win32 common utils
arek at svn.xiph.org
arek at svn.xiph.org
Sat Dec 10 11:33:49 PST 2005
Author: arek
Date: 2005-12-10 11:33:16 -0800 (Sat, 10 Dec 2005)
New Revision: 10575
Modified:
trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.cpp
trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.h
trunk/xiph-qt/CASpeex/src/CASpeexDecoder.cpp
trunk/xiph-qt/CASpeex/src/CASpeexDecoder.h
trunk/xiph-qt/CASpeex/src/speex_entrypoints.cpp
trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp
trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.h
trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.cpp
trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.h
trunk/xiph-qt/CAVorbis/src/vorbis_entrypoints.cpp
trunk/xiph-qt/OggImport/src/OggImport.c
trunk/xiph-qt/OggImport/src/OggImport.r
trunk/xiph-qt/OggImport/src/importer_types.h
trunk/xiph-qt/OggImport/src/rb.c
trunk/xiph-qt/OggImport/src/rb.h
trunk/xiph-qt/OggImport/src/stream_speex.c
trunk/xiph-qt/OggImport/src/stream_speex.h
trunk/xiph-qt/OggImport/src/stream_types_speex.h
trunk/xiph-qt/OggImport/src/stream_types_vorbis.h
trunk/xiph-qt/OggImport/src/stream_vorbis.c
trunk/xiph-qt/OggImport/src/stream_vorbis.h
trunk/xiph-qt/build-win32/DllMain.c
trunk/xiph-qt/build-win32/pxml.c
trunk/xiph-qt/common/XCACodec.cpp
trunk/xiph-qt/common/XCACodec.h
trunk/xiph-qt/common/data_types.h
trunk/xiph-qt/common/fccs.h
trunk/xiph-qt/utils/ringbuffer.cpp
trunk/xiph-qt/utils/ringbuffer.h
trunk/xiph-qt/utils/wrap_ogg.cpp
Log:
White-space cleanup, solely.
Modified: trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.cpp
===================================================================
--- trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -41,15 +41,15 @@
CAOggSpeexDecoder::CAOggSpeexDecoder() :
-CASpeexDecoder(true),
-mO_st(), mFramesBufferedList()
+ CASpeexDecoder(true),
+ mO_st(), mFramesBufferedList()
{
CAStreamBasicDescription theInputFormat(kAudioStreamAnyRate, kAudioFormatXiphOggFramedSpeex,
kSpeexBytesPerPacket, kSpeexFramesPerPacket,
kSpeexBytesPerFrame, kSpeexChannelsPerFrame,
kSpeexBitsPerChannel, kSpeexFormatFlags);
AddInputFormat(theInputFormat);
-
+
mInputFormat.mSampleRate = 44100;
mInputFormat.mFormatID = kAudioFormatXiphOggFramedSpeex;
mInputFormat.mFormatFlags = kSpeexFormatFlags;
@@ -58,7 +58,7 @@
mInputFormat.mBytesPerFrame = kSpeexBytesPerFrame;
mInputFormat.mChannelsPerFrame = 2;
mInputFormat.mBitsPerChannel = 16;
-
+
CAStreamBasicDescription theOutputFormat1(kAudioStreamAnyRate, kAudioFormatLinearPCM, 0, 1, 0, 0, 16,
kAudioFormatFlagsNativeEndian |
kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked);
@@ -66,15 +66,15 @@
CAStreamBasicDescription theOutputFormat2(kAudioStreamAnyRate, kAudioFormatLinearPCM, 0, 1, 0, 0, 32,
kAudioFormatFlagsNativeFloatPacked);
AddOutputFormat(theOutputFormat2);
-
+
mOutputFormat.mSampleRate = 44100;
- mOutputFormat.mFormatID = kAudioFormatLinearPCM;
- mOutputFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
- mOutputFormat.mBytesPerPacket = 8;
- mOutputFormat.mFramesPerPacket = 1;
- mOutputFormat.mBytesPerFrame = 8;
- mOutputFormat.mChannelsPerFrame = 2;
- mOutputFormat.mBitsPerChannel = 32;
+ mOutputFormat.mFormatID = kAudioFormatLinearPCM;
+ mOutputFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
+ mOutputFormat.mBytesPerPacket = 8;
+ mOutputFormat.mFramesPerPacket = 1;
+ mOutputFormat.mBytesPerFrame = 8;
+ mOutputFormat.mChannelsPerFrame = 2;
+ mOutputFormat.mBitsPerChannel = 32;
}
CAOggSpeexDecoder::~CAOggSpeexDecoder()
@@ -85,18 +85,18 @@
void CAOggSpeexDecoder::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
{
- if (!mIsInitialized) {
- // check to make sure the input format is legal
- if (inInputFormat.mFormatID != kAudioFormatXiphOggFramedSpeex) {
- dbg_printf("CASpeexDecoder::SetFormats: only supports Xiph Speex (Ogg-framed)for input\n");
- CODEC_THROW(kAudioCodecUnsupportedFormatError);
- }
-
- // tell our base class about the new format
- XCACodec::SetCurrentInputFormat(inInputFormat);
- } else {
- CODEC_THROW(kAudioCodecStateError);
- }
+ if (!mIsInitialized) {
+ // check to make sure the input format is legal
+ if (inInputFormat.mFormatID != kAudioFormatXiphOggFramedSpeex) {
+ dbg_printf("CASpeexDecoder::SetFormats: only supports Xiph Speex (Ogg-framed)for input\n");
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
+
+ // tell our base class about the new format
+ XCACodec::SetCurrentInputFormat(inInputFormat);
+ } else {
+ CODEC_THROW(kAudioCodecStateError);
+ }
}
UInt32 CAOggSpeexDecoder::ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
@@ -125,7 +125,7 @@
ogg_packets++;
mFramesBufferedList.erase(mFramesBufferedList.begin());
}
-
+
speex_total_returned_data += speex_returned_data;
if (speex_total_returned_data == ioOutputDataByteSize || speex_return == kAudioCodecProduceOutputPacketSuccess)
@@ -184,7 +184,7 @@
{
if (!mCompressionInitialized)
CODEC_THROW(kAudioCodecUnspecifiedError);
-
+
ogg_page op;
if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize, inPacketDescription->mStartOffset))
@@ -218,7 +218,7 @@
packet_length_adjust = 0;
continue;
}
-
+
packet_count++;
speex_packet_desc.mDataByteSize = opk.bytes;
@@ -244,7 +244,7 @@
ogg_stream_clear(&mO_st);
OggSerialNoAtom *atom = reinterpret_cast<OggSerialNoAtom*> (mCookie);
-
+
if (EndianS32_BtoN(atom->type) == kCookieTypeOggSerialNo && (mCookieSize - EndianS32_BtoN(atom->size) >= 0)) {
ogg_stream_init(&mO_st, EndianS32_BtoN(atom->serialno));
}
Modified: trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.h
===================================================================
--- trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CASpeex/src/CAOggSpeexDecoder.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -42,27 +42,27 @@
class CAOggSpeexDecoder :
public CASpeexDecoder
{
-public:
+ public:
CAOggSpeexDecoder();
virtual ~CAOggSpeexDecoder();
- virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
-
- virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
+ virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
+
+ virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
AudioStreamPacketDescription* outPacketDescription);
-protected:
- virtual void BDCInitialize(UInt32 inInputBufferByteSize);
- virtual void BDCUninitialize();
- virtual void BDCReset();
- virtual void BDCReallocate(UInt32 inInputBufferByteSize);
+ protected:
+ virtual void BDCInitialize(UInt32 inInputBufferByteSize);
+ virtual void BDCUninitialize();
+ virtual void BDCReset();
+ virtual void BDCReallocate(UInt32 inInputBufferByteSize);
- virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription);
-
- void InitializeCompressionSettings();
+ virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription);
- ogg_stream_state mO_st;
- std::vector<SInt32> mFramesBufferedList;
+ void InitializeCompressionSettings();
+
+ ogg_stream_state mO_st;
+ std::vector<SInt32> mFramesBufferedList;
};
Modified: trunk/xiph-qt/CASpeex/src/CASpeexDecoder.cpp
===================================================================
--- trunk/xiph-qt/CASpeex/src/CASpeexDecoder.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CASpeex/src/CASpeexDecoder.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -44,11 +44,11 @@
#include "debug.h"
CASpeexDecoder::CASpeexDecoder(Boolean inSkipFormatsInitialization /* = false */) :
-mCookie(NULL), mCookieSize(0), mCompressionInitialized(false),
-mOutBuffer(NULL), mOutBufferSize(0), mOutBufferUsedSize(0), mOutBufferStart(0),
-mSpeexFPList(),
-mNumFrames(0),
-mSpeexDecoderState(NULL)
+ mCookie(NULL), mCookieSize(0), mCompressionInitialized(false),
+ mOutBuffer(NULL), mOutBufferSize(0), mOutBufferUsedSize(0), mOutBufferStart(0),
+ mSpeexFPList(),
+ mNumFrames(0),
+ mSpeexDecoderState(NULL)
{
mSpeexStereoState.balance = 1.0;
mSpeexStereoState.e_ratio = 0.5;
@@ -57,7 +57,7 @@
if (inSkipFormatsInitialization)
return;
-
+
CAStreamBasicDescription theInputFormat(kAudioStreamAnyRate, kAudioFormatXiphSpeex,
kSpeexBytesPerPacket, kSpeexFramesPerPacket,
kSpeexBytesPerFrame, kSpeexChannelsPerFrame,
@@ -72,7 +72,7 @@
mInputFormat.mBytesPerFrame = kSpeexBytesPerFrame;
mInputFormat.mChannelsPerFrame = 2;
mInputFormat.mBitsPerChannel = 16;
-
+
CAStreamBasicDescription theOutputFormat1(kAudioStreamAnyRate, kAudioFormatLinearPCM, 0, 1, 0, 0, 16,
kAudioFormatFlagsNativeEndian |
kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked);
@@ -82,13 +82,13 @@
AddOutputFormat(theOutputFormat2);
mOutputFormat.mSampleRate = 44100;
- mOutputFormat.mFormatID = kAudioFormatLinearPCM;
- mOutputFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
- mOutputFormat.mBytesPerPacket = 8;
- mOutputFormat.mFramesPerPacket = 1;
- mOutputFormat.mBytesPerFrame = 8;
- mOutputFormat.mChannelsPerFrame = 2;
- mOutputFormat.mBitsPerChannel = 32;
+ mOutputFormat.mFormatID = kAudioFormatLinearPCM;
+ mOutputFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
+ mOutputFormat.mBytesPerPacket = 8;
+ mOutputFormat.mFramesPerPacket = 1;
+ mOutputFormat.mBytesPerFrame = 8;
+ mOutputFormat.mChannelsPerFrame = 2;
+ mOutputFormat.mBitsPerChannel = 32;
}
CASpeexDecoder::~CASpeexDecoder()
@@ -104,184 +104,184 @@
}
void CASpeexDecoder::Initialize(const AudioStreamBasicDescription* inInputFormat,
- const AudioStreamBasicDescription* inOutputFormat,
- const void* inMagicCookie, UInt32 inMagicCookieByteSize)
+ const AudioStreamBasicDescription* inOutputFormat,
+ const void* inMagicCookie, UInt32 inMagicCookieByteSize)
{
dbg_printf(" >> [%08lx] CASpeexDecoder :: Initialize(%d, %d, %d)\n", (UInt32) this, inInputFormat != NULL, inOutputFormat != NULL, inMagicCookieByteSize != 0);
if(inInputFormat != NULL) {
- SetCurrentInputFormat(*inInputFormat);
- }
-
- if(inOutputFormat != NULL) {
- SetCurrentOutputFormat(*inOutputFormat);
- }
-
+ SetCurrentInputFormat(*inInputFormat);
+ }
+
+ if(inOutputFormat != NULL) {
+ SetCurrentOutputFormat(*inOutputFormat);
+ }
+
if ((mInputFormat.mSampleRate != mOutputFormat.mSampleRate) ||
- (mInputFormat.mChannelsPerFrame != mOutputFormat.mChannelsPerFrame)) {
- CODEC_THROW(kAudioCodecUnsupportedFormatError);
- }
-
+ (mInputFormat.mChannelsPerFrame != mOutputFormat.mChannelsPerFrame)) {
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
+
// needs to be called after input & output format have been set
BDCInitialize(kSpeexDecoderInBufferSize);
//if (inMagicCookieByteSize == 0)
// CODEC_THROW(kAudioCodecUnsupportedFormatError);
-
+
if (inMagicCookieByteSize != 0) {
SetMagicCookie(inMagicCookie, inMagicCookieByteSize);
}
-
+
XCACodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
dbg_printf("<.. [%08lx] CASpeexDecoder :: Initialize(%d, %d, %d)\n", (UInt32) this, inInputFormat != NULL, inOutputFormat != NULL, inMagicCookieByteSize != 0);
}
-void CASpeexDecoder::Uninitialize()
+void CASpeexDecoder::Uninitialize()
{
dbg_printf(" >> [%08lx] CASpeexDecoder :: Uninitialize()\n", (UInt32) this);
BDCUninitialize();
- XCACodec::Uninitialize();
+ XCACodec::Uninitialize();
dbg_printf("<.. [%08lx] CASpeexDecoder :: Uninitialize()\n", (UInt32) this);
}
-void CASpeexDecoder::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData)
-{
+void CASpeexDecoder::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData)
+{
dbg_printf(" >> [%08lx] CASpeexDecoder :: GetProperty('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
- switch(inPropertyID)
- {
- case kAudioCodecPropertyRequiresPacketDescription:
- if(ioPropertyDataSize == sizeof(UInt32))
- {
- *reinterpret_cast<UInt32*>(outPropertyData) = 1;
- }
- else
- {
- CODEC_THROW(kAudioCodecBadPropertySizeError);
- }
- break;
- case kAudioCodecPropertyHasVariablePacketByteSizes:
- if(ioPropertyDataSize == sizeof(UInt32))
- {
- *reinterpret_cast<UInt32*>(outPropertyData) = 1;
- }
- else
- {
- CODEC_THROW(kAudioCodecBadPropertySizeError);
- }
- break;
- case kAudioCodecPropertyPacketFrameSize:
- if(ioPropertyDataSize == sizeof(UInt32))
- {
- *reinterpret_cast<UInt32*>(outPropertyData) = kSpeexFramesPerPacket;
- }
- else
- {
- CODEC_THROW(kAudioCodecBadPropertySizeError);
- }
- break;
-
+ switch(inPropertyID)
+ {
+ case kAudioCodecPropertyRequiresPacketDescription:
+ if(ioPropertyDataSize == sizeof(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = 1;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+ case kAudioCodecPropertyHasVariablePacketByteSizes:
+ if(ioPropertyDataSize == sizeof(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = 1;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+ case kAudioCodecPropertyPacketFrameSize:
+ if(ioPropertyDataSize == sizeof(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = kSpeexFramesPerPacket;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
//case kAudioCodecPropertyQualitySetting: ???
#if TARGET_OS_MAC
- case kAudioCodecPropertyNameCFString:
- {
- if (ioPropertyDataSize != sizeof(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError);
-
- CABundleLocker lock;
- CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Xiph Speex decoder"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR(""));
- *(CFStringRef*)outPropertyData = name;
- break;
- }
+ case kAudioCodecPropertyNameCFString:
+ {
+ if (ioPropertyDataSize != sizeof(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError);
+ CABundleLocker lock;
+ CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Xiph Speex decoder"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR(""));
+ *(CFStringRef*)outPropertyData = name;
+ break;
+ }
+
//case kAudioCodecPropertyManufacturerCFString:
#endif
- default:
- ACBaseCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
- }
+ default:
+ ACBaseCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
+ }
dbg_printf("<.. [%08lx] CASpeexDecoder :: GetProperty('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
}
-void CASpeexDecoder::GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, bool& outWritable)
+void CASpeexDecoder::GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, bool& outWritable)
{
dbg_printf(" >> [%08lx] CASpeexDecoder :: GetPropertyInfo('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
- switch(inPropertyID)
- {
- case kAudioCodecPropertyRequiresPacketDescription:
- outPropertyDataSize = sizeof(UInt32);
- outWritable = false;
- break;
-
- case kAudioCodecPropertyHasVariablePacketByteSizes:
- outPropertyDataSize = sizeof(UInt32);
- outWritable = false;
- break;
-
- case kAudioCodecPropertyPacketFrameSize:
- outPropertyDataSize = sizeof(UInt32);
- outWritable = false;
- break;
-
- default:
- ACBaseCodec::GetPropertyInfo(inPropertyID, outPropertyDataSize, outWritable);
- break;
-
- }
+ switch(inPropertyID)
+ {
+ case kAudioCodecPropertyRequiresPacketDescription:
+ outPropertyDataSize = sizeof(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyHasVariablePacketByteSizes:
+ outPropertyDataSize = sizeof(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyPacketFrameSize:
+ outPropertyDataSize = sizeof(UInt32);
+ outWritable = false;
+ break;
+
+ default:
+ ACBaseCodec::GetPropertyInfo(inPropertyID, outPropertyDataSize, outWritable);
+ break;
+
+ }
dbg_printf("<.. [%08lx] CASpeexDecoder :: GetPropertyInfo('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
}
-void CASpeexDecoder::Reset()
+void CASpeexDecoder::Reset()
{
dbg_printf(">> [%08lx] CASpeexDecoder :: Reset()\n", (UInt32) this);
BDCReset();
- XCACodec::Reset();
+ XCACodec::Reset();
dbg_printf("<< [%08lx] CASpeexDecoder :: Reset()\n", (UInt32) this);
}
-UInt32 CASpeexDecoder::GetVersion() const
+UInt32 CASpeexDecoder::GetVersion() const
{
- return kCASpeex_adec_Version;
+ return kCASpeex_adec_Version;
}
void CASpeexDecoder::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
{
- if (!mIsInitialized) {
- // check to make sure the input format is legal
- if (inInputFormat.mFormatID != kAudioFormatXiphSpeex) {
- dbg_printf("CASpeexDecoder::SetFormats: only supports Xiph Speex for input\n");
- CODEC_THROW(kAudioCodecUnsupportedFormatError);
- }
-
- // tell our base class about the new format
- XCACodec::SetCurrentInputFormat(inInputFormat);
- } else {
- CODEC_THROW(kAudioCodecStateError);
- }
+ if (!mIsInitialized) {
+ // check to make sure the input format is legal
+ if (inInputFormat.mFormatID != kAudioFormatXiphSpeex) {
+ dbg_printf("CASpeexDecoder::SetFormats: only supports Xiph Speex for input\n");
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
+
+ // tell our base class about the new format
+ XCACodec::SetCurrentInputFormat(inInputFormat);
+ } else {
+ CODEC_THROW(kAudioCodecStateError);
+ }
}
-void CASpeexDecoder::SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat)
+void CASpeexDecoder::SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat)
{
- if (!mIsInitialized)
- {
- // check to make sure the output format is legal
- if ((inOutputFormat.mFormatID != kAudioFormatLinearPCM) ||
- !(((inOutputFormat.mFormatFlags == kAudioFormatFlagsNativeFloatPacked) &&
+ if (!mIsInitialized)
+ {
+ // check to make sure the output format is legal
+ if ((inOutputFormat.mFormatID != kAudioFormatLinearPCM) ||
+ !(((inOutputFormat.mFormatFlags == kAudioFormatFlagsNativeFloatPacked) &&
(inOutputFormat.mBitsPerChannel == 32)) ||
- ((inOutputFormat.mFormatFlags == (kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked)) &&
- (inOutputFormat.mBitsPerChannel == 16))))
+ ((inOutputFormat.mFormatFlags == (kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked)) &&
+ (inOutputFormat.mBitsPerChannel == 16))))
{
- dbg_printf("CASpeexDecoder::SetFormats: only supports"
- " either 16 bit native endian signed integer or 32 bit native endian CoreAudio floats for output\n");
- CODEC_THROW(kAudioCodecUnsupportedFormatError);
- }
-
- // tell our base class about the new format
- XCACodec::SetCurrentOutputFormat(inOutputFormat);
- } else {
- CODEC_THROW(kAudioCodecStateError);
- }
+ dbg_printf("CASpeexDecoder::SetFormats: only supports"
+ " either 16 bit native endian signed integer or 32 bit native endian CoreAudio floats for output\n");
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
+
+ // tell our base class about the new format
+ XCACodec::SetCurrentOutputFormat(inOutputFormat);
+ } else {
+ CODEC_THROW(kAudioCodecStateError);
+ }
}
UInt32 CASpeexDecoder::GetMagicCookieByteSize() const
@@ -292,7 +292,7 @@
void CASpeexDecoder::GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const
{
ioMagicCookieDataByteSize = mCookieSize;
-
+
if (mCookie != NULL)
outMagicCookieData = mCookie;
}
@@ -300,13 +300,13 @@
void CASpeexDecoder::SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize)
{
dbg_printf(" >> [%08lx] CASpeexDecoder :: SetMagicCookie()\n", (UInt32) this);
- if (mIsInitialized)
- CODEC_THROW(kAudioCodecStateError);
-
+ if (mIsInitialized)
+ CODEC_THROW(kAudioCodecStateError);
+
SetCookie(inMagicCookieData, inMagicCookieDataByteSize);
-
+
InitializeCompressionSettings();
-
+
if (!mCompressionInitialized)
CODEC_THROW(kAudioCodecUnsupportedFormatError);
dbg_printf("<.. [%08lx] CASpeexDecoder :: SetMagicCookie()\n", (UInt32) this);
@@ -316,7 +316,7 @@
{
if (mCookie != NULL)
delete[] mCookie;
-
+
mCookieSize = inMagicCookieDataByteSize;
if (inMagicCookieDataByteSize != 0) {
mCookie = new Byte[inMagicCookieDataByteSize];
@@ -330,7 +330,7 @@
{
if (mCookie == NULL)
return;
-
+
if (mCompressionInitialized) {
memset(&mSpeexHeader, 0, sizeof(mSpeexHeader));
@@ -344,13 +344,13 @@
mSpeexDecoderState = NULL;
}
}
-
+
mCompressionInitialized = false;
-
+
OggSerialNoAtom *atom = reinterpret_cast<OggSerialNoAtom*> (mCookie);
Byte *ptrheader = mCookie + EndianU32_BtoN(atom->size);
CookieAtomHeader *aheader = reinterpret_cast<CookieAtomHeader*> (ptrheader);
-
+
// scan quickly through the cookie, check types and packet sizes
if (EndianS32_BtoN(atom->type) != kCookieTypeOggSerialNo || static_cast<UInt32> (ptrheader - mCookie) > mCookieSize)
return;
@@ -362,34 +362,34 @@
// all OK, back to the first speex packet
aheader = reinterpret_cast<CookieAtomHeader*> (mCookie + EndianU32_BtoN(atom->size));
SpeexHeader *inheader = reinterpret_cast<SpeexHeader *> (&aheader->data[0]);
-
+
// TODO: convert, at some point, mSpeexHeader to a pointer?
- mSpeexHeader.bitrate = EndianS32_LtoN(inheader->bitrate);
- mSpeexHeader.extra_headers = EndianS32_LtoN(inheader->extra_headers);
- mSpeexHeader.frame_size = EndianS32_LtoN(inheader->frame_size);
- mSpeexHeader.frames_per_packet = EndianS32_LtoN(inheader->frames_per_packet);
- mSpeexHeader.header_size = EndianS32_LtoN(inheader->header_size);
- mSpeexHeader.mode = EndianS32_LtoN(inheader->mode);
- mSpeexHeader.mode_bitstream_version = EndianS32_LtoN(inheader->mode_bitstream_version);
- mSpeexHeader.nb_channels = EndianS32_LtoN(inheader->nb_channels);
- mSpeexHeader.rate = EndianS32_LtoN(inheader->rate);
- mSpeexHeader.reserved1 = EndianS32_LtoN(inheader->reserved1);
- mSpeexHeader.reserved2 = EndianS32_LtoN(inheader->reserved2);
- mSpeexHeader.speex_version_id = EndianS32_LtoN(inheader->speex_version_id);
- mSpeexHeader.vbr = EndianS32_LtoN(inheader->vbr);
+ mSpeexHeader.bitrate = EndianS32_LtoN(inheader->bitrate);
+ mSpeexHeader.extra_headers = EndianS32_LtoN(inheader->extra_headers);
+ mSpeexHeader.frame_size = EndianS32_LtoN(inheader->frame_size);
+ mSpeexHeader.frames_per_packet = EndianS32_LtoN(inheader->frames_per_packet);
+ mSpeexHeader.header_size = EndianS32_LtoN(inheader->header_size);
+ mSpeexHeader.mode = EndianS32_LtoN(inheader->mode);
+ mSpeexHeader.mode_bitstream_version = EndianS32_LtoN(inheader->mode_bitstream_version);
+ mSpeexHeader.nb_channels = EndianS32_LtoN(inheader->nb_channels);
+ mSpeexHeader.rate = EndianS32_LtoN(inheader->rate);
+ mSpeexHeader.reserved1 = EndianS32_LtoN(inheader->reserved1);
+ mSpeexHeader.reserved2 = EndianS32_LtoN(inheader->reserved2);
+ mSpeexHeader.speex_version_id = EndianS32_LtoN(inheader->speex_version_id);
+ mSpeexHeader.vbr = EndianS32_LtoN(inheader->vbr);
if (mSpeexHeader.mode >= SPEEX_NB_MODES)
CODEC_THROW(kAudioCodecUnsupportedFormatError);
-
+
//TODO: check bitstream version here
-
+
mSpeexDecoderState = speex_decoder_init(speex_lib_get_mode(mSpeexHeader.mode));
if (!mSpeexDecoderState)
CODEC_THROW(kAudioCodecUnsupportedFormatError);
-
+
//TODO: fix some of the header fields here
-
+
if (mSpeexHeader.nb_channels == 2)
{
SpeexCallback callback;
@@ -416,7 +416,7 @@
mOutBufferSize = kSpeexDecoderOutBufferSize;
mOutBufferUsedSize = 0;
mOutBufferStart = 0;
-
+
XCACodec::BDCInitialize(inInputBufferByteSize);
}
@@ -427,14 +427,14 @@
speex_decoder_ctl(mSpeexDecoderState, SPEEX_RESET_STATE, NULL); //??!
mSpeexFPList.clear();
-
+
if (mOutBuffer)
delete[] mOutBuffer;
mOutBuffer = NULL;
mOutBufferSize = 0;
mOutBufferUsedSize = 0;
mOutBufferStart = 0;
-
+
XCACodec::BDCUninitialize();
}
@@ -494,12 +494,12 @@
result = speex_decode(mSpeexDecoderState, &mSpeexBits, reinterpret_cast<float*> (mOutBuffer + mOutBufferUsedSize));
else
result = speex_decode_int(mSpeexDecoderState, &mSpeexBits, reinterpret_cast<spx_int16_t*> (mOutBuffer + mOutBufferUsedSize));
-
+
if (result < 0) {
mBDCStatus = kBDCStatusAbort;
return false;
}
-
+
if (mSpeexHeader.nb_channels == 2) {
if (mOutputFormat.mFormatFlags & kAudioFormatFlagsNativeFloatPacked != 0)
speex_decode_stereo(reinterpret_cast<float*> (mOutBuffer + mOutBufferUsedSize), mSpeexHeader.frame_size, &mSpeexStereoState);
@@ -546,10 +546,10 @@
void CASpeexDecoder::Zap(UInt32 inFrames)
{
mNumFrames -= inFrames;
-
+
if (mNumFrames < 0)
mNumFrames = 0;
-
+
if (mNumFrames == 0) {
mOutBufferUsedSize = 0;
mOutBufferStart = 0;
Modified: trunk/xiph-qt/CASpeex/src/CASpeexDecoder.h
===================================================================
--- trunk/xiph-qt/CASpeex/src/CASpeexDecoder.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CASpeex/src/CASpeexDecoder.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -51,74 +51,74 @@
class CASpeexDecoder:
public XCACodec
{
-public:
+ public:
CASpeexDecoder(Boolean inSkipFormatsInitialization = false);
virtual ~CASpeexDecoder();
- virtual void Initialize(const AudioStreamBasicDescription* inInputFormat, \
- const AudioStreamBasicDescription* inOutputFormat, \
+ virtual void Initialize(const AudioStreamBasicDescription* inInputFormat,
+ const AudioStreamBasicDescription* inOutputFormat,
const void* inMagicCookie, UInt32 inMagicCookieByteSize);
- virtual void Uninitialize();
- virtual void Reset();
+ virtual void Uninitialize();
+ virtual void Reset();
- virtual void GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData);
- virtual void GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, bool& outWritable);
-
- virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
- virtual void SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat);
- virtual UInt32 GetVersion() const;
+ virtual void GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData);
+ virtual void GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, bool& outWritable);
- virtual UInt32 GetMagicCookieByteSize() const;
- virtual void GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const;
- virtual void SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize);
+ virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
+ virtual void SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat);
+ virtual UInt32 GetVersion() const;
-protected:
- virtual void BDCInitialize(UInt32 inInputBufferByteSize);
- virtual void BDCUninitialize();
- virtual void BDCReset();
- virtual void BDCReallocate(UInt32 inInputBufferByteSize);
-
- virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription);
-
- virtual UInt32 FramesReady() const;
- virtual Boolean GenerateFrames();
- virtual void OutputFrames(void* outOutputData, UInt32 inNumberFrames, UInt32 inFramesOffset) const;
- virtual void Zap(UInt32 inFrames);
-
- void SetCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize);
- virtual void InitializeCompressionSettings();
+ virtual UInt32 GetMagicCookieByteSize() const;
+ virtual void GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const;
+ virtual void SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize);
+ protected:
+ virtual void BDCInitialize(UInt32 inInputBufferByteSize);
+ virtual void BDCUninitialize();
+ virtual void BDCReset();
+ virtual void BDCReallocate(UInt32 inInputBufferByteSize);
+
+ virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription);
+
+ virtual UInt32 FramesReady() const;
+ virtual Boolean GenerateFrames();
+ virtual void OutputFrames(void* outOutputData, UInt32 inNumberFrames, UInt32 inFramesOffset) const;
+ virtual void Zap(UInt32 inFrames);
+
+ void SetCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize);
+ virtual void InitializeCompressionSettings();
+
//virtual void FixFormats();
-protected:
- Byte* mCookie;
- UInt32 mCookieSize;
+ protected:
+ Byte* mCookie;
+ UInt32 mCookieSize;
- Boolean mCompressionInitialized;
+ Boolean mCompressionInitialized;
- Byte* mOutBuffer;
- UInt32 mOutBufferSize;
- UInt32 mOutBufferUsedSize;
- UInt32 mOutBufferStart;
+ Byte* mOutBuffer;
+ UInt32 mOutBufferSize;
+ UInt32 mOutBufferUsedSize;
+ UInt32 mOutBufferStart;
struct SpeexFramePacket {
SInt32 frames;
- UInt32 bytes;
- UInt32 left;
-
+ UInt32 bytes;
+ UInt32 left;
+
SpeexFramePacket() : frames(0), bytes(0), left(0) {};
SpeexFramePacket(SInt32 inFrames, UInt32 inBytes) : frames(inFrames), bytes(inBytes), left(inBytes) {};
};
-
+
typedef std::vector<SpeexFramePacket> SpeexFramePacketList;
- SpeexFramePacketList mSpeexFPList;
+ SpeexFramePacketList mSpeexFPList;
- UInt32 mNumFrames;
+ UInt32 mNumFrames;
- SpeexHeader mSpeexHeader;
- SpeexBits mSpeexBits;
- void *mSpeexDecoderState;
- SpeexStereoState mSpeexStereoState;
+ SpeexHeader mSpeexHeader;
+ SpeexBits mSpeexBits;
+ void *mSpeexDecoderState;
+ SpeexStereoState mSpeexStereoState;
enum {
Modified: trunk/xiph-qt/CASpeex/src/speex_entrypoints.cpp
===================================================================
--- trunk/xiph-qt/CASpeex/src/speex_entrypoints.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CASpeex/src/speex_entrypoints.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -35,12 +35,12 @@
extern "C"
ComponentResult CASpeexDecoderEntry(ComponentParameters* inParameters, CASpeexDecoder* inThis)
-{
- return ACCodecDispatch(inParameters, inThis);
+{
+ return ACCodecDispatch(inParameters, inThis);
}
extern "C"
ComponentResult CAOggSpeexDecoderEntry(ComponentParameters* inParameters, CAOggSpeexDecoder* inThis)
-{
- return ACCodecDispatch(inParameters, inThis);
+{
+ return ACCodecDispatch(inParameters, inThis);
}
Modified: trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp
===================================================================
--- trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -41,15 +41,15 @@
CAOggVorbisDecoder::CAOggVorbisDecoder() :
-CAVorbisDecoder(true),
-mFramesBufferedList()
+ CAVorbisDecoder(true),
+ mFramesBufferedList()
{
CAStreamBasicDescription theInputFormat(kAudioStreamAnyRate, kAudioFormatXiphOggFramedVorbis,
kVorbisBytesPerPacket, kVorbisFramesPerPacket,
kVorbisBytesPerFrame, kVorbisChannelsPerFrame,
kVorbisBitsPerChannel, kVorbisFormatFlags);
AddInputFormat(theInputFormat);
-
+
mInputFormat.mSampleRate = 44100;
mInputFormat.mFormatID = kAudioFormatXiphOggFramedVorbis;
mInputFormat.mFormatFlags = kVorbisFormatFlags;
@@ -58,7 +58,7 @@
mInputFormat.mBytesPerFrame = kVorbisBytesPerFrame;
mInputFormat.mChannelsPerFrame = 2;
mInputFormat.mBitsPerChannel = kVorbisBitsPerChannel;
-
+
CAStreamBasicDescription theOutputFormat1(kAudioStreamAnyRate, kAudioFormatLinearPCM, 0, 1, 0, 0, 16,
kAudioFormatFlagsNativeEndian |
kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked);
@@ -66,15 +66,15 @@
CAStreamBasicDescription theOutputFormat2(kAudioStreamAnyRate, kAudioFormatLinearPCM, 0, 1, 0, 0, 32,
kAudioFormatFlagsNativeFloatPacked);
AddOutputFormat(theOutputFormat2);
-
+
mOutputFormat.mSampleRate = 44100;
- mOutputFormat.mFormatID = kAudioFormatLinearPCM;
- mOutputFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
- mOutputFormat.mBytesPerPacket = 8;
- mOutputFormat.mFramesPerPacket = 1;
- mOutputFormat.mBytesPerFrame = 8;
- mOutputFormat.mChannelsPerFrame = 2;
- mOutputFormat.mBitsPerChannel = 32;
+ mOutputFormat.mFormatID = kAudioFormatLinearPCM;
+ mOutputFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
+ mOutputFormat.mBytesPerPacket = 8;
+ mOutputFormat.mFramesPerPacket = 1;
+ mOutputFormat.mBytesPerFrame = 8;
+ mOutputFormat.mChannelsPerFrame = 2;
+ mOutputFormat.mBitsPerChannel = 32;
}
CAOggVorbisDecoder::~CAOggVorbisDecoder()
@@ -85,15 +85,15 @@
void CAOggVorbisDecoder::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
{
- if (!mIsInitialized) {
- if (inInputFormat.mFormatID != kAudioFormatXiphOggFramedVorbis) {
- dbg_printf("CAOggVorbisDecoder::SetFormats: only support Xiph Vorbis (Ogg-framed) for input\n");
- CODEC_THROW(kAudioCodecUnsupportedFormatError);
- }
+ if (!mIsInitialized) {
+ if (inInputFormat.mFormatID != kAudioFormatXiphOggFramedVorbis) {
+ dbg_printf("CAOggVorbisDecoder::SetFormats: only support Xiph Vorbis (Ogg-framed) for input\n");
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
XCACodec::SetCurrentInputFormat(inInputFormat);
- } else {
- CODEC_THROW(kAudioCodecStateError);
- }
+ } else {
+ CODEC_THROW(kAudioCodecStateError);
+ }
}
UInt32 CAOggVorbisDecoder::ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
@@ -107,7 +107,7 @@
ioNumberPackets = 0;
ret = kAudioCodecProduceOutputPacketNeedsMoreInputData;
dbg_printf("<!E [%08lx] CAOggVorbisDecoder :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n", (UInt32) this,
- ioNumberPackets, ioOutputDataByteSize, ret, FramesReady());
+ ioNumberPackets, ioOutputDataByteSize, ret, FramesReady());
return ret;
}
@@ -127,7 +127,7 @@
ogg_packets++;
mFramesBufferedList.erase(mFramesBufferedList.begin());
}
-
+
vorbis_total_returned_data += vorbis_returned_data;
if (vorbis_total_returned_data == ioOutputDataByteSize || vorbis_return == kAudioCodecProduceOutputPacketSuccess)
@@ -155,7 +155,7 @@
}
dbg_printf("<.. [%08lx] CAOggVorbisDecoder :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n",
- (UInt32) this, ioNumberPackets, ioOutputDataByteSize, ret, FramesReady());
+ (UInt32) this, ioNumberPackets, ioOutputDataByteSize, ret, FramesReady());
return ret;
}
@@ -190,7 +190,7 @@
{
if (!mCompressionInitialized)
CODEC_THROW(kAudioCodecUnspecifiedError);
-
+
ogg_page op;
if (!WrapOggPage(&op, inInputData, inPacketDescription->mDataByteSize, inPacketDescription->mStartOffset))
@@ -208,7 +208,7 @@
page_packets--;
continue;
}
-
+
packet_count++;
vorbis_packet_desc.mDataByteSize = opk.bytes;
@@ -227,7 +227,7 @@
ogg_stream_clear(&mO_st);
OggSerialNoAtom *atom = reinterpret_cast<OggSerialNoAtom*> (mCookie);
-
+
if (EndianS32_BtoN(atom->type) == kCookieTypeOggSerialNo && EndianS32_BtoN(atom->size) <= mCookieSize) {
ogg_stream_init(&mO_st, EndianS32_BtoN(atom->serialno));
}
Modified: trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.h
===================================================================
--- trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CAVorbis/src/CAOggVorbisDecoder.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -42,26 +42,26 @@
class CAOggVorbisDecoder :
public CAVorbisDecoder
{
-public:
+ public:
CAOggVorbisDecoder();
virtual ~CAOggVorbisDecoder();
- virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
+ virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
AudioStreamPacketDescription* outPacketDescription);
- virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
+ virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
-protected:
- virtual void BDCInitialize(UInt32 inInputBufferByteSize);
- virtual void BDCUninitialize();
- virtual void BDCReset();
- virtual void BDCReallocate(UInt32 inInputBufferByteSize);
+ protected:
+ virtual void BDCInitialize(UInt32 inInputBufferByteSize);
+ virtual void BDCUninitialize();
+ virtual void BDCReset();
+ virtual void BDCReallocate(UInt32 inInputBufferByteSize);
- virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription);
-
- void InitializeCompressionSettings();
+ virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription);
- ogg_stream_state mO_st;
- std::vector<SInt32> mFramesBufferedList;
+ void InitializeCompressionSettings();
+
+ ogg_stream_state mO_st;
+ std::vector<SInt32> mFramesBufferedList;
};
Modified: trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.cpp
===================================================================
--- trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -44,9 +44,9 @@
#include "debug.h"
CAVorbisDecoder::CAVorbisDecoder(Boolean inSkipFormatsInitialization /* = false */) :
-mCookie(NULL), mCookieSize(0), mCompressionInitialized(false),
-mVorbisFPList(), mConsumedFPList(),
-mFullInPacketsZapped(0)
+ mCookie(NULL), mCookieSize(0), mCompressionInitialized(false),
+ mVorbisFPList(), mConsumedFPList(),
+ mFullInPacketsZapped(0)
{
if (inSkipFormatsInitialization)
return;
@@ -56,7 +56,7 @@
kVorbisBytesPerFrame, kVorbisChannelsPerFrame,
kVorbisBitsPerChannel, kVorbisFormatFlags);
AddInputFormat(theInputFormat);
-
+
mInputFormat.mSampleRate = 44100;
mInputFormat.mFormatID = kAudioFormatXiphVorbis;
mInputFormat.mFormatFlags = kVorbisFormatFlags;
@@ -65,7 +65,7 @@
mInputFormat.mBytesPerFrame = kVorbisBytesPerFrame;
mInputFormat.mChannelsPerFrame = 2;
mInputFormat.mBitsPerChannel = kVorbisBitsPerChannel;
-
+
CAStreamBasicDescription theOutputFormat1(kAudioStreamAnyRate, kAudioFormatLinearPCM, 0, 1, 0, 0, 16,
kAudioFormatFlagsNativeEndian |
kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked);
@@ -73,26 +73,26 @@
CAStreamBasicDescription theOutputFormat2(kAudioStreamAnyRate, kAudioFormatLinearPCM, 0, 1, 0, 0, 32,
kAudioFormatFlagsNativeFloatPacked);
AddOutputFormat(theOutputFormat2);
-
+
mOutputFormat.mSampleRate = 44100;
- mOutputFormat.mFormatID = kAudioFormatLinearPCM;
- mOutputFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
- mOutputFormat.mBytesPerPacket = 8;
- mOutputFormat.mFramesPerPacket = 1;
- mOutputFormat.mBytesPerFrame = 8;
- mOutputFormat.mChannelsPerFrame = 2;
- mOutputFormat.mBitsPerChannel = 32;
+ mOutputFormat.mFormatID = kAudioFormatLinearPCM;
+ mOutputFormat.mFormatFlags = kAudioFormatFlagsNativeFloatPacked;
+ mOutputFormat.mBytesPerPacket = 8;
+ mOutputFormat.mFramesPerPacket = 1;
+ mOutputFormat.mBytesPerFrame = 8;
+ mOutputFormat.mChannelsPerFrame = 2;
+ mOutputFormat.mBitsPerChannel = 32;
}
CAVorbisDecoder::~CAVorbisDecoder()
{
if (mCookie != NULL)
delete[] mCookie;
-
+
if (mCompressionInitialized) {
vorbis_block_clear(&mV_vb);
vorbis_dsp_clear(&mV_vd);
-
+
vorbis_info_clear(&mV_vi);
}
}
@@ -102,32 +102,32 @@
const void* inMagicCookie, UInt32 inMagicCookieByteSize)
{
dbg_printf(" >> [%08lx] :: Initialize(%d, %d, %d)\n", (UInt32) this, inInputFormat != NULL, inOutputFormat != NULL, inMagicCookieByteSize != 0);
-
+
if(inInputFormat != NULL) {
- SetCurrentInputFormat(*inInputFormat);
- }
-
- if(inOutputFormat != NULL) {
- SetCurrentOutputFormat(*inOutputFormat);
- }
-
- if ((mInputFormat.mSampleRate != mOutputFormat.mSampleRate) ||
- (mInputFormat.mChannelsPerFrame != mOutputFormat.mChannelsPerFrame)) {
- CODEC_THROW(kAudioCodecUnsupportedFormatError);
- }
-
+ SetCurrentInputFormat(*inInputFormat);
+ }
+
+ if(inOutputFormat != NULL) {
+ SetCurrentOutputFormat(*inOutputFormat);
+ }
+
+ if ((mInputFormat.mSampleRate != mOutputFormat.mSampleRate) ||
+ (mInputFormat.mChannelsPerFrame != mOutputFormat.mChannelsPerFrame)) {
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
+
BDCInitialize(kVorbisDecoderBufferSize);
//if (inMagicCookieByteSize == 0)
// CODEC_THROW(kAudioCodecUnsupportedFormatError);
-
+
if (inMagicCookieByteSize != 0) {
SetMagicCookie(inMagicCookie, inMagicCookieByteSize);
}
-
+
//if (mCompressionInitialized)
// FixFormats();
-
+
XCACodec::Initialize(inInputFormat, inOutputFormat, inMagicCookie, inMagicCookieByteSize);
dbg_printf("<.. [%08lx] :: Initialize(%d, %d, %d)\n", (UInt32) this, inInputFormat != NULL, inOutputFormat != NULL, inMagicCookieByteSize != 0);
}
@@ -142,86 +142,86 @@
}
void CAVorbisDecoder::GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData)
-{
+{
dbg_printf(" >> [%08lx] :: GetProperty('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
- switch(inPropertyID)
- {
- case kAudioCodecPropertyRequiresPacketDescription:
- if(ioPropertyDataSize == sizeof(UInt32))
- {
- *reinterpret_cast<UInt32*>(outPropertyData) = 1;
- }
- else
- {
- CODEC_THROW(kAudioCodecBadPropertySizeError);
- }
- break;
- case kAudioCodecPropertyHasVariablePacketByteSizes:
- if(ioPropertyDataSize == sizeof(UInt32))
- {
- *reinterpret_cast<UInt32*>(outPropertyData) = 1;
- }
- else
- {
- CODEC_THROW(kAudioCodecBadPropertySizeError);
- }
- break;
- case kAudioCodecPropertyPacketFrameSize:
- if(ioPropertyDataSize == sizeof(UInt32))
- {
- *reinterpret_cast<UInt32*>(outPropertyData) = kVorbisFramesPerPacket;
- }
- else
- {
- CODEC_THROW(kAudioCodecBadPropertySizeError);
- }
- break;
-
+ switch(inPropertyID)
+ {
+ case kAudioCodecPropertyRequiresPacketDescription:
+ if(ioPropertyDataSize == sizeof(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = 1;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+ case kAudioCodecPropertyHasVariablePacketByteSizes:
+ if(ioPropertyDataSize == sizeof(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = 1;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+ case kAudioCodecPropertyPacketFrameSize:
+ if(ioPropertyDataSize == sizeof(UInt32))
+ {
+ *reinterpret_cast<UInt32*>(outPropertyData) = kVorbisFramesPerPacket;
+ }
+ else
+ {
+ CODEC_THROW(kAudioCodecBadPropertySizeError);
+ }
+ break;
+
//case kAudioCodecPropertyQualitySetting: ???
#if TARGET_OS_MAC
- case kAudioCodecPropertyNameCFString:
- {
- if (ioPropertyDataSize != sizeof(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError);
-
- CABundleLocker lock;
- CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Xiph Vorbis decoder"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR(""));
- *(CFStringRef*)outPropertyData = name;
- break;
- }
+ case kAudioCodecPropertyNameCFString:
+ {
+ if (ioPropertyDataSize != sizeof(CFStringRef)) CODEC_THROW(kAudioCodecBadPropertySizeError);
+ CABundleLocker lock;
+ CFStringRef name = CFCopyLocalizedStringFromTableInBundle(CFSTR("Xiph Vorbis decoder"), CFSTR("CodecNames"), GetCodecBundle(), CFSTR(""));
+ *(CFStringRef*)outPropertyData = name;
+ break;
+ }
+
//case kAudioCodecPropertyManufacturerCFString:
#endif
- default:
- ACBaseCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
- }
+ default:
+ ACBaseCodec::GetProperty(inPropertyID, ioPropertyDataSize, outPropertyData);
+ }
dbg_printf("<.. [%08lx] :: GetProperty('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
}
void CAVorbisDecoder::GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, bool& outWritable)
{
dbg_printf(" >> [%08lx] :: GetPropertyInfo('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
- switch(inPropertyID)
- {
- case kAudioCodecPropertyRequiresPacketDescription:
- outPropertyDataSize = sizeof(UInt32);
- outWritable = false;
- break;
-
- case kAudioCodecPropertyHasVariablePacketByteSizes:
- outPropertyDataSize = sizeof(UInt32);
- outWritable = false;
- break;
-
- case kAudioCodecPropertyPacketFrameSize:
- outPropertyDataSize = sizeof(UInt32);
- outWritable = false;
- break;
-
- default:
- ACBaseCodec::GetPropertyInfo(inPropertyID, outPropertyDataSize, outWritable);
- break;
-
- }
+ switch(inPropertyID)
+ {
+ case kAudioCodecPropertyRequiresPacketDescription:
+ outPropertyDataSize = sizeof(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyHasVariablePacketByteSizes:
+ outPropertyDataSize = sizeof(UInt32);
+ outWritable = false;
+ break;
+
+ case kAudioCodecPropertyPacketFrameSize:
+ outPropertyDataSize = sizeof(UInt32);
+ outWritable = false;
+ break;
+
+ default:
+ ACBaseCodec::GetPropertyInfo(inPropertyID, outPropertyDataSize, outWritable);
+ break;
+
+ }
dbg_printf("<.. [%08lx] :: GetPropertyInfo('%4.4s')\n", (UInt32) this, reinterpret_cast<char*> (&inPropertyID));
}
@@ -230,51 +230,51 @@
dbg_printf(">> [%08lx] :: Reset()\n", (UInt32) this);
BDCReset();
- XCACodec::Reset();
+ XCACodec::Reset();
dbg_printf("<< [%08lx] :: Reset()\n", (UInt32) this);
}
UInt32 CAVorbisDecoder::GetVersion() const
{
- return kCAVorbis_adec_Version;
+ return kCAVorbis_adec_Version;
}
void CAVorbisDecoder::SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat)
{
- if (!mIsInitialized) {
- // check to make sure the input format is legal
- if (inInputFormat.mFormatID != kAudioFormatXiphVorbis) {
- dbg_printf("CAVorbisDecoder::SetFormats: only support Xiph Vorbis for input\n");
- CODEC_THROW(kAudioCodecUnsupportedFormatError);
- }
-
- // tell our base class about the new format
- XCACodec::SetCurrentInputFormat(inInputFormat);
- } else {
- CODEC_THROW(kAudioCodecStateError);
- }
+ if (!mIsInitialized) {
+ // check to make sure the input format is legal
+ if (inInputFormat.mFormatID != kAudioFormatXiphVorbis) {
+ dbg_printf("CAVorbisDecoder::SetFormats: only support Xiph Vorbis for input\n");
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
+
+ // tell our base class about the new format
+ XCACodec::SetCurrentInputFormat(inInputFormat);
+ } else {
+ CODEC_THROW(kAudioCodecStateError);
+ }
}
void CAVorbisDecoder::SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat)
{
- if (!mIsInitialized) {
- // check to make sure the output format is legal
- if ((inOutputFormat.mFormatID != kAudioFormatLinearPCM) ||
- !(((inOutputFormat.mFormatFlags == kAudioFormatFlagsNativeFloatPacked) &&
+ if (!mIsInitialized) {
+ // check to make sure the output format is legal
+ if ((inOutputFormat.mFormatID != kAudioFormatLinearPCM) ||
+ !(((inOutputFormat.mFormatFlags == kAudioFormatFlagsNativeFloatPacked) &&
(inOutputFormat.mBitsPerChannel == 32)) ||
- ((inOutputFormat.mFormatFlags == (kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked)) &&
- (inOutputFormat.mBitsPerChannel == 16))))
+ ((inOutputFormat.mFormatFlags == (kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked)) &&
+ (inOutputFormat.mBitsPerChannel == 16))))
{
- dbg_printf("CAVorbisDecoder::SetFormats: only supports either 16 bit native endian signed integer or 32 bit native endian Core Audio floats for output\n");
- CODEC_THROW(kAudioCodecUnsupportedFormatError);
- }
-
- // tell our base class about the new format
- XCACodec::SetCurrentOutputFormat(inOutputFormat);
- } else {
- CODEC_THROW(kAudioCodecStateError);
- }
+ dbg_printf("CAVorbisDecoder::SetFormats: only supports either 16 bit native endian signed integer or 32 bit native endian Core Audio floats for output\n");
+ CODEC_THROW(kAudioCodecUnsupportedFormatError);
+ }
+
+ // tell our base class about the new format
+ XCACodec::SetCurrentOutputFormat(inOutputFormat);
+ } else {
+ CODEC_THROW(kAudioCodecStateError);
+ }
}
UInt32 CAVorbisDecoder::GetMagicCookieByteSize() const
@@ -285,7 +285,7 @@
void CAVorbisDecoder::GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const
{
ioMagicCookieDataByteSize = mCookieSize;
-
+
if (mCookie != NULL)
outMagicCookieData = mCookie;
}
@@ -293,13 +293,13 @@
void CAVorbisDecoder::SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize)
{
dbg_printf(" >> [%08lx] :: SetMagicCookie()\n", (UInt32) this);
- if (mIsInitialized)
- CODEC_THROW(kAudioCodecStateError);
-
+ if (mIsInitialized)
+ CODEC_THROW(kAudioCodecStateError);
+
SetCookie(inMagicCookieData, inMagicCookieDataByteSize);
-
+
InitializeCompressionSettings();
-
+
if (!mCompressionInitialized)
CODEC_THROW(kAudioCodecUnsupportedFormatError);
dbg_printf("<.. [%08lx] :: SetMagicCookie()\n", (UInt32) this);
@@ -309,7 +309,7 @@
{
if (mCookie != NULL)
delete[] mCookie;
-
+
mCookieSize = inMagicCookieDataByteSize;
if (inMagicCookieDataByteSize != 0) {
mCookie = new Byte[inMagicCookieDataByteSize];
@@ -328,10 +328,10 @@
mInputFormat.mChannelsPerFrame = mV_vi.channels;
/*
- mInputFormat.mFramesPerPacket = 64;
- mInputFormat.mBytesPerPacket = mInputFormat.mChannelsPerFrame * 34;
- mInputFormat.mBytesPerFrame = 0;
- */
+ mInputFormat.mFramesPerPacket = 64;
+ mInputFormat.mBytesPerPacket = mInputFormat.mChannelsPerFrame * 34;
+ mInputFormat.mBytesPerFrame = 0;
+ */
}
#endif
@@ -344,10 +344,10 @@
if (mCompressionInitialized) {
vorbis_block_clear(&mV_vb);
vorbis_dsp_clear(&mV_vd);
-
- vorbis_info_clear(&mV_vi);
+
+ vorbis_info_clear(&mV_vi);
}
-
+
mCompressionInitialized = false;
OggSerialNoAtom *atom = reinterpret_cast<OggSerialNoAtom*> (mCookie);
@@ -389,11 +389,11 @@
if (vorbis_synthesis_headerin(&mV_vi, &vc, &op) < 0) {
//ogg_stream_clear(&mO_st);
-
+
vorbis_comment_clear(&vc);
vorbis_info_clear(&mV_vi);
-
- return;
+
+ return;
}
op.b_o_s = 0;
@@ -408,10 +408,10 @@
vorbis_synthesis_headerin(&mV_vi, &vc, &op);
i++;
}
-
+
vorbis_synthesis_init(&mV_vd, &mV_vi);
vorbis_block_init(&mV_vd, &mV_vb);
-
+
vorbis_comment_clear(&vc);
//ogg_stream_reset(&mO_st);
@@ -431,7 +431,7 @@
mVorbisFPList.clear();
mConsumedFPList.clear();
mFullInPacketsZapped = 0;
-
+
XCACodec::BDCUninitialize();
}
@@ -442,10 +442,10 @@
mFullInPacketsZapped = 0;
vorbis_synthesis_restart(&mV_vd);
-
+
//vorbis_block_clear(&globals->vb);
//vorbis_block_init(&globals->vd, &globals->vb);
-
+
XCACodec::BDCReset();
}
@@ -491,7 +491,7 @@
op.packetno = 0; // ??!
op.bytes = sfp.bytes; // FIXME??
op.packet = mBDCBuffer.GetData();
-
+
if ((vErr = vorbis_synthesis(&mV_vb, &op)) == 0)
vorbis_synthesis_blockin(&mV_vd, &mV_vb);
else {
@@ -533,12 +533,12 @@
float* mono = pcm[i];
for (UInt32 j = 0; j < inNumberFrames; j++) {
SInt32 val = static_cast<SInt32> (mono[j] * 32767.f);
-
+
if (val > 32767)
val = 32767;
if (val < -32768)
val = -32768;
-
+
*theOutputData = val;
theOutputData += mV_vi.channels;
}
@@ -569,4 +569,3 @@
{
return mFullInPacketsZapped;
}
-
Modified: trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.h
===================================================================
--- trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CAVorbis/src/CAVorbisDecoder.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -50,73 +50,73 @@
class CAVorbisDecoder:
public XCACodec
{
-public:
+ public:
CAVorbisDecoder(Boolean inSkipFormatsInitialization = false);
~CAVorbisDecoder();
- virtual void Initialize(const AudioStreamBasicDescription* inInputFormat, \
- const AudioStreamBasicDescription* inOutputFormat, \
+ virtual void Initialize(const AudioStreamBasicDescription* inInputFormat,
+ const AudioStreamBasicDescription* inOutputFormat,
const void* inMagicCookie, UInt32 inMagicCookieByteSize);
virtual void Uninitialize();
virtual void Reset();
-
+
virtual void GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData);
virtual void GetPropertyInfo(AudioCodecPropertyID inPropertyID, UInt32& outPropertyDataSize, bool& outWritable);
-
- virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
- virtual void SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat);
- virtual UInt32 GetVersion() const;
- virtual UInt32 GetMagicCookieByteSize() const;
- virtual void GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const;
- virtual void SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize);
+ virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat);
+ virtual void SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat);
+ virtual UInt32 GetVersion() const;
-protected:
- virtual void BDCInitialize(UInt32 inInputBufferByteSize);
- virtual void BDCUninitialize();
- virtual void BDCReset();
- virtual void BDCReallocate(UInt32 inInputBufferByteSize);
-
- virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription);
-
- virtual UInt32 FramesReady() const;
- virtual Boolean GenerateFrames();
- virtual void OutputFrames(void* outOutputData, UInt32 inNumberFrames, UInt32 inFramesOffset) const;
- virtual void Zap(UInt32 inFrames);
-
- virtual UInt32 InPacketsConsumed() const;
+ virtual UInt32 GetMagicCookieByteSize() const;
+ virtual void GetMagicCookie(void* outMagicCookieData, UInt32& ioMagicCookieDataByteSize) const;
+ virtual void SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize);
- void SetCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize);
- virtual void InitializeCompressionSettings();
-
+ protected:
+ virtual void BDCInitialize(UInt32 inInputBufferByteSize);
+ virtual void BDCUninitialize();
+ virtual void BDCReset();
+ virtual void BDCReallocate(UInt32 inInputBufferByteSize);
+
+ virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription);
+
+ virtual UInt32 FramesReady() const;
+ virtual Boolean GenerateFrames();
+ virtual void OutputFrames(void* outOutputData, UInt32 inNumberFrames, UInt32 inFramesOffset) const;
+ virtual void Zap(UInt32 inFrames);
+
+ virtual UInt32 InPacketsConsumed() const;
+
+ void SetCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize);
+ virtual void InitializeCompressionSettings();
+
//virtual void FixFormats();
-
-protected:
- Byte* mCookie;
- UInt32 mCookieSize;
- Boolean mCompressionInitialized;
+ protected:
+ Byte* mCookie;
+ UInt32 mCookieSize;
- vorbis_info mV_vi;
- vorbis_dsp_state mV_vd;
- vorbis_block mV_vb;
+ Boolean mCompressionInitialized;
+ vorbis_info mV_vi;
+ vorbis_dsp_state mV_vd;
+ vorbis_block mV_vb;
+
struct VorbisFramePacket {
UInt32 frames;
- UInt32 bytes;
- UInt32 left;
-
+ UInt32 bytes;
+ UInt32 left;
+
VorbisFramePacket() : frames(0), bytes(0), left(0) {};
VorbisFramePacket(UInt32 inFrames, UInt32 inBytes) : frames(inFrames), bytes(inBytes), left(inBytes) {};
};
-
+
typedef std::vector<VorbisFramePacket> VorbisFramePacketList;
- VorbisFramePacketList mVorbisFPList;
- VorbisFramePacketList mConsumedFPList;
+ VorbisFramePacketList mVorbisFPList;
+ VorbisFramePacketList mConsumedFPList;
- UInt32 mFullInPacketsZapped;
-
+ UInt32 mFullInPacketsZapped;
+
enum {
kVorbisBytesPerPacket = 0,
kVorbisFramesPerPacket = _SHOULD_BE_ZERO_HERE,
Modified: trunk/xiph-qt/CAVorbis/src/vorbis_entrypoints.cpp
===================================================================
--- trunk/xiph-qt/CAVorbis/src/vorbis_entrypoints.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/CAVorbis/src/vorbis_entrypoints.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -35,13 +35,12 @@
extern "C"
ComponentResult CAVorbisDecoderEntry(ComponentParameters* inParameters, CAVorbisDecoder* inThis)
-{
- return ACCodecDispatch(inParameters, inThis);
+{
+ return ACCodecDispatch(inParameters, inThis);
}
extern "C"
ComponentResult CAOggVorbisDecoderEntry(ComponentParameters* inParameters, CAOggVorbisDecoder* inThis)
-{
- return ACCodecDispatch(inParameters, inThis);
+{
+ return ACCodecDispatch(inParameters, inThis);
}
-
Modified: trunk/xiph-qt/OggImport/src/OggImport.c
===================================================================
--- trunk/xiph-qt/OggImport/src/OggImport.c 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/OggImport.c 2005-12-10 19:33:16 UTC (rev 10575)
@@ -72,7 +72,7 @@
#if defined(_HAVE__SPEEX_SUPPORT)
HANDLE_FUNCTIONS__SPEEX,
#endif
-
+
HANDLE_FUNCTIONS__NULL
};
@@ -84,9 +84,9 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
enum {
- kDataBufferSize = 64 * 1024,
- kDataAsyncBufferSize = 16 * 1024,
-
+ kDataBufferSize = 64 * 1024,
+ kDataAsyncBufferSize = 16 * 1024,
+
kDefaultChunkSize = 11000
};
@@ -97,7 +97,7 @@
/* sometimes I wonder if using ComponentDispatch.h is worth it. This is
one of those times. MacOS functions are declared pascal, win32 are not.
- */
+*/
#if TARGET_OS_MAC
#define COMPONENTFUNC static pascal ComponentResult
#else
@@ -109,34 +109,34 @@
COMPONENTFUNC OggImportVersion(OggImportGlobalsPtr globals);
COMPONENTFUNC OggImportSetOffsetAndLimit64(OggImportGlobalsPtr globals, const wide *offset,
- const wide *limit);
+ const wide *limit);
COMPONENTFUNC OggImportSetOffsetAndLimit(OggImportGlobalsPtr globals, unsigned long offset,
- unsigned long limit);
+ unsigned long limit);
-COMPONENTFUNC OggImportValidate(OggImportGlobalsPtr globals,
- const FSSpec * theFile,
- Handle theData,
- Boolean * valid);
-COMPONENTFUNC OggImportValidateDataRef(OggImportGlobalsPtr globals,
- Handle dataRef,
- OSType dataRefType,
- UInt8 * valid);
+COMPONENTFUNC OggImportValidate(OggImportGlobalsPtr globals,
+ const FSSpec * theFile,
+ Handle theData,
+ Boolean * valid);
+COMPONENTFUNC OggImportValidateDataRef(OggImportGlobalsPtr globals,
+ Handle dataRef,
+ OSType dataRefType,
+ UInt8 * valid);
COMPONENTFUNC OggImportSetChunkSize(OggImportGlobalsPtr globals, long chunkSize);
COMPONENTFUNC OggImportIdle(OggImportGlobalsPtr globals,
- long inFlags,
- long * outFlags);
+ long inFlags,
+ long * outFlags);
COMPONENTFUNC OggImportFile(OggImportGlobalsPtr globals, const FSSpec *theFile,
- Movie theMovie, Track targetTrack, Track *usedTrack,
- TimeValue atTime, TimeValue *durationAdded, long inFlags, long *outFlags);
+ Movie theMovie, Track targetTrack, Track *usedTrack,
+ TimeValue atTime, TimeValue *durationAdded, long inFlags, long *outFlags);
COMPONENTFUNC OggImportGetMIMETypeList(OggImportGlobalsPtr globals, QTAtomContainer *retMimeInfo);
COMPONENTFUNC OggImportDataRef(OggImportGlobalsPtr globals, Handle dataRef,
- OSType dataRefType, Movie theMovie,
- Track targetTrack, Track *usedTrack,
- TimeValue atTime, TimeValue *durationAdded,
- long inFlags, long *outFlags);
+ OSType dataRefType, Movie theMovie,
+ Track targetTrack, Track *usedTrack,
+ TimeValue atTime, TimeValue *durationAdded,
+ long inFlags, long *outFlags);
COMPONENTFUNC OggImportGetFileType(OggImportGlobalsPtr globals, OSType *fileType);
COMPONENTFUNC OggImportGetLoadState(OggImportGlobalsPtr globals, long *loadState);
COMPONENTFUNC OggImportGetMaxLoadedTime(OggImportGlobalsPtr globals, TimeValue *time);
@@ -150,14 +150,14 @@
// Component Dispatcher
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#define CALLCOMPONENT_BASENAME() OggImport
-#define CALLCOMPONENT_GLOBALS() OggImportGlobalsPtr storage
+#define CALLCOMPONENT_BASENAME() OggImport
+#define CALLCOMPONENT_GLOBALS() OggImportGlobalsPtr storage
-#define MOVIEIMPORT_BASENAME() CALLCOMPONENT_BASENAME()
-#define MOVIEIMPORT_GLOBALS() CALLCOMPONENT_GLOBALS()
+#define MOVIEIMPORT_BASENAME() CALLCOMPONENT_BASENAME()
+#define MOVIEIMPORT_GLOBALS() CALLCOMPONENT_GLOBALS()
-#define COMPONENT_UPP_SELECT_ROOT() MovieImport
-#define COMPONENT_DISPATCH_FILE "OggImportDispatch.h"
+#define COMPONENT_UPP_SELECT_ROOT() MovieImport
+#define COMPONENT_DISPATCH_FILE "OggImportDispatch.h"
#if !TARGET_OS_WIN32
#include <CoreServices/Components.k.h>
@@ -172,113 +172,113 @@
#if TARGET_OS_WIN32
EXTERN_API_C(SInt32 ) S64Compare(SInt64 left, SInt64 right)
{
- if (left < right)
- return -1;
- if (left == right)
- return 0;
- return 1;
+ if (left < right)
+ return -1;
+ if (left == right)
+ return 0;
+ return 1;
}
#endif
static ComponentResult DoRead(OggImportGlobalsPtr globals, Ptr buffer, SInt64 offset, long size)
{
- ComponentResult err;
+ ComponentResult err;
const wide wideOffset = SInt64ToWide(offset);
-
- dbg_printf("---- DoRead() called\n");
-
- dbg_printf("--->> READING: %lld [%ld] --> %lld\n", offset, size, offset + size);
- dbg_printf("----> READING: usingIdle: %d, dataCanDoAsyncRead: %d, canDoGetFileSizeAsync: %d, canDoGetFileSize64: %d\n",
- globals->usingIdle, globals->dataCanDoAsyncRead, globals->dataCanDoGetFileSizeAsync, globals->dataCanDoGetFileSize64);
+ dbg_printf("---- DoRead() called\n");
+
+ dbg_printf("--->> READING: %lld [%ld] --> %lld\n", offset, size, offset + size);
+ dbg_printf("----> READING: usingIdle: %d, dataCanDoAsyncRead: %d, canDoGetFileSizeAsync: %d, canDoGetFileSize64: %d\n",
+ globals->usingIdle, globals->dataCanDoAsyncRead, globals->dataCanDoGetFileSizeAsync, globals->dataCanDoGetFileSize64);
+
if (globals->usingIdle && globals->dataCanDoAsyncRead)
{
- globals->dataRequested = true;
- err = DataHReadAsync(globals->dataReader, buffer, size, &wideOffset,
- globals->dataReadCompletion, (long) globals);
- dbg_printf("----: READ: %ld\n", err);
- err = QTIdleManagerSetNextIdleTimeNever(globals->idleManager);
- dbg_printf("----: Disabling Idles: %ld\n", err);
+ globals->dataRequested = true;
+ err = DataHReadAsync(globals->dataReader, buffer, size, &wideOffset,
+ globals->dataReadCompletion, (long) globals);
+ dbg_printf("----: READ: %ld\n", err);
+ err = QTIdleManagerSetNextIdleTimeNever(globals->idleManager);
+ dbg_printf("----: Disabling Idles: %ld\n", err);
}
else
{
- err = DataHScheduleData64(globals->dataReader, buffer, &wideOffset,
- size, 0, NULL, NULL);
- if (err == noErr)
- rb_sync_reserved(&globals->dataRB);
+ err = DataHScheduleData64(globals->dataReader, buffer, &wideOffset,
+ size, 0, NULL, NULL);
+ if (err == noErr)
+ rb_sync_reserved(&globals->dataRB);
}
globals->readError = err;
-
+
return err;
}
static ComponentResult FillBuffer(OggImportGlobalsPtr globals)
{
- int dataLeft;
+ int dataLeft;
SInt64 readDataOffset;
- dbg_printf("---- FillBuffer() called\n");
- dbg_printf(" - dataOffset: %lld, dataEndOffset: %lld\n", globals->dataOffset, globals->dataEndOffset);
- dbg_printf(" - dataOffset != -1: %d, dataOffset >= dataEndOffset: %d\n",
- S64Compare(globals->dataOffset, S64Set(-1)) != 0,
- S64Compare(globals->dataOffset, globals->dataEndOffset) >= 0);
+ dbg_printf("---- FillBuffer() called\n");
+ dbg_printf(" - dataOffset: %lld, dataEndOffset: %lld\n", globals->dataOffset, globals->dataEndOffset);
+ dbg_printf(" - dataOffset != -1: %d, dataOffset >= dataEndOffset: %d\n",
+ S64Compare(globals->dataOffset, S64Set(-1)) != 0,
+ S64Compare(globals->dataOffset, globals->dataEndOffset) >= 0);
/* have we hit the end of file or our upper limit? */
- if (globals->sizeInitialised && S64Compare(globals->dataEndOffset, S64Set(-1)) != 0) {
- if (S64Compare(globals->dataOffset, S64Set(-1)) != 0 &&
- S64Compare(globals->dataOffset, globals->dataEndOffset) >= 0)
- return eofErr;
- }
-
- dbg_printf("--1- FillBuffer() called\n");
+ if (globals->sizeInitialised && S64Compare(globals->dataEndOffset, S64Set(-1)) != 0) {
+ if (S64Compare(globals->dataOffset, S64Set(-1)) != 0 &&
+ S64Compare(globals->dataOffset, globals->dataEndOffset) >= 0)
+ return eofErr;
+ }
+
+ dbg_printf("--1- FillBuffer() called\n");
/* can another page from the disk fit in the buffer? */
if (globals->dataReadChunkSize > rb_space_available(&globals->dataRB))
return -50; ///@@@ page won't fit in buffer, they always should
- dbg_printf("--2- FillBuffer() called\n");
+ dbg_printf("--2- FillBuffer() called\n");
readDataOffset = S64Add(globals->dataOffset, S64Set(rb_data_available(&globals->dataRB)));
-
+
/* figure out how much data is left, and read either a chunk or what's left */
- if (globals->sizeInitialised && S64Compare(globals->dataEndOffset, S64Set(-1)) != 0) {
- dataLeft = S32Set(S64Subtract(globals->dataEndOffset, readDataOffset));
- } else {
+ if (globals->sizeInitialised && S64Compare(globals->dataEndOffset, S64Set(-1)) != 0) {
+ dataLeft = S32Set(S64Subtract(globals->dataEndOffset, readDataOffset));
+ } else {
dataLeft = globals->dataReadChunkSize;
- }
+ }
if (dataLeft > globals->dataReadChunkSize)
dataLeft = globals->dataReadChunkSize;
-
+
if (dataLeft == 0)
- return eofErr;
+ return eofErr;
return DoRead(globals, (Ptr) rb_reserve(&globals->dataRB, dataLeft), readDataOffset, dataLeft);
}
static OSErr CheckVorbisHeader(ogg_page *opg)
{
- OSErr err = noErr;
+ OSErr err = noErr;
- ogg_stream_state os;
- ogg_packet op;
+ ogg_stream_state os;
+ ogg_packet op;
- vorbis_info vi;
- vorbis_comment vc;
+ vorbis_info vi;
+ vorbis_comment vc;
- ogg_stream_init(&os, ogg_page_serialno(opg));
+ ogg_stream_init(&os, ogg_page_serialno(opg));
vorbis_info_init(&vi);
vorbis_comment_init(&vc);
- if (ogg_stream_pagein(&os, opg) < 0)
- err = invalidMedia;
- else if (ogg_stream_packetout(&os, &op) != 1)
- err = invalidMedia;
- else if (vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
- err = noSoundTrackInMovieErr;
-
- ogg_stream_clear(&os);
+ if (ogg_stream_pagein(&os, opg) < 0)
+ err = invalidMedia;
+ else if (ogg_stream_packetout(&os, &op) != 1)
+ err = invalidMedia;
+ else if (vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
+ err = noSoundTrackInMovieErr;
+ ogg_stream_clear(&os);
+
vorbis_comment_clear(&vc);
vorbis_info_clear(&vi);
@@ -289,41 +289,41 @@
static ComponentResult OpenStream(OggImportGlobalsPtr globals, long serialno, ogg_page *opg, stream_format_handle_funcs *ff)
{
ComponentResult err;
-
- if (globals->streamInfoHandle)
- {
- globals->streamCount++;
- SetHandleSize((Handle)globals->streamInfoHandle, sizeof(StreamInfo) * globals->streamCount);
- }
- else
- {
- globals->streamInfoHandle = (StreamInfo **)NewHandle(sizeof(StreamInfo));
- globals->streamCount = 1;
- }
- err = MemError();
-
- if (err == noErr)
- {
- StreamInfo *si = &(*globals->streamInfoHandle)[globals->streamCount - 1];
- si->serialno = serialno;
- si->timeLoaded = 0;
- ogg_stream_init(&si->os,serialno);
+ if (globals->streamInfoHandle)
+ {
+ globals->streamCount++;
+ SetHandleSize((Handle)globals->streamInfoHandle, sizeof(StreamInfo) * globals->streamCount);
+ }
+ else
+ {
+ globals->streamInfoHandle = (StreamInfo **)NewHandle(sizeof(StreamInfo));
+ globals->streamCount = 1;
+ }
+ err = MemError();
+ if (err == noErr)
+ {
+ StreamInfo *si = &(*globals->streamInfoHandle)[globals->streamCount - 1];
+ si->serialno = serialno;
+ si->timeLoaded = 0;
+
+ ogg_stream_init(&si->os,serialno);
+
si->sfhf = ff;
if (ff->initialize != NULL)
(*ff->initialize)(si); // check for error here and clean-up if not OK
-
- si->startTime = globals->startTime;
- si->soundDescExtension = NewHandle(0);
-
- si->MDmapping = NULL;
- si->UDmapping = NULL;
- globals->numTracksStarted++;
- }
-
+ si->startTime = globals->startTime;
+ si->soundDescExtension = NewHandle(0);
+
+ si->MDmapping = NULL;
+ si->UDmapping = NULL;
+
+ globals->numTracksStarted++;
+ }
+
return err;
}
@@ -331,7 +331,7 @@
static StreamInfoPtr FindStream(OggImportGlobalsPtr globals, long serialno)
{
int i;
-
+
for (i = 0; i < globals->streamCount; i++)
{
if ((*globals->streamInfoHandle)[i].serialno == serialno)
@@ -339,40 +339,40 @@
return &(*globals->streamInfoHandle)[i];
}
}
-
+
return NULL;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static void CloseStream(OggImportGlobalsPtr globals, StreamInfoPtr si)
{
- ogg_stream_clear(&si->os);
+ ogg_stream_clear(&si->os);
if (si->sfhf->clear != NULL)
(*si->sfhf->clear)(si);
- if (si->MDmapping != NULL)
- CFRelease(si->MDmapping);
- if (si->UDmapping != NULL)
- CFRelease(si->UDmapping);
-
- DisposeHandle(si->soundDescExtension);
- DisposeHandle((Handle)si->sampleDesc);
-
+ if (si->MDmapping != NULL)
+ CFRelease(si->MDmapping);
+ if (si->UDmapping != NULL)
+ CFRelease(si->UDmapping);
+
+ DisposeHandle(si->soundDescExtension);
+ DisposeHandle((Handle)si->sampleDesc);
+
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static void CloseAllStreams(OggImportGlobalsPtr globals)
{
int i;
-
+
for (i = 0; i < globals->streamCount; i++)
{
- StreamInfoPtr si = &(*globals->streamInfoHandle)[i];
- CloseStream(globals, si);
+ StreamInfoPtr si = &(*globals->streamInfoHandle)[i];
+ CloseStream(globals, si);
}
- globals->streamCount = 0;
- SetHandleSize((Handle) globals->streamInfoHandle, 0);
+ globals->streamCount = 0;
+ SetHandleSize((Handle) globals->streamInfoHandle, 0);
}
@@ -454,36 +454,36 @@
return -1;
}
- len = strcspn(str, "=");
+ len = strcspn(str, "=");
- if (len > 0) {
- CFStringRef tmpkstr = CFStringCreateWithBytes(NULL, str, len + 1, kCFStringEncodingUTF8, true);
- if (tmpkstr != NULL) {
- CFMutableStringRef keystr = CFStringCreateMutableCopy(NULL, len + 1, tmpkstr);
- if (keystr != NULL) {
- //CFLocaleRef loc = CFLocaleCopyCurrent();
- CFLocaleRef loc = NULL;
- CFStringUppercase(keystr, loc);
- //CFRelease(loc);
- dbg_printf("--- luTud: %s [%s]\n", (char *)str, (char *)CFStringGetCStringPtr(keystr,kCFStringEncodingUTF8));
- if (CFDictionaryContainsKey(si->UDmapping, keystr)) {
- CFStringRef udkey = (CFStringRef) CFDictionaryGetValue(si->UDmapping, keystr);
+ if (len > 0) {
+ CFStringRef tmpkstr = CFStringCreateWithBytes(NULL, str, len + 1, kCFStringEncodingUTF8, true);
+ if (tmpkstr != NULL) {
+ CFMutableStringRef keystr = CFStringCreateMutableCopy(NULL, len + 1, tmpkstr);
+ if (keystr != NULL) {
+ //CFLocaleRef loc = CFLocaleCopyCurrent();
+ CFLocaleRef loc = NULL;
+ CFStringUppercase(keystr, loc);
+ //CFRelease(loc);
+ dbg_printf("--- luTud: %s [%s]\n", (char *)str, (char *)CFStringGetCStringPtr(keystr,kCFStringEncodingUTF8));
+ if (CFDictionaryContainsKey(si->UDmapping, keystr)) {
+ CFStringRef udkey = (CFStringRef) CFDictionaryGetValue(si->UDmapping, keystr);
- *osType = (CFStringGetCharacterAtIndex(udkey, 0) & 0xff) << 24 |
- (CFStringGetCharacterAtIndex(udkey, 1) & 0xff) << 16 |
- (CFStringGetCharacterAtIndex(udkey, 2) & 0xff) << 8 |
- (CFStringGetCharacterAtIndex(udkey, 3) & 0xff);
+ *osType = (CFStringGetCharacterAtIndex(udkey, 0) & 0xff) << 24 |
+ (CFStringGetCharacterAtIndex(udkey, 1) & 0xff) << 16 |
+ (CFStringGetCharacterAtIndex(udkey, 2) & 0xff) << 8 |
+ (CFStringGetCharacterAtIndex(udkey, 3) & 0xff);
- dbg_printf("--- luTud: %s [%s]\n", (char *)str, (char *)keystr);
- ret = len + 1;
- }
- CFRelease(keystr);
- }
- CFRelease(tmpkstr);
- }
- }
+ dbg_printf("--- luTud: %s [%s]\n", (char *)str, (char *)keystr);
+ ret = len + 1;
+ }
+ CFRelease(keystr);
+ }
+ CFRelease(tmpkstr);
+ }
+ }
- return ret;
+ return ret;
}
static int LookupTagMD(OggImportGlobalsPtr globals, StreamInfoPtr si, const char *str, long *osType) {
@@ -496,36 +496,36 @@
return -1;
}
- len = strcspn(str, "=");
+ len = strcspn(str, "=");
- if (len > 0) {
- CFStringRef tmpkstr = CFStringCreateWithBytes(NULL, str, len + 1, kCFStringEncodingUTF8, true);
- if (tmpkstr != NULL) {
- CFMutableStringRef keystr = CFStringCreateMutableCopy(NULL, len + 1, tmpkstr);
- if (keystr != NULL) {
- //CFLocaleRef loc = CFLocaleCopyCurrent();
- CFLocaleRef loc = NULL;
- CFStringUppercase(keystr, loc);
- //CFRelease(loc);
- dbg_printf("--- luTmd: %s [%s]\n", (char *)str, (char *)CFStringGetCStringPtr(keystr,kCFStringEncodingUTF8));
- if (CFDictionaryContainsKey(si->MDmapping, keystr)) {
- CFStringRef mdkey = (CFStringRef) CFDictionaryGetValue(si->MDmapping, keystr);
+ if (len > 0) {
+ CFStringRef tmpkstr = CFStringCreateWithBytes(NULL, str, len + 1, kCFStringEncodingUTF8, true);
+ if (tmpkstr != NULL) {
+ CFMutableStringRef keystr = CFStringCreateMutableCopy(NULL, len + 1, tmpkstr);
+ if (keystr != NULL) {
+ //CFLocaleRef loc = CFLocaleCopyCurrent();
+ CFLocaleRef loc = NULL;
+ CFStringUppercase(keystr, loc);
+ //CFRelease(loc);
+ dbg_printf("--- luTmd: %s [%s]\n", (char *)str, (char *)CFStringGetCStringPtr(keystr,kCFStringEncodingUTF8));
+ if (CFDictionaryContainsKey(si->MDmapping, keystr)) {
+ CFStringRef mdkey = (CFStringRef) CFDictionaryGetValue(si->MDmapping, keystr);
- *osType = (CFStringGetCharacterAtIndex(mdkey, 0) & 0xff) << 24 |
- (CFStringGetCharacterAtIndex(mdkey, 1) & 0xff) << 16 |
- (CFStringGetCharacterAtIndex(mdkey, 2) & 0xff) << 8 |
- (CFStringGetCharacterAtIndex(mdkey, 3) & 0xff);
+ *osType = (CFStringGetCharacterAtIndex(mdkey, 0) & 0xff) << 24 |
+ (CFStringGetCharacterAtIndex(mdkey, 1) & 0xff) << 16 |
+ (CFStringGetCharacterAtIndex(mdkey, 2) & 0xff) << 8 |
+ (CFStringGetCharacterAtIndex(mdkey, 3) & 0xff);
- dbg_printf("--- luTmd: %s [%s]\n", (char *)str, (char *)keystr);
- ret = len + 1;
- }
- CFRelease(keystr);
- }
- CFRelease(tmpkstr);
- }
- }
+ dbg_printf("--- luTmd: %s [%s]\n", (char *)str, (char *)keystr);
+ ret = len + 1;
+ }
+ CFRelease(keystr);
+ }
+ CFRelease(tmpkstr);
+ }
+ }
- return ret;
+ return ret;
}
static ComponentResult ConvertUTF8toScriptCode(const char *str, Handle *h)
@@ -614,43 +614,43 @@
ComponentResult DecodeCommentsQT(OggImportGlobalsPtr globals, StreamInfoPtr si, vorbis_comment *vc)
{
ComponentResult ret = noErr;
- int i;
- QTMetaDataRef md;
-
- //ret = QTCopyTrackMetaData(si->theTrack, &md);
- ret = QTCopyMovieMetaData(globals->theMovie, &md);
+ int i;
+ QTMetaDataRef md;
- if (ret != noErr)
- return ret;
-
+ //ret = QTCopyTrackMetaData(si->theTrack, &md);
+ ret = QTCopyMovieMetaData(globals->theMovie, &md);
+
+ if (ret != noErr)
+ return ret;
+
for (i = 0; i < vc->comments; i++)
{
ret = AddCommentToMetaData(globals, si, vc->user_comments[i], vc->comment_lengths[i], md);
if (ret != noErr) {
//break;
- dbg_printf("AddCommentToMetaData() failed? = %d\n", ret);
- }
+ dbg_printf("AddCommentToMetaData() failed? = %d\n", ret);
+ }
}
-
- QTMetaDataRelease(md);
- ret = QTCopyTrackMetaData(si->theTrack, &md);
- //ret = QTCopyMovieMetaData(globals->theMovie, &md);
+ QTMetaDataRelease(md);
- if (ret != noErr)
- return ret;
-
+ ret = QTCopyTrackMetaData(si->theTrack, &md);
+ //ret = QTCopyMovieMetaData(globals->theMovie, &md);
+
+ if (ret != noErr)
+ return ret;
+
for (i = 0; i < vc->comments; i++)
{
ret = AddCommentToMetaData(globals, si, vc->user_comments[i], vc->comment_lengths[i], md);
if (ret != noErr) {
//break;
- dbg_printf("AddCommentToMetaData() failed? = %d\n", ret);
- }
+ dbg_printf("AddCommentToMetaData() failed? = %d\n", ret);
+ }
}
-
- QTMetaDataRelease(md);
+ QTMetaDataRelease(md);
+
return ret;
}
@@ -661,7 +661,7 @@
err = (*si->sfhf->sample_description)(si);
else
err = invalidMedia; // ??!
-
+
return err;
}
@@ -682,12 +682,12 @@
dbg_printf("! -- MovieTrack created OK\n");
dbg_printf("! -- calling => NewTrackMedia(%lx)\n", si->rate);
si->theMedia = NewTrackMedia(si->theTrack, SoundMediaType,
- si->rate, globals->dataRef, globals->dataRefType);
+ si->rate, globals->dataRef, globals->dataRefType);
if (si->theMedia)
{
dbg_printf("! -- TrackMedia created OK\n");
SetTrackEnabled(si->theTrack, true);
-
+
si->lastGranulePos = 0;
}
else
@@ -699,7 +699,7 @@
err = GetMoviesError();
}
}
-
+
return err;
}
@@ -714,20 +714,20 @@
{
QTAtom anAction;
OSType whichAction = EndianU32_NtoB (kActionMovieChanged);
-
+
err = QTInsertChild (container, kParentAtomIsContainer, kAction, 1, 0, 0, NULL, &anAction);
- if (err == noErr)
+ if (err == noErr)
err = QTInsertChild (container, anAction, kWhichAction, 1, 0, sizeof (whichAction), &whichAction, NULL);
- if (err == noErr)
+ if (err == noErr)
err = MovieExecuteWiredActions (globals->theMovie, 0, container);
-
+
err = QTDisposeAtomContainer (container);
}
return err;
}
static ComponentResult ProcessStreamPage(OggImportGlobalsPtr globals, StreamInfoPtr si, ogg_page *opg) {
- ComponentResult ret = noErr;
+ ComponentResult ret = noErr;
if (si->sfhf->process_page != NULL)
ret = (*si->sfhf->process_page)(globals, si, opg);
@@ -739,7 +739,7 @@
; // do nothing, just loop
}
- return ret;
+ return ret;
}
static stream_format_handle_funcs* find_stream_support(ogg_page *op) {
@@ -761,49 +761,49 @@
}
static ComponentResult ProcessPage(OggImportGlobalsPtr globals, ogg_page *op) {
- ComponentResult ret = noErr;
- long serialno;
- StreamInfoPtr si;
+ ComponentResult ret = noErr;
+ long serialno;
+ StreamInfoPtr si;
- serialno = ogg_page_serialno(op);
+ serialno = ogg_page_serialno(op);
- dbg_printf(" - = page found, nr: %08lx\n", ogg_page_pageno(op));
- if (ogg_page_bos(op)) {
- stream_format_handle_funcs *ff = NULL;
- dbg_printf(" - = new stream found: %lx\n" , serialno);
- ff = find_stream_support(op);
- if (ff != NULL) {
- dbg_printf(" - == And a supported one!\n");
- ret = OpenStream(globals, serialno, op, ff);
-
- if (ret == noErr) {
- ogg_packet opckt;
- StreamInfoPtr si = FindStream(globals, serialno);
+ dbg_printf(" - = page found, nr: %08lx\n", ogg_page_pageno(op));
+ if (ogg_page_bos(op)) {
+ stream_format_handle_funcs *ff = NULL;
+ dbg_printf(" - = new stream found: %lx\n" , serialno);
+ ff = find_stream_support(op);
+ if (ff != NULL) {
+ dbg_printf(" - == And a supported one!\n");
+ ret = OpenStream(globals, serialno, op, ff);
- if (si != NULL) {
- ogg_stream_pagein(&si->os, op); //check errors?
- ogg_stream_packetout(&si->os, &opckt); //check errors?
+ if (ret == noErr) {
+ ogg_packet opckt;
+ StreamInfoPtr si = FindStream(globals, serialno);
+ if (si != NULL) {
+ ogg_stream_pagein(&si->os, op); //check errors?
+ ogg_stream_packetout(&si->os, &opckt); //check errors?
+
if (si->sfhf->first_packet != NULL)
(*si->sfhf->first_packet)(si, op, &opckt); //check errors?
}
- }
- }
- } else {
- si = FindStream(globals, serialno);
-
- if (si != NULL) {
- ret = ProcessStreamPage(globals, si, op);
- }
- }
+ }
+ }
+ } else {
+ si = FindStream(globals, serialno);
- globals->dataOffset = S64Add(globals->dataOffset, S64Set(globals->currentData - globals->dataRB.b_start));
- rb_zap(&globals->dataRB, globals->currentData - globals->dataRB.b_start);
+ if (si != NULL) {
+ ret = ProcessStreamPage(globals, si, op);
+ }
+ }
- globals->currentData = rb_data(&globals->dataRB);
- globals->validDataEnd = globals->currentData + rb_data_available(&globals->dataRB);
+ globals->dataOffset = S64Add(globals->dataOffset, S64Set(globals->currentData - globals->dataRB.b_start));
+ rb_zap(&globals->dataRB, globals->currentData - globals->dataRB.b_start);
- return ret;
+ globals->currentData = rb_data(&globals->dataRB);
+ globals->validDataEnd = globals->currentData + rb_data_available(&globals->dataRB);
+
+ return ret;
}
static ComponentResult XQTGetFileSize(OggImportGlobalsPtr globals);
@@ -811,125 +811,125 @@
static ComponentResult StateProcess(OggImportGlobalsPtr globals) {
ComponentResult result = noErr;
ogg_page og;
- Boolean process = true;
+ Boolean process = true;
- dbg_printf("-----= StateProcess() called\n");
- while (process) {
- switch (globals->state) {
- case kStateInitial:
- dbg_printf(" - (:kStateInitial:)\n");
- globals->dataOffset = globals->dataStartOffset;
- globals->numTracksSeen = 0;
- globals->timeLoaded = 0;
- globals->dataRequested = false;
- globals->startTickCount = TickCount();
-
- if (S64Compare(globals->dataEndOffset, S64Set(-1)) == 0) {
- globals->sizeInitialised = false;
- globals->state = kStateGettingSize;
- result = XQTGetFileSize(globals);
- if (!globals->sizeInitialised)
- process = false;
- } else
- globals->state = kStateReadingPages;
-
- break;
-
- case kStateGettingSize:
- dbg_printf(" - (:kStateGettingSize:)\n");
- if (!globals->sizeInitialised) {
- process = false;
- break;
- }
-
- globals->state = kStateReadingPages;
- break;
-
- case kStateReadingPages:
- dbg_printf(" - (:kStateReadingPages:)\n");
- if (globals->dataRequested) {
- DataHTask(globals->dataReader);
- process = false;
- break;
- }
- globals->currentData = rb_data(&globals->dataRB);
- globals->validDataEnd = globals->currentData + rb_data_available(&globals->dataRB);
-
- while (result == noErr && FindPage(&globals->currentData, globals->validDataEnd, &og)) {
- result = ProcessPage(globals, &og);
- }
-
- if (result != noErr)
- break;
+ dbg_printf("-----= StateProcess() called\n");
+ while (process) {
+ switch (globals->state) {
+ case kStateInitial:
+ dbg_printf(" - (:kStateInitial:)\n");
+ globals->dataOffset = globals->dataStartOffset;
+ globals->numTracksSeen = 0;
+ globals->timeLoaded = 0;
+ globals->dataRequested = false;
+ globals->startTickCount = TickCount();
- result = FillBuffer(globals);
- if (result == eofErr)
- globals->state = kStateReadingLastPages;
+ if (S64Compare(globals->dataEndOffset, S64Set(-1)) == 0) {
+ globals->sizeInitialised = false;
+ globals->state = kStateGettingSize;
+ result = XQTGetFileSize(globals);
+ if (!globals->sizeInitialised)
+ process = false;
+ } else
+ globals->state = kStateReadingPages;
- break;
-
- case kStateReadingLastPages:
- dbg_printf(" - (:kStateReadingLastPages:)\n");
- globals->currentData = rb_data(&globals->dataRB);
- globals->validDataEnd = globals->currentData + rb_data_available(&globals->dataRB);
-
- dbg_printf(" + (:kStateReadingLastPages:)\n");
- while (FindPage(&globals->currentData, globals->validDataEnd, &og)) {
- result = ProcessPage(globals, &og);
- dbg_printf(" <- (:kStateReadingLastPages:) = %ld\n", (long)result);
- }
-
- globals->state = kStateImportComplete;
- break;
-
- case kStateImportComplete:
- dbg_printf(" - (:kStateImportComplete:)\n");
- process = false;
- break;
- }
- }
-
- return result;
+ break;
+
+ case kStateGettingSize:
+ dbg_printf(" - (:kStateGettingSize:)\n");
+ if (!globals->sizeInitialised) {
+ process = false;
+ break;
+ }
+
+ globals->state = kStateReadingPages;
+ break;
+
+ case kStateReadingPages:
+ dbg_printf(" - (:kStateReadingPages:)\n");
+ if (globals->dataRequested) {
+ DataHTask(globals->dataReader);
+ process = false;
+ break;
+ }
+ globals->currentData = rb_data(&globals->dataRB);
+ globals->validDataEnd = globals->currentData + rb_data_available(&globals->dataRB);
+
+ while (result == noErr && FindPage(&globals->currentData, globals->validDataEnd, &og)) {
+ result = ProcessPage(globals, &og);
+ }
+
+ if (result != noErr)
+ break;
+
+ result = FillBuffer(globals);
+ if (result == eofErr)
+ globals->state = kStateReadingLastPages;
+
+ break;
+
+ case kStateReadingLastPages:
+ dbg_printf(" - (:kStateReadingLastPages:)\n");
+ globals->currentData = rb_data(&globals->dataRB);
+ globals->validDataEnd = globals->currentData + rb_data_available(&globals->dataRB);
+
+ dbg_printf(" + (:kStateReadingLastPages:)\n");
+ while (FindPage(&globals->currentData, globals->validDataEnd, &og)) {
+ result = ProcessPage(globals, &og);
+ dbg_printf(" <- (:kStateReadingLastPages:) = %ld\n", (long)result);
+ }
+
+ globals->state = kStateImportComplete;
+ break;
+
+ case kStateImportComplete:
+ dbg_printf(" - (:kStateImportComplete:)\n");
+ process = false;
+ break;
+ }
+ }
+
+ return result;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
static void ReadCompletion(Ptr request, long refcon, OSErr readErr)
{
OggImportGlobalsPtr globals = (OggImportGlobalsPtr) refcon;
- ComponentResult result = readErr;
-
- dbg_printf("---> ReadCompletion() called\n");
+ ComponentResult result = readErr;
+
+ dbg_printf("---> ReadCompletion() called\n");
if (readErr == noErr)
{
- dbg_printf("--1- ReadCompletion() :: noErr\n");
+ dbg_printf("--1- ReadCompletion() :: noErr\n");
- rb_sync_reserved(&globals->dataRB);
- globals->dataRequested = false;
+ rb_sync_reserved(&globals->dataRB);
+ globals->dataRequested = false;
- if (globals->idleManager != NULL) {
- dbg_printf("--2- ReadCompletion() :: requesting Idle\n");
- QTIdleManagerSetNextIdleTimeNow(globals->idleManager);
- }
- }
-
+ if (globals->idleManager != NULL) {
+ dbg_printf("--2- ReadCompletion() :: requesting Idle\n");
+ QTIdleManagerSetNextIdleTimeNow(globals->idleManager);
+ }
+ }
+
if (result != noErr)
{
- dbg_printf("--3- ReadCompletion() :: !noErr - %ld (%lx), eofErr: %d\n", result, result, result == eofErr);
+ dbg_printf("--3- ReadCompletion() :: !noErr - %ld (%lx), eofErr: %d\n", result, result, result == eofErr);
if (result == eofErr) {
result = noErr;
- globals->dataRequested = false;
- globals->state = kStateImportComplete;
- }
+ globals->dataRequested = false;
+ globals->state = kStateImportComplete;
+ }
globals->errEncountered = result;
-
+
/* close off every open stream */
- if (globals->streamCount > 0)
- CloseAllStreams(globals);
+ if (globals->streamCount > 0)
+ CloseAllStreams(globals);
}
- dbg_printf("---< ReadCompletion()\n");
+ dbg_printf("---< ReadCompletion()\n");
}
@@ -938,77 +938,77 @@
{
OggImportGlobalsPtr globals = (OggImportGlobalsPtr) refcon;
- dbg_printf("----- FileSizeCompletion() called = %ld\n", (long) readErr);
+ dbg_printf("----- FileSizeCompletion() called = %ld\n", (long) readErr);
if (readErr == noErr)
{
globals->dataEndOffset = WideToSInt64(globals->wideTempforFileSize);
- globals->sizeInitialised = true;
- QTIdleManagerSetNextIdleTimeNow(globals->idleManager);
+ globals->sizeInitialised = true;
+ QTIdleManagerSetNextIdleTimeNow(globals->idleManager);
}
}
static ComponentResult XQTGetFileSize(OggImportGlobalsPtr globals)
{
- ComponentResult err = badComponentSelector;
- wide size;
-
- dbg_printf("---> XQTGetFileSize() called\n");
- if (globals->usingIdle && globals->dataCanDoGetFileSizeAsync && false) {
- err = DataHGetFileSizeAsync(globals->dataReader, &globals->wideTempforFileSize,
- globals->fileSizeCompletion, (long) globals);
- dbg_printf("---- :: async size, err: %ld (%lx)\n", (long)err, (long)err);
+ ComponentResult err = badComponentSelector;
+ wide size;
+ dbg_printf("---> XQTGetFileSize() called\n");
+ if (globals->usingIdle && globals->dataCanDoGetFileSizeAsync && false) {
+ err = DataHGetFileSizeAsync(globals->dataReader, &globals->wideTempforFileSize,
+ globals->fileSizeCompletion, (long) globals);
+ dbg_printf("---- :: async size, err: %ld (%lx)\n", (long)err, (long)err);
+
} else if (globals->dataCanDoGetFileSize64) {
err = DataHGetFileSize64(globals->dataReader, &size);
- dbg_printf("---- :: size: %ld%ld, err: %ld (%lx)\n", size.hi, size.lo, (long)err, (long)err);
+ dbg_printf("---- :: size: %ld%ld, err: %ld (%lx)\n", size.hi, size.lo, (long)err, (long)err);
globals->readError = err;
if (err == noErr) {
globals->dataEndOffset = WideToSInt64(size);
- globals->sizeInitialised = true;
- }
+ globals->sizeInitialised = true;
+ }
} else {
- globals->dataEndOffset = S64Set(-1);
- globals->sizeInitialised = true;
- err = noErr;
- }
-
- dbg_printf("---< XQTGetFileSize() = %ld (%lx)\n", (long) err, (long) err);
+ globals->dataEndOffset = S64Set(-1);
+ globals->sizeInitialised = true;
+ err = noErr;
+ }
+
+ dbg_printf("---< XQTGetFileSize() = %ld (%lx)\n", (long) err, (long) err);
return err;
}
static ComponentResult StartImport(OggImportGlobalsPtr globals, Handle dataRef, OSType dataRefType)
{
ComponentResult err = noErr;
-
+
globals->state = kStateInitial;
-
+
return err;
}
static ComponentResult JustImport(OggImportGlobalsPtr globals, Handle dataRef, OSType dataRefType) {
- ComponentResult ret = noErr;
- Boolean do_read = true;
-
+ ComponentResult ret = noErr;
+ Boolean do_read = true;
+
globals->state = kStateInitial;
-
+
/* if limits have not been set, then try to get the size of the file. */
if (S64Compare(globals->dataEndOffset, S64Set(-1)) == 0) {
ret = XQTGetFileSize(globals);
}
- if (ret != noErr)
- return ret;
+ if (ret != noErr)
+ return ret;
- while (do_read) {
- ret = StateProcess(globals);
- if ((ret != noErr && ret != eofErr) || globals->state == kStateImportComplete)
- do_read = false;
- }
+ while (do_read) {
+ ret = StateProcess(globals);
+ if ((ret != noErr && ret != eofErr) || globals->state == kStateImportComplete)
+ do_read = false;
+ }
- if (ret == eofErr)
- ret = noErr;
+ if (ret == eofErr)
+ ret = noErr;
- dbg_printf("-<<- JustImport(): %ld\n", (long)ret);
+ dbg_printf("-<<- JustImport(): %ld\n", (long)ret);
return ret;
}
@@ -1016,93 +1016,93 @@
static ComponentResult SetupDataHandler(OggImportGlobalsPtr globals, Handle dataRef, OSType dataRefType)
{
ComponentResult err = noErr;
-
- dbg_printf("---> SetupDataHandler(type: '%4.4s') called\n", &dataRefType);
+
+ dbg_printf("---> SetupDataHandler(type: '%4.4s') called\n", &dataRefType);
if (globals->dataReader == NULL)
{
- Component dataHComponent = NULL;
+ Component dataHComponent = NULL;
#if 0
- if (dataRefType == URLDataHandlerSubType)
- {
- ComponentDescription cdesc, cd;
- int count;
- Handle cname = NewHandle(0);
-
- cdesc.componentType = DataHandlerType;
- cdesc.componentSubType = URLDataHandlerSubType;
- cdesc.componentManufacturer = kAnyComponentManufacturer;
- cdesc.componentFlags = kAnyComponentFlagsMask;
- cdesc.componentFlagsMask = kAnyComponentFlagsMask;
-
- dbg_printf("---- >> CountComponents(urlDataHandlers): %ld\n", CountComponents(&cdesc));
- count = 6;
- while (count-- > 0) {
- dataHComponent = FindNextComponent(dataHComponent, &cdesc);
- GetComponentInfo(dataHComponent, &cd, cname, NULL, NULL);
- dbg_printf("---- ->-> component desc: %s, manu: %4.4s\n", *cname, &cd.componentManufacturer);
- }
-
- } else {
+ if (dataRefType == URLDataHandlerSubType)
+ {
+ ComponentDescription cdesc, cd;
+ int count;
+ Handle cname = NewHandle(0);
+
+ cdesc.componentType = DataHandlerType;
+ cdesc.componentSubType = URLDataHandlerSubType;
+ cdesc.componentManufacturer = kAnyComponentManufacturer;
+ cdesc.componentFlags = kAnyComponentFlagsMask;
+ cdesc.componentFlagsMask = kAnyComponentFlagsMask;
+
+ dbg_printf("---- >> CountComponents(urlDataHandlers): %ld\n", CountComponents(&cdesc));
+ count = 6;
+ while (count-- > 0) {
+ dataHComponent = FindNextComponent(dataHComponent, &cdesc);
+ GetComponentInfo(dataHComponent, &cd, cname, NULL, NULL);
+ dbg_printf("---- ->-> component desc: %s, manu: %4.4s\n", *cname, &cd.componentManufacturer);
+ }
+
+ } else {
#endif
- dataHComponent = GetDataHandler(dataRef, dataRefType, kDataHCanRead);
+ dataHComponent = GetDataHandler(dataRef, dataRefType, kDataHCanRead);
#if 0
- }
+ }
#endif
err = OpenAComponent(dataHComponent, &globals->dataReader);
-
- dbg_printf("---- >> OpenAComponent() = %ld\n", (long)err);
+
+ dbg_printf("---- >> OpenAComponent() = %ld\n", (long)err);
if (err == noErr)
{
err = DataHSetDataRef(globals->dataReader, dataRef);
- dbg_printf("---- >> DataHSetDataRef() = %ld\n", (long)err);
+ dbg_printf("---- >> DataHSetDataRef() = %ld\n", (long)err);
if (err == noErr)
err = DataHOpenForRead(globals->dataReader);
#if 0
- else {
- Boolean wc;
- err = DataHResolveDataRef(globals->dataReader, dataRef, &wc, false);
- dbg_printf("---- >> DataHResolveDataRef() = %ld\n", (long)err);
- err = noErr;
- }
+ else {
+ Boolean wc;
+ err = DataHResolveDataRef(globals->dataReader, dataRef, &wc, false);
+ dbg_printf("---- >> DataHResolveDataRef() = %ld\n", (long)err);
+ err = noErr;
+ }
#endif
- DataHPlaybackHints(globals->dataReader, 0, 0, -1, 49152); // Don't care if it fails
-
+ DataHPlaybackHints(globals->dataReader, 0, 0, -1, 49152); // Don't care if it fails
+
if (err == noErr)
{
- long blockSize = 1024;
-
+ long blockSize = 1024;
+
globals->dataOffset = S64Set(0);
-
+
globals->dataRef = dataRef;
globals->dataRefType = dataRefType;
-
+
globals->dataCanDoAsyncRead = (CallComponentCanDo(globals->dataReader, kDataHReadAsyncSelect) == true);
globals->dataCanDoGetFileSizeAsync = (CallComponentCanDo(globals->dataReader, kDataHGetFileSizeAsyncSelect) == true);
globals->dataCanDoGetFileSize64 = (CallComponentCanDo(globals->dataReader, kDataHGetFileSize64Select) == true);
-
+
globals->dataReadChunkSize = kDataBufferSize;
- if ((globals->newMovieFlags & newMovieAsyncOK) != 0 && globals->dataCanDoGetFileSizeAsync)
- globals->dataReadChunkSize = kDataAsyncBufferSize;
+ if ((globals->newMovieFlags & newMovieAsyncOK) != 0 && globals->dataCanDoGetFileSizeAsync)
+ globals->dataReadChunkSize = kDataAsyncBufferSize;
err = DataHGetPreferredBlockSize(globals->dataReader, &blockSize);
if (err == noErr && blockSize < globals->dataReadChunkSize && blockSize > 1024)
globals->dataReadChunkSize = blockSize;
- dbg_printf(" - allocating buffer, size: %d (prefBlockSize: %ld); ret = %ld\n",
- globals->dataReadChunkSize, blockSize, (long)err);
+ dbg_printf(" - allocating buffer, size: %d (prefBlockSize: %ld); ret = %ld\n",
+ globals->dataReadChunkSize, blockSize, (long)err);
err = noErr; /* ignore any error and use our default read block size */
-
- err = rb_init(&globals->dataRB, 2 * globals->dataReadChunkSize); //hmm why was it x2 ?
+ err = rb_init(&globals->dataRB, 2 * globals->dataReadChunkSize); //hmm why was it x2 ?
+
globals->currentData = (unsigned char *)globals->dataRB.buffer;
globals->validDataEnd = (unsigned char *)globals->dataRB.buffer;
}
-
+
if (err == noErr)
{
globals->dataReadCompletion = NewDataHCompletionUPP(ReadCompletion);
}
-
+
if (err == noErr && globals->dataCanDoGetFileSizeAsync)
{
globals->fileSizeCompletion = NewDataHCompletionUPP(FileSizeCompletion);
@@ -1110,31 +1110,31 @@
if (err == noErr && globals->idleManager)
{
- // purposely ignore the error message here, i.e. set it if the data handler supports it
+ // purposely ignore the error message here, i.e. set it if the data handler supports it
OggImportSetIdleManager(globals, globals->idleManager);
}
if (err == noErr)
{
- // This logic is similar to the MP3 importer
+ // This logic is similar to the MP3 importer
UInt32 flags = 0;
-
+
globals->dataIsStream = globals->dataCanDoGetFileSizeAsync;
err = DataHGetInfoFlags(globals->dataReader, &flags);
if (err == noErr && (flags & kDataHInfoFlagNeverStreams))
globals->dataIsStream = false;
err = noErr;
- dbg_printf("---- -:: InfoFlags: NeverStreams: %d, CanUpdate...: %d, NeedsNet: %d\n",
- (flags & kDataHInfoFlagNeverStreams) != 0,
- (flags & kDataHInfoFlagCanUpdateDataRefs) != 0,
- (flags & kDataHInfoFlagNeedsNetworkBandwidth) != 0);
+ dbg_printf("---- -:: InfoFlags: NeverStreams: %d, CanUpdate...: %d, NeedsNet: %d\n",
+ (flags & kDataHInfoFlagNeverStreams) != 0,
+ (flags & kDataHInfoFlagCanUpdateDataRefs) != 0,
+ (flags & kDataHInfoFlagNeedsNetworkBandwidth) != 0);
}
}
}
-
- dbg_printf("---< SetupDataHandler() = %ld\n", (long)err);
- return err;
+
+ dbg_printf("---< SetupDataHandler() = %ld\n", (long)err);
+ return err;
}
@@ -1145,204 +1145,204 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportOpen(OggImportGlobalsPtr globals, ComponentInstance self)
{
- OSErr result;
-
- dbg_printf("-- Open() called\n");
+ OSErr result;
+
+ dbg_printf("-- Open() called\n");
globals = (OggImportGlobalsPtr)NewPtrClear(sizeof(OggImportGlobals));
if (globals != nil)
- {
+ {
// set our storage pointer to our globals
SetComponentInstanceStorage(self, (Handle) globals);
globals->self = self;
-
+
globals->dataEndOffset = S64Set(-1);
- globals->idleManager = NULL;
- globals->dataIdleManager = NULL;
-
+ globals->idleManager = NULL;
+ globals->dataIdleManager = NULL;
+
result = noErr;
}
else
result = MemError();
-
+
return (result);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportClose(OggImportGlobalsPtr globals, ComponentInstance self)
{
- ComponentResult result;
+ ComponentResult result;
(void)self;
-
- dbg_printf("-- Close() called\n");
- if (globals != nil) // we have some globals
+
+ dbg_printf("-- Close() called\n");
+ if (globals != nil) // we have some globals
{
if (globals->streamInfoHandle)
{
- if (globals->streamCount > 0)
- CloseAllStreams(globals);
+ if (globals->streamCount > 0)
+ CloseAllStreams(globals);
DisposeHandle((Handle)globals->streamInfoHandle);
}
-
+
if (globals->dataReader)
{
result = CloseComponent(globals->dataReader);
//FailMessage(result != noErr); //@@@
globals->dataReader = NULL;
}
-
+
if (globals->dataBuffer)
{
DisposePtr(globals->dataBuffer);
globals->dataBuffer = NULL;
}
-
- if (globals->dataRB.buffer) {
- rb_free(&globals->dataRB);
- }
-
+
+ if (globals->dataRB.buffer) {
+ rb_free(&globals->dataRB);
+ }
+
if (globals->dataReadCompletion)
DisposeDataHCompletionUPP(globals->dataReadCompletion);
-
+
if (globals->fileSizeCompletion)
DisposeDataHCompletionUPP(globals->fileSizeCompletion);
-
+
if (globals->aliasHandle)
DisposeHandle((Handle)globals->aliasHandle);
-
- if (globals->dataIdleManager != NULL)
- QTIdleManagerClose(globals->dataIdleManager);
-
+
+ if (globals->dataIdleManager != NULL)
+ QTIdleManagerClose(globals->dataIdleManager);
+
DisposePtr((Ptr)globals);
}
-
+
return noErr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportVersion(OggImportGlobalsPtr globals)
{
- dbg_printf("-- Version() called\n");
+ dbg_printf("-- Version() called\n");
return kOgg_eat__Version;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportSetOffsetAndLimit64(OggImportGlobalsPtr globals, const wide *offset,
- const wide *limit)
+ const wide *limit)
{
- dbg_printf("-- SetOffsetAndLimit64(%ld%ld, %ld%ld) called\n", offset->hi, offset->lo, limit->hi, limit->lo);
+ dbg_printf("-- SetOffsetAndLimit64(%ld%ld, %ld%ld) called\n", offset->hi, offset->lo, limit->hi, limit->lo);
globals->dataStartOffset = WideToSInt64(*offset);
globals->dataEndOffset = WideToSInt64(*limit);
-
+
return noErr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportSetOffsetAndLimit(OggImportGlobalsPtr globals, unsigned long offset,
- unsigned long limit)
+ unsigned long limit)
{
- dbg_printf("-- SetOffsetAndLimit(%ld, %ld) called\n", offset, limit);
- globals->dataStartOffset = S64SetU(offset);
+ dbg_printf("-- SetOffsetAndLimit(%ld, %ld) called\n", offset, limit);
+ globals->dataStartOffset = S64SetU(offset);
globals->dataEndOffset = S64SetU(limit);
-
+
return noErr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-COMPONENTFUNC OggImportValidate(OggImportGlobalsPtr globals,
- const FSSpec * theFile,
- Handle theData,
- Boolean * valid)
+COMPONENTFUNC OggImportValidate(OggImportGlobalsPtr globals,
+ const FSSpec * theFile,
+ Handle theData,
+ Boolean * valid)
{
ComponentResult err = noErr;
- UInt8 extvalid = 0;
+ UInt8 extvalid = 0;
- dbg_printf("-- Validate() called\n");
+ dbg_printf("-- Validate() called\n");
if (theFile == NULL)
{
- Handle dataHandle = NewHandle(sizeof(HandleDataRefRecord));
+ Handle dataHandle = NewHandle(sizeof(HandleDataRefRecord));
if (dataHandle != NULL)
{
(*(HandleDataRefRecord **)dataHandle)->dataHndl = theData;
err = MovieImportValidateDataRef(globals->self,
- dataHandle,
- HandleDataHandlerSubType,
- &extvalid);
+ dataHandle,
+ HandleDataHandlerSubType,
+ &extvalid);
DisposeHandle(dataHandle);
}
}
else
{
AliasHandle alias = NULL;
-
+
err = NewAliasMinimal(theFile, &alias);
if (err == noErr)
{
err = MovieImportValidateDataRef(globals->self,
- (Handle)alias,
- rAliasType,
- &extvalid);
-
+ (Handle)alias,
+ rAliasType,
+ &extvalid);
+
DisposeHandle((Handle)alias);
}
}
-
- if (extvalid > 0)
- *valid = true;
- else
- *valid = false;
+ if (extvalid > 0)
+ *valid = true;
+ else
+ *valid = false;
+
return err;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-COMPONENTFUNC OggImportValidateDataRef(OggImportGlobalsPtr globals,
- Handle dataRef,
- OSType dataRefType,
- UInt8 * valid)
+COMPONENTFUNC OggImportValidateDataRef(OggImportGlobalsPtr globals,
+ Handle dataRef,
+ OSType dataRefType,
+ UInt8 * valid)
{
ComponentResult err = noErr;
- dbg_printf("-- ValidateDataRef() called\n");
-
- *valid = 128;
+ dbg_printf("-- ValidateDataRef() called\n");
+ *valid = 128;
+
return err;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportFile(OggImportGlobalsPtr globals, const FSSpec *theFile,
- Movie theMovie, Track targetTrack, Track *usedTrack,
- TimeValue atTime, TimeValue *durationAdded,
- long inFlags, long *outFlags)
+ Movie theMovie, Track targetTrack, Track *usedTrack,
+ TimeValue atTime, TimeValue *durationAdded,
+ long inFlags, long *outFlags)
{
ComponentResult err = noErr;
AliasHandle alias = NULL;
- dbg_printf("-- File() called\n");
-
+ dbg_printf("-- File() called\n");
+
*outFlags = 0;
-
+
err = NewAliasMinimal(theFile, &alias);
if (err == noErr)
{
err = MovieImportDataRef(globals->self,
- (Handle)alias,
- rAliasType,
- theMovie,
- targetTrack,
- usedTrack,
- atTime,
- durationAdded,
- inFlags,
- outFlags);
-
+ (Handle)alias,
+ rAliasType,
+ theMovie,
+ targetTrack,
+ usedTrack,
+ atTime,
+ durationAdded,
+ inFlags,
+ outFlags);
+
if (!(*outFlags & movieImportResultNeedIdles))
DisposeHandle((Handle) alias);
else
globals->aliasHandle = alias;
}
-
+
return err;
}
@@ -1350,7 +1350,7 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportGetMIMETypeList(OggImportGlobalsPtr globals, QTAtomContainer *retMimeInfo)
{
- dbg_printf("-- GetMIMETypeList() called\n");
+ dbg_printf("-- GetMIMETypeList() called\n");
return GetComponentResource((Component)globals->self, FOUR_CHAR_CODE('mime'), kImporterResID, (Handle *)retMimeInfo);
}
@@ -1358,7 +1358,7 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportGetFileType(OggImportGlobalsPtr globals, OSType *fileType)
{
- dbg_printf("-- GetFileType() called\n");
+ dbg_printf("-- GetFileType() called\n");
*fileType = kCodecFormat;
return noErr;
}
@@ -1367,172 +1367,172 @@
COMPONENTFUNC OggImportSetChunkSize(OggImportGlobalsPtr globals, long chunkSize)
{
ComponentResult err = noErr;
-
- dbg_printf("-- ImportSetChunkSize(%ld) called\n", chunkSize);
+
+ dbg_printf("-- ImportSetChunkSize(%ld) called\n", chunkSize);
if (chunkSize > 2048 && chunkSize < 204800)
globals->chunkSize = chunkSize;
else
err = paramErr;
-
+
return err;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportIdle(OggImportGlobalsPtr globals,
- long inFlags,
- long *outFlags)
+ long inFlags,
+ long *outFlags)
{
ComponentResult err = noErr;
- dbg_printf("-> Idle() called [%08lx]\n", (long)globals);
+ dbg_printf("-> Idle() called [%08lx]\n", (long)globals);
- if (globals->state == kStateImportComplete) {
- *outFlags |= movieImportResultComplete;
- return err;
- }
+ if (globals->state == kStateImportComplete) {
+ *outFlags |= movieImportResultComplete;
+ return err;
+ }
- err = StateProcess(globals);
+ err = StateProcess(globals);
#if 0
- if (true) {
- Boolean needs = false;
- TimeRecord ni;
+ if (true) {
+ Boolean needs = false;
+ TimeRecord ni;
- if (globals->idleManager != NULL) {
- QTIdleManagerNeedsAnIdle(globals->idleManager, &needs);
- if (needs) {
- QTIdleManagerGetNextIdleTime(globals->idleManager, &ni);
- dbg_printf("-- -- IdleManager :: requested: base: %ld, scale: %ld, value: %ld %ld\n", (long)ni.base, ni.scale,
- ni.value.hi, ni.value.lo);
- } else {
- dbg_printf("-- -- IdleManager :: not needed\n");
- }
- }
+ if (globals->idleManager != NULL) {
+ QTIdleManagerNeedsAnIdle(globals->idleManager, &needs);
+ if (needs) {
+ QTIdleManagerGetNextIdleTime(globals->idleManager, &ni);
+ dbg_printf("-- -- IdleManager :: requested: base: %ld, scale: %ld, value: %ld %ld\n", (long)ni.base, ni.scale,
+ ni.value.hi, ni.value.lo);
+ } else {
+ dbg_printf("-- -- IdleManager :: not needed\n");
+ }
+ }
- if (globals->dataIdleManager != NULL) {
- QTIdleManagerNeedsAnIdle(globals->dataIdleManager, &needs);
- if (needs) {
- QTIdleManagerGetNextIdleTime(globals->dataIdleManager, &ni);
- dbg_printf("-- -- DataIdleManager :: requested: base: %ld, scale: %ld, value: %ld %ld\n", (long)ni.base, ni.scale,
- ni.value.hi, ni.value.lo);
- } else {
- dbg_printf("-- -- DataIdleManager :: not needed\n");
- }
- }
- }
+ if (globals->dataIdleManager != NULL) {
+ QTIdleManagerNeedsAnIdle(globals->dataIdleManager, &needs);
+ if (needs) {
+ QTIdleManagerGetNextIdleTime(globals->dataIdleManager, &ni);
+ dbg_printf("-- -- DataIdleManager :: requested: base: %ld, scale: %ld, value: %ld %ld\n", (long)ni.base, ni.scale,
+ ni.value.hi, ni.value.lo);
+ } else {
+ dbg_printf("-- -- DataIdleManager :: not needed\n");
+ }
+ }
+ }
#endif
- dbg_printf("-< Idle: %ld [%08lx]\n", (long)err, (long)globals);
+ dbg_printf("-< Idle: %ld [%08lx]\n", (long)err, (long)globals);
return err;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportDataRef(OggImportGlobalsPtr globals, Handle dataRef,
- OSType dataRefType, Movie theMovie,
- Track targetTrack, Track *usedTrack,
- TimeValue atTime, TimeValue *durationAdded,
- long inFlags, long *outFlags)
+ OSType dataRefType, Movie theMovie,
+ Track targetTrack, Track *usedTrack,
+ TimeValue atTime, TimeValue *durationAdded,
+ long inFlags, long *outFlags)
{
ComponentResult err = noErr;
-
- *outFlags = 0;
-
- globals->theMovie = theMovie;
- globals->startTime = atTime;
- dbg_printf("-- DataRef(at:%ld) called\n", atTime);
- if (GetHandleSize(dataRef) < 256) {
- dbg_printf("-- - DataRef: \"%s\"\n", *dataRef);
- } else {
- dbg_printf("-- - DataRef: '%c'\n", *dataRef[0]);
- }
+ *outFlags = 0;
- dbg_printf(" theMovie: %lx, targetTrack: %lx\n", theMovie, targetTrack);
- dbg_printf(" track count: %ld\n", GetMovieTrackCount(theMovie));
- dbg_printf(" flags:\n\tmovieImportCreateTrack:%d\n\tmovieImportInParallel:%d\n"
- "\tmovieImportMustUseTrack:%d\n\tmovieImportWithIdle:%d\n",
- (inFlags & movieImportCreateTrack) != 0,
- (inFlags & movieImportInParallel) != 0,
- (inFlags & movieImportMustUseTrack) != 0,
- (inFlags & movieImportWithIdle) != 0);
- dbg_printf(" : importing at: %ld, added: %ld\n", atTime, *durationAdded);
+ globals->theMovie = theMovie;
+ globals->startTime = atTime;
+
+ dbg_printf("-- DataRef(at:%ld) called\n", atTime);
+ if (GetHandleSize(dataRef) < 256) {
+ dbg_printf("-- - DataRef: \"%s\"\n", *dataRef);
+ } else {
+ dbg_printf("-- - DataRef: '%c'\n", *dataRef[0]);
+ }
+
+ dbg_printf(" theMovie: %lx, targetTrack: %lx\n", theMovie, targetTrack);
+ dbg_printf(" track count: %ld\n", GetMovieTrackCount(theMovie));
+ dbg_printf(" flags:\n\tmovieImportCreateTrack:%d\n\tmovieImportInParallel:%d\n"
+ "\tmovieImportMustUseTrack:%d\n\tmovieImportWithIdle:%d\n",
+ (inFlags & movieImportCreateTrack) != 0,
+ (inFlags & movieImportInParallel) != 0,
+ (inFlags & movieImportMustUseTrack) != 0,
+ (inFlags & movieImportWithIdle) != 0);
+ dbg_printf(" : importing at: %ld, added: %ld\n", atTime, *durationAdded);
err = SetupDataHandler(globals, dataRef, dataRefType);
- if (err == noErr)
- dbg_printf(" SetupDataHandler() succeeded\n");
+ if (err == noErr)
+ dbg_printf(" SetupDataHandler() succeeded\n");
- globals->usingIdle = ((globals->dataIsStream || globals->dataCanDoAsyncRead)
- //&& globals->dataCanDoGetFileSizeAsync
- && (inFlags & movieImportWithIdle) != 0);
+ globals->usingIdle = ((globals->dataIsStream || globals->dataCanDoAsyncRead)
+ //&& globals->dataCanDoGetFileSizeAsync
+ && (inFlags & movieImportWithIdle) != 0);
if (dataRefType != URLDataHandlerSubType)
globals->usingIdle = false;
- dbg_printf("--> 2: globals->usingIdle: %d\n", globals->usingIdle);
+ dbg_printf("--> 2: globals->usingIdle: %d\n", globals->usingIdle);
- if (globals->usingIdle) {
- err = StartImport(globals, dataRef, dataRefType);
- *outFlags |= movieImportResultNeedIdles;
- *durationAdded = 0;
- } else {
- err = JustImport(globals, dataRef, dataRefType);
- *outFlags &= !movieImportResultNeedIdles;
- if (err == noErr) {
- *outFlags |= movieImportResultComplete;
- *durationAdded = globals->timeLoaded;
- if (globals->numTracksSeen == 1)
- *usedTrack = globals->firstTrack;
- }
- }
-
- //globals->usingIdle = true;
- //*outFlags |= movieImportResultNeedIdles;
-
- dbg_printf("-< DataRef(at:%ld)\n", atTime);
+ if (globals->usingIdle) {
+ err = StartImport(globals, dataRef, dataRefType);
+ *outFlags |= movieImportResultNeedIdles;
+ *durationAdded = 0;
+ } else {
+ err = JustImport(globals, dataRef, dataRefType);
+ *outFlags &= !movieImportResultNeedIdles;
+ if (err == noErr) {
+ *outFlags |= movieImportResultComplete;
+ *durationAdded = globals->timeLoaded;
+ if (globals->numTracksSeen == 1)
+ *usedTrack = globals->firstTrack;
+ }
+ }
+
+ //globals->usingIdle = true;
+ //*outFlags |= movieImportResultNeedIdles;
+
+ dbg_printf("-< DataRef(at:%ld)\n", atTime);
return err;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportGetLoadState(OggImportGlobalsPtr globals, long *loadState)
{
- dbg_printf("-- GetLoadState() called\n");
+ dbg_printf("-- GetLoadState() called\n");
switch (globals->state)
{
- case kStateInitial:
+ case kStateInitial:
case kStateGettingSize:
*loadState = kMovieLoadStateLoading;
break;
-
+
case kStateReadingPages:
- if (globals->timeLoaded > 0)
- if (globals->sizeInitialised && S64Compare(globals->dataEndOffset, S64Set(-1)) == 0)
- *loadState = kMovieLoadStatePlaythroughOK;
- else
- *loadState = kMovieLoadStatePlayable;
- else
- *loadState = kMovieLoadStateLoading;
+ if (globals->timeLoaded > 0)
+ if (globals->sizeInitialised && S64Compare(globals->dataEndOffset, S64Set(-1)) == 0)
+ *loadState = kMovieLoadStatePlaythroughOK;
+ else
+ *loadState = kMovieLoadStatePlayable;
+ else
+ *loadState = kMovieLoadStateLoading;
- break;
+ break;
case kStateReadingLastPages:
- *loadState = kMovieLoadStatePlaythroughOK;
+ *loadState = kMovieLoadStatePlaythroughOK;
break;
-
+
case kStateImportComplete:
*loadState = kMovieLoadStateComplete;
- break;
+ break;
}
-
- dbg_printf("-- GetLoadState returning %ld\n", *loadState);
+ dbg_printf("-- GetLoadState returning %ld\n", *loadState);
+
return noErr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportGetMaxLoadedTime(OggImportGlobalsPtr globals, TimeValue *time)
{
- dbg_printf("-- GetMaxLoadedTime() called: %8ld (at: %ld)\n", globals->timeLoaded, TickCount());
+ dbg_printf("-- GetMaxLoadedTime() called: %8ld (at: %ld)\n", globals->timeLoaded, TickCount());
- *time = globals->timeLoaded;
+ *time = globals->timeLoaded;
- return noErr;
+ return noErr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1543,20 +1543,20 @@
SInt64 dataLeft = S64Subtract(globals->dataEndOffset, globals->dataOffset);
SInt64 ratio = S64Div(S64Multiply(S64Set(timeUsed), dataLeft), dataUsed);
- dbg_printf("-- EstimateCompletionTime() called: ratio = %lld\n", ratio);
+ dbg_printf("-- EstimateCompletionTime() called: ratio = %lld\n", ratio);
time->value = SInt64ToWide(ratio);
time->scale = 60;
time->base = NULL; // this time record is a duration
- return noErr;
+ return noErr;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportSetDontBlock(OggImportGlobalsPtr globals, Boolean dontBlock)
{
- dbg_printf("-- SetDontBlock(%d) called\n", dontBlock);
+ dbg_printf("-- SetDontBlock(%d) called\n", dontBlock);
globals->blocking = dontBlock;
return noErr;
}
@@ -1564,7 +1564,7 @@
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportGetDontBlock(OggImportGlobalsPtr globals, Boolean *willBlock)
{
- dbg_printf("-- GetDontBlock() called\n");
+ dbg_printf("-- GetDontBlock() called\n");
*willBlock = globals->blocking;
return noErr;
}
@@ -1574,39 +1574,39 @@
{
ComponentResult err = noErr;
- dbg_printf("-- SetIdleManager() called\n");
+ dbg_printf("-- SetIdleManager() called\n");
globals->idleManager = im;
if (globals->dataReader)
{
if (CallComponentCanDo(globals->dataReader, kDataHSetIdleManagerSelect) == true)
{
- globals->dataIdleManager = QTIdleManagerOpen();
- if (globals->dataIdleManager != NULL) {
- err = DataHSetIdleManager(globals->dataReader, im);
- dbg_printf("-- -- SetIdleManager(dataReader) = %ld\n", (long)err);
- if (err != noErr) {
- QTIdleManagerClose(globals->dataIdleManager);
- err = noErr;
- } else {
- err = QTIdleManagerSetParent(globals->dataIdleManager, globals->idleManager);
- dbg_printf("-- -- SetParentIdleManager() = %ld\n", (long)err);
- err = noErr;
- }
- }
+ globals->dataIdleManager = QTIdleManagerOpen();
+ if (globals->dataIdleManager != NULL) {
+ err = DataHSetIdleManager(globals->dataReader, im);
+ dbg_printf("-- -- SetIdleManager(dataReader) = %ld\n", (long)err);
+ if (err != noErr) {
+ QTIdleManagerClose(globals->dataIdleManager);
+ err = noErr;
+ } else {
+ err = QTIdleManagerSetParent(globals->dataIdleManager, globals->idleManager);
+ dbg_printf("-- -- SetParentIdleManager() = %ld\n", (long)err);
+ err = noErr;
+ }
+ }
} else {
- dbg_printf("-- -- SetIdleManager(dataReader) = DOESN'T SUPPORT IDLE!!\n");
- }
+ dbg_printf("-- -- SetIdleManager(dataReader) = DOESN'T SUPPORT IDLE!!\n");
+ }
}
-
- QTIdleManagerSetNextIdleTimeNow(globals->idleManager);
+
+ QTIdleManagerSetNextIdleTimeNow(globals->idleManager);
return err;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
COMPONENTFUNC OggImportSetNewMovieFlags(OggImportGlobalsPtr globals, long flags)
{
- dbg_printf("-- SetNewMovieFlags() called: %08lx\n", flags);
+ dbg_printf("-- SetNewMovieFlags() called: %08lx\n", flags);
globals->newMovieFlags = flags;
return noErr;
Modified: trunk/xiph-qt/OggImport/src/OggImport.r
===================================================================
--- trunk/xiph-qt/OggImport/src/OggImport.r 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/OggImport.r 2005-12-10 19:33:16 UTC (rev 10575)
@@ -55,14 +55,14 @@
// Ogg Importer
#define kImporterFlags canMovieImportFiles | canMovieImportValidateFile | \
- canMovieImportPartial | canMovieImportInPlace | hasMovieImportMIMEList | \
- canMovieImportDataReferences | canMovieImportWithIdle | \
- canMovieImportAvoidBlocking | canMovieImportValidateDataReferences | \
- cmpThreadSafe
+ canMovieImportPartial | canMovieImportInPlace | hasMovieImportMIMEList | \
+ canMovieImportDataReferences | canMovieImportWithIdle | \
+ canMovieImportAvoidBlocking | canMovieImportValidateDataReferences | \
+ cmpThreadSafe
resource 'thng' (kImporterResID, OggImporterName, purgeable) {
- kImporterComponentType, kCodecFormat, 'soun',
+ kImporterComponentType, kCodecFormat, 'soun',
0, 0, 0, 0,
'STR ', kImporterNameStringResID,
'STR ', kImporterInfoStringResID,
@@ -71,13 +71,13 @@
componentDoAutoVersion|componentHasMultiplePlatforms, 0,
{
#if TARGET_OS_MAC // COMPONENT PLATFORM INFORMATION ----------------------
- kImporterFlags,
+ kImporterFlags,
'dlle', // Code Resource type - Entry point found by symbol name 'dlle' resource
kImporterResID, // ID of 'dlle' resource
platformPowerPCNativeEntryPoint,
#endif
#if TARGET_OS_WIN32
- kImporterFlags,
+ kImporterFlags,
'dlle',
kImporterResID,
platformWin32,
@@ -98,8 +98,8 @@
'STR ', // Name Type
kImporterNameStringResID, // Name ID
'STR ', // Info Type
- kImporterInfoStringResID, // Info ID
- 0, // Icon Type
+ kImporterInfoStringResID, // Info ID
+ 0, // Icon Type
0, // Icon ID
// TARGET COMPONENT ---------------
kImporterComponentType, // Type
@@ -122,8 +122,8 @@
'STR ', // Name Type
kImporterNameStringResID, // Name ID
'STR ', // Info Type
- kImporterInfoStringResID, // Info ID
- 0, // Icon Type
+ kImporterInfoStringResID, // Info ID
+ 0, // Icon Type
0, // Icon ID
// TARGET COMPONENT ---------------
kImporterComponentType, // Type
@@ -147,8 +147,8 @@
'STR ', // Name Type
kImporterNameStringResID, // Name ID
'STR ', // Info Type
- kImporterInfoStringResID, // Info ID
- 0, // Icon Type
+ kImporterInfoStringResID, // Info ID
+ 0, // Icon Type
0, // Icon ID
// TARGET COMPONENT ---------------
kImporterComponentType, // Type
@@ -183,7 +183,7 @@
};
-/*
+/*
This is an example of how to build an atom container resource to hold mime types.
This component's GetMIMETypeList implementation simply loads this resource and returns it.
Please note that atoms of the same type MUST be grouped together within an atom container.
@@ -212,23 +212,23 @@
kQTMediaConfigBinaryFile | kQTMediaConfigCanUseApp,
'OggS',
'TVOD', /* we don't have a creator code for our files, hijack QT player */
- kImporterComponentType, kCodecFormat, kSoundComponentManufacturer,
+ kImporterComponentType, kCodecFormat, kSoundComponentManufacturer,
0, 0,
'OGG ',
kQTMediaInfoNetGroup,
-
+
/* no synonyms */
{
},
-
+
{
- "Ogg Vorbis sound file",
- "ogg",
- "QuickTime Player",
- "Ogg Vorbis file importer",
- "",
+ "Ogg Vorbis sound file",
+ "ogg",
+ "QuickTime Player",
+ "Ogg Vorbis file importer",
+ "",
},
-
+
/* mime types array */
{
"application/x-ogg";
@@ -244,11 +244,11 @@
0, 0,
'SPX ',
kQTMediaInfoNetGroup,
-
+
/* no synonyms */
{
},
-
+
{
"Ogg Speex sound file",
"spx",
@@ -256,7 +256,7 @@
"Ogg Speex file importer",
"",
},
-
+
/* mime types array */
{
"audio/x-speex";
Modified: trunk/xiph-qt/OggImport/src/importer_types.h
===================================================================
--- trunk/xiph-qt/OggImport/src/importer_types.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/importer_types.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -69,11 +69,11 @@
typedef enum ImportStates {
- kStateInitial,
- kStateGettingSize,
- kStateReadingPages,
- kStateReadingLastPages,
- kStateImportComplete
+ kStateInitial,
+ kStateGettingSize,
+ kStateReadingPages,
+ kStateReadingLastPages,
+ kStateImportComplete
} ImportStates;
@@ -88,28 +88,28 @@
typedef struct {
long serialno;
TimeValue timeLoaded;
-
- ogg_stream_state os;
-
+
+ ogg_stream_state os;
+
int numChannels;
int rate;
Handle soundDescExtension;
-
+
Track theTrack;
Media theMedia;
SampleDescriptionHandle sampleDesc;
-
+
ogg_int64_t lastGranulePos;
SInt64 prevPageOffset;
-
+
ogg_int64_t lastSeenGranulePos;
SInt64 lastSeenEndOffset;
-
+
TimeValue startTime;
-
- CFDictionaryRef MDmapping;
- CFDictionaryRef UDmapping;
-
+
+ CFDictionaryRef MDmapping;
+ CFDictionaryRef UDmapping;
+
struct stream_format_handle_funcs *sfhf;
union {
@@ -126,7 +126,7 @@
typedef struct {
ComponentInstance self;
-
+
Movie theMovie;
Handle dataRef;
long dataRefType;
@@ -134,61 +134,61 @@
Boolean usingIdle;
int chunkSize;
TimeValue startTime;
-
+
ImportStates state;
ComponentResult errEncountered;
-
+
SInt64 dataStartOffset;
SInt64 dataEndOffset;
-
+
IdleManager idleManager;
IdleManager dataIdleManager;
-
+
long newMovieFlags;
-
+
ComponentInstance dataReader;
-
+
DataHCompletionUPP dataReadCompletion;
DataHCompletionUPP fileSizeCompletion;
-
+
wide wideTempforFileSize;
-
+
int dataReadChunkSize;
-
+
Boolean dataCanDoAsyncRead;
Boolean dataCanDoGetFileSizeAsync;
Boolean dataCanDoGetFileSize64;
-
+
Boolean blocking;
AliasHandle aliasHandle;
-
+
ComponentResult readError;
-
+
/* information about the data buffer */
Ptr dataBuffer;
int maxDataBufferSize;
SInt64 dataOffset;
unsigned char *validDataEnd;
unsigned char *currentData;
-
- ring_buffer dataRB;
-
+
+ ring_buffer dataRB;
+
int numTracksStarted;
int numTracksSeen; // completed tracks
Track firstTrack;
-
+
TimeValue timeLoaded;
-
- unsigned long startTickCount;
-
+
+ unsigned long startTickCount;
+
// Track ghostTrack;
-
+
int streamCount;
StreamInfo **streamInfoHandle;
-
- Boolean dataRequested;
- Boolean sizeInitialised;
+ Boolean dataRequested;
+ Boolean sizeInitialised;
+
} OggImportGlobals, *OggImportGlobalsPtr;
@@ -208,7 +208,7 @@
recognize_header recognize;
verify_header verify;
-
+
process_first_packet first_packet;
create_sample_description sample_description;
Modified: trunk/xiph-qt/OggImport/src/rb.c
===================================================================
--- trunk/xiph-qt/OggImport/src/rb.c 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/rb.c 2005-12-10 19:33:16 UTC (rev 10575)
@@ -33,141 +33,141 @@
OSErr rb_init(ring_buffer *rb, long size) {
- OSErr ret = noErr;
-
- if (!rb->buffer) {
- rb->buffer = (unsigned char *) NewPtr(2 * size);
- ret = MemError();
-
- if (ret == noErr) {
- rb->b_start = rb->buffer;
- rb->b_end = rb->buffer;
- rb->b_reserved = rb->buffer;
- rb->b_size = size;
- rb->b_real_size = 2 * size;
- }
- }
-
- return ret;
+ OSErr ret = noErr;
+
+ if (!rb->buffer) {
+ rb->buffer = (unsigned char *) NewPtr(2 * size);
+ ret = MemError();
+
+ if (ret == noErr) {
+ rb->b_start = rb->buffer;
+ rb->b_end = rb->buffer;
+ rb->b_reserved = rb->buffer;
+ rb->b_size = size;
+ rb->b_real_size = 2 * size;
+ }
+ }
+
+ return ret;
}
void rb_free(ring_buffer *rb) {
- DisposePtr((Ptr) rb->buffer);
- rb->buffer = NULL;
-
- rb->b_size = 0;
- rb->b_real_size = 0;
- rb->b_start = NULL;
- rb->b_end = NULL;
- rb->b_reserved = NULL;
+ DisposePtr((Ptr) rb->buffer);
+ rb->buffer = NULL;
+
+ rb->b_size = 0;
+ rb->b_real_size = 0;
+ rb->b_start = NULL;
+ rb->b_end = NULL;
+ rb->b_reserved = NULL;
}
void rb_reset(ring_buffer *rb) {
- rb->b_start = rb->buffer;
- rb->b_end = rb->buffer;
- rb->b_reserved = rb->buffer;
+ rb->b_start = rb->buffer;
+ rb->b_end = rb->buffer;
+ rb->b_reserved = rb->buffer;
}
long rb_data_available(ring_buffer *rb) {
- long ret = 0;
-
- if (rb->b_start < rb->b_end)
- ret = (long) (rb->b_end - rb->b_start);
- else if (rb->b_end < rb->b_start)
- ret = (long) (rb->b_end) + rb->b_size - (long) (rb->b_start);
+ long ret = 0;
- return ret;
+ if (rb->b_start < rb->b_end)
+ ret = (long) (rb->b_end - rb->b_start);
+ else if (rb->b_end < rb->b_start)
+ ret = (long) (rb->b_end) + rb->b_size - (long) (rb->b_start);
+
+ return ret;
}
long rb_space_available(ring_buffer *rb) {
- long ret = rb->b_size;
-
- if (rb->b_end < rb->b_start)
- ret = (long) (rb->b_start - rb->b_end);
- else if (rb->b_start < rb->b_end)
- ret = (long) (rb->b_start) + rb->b_size - (long) (rb->b_end);
-
- return ret;
+ long ret = rb->b_size;
+
+ if (rb->b_end < rb->b_start)
+ ret = (long) (rb->b_start - rb->b_end);
+ else if (rb->b_start < rb->b_end)
+ ret = (long) (rb->b_start) + rb->b_size - (long) (rb->b_end);
+
+ return ret;
}
int rb_in(ring_buffer *rb, unsigned char *src, long size) {
- if (size > rb->b_size - rb_data_available(rb))
- return 0;
-
- if ((long) rb->b_end - (long) rb->buffer + size <= rb->b_size) {
- BlockMoveData(src, rb->b_end, size);
- rb->b_end += size;
- } else {
- long wrapped_size = rb->b_size - ((long) rb->b_end - (long) rb->buffer);
- BlockMoveData(src, rb->b_end, wrapped_size);
-
- BlockMoveData(src + wrapped_size, rb->buffer, size - wrapped_size);
- rb->b_end = rb->buffer + (size - wrapped_size);
- }
-
- rb->b_reserved = rb->b_end;
- return 1;
+ if (size > rb->b_size - rb_data_available(rb))
+ return 0;
+
+ if ((long) rb->b_end - (long) rb->buffer + size <= rb->b_size) {
+ BlockMoveData(src, rb->b_end, size);
+ rb->b_end += size;
+ } else {
+ long wrapped_size = rb->b_size - ((long) rb->b_end - (long) rb->buffer);
+ BlockMoveData(src, rb->b_end, wrapped_size);
+
+ BlockMoveData(src + wrapped_size, rb->buffer, size - wrapped_size);
+ rb->b_end = rb->buffer + (size - wrapped_size);
+ }
+
+ rb->b_reserved = rb->b_end;
+ return 1;
}
void rb_zap(ring_buffer *rb, long size) {
- if (size >= rb_data_available(rb))
- //rb_reset(rb);
- rb->b_start = rb->b_end;
- else {
- if (rb->b_start < rb->b_end || rb->b_start + size < rb->buffer + rb->b_size)
- rb->b_start = rb->b_start + size;
- else
- rb->b_start = rb->b_start + size - rb->b_size;
- }
+ if (size >= rb_data_available(rb))
+ //rb_reset(rb);
+ rb->b_start = rb->b_end;
+ else {
+ if (rb->b_start < rb->b_end || rb->b_start + size < rb->buffer + rb->b_size)
+ rb->b_start = rb->b_start + size;
+ else
+ rb->b_start = rb->b_start + size - rb->b_size;
+ }
}
void* rb_data(ring_buffer *rb) {
- long available = rb_data_available(rb);
-
- if (available == 0)
- return rb->buffer;
- else {
- if (rb->b_start > rb->b_end) {
- // OK, here we're taking advange of the facts that the real buffer size
- // is twice as long as the official size; so we can copy wrapped tail of
- // the buffer at the end of the (official size) buffer, and return pointer
- // to a continuous block of data... is that OK?
- BlockMoveData(rb->buffer, rb->buffer + rb->b_size, (long) (rb->b_end - rb->buffer));
- }
- return rb->b_start;
- }
-
+ long available = rb_data_available(rb);
+
+ if (available == 0)
+ return rb->buffer;
+ else {
+ if (rb->b_start > rb->b_end) {
+ // OK, here we're taking advange of the facts that the real buffer size
+ // is twice as long as the official size; so we can copy wrapped tail of
+ // the buffer at the end of the (official size) buffer, and return pointer
+ // to a continuous block of data... is that OK?
+ BlockMoveData(rb->buffer, rb->buffer + rb->b_size, (long) (rb->b_end - rb->buffer));
+ }
+ return rb->b_start;
+ }
+
}
void* rb_reserve(ring_buffer *rb, long size) {
- long available = rb_space_available(rb);
-
- if (size == 0) {
- rb->b_reserved = rb->b_end;
- return NULL;
- }
+ long available = rb_space_available(rb);
- if (available == 0 || size > available)
- return NULL;
+ if (size == 0) {
+ rb->b_reserved = rb->b_end;
+ return NULL;
+ }
- if (rb->b_end <= rb->b_start) {
- // size is smaller then available space, so reserved end should be still before the start
- rb->b_reserved = rb->b_end + size;
- return rb->b_end;
- } else if (rb->b_end + size <= rb->buffer + rb->b_size) {
- rb->b_reserved = rb->b_end + size;
- return rb->b_end;
- } else {
- rb->b_reserved = rb->b_end + size;
- return rb->b_end; // :D
- }
+ if (available == 0 || size > available)
+ return NULL;
+
+ if (rb->b_end <= rb->b_start) {
+ // size is smaller then available space, so reserved end should be still before the start
+ rb->b_reserved = rb->b_end + size;
+ return rb->b_end;
+ } else if (rb->b_end + size <= rb->buffer + rb->b_size) {
+ rb->b_reserved = rb->b_end + size;
+ return rb->b_end;
+ } else {
+ rb->b_reserved = rb->b_end + size;
+ return rb->b_end; // :D
+ }
}
void rb_sync_reserved(ring_buffer *rb) {
- if (rb->b_reserved > rb->buffer + rb->b_size) {
- BlockMoveData(rb->buffer + rb->b_size, rb->buffer, rb->b_reserved - rb->buffer - rb->b_size);
- rb->b_reserved = rb->b_reserved - rb->b_size;
- }
+ if (rb->b_reserved > rb->buffer + rb->b_size) {
+ BlockMoveData(rb->buffer + rb->b_size, rb->buffer, rb->b_reserved - rb->buffer - rb->b_size);
+ rb->b_reserved = rb->b_reserved - rb->b_size;
+ }
- rb->b_end = rb->b_reserved;
+ rb->b_end = rb->b_reserved;
}
Modified: trunk/xiph-qt/OggImport/src/rb.h
===================================================================
--- trunk/xiph-qt/OggImport/src/rb.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/rb.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -35,13 +35,13 @@
#include "config.h"
typedef struct {
- unsigned char *buffer;
- unsigned char *b_start;
- unsigned char *b_end;
- unsigned char *b_reserved;
-
- long b_size;
- long b_real_size;
+ unsigned char *buffer;
+ unsigned char *b_start;
+ unsigned char *b_end;
+ unsigned char *b_reserved;
+
+ long b_size;
+ long b_real_size;
} ring_buffer;
@@ -63,7 +63,7 @@
extern void* rb_reserve(ring_buffer *rb, long size);
-extern void rb_sync_reserved(ring_buffer *rb);
+extern void rb_sync_reserved(ring_buffer *rb);
#endif /* __rb_h__ */
Modified: trunk/xiph-qt/OggImport/src/stream_speex.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_speex.c 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/stream_speex.c 2005-12-10 19:33:16 UTC (rev 10575)
@@ -58,7 +58,7 @@
{
memset(&si->si_speex.header, 0, sizeof(SpeexHeader));
vorbis_comment_init(&si->si_speex.vc);
-
+
si->si_speex.skipped_headers = 0;
si->si_speex.state = kSStateInitial;
@@ -67,7 +67,7 @@
void clear_stream__speex(StreamInfo *si)
{
- vorbis_comment_clear(&si->si_speex.vc);
+ vorbis_comment_clear(&si->si_speex.vc);
};
ComponentResult create_sample_description__speex(StreamInfo *si)
@@ -78,7 +78,7 @@
AudioChannelLayout acl;
AudioChannelLayout *pacl = &acl;
ByteCount acl_size = sizeof(acl);
-
+
asbd.mSampleRate = si->rate;
asbd.mFormatID = kAudioFormatXiphOggFramedSpeex;
asbd.mFormatFlags = 0;
@@ -90,7 +90,7 @@
//asbd.mBitsPerChannel = 16;
asbd.mBitsPerChannel = 0;
asbd.mReserved = 0;
-
+
if (si->numChannels == 1)
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
else if (si->numChannels == 2)
@@ -101,9 +101,9 @@
}
acl.mChannelBitmap = 0;
acl.mNumberChannelDescriptions = 0;
-
+
err = QTSoundDescriptionCreate(&asbd, pacl, acl_size, NULL, 0, kQTSoundDescriptionKind_Movie_Version2, (SoundDescriptionHandle*) &desc);
-
+
if (err == noErr) {
si->sampleDesc = (SampleDescriptionHandle) desc;
}
@@ -114,24 +114,24 @@
int process_first_packet__speex(StreamInfo *si, ogg_page *op, ogg_packet *opckt)
{
unsigned long serialnoatom[3] = { EndianU32_NtoB(sizeof(serialnoatom)), EndianU32_NtoB(kCookieTypeOggSerialNo),
- EndianS32_NtoB(ogg_page_serialno(op)) };
+ EndianS32_NtoB(ogg_page_serialno(op)) };
unsigned long atomhead[2] = { EndianU32_NtoB(opckt->bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeSpeexHeader) };
SpeexHeader *inheader = (SpeexHeader *) opckt->packet;
//vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, opckt); //check errors?
-
- si->si_speex.header.bitrate = EndianS32_LtoN(inheader->bitrate);
- si->si_speex.header.extra_headers = EndianS32_LtoN(inheader->extra_headers);
- si->si_speex.header.frame_size = EndianS32_LtoN(inheader->frame_size);
- si->si_speex.header.frames_per_packet = EndianS32_LtoN(inheader->frames_per_packet);
- si->si_speex.header.header_size = EndianS32_LtoN(inheader->header_size);
- si->si_speex.header.mode = EndianS32_LtoN(inheader->mode);
- si->si_speex.header.mode_bitstream_version = EndianS32_LtoN(inheader->mode_bitstream_version);
- si->si_speex.header.nb_channels = EndianS32_LtoN(inheader->nb_channels);
- si->si_speex.header.rate = EndianS32_LtoN(inheader->rate);
- si->si_speex.header.reserved1 = EndianS32_LtoN(inheader->reserved1);
- si->si_speex.header.reserved2 = EndianS32_LtoN(inheader->reserved2);
- si->si_speex.header.speex_version_id = EndianS32_LtoN(inheader->speex_version_id);
- si->si_speex.header.vbr = EndianS32_LtoN(inheader->vbr);
+
+ si->si_speex.header.bitrate = EndianS32_LtoN(inheader->bitrate);
+ si->si_speex.header.extra_headers = EndianS32_LtoN(inheader->extra_headers);
+ si->si_speex.header.frame_size = EndianS32_LtoN(inheader->frame_size);
+ si->si_speex.header.frames_per_packet = EndianS32_LtoN(inheader->frames_per_packet);
+ si->si_speex.header.header_size = EndianS32_LtoN(inheader->header_size);
+ si->si_speex.header.mode = EndianS32_LtoN(inheader->mode);
+ si->si_speex.header.mode_bitstream_version = EndianS32_LtoN(inheader->mode_bitstream_version);
+ si->si_speex.header.nb_channels = EndianS32_LtoN(inheader->nb_channels);
+ si->si_speex.header.rate = EndianS32_LtoN(inheader->rate);
+ si->si_speex.header.reserved1 = EndianS32_LtoN(inheader->reserved1);
+ si->si_speex.header.reserved2 = EndianS32_LtoN(inheader->reserved2);
+ si->si_speex.header.speex_version_id = EndianS32_LtoN(inheader->speex_version_id);
+ si->si_speex.header.vbr = EndianS32_LtoN(inheader->vbr);
//si->si_speex.header. = EndianS32_LtoN(inheader->);
dbg_printf("! -- - speex_first_packet: ch: %d, rate: %ld\n", si->si_speex.header.nb_channels, si->si_speex.header.rate);
@@ -149,155 +149,154 @@
ComponentResult process_stream_page__speex(OggImportGlobals *globals, StreamInfo *si, ogg_page *opg)
{
- ComponentResult ret = noErr;
- int ovret = 0;
- Boolean loop = true;
- Boolean movie_changed = false;
-
- ogg_packet op;
-
- switch(si->si_speex.state) {
- case kSStateReadingComments:
- case kSStateReadingAdditionalHeaders:
- ogg_stream_pagein(&si->os, opg);
- break;
- default:
- break;
- }
-
- do {
- switch(si->si_speex.state) {
- case kSStateReadingComments:
- ovret = ogg_stream_packetout(&si->os, &op);
- if (ovret < 0) {
- loop = false;
- ret = invalidMedia;
- } else if (ovret < 1) {
- loop = false;
- } else {
- unsigned long atomhead[2] = { EndianU32_NtoB(op.bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeSpeexComments) };
+ ComponentResult ret = noErr;
+ int ovret = 0;
+ Boolean loop = true;
+ Boolean movie_changed = false;
- PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
- PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
- //vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, &op);
-
- ret = CreateTrackAndMedia(globals, si, opg);
- if (ret != noErr) {
- dbg_printf("??? -- CreateTrackAndMedia failed?: %ld\n", (long)ret);
- }
-
- // /*err =*/ DecodeCommentsQT(globals, si, &si->si_vorbis.vc);
- //NotifyMovieChanged(globals);
-
- si->si_speex.state = kSStateReadingAdditionalHeaders;
- }
+ ogg_packet op;
- break;
+ switch(si->si_speex.state) {
+ case kSStateReadingComments:
+ case kSStateReadingAdditionalHeaders:
+ ogg_stream_pagein(&si->os, opg);
+ break;
+ default:
+ break;
+ }
- case kSStateReadingAdditionalHeaders:
- if (si->si_speex.skipped_headers >= si->si_speex.header.extra_headers) {
- unsigned long endAtom[2] = { EndianU32_NtoB(sizeof(endAtom)), EndianU32_NtoB(kAudioTerminatorAtomType) };
-
- ret = PtrAndHand(endAtom, si->soundDescExtension, sizeof(endAtom));
- if (ret == noErr) {
- ret = AddSoundDescriptionExtension((SoundDescriptionHandle) si->sampleDesc,
- si->soundDescExtension, siDecompressionParams);
- //dbg_printf("??? -- Adding extension: %ld\n", ret);
- } else {
- //dbg_printf("??? -- Hmm, something went wrong: %ld\n", ret);
- }
-
- si->startTime = 0;
- si->prevPageOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
+ do {
+ switch(si->si_speex.state) {
+ case kSStateReadingComments:
+ ovret = ogg_stream_packetout(&si->os, &op);
+ if (ovret < 0) {
+ loop = false;
+ ret = invalidMedia;
+ } else if (ovret < 1) {
+ loop = false;
+ } else {
+ unsigned long atomhead[2] = { EndianU32_NtoB(op.bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeSpeexComments) };
- si->si_speex.state = kSStateReadingFirstPacket;
+ PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
+ PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
+ //vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, &op);
- loop = false; // ??!
- break;
+ ret = CreateTrackAndMedia(globals, si, opg);
+ if (ret != noErr) {
+ dbg_printf("??? -- CreateTrackAndMedia failed?: %ld\n", (long)ret);
}
- ovret = ogg_stream_packetout(&si->os, &op);
- if (ovret < 0) {
- loop = false;
- ret = invalidMedia;
- } else if (ovret < 1) {
- loop = false;
+ // /*err =*/ DecodeCommentsQT(globals, si, &si->si_vorbis.vc);
+ //NotifyMovieChanged(globals);
+
+ si->si_speex.state = kSStateReadingAdditionalHeaders;
+ }
+
+ break;
+
+ case kSStateReadingAdditionalHeaders:
+ if (si->si_speex.skipped_headers >= si->si_speex.header.extra_headers) {
+ unsigned long endAtom[2] = { EndianU32_NtoB(sizeof(endAtom)), EndianU32_NtoB(kAudioTerminatorAtomType) };
+
+ ret = PtrAndHand(endAtom, si->soundDescExtension, sizeof(endAtom));
+ if (ret == noErr) {
+ ret = AddSoundDescriptionExtension((SoundDescriptionHandle) si->sampleDesc,
+ si->soundDescExtension, siDecompressionParams);
+ //dbg_printf("??? -- Adding extension: %ld\n", ret);
} else {
- // not much here so far, basically just skip the extra header packet
- unsigned long atomhead[2] = { EndianU32_NtoB(op.bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeSpeexExtraHeader) };
- PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
- PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
-
- si->si_speex.skipped_headers += 1;
+ //dbg_printf("??? -- Hmm, something went wrong: %ld\n", ret);
}
+ si->startTime = 0;
+ si->prevPageOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
+
+ si->si_speex.state = kSStateReadingFirstPacket;
+
+ loop = false; // ??!
break;
+ }
- case kSStateReadingFirstPacket:
- if (ogg_page_pageno(opg) > 2) {
- si->lastGranulePos = ogg_page_granulepos(opg);
- si->prevPageOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
- dbg_printf("----==< skipping: %llx, %lx\n", si->lastGranulePos, ogg_page_pageno(opg));
- loop = false;
-
- if (si->lastGranulePos < 0)
- si->lastGranulePos = 0;
- }
- si->si_speex.state = kSStateReadingPackets;
- break;
-
- case kVStateReadingPackets:
- {
- ogg_int64_t pos = ogg_page_granulepos(opg);
- SInt64 endOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
- int len = S64Subtract(endOffset, si->prevPageOffset);
- int duration = pos - si->lastGranulePos;
- TimeValue inserted = 0;
-
- if (pos < 0) {
- //dbg_printf(" - :XX: not added page %ld (single, looooong packet)\n", ogg_page_pageno(opg));
- } else {
- dbg_printf(" - :++: adding sampleRef: %lld, len: %d, dur: %d\n", si->prevPageOffset, len, duration);
- ret = AddMediaSampleReference(si->theMedia, si->prevPageOffset,
- len, duration, si->sampleDesc, 1, 0, &inserted); //@@@@ 64-bit enable
- if (ret == noErr) {
- dbg_printf(" - :><: added page %04ld at %14ld (size: %5ld, tsize: %6d), f: %d\n",
- ogg_page_pageno(opg), inserted,
- opg->header_len + opg->body_len, len, !logg_page_last_packet_incomplete(opg));
- dbg_printf(" - :/>: inserting media: %ld, mt: %lld, dur: %d\n", si->startTime, si->lastGranulePos, duration);
- ret = InsertMediaIntoTrack(si->theTrack, si->startTime /*inserted*/, /* si->lastGranulePos */ inserted,
- duration, fixed1);
- si->startTime = -1;
- si->timeLoaded = GetTrackOffset(si->theTrack) + GetTrackDuration(si->theTrack);
- //if (globals->dataIsStream)
- // si->timeLoaded = (duration + inserted) * GetMovieTimeScale(globals->theMovie) / GetMediaTimeScale(si->theMedia);
-
- dbg_printf(" - :><: added page %04ld at %14ld; offset: %ld, duration: %ld (%ld, %ld), mediats: %ld; moviets: %ld, ret = %ld\n",
- ogg_page_pageno(opg), inserted,
- GetTrackOffset(si->theTrack), GetTrackDuration(si->theTrack), si->timeLoaded,
- (duration * GetMovieTimeScale(globals->theMovie)) / GetMediaTimeScale(si->theMedia),
- GetMediaTimeScale(si->theMedia), GetMovieTimeScale(globals->theMovie), ret);
- if (globals->timeLoaded < si->timeLoaded)
- globals->timeLoaded = si->timeLoaded;
-
- movie_changed = true;
- }
-
- si->prevPageOffset = endOffset;
- si->lastGranulePos = pos;
+ ovret = ogg_stream_packetout(&si->os, &op);
+ if (ovret < 0) {
+ loop = false;
+ ret = invalidMedia;
+ } else if (ovret < 1) {
+ loop = false;
+ } else {
+ // not much here so far, basically just skip the extra header packet
+ unsigned long atomhead[2] = { EndianU32_NtoB(op.bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeSpeexExtraHeader) };
+ PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
+ PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
+
+ si->si_speex.skipped_headers += 1;
+ }
+
+ break;
+
+ case kSStateReadingFirstPacket:
+ if (ogg_page_pageno(opg) > 2) {
+ si->lastGranulePos = ogg_page_granulepos(opg);
+ si->prevPageOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
+ dbg_printf("----==< skipping: %llx, %lx\n", si->lastGranulePos, ogg_page_pageno(opg));
+ loop = false;
+
+ if (si->lastGranulePos < 0)
+ si->lastGranulePos = 0;
+ }
+ si->si_speex.state = kSStateReadingPackets;
+ break;
+
+ case kVStateReadingPackets:
+ {
+ ogg_int64_t pos = ogg_page_granulepos(opg);
+ SInt64 endOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
+ int len = S64Subtract(endOffset, si->prevPageOffset);
+ int duration = pos - si->lastGranulePos;
+ TimeValue inserted = 0;
+
+ if (pos < 0) {
+ //dbg_printf(" - :XX: not added page %ld (single, looooong packet)\n", ogg_page_pageno(opg));
+ } else {
+ dbg_printf(" - :++: adding sampleRef: %lld, len: %d, dur: %d\n", si->prevPageOffset, len, duration);
+ ret = AddMediaSampleReference(si->theMedia, si->prevPageOffset,
+ len, duration, si->sampleDesc, 1, 0, &inserted); //@@@@ 64-bit enable
+ if (ret == noErr) {
+ dbg_printf(" - :><: added page %04ld at %14ld (size: %5ld, tsize: %6d), f: %d\n",
+ ogg_page_pageno(opg), inserted,
+ opg->header_len + opg->body_len, len, !logg_page_last_packet_incomplete(opg));
+ dbg_printf(" - :/>: inserting media: %ld, mt: %lld, dur: %d\n", si->startTime, si->lastGranulePos, duration);
+ ret = InsertMediaIntoTrack(si->theTrack, si->startTime /*inserted*/, /* si->lastGranulePos */ inserted,
+ duration, fixed1);
+ si->startTime = -1;
+ si->timeLoaded = GetTrackOffset(si->theTrack) + GetTrackDuration(si->theTrack);
+ //if (globals->dataIsStream)
+ // si->timeLoaded = (duration + inserted) * GetMovieTimeScale(globals->theMovie) / GetMediaTimeScale(si->theMedia);
+
+ dbg_printf(" - :><: added page %04ld at %14ld; offset: %ld, duration: %ld (%ld, %ld), mediats: %ld; moviets: %ld, ret = %ld\n",
+ ogg_page_pageno(opg), inserted,
+ GetTrackOffset(si->theTrack), GetTrackDuration(si->theTrack), si->timeLoaded,
+ (duration * GetMovieTimeScale(globals->theMovie)) / GetMediaTimeScale(si->theMedia),
+ GetMediaTimeScale(si->theMedia), GetMovieTimeScale(globals->theMovie), ret);
+ if (globals->timeLoaded < si->timeLoaded)
+ globals->timeLoaded = si->timeLoaded;
+
+ movie_changed = true;
}
+
+ si->prevPageOffset = endOffset;
+ si->lastGranulePos = pos;
}
- loop = false;
- break;
-
- default:
- loop = false;
- }
- } while(loop);
-
- if (movie_changed)
- NotifyMovieChanged(globals);
-
- return ret;
-};
+ }
+ loop = false;
+ break;
+ default:
+ loop = false;
+ }
+ } while(loop);
+
+ if (movie_changed)
+ NotifyMovieChanged(globals);
+
+ return ret;
+};
Modified: trunk/xiph-qt/OggImport/src/stream_speex.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_speex.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/stream_speex.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -47,8 +47,8 @@
extern ComponentResult process_stream_page__speex(OggImportGlobals *globals, StreamInfo *si, ogg_page *opg);
#define HANDLE_FUNCTIONS__SPEEX { &process_stream_page__speex, &recognize_header__speex, \
- &verify_header__speex, &process_first_packet__speex, &create_sample_description__speex, \
- &initialize_stream__speex, &clear_stream__speex }
+ &verify_header__speex, &process_first_packet__speex, &create_sample_description__speex, \
+ &initialize_stream__speex, &clear_stream__speex }
#endif /* __stream_vorbis_h__ */
Modified: trunk/xiph-qt/OggImport/src/stream_types_speex.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_types_speex.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/stream_types_speex.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -36,24 +36,22 @@
#include <Speex/speex_header.h>
typedef enum SpeexImportStates {
- kSStateInitial,
- kSStateReadingComments,
- kSStateReadingAdditionalHeaders,
- kSStateReadingFirstPacket,
+ kSStateInitial,
+ kSStateReadingComments,
+ kSStateReadingAdditionalHeaders,
+ kSStateReadingFirstPacket,
kSStateReadingPackets
} SpeexImportStates;
typedef struct {
- SpeexImportStates state;
-
- UInt32 skipped_headers;
- SpeexHeader header;
- vorbis_comment vc;
+ SpeexImportStates state;
+
+ UInt32 skipped_headers;
+ SpeexHeader header;
+ vorbis_comment vc;
} StreamInfo__speex;
-
-
#define _HAVE__SPEEX_SUPPORT 1
-#endif /* __stream_types_speex_h__ */
\ No newline at end of file
+#endif /* __stream_types_speex_h__ */
Modified: trunk/xiph-qt/OggImport/src/stream_types_vorbis.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_types_vorbis.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/stream_types_vorbis.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -35,24 +35,22 @@
#include <Vorbis/codec.h>
typedef enum VorbisImportStates {
- kVStateInitial,
- kVStateReadingComments,
- kVStateReadingCodebooks,
- kVStateReadingFirstPacket,
- //kVStateSeekingLastPacket,
+ kVStateInitial,
+ kVStateReadingComments,
+ kVStateReadingCodebooks,
+ kVStateReadingFirstPacket,
+ //kVStateSeekingLastPacket,
kVStateReadingPackets
} VorbisImportStates;
typedef struct {
- VorbisImportStates state;
-
- vorbis_info vi;
- vorbis_comment vc;
+ VorbisImportStates state;
+
+ vorbis_info vi;
+ vorbis_comment vc;
} StreamInfo__vorbis;
-
-
#define _HAVE__VORBIS_SUPPORT 1
-#endif /* __stream_types_vorbis_h__ */
\ No newline at end of file
+#endif /* __stream_types_vorbis_h__ */
Modified: trunk/xiph-qt/OggImport/src/stream_vorbis.c
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_vorbis.c 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/stream_vorbis.c 2005-12-10 19:33:16 UTC (rev 10575)
@@ -49,31 +49,31 @@
int verify_header__vorbis(ogg_page *op) //?
{
- OSErr err = noErr;
-
- ogg_stream_state os;
- ogg_packet opk;
-
- vorbis_info vi;
- vorbis_comment vc;
-
- ogg_stream_init(&os, ogg_page_serialno(op));
-
+ OSErr err = noErr;
+
+ ogg_stream_state os;
+ ogg_packet opk;
+
+ vorbis_info vi;
+ vorbis_comment vc;
+
+ ogg_stream_init(&os, ogg_page_serialno(op));
+
vorbis_info_init(&vi);
vorbis_comment_init(&vc);
-
- if (ogg_stream_pagein(&os, op) < 0)
- err = invalidMedia;
- else if (ogg_stream_packetout(&os, &opk) != 1)
- err = invalidMedia;
- else if (vorbis_synthesis_headerin(&vi, &vc, &opk) < 0)
- err = noSoundTrackInMovieErr;
-
- ogg_stream_clear(&os);
-
+
+ if (ogg_stream_pagein(&os, op) < 0)
+ err = invalidMedia;
+ else if (ogg_stream_packetout(&os, &opk) != 1)
+ err = invalidMedia;
+ else if (vorbis_synthesis_headerin(&vi, &vc, &opk) < 0)
+ err = noSoundTrackInMovieErr;
+
+ ogg_stream_clear(&os);
+
vorbis_comment_clear(&vc);
vorbis_info_clear(&vi);
-
+
return err;
};
@@ -81,7 +81,7 @@
{
vorbis_info_init(&si->si_vorbis.vi);
vorbis_comment_init(&si->si_vorbis.vc);
-
+
si->si_vorbis.state = kVStateInitial;
return 0;
@@ -89,8 +89,8 @@
void clear_stream__vorbis(StreamInfo *si)
{
- vorbis_info_clear(&si->si_vorbis.vi);
- vorbis_comment_clear(&si->si_vorbis.vc);
+ vorbis_info_clear(&si->si_vorbis.vi);
+ vorbis_comment_clear(&si->si_vorbis.vc);
};
ComponentResult create_sample_description__vorbis(StreamInfo *si)
@@ -101,7 +101,7 @@
AudioChannelLayout acl;
AudioChannelLayout *pacl = &acl;
ByteCount acl_size = sizeof(acl);
-
+
asbd.mSampleRate = si->rate;
asbd.mFormatID = kAudioFormatXiphOggFramedVorbis;
asbd.mFormatFlags = 0;
@@ -137,11 +137,11 @@
int process_first_packet__vorbis(StreamInfo *si, ogg_page *op, ogg_packet *opckt)
{
unsigned long serialnoatom[3] = { EndianU32_NtoB(sizeof(serialnoatom)), EndianU32_NtoB(kCookieTypeOggSerialNo),
- EndianS32_NtoB(ogg_page_serialno(op)) };
+ EndianS32_NtoB(ogg_page_serialno(op)) };
unsigned long atomhead[2] = { EndianU32_NtoB(opckt->bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeVorbisHeader) };
vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, opckt); //check errors?
-
+
si->numChannels = si->si_vorbis.vi.channels;
si->rate = si->si_vorbis.vi.rate;
@@ -156,150 +156,149 @@
ComponentResult process_stream_page__vorbis(OggImportGlobals *globals, StreamInfo *si, ogg_page *opg)
{
- ComponentResult ret = noErr;
- int ovret = 0;
- Boolean loop = true;
- Boolean movie_changed = false;
-
- ogg_packet op;
-
- switch(si->si_vorbis.state) {
- case kVStateReadingComments:
- case kVStateReadingCodebooks:
- ogg_stream_pagein(&si->os, opg);
- break;
- default:
- break;
- }
-
- do {
- switch(si->si_vorbis.state) {
- case kVStateReadingComments:
- ovret = ogg_stream_packetout(&si->os, &op);
- if (ovret < 0) {
- loop = false;
- ret = invalidMedia;
- } else if (ovret < 1) {
- loop = false;
- } else {
- unsigned long atomhead[2] = { EndianU32_NtoB(op.bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeVorbisComments) };
+ ComponentResult ret = noErr;
+ int ovret = 0;
+ Boolean loop = true;
+ Boolean movie_changed = false;
- PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
- PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
- vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, &op);
-
- ret = CreateTrackAndMedia(globals, si, opg);
- if (ret != noErr) {
- dbg_printf("??? -- CreateTrackAndMedia failed?: %ld\n", (long)ret);
- }
-
- /*err =*/ DecodeCommentsQT(globals, si, &si->si_vorbis.vc);
- //NotifyMovieChanged(globals);
-
- si->si_vorbis.state = kVStateReadingCodebooks;
- }
- break;
-
- case kVStateReadingCodebooks:
- ovret = ogg_stream_packetout(&si->os, &op);
- if (ovret < 0) {
- loop = false;
- ret = invalidMedia;
- } else if (ovret < 1) {
- loop = false;
- } else {
- unsigned long atomhead[2] = { EndianU32_NtoB(op.bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeVorbisCodebooks) };
- PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
- PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
-
- vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, &op);
- {
- unsigned long endAtom[2] = { EndianU32_NtoB(sizeof(endAtom)), EndianU32_NtoB(kAudioTerminatorAtomType) };
-
- ret = PtrAndHand(endAtom, si->soundDescExtension, sizeof(endAtom));
- if (ret == noErr) {
- ret = AddSoundDescriptionExtension((SoundDescriptionHandle) si->sampleDesc,
- si->soundDescExtension, siDecompressionParams);
- //dbg_printf("??? -- Adding extension: %ld\n", ret);
- } else {
- //dbg_printf("??? -- Hmm, something went wrong: %ld\n", ret);
- }
- }
-
- si->si_vorbis.state = kVStateReadingFirstPacket;
- si->startTime = 0;
- si->prevPageOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
- loop = false; //there should be an end of page here according to specs...
- }
- break;
-
- case kVStateReadingFirstPacket:
- if (ogg_page_pageno(opg) > 3) {
- si->lastGranulePos = ogg_page_granulepos(opg);
- si->prevPageOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
- dbg_printf("----==< skipping: %llx, %lx\n", si->lastGranulePos, ogg_page_pageno(opg));
- loop = false;
-
- if (si->lastGranulePos < 0)
- si->lastGranulePos = 0;
- }
- si->si_vorbis.state = kVStateReadingPackets;
- break;
-
- case kVStateReadingPackets:
- {
- ogg_int64_t pos = ogg_page_granulepos(opg);
- SInt64 endOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
- int len = S64Subtract(endOffset, si->prevPageOffset);
- int duration = pos - si->lastGranulePos;
- TimeValue inserted = 0;
-
- if (pos < 0) {
- //dbg_printf(" - :XX: not added page %ld (single, looooong packet)\n", ogg_page_pageno(opg));
- } else {
- dbg_printf(" - :++: adding sampleRef: %lld, len: %d, dur: %d\n", si->prevPageOffset, len, duration);
- ret = AddMediaSampleReference(si->theMedia, si->prevPageOffset,
+ ogg_packet op;
+
+ switch(si->si_vorbis.state) {
+ case kVStateReadingComments:
+ case kVStateReadingCodebooks:
+ ogg_stream_pagein(&si->os, opg);
+ break;
+ default:
+ break;
+ }
+
+ do {
+ switch(si->si_vorbis.state) {
+ case kVStateReadingComments:
+ ovret = ogg_stream_packetout(&si->os, &op);
+ if (ovret < 0) {
+ loop = false;
+ ret = invalidMedia;
+ } else if (ovret < 1) {
+ loop = false;
+ } else {
+ unsigned long atomhead[2] = { EndianU32_NtoB(op.bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeVorbisComments) };
+
+ PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
+ PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
+ vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, &op);
+
+ ret = CreateTrackAndMedia(globals, si, opg);
+ if (ret != noErr) {
+ dbg_printf("??? -- CreateTrackAndMedia failed?: %ld\n", (long)ret);
+ }
+
+ /*err =*/ DecodeCommentsQT(globals, si, &si->si_vorbis.vc);
+ //NotifyMovieChanged(globals);
+
+ si->si_vorbis.state = kVStateReadingCodebooks;
+ }
+ break;
+
+ case kVStateReadingCodebooks:
+ ovret = ogg_stream_packetout(&si->os, &op);
+ if (ovret < 0) {
+ loop = false;
+ ret = invalidMedia;
+ } else if (ovret < 1) {
+ loop = false;
+ } else {
+ unsigned long atomhead[2] = { EndianU32_NtoB(op.bytes + sizeof(atomhead)), EndianU32_NtoB(kCookieTypeVorbisCodebooks) };
+ PtrAndHand(atomhead, si->soundDescExtension, sizeof(atomhead));
+ PtrAndHand(op.packet, si->soundDescExtension, op.bytes);
+
+ vorbis_synthesis_headerin(&si->si_vorbis.vi, &si->si_vorbis.vc, &op);
+ {
+ unsigned long endAtom[2] = { EndianU32_NtoB(sizeof(endAtom)), EndianU32_NtoB(kAudioTerminatorAtomType) };
+
+ ret = PtrAndHand(endAtom, si->soundDescExtension, sizeof(endAtom));
+ if (ret == noErr) {
+ ret = AddSoundDescriptionExtension((SoundDescriptionHandle) si->sampleDesc,
+ si->soundDescExtension, siDecompressionParams);
+ //dbg_printf("??? -- Adding extension: %ld\n", ret);
+ } else {
+ //dbg_printf("??? -- Hmm, something went wrong: %ld\n", ret);
+ }
+ }
+
+ si->si_vorbis.state = kVStateReadingFirstPacket;
+ si->startTime = 0;
+ si->prevPageOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
+ loop = false; //there should be an end of page here according to specs...
+ }
+ break;
+
+ case kVStateReadingFirstPacket:
+ if (ogg_page_pageno(opg) > 3) {
+ si->lastGranulePos = ogg_page_granulepos(opg);
+ si->prevPageOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
+ dbg_printf("----==< skipping: %llx, %lx\n", si->lastGranulePos, ogg_page_pageno(opg));
+ loop = false;
+
+ if (si->lastGranulePos < 0)
+ si->lastGranulePos = 0;
+ }
+ si->si_vorbis.state = kVStateReadingPackets;
+ break;
+
+ case kVStateReadingPackets:
+ {
+ ogg_int64_t pos = ogg_page_granulepos(opg);
+ SInt64 endOffset = S64Add(globals->dataOffset, opg->header_len + opg->body_len);
+ int len = S64Subtract(endOffset, si->prevPageOffset);
+ int duration = pos - si->lastGranulePos;
+ TimeValue inserted = 0;
+
+ if (pos < 0) {
+ //dbg_printf(" - :XX: not added page %ld (single, looooong packet)\n", ogg_page_pageno(opg));
+ } else {
+ dbg_printf(" - :++: adding sampleRef: %lld, len: %d, dur: %d\n", si->prevPageOffset, len, duration);
+ ret = AddMediaSampleReference(si->theMedia, si->prevPageOffset,
len, duration, si->sampleDesc, 1, 0, &inserted); //@@@@ 64-bit enable
- if (ret == noErr)
- {
- dbg_printf(" - :><: added page %04ld at %14ld (size: %5ld, tsize: %6d), f: %d\n",
- ogg_page_pageno(opg), inserted,
- opg->header_len + opg->body_len, len, !logg_page_last_packet_incomplete(opg));
- dbg_printf(" - :/>: inserting media: %ld, mt: %lld, dur: %d\n", si->startTime, si->lastGranulePos, duration);
- ret = InsertMediaIntoTrack(si->theTrack, si->startTime /*inserted*/, /* si->lastGranulePos */ inserted,
+ if (ret == noErr)
+ {
+ dbg_printf(" - :><: added page %04ld at %14ld (size: %5ld, tsize: %6d), f: %d\n",
+ ogg_page_pageno(opg), inserted,
+ opg->header_len + opg->body_len, len, !logg_page_last_packet_incomplete(opg));
+ dbg_printf(" - :/>: inserting media: %ld, mt: %lld, dur: %d\n", si->startTime, si->lastGranulePos, duration);
+ ret = InsertMediaIntoTrack(si->theTrack, si->startTime /*inserted*/, /* si->lastGranulePos */ inserted,
duration, fixed1);
- si->startTime = -1;
- si->timeLoaded = GetTrackOffset(si->theTrack) + GetTrackDuration(si->theTrack);
- //if (globals->dataIsStream)
- // si->timeLoaded = (duration + inserted) * GetMovieTimeScale(globals->theMovie) / GetMediaTimeScale(si->theMedia);
-
- dbg_printf(" - :><: added page %04ld at %14ld; offset: %ld, duration: %ld (%ld, %ld), mediats: %ld; moviets: %ld, ret = %ld\n",
- ogg_page_pageno(opg), inserted,
- GetTrackOffset(si->theTrack), GetTrackDuration(si->theTrack), si->timeLoaded,
- (duration * GetMovieTimeScale(globals->theMovie)) / GetMediaTimeScale(si->theMedia),
- GetMediaTimeScale(si->theMedia), GetMovieTimeScale(globals->theMovie), ret);
- if (globals->timeLoaded < si->timeLoaded)
- globals->timeLoaded = si->timeLoaded;
-
- movie_changed = true;
-
- }
-
- si->prevPageOffset = endOffset;
- si->lastGranulePos = pos;
- }
- }
- loop = false;
- break;
-
- default:
- loop = false;
- }
- } while(loop);
-
- if (movie_changed)
- NotifyMovieChanged(globals);
-
- return ret;
-};
+ si->startTime = -1;
+ si->timeLoaded = GetTrackOffset(si->theTrack) + GetTrackDuration(si->theTrack);
+ //if (globals->dataIsStream)
+ // si->timeLoaded = (duration + inserted) * GetMovieTimeScale(globals->theMovie) / GetMediaTimeScale(si->theMedia);
+ dbg_printf(" - :><: added page %04ld at %14ld; offset: %ld, duration: %ld (%ld, %ld), mediats: %ld; moviets: %ld, ret = %ld\n",
+ ogg_page_pageno(opg), inserted,
+ GetTrackOffset(si->theTrack), GetTrackDuration(si->theTrack), si->timeLoaded,
+ (duration * GetMovieTimeScale(globals->theMovie)) / GetMediaTimeScale(si->theMedia),
+ GetMediaTimeScale(si->theMedia), GetMovieTimeScale(globals->theMovie), ret);
+ if (globals->timeLoaded < si->timeLoaded)
+ globals->timeLoaded = si->timeLoaded;
+
+ movie_changed = true;
+
+ }
+
+ si->prevPageOffset = endOffset;
+ si->lastGranulePos = pos;
+ }
+ }
+ loop = false;
+ break;
+
+ default:
+ loop = false;
+ }
+ } while(loop);
+
+ if (movie_changed)
+ NotifyMovieChanged(globals);
+
+ return ret;
+};
Modified: trunk/xiph-qt/OggImport/src/stream_vorbis.h
===================================================================
--- trunk/xiph-qt/OggImport/src/stream_vorbis.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/OggImport/src/stream_vorbis.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -47,8 +47,8 @@
extern ComponentResult process_stream_page__vorbis(OggImportGlobals *globals, StreamInfo *si, ogg_page *opg);
#define HANDLE_FUNCTIONS__VORBIS { &process_stream_page__vorbis, &recognize_header__vorbis, \
- &verify_header__vorbis, &process_first_packet__vorbis, &create_sample_description__vorbis, \
- &initialize_stream__vorbis, &clear_stream__vorbis }
+ &verify_header__vorbis, &process_first_packet__vorbis, &create_sample_description__vorbis, \
+ &initialize_stream__vorbis, &clear_stream__vorbis }
#endif /* __stream_vorbis_h__ */
Modified: trunk/xiph-qt/build-win32/DllMain.c
===================================================================
--- trunk/xiph-qt/build-win32/DllMain.c 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/build-win32/DllMain.c 2005-12-10 19:33:16 UTC (rev 10575)
@@ -35,12 +35,12 @@
BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
- ghInst = (HINSTANCE) hInst;
+ ghInst = (HINSTANCE) hInst;
- switch (ul_reason_for_call) {
- //do nothing, so far...
- default:
- break;
+ switch (ul_reason_for_call) {
+ //do nothing, so far...
+ default:
+ break;
}
return TRUE;
Modified: trunk/xiph-qt/build-win32/pxml.c
===================================================================
--- trunk/xiph-qt/build-win32/pxml.c 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/build-win32/pxml.c 2005-12-10 19:33:16 UTC (rev 10575)
@@ -33,210 +33,210 @@
#include <string.h>
CFStringRef pxml_parse_key(unsigned char **str, long *str_size) {
- CFStringRef ret = NULL;
+ CFStringRef ret = NULL;
- char *l_str_pos = *str;
- char *tmp_pos = NULL;
- char *end_pos = NULL;
- long l_str_size = *str_size;
+ char *l_str_pos = *str;
+ char *tmp_pos = NULL;
+ char *end_pos = NULL;
+ long l_str_size = *str_size;
- if (strncmp(l_str_pos, "<key", 4) != 0)
- return NULL;
- else {
- l_str_pos += 4;
- l_str_size -= 4;
- }
+ if (strncmp(l_str_pos, "<key", 4) != 0)
+ return NULL;
+ else {
+ l_str_pos += 4;
+ l_str_size -= 4;
+ }
- tmp_pos = memchr(l_str_pos, '>', l_str_size);
- if (tmp_pos == NULL)
- return NULL;
+ tmp_pos = memchr(l_str_pos, '>', l_str_size);
+ if (tmp_pos == NULL)
+ return NULL;
- tmp_pos += 1;
- l_str_size -= tmp_pos - l_str_pos;
- l_str_pos = tmp_pos;
- if (l_str_size < 0)
- return NULL;
+ tmp_pos += 1;
+ l_str_size -= tmp_pos - l_str_pos;
+ l_str_pos = tmp_pos;
+ if (l_str_size < 0)
+ return NULL;
- end_pos = memchr(l_str_pos, '<', l_str_size);
- if (end_pos == NULL)
- return NULL;
+ end_pos = memchr(l_str_pos, '<', l_str_size);
+ if (end_pos == NULL)
+ return NULL;
- l_str_size -= end_pos - l_str_pos;
- l_str_pos = end_pos;
+ l_str_size -= end_pos - l_str_pos;
+ l_str_pos = end_pos;
- if (l_str_size < 6 || strncmp(l_str_pos, "</key>", 6) != 0)
- return NULL;
+ if (l_str_size < 6 || strncmp(l_str_pos, "</key>", 6) != 0)
+ return NULL;
- *str = end_pos + 6;
- *str_size = l_str_size - 6;
+ *str = end_pos + 6;
+ *str_size = l_str_size - 6;
- ret = CFStringCreateWithBytes(NULL, tmp_pos, end_pos - tmp_pos, kCFStringEncodingUTF8, true);
+ ret = CFStringCreateWithBytes(NULL, tmp_pos, end_pos - tmp_pos, kCFStringEncodingUTF8, true);
- return ret;
+ return ret;
}
CFStringRef pxml_parse_string(unsigned char **str, long *str_size) {
- CFStringRef ret = NULL;
+ CFStringRef ret = NULL;
- char *l_str_pos = *str;
- char *tmp_pos = NULL;
- char *end_pos = NULL;
- long l_str_size = *str_size;
+ char *l_str_pos = *str;
+ char *tmp_pos = NULL;
+ char *end_pos = NULL;
+ long l_str_size = *str_size;
- if (strncmp(l_str_pos, "<string", 7) != 0)
- return NULL;
- else {
- l_str_pos += 7;
- l_str_size -= 7;
- }
+ if (strncmp(l_str_pos, "<string", 7) != 0)
+ return NULL;
+ else {
+ l_str_pos += 7;
+ l_str_size -= 7;
+ }
- tmp_pos = memchr(l_str_pos, '>', l_str_size);
- if (tmp_pos == NULL)
- return NULL;
+ tmp_pos = memchr(l_str_pos, '>', l_str_size);
+ if (tmp_pos == NULL)
+ return NULL;
- tmp_pos += 1;
- l_str_size -= tmp_pos - l_str_pos;
- l_str_pos = tmp_pos;
- if (l_str_size < 0)
- return NULL;
+ tmp_pos += 1;
+ l_str_size -= tmp_pos - l_str_pos;
+ l_str_pos = tmp_pos;
+ if (l_str_size < 0)
+ return NULL;
- end_pos = memchr(l_str_pos, '<', l_str_size);
- if (end_pos == NULL)
- return NULL;
+ end_pos = memchr(l_str_pos, '<', l_str_size);
+ if (end_pos == NULL)
+ return NULL;
- l_str_size -= end_pos - l_str_pos;
- l_str_pos = end_pos;
+ l_str_size -= end_pos - l_str_pos;
+ l_str_pos = end_pos;
- if (l_str_size < 9 || strncmp(l_str_pos, "</string>", 9) != 0)
- return NULL;
+ if (l_str_size < 9 || strncmp(l_str_pos, "</string>", 9) != 0)
+ return NULL;
- *str = end_pos + 9;
- *str_size = l_str_size - 9;
+ *str = end_pos + 9;
+ *str_size = l_str_size - 9;
- ret = CFStringCreateWithBytes(NULL, tmp_pos, end_pos - tmp_pos, kCFStringEncodingUTF8, true);
+ ret = CFStringCreateWithBytes(NULL, tmp_pos, end_pos - tmp_pos, kCFStringEncodingUTF8, true);
- return ret;
+ return ret;
}
CFDictionaryRef pxml_parse_dict(unsigned char **str, long *str_size) {
- CFDictionaryRef ret = NULL;
- CFMutableDictionaryRef tmp_ret = NULL;
- char *l_str_pos = *str;
- char *tmp_pos = NULL;
- long l_str_size = *str_size;
+ CFDictionaryRef ret = NULL;
+ CFMutableDictionaryRef tmp_ret = NULL;
+ char *l_str_pos = *str;
+ char *tmp_pos = NULL;
+ long l_str_size = *str_size;
- if (strncmp(l_str_pos, "<dict", 5) != 0)
- return NULL;
- else {
- l_str_pos += 5;
- l_str_size -= 5;
- }
+ if (strncmp(l_str_pos, "<dict", 5) != 0)
+ return NULL;
+ else {
+ l_str_pos += 5;
+ l_str_size -= 5;
+ }
- tmp_ret = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ tmp_ret = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- while ((tmp_pos = memchr(l_str_pos, '<', l_str_size)) != NULL) {
- CFStringRef d_key = NULL;
- void *d_value = NULL;
+ while ((tmp_pos = memchr(l_str_pos, '<', l_str_size)) != NULL) {
+ CFStringRef d_key = NULL;
+ void *d_value = NULL;
- l_str_size -= tmp_pos - l_str_pos;
- l_str_pos = tmp_pos;
+ l_str_size -= tmp_pos - l_str_pos;
+ l_str_pos = tmp_pos;
- if (l_str_size > 7 && strncmp(l_str_pos, "</dict>", 7) == 0) {
- l_str_size -= 7;
- l_str_pos += 7;
- break;
- } else if (l_str_size < 4 || strncmp(l_str_pos, "<key", 4) != 0)
- break;
+ if (l_str_size > 7 && strncmp(l_str_pos, "</dict>", 7) == 0) {
+ l_str_size -= 7;
+ l_str_pos += 7;
+ break;
+ } else if (l_str_size < 4 || strncmp(l_str_pos, "<key", 4) != 0)
+ break;
- d_key = pxml_parse_key(&l_str_pos, &l_str_size);
- if (d_key == NULL)
- break;
+ d_key = pxml_parse_key(&l_str_pos, &l_str_size);
+ if (d_key == NULL)
+ break;
- tmp_pos = memchr(l_str_pos, '<', l_str_size);
- if (tmp_pos == NULL) {
- CFRelease(d_key);
- break;
- }
+ tmp_pos = memchr(l_str_pos, '<', l_str_size);
+ if (tmp_pos == NULL) {
+ CFRelease(d_key);
+ break;
+ }
- l_str_size -= tmp_pos - l_str_pos;
- l_str_pos = tmp_pos;
+ l_str_size -= tmp_pos - l_str_pos;
+ l_str_pos = tmp_pos;
- if (l_str_size > 7 && strncmp(l_str_pos, "</dict>", 7) == 0) {
- l_str_size -= 7;
- l_str_pos += 7;
- break;
- } else if (l_str_size > 7 && strncmp(l_str_pos, "<string", 7) == 0) {
- d_value = pxml_parse_string(&l_str_pos, &l_str_size);
- } else if (l_str_size > 5 && strncmp(l_str_pos, "<dict", 5) == 0) {
- d_value = pxml_parse_dict(&l_str_pos, &l_str_size);
- } else {
- // other value types not supported
- CFRelease(d_key);
- break;
- }
+ if (l_str_size > 7 && strncmp(l_str_pos, "</dict>", 7) == 0) {
+ l_str_size -= 7;
+ l_str_pos += 7;
+ break;
+ } else if (l_str_size > 7 && strncmp(l_str_pos, "<string", 7) == 0) {
+ d_value = pxml_parse_string(&l_str_pos, &l_str_size);
+ } else if (l_str_size > 5 && strncmp(l_str_pos, "<dict", 5) == 0) {
+ d_value = pxml_parse_dict(&l_str_pos, &l_str_size);
+ } else {
+ // other value types not supported
+ CFRelease(d_key);
+ break;
+ }
- if (d_value == NULL) {
- CFRelease(d_key);
- break;
+ if (d_value == NULL) {
+ CFRelease(d_key);
+ break;
+ }
+ CFDictionaryAddValue(tmp_ret, d_key, d_value);
}
- CFDictionaryAddValue(tmp_ret, d_key, d_value);
- }
- if (CFDictionaryGetCount(tmp_ret) > 0) {
- ret = CFDictionaryCreateCopy(NULL, tmp_ret);
- CFDictionaryRemoveAllValues(tmp_ret);
- }
+ if (CFDictionaryGetCount(tmp_ret) > 0) {
+ ret = CFDictionaryCreateCopy(NULL, tmp_ret);
+ CFDictionaryRemoveAllValues(tmp_ret);
+ }
- if (ret != NULL) {
- *str = l_str_pos;
- *str_size = l_str_size;
- }
+ if (ret != NULL) {
+ *str = l_str_pos;
+ *str_size = l_str_size;
+ }
- return ret;
+ return ret;
}
CFDictionaryRef pxml_parse_plist(unsigned char *plist_str, long plist_size) {
- CFDictionaryRef ret = NULL;
- char *l_str_pos = plist_str;
- char *tmp_pos = NULL;
- long l_str_size = plist_size;
+ CFDictionaryRef ret = NULL;
+ char *l_str_pos = plist_str;
+ char *tmp_pos = NULL;
+ long l_str_size = plist_size;
- while (l_str_size > 6 && strncmp(l_str_pos, "<plist", 6) != 0) {
- tmp_pos = memchr(l_str_pos + 1, '<', l_str_size - 1);
+ while (l_str_size > 6 && strncmp(l_str_pos, "<plist", 6) != 0) {
+ tmp_pos = memchr(l_str_pos + 1, '<', l_str_size - 1);
- if (tmp_pos == NULL) {
- l_str_pos = NULL;
- break;
+ if (tmp_pos == NULL) {
+ l_str_pos = NULL;
+ break;
+ }
+
+ l_str_size -= tmp_pos - l_str_pos;
+ l_str_pos = tmp_pos;
}
- l_str_size -= tmp_pos - l_str_pos;
- l_str_pos = tmp_pos;
- }
+ if (l_str_pos != NULL) {
+ l_str_pos += 6;
+ l_str_size -= 6;
- if (l_str_pos != NULL) {
- l_str_pos += 6;
- l_str_size -= 6;
+ while (l_str_size > 5 && strncmp(l_str_pos, "<dict", 5) != 0) {
+ tmp_pos = memchr(l_str_pos + 1, '<', l_str_size - 1);
- while (l_str_size > 5 && strncmp(l_str_pos, "<dict", 5) != 0) {
- tmp_pos = memchr(l_str_pos + 1, '<', l_str_size - 1);
+ if (tmp_pos == NULL) {
+ l_str_pos = NULL;
+ break;
+ }
- if (tmp_pos == NULL) {
- l_str_pos = NULL;
- break;
- }
+ l_str_size -= tmp_pos - l_str_pos;
+ l_str_pos = tmp_pos;
+ }
- l_str_size -= tmp_pos - l_str_pos;
- l_str_pos = tmp_pos;
+ if (l_str_pos != NULL) {
+ ret = pxml_parse_dict(&l_str_pos, &l_str_size);
+ }
}
- if (l_str_pos != NULL) {
- ret = pxml_parse_dict(&l_str_pos, &l_str_size);
- }
- }
-
- return ret;
+ return ret;
}
@@ -246,17 +246,17 @@
#include <fcntl.h>
int main(int argc, char **argv) {
- char fbuf[65536];
- CFDictionaryRef dict = NULL;
- int f = open(argv[1], O_RDONLY, 0);
- int bytes_read = read(f, fbuf, 65535);
- close(f);
- fbuf[bytes_read] = '\0';
- dict = parse_plist(fbuf, strlen(fbuf));
+ char fbuf[65536];
+ CFDictionaryRef dict = NULL;
+ int f = open(argv[1], O_RDONLY, 0);
+ int bytes_read = read(f, fbuf, 65535);
+ close(f);
+ fbuf[bytes_read] = '\0';
+ dict = parse_plist(fbuf, strlen(fbuf));
- if (dict != NULL)
- printf("Key count: %d\n", CFDictionaryGetCount(dict));
+ if (dict != NULL)
+ printf("Key count: %d\n", CFDictionaryGetCount(dict));
- return 0;
+ return 0;
}
#endif /* PXML_TEST_IN_PLACE */
Modified: trunk/xiph-qt/common/XCACodec.cpp
===================================================================
--- trunk/xiph-qt/common/XCACodec.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/common/XCACodec.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -35,8 +35,8 @@
XCACodec::XCACodec() :
-mBDCBuffer(),
-mBDCStatus(kBDCStatusOK)
+ mBDCBuffer(),
+ mBDCStatus(kBDCStatusOK)
{
}
@@ -47,11 +47,11 @@
#pragma mark The Core Functions
void XCACodec::AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets,
- const AudioStreamPacketDescription* inPacketDescription)
+ const AudioStreamPacketDescription* inPacketDescription)
{
dbg_printf(" >> [%08lx] XCACodec :: AppendInputData(%ld [%ld])\n", (UInt32) this, ioNumberPackets, ioInputDataByteSize);
- if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);
-
+ if(!mIsInitialized) CODEC_THROW(kAudioCodecStateError);
+
UInt32 bytesToCopy = BufferGetAvailableBytesSize();
if (bytesToCopy > 0) {
UInt32 packet = 0;
@@ -60,13 +60,13 @@
if (bytes + inPacketDescription[packet].mDataByteSize > bytesToCopy)
break;
dbg_printf(" ---- :: %ld: %ld [%ld]\n", packet, inPacketDescription[packet].mDataByteSize,
- inPacketDescription[packet].mVariableFramesInPacket);
+ inPacketDescription[packet].mVariableFramesInPacket);
InPacket(inInputData, &inPacketDescription[packet]);
-
+
bytes += inPacketDescription[packet].mDataByteSize;
packet++;
}
-
+
if (bytes == 0)
CODEC_THROW(kAudioCodecNotEnoughBufferSpaceError);
else {
@@ -80,22 +80,22 @@
}
UInt32 XCACodec::ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
- AudioStreamPacketDescription* outPacketDescription)
+ AudioStreamPacketDescription* outPacketDescription)
{
dbg_printf(" >> [%08lx] XCACodec :: ProduceOutputPackets(%ld [%ld])\n", (UInt32) this, ioNumberPackets, ioOutputDataByteSize);
- UInt32 theAnswer = kAudioCodecProduceOutputPacketSuccess;
-
- if(!mIsInitialized)
- CODEC_THROW(kAudioCodecStateError);
-
+ UInt32 theAnswer = kAudioCodecProduceOutputPacketSuccess;
+
+ if (!mIsInitialized)
+ CODEC_THROW(kAudioCodecStateError);
+
UInt32 frames = 0;
UInt32 fout = 0; //frames produced
UInt32 pout = 0; //full (input) packets processed
UInt32 requested_space_as_frames = ioOutputDataByteSize / mOutputFormat.mBytesPerFrame;
-
+
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
-
+
//TODO: zamienic fout/pout z ioOutputDataByteSize/ioNumberPackets:
// zainicjowac na poczatku, a potem bezposrednio modyfikowac io*, nie [pf]out ...
while (fout < requested_space_as_frames && pout < ioNumberPackets) {
@@ -105,47 +105,47 @@
ioOutputDataByteSize = mOutputFormat.mBytesPerFrame * fout;
theAnswer = kAudioCodecProduceOutputPacketNeedsMoreInputData;
dbg_printf("<.! [%08lx] XCACodec :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n", (UInt32) this,
- ioNumberPackets, ioOutputDataByteSize, theAnswer, FramesReady());
+ ioNumberPackets, ioOutputDataByteSize, theAnswer, FramesReady());
return theAnswer;
}
-
+
if (GenerateFrames() != true) {
if (BDCGetStatus() == kBDCStatusAbort) {
ioNumberPackets = pout;
ioOutputDataByteSize = mOutputFormat.mBytesPerFrame * fout;
theAnswer = kAudioCodecProduceOutputPacketFailure;
dbg_printf("<!! [%08lx] XCACodec :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n", (UInt32) this,
- ioNumberPackets, ioOutputDataByteSize, theAnswer, FramesReady());
+ ioNumberPackets, ioOutputDataByteSize, theAnswer, FramesReady());
return theAnswer;
}
}
}
-
+
if (frames == 0)
continue;
-
+
if ((fout + frames) * mOutputFormat.mBytesPerFrame > ioOutputDataByteSize)
frames = requested_space_as_frames - fout;
-
+
OutputFrames(outOutputData, frames, fout);
fout += frames;
-
+
Zap(frames);
-
+
pout += InPacketsConsumed();
}
-
+
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
+
ioOutputDataByteSize = mOutputFormat.mBytesPerFrame * fout; //???
ioNumberPackets = pout;
-
+
theAnswer = (FramesReady() > 0 || !BufferIsEmpty()) ? kAudioCodecProduceOutputPacketSuccessHasMore
- : kAudioCodecProduceOutputPacketSuccess;
-
+ : kAudioCodecProduceOutputPacketSuccess;
+
dbg_printf("<.. [%08lx] XCACodec :: ProduceOutputPackets(%ld [%ld]) = %ld [%ld]\n",
- (UInt32) this, ioNumberPackets, ioOutputDataByteSize, theAnswer, FramesReady());
+ (UInt32) this, ioNumberPackets, ioOutputDataByteSize, theAnswer, FramesReady());
return theAnswer;
}
@@ -201,4 +201,3 @@
{
return (mBDCBuffer.GetDataAvailable() == 0);
}
-
Modified: trunk/xiph-qt/common/XCACodec.h
===================================================================
--- trunk/xiph-qt/common/XCACodec.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/common/XCACodec.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -48,48 +48,48 @@
class XCACodec : public ACBaseCodec
{
-public:
+ public:
XCACodec();
virtual ~XCACodec();
-
+
// AudioCodec interface
- virtual void ReallocateInputBuffer(UInt32 inInputBufferByteSize) { BDCReallocate(inInputBufferByteSize); };
- virtual UInt32 GetInputBufferByteSize() const { return BufferGetBytesSize(); };
- virtual UInt32 GetUsedInputBufferByteSize() const { return BufferGetUsedBytesSize(); };
+ virtual void ReallocateInputBuffer(UInt32 inInputBufferByteSize) { BDCReallocate(inInputBufferByteSize); };
+ virtual UInt32 GetInputBufferByteSize() const { return BufferGetBytesSize(); };
+ virtual UInt32 GetUsedInputBufferByteSize() const { return BufferGetUsedBytesSize(); };
- virtual void AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets,
- const AudioStreamPacketDescription* inPacketDescription);
- virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
- AudioStreamPacketDescription* outPacketDescription);
+ virtual void AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets,
+ const AudioStreamPacketDescription* inPacketDescription);
+ virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets,
+ AudioStreamPacketDescription* outPacketDescription);
#pragma mark Buffer/Decode/Convert interface
-protected:
- RingBuffer mBDCBuffer;
- BDCStatus mBDCStatus;
+ protected:
+ RingBuffer mBDCBuffer;
+ BDCStatus mBDCStatus;
- virtual void BDCInitialize(UInt32 inInputBufferByteSize);
- virtual void BDCUninitialize();
- virtual void BDCReset();
- virtual void BDCReallocate(UInt32 inInputBufferByteSize);
+ virtual void BDCInitialize(UInt32 inInputBufferByteSize);
+ virtual void BDCUninitialize();
+ virtual void BDCReset();
+ virtual void BDCReallocate(UInt32 inInputBufferByteSize);
- virtual BDCStatus BDCGetStatus() const { return mBDCStatus; };
+ virtual BDCStatus BDCGetStatus() const { return mBDCStatus; };
- virtual UInt32 BufferGetBytesSize() const;
- virtual UInt32 BufferGetUsedBytesSize() const;
- virtual UInt32 BufferGetAvailableBytesSize() const;
- virtual Boolean BufferIsEmpty() const;
+ virtual UInt32 BufferGetBytesSize() const;
+ virtual UInt32 BufferGetUsedBytesSize() const;
+ virtual UInt32 BufferGetAvailableBytesSize() const;
+ virtual Boolean BufferIsEmpty() const;
- virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription) = 0;
+ virtual void InPacket(const void* inInputData, const AudioStreamPacketDescription* inPacketDescription) = 0;
- virtual UInt32 FramesReady() const = 0;
- virtual Boolean GenerateFrames() = 0;
- virtual void OutputFrames(void* outOutputData, UInt32 inNumberFrames, UInt32 inFramesOffset) const = 0;
- virtual void Zap(UInt32 inFrames) = 0;
+ virtual UInt32 FramesReady() const = 0;
+ virtual Boolean GenerateFrames() = 0;
+ virtual void OutputFrames(void* outOutputData, UInt32 inNumberFrames, UInt32 inFramesOffset) const = 0;
+ virtual void Zap(UInt32 inFrames) = 0;
- virtual UInt32 InPacketsConsumed() const;
+ virtual UInt32 InPacketsConsumed() const;
};
Modified: trunk/xiph-qt/common/data_types.h
===================================================================
--- trunk/xiph-qt/common/data_types.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/common/data_types.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -40,31 +40,31 @@
// format specific cookie types
enum {
- kCookieTypeVorbisHeader = 'vCtH',
- kCookieTypeVorbisComments = 'vCt#',
- kCookieTypeVorbisCodebooks = 'vCtC'
+ kCookieTypeVorbisHeader = 'vCtH',
+ kCookieTypeVorbisComments = 'vCt#',
+ kCookieTypeVorbisCodebooks = 'vCtC'
};
enum {
- kCookieTypeSpeexHeader = 'sCtH',
- kCookieTypeSpeexComments = 'sCt#',
+ kCookieTypeSpeexHeader = 'sCtH',
+ kCookieTypeSpeexComments = 'sCt#',
kCookieTypeSpeexExtraHeader = 'sCtX'
};
struct OggSerialNoAtom {
- long size; // = sizeof(OggSerialNoAtom)
- long type; // = kOggCookieSerialNoType
- long serialno;
+ long size; // = sizeof(OggSerialNoAtom)
+ long type; // = kOggCookieSerialNoType
+ long serialno;
};
typedef struct OggSerialNoAtom OggSerialNoAtom;
struct CookieAtomHeader {
- long size;
- long type;
- unsigned char data[1];
+ long size;
+ long type;
+ unsigned char data[1];
};
typedef struct CookieAtomHeader CookieAtomHeader;
-#endif /* __data_types_h__ */
\ No newline at end of file
+#endif /* __data_types_h__ */
Modified: trunk/xiph-qt/common/fccs.h
===================================================================
--- trunk/xiph-qt/common/fccs.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/common/fccs.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -36,11 +36,11 @@
enum {
- kAudioFormatXiphVorbis = 'XiVs',
- kAudioFormatXiphOggFramedVorbis = 'XoVs',
+ kAudioFormatXiphVorbis = 'XiVs',
+ kAudioFormatXiphOggFramedVorbis = 'XoVs',
- kAudioFormatXiphSpeex = 'XiSp',
- kAudioFormatXiphOggFramedSpeex = 'XoSp'
+ kAudioFormatXiphSpeex = 'XiSp',
+ kAudioFormatXiphOggFramedSpeex = 'XoSp'
};
Modified: trunk/xiph-qt/utils/ringbuffer.cpp
===================================================================
--- trunk/xiph-qt/utils/ringbuffer.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/utils/ringbuffer.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -66,7 +66,7 @@
delete[] mBuffer;
mBuffer = NULL;
}
-
+
Reset();
}
@@ -94,14 +94,14 @@
UInt32 RingBuffer::GetSpaceAvailable() const {
UInt32 ret = mBSize;
-
+
if (mBStart > mBEnd)
ret = mBStart - mBEnd;
else if (mBEnd > mBStart)
ret = mBSize - mBEnd + mBStart;
-
+
return ret;
-
+
}
@@ -122,7 +122,7 @@
BlockMoveData(data, mBuffer + mBEnd, wrappedBytes);
BlockMoveData(dataSplit, mBuffer, mBEnd);
-
+
mNeedsWrapping = true;
}
Modified: trunk/xiph-qt/utils/ringbuffer.h
===================================================================
--- trunk/xiph-qt/utils/ringbuffer.h 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/utils/ringbuffer.h 2005-12-10 19:33:16 UTC (rev 10575)
@@ -36,34 +36,34 @@
class RingBuffer
{
-public:
+ public:
RingBuffer();
virtual ~RingBuffer();
-public:
- virtual void Initialize(UInt32 inBufferByteSize);
- virtual void Uninitialize();
- virtual void Reset();
+ public:
+ virtual void Initialize(UInt32 inBufferByteSize);
+ virtual void Uninitialize();
+ virtual void Reset();
- virtual UInt32 GetBufferByteSize() const;
- virtual UInt32 GetDataAvailable() const;
- virtual UInt32 GetSpaceAvailable() const;
+ virtual UInt32 GetBufferByteSize() const;
+ virtual UInt32 GetDataAvailable() const;
+ virtual UInt32 GetSpaceAvailable() const;
- virtual void In(const void* data, UInt32& ioBytes);
- virtual void Zap(UInt32 inBytes);
+ virtual void In(const void* data, UInt32& ioBytes);
+ virtual void Zap(UInt32 inBytes);
- virtual Byte * GetData();
- virtual Byte * GetDataEnd();
-
-protected:
- Byte * mBuffer;
+ virtual Byte * GetData();
+ virtual Byte * GetDataEnd();
- UInt32 mBStart;
- UInt32 mBEnd;
-
- UInt32 mBSize;
-
- Boolean mNeedsWrapping;
+ protected:
+ Byte * mBuffer;
+
+ UInt32 mBStart;
+ UInt32 mBEnd;
+
+ UInt32 mBSize;
+
+ Boolean mNeedsWrapping;
};
Modified: trunk/xiph-qt/utils/wrap_ogg.cpp
===================================================================
--- trunk/xiph-qt/utils/wrap_ogg.cpp 2005-12-10 16:22:13 UTC (rev 10574)
+++ trunk/xiph-qt/utils/wrap_ogg.cpp 2005-12-10 19:33:16 UTC (rev 10575)
@@ -36,31 +36,31 @@
{
if (inDataByteSize - inDataStartOffset < 27)
return false;
-
+
const Byte* data = static_cast<const Byte*> (inRawData) + inDataStartOffset;
-
+
if (memcmp(data, "OggS", 4) != 0)
return false;
-
+
UInt32 headerBytes = data[26] + 27;
-
+
if (inDataByteSize - inDataStartOffset < headerBytes)
return false;
-
+
UInt32 bodyBytes = 0;
UInt32 i;
-
+
/* just checking... */
for (i = 0; i < data[26]; i++) {
bodyBytes += data[27 + i];
}
if (bodyBytes > inDataByteSize - inDataStartOffset)
return false;
-
+
outOggPage->header = const_cast<unsigned char*> (data);
outOggPage->header_len = headerBytes;
outOggPage->body = const_cast<unsigned char*> (data + headerBytes);
outOggPage->body_len = bodyBytes;
-
+
return true;
}
More information about the commits
mailing list