[xiph-commits] r10356 - in branches/oggdsf_new_demux/src/lib/codecs/flac: filters/dsfFLACDecoder libs/libFLACHelper

illiminable at svn.xiph.org illiminable at svn.xiph.org
Mon Nov 7 23:30:00 PST 2005


Author: illiminable
Date: 2005-11-07 23:29:49 -0800 (Mon, 07 Nov 2005)
New Revision: 10356

Modified:
   branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.cpp
   branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.h
   branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp
   branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h
   branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACdecoderdllstuff.h
   branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/dsfFLACDecoder.vcproj
   branches/oggdsf_new_demux/src/lib/codecs/flac/libs/libFLACHelper/FLACPushDecoder.h
Log:
* Sample accurate seeking in ogg flac classic.
* All codecs converted to new format, except support for new ogg flac 1.0

Modified: branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.cpp	2005-11-07 16:40:16 UTC (rev 10355)
+++ branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.cpp	2005-11-08 07:29:49 UTC (rev 10356)
@@ -84,8 +84,9 @@
 	locAcceptMediaType = NULL;
 	locAcceptMediaType = new CMediaType(&MEDIATYPE_Audio);			//Deleted by pin
 
-	locAcceptMediaType->subtype = MEDIASUBTYPE_FLAC;
-	locAcceptMediaType->formattype = FORMAT_FLAC;
+	locAcceptMediaType->majortype = MEDIATYPE_OggPacketStream;
+	locAcceptMediaType->subtype = MEDIASUBTYPE_None;
+	locAcceptMediaType->formattype = FORMAT_OggIdentHeader;
 
 	locAcceptableTypes.push_back(locAcceptMediaType);
 	
@@ -108,9 +109,26 @@
 {
 	return mFLACFormatBlock;
 }
-void FLACDecodeFilter::setFLACFormatBlock(sFLACFormatBlock* inFormatBlock) 
+void FLACDecodeFilter::setFLACFormatBlock(BYTE* inFormatBlock) 
 {
 	delete mFLACFormatBlock;
 	mFLACFormatBlock = new sFLACFormatBlock;		//Deleted in destructor.
-	*mFLACFormatBlock = *inFormatBlock;
+
+	const unsigned char FLAC_CHANNEL_MASK = 14;  //00001110
+	const unsigned char FLAC_BPS_START_MASK = 1; //00000001
+	const unsigned char FLAC_BPS_END_MASK = 240;  //11110000
+	mFLACFormatBlock = new sFLACFormatBlock;
+	//Fix the format block data... use header version and other version.
+	//mFLACFormatBlock->FLACVersion = FLACMath::charArrToULong(mCodecHeaders->getPacket(1)->packetData() + 28);
+
+
+	//This is ogg flac classic
+	mFLACFormatBlock->numChannels = (((inFormatBlock[20]) & FLAC_CHANNEL_MASK) >> 1) + 1;
+	mFLACFormatBlock->samplesPerSec = (iBE_Math::charArrToULong(inFormatBlock + 18)) >> 12;
+	
+	mFLACFormatBlock->numBitsPerSample =	(((inFormatBlock[20] & FLAC_BPS_START_MASK) << 4)	|
+											((inFormatBlock[21] & FLAC_BPS_END_MASK) >> 4)) + 1;	
+
+	//*mFLACFormatBlock = *inFormatBlock;
+
 }
\ No newline at end of file

Modified: branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.h	2005-11-07 16:40:16 UTC (rev 10355)
+++ branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeFilter.h	2005-11-08 07:29:49 UTC (rev 10356)
@@ -36,6 +36,8 @@
 //External INcludes
 #include "FLAC++/decoder.h"
 
+#include <libilliCore/iBE_Math.h>
+
 class FLACDecodeFilter
 	//Base Classes
 	:	public AbstractTransformFilter
@@ -52,8 +54,8 @@
 	//COM Creator Function
 	static CUnknown* WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr);
 
-	void FLACDecodeFilter::setFLACFormatBlock(sFLACFormatBlock* inFormatBlock) ;
-	sFLACFormatBlock* FLACDecodeFilter::getFLACFormatBlock();
+	void setFLACFormatBlock(BYTE* inFormatBlock) ;
+	sFLACFormatBlock* getFLACFormatBlock();
 protected:
 	//Implemenation of Pue Virtuals from AbstractTransformFilter
 	virtual bool ConstructPins();

Modified: branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp	2005-11-07 16:40:16 UTC (rev 10355)
+++ branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp	2005-11-08 07:29:49 UTC (rev 10356)
@@ -36,6 +36,12 @@
 	:	AbstractTransformInputPin(inParentFilter, inFilterLock, inOutputPin, NAME("FLACDecodeInputPin"), L"FLAC In", inAcceptableMediaTypes)
 	,	mGotMetaData(false)
 	,	mCodecLock(NULL)
+	,	mFLACType(FT_UNKNOWN)
+	,	mMetadataPacket(NULL)
+	,	mSetupState(VSS_SEEN_NOTHING)
+	,	mDecodedByteCount(0)
+	,	mDecodedBuffer(NULL)
+	,	mRateNumerator(RATE_DENOMINATOR)
 
 	,	mUptoFrame(0)
 
@@ -43,12 +49,16 @@
 	//debugLog.open("G:\\logs\\flacfilter.log", ios_base::out);
 	mCodecLock = new CCritSec;			//Deleted in destructor.
 	ConstructCodec();
+
+	mDecodedBuffer = new unsigned char[DECODED_BUFFER_SIZE];
 }
 
 FLACDecodeInputPin::~FLACDecodeInputPin(void)
 {
 	//debugLog.close();
 	delete mCodecLock;
+	delete mMetadataPacket;
+	delete mDecodedBuffer;
 	
 }
 
@@ -58,6 +68,11 @@
 		*ppv = (IMediaSeeking*)this;
 		((IUnknown*)*ppv)->AddRef();
 		return NOERROR;
+	} else if (riid == IID_IOggDecoder) {
+		*ppv = (IOggDecoder*)this;
+		//((IUnknown*)*ppv)->AddRef();
+		return NOERROR;
+
 	}
 
 	return CBaseInputPin::NonDelegatingQueryInterface(riid, ppv); 
@@ -80,11 +95,185 @@
 	return AbstractTransformInputPin::NewSegment(inStartTime, inStopTime, inRate);
 	
 }
+
+
+
+STDMETHODIMP FLACDecodeInputPin::Receive(IMediaSample* inSample) 
+{
+	CAutoLock locLock(mStreamLock);
+
+	HRESULT locHR = CheckStreaming();
+
+	if (locHR == S_OK) {
+		BYTE* locBuff = NULL;
+		locHR = inSample->GetPointer(&locBuff);
+
+		if ((inSample->GetActualDataLength() > 1) && ((locBuff[0] != 0xff) || (locBuff[1] != 0xf8))) {
+			//inInputSample->Release();
+
+			//This is a header, so ignore it
+			return S_OK;
+		}
+
+
+
+		if (locHR != S_OK) {
+			//TODO::: Do a debug dump or something here with specific error info.
+			return locHR;
+		} else {
+			REFERENCE_TIME locStart = -1;
+			REFERENCE_TIME locEnd = -1;
+			__int64 locSampleDuration = 0;
+			inSample->GetTime(&locStart, &locEnd);
+
+			HRESULT locResult = TransformData(locBuff, inSample->GetActualDataLength());
+			if (locResult != S_OK) {
+				return S_FALSE;
+			}
+			if (locEnd > 0) {
+				//Can dump it all downstream now	
+				IMediaSample* locSample;
+				unsigned long locBytesCopied = 0;
+				unsigned long locBytesToCopy = 0;
+
+				locStart = convertGranuleToTime(locEnd) - (((mDecodedByteCount / mFLACDecoder.mFrameSize) * UNITS) / mFLACDecoder.mSampleRate);
+				do {
+					HRESULT locHR = mOutputPin->GetDeliveryBuffer(&locSample, NULL, NULL, NULL);
+					if (locHR != S_OK) {
+						return locHR;
+					}
+
+					BYTE* locBuffer = NULL;
+					locHR = locSample->GetPointer(&locBuffer);
+				
+					if (locHR != S_OK) {
+						return locHR;
+					}
+
+					locBytesToCopy = ((mDecodedByteCount - locBytesCopied) <= locSample->GetSize()) ? (mDecodedByteCount - locBytesCopied) : locSample->GetSize();
+					//locBytesCopied += locBytesToCopy;
+
+					locSampleDuration = (((locBytesToCopy/mFLACDecoder.mFrameSize) * UNITS) / mFLACDecoder.mSampleRate);
+					locEnd = locStart + locSampleDuration;
+
+					//Adjust the time stamps for rate and seeking
+					REFERENCE_TIME locAdjustedStart = (locStart * RATE_DENOMINATOR) / mRateNumerator;
+					REFERENCE_TIME locAdjustedEnd = (locEnd * RATE_DENOMINATOR) / mRateNumerator;
+					locAdjustedStart -= m_tStart;
+					locAdjustedEnd -= m_tStart;
+
+					__int64 locSeekStripOffset = 0;
+					if (locAdjustedEnd < 0) {
+						locSample->Release();
+					} else {
+						if (locAdjustedStart < 0) {
+							locSeekStripOffset = (-locAdjustedStart) * mFLACDecoder.mSampleRate;
+							locSeekStripOffset *= mFLACDecoder.mFrameSize;
+							locSeekStripOffset /= UNITS;
+							locSeekStripOffset += (mFLACDecoder.mFrameSize - (locSeekStripOffset % mFLACDecoder.mFrameSize));
+							__int64 locStrippedDuration = (((locSeekStripOffset/mFLACDecoder.mFrameSize) * UNITS) / mFLACDecoder.mSampleRate);
+							locAdjustedStart += locStrippedDuration;
+						}
+							
+
+					
+
+						memcpy((void*)locBuffer, (const void*)&mDecodedBuffer[locBytesCopied + locSeekStripOffset], locBytesToCopy - locSeekStripOffset);
+
+						locSample->SetTime(&locAdjustedStart, &locAdjustedEnd);
+						locSample->SetMediaTime(&locStart, &locEnd);
+						locSample->SetSyncPoint(TRUE);
+						locSample->SetActualDataLength(locBytesToCopy - locSeekStripOffset);
+						locHR = ((FLACDecodeOutputPin*)(mOutputPin))->mDataQueue->Receive(locSample);
+						if (locHR != S_OK) {
+							return locHR;
+						}
+						locStart += locSampleDuration;
+
+					}
+					locBytesCopied += locBytesToCopy;
+
+				
+				} while(locBytesCopied < mDecodedByteCount);
+
+				mDecodedByteCount = 0;
+				
+			}
+			return S_OK;
+
+		}
+	} else {
+		//Not streaming - Bail out.
+		return S_FALSE;
+	}
+}
+
+
+
+
 HRESULT FLACDecodeInputPin::TransformData(BYTE* inBuf, long inNumBytes) 
 {
 
-	//TODO::: Locks ???
+	if (CheckStreaming() == S_OK) {
+		unsigned char* locInBuff = new unsigned char[inNumBytes];
+		memcpy((void*)locInBuff, (const void*)inBuf, inNumBytes);
+		OggPacket* locInputPacket = new OggPacket(locInBuff, inNumBytes, false, false);
 
+	
+		StampedOggPacket* locStamped = (StampedOggPacket*)mFLACDecoder.decodeFLAC(locInputPacket)->clone();
+
+		FLACDecodeFilter* locFilter = reinterpret_cast<FLACDecodeFilter*>(m_pFilter);
+
+	
+
+		unsigned long locActualSize = locStamped->packetSize();
+		//unsigned long locTotalFrameCount = inFrames * locThis->mNumChannels;
+		unsigned long locBufferRemaining = DECODED_BUFFER_SIZE - mDecodedByteCount;
+		
+
+
+		//Create a pointer into the buffer		
+		//signed short* locShortBuffer = (signed short*)&mDecodedBuffer[mDecodedByteCount];
+		
+		
+		//signed short tempInt = 0;
+		//float tempFloat = 0;
+		
+		//FIX:::Move the clipping to the abstract function
+
+		if (locBufferRemaining >= locActualSize) {
+			
+			memcpy((void*)&mDecodedBuffer[mDecodedByteCount], (const void*)locStamped->packetData(), locActualSize);
+
+			mDecodedByteCount += locActualSize;
+			delete locStamped;
+			return S_OK;
+		} else {
+			throw 0;
+		}
+	} else {
+		DbgLog((LOG_TRACE,1,TEXT("Not streaming")));
+		return -1;
+	}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/*
+
 	//What happens when another packet arrives and the other one is still there ?
 	//delete mPendingPacket;
 	//debugLog<<"decodeData : "<<endl;
@@ -172,7 +361,7 @@
 		return S_FALSE;
 	}
 
-	
+*/	
 }
 
 
@@ -190,6 +379,15 @@
 	
 }
 
+STDMETHODIMP FLACDecodeInputPin::EndFlush()
+{
+	CAutoLock locLock(m_pLock);
+	
+	HRESULT locHR = AbstractTransformInputPin::EndFlush();
+	mDecodedByteCount = 0;
+	return locHR;
+}
+
 STDMETHODIMP FLACDecodeInputPin::EndOfStream(void) {
 	CAutoLock locStreamLock(mStreamLock);
 	{	//PROTECT CODEC FROM IMPLODING
@@ -200,19 +398,169 @@
 	return AbstractTransformInputPin::EndOfStream();
 }
 
+HRESULT FLACDecodeInputPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *outRequestedProps)
+{
+	outRequestedProps->cbBuffer = FLAC_BUFFER_SIZE;
+	outRequestedProps->cBuffers = FLAC_NUM_BUFFERS;
+	outRequestedProps->cbAlign = 1;
+	outRequestedProps->cbPrefix = 0;
+
+	return S_OK;
+}
+HRESULT FLACDecodeInputPin::CheckMediaType(const CMediaType *inMediaType)
+{
+	if (AbstractTransformInputPin::CheckMediaType(inMediaType) == S_OK) {
+		if (inMediaType->cbFormat == 4) {
+			if (strncmp((char*)inMediaType->pbFormat, "fLaC", 4) == 0) {
+				//TODO::: Possibly verify version
+				return S_OK;
+			}
+		} else if (inMediaType->cbFormat > 4) {
+			if (strncmp((char*)inMediaType->pbFormat, "\177FLAC", 5) == 0) {
+				//TODO::: Possibly verify version
+				return S_OK;
+			}
+		}
+	}
+	return S_FALSE;
+	
+}
 HRESULT FLACDecodeInputPin::SetMediaType(const CMediaType* inMediaType) {
 	//FIX:::Error checking
 	//RESOLVED::: Bit better.
-
-	if (inMediaType->subtype == MEDIASUBTYPE_FLAC) {
+	if (CheckMediaType(inMediaType) == S_OK) {
+		//((FLACDecodeFilter*)mParentFilter)->setFLACFormatBlock(inMediaType->pbFormat);
+		if (inMediaType->cbFormat == 4) {
+			if (strncmp((char*)inMediaType->pbFormat, "fLaC", 4) == 0) {
+				mFLACType = FT_CLASSIC;
+				return S_OK;
+			}
+		} else if (inMediaType->cbFormat > 4) {
+			if (strncmp((char*)inMediaType->pbFormat, "\177FLAC", 5) == 0) {
+				mFLACType = FT_OGG_FLAC_1;
+				return S_OK;
+				
+			}
+		}
+		return S_FALSE;
 		
-		//Keep the format block
-		
-		((FLACDecodeFilter*)mParentFilter)->setFLACFormatBlock((sFLACFormatBlock*)inMediaType->pbFormat);		//Copies the format in the mutator
-
 	} else {
 		throw 0;
 	}
+
+	//if (inMediaType->subtype == MEDIASUBTYPE_FLAC) {
+	//	
+	//	//Keep the format block
+	//	
+	//	((FLACDecodeFilter*)mParentFilter)->setFLACFormatBlock((sFLACFormatBlock*)inMediaType->pbFormat);		//Copies the format in the mutator
+
+	//} else {
+	//	throw 0;
+	//}
 	return CBaseInputPin::SetMediaType(inMediaType);
 }
 
+LOOG_INT64 FLACDecodeInputPin::convertGranuleToTime(LOOG_INT64 inGranule)
+{
+		
+	return (inGranule * UNITS) / ((FLACDecodeFilter*)mParentFilter)->getFLACFormatBlock()->samplesPerSec;
+	
+}
+
+LOOG_INT64 FLACDecodeInputPin::mustSeekBefore(LOOG_INT64 inGranule)
+{
+	//TODO::: Get adjustment from block size info... for now, it doesn't matter if no preroll
+	return inGranule;
+}
+IOggDecoder::eAcceptHeaderResult FLACDecodeInputPin::showHeaderPacket(OggPacket* inCodecHeaderPacket)
+{
+	const unsigned char MORE_HEADERS_MASK = 128;   //10000000
+	switch (mFLACType) {
+		case FT_CLASSIC:
+			switch (mSetupState) {
+				case VSS_SEEN_NOTHING:
+					if (strncmp((char*)inCodecHeaderPacket->packetData(), "fLaC", 4) == 0) {
+						mSetupState = VSS_SEEN_BOS;
+						delete mMetadataPacket;
+						mMetadataPacket = inCodecHeaderPacket->clone();
+						return IOggDecoder::AHR_MORE_HEADERS_TO_COME;
+					}
+
+					//TODO::: new flac format
+					mSetupState = VSS_ERROR;
+					return IOggDecoder::AHR_INVALID_HEADER;
+				case VSS_SEEN_BOS:
+					mMetadataPacket->merge(inCodecHeaderPacket);
+					if ((inCodecHeaderPacket->packetData()[0] & MORE_HEADERS_MASK) != 0) {
+						//Last packet
+						mSetupState = VSS_ALL_HEADERS_SEEN; 
+						((FLACDecodeFilter*)mParentFilter)->setFLACFormatBlock(mMetadataPacket->packetData());
+						mFLACDecoder.acceptMetadata(mMetadataPacket);
+						mMetadataPacket = NULL;
+				
+						//TODO::: Give it to the codec
+
+						return IOggDecoder::AHR_ALL_HEADERS_RECEIVED;
+					}
+
+					return IOggDecoder::AHR_MORE_HEADERS_TO_COME;
+				default:
+					return IOggDecoder::AHR_UNEXPECTED;
+			}
+		default:
+			return IOggDecoder::AHR_INVALID_HEADER;
+
+
+	}
+	//switch (mSetupState) {
+	//	case VSS_SEEN_NOTHING:
+	//		if (strncmp((char*)inCodecHeaderPacket->packetData(), "fLaC", 4) == 0) {
+	//			//TODO::: Possibly verify version
+	//			if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
+	//				mSetupState = VSS_SEEN_BOS;
+	//				return IOggDecoder::AHR_MORE_HEADERS_TO_COME;
+	//			}
+	//		}
+	//		return IOggDecoder::AHR_INVALID_HEADER;
+	//		
+	//		
+	//	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.
+
+	//		//if (strncmp((char*)inCodecHeaderPacket->packetData(), "\003vorbis", 7) == 0) {
+	//			if (fish_sound_decode(mFishSound, inCodecHeaderPacket->packetData(), inCodecHeaderPacket->packetSize()) >= 0) {
+	//				mSetupState = VSS_ALL_HEADERS_SEEN;
+
+	//				fish_sound_command (mFishSound, FISH_SOUND_GET_INFO, &(mFishInfo), sizeof (FishSoundInfo)); 
+	//				mBegun = true;
+	//		
+	//				mNumChannels = mFishInfo.channels;
+	//				mFrameSize = mNumChannels * SIZE_16_BITS;
+	//				mSampleRate = mFishInfo.samplerate;
+
+	//				return IOggDecoder::AHR_ALL_HEADERS_RECEIVED;
+	//			}
+	//			
+	//			
+	//		//}
+	//		return IOggDecoder::AHR_INVALID_HEADER;
+	//		
+	//		
+	//
+	//	case VSS_ALL_HEADERS_SEEN:
+	//	case VSS_ERROR:
+	//	default:
+	//		return IOggDecoder::AHR_UNEXPECTED;
+	//}
+}
+string FLACDecodeInputPin::getCodecShortName()
+{
+	return "flac";
+}
+string FLACDecodeInputPin::getCodecIdentString()
+{
+	//TODO:::
+	return "flac";
+}
+

Modified: branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h	2005-11-07 16:40:16 UTC (rev 10355)
+++ branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h	2005-11-08 07:29:49 UTC (rev 10356)
@@ -36,6 +36,7 @@
 
 //External Includes
 #include "FLACPushDecoder.h"
+#include "IOggDecoder.h"
 #include <libOOOgg/OggPacket.h>
 #include <libOOOgg/StampedOggPacket.h>
 
@@ -49,6 +50,7 @@
 class FLACDecodeInputPin
 	//Base Classes
 	:	public AbstractTransformInputPin
+	,	public IOggDecoder
 {
 public:
 	//COM Initialisation
@@ -59,13 +61,32 @@
 	FLACDecodeInputPin(AbstractTransformFilter* inFilter, CCritSec* inFilterLock, AbstractTransformOutputPin* inOutputPin, vector<CMediaType*> inAcceptableMediaTypes);
 	virtual ~FLACDecodeInputPin(void);
 
-	HRESULT SetMediaType(const CMediaType* inMediaType);
+	virtual HRESULT SetMediaType(const CMediaType* inMediaType);
+	virtual HRESULT CheckMediaType(const CMediaType *inMediaType);
 
 	virtual STDMETHODIMP BeginFlush();
+	virtual STDMETHODIMP EndFlush();
 	virtual STDMETHODIMP EndOfStream(void);
 	virtual STDMETHODIMP NewSegment(REFERENCE_TIME inStartTime, REFERENCE_TIME inStopTime, double inRate);
+
+	virtual STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *outRequestedProps);
+
+	virtual STDMETHODIMP FLACDecodeInputPin::Receive(IMediaSample* inSample);
+
+	//IOggDecoder Interface
+	virtual LOOG_INT64 convertGranuleToTime(LOOG_INT64 inGranule);
+	virtual LOOG_INT64 mustSeekBefore(LOOG_INT64 inGranule);
+	virtual IOggDecoder::eAcceptHeaderResult showHeaderPacket(OggPacket* inCodecHeaderPacket);
+	virtual string getCodecShortName();
+	virtual string getCodecIdentString();
 	
 protected:
+
+	static const unsigned long DECODED_BUFFER_SIZE = 1<<20;		//1 Meg buffer
+	
+	static const unsigned long FLAC_NUM_BUFFERS = 75;
+	static const unsigned long FLAC_BUFFER_SIZE = 65536; //Check
+
 	//Implementation of pure virtuals from AbstractTransformInputPin
 	virtual bool ConstructCodec();
 	virtual void DestroyCodec();
@@ -76,6 +97,34 @@
 	FLACPushDecoder mFLACDecoder;
 	CCritSec* mCodecLock;
 	unsigned long mUptoFrame;
+
+	OggPacket* mMetadataPacket;
+
+	enum eFLACType {
+		FT_UNKNOWN,
+		FT_CLASSIC,
+		FT_OGG_FLAC_1,
+	};
+
+	eFLACType mFLACType;
+
+	enum eFLACSetupState {
+		VSS_SEEN_NOTHING,
+		VSS_SEEN_BOS,
+		VSS_SEEN_COMMENT,
+		VSS_ALL_HEADERS_SEEN,
+		VSS_ERROR
+	};
+
+	eFLACSetupState mSetupState;
+
+	unsigned long mDecodedByteCount;
+	unsigned char* mDecodedBuffer;
+
+	__int64 mRateNumerator;
+	static const __int64 RATE_DENOMINATOR = 65536;
+
+
 	
 	//debug only
 	//fstream debugLog;

Modified: branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACdecoderdllstuff.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACdecoderdllstuff.h	2005-11-07 16:40:16 UTC (rev 10355)
+++ branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACdecoderdllstuff.h	2005-11-08 07:29:49 UTC (rev 10356)
@@ -53,27 +53,39 @@
 #include "FLACDecodeOutputPin.h"
 
 
-// {3913F0AB-E7ED-41c4-979B-1D1FDD983C07}
-DEFINE_GUID(MEDIASUBTYPE_FLAC, 
-0x3913f0ab, 0xe7ed, 0x41c4, 0x97, 0x9b, 0x1d, 0x1f, 0xdd, 0x98, 0x3c, 0x7);
 
+
 // {3376086C-D6F9-4ce4-8B89-33CD570106B5}
 DEFINE_GUID(CLSID_FLACDecodeFilter, 
 0x3376086c, 0xd6f9, 0x4ce4, 0x8b, 0x89, 0x33, 0xcd, 0x57, 0x1, 0x6, 0xb5);
 
-// {1CDC48AC-4C24-4b8b-982B-7007A29D83C4}
-DEFINE_GUID(FORMAT_FLAC, 
-0x1cdc48ac, 0x4c24, 0x4b8b, 0x98, 0x2b, 0x70, 0x7, 0xa2, 0x9d, 0x83, 0xc4);
+//// {1CDC48AC-4C24-4b8b-982B-7007A29D83C4}
+//DEFINE_GUID(FORMAT_FLAC, 
+//0x1cdc48ac, 0x4c24, 0x4b8b, 0x98, 0x2b, 0x70, 0x7, 0xa2, 0x9d, 0x83, 0xc4);
+//
+//// {3913F0AB-E7ED-41c4-979B-1D1FDD983C07}
+//DEFINE_GUID(MEDIASUBTYPE_FLAC, 
+//0x3913f0ab, 0xe7ed, 0x41c4, 0x97, 0x9b, 0x1d, 0x1f, 0xdd, 0x98, 0x3c, 0x7);
 
+// {60891713-C24F-4767-B6C9-6CA05B3338FC}
+DEFINE_GUID(MEDIATYPE_OggPacketStream, 
+0x60891713, 0xc24f, 0x4767, 0xb6, 0xc9, 0x6c, 0xa0, 0x5b, 0x33, 0x38, 0xfc);
 
+// {95388704-162C-42a9-8149-C3577C12AAF9}
+DEFINE_GUID(FORMAT_OggIdentHeader, 
+0x95388704, 0x162c, 0x42a9, 0x81, 0x49, 0xc3, 0x57, 0x7c, 0x12, 0xaa, 0xf9);
+
+// {43F0F818-10B0-4c86-B9F1-F6B6E2D33462}
+DEFINE_GUID(IID_IOggDecoder, 
+0x43f0f818, 0x10b0, 0x4c86, 0xb9, 0xf1, 0xf6, 0xb6, 0xe2, 0xd3, 0x34, 0x62);
 const REGPINTYPES FLACDecodeOutputTypes = {
     &MEDIATYPE_Audio,
 	&MEDIASUBTYPE_PCM
 };
 
 const REGPINTYPES FLACDecodeInputTypes = {
-	&MEDIATYPE_Audio,
-	&MEDIASUBTYPE_FLAC
+	&MEDIATYPE_OggPacketStream,
+	&MEDIASUBTYPE_None
 };
 const REGFILTERPINS FLACDecodePinReg[] = {
 	{

Modified: branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/dsfFLACDecoder.vcproj
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/dsfFLACDecoder.vcproj	2005-11-07 16:40:16 UTC (rev 10355)
+++ branches/oggdsf_new_demux/src/lib/codecs/flac/filters/dsfFLACDecoder/dsfFLACDecoder.vcproj	2005-11-08 07:29:49 UTC (rev 10356)
@@ -19,7 +19,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\libs\libFLACHelper"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\libs\libFLACHelper;..\..\..\..\core\directshow\dsfOggDemux2"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DSFFLACDECODER_EXPORTS"
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
@@ -81,7 +81,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\libs\libFLACHelper"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\libs\libFLACHelper;..\..\..\..\core\directshow\dsfOggDemux2"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSFFLACDECODER_EXPORTS"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -144,7 +144,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\libs\libFLACHelper"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\libs\libFLACHelper;..\..\..\..\core\directshow\dsfOggDemux2"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSFFLACDECODER_EXPORTS"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"
@@ -208,7 +208,7 @@
 				FavorSizeOrSpeed="1"
 				OmitFramePointers="TRUE"
 				OptimizeForProcessor="3"
-				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\libs\libFLACHelper"
+				AdditionalIncludeDirectories="&quot;C:\DXSDK\Samples\C++\DirectShow\BaseClasses&quot;;C:\DXSDK\Include;..\..\libs\libflac\include;..\..\..\..\core\directshow\libDirectshowAbstracts;..\..\..\..\core\ogg;..\..\..\..\core\directshow\dsfSeeking;..\..\..\..\helper;..\..\libs\libFLACHelper;..\..\..\..\core\directshow\dsfOggDemux2"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;DSFFLACDECODER_EXPORTS"
 				StringPooling="TRUE"
 				RuntimeLibrary="2"

Modified: branches/oggdsf_new_demux/src/lib/codecs/flac/libs/libFLACHelper/FLACPushDecoder.h
===================================================================
--- branches/oggdsf_new_demux/src/lib/codecs/flac/libs/libFLACHelper/FLACPushDecoder.h	2005-11-07 16:40:16 UTC (rev 10355)
+++ branches/oggdsf_new_demux/src/lib/codecs/flac/libs/libFLACHelper/FLACPushDecoder.h	2005-11-08 07:29:49 UTC (rev 10356)
@@ -20,6 +20,7 @@
 	unsigned long mNumChannels;
 	unsigned long mFrameSize;
 	unsigned long mSampleRate;
+	bool mBegun;
 protected:
 	static const int SIZE_16_BITS = 2;
 	//Virtuals frmo FLAC decoder
@@ -30,7 +31,7 @@
 
 	OggPacket* mInPacket;
 	StampedOggPacket* mOutPacket;
-	bool mBegun;
+	
 	bool mGotMetaData;
 	
 };



More information about the commits mailing list