[xiph-commits] r8011 - in trunk/oggdsf/src/lib: codecs/flac/libs/libFLACHelper core/directshow/dsfOggMux

illiminable at motherfish-iii.xiph.org illiminable at motherfish-iii.xiph.org
Fri Oct 15 05:34:53 PDT 2004


Author: illiminable
Date: 2004-10-15 05:34:53 -0700 (Fri, 15 Oct 2004)
New Revision: 8011

Modified:
   trunk/oggdsf/src/lib/codecs/flac/libs/libFLACHelper/FLACHeaderTweaker.cpp
   trunk/oggdsf/src/lib/codecs/flac/libs/libFLACHelper/FLACMetadataSplitter.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.cpp
   trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.h
Log:
* Fixed a crashing bug, when converting flac classic to new flac.

Modified: trunk/oggdsf/src/lib/codecs/flac/libs/libFLACHelper/FLACHeaderTweaker.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/libs/libFLACHelper/FLACHeaderTweaker.cpp	2004-10-15 11:03:15 UTC (rev 8010)
+++ trunk/oggdsf/src/lib/codecs/flac/libs/libFLACHelper/FLACHeaderTweaker.cpp	2004-10-15 12:34:53 UTC (rev 8011)
@@ -42,10 +42,13 @@
 
 FLACHeaderTweaker::~FLACHeaderTweaker(void)
 {
-	debugLog.close();
-
+	
+	debugLog<<"Pre delete old..."<<endl;
 	deleteOldHeaders();
+	debugLog<<"Pre delete new..."<<endl;
 	deleteNewHeaders();
+	debugLog<<"Post delete..."<<endl;
+	debugLog.close();
 }
 
 FLACHeaderTweaker::eFLACAcceptHeaderResult FLACHeaderTweaker::acceptHeader(OggPacket* inHeader) {
@@ -163,20 +166,24 @@
 
 void FLACHeaderTweaker::deleteOldHeaders() {
 	int locSize = mOldHeaderList.size();
+	debugLog<<"Num old headers... = "<<locSize<<endl;
 	for (int i = 0; i < locSize; i++) {
 		delete mOldHeaderList[i];		
 	}
-
-	mOldHeaderList.empty();
+	debugLog<<"Post old delete loop..."<<endl;
+	mOldHeaderList.clear();
+	
 }
 
 void FLACHeaderTweaker::deleteNewHeaders() {
 	int locSize = mNewHeaderList.size();
+	debugLog<<"Num new headers... = "<<locSize<<endl;
 	for (int i = 0; i < locSize; i++) {
 		delete mNewHeaderList[i];		
 	}
+	debugLog<<"Post new delete loop"<<endl;
 
-	mNewHeaderList.empty();
+	mNewHeaderList.clear();
 }
 
 unsigned long FLACHeaderTweaker::numNewHeaders() {

Modified: trunk/oggdsf/src/lib/codecs/flac/libs/libFLACHelper/FLACMetadataSplitter.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/flac/libs/libFLACHelper/FLACMetadataSplitter.cpp	2004-10-15 11:03:15 UTC (rev 8010)
+++ trunk/oggdsf/src/lib/codecs/flac/libs/libFLACHelper/FLACMetadataSplitter.cpp	2004-10-15 12:34:53 UTC (rev 8011)
@@ -40,17 +40,20 @@
 
 FLACMetadataSplitter::~FLACMetadataSplitter(void)
 {
+	delete mMetadataBlock;
+	//Delete stuff !!
 	debugLog.close();
 }
 StampedOggPacket* FLACMetadataSplitter::convertToStampedPacket(OggPacket* inPacket) {
 	//Convert the old packet to the new one.
 	//This function deletes the incoming packet... and transfers the buffer directly into
 	// the stamped packet without a memcpy
-
+	//debugLog<<"Convert packet..."<<endl;
 	StampedOggPacket* locStamped = new StampedOggPacket(inPacket->packetData(), inPacket->packetSize(), false, false, 0,0,StampedOggPacket::OGG_END_ONLY);
 	//Ensure when we delete the old packet, it doesn't delete it's buffer
 	inPacket->setPacketData(NULL);
-	delete inPacket;
+	delete inPacket;		
+	//debugLog<<"Post delete..."<<endl;
 	return locStamped;
 }
 
@@ -65,7 +68,7 @@
 }
 StampedOggPacket* FLACMetadataSplitter::getHeader(unsigned long inIndex) {
 	if (inIndex < mHeaderTweaker.numNewHeaders()) {
-		return (FLACMetadataSplitter::convertToStampedPacket(mHeaderTweaker.getHeader(inIndex)->clone()));
+		return (FLACMetadataSplitter::convertToStampedPacket(mHeaderTweaker.getHeader(inIndex)));
 	} else {
 		return NULL;
 	}
@@ -106,24 +109,27 @@
 	unsigned long locPacketSize = 0;
 	OggPacket* locPacket = NULL;
 
+	debugLog<<"Metadata size = "<<locMetaSize<<endl;
 	while ( locUpto < locMetaSize) {
 		debugLog<<"Add others loop... upto = "<<locUpto<<endl;
-		for (int i = 0; i < 3; i++) {
+		for (int i = 1; i < 4; i++) {
 			locPacketSize <<=8;
 			locPacketSize += locSourceBuff[locUpto+i];
 		}
-		
-		locUpto += 4;
+		locPacketSize += 4;
+		debugLog<<"Packet size = "<<locPacketSize<<endl;
+		//locUpto += 4;
 
 		locNewBuff = new unsigned char[locPacketSize];
-		memcpy((void*)locNewBuff, (const void*)locSourceBuff, locPacketSize);
+		memcpy((void*)locNewBuff, (const void*)(locSourceBuff + locUpto), locPacketSize);
 
 		locPacket = new OggPacket(locNewBuff, locPacketSize, false, false);
-
+		debugLog<<"Adding other packet..."<<endl;
+		debugLog<<locPacket->toPackDumpString()<<endl;
 		mHeaderTweaker.acceptHeader(locPacket);
 		locPacket = NULL;
 
-		locUpto += locPacketSize;
+		locUpto += (locPacketSize);
 		
 
 	}
@@ -136,7 +142,9 @@
 	unsigned char* locBuff = new unsigned char[38];
 	
 	memcpy((void*)locBuff, (const void*)(mMetadataBlock->packetData()+4), 38);
-	locPacket = new OggPacket(locBuff, 38, false, false);
+	locPacket = new OggPacket(locBuff, 38, false, false);		//No need to delete
+	debugLog<<"Adding stream info packet..."<<endl;
+	debugLog<<locPacket->toPackDumpString()<<endl;
 	mHeaderTweaker.acceptHeader(locPacket);
 	return true;
 }
@@ -148,7 +156,7 @@
 	locBuff[1] = 'L';
 	locBuff[2] = 'a';
 	locBuff[3] = 'C';
-	locPacket = new OggPacket(locBuff, 4, false, false);
+	locPacket = new OggPacket(locBuff, 4, false, false);		//No need to delete.
 	mHeaderTweaker.acceptHeader(locPacket);
 	return true;
 }

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.cpp
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.cpp	2004-10-15 11:03:15 UTC (rev 8010)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.cpp	2004-10-15 12:34:53 UTC (rev 8011)
@@ -36,7 +36,7 @@
 	,	mParentFilter(inParentFilter)
 	,	mMuxStream(inMuxStream)
 	,	mNeedsFLACHeaderTweak(false)
-	,	mFLACSplitter(NULL)
+
 {
 	OggPaginatorSettings* locSettings = new OggPaginatorSettings;
 	locSettings->mMinPageSize = 4096;
@@ -52,7 +52,7 @@
 	mPaginator.setParameters(locSettings);
 	mPaginator.setPageCallback(mMuxStream);
 
-	//debugLog.open("C:\\temp\\oggmuxinpin.log", ios_base::out);
+	debugLog.open("G:\\logs\\oggmuxinpin.log", ios_base::out);
 }
 
 OggMuxInputPin::~OggMuxInputPin(void)
@@ -124,7 +124,11 @@
 			outMediaType->majortype = MEDIATYPE_Audio;
 			outMediaType->subtype = MEDIASUBTYPE_OggFLAC_1_0;
 			return S_OK;
+		case 4:
+			outMediaType->majortype = MEDIATYPE_Audio;
+			outMediaType->subtype = MEDIASUBTYPE_FLAC;
 
+
 		default:
 			return VFW_S_NO_MORE_ITEMS;
 	
@@ -146,6 +150,11 @@
 			(inMediaType->majortype == MEDIATYPE_Audio
 				&&	inMediaType->subtype == MEDIASUBTYPE_OggFLAC_1_0
 				&&	inMediaType->formattype == FORMAT_FLAC)
+			||
+			(inMediaType->majortype == MEDIATYPE_Audio
+				&&	inMediaType->subtype == MEDIASUBTYPE_FLAC
+				&&	inMediaType->formattype == FORMAT_FLAC)
+
 		) {
 		return S_OK;
 	} else {
@@ -189,19 +198,29 @@
 		//This could be to mux multi stream flac.
 		//Alternatively this configuration could be used to convert the old format to the new.
 
-		mFLACSplitter = new FLACMetadataSplitter;
+		debugLog<<"In the header tweak section..."<<endl;
+		FLACMetadataSplitter* locFLACSplitter = new FLACMetadataSplitter;
 
-		mFLACSplitter->loadMetadata(locPacket->clone());
-		delete locPacket;
+		debugLog<<"Feeding metadata..."<<endl;
+		locFLACSplitter->loadMetadata(locPacket->clone());
+		
+		//delete locPacket;		//Don't delete the splitter will delete when it's done.
 
-		for (int i = 0; i < mFLACSplitter->numHeaders(); i++) {
-			mPaginator.acceptStampedOggPacket(mFLACSplitter->getHeader(i));
+		for (int i = 0; i < locFLACSplitter->numHeaders(); i++) {
+			debugLog<<"Giving pager, packet "<<i<<endl;
+			debugLog<<locFLACSplitter->getHeader(i)->toPackDumpString()<<endl;		//This is a leak !!
+			mPaginator.acceptStampedOggPacket(locFLACSplitter->getHeader(i));
+			debugLog<<"After paginator feed..."<<endl;
 		}
 		mNeedsFLACHeaderTweak = false;
+		debugLog<<"Pre delete of splitter..."<<endl;
+		delete locFLACSplitter;
+		debugLog<<"Post delete of splitter"<<endl;
+
 	} else {
 		//Not truncated or contuned... its a full packet.
 		
-	
+		debugLog<<"Normal add packet..."<<endl;
 		mPaginator.acceptStampedOggPacket(locPacket);
 	}
 

Modified: trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.h
===================================================================
--- trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.h	2004-10-15 11:03:15 UTC (rev 8010)
+++ trunk/oggdsf/src/lib/core/directshow/dsfOggMux/OggMuxInputPin.h	2004-10-15 12:34:53 UTC (rev 8011)
@@ -80,8 +80,8 @@
 	OggMuxFilter* mParentFilter;
 
 	bool mNeedsFLACHeaderTweak;
-	FLACMetadataSplitter* mFLACSplitter;
+	
 	OggPaginator mPaginator;
 	OggMuxStream* mMuxStream;
-	//fstream debugLog;
+	fstream debugLog;
 };



More information about the commits mailing list