[matroska] r1178 - in trunk/libebml: ebml src

[email protected] Thu, 19 May 2005 19:47:13 +0400 (MSD)
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2005-05-19 19:47:11 +0400 (Thu, 19 May 2005)
New Revision: 1178

Modified:
   trunk/libebml/ebml/EbmlElement.h
   trunk/libebml/src/EbmlMaster.cpp
Log:
libebml: better evaluation of the data left to read

Modified: trunk/libebml/ebml/EbmlElement.h
===================================================================
--- trunk/libebml/ebml/EbmlElement.h	2005-05-17 16:30:44 UTC (rev 1177)
+++ trunk/libebml/ebml/EbmlElement.h	2005-05-19 15:47:11 UTC (rev 1178)
@@ -235,6 +235,10 @@
 		virtual void SetDefaultSize(const uint64 aDefaultSize) {DefaultSize = aDefaultSize;}
 
 		bool ValueIsSet() const {return bValueIsSet;}
+
+		inline uint64 GetEndPosition() const {
+			return SizePosition + CodedSizeLength(Size, SizeLength) + Size;
+		}
 		
 	protected:
 		uint64 Size;        ///< the size of the data to write

Modified: trunk/libebml/src/EbmlMaster.cpp
===================================================================
--- trunk/libebml/src/EbmlMaster.cpp	2005-05-17 16:30:44 UTC (rev 1177)
+++ trunk/libebml/src/EbmlMaster.cpp	2005-05-19 15:47:11 UTC (rev 1178)
@@ -416,7 +416,7 @@
 			inDataStream.I_O().setFilePointer(SizePosition + SizeLength, seek_beginning);
 			ElementLevelA = inDataStream.FindNextElement(sContext, UpperEltFound, MaxSizeToRead, AllowDummyElt);
 			while (ElementLevelA != NULL && MaxSizeToRead > 0 && UpperEltFound <= 0) {
-				MaxSizeToRead -= ElementLevelA->ElementSize(true); // even if it's the default value
+				MaxSizeToRead = GetEndPosition() - ElementLevelA->GetEndPosition(); // even if it's the default value
 				if (!AllowDummyElt && ElementLevelA->IsDummy()) {
 					ElementLevelA->SkipData(inDataStream, sContext);
 					delete ElementLevelA; // forget this unknown element