[xiph-commits] r11235 - branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder

illiminable at svn.xiph.org illiminable at svn.xiph.org
Sat Apr 22 08:20:35 PDT 2006


Author: illiminable
Date: 2006-04-22 08:20:24 -0700 (Sat, 22 Apr 2006)
New Revision: 11235

Modified:
   branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeFilter.cpp
   branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeFilter.h
   branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeInputPin.cpp
   branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeInputPin.h
   branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeOutputPin.cpp
   branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeOutputPin.h
Log:
* Tidy up speex decode filter, add some more doc, remove some dead code

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeFilter.cpp
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeFilter.cpp	2006-04-22 04:57:02 UTC (rev 11234)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeFilter.cpp	2006-04-22 15:20:24 UTC (rev 11235)
@@ -1,5 +1,5 @@
 //===========================================================================
-//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//Copyright (C) 2003-2006 Zentaro Kavanagh
 //
 //Redistribution and use in source and binary forms, with or without
 //modification, are permitted provided that the following conditions
@@ -56,6 +56,7 @@
 int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); 
 
 
+
 #ifdef WINCE
 LPAMOVIESETUP_FILTER SpeexDecodeFilter::GetSetupData()
 {	
@@ -100,9 +101,6 @@
 	locAcceptMediaType = NULL;
 	locAcceptMediaType = new CMediaType(&MEDIATYPE_OggPacketStream);			//Deleted by pin
 
-	//locAcceptMediaType->subtype = MEDIASUBTYPE_Speex;
-	//locAcceptMediaType->formattype = FORMAT_Speex;
-
 	locAcceptMediaType->subtype = MEDIASUBTYPE_None;
 	locAcceptMediaType->formattype = FORMAT_OggIdentHeader;
 

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeFilter.h
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeFilter.h	2006-04-22 04:57:02 UTC (rev 11234)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeFilter.h	2006-04-22 15:20:24 UTC (rev 11235)
@@ -1,5 +1,5 @@
 //===========================================================================
-//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//Copyright (C) 2003-2006 Zentaro Kavanagh
 //
 //Redistribution and use in source and binary forms, with or without
 //modification, are permitted provided that the following conditions
@@ -54,18 +54,23 @@
 	SpeexDecodeFilter(void);
 	virtual ~SpeexDecodeFilter(void);
 
-	//COM Creator Function
+	///COM CreateInstance Function
 	static CUnknown* WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
 
 	
-	//FIX::: Do we need these ? Aren't they all friends ??
+	//TODO::: Do we need these ? Aren't they all friends ?? Should set be public?
+
+	///Gets the speex format block
 	virtual sSpeexFormatBlock* getSpeexFormatBlock();
+
+	///Sets the speex format block
 	virtual void setSpeexFormat(BYTE* inFormatBlock);
 
 #ifdef WINCE
-	virtual LPAMOVIESETUP_FILTER GetSetupData(); //		{	return (LPAMOVIESETUP_FILTER)&VorbisDecodeFilterReg;	}
+	virtual LPAMOVIESETUP_FILTER GetSetupData();
 	virtual HRESULT Register();
 #endif
+
 protected:
 	//Pure Virtuals from AbstracttransformFilter
 	virtual bool ConstructPins();

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeInputPin.cpp
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeInputPin.cpp	2006-04-22 04:57:02 UTC (rev 11234)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeInputPin.cpp	2006-04-22 15:20:24 UTC (rev 11235)
@@ -1,5 +1,5 @@
 //===========================================================================
-//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//Copyright (C) 2003-2006 Zentaro Kavanagh
 //
 //Redistribution and use in source and binary forms, with or without
 //modification, are permitted provided that the following conditions
@@ -35,8 +35,6 @@
 
 SpeexDecodeInputPin::SpeexDecodeInputPin(AbstractTransformFilter* inFilter, CCritSec* inFilterLock, AbstractTransformOutputPin* inOutputPin, vector<CMediaType*> inAcceptableMediaTypes)
 	:	AbstractTransformInputPin(inFilter, inFilterLock, inOutputPin, NAME("SpeexDecodeInputPin"), L"Speex In", inAcceptableMediaTypes)
-	//FSN:::
-	//,	mFishSound(NULL)
 
 	,	mNumChannels(0)
 	,	mSampleFrameSize(0)
@@ -46,6 +44,7 @@
 
 	,	mDecodedByteCount(0)
 	,	mDecodedBuffer(NULL)
+
 	,	mRateNumerator(RATE_DENOMINATOR)
 
 	,	mSetupState(VSS_SEEN_NOTHING)
@@ -64,32 +63,21 @@
 	//Don't need to do much... mSpeexDecoder is good to go
 	return true;
 
-	////FSN:::
-	//mFishSound = fish_sound_new (FISH_SOUND_DECODE, &mFishInfo);
-
-	//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, SpeexDecodeInputPin::SpeexDecoded, this);
-	//FIX::: Proper return value
-	//return true;
 }
 void SpeexDecodeInputPin::DestroyCodec() 
 {
-	//FSN:::
-	//fish_sound_delete(mFishSound);
-	//mFishSound = NULL;
+
 }
 SpeexDecodeInputPin::~SpeexDecodeInputPin(void)
 {
 	DestroyCodec();
 
-	delete mDecodedBuffer;
+	delete[] mDecodedBuffer;
 }
 
 STDMETHODIMP SpeexDecodeInputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)
 {
+	//TODO::: Make the IOggDecoder interface a proper COM interface
 	if (riid == IID_IMediaSeeking) {
 		*ppv = (IMediaSeeking*)this;
 		((IUnknown*)*ppv)->AddRef();
@@ -109,6 +97,7 @@
 	//debugLog<<"New segment "<<inStartTime<<" - "<<inStopTime<<endl;
 	mUptoFrame = 0;
 
+	//Denominator and numerator are a 16 bit fraction
 	mRateNumerator = RATE_DENOMINATOR * inRate;
 	if (mRateNumerator > RATE_DENOMINATOR) {
 		mRateNumerator = RATE_DENOMINATOR;
@@ -133,65 +122,12 @@
 
 	return S_OK;
 }
-//int SpeexDecodeInputPin::SpeexDecoded (FishSound* inFishSound, float** inPCM, long inFrames, void* inThisPointer) 
-//{
-//
-//	SpeexDecodeInputPin* locThis = reinterpret_cast<SpeexDecodeInputPin*> (inThisPointer);
-//	SpeexDecodeFilter* locFilter = reinterpret_cast<SpeexDecodeFilter*>(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;
-//	}
-//
-//}
 
+
 STDMETHODIMP SpeexDecodeInputPin::Receive(IMediaSample* inSample) 
 {
+	//TODO::: All the internal buffer handling should be abstracted - it's duped in vorbis speex and flac
+	//TODO::: Document the buffer end point cutting better
 	CAutoLock locLock(mStreamLock);
 
 	HRESULT locHR = CheckStreaming();
@@ -296,13 +232,6 @@
 
 HRESULT SpeexDecodeInputPin::TransformData(BYTE* inBuf, long inNumBytes) 
 {
-	////FSN:::
-	//long locErr = fish_sound_decode(mFishSound, inBuf, inNumBytes);
-	//if (locErr == 0) {
-	//	return S_OK;
-	//} else {
-	//	return S_FALSE;
-	//}
 
 	//TODO::: Verify size of remaining buffer
 	SpeexDecoder::eSpeexResult locResult;
@@ -324,8 +253,6 @@
 
 HRESULT SpeexDecodeInputPin::SetMediaType(const CMediaType* inMediaType) 
 {
-	//FIX:::Error checking
-	//RESOLVED::: Bit better.
 	if (CheckMediaType(inMediaType) == S_OK) {
 		((SpeexDecodeFilter*)mParentFilter)->setSpeexFormat(inMediaType->pbFormat);
 		
@@ -365,6 +292,7 @@
 	//TODO::: Get adjustment from block size info... for now, it doesn't matter if no preroll
 	return inGranule;
 }
+
 IOggDecoder::eAcceptHeaderResult SpeexDecodeInputPin::showHeaderPacket(OggPacket* inCodecHeaderPacket)
 {
 	switch (mSetupState) {
@@ -372,10 +300,7 @@
 			if (strncmp((char*)inCodecHeaderPacket->packetData(), "Speex   ", 8) == 0) {
 				//TODO::: Possibly verify version
 
-				//FSN:::
-				//if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
 				if (mSpeexDecoder.decodePacket(	inCodecHeaderPacket->packetData(),	inCodecHeaderPacket->packetSize(),	NULL, 0) == SpeexDecoder::SPEEX_HEADER_OK) {
-					 
 					mSetupState = VSS_SEEN_BOS;
 					return IOggDecoder::AHR_MORE_HEADERS_TO_COME;
 				}
@@ -385,31 +310,22 @@
 			
 		case VSS_SEEN_BOS:
 			//The comment packet can't be easily identified in speex.
-			//Just ignore the second packet we see, and hope fishsound does better.
+			//Just ignore the second packet we see, and hope for the best
 
-			//if (strncmp((char*)inCodecHeaderPacket->packetData(), "\003vorbis", 7) == 0) {
-			//FSN:::
-				//if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
 			if (mSpeexDecoder.decodePacket(	inCodecHeaderPacket->packetData(),	inCodecHeaderPacket->packetSize(),	NULL, 0) == SpeexDecoder::SPEEX_COMMENT_OK) {
-					mSetupState = VSS_ALL_HEADERS_SEEN;
+				mSetupState = VSS_ALL_HEADERS_SEEN;
 
-					//FSN:::
-					//fish_sound_command (mFishSound, FISH_SOUND_GET_INFO, &(mFishInfo), sizeof (FishSoundInfo)); 
-					mBegun = true;
-			
-					mNumChannels = mSpeexDecoder.numChannels();//mFishInfo.channels;
-					mSampleFrameSize = mNumChannels * SIZE_16_BITS;
-					mSampleRate = mSpeexDecoder.sampleRate(); //mFishInfo.samplerate;
-					mSpeexFrameSize = mSampleFrameSize * mSpeexDecoder.frameSize();
+				mBegun = true;
+		
+				mNumChannels = mSpeexDecoder.numChannels();//mFishInfo.channels;
+				mSampleFrameSize = mNumChannels * SIZE_16_BITS;
+				mSampleRate = mSpeexDecoder.sampleRate(); //mFishInfo.samplerate;
+				mSpeexFrameSize = mSampleFrameSize * mSpeexDecoder.frameSize();
 
-					return IOggDecoder::AHR_ALL_HEADERS_RECEIVED;
-				}
+				return IOggDecoder::AHR_ALL_HEADERS_RECEIVED;
+			}
 				
-				
-			//}
 			return IOggDecoder::AHR_INVALID_HEADER;
-			
-			
 	
 		case VSS_ALL_HEADERS_SEEN:
 		case VSS_ERROR:
@@ -421,9 +337,10 @@
 {
 	return "speex";
 }
+
 string SpeexDecodeInputPin::getCodecIdentString()
 {
-	//TODO:::
+	//TODO::: Get the full ident string from the decoder
 	return "speex";
 }
 

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeInputPin.h
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeInputPin.h	2006-04-22 04:57:02 UTC (rev 11234)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeInputPin.h	2006-04-22 15:20:24 UTC (rev 11235)
@@ -1,5 +1,5 @@
 //===========================================================================
-//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//Copyright (C) 2003-2006 Zentaro Kavanagh
 //
 //Redistribution and use in source and binary forms, with or without
 //modification, are permitted provided that the following conditions
@@ -39,11 +39,7 @@
 
 #include "SpeexDecoder.h"
 
-//extern "C" {
-////#include <fishsound/fishsound.h>
-//#include "fish_cdecl.h"
-//}
-
+//Forward declaration
 class SpeexDecodeOutputPin;
 
 class SpeexDecodeInputPin 
@@ -53,26 +49,44 @@
 public:
 	DECLARE_IUNKNOWN
 	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
-	SpeexDecodeInputPin(AbstractTransformFilter* inFilter, CCritSec* inFilterLock, AbstractTransformOutputPin* inOutputPin, vector<CMediaType*> inAcceptableMediaTypes);
+
+	SpeexDecodeInputPin(		AbstractTransformFilter* inFilter
+							,	CCritSec* inFilterLock
+							,	AbstractTransformOutputPin* inOutputPin
+							,	vector<CMediaType*> inAcceptableMediaTypes);
 	virtual ~SpeexDecodeInputPin(void);
 	
-	//static int __cdecl SpeexDecoded (FishSound* inFishSound, float** inPCM, long inFrames, void* inThisPointer);
+	///Called when the connection type is determined
+	virtual HRESULT SetMediaType(const CMediaType* inMediaType);
 
+	///Called to check if the media type is acceptable to this pin
+	virtual HRESULT CheckMediaType(const CMediaType *inMediaType);
 
-	virtual HRESULT SetMediaType(const CMediaType* inMediaType);
-	virtual HRESULT CheckMediaType(const CMediaType *inMediaType);
+	///New segment messages pass downstream to inform a new segment is about to play
 	virtual STDMETHODIMP NewSegment(REFERENCE_TIME inStartTime, REFERENCE_TIME inStopTime, double inRate);
+
+	///Called at the end of a flush operation
 	virtual STDMETHODIMP EndFlush();
 
+	///Called by the connecting pin to ask this pins buffer requirements
 	virtual STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *outRequestedProps);
 
+	///Receive is the main data path, data travels downstream through successive Receive's
 	virtual STDMETHODIMP Receive(IMediaSample* inSample);
 
-	//IOggDecoder Interface
+	///Called by upstream(demux) to get a conversion from granules to time
 	virtual LOOG_INT64 convertGranuleToTime(LOOG_INT64 inGranule);
+
+	///Called by upstream to determine preroll data, ie how far back to seek to decode the given granule
 	virtual LOOG_INT64 mustSeekBefore(LOOG_INT64 inGranule);
+
+	///Called during pin setup to prime the decoder
 	virtual IOggDecoder::eAcceptHeaderResult showHeaderPacket(OggPacket* inCodecHeaderPacket);
+
+	///Returns the short name for this codec "speex"
 	virtual string getCodecShortName();
+
+	///Returns the codec ident string, could include version, build etc info. Purely for display purposes.
 	virtual string getCodecIdentString();
 
 
@@ -85,11 +99,12 @@
 	//Implementation of pure virtuals from AbstractTransformInputPin
 	virtual bool ConstructCodec();
 	virtual void DestroyCodec();
+
+	///Internal method for doing decoding into the main buffer
 	virtual HRESULT TransformData(unsigned char* inBuf, long inNumBytes);
 
-	//FSN:::
-	//FishSound* mFishSound;
-	//FishSoundInfo mFishInfo; 
+	unsigned char* mDecodedBuffer;
+	unsigned long mDecodedByteCount;
 
 	SpeexDecoder mSpeexDecoder;
 
@@ -102,9 +117,6 @@
 	unsigned int mUptoFrame;
 	bool mBegun;
 
-	unsigned char* mDecodedBuffer;
-	unsigned long mDecodedByteCount;
-
 	enum eSpeexSetupState {
 		VSS_SEEN_NOTHING,
 		VSS_SEEN_BOS,
@@ -118,6 +130,4 @@
 	__int64 mRateNumerator;
 	static const __int64 RATE_DENOMINATOR = 65536;
 
-
-
 };

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeOutputPin.cpp
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeOutputPin.cpp	2006-04-22 04:57:02 UTC (rev 11234)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeOutputPin.cpp	2006-04-22 15:20:24 UTC (rev 11235)
@@ -1,5 +1,5 @@
 //===========================================================================
-//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//Copyright (C) 2003-2006 Zentaro Kavanagh
 //
 //Redistribution and use in source and binary forms, with or without
 //modification, are permitted provided that the following conditions
@@ -32,12 +32,22 @@
 #include "stdafx.h"
 #include "speexdecodeoutputpin.h"
 
-SpeexDecodeOutputPin::SpeexDecodeOutputPin(SpeexDecodeFilter* inParentFilter, CCritSec* inFilterLock, vector<CMediaType*> inAcceptableMediaTypes)
-	: AbstractTransformOutputPin(inParentFilter, inFilterLock,NAME("SpeexDecodeOutputPin"), L"PCM Out", 65536, 20, inAcceptableMediaTypes)
+SpeexDecodeOutputPin::SpeexDecodeOutputPin(		SpeexDecodeFilter* inParentFilter
+											,	CCritSec* inFilterLock
+											,	vector<CMediaType*> inAcceptableMediaTypes)
+
+	: AbstractTransformOutputPin(		inParentFilter
+									,	inFilterLock
+									,	NAME("SpeexDecodeOutputPin")
+									,	L"PCM Out"
+									,	65536
+									,	20
+									,	inAcceptableMediaTypes)
 {
 
 		
 }
+
 SpeexDecodeOutputPin::~SpeexDecodeOutputPin(void)
 {
 	
@@ -54,6 +64,7 @@
 
 	return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv); 
 }
+
 HRESULT SpeexDecodeOutputPin::CreateAndFillFormatBuffer(CMediaType* outMediaType, int inPosition)
 {
 	if (inPosition == 0) {

Modified: branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeOutputPin.h
===================================================================
--- branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeOutputPin.h	2006-04-22 04:57:02 UTC (rev 11234)
+++ branches/oggdsf_ce_port/src/lib/codecs/speex/filters/dsfSpeexDecoder/SpeexDecodeOutputPin.h	2006-04-22 15:20:24 UTC (rev 11235)
@@ -1,5 +1,5 @@
 //===========================================================================
-//Copyright (C) 2003, 2004 Zentaro Kavanagh
+//Copyright (C) 2003-2006 Zentaro Kavanagh
 //
 //Redistribution and use in source and binary forms, with or without
 //modification, are permitted provided that the following conditions
@@ -35,6 +35,8 @@
 
 
 class SpeexDecodeFilter;
+
+
 class SpeexDecodeOutputPin :
 	public AbstractTransformOutputPin
 {
@@ -48,8 +50,8 @@
 	SpeexDecodeOutputPin(SpeexDecodeFilter* inParentFilter,CCritSec* inFilterLock, vector<CMediaType*> inAcceptableMediaTypes);
 	virtual ~SpeexDecodeOutputPin(void);
 
-	//virtual bool FillWaveFormatExBuffer(WAVEFORMATEX* inFormatBuffer);
 protected:
+	///Internal method to setup format buffer
 	virtual HRESULT CreateAndFillFormatBuffer(CMediaType* outMediaType, int inPosition);
 
 };



More information about the commits mailing list