[xiph-commits] r7956 - in trunk/oggdsf/src/lib/core: directshow/dsfOggDemux directshow/dsfOggMux ogg/libOOOgg ogg/libOOOggSeek

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Sun Oct 10 00:38:01 PDT 2004


Author: illiminable
Date: 2004-10-10 00:38:01 -0700 (Sun, 10 Oct 2004)
New Revision: 7956

Modified:
   trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStream.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.cpp
   trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPaginator.cpp
   trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPaginator.h
   trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp
Log:
* Fixed a muxing bug in flac, where audio and headers would be mixed on a page.
* Now in all codecs, every packet with a 0 granule pos gets it's own page.

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStream.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStream.cpp	2004-10-10 06:34:44 UTC (rev 7955)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggDemux/OggStream.cpp	2004-10-10 07:38:01 UTC (rev 7956)
@@ -258,7 +258,7 @@
 
 //ANX::: Maybe also needs override. ??
 bool OggStream::dispatchPacket(StampedOggPacket* inPacket) {
-	//debugLog<<"Ogg Stream : Packet stamps = "<<inPacket->startTime()<<" - "<<inPacket->endTime()<<endl;
+	debugLog<<"Ogg Stream : Packet stamps = "<<inPacket->startTime()<<" - "<<inPacket->endTime()<<endl;
 	return mSourcePin->deliverOggPacket(inPacket);
 }
 

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.cpp	2004-10-10 06:34:44 UTC (rev 7955)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.cpp	2004-10-10 07:38:01 UTC (rev 7956)
@@ -44,6 +44,7 @@
 	QueryPerformanceCounter(&locTicks);
 	srand((unsigned int)locTicks.LowPart);
 	locSettings->mSerialNo = ((unsigned long)(rand() + 1)) * ((unsigned long)(rand() + 1));
+
 	//locSettings->mSerialNo = 13130;
 	
 	mPaginator.setParameters(locSettings);

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPaginator.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPaginator.cpp	2004-10-10 06:34:44 UTC (rev 7955)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPaginator.cpp	2004-10-10 07:38:01 UTC (rev 7956)
@@ -113,13 +113,13 @@
 	,	mSequenceNo(0)
 	,	mPacketCount(0)
 {
-	//debugLog.open("G:\\logs\\paginator.log", ios_base::out);
+	debugLog.open("G:\\logs\\paginator.log", ios_base::out);
 	
 }
 
 OggPaginator::~OggPaginator(void)
 {
-	//debugLog.close();
+	debugLog.close();
 }
 
 
@@ -169,7 +169,7 @@
 	//	}
 	//}
 
-	//debugLog<<"Accepting packet"<<endl;
+	debugLog<<"Accepting packet"<<endl;
 	addPacketToPage(inOggPacket);
 
 	return true;
@@ -235,7 +235,7 @@
 
 }
 bool OggPaginator::deliverCurrentPage() {
-	//debugLog<<"Delivering page"<<endl;
+	debugLog<<"Delivering page"<<endl;
 	mPendingPage->header()->setSegmentTable((const unsigned char*)mSegmentTable, mSegmentTableSize);
 	mPendingPage->header()->setDataSize(mCurrentPageSize - mPendingPage->headerSize());  //This is odd
 
@@ -255,7 +255,7 @@
 
 }
 bool OggPaginator::createFreshPage() {
-	//debugLog<<"Creating fresh page"<<endl;
+	debugLog<<"Creating fresh page"<<endl;
 	mPendingPage = new OggPage;
 	mCurrentPageSize = OggPageHeader::OGG_BASE_HEADER_SIZE;
 	mPendingPageHasData = false;
@@ -278,7 +278,7 @@
 }
 bool OggPaginator::addPacketToPage(StampedOggPacket* inOggPacket) {
 
-	//debugLog<<"Add packet to page"<<endl;
+	debugLog<<"Add packet to page"<<endl;
 	mPendingPageHasData = true;
 	//while some packet left
 	//	add as much as possible
@@ -299,15 +299,28 @@
 
 	//While there is still more packet not added to the page
 	while (locPacketRemaining > 0) {
-		//debugLog<<"Packet remaining = "<<locPacketRemaining<<endl;
+		debugLog<<"Packet remaining = "<<locPacketRemaining<<endl;
 		locConsumed = addAsMuchPacketAsPossible(inOggPacket, locPacketStartPoint, locPacketRemaining);
-		//debugLog<<"Consumed = "<<locConsumed<<endl;
+		debugLog<<"Consumed = "<<locConsumed<<endl;
 		locPacketStartPoint += locConsumed;
 		locPacketRemaining -= locConsumed;
 	}
 
 	//To ensure you get vorbis comments and codebook ending a page.
-	if ((mPacketCount == 2) && (mPendingPageHasData)) {
+	//if ((mPacketCount == 2) && (mPendingPageHasData)) {
+	//	deliverCurrentPage();
+	//}
+
+	//This will ensure that any packet that has a 0 time stamp appears on it's own page...
+	// For codecs with fixed number of headers, it's easy to put several of these packets on a page
+	// But it's more difficult to do it generically for variable numbers of headers.
+	// Just ensuring that any packet with 0 gran pos (which is usually only headers, or possibly
+	// the first packet in a non-continuous codec) has it's own page is the simplest solution
+	// An added benefit, is that comment packets appear on their own page, this makes it
+	// significantly easier to add/modify comments without bumping data across a page which could
+	// require changing of all the headers in all the pages.
+	if ((inOggPacket->endTime() == 0) && (mPendingPageHasData)) {
+		debugLog<<"Flushing a 0 gran pos page..."<<endl;
 		deliverCurrentPage();
 	}
 	mPacketCount++;
@@ -346,6 +359,7 @@
 	addPartOfPacketToPage(inOggPacket, inStartAt, locHowMuchToAdd);
 
 
+	//This puts only a single packet on the first page...
 	if ((mCurrentPageSize >= mSettings->mMinPageSize) || (mPendingPage->header()->PageSequenceNo() == 0)) {
 		deliverCurrentPage();
 	}

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPaginator.h
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPaginator.h	2004-10-10 06:34:44 UTC (rev 7955)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOgg/OggPaginator.h	2004-10-10 07:38:01 UTC (rev 7956)
@@ -78,6 +78,6 @@
 	OggPaginatorSettings* mSettings;
 	OggPage* mPendingPage;
 
-	//fstream debugLog;
+	fstream debugLog;
 	
 };

Modified: trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp	2004-10-10 06:34:44 UTC (rev 7955)
+++ trunk/oggdsf/src/lib/core/ogg/libOOOggSeek/AutoOggSeekTable.cpp	2004-10-10 07:38:01 UTC (rev 7956)
@@ -116,15 +116,19 @@
 				}
 			}
 		} else if ((strncmp((char*)inOggPage->getPacket(0)->packetData(),  "\177FLAC", 5) == 0)) {
+			debugLog<<"Identified new flac..."<<endl;
 			//mPacketCount--;
 			//POTENTIAL BUG::: Only looks at low order byte
 			mNumHeaders = inOggPage->getPacket(0)->packetData()[8];
+			debugLog<<"Header says there are this many headers "<<mNumHeaders<<endl;
 			mSerialNoToTrack = inOggPage->header()->StreamSerialNo();
 			if (mNumHeaders == 0) {
 				//Variable number of headers... need to pick it up again...
+				debugLog<<"Variable number of headers... 1 so far..."<<endl;
 				mNumHeaders = 1;
                 isOggFLAC_1_0 = true;
 			} else {
+				debugLog<<"Fixed number of headers..."<<endl;
 				mFoundStreamInfo = true;
 			}
 			mSampleRate = iBE_Math::charArrToULong(inOggPage->getPacket(0)->packetData() + 27) >> 12;
@@ -162,7 +166,9 @@
 
 	if ((mFoundStreamInfo) && (mSerialNoToTrack == inOggPage->header()->StreamSerialNo()) && (inOggPage->header()->GranulePos() != -1)) {
 		//if ((mPacketCount > 3) && (mLastIsSeekable == true)) {
+		debugLog<<"Stream headers complete..."<<endl;
 		if ((mPacketCount > mNumHeaders) && ((inOggPage->header()->HeaderFlags() & 1) != 1)) {
+			debugLog<<"Adding seek point Time = "<<mLastSeekTime<<"  --  File pos = "<<mFilePos<<endl;
 			addSeekPoint(mLastSeekTime, mFilePos);
 			
 		}



More information about the commits mailing list