[xiph-commits] r11224 - branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder

illiminable at svn.xiph.org illiminable at svn.xiph.org
Fri Apr 21 15:47:35 PDT 2006


Author: illiminable
Date: 2006-04-21 15:47:28 -0700 (Fri, 21 Apr 2006)
New Revision: 11224

Modified:
   branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.cpp
   branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.h
   branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/dsfVorbisDecoder.vcproj
Log:
* Vorbis decode filter, using new vorbis wrapper

Modified: branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.cpp
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.cpp	2006-04-21 21:34:40 UTC (rev 11223)
+++ branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.cpp	2006-04-21 22:47:28 UTC (rev 11224)
@@ -47,7 +47,7 @@
 												,	L"Vorbis In", inAcceptableMediaTypes
 											)
 	,	mBegun(false)
-	,	mFishSound(NULL)
+	//,	mFishSound(NULL)
 
 	,	mNumChannels(0)
 	,	mFrameSize(0)
@@ -94,20 +94,24 @@
 }
 bool VorbisDecodeInputPin::ConstructCodec() 
 {
-	mFishSound = fish_sound_new (FISH_SOUND_DECODE, &mFishInfo);			//Deleted by destroycodec from destructor.
+	return true;
+	//Vorbis decoder should be good to go
 
-	int i = 1;
-	//FIX::: Use new API for interleave setting
-	fish_sound_command(mFishSound, FISH_SOUND_SET_INTERLEAVE, &i, sizeof(int));
 
-	fish_sound_set_decoded_callback (mFishSound, VorbisDecodeInputPin::VorbisDecoded, this);
-	//FIX::: Proper return value
-	return true;
+	//mFishSound = fish_sound_new (FISH_SOUND_DECODE, &mFishInfo);			//Deleted by destroycodec from destructor.
+
+	//int i = 1;
+	////FIX::: Use new API for interleave setting
+	//fish_sound_command(mFishSound, FISH_SOUND_SET_INTERLEAVE, &i, sizeof(int));
+
+	//fish_sound_set_decoded_callback (mFishSound, VorbisDecodeInputPin::VorbisDecoded, this);
+	////FIX::: Proper return value
+	//return true;
 }
 void VorbisDecodeInputPin::DestroyCodec() 
 {
-	fish_sound_delete(mFishSound);
-	mFishSound = NULL;
+	//fish_sound_delete(mFishSound);
+	//mFishSound = NULL;
 }
 
 
@@ -133,63 +137,63 @@
 	return locHR;
 }
 
-int __cdecl VorbisDecodeInputPin::VorbisDecoded (FishSound* inFishSound, float** inPCM, long inFrames, void* inThisPointer) 
-{
-	
-	VorbisDecodeInputPin* locThis = reinterpret_cast<VorbisDecodeInputPin*> (inThisPointer);
-	VorbisDecodeFilter* locFilter = reinterpret_cast<VorbisDecodeFilter*>(locThis->m_pFilter);
+//int __cdecl VorbisDecodeInputPin::VorbisDecoded (FishSound* inFishSound, float** inPCM, long inFrames, void* inThisPointer) 
+//{
+//	
+//	VorbisDecodeInputPin* locThis = reinterpret_cast<VorbisDecodeInputPin*> (inThisPointer);
+//	VorbisDecodeFilter* locFilter = reinterpret_cast<VorbisDecodeFilter*>(locThis->m_pFilter);
+//
+//	if (locThis->CheckStreaming() == S_OK) {
+//
+//		unsigned long locActualSize = inFrames * locThis->mFrameSize;
+//		unsigned long locTotalFrameCount = inFrames * locThis->mNumChannels;
+//		unsigned long locBufferRemaining = DECODED_BUFFER_SIZE - locThis->mDecodedByteCount;
+//		
+//
+//
+//		//Create a pointer into the buffer		
+//		signed short* locShortBuffer = (signed short*)&locThis->mDecodedBuffer[locThis->mDecodedByteCount];
+//		
+//		
+//		signed short tempInt = 0;
+//		float tempFloat = 0;
+//		
+//		//FIX:::Move the clipping to the abstract function
+//
+//		if (locBufferRemaining >= locActualSize) {
+//			//Do float to int conversion with clipping
+//			const float SINT_MAX_AS_FLOAT = 32767.0f;
+//			for (unsigned long i = 0; i < locTotalFrameCount; i++) {
+//				//Clipping because vorbis puts out floats out of range -1 to 1
+//				if (((float*)inPCM)[i] <= -1.0f) {
+//					tempInt = SINT_MIN;	
+//				} else if (((float*)inPCM)[i] >= 1.0f) {
+//					tempInt = SINT_MAX;
+//				} else {
+//					//FIX:::Take out the unnescessary variable.
+//					tempFloat = ((( (float*) inPCM )[i]) * SINT_MAX_AS_FLOAT);
+//					//ASSERT((tempFloat <= 32767.0f) && (tempFloat >= -32786.0f));
+//					tempInt = (signed short)(tempFloat);
+//					//tempInt = (signed short) ((( (float*) inPCM )[i]) * SINT_MAX_AS_FLOAT);
+//				}
+//				
+//				*locShortBuffer = tempInt;
+//				locShortBuffer++;
+//			}
+//
+//			locThis->mDecodedByteCount += locActualSize;
+//			
+//			return 0;
+//		} else {
+//			throw 0;
+//		}
+//	} else {
+//		DbgLog((LOG_TRACE,1,TEXT("Fishsound sending stuff we aren't ready for...")));
+//		return -1;
+//	}
+//
+//}
 
-	if (locThis->CheckStreaming() == S_OK) {
-
-		unsigned long locActualSize = inFrames * locThis->mFrameSize;
-		unsigned long locTotalFrameCount = inFrames * locThis->mNumChannels;
-		unsigned long locBufferRemaining = DECODED_BUFFER_SIZE - locThis->mDecodedByteCount;
-		
-
-
-		//Create a pointer into the buffer		
-		signed short* locShortBuffer = (signed short*)&locThis->mDecodedBuffer[locThis->mDecodedByteCount];
-		
-		
-		signed short tempInt = 0;
-		float tempFloat = 0;
-		
-		//FIX:::Move the clipping to the abstract function
-
-		if (locBufferRemaining >= locActualSize) {
-			//Do float to int conversion with clipping
-			const float SINT_MAX_AS_FLOAT = 32767.0f;
-			for (unsigned long i = 0; i < locTotalFrameCount; i++) {
-				//Clipping because vorbis puts out floats out of range -1 to 1
-				if (((float*)inPCM)[i] <= -1.0f) {
-					tempInt = SINT_MIN;	
-				} else if (((float*)inPCM)[i] >= 1.0f) {
-					tempInt = SINT_MAX;
-				} else {
-					//FIX:::Take out the unnescessary variable.
-					tempFloat = ((( (float*) inPCM )[i]) * SINT_MAX_AS_FLOAT);
-					//ASSERT((tempFloat <= 32767.0f) && (tempFloat >= -32786.0f));
-					tempInt = (signed short)(tempFloat);
-					//tempInt = (signed short) ((( (float*) inPCM )[i]) * SINT_MAX_AS_FLOAT);
-				}
-				
-				*locShortBuffer = tempInt;
-				locShortBuffer++;
-			}
-
-			locThis->mDecodedByteCount += locActualSize;
-			
-			return 0;
-		} else {
-			throw 0;
-		}
-	} else {
-		DbgLog((LOG_TRACE,1,TEXT("Fishsound sending stuff we aren't ready for...")));
-		return -1;
-	}
-
-}
-
 STDMETHODIMP VorbisDecodeInputPin::Receive(IMediaSample* inSample) 
 {
 	CAutoLock locLock(mStreamLock);
@@ -313,19 +317,35 @@
 {
 	//TODO::: Return types !!!
 
-	//debugLog << "Decode called... Last Gran Pos : "<<mLastSeenStartGranPos<<endl;
-	DbgLog((LOG_TRACE,1,TEXT("decodeData")));
-	long locErr = fish_sound_decode(mFishSound, inBuf, inNumBytes);
-	//FIX::: Do something here ?
-	if (locErr < 0) {
-		DbgLog((LOG_TRACE,1,TEXT("decodeData : fishsound returns < 0")));
-		return S_FALSE;
-		//debugLog <<"** Fish Sound error **"<<endl;
-	} else {
+	VorbisDecoder::eVorbisResult locResult;
+	unsigned long locNumSamples = 0;
+	locResult = mVorbisDecoder.decodePacket(	inBuf
+											,	inNumBytes
+											,	(short*)(mDecodedBuffer + mDecodedByteCount)
+											,	DECODED_BUFFER_SIZE - mDecodedByteCount
+											,	&locNumSamples);
+
+	if (locResult == VorbisDecoder::VORBIS_DATA_OK) {
+		mDecodedByteCount += locNumSamples * mFrameSize;
 		return S_OK;
-		//debugLog << "Fish Sound OK >=0 "<<endl;
 	}
-	//return locErr;
+
+	//For now, just silently ignore busted packets.
+	return S_OK;
+
+	////debugLog << "Decode called... Last Gran Pos : "<<mLastSeenStartGranPos<<endl;
+	//DbgLog((LOG_TRACE,1,TEXT("decodeData")));
+	//long locErr = fish_sound_decode(mFishSound, inBuf, inNumBytes);
+	////FIX::: Do something here ?
+	//if (locErr < 0) {
+	//	DbgLog((LOG_TRACE,1,TEXT("decodeData : fishsound returns < 0")));
+	//	return S_FALSE;
+	//	//debugLog <<"** Fish Sound error **"<<endl;
+	//} else {
+	//	return S_OK;
+	//	//debugLog << "Fish Sound OK >=0 "<<endl;
+	//}
+	////return locErr;
 }
 
 
@@ -383,11 +403,17 @@
 }
 IOggDecoder::eAcceptHeaderResult VorbisDecodeInputPin::showHeaderPacket(OggPacket* inCodecHeaderPacket)
 {
+	unsigned long locDummy;
 	switch (mSetupState) {
 		case VSS_SEEN_NOTHING:
 			if (strncmp((char*)inCodecHeaderPacket->packetData(), "\001vorbis", 7) == 0) {
 				//TODO::: Possibly verify version
-				if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
+				//if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
+				if (mVorbisDecoder.decodePacket(		inCodecHeaderPacket->packetData()
+													,	inCodecHeaderPacket->packetSize()
+													,	NULL
+													,	0
+													,	&locDummy) == VorbisDecoder::VORBIS_HEADER_OK) {
 					mSetupState = VSS_SEEN_BOS;
 					debugLog<<"Saw first header"<<endl;
 					return IOggDecoder::AHR_MORE_HEADERS_TO_COME;
@@ -398,7 +424,13 @@
 			
 		case VSS_SEEN_BOS:
 			if (strncmp((char*)inCodecHeaderPacket->packetData(), "\003vorbis", 7) == 0) {
-				if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
+				//if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
+				if (mVorbisDecoder.decodePacket(		inCodecHeaderPacket->packetData()
+													,	inCodecHeaderPacket->packetSize()
+													,	NULL
+													,	0
+													,	&locDummy) == VorbisDecoder::VORBIS_COMMENT_OK) {
+
 					mSetupState = VSS_SEEN_COMMENT;
 					debugLog<<"Saw second header"<<endl;
 					return IOggDecoder::AHR_MORE_HEADERS_TO_COME;
@@ -411,15 +443,21 @@
 			
 		case VSS_SEEN_COMMENT:
 			if (strncmp((char*)inCodecHeaderPacket->packetData(), "\005vorbis", 7) == 0) {
-				if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
+				//if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
+				if (mVorbisDecoder.decodePacket(		inCodecHeaderPacket->packetData()
+													,	inCodecHeaderPacket->packetSize()
+													,	NULL
+													,	0
+													,	&locDummy) == VorbisDecoder::VORBIS_CODEBOOK_OK) {
+
 		
-					fish_sound_command (mFishSound, FISH_SOUND_GET_INFO, &(mFishInfo), sizeof (FishSoundInfo)); 
+					//fish_sound_command (mFishSound, FISH_SOUND_GET_INFO, &(mFishInfo), sizeof (FishSoundInfo)); 
 					//Is mBegun useful ?
 					mBegun = true;
 			
-					mNumChannels = mFishInfo.channels;
+					mNumChannels = mVorbisDecoder.numChannels();//mFishInfo.channels;
 					mFrameSize = mNumChannels * SIZE_16_BITS;
-					mSampleRate = mFishInfo.samplerate;
+					mSampleRate = mVorbisDecoder.sampleRate(); //mFishInfo.samplerate;
 
 		
 					mSetupState = VSS_ALL_HEADERS_SEEN;

Modified: branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.h
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.h	2006-04-21 21:34:40 UTC (rev 11223)
+++ branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/VorbisDecodeInputPin.h	2006-04-21 22:47:28 UTC (rev 11224)
@@ -44,10 +44,12 @@
 
 #include "VorbisDecodeFilter.h"
 
-extern "C" {
+#include "VorbisDecoder.h"
+
+//extern "C" {
 //#include <fishsound/fishsound.h>
-#include "fish_cdecl.h"
-}
+//#include "fish_cdecl.h"
+//}
 
 class VorbisDecodeOutputPin;
 
@@ -61,7 +63,7 @@
 	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
 	VorbisDecodeInputPin(AbstractTransformFilter* inFilter, CCritSec* inFilterLock, AbstractTransformOutputPin* inOutputPin, vector<CMediaType*> inAcceptableMediaTypes);
 	virtual ~VorbisDecodeInputPin(void);
-	static int __cdecl VorbisDecoded (FishSound* inFishSound, float** inPCM, long inFrames, void* inThisPointer);
+	//static int __cdecl VorbisDecoded (FishSound* inFishSound, float** inPCM, long inFrames, void* inThisPointer);
 
 	virtual HRESULT SetMediaType(const CMediaType* inMediaType);
 	virtual HRESULT CheckMediaType(const CMediaType *inMediaType);
@@ -114,17 +116,24 @@
 	virtual void DestroyCodec();
 	virtual HRESULT TransformData(unsigned char* inBuf, long inNumBytes);
 
+	
+
+	//TODO::: Are these needed?
+	bool mBegun;
+	unsigned int mUptoFrame;
 	HRESULT mHR;
-	bool mBegun;
+	//FishSound* mFishSound;
+	//FishSoundInfo mFishInfo; 
 
-	FishSound* mFishSound;
-	FishSoundInfo mFishInfo; 
-
 	int mNumChannels;
 	int mFrameSize;
 	int mSampleRate;
-	unsigned int mUptoFrame;
 
+	VorbisDecoder mVorbisDecoder;
+
+
+	
+
 	unsigned char* mDecodedBuffer;
 	unsigned long mDecodedByteCount;
 

Modified: branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/dsfVorbisDecoder.vcproj
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/dsfVorbisDecoder.vcproj	2006-04-21 21:34:40 UTC (rev 11223)
+++ branches/oggdsf_ce_port/src/lib/codecs/vorbis/filters/dsfVorbisDecoder/dsfVorbisDecoder.vcproj	2006-04-21 22:47:28 UTC (rev 11224)
@@ -47,7 +47,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\..\core\directshow\BaseClasses;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\helper\libfishsound\include;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\..\..\core\directshow\dsfOggDemux2"
+				AdditionalIncludeDirectories="..\..\..\..\core\directshow\BaseClasses;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\helper;..\..\..\..\core\directshow\dsfOggDemux2;..\..\libs\libOOVorbis;..\..\libs\libvorbis\include;..\..\..\..\core\ogg\libogg\include"
 				PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_WINDOWS;_USRDLL;DSFVORBISDECODER_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -298,7 +298,7 @@
 				EnableIntrinsicFunctions="true"
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="true"
-				AdditionalIncludeDirectories="..\..\..\..\core\directshow\BaseClasses;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\helper\libfishsound\include;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\..\..\core\directshow\dsfOggDemux2"
+				AdditionalIncludeDirectories="..\..\..\..\core\directshow\BaseClasses;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\helper;..\..\..\..\core\directshow\dsfOggDemux2;..\..\libs\libOOVorbis;..\..\libs\libvorbis\include;..\..\..\..\core\ogg\libogg\include"
 				PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;NDEBUG;_WINDOWS;_USRDLL;DSFVORBISDECODER_EXPORTS"
 				StringPooling="true"
 				RuntimeLibrary="2"
@@ -808,7 +808,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\..\core\directshow\BaseClasses;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\helper\libfishsound\include;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\..\..\core\directshow\dsfOggDemux2"
+				AdditionalIncludeDirectories="..\..\..\..\core\directshow\BaseClasses;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\helper;..\..\..\..\core\directshow\dsfOggDemux2;..\..\libs\libOOVorbis;..\..\libs\libvorbis\include;..\..\..\..\core\ogg\libogg\include"
 				PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_WINDOWS;_USRDLL;DSFVORBISDECODER_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
@@ -1056,7 +1056,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\..\..\core\directshow\BaseClasses;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\helper\libfishsound\include;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\..\..\core\directshow\dsfOggDemux2"
+				AdditionalIncludeDirectories="..\..\..\..\core\directshow\BaseClasses;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\helper;..\..\..\..\core\directshow\dsfOggDemux2;..\..\libs\libOOVorbis;..\..\libs\libvorbis\include;..\..\..\..\core\ogg\libogg\include"
 				PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;WIN32;_DEBUG;_WINDOWS;_USRDLL;DSFVORBISDECODER_EXPORTS"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"



More information about the commits mailing list