[xiph-commits] r8712 - trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse

ozone at motherfish-iii.xiph.org ozone at motherfish-iii.xiph.org
Sun Jan 9 19:28:15 PST 2005


Author: ozone
Date: 2005-01-09 19:28:15 -0800 (Sun, 09 Jan 2005)
New Revision: 8712

Modified:
   trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse/CMMLTagUtils.cpp
Log:
oggdsf:
 * Added some debug code to CMMLTagUtils
 * Extra sanity checks in CMMLTagUtils::getClipsFrom()


Modified: trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse/CMMLTagUtils.cpp
===================================================================
--- trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse/CMMLTagUtils.cpp	2005-01-10 01:20:30 UTC (rev 8711)
+++ trunk/oggdsf/src/lib/codecs/cmml/libWinCMMLParse/CMMLTagUtils.cpp	2005-01-10 03:28:15 UTC (rev 8712)
@@ -37,21 +37,39 @@
 #include <libWinCMMLParse/CMMLTagUtils.h>
 #include <libTemporalURI/C_TimeStamp.h>
 
+#include <fstream>
+
+#undef DEBUG
+
 /** Note that the returned C_ClipTagList must be deleted by you.
   */
 C_ClipTagList *CMMLTagUtils::getClipsFrom(C_ClipTagList *inClipTagList, LOOG_INT64 inTimeInDirectShowUnits)
 {
+
+#ifdef DEBUG
+	fstream locDebugFile;
+	locDebugFile.open("G:\\Logs\\getClipsFrom.log", ios_base::out);
+#endif
+
 	C_ClipTagList *locClipTagList = new C_ClipTagList;
 
 	bool locAlreadyEncounteredClipInTimeRange = false;
 
 	for (unsigned long i = 0; i < inClipTagList->numTags(); i++) {
 		C_ClipTag *locTag = inClipTagList->getTag(i);
+
+#ifdef DEBUG
+		locDebugFile << "Processing tag " << i << endl;
+#endif
 		
 		// Convert the time stamp from a string to time in DirectSeconds(TM)
 		wstring locStart = locTag->start();
 		C_TimeStamp locTimeStamp;
 		if (!locTimeStamp.parseTimeStamp(StringHelper::toNarrowStr(locStart))) {
+#ifdef DEBUG
+			locDebugFile << "Couldn't parse time stamp: " << 
+				StringHelper::toNarrowStr(locStart) << endl;
+#endif
 			// Mmm, couldn't parse the time stamp for this clip ... so, err,
 			// let's just skip it.  Yeah, that's a grreeeeat idea ...
 			continue;
@@ -59,16 +77,24 @@
 		LOOG_INT64 locStartTime = locTimeStamp.toHunNanos();
 
 		if (locStartTime >= inTimeInDirectShowUnits) {
+#ifdef DEBUG
+			locDebugFile << "Found clip with greater start time " << locStartTime << endl;
+#endif
 			if (!locAlreadyEncounteredClipInTimeRange) {
-				// Only add the previous clip to the clip list if its end time
-				// is beyond the requested time
 				{
+					// Only add the previous clip to the clip list if its end time
+					// is beyond the requested time
 					wstring locEnd = locTag->end();
 					C_TimeStamp locEndTimeStamp;
 					if (locEndTimeStamp.parseTimeStamp(StringHelper::toNarrowStr(locEnd))) {
 						// Clip has an end time: check if it's before the requested time
 						LOOG_INT64 locEndTime = locEndTimeStamp.toHunNanos();
-						if (locEndTime < inTimeInDirectShowUnits) {
+						if (	locEndTime != 0
+							&&	locEndTime >= locStartTime
+							&&	locEndTime < inTimeInDirectShowUnits) {
+#ifdef DEBUG
+						locDebugFile << "Skipping add due to end time " << locEndTime << endl;
+#endif
 							continue;
 						}
 					}
@@ -76,14 +102,23 @@
 
 				// If we're not the very first clip ...
 				if (i > 0) {
+#ifdef DEBUG
+					locDebugFile << "Cloning previous clip " << i << endl;
+#endif
 					C_ClipTag *locClipInTimeRange = inClipTagList->getTag(i - 1);
 					locClipTagList->addTag(locClipInTimeRange->clone());
 				}
 				locAlreadyEncounteredClipInTimeRange = true;
 			}
+#ifdef DEBUG
+			locDebugFile << "Cloning clip " << i << endl;
+#endif
 			locClipTagList->addTag(locTag->clone());
 		}
 	}
 
+#ifdef DEBUG
+	locDebugFile.close();
+#endif
 	return locClipTagList;
 }



More information about the commits mailing list