[xiph-commits] r7190 - in trunk/oggdsf/src/lib:

illiminable at dactyl.lonelymoon.com illiminable
Tue Jul 20 00:50:47 PDT 2004


codecs/flac/filters/dsfFLACDecoder core/ogg/libOOOggSeek
Message-ID: <20040720075047.032E49AAAB at dactyl.lonelymoon.com>

Author: illiminable
Date: Tue Jul 20 00:50:47 2004
New Revision: 7190

Modified:
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp
trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp
trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.h
Log:
* Partially fixed seeking in flac. Still encounters dead spots occasioanlly, and locks up.

Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp	2004-07-20 07:29:57 UTC (rev 7189)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.cpp	2004-07-20 07:50:45 UTC (rev 7190)
@@ -136,12 +136,18 @@
//Make the start timestamp
//FIX:::Abstract this calculation
//REFERENCE_TIME locFrameStart = CurrentStartTime() + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
-	REFERENCE_TIME locFrameStart = (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
+
+
+	//ADDING TIMEBASE INFO.
+	REFERENCE_TIME locTimeBase = ((mLastSeenStartGranPos * UNITS) / mSampleRate) - mSeekTimeBase;
+
+
+	REFERENCE_TIME locFrameStart = locTimeBase + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
//Increment the frame counter
mUptoFrame += locNumFrames;
//Make the end frame counter
//REFERENCE_TIME locFrameEnd = CurrentStartTime() + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
-	REFERENCE_TIME locFrameEnd = (((__int64)(mUptoFrame * UNITS)) / mSampleRate);
+	REFERENCE_TIME locFrameEnd = locTimeBase + (((__int64)(mUptoFrame * UNITS)) / mSampleRate);

//Get a pointer to a new sample stamped with our time
IMediaSample* locSample;
@@ -242,7 +248,11 @@
int locRet = 0;
//for(unsigned long i = 0; i < mPendingPackets.size(); i++) {
ASSERT((locBuff[0] == 255) && (locBuff[1] == 248));
+			if (mPendingPackets.size() == 1) {
locRet = process_single();
+			} else {
+				//Shouldn't be possible to get here !
+			}
//}
//mNumPacksBuffered = 0;
} else {
@@ -256,14 +266,25 @@

}

-STDMETHODIMP FLACDecodeInputPin::EndFlush() {
+//STDMETHODIMP FLACDecodeInputPin::EndFlush() {
+//	flush();
+//	unsigned long locSize = mPendingPackets.size();
+//	for (unsigned long i = 0; i < locSize; i++) {
+//		delete mPendingPackets.front();
+//		mPendingPackets.pop();
+//	}
+//	return AbstractAudioDecodeInputPin::EndFlush();
+//
+//}
+
+STDMETHODIMP FLACDecodeInputPin::BeginFlush() {
flush();
unsigned long locSize = mPendingPackets.size();
for (unsigned long i = 0; i < locSize; i++) {
delete mPendingPackets.front();
mPendingPackets.pop();
}
-	return AbstractAudioDecodeInputPin::EndFlush();
+	return AbstractAudioDecodeInputPin::BeginFlush();

}


Modified: trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h	2004-07-20 07:29:57 UTC (rev 7189)
+++ trunk/oggdsf/src/lib/codecs/flac/filters/dsfFLACDecoder/FLACDecodeInputPin.h	2004-07-20 07:50:45 UTC (rev 7190)
@@ -59,7 +59,8 @@
//FIX:::These should be protected.
virtual bool ConstructCodec();
virtual void DestroyCodec();
-	virtual STDMETHODIMP EndFlush();
+	//virtual STDMETHODIMP EndFlush();
+	virtual STDMETHODIMP BeginFlush();
virtual STDMETHODIMP EndOfStream(void);

long decodeData(unsigned char* inBuf, long inNumBytes);

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp	2004-07-20 07:29:57 UTC (rev 7189)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp	2004-07-20 07:50:45 UTC (rev 7190)
@@ -41,6 +41,8 @@
,	mNumHeaders(0)
,	mSerialNoToTrack(LINT_MAX)
,	isTheora(false)
+	,	isFLAC(false)
+	,	mFoundStreamInfo(false)
,	mGranulePosShift(0)
,	mLastIsSeekable(false)

@@ -61,15 +63,17 @@
mPacketCount += inOggPage->numPackets();

//TODO ::: Some of this could be shared from other places.
-	if (mPacketCount == 1) {
+	if (!mFoundStreamInfo) {
if (strncmp((const char*)inOggPage->getPacket(0)->packetData(), "\001vorbis", 7) == 0) {
mSampleRate = OggMath::charArrToULong(inOggPage->getPacket(0)->packetData() + 12);
mNumHeaders = 3;
mSerialNoToTrack = inOggPage->header()->StreamSerialNo();
+			mFoundStreamInfo = true;
} else if (strncmp((const char*)inOggPage->getPacket(0)->packetData(), "Speex   ", 8) == 0) {
mSampleRate = OggMath::charArrToULong(inOggPage->getPacket(0)->packetData() + 36);
mNumHeaders = 2;
mSerialNoToTrack = inOggPage->header()->StreamSerialNo();
+			mFoundStreamInfo = true;
} else if ((strncmp((char*)inOggPage->getPacket(0)->packetData(), "\200theora", 7)) == 0){
//FIX ::: Dunno what this is... do something better than this later !!
//mEnabled = false;
@@ -79,9 +83,20 @@
mGranulePosShift = (((inOggPage->getPacket(0)->packetData()[40]) % 4) << 3) + ((inOggPage->getPacket(0)->packetData()[41]) >> 5);
mSampleRate = FLACMath::charArrToULong(inOggPage->getPacket(0)->packetData() + 22) / FLACMath::charArrToULong(inOggPage->getPacket(0)->packetData() + 26);
mNumHeaders = 3;
+			mFoundStreamInfo = true;
//Need denominators
//mTheoraFormatBlock->frameRateDenominator = FLACMath::charArrToULong(locIdentHeader + 26);
-		} else {
+		} else if ((strncmp((char*)inOggPage->getPacket(0)->packetData(),  "fLaC", 4) == 0)) {
+			//mPacketCount--;
+			mNumHeaders = 2;
+			mSerialNoToTrack = inOggPage->header()->StreamSerialNo();
+			isFLAC = true;
+		} else if (isFLAC && (mSerialNoToTrack == inOggPage->header()->StreamSerialNo())) {
+			//Catch the second flac packet.
+			mSampleRate = FLACMath::charArrToULong(inOggPage->getPacket(0)->packetData() + 14) >> 12;
+			mFoundStreamInfo = true;
+		}else {
+			mFoundStreamInfo = true;
mEnabled = false;
mSampleRate = 1;

@@ -89,7 +104,7 @@
}


-	if ((mSerialNoToTrack == inOggPage->header()->StreamSerialNo()) && (inOggPage->header()->GranulePos()->value() != -1)) {
+	if ((mFoundStreamInfo) && (mSerialNoToTrack == inOggPage->header()->StreamSerialNo()) && (inOggPage->header()->GranulePos()->value() != -1)) {
//if ((mPacketCount > 3) && (mLastIsSeekable == true)) {
if ((mPacketCount > mNumHeaders) && ((inOggPage->header()->HeaderFlags() & 1) != 1)) {
addSeekPoint(mLastSeekTime, mFilePos);

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.h	2004-07-20 07:29:57 UTC (rev 7189)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.h	2004-07-20 07:50:45 UTC (rev 7190)
@@ -66,6 +66,8 @@
unsigned long mGranulePosShift;
bool mLastIsSeekable;
bool isTheora;
+	bool isFLAC;
+	bool mFoundStreamInfo;
__int64 mLastSeekTime;
__int64 mFileDuration;
fstream mFile;



More information about the commits mailing list