[matroska] r1209 - in trunk/libmatroska: matroska src

[email protected] Fri, 7 Oct 2005 01:20:45 +0400 (MSD)
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: robux4
Date: 2005-10-07 01:20:42 +0400 (Fri, 07 Oct 2005)
New Revision: 1209

Modified:
   trunk/libmatroska/matroska/KaxBlock.h
   trunk/libmatroska/src/KaxBlock.cpp
   trunk/libmatroska/src/KaxCluster.cpp
Log:
libmatroska: add KaxSimpleBlock and a parent class used by KaxBlock
  (not tested yet, and some things left to implement)

Modified: trunk/libmatroska/matroska/KaxBlock.h
===================================================================
--- trunk/libmatroska/matroska/KaxBlock.h	2005-10-02 15:16:53 UTC (rev 1208)
+++ trunk/libmatroska/matroska/KaxBlock.h	2005-10-06 21:20:42 UTC (rev 1209)
@@ -3,7 +3,7 @@
 **
 ** <file/class description>
 **
-** Copyright (C) 2002-2004 Steve Lhomme.  All rights reserved.
+** Copyright (C) 2002-2005 Steve Lhomme.  All rights reserved.
 **
 ** This library is free software; you can redistribute it and/or
 ** modify it under the terms of the GNU Lesser General Public
@@ -189,15 +189,13 @@
 		const KaxTrackEntry * ParentTrack;
 };
 
-class MATROSKA_DLL_API KaxBlock : public EbmlBinary {
+class KaxInternalBlock : public EbmlBinary {
 	public:
-		KaxBlock() :bLocalTimecodeUsed(false), mLacing(LACING_AUTO), mInvisible(false), ParentCluster(NULL) {}
-		KaxBlock(const KaxBlock & ElementToClone);
-		~KaxBlock();
-		static EbmlElement & Create() {return *(new KaxBlock);}
-		const EbmlCallbacks & Generic() const {return ClassInfos;}
-		static const EbmlCallbacks ClassInfos;
-		operator const EbmlId &() const {return ClassInfos.GlobalId;}
+		KaxInternalBlock( bool bSimple ) :bLocalTimecodeUsed(false), mLacing(LACING_AUTO), mInvisible(false)
+			,ParentCluster(NULL), bIsSimple(bSimple)
+		{}
+		KaxInternalBlock(const KaxInternalBlock & ElementToClone);
+		~KaxInternalBlock();
 		bool ValidateSize() const;
 
 		uint16 TrackNum() const {return TrackNumber;}
@@ -230,8 +228,6 @@
 
 		void SetParent(KaxCluster & aParentCluster);
 
-		EbmlElement * Clone() const {return new KaxBlock(*this);}
-
 		/*!
 			\return Returns the lacing type that produces the smallest footprint.
 		*/
@@ -267,8 +263,29 @@
 		uint32 RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault = false);
 
 		KaxCluster * ParentCluster;
+		bool       bIsSimple;
 };
 
+class MATROSKA_DLL_API KaxBlock : public KaxInternalBlock {
+	public:
+		KaxBlock() :KaxInternalBlock(false) {}
+		static EbmlElement & Create() {return *(new KaxBlock);}
+		static const EbmlCallbacks ClassInfos;
+		operator const EbmlId &() const {return ClassInfos.GlobalId;}
+		const EbmlCallbacks & Generic() const {return ClassInfos;}
+		EbmlElement * Clone() const {return new KaxBlock(*this);}
+};
+
+class MATROSKA_DLL_API KaxSimpleBlock : public KaxInternalBlock {
+	public:
+		KaxSimpleBlock() :KaxInternalBlock(true) {}
+		static EbmlElement & Create() {return *(new KaxSimpleBlock);}
+		static const EbmlCallbacks ClassInfos;
+		operator const EbmlId &() const {return ClassInfos.GlobalId;}
+		const EbmlCallbacks & Generic() const {return ClassInfos;}
+		EbmlElement * Clone() const {return new KaxSimpleBlock(*this);}
+};
+
 class MATROSKA_DLL_API KaxBlockDuration : public EbmlUInteger {
 	public:
 		KaxBlockDuration() {}

Modified: trunk/libmatroska/src/KaxBlock.cpp
===================================================================
--- trunk/libmatroska/src/KaxBlock.cpp	2005-10-02 15:16:53 UTC (rev 1208)
+++ trunk/libmatroska/src/KaxBlock.cpp	2005-10-06 21:20:42 UTC (rev 1209)
@@ -3,7 +3,7 @@
 **
 ** <file/class description>
 **
-** Copyright (C) 2002-2004 Steve Lhomme.  All rights reserved.
+** Copyright (C) 2002-2005 Steve Lhomme.  All rights reserved.
 **
 ** This library is free software; you can redistribute it and/or
 ** modify it under the terms of the GNU Lesser General Public
@@ -75,6 +75,7 @@
 
 EbmlId KaxBlockGroup_TheId     (0xA0, 1);
 EbmlId KaxBlock_TheId          (0xA1, 1);
+EbmlId KaxSimpleBlock_TheId    (0xA3, 1);
 EbmlId KaxBlockDuration_TheId  (0x9B, 1);
 #if MATROSKA_VERSION >= 2
 EbmlId KaxBlockVirtual_TheId   (0xA2, 1);
@@ -86,6 +87,7 @@
 
 const EbmlSemanticContext KaxBlockGroup_Context = EbmlSemanticContext(countof(KaxBlockGroup_ContextList), KaxBlockGroup_ContextList, &KaxCluster_Context, *GetKaxGlobal_Context, &KaxBlockGroup::ClassInfos);
 const EbmlSemanticContext KaxBlock_Context = EbmlSemanticContext(0, NULL, &KaxBlockGroup_Context, *GetKaxGlobal_Context, &KaxBlock::ClassInfos);
+const EbmlSemanticContext KaxSimpleBlock_Context = EbmlSemanticContext(0, NULL, &KaxCluster_Context, *GetKaxGlobal_Context, &KaxSimpleBlock::ClassInfos);
 const EbmlSemanticContext KaxBlockDuration_Context = EbmlSemanticContext(0, NULL, &KaxBlockGroup_Context, *GetKaxGlobal_Context, &KaxBlockDuration::ClassInfos);
 #if MATROSKA_VERSION >= 2
 const EbmlSemanticContext KaxBlockVirtual_Context = EbmlSemanticContext(0, NULL, &KaxBlockGroup_Context, *GetKaxGlobal_Context, &KaxBlockVirtual::ClassInfos);
@@ -97,6 +99,7 @@
 
 const EbmlCallbacks KaxBlockGroup::ClassInfos(KaxBlockGroup::Create, KaxBlockGroup_TheId, "BlockGroup", KaxBlockGroup_Context);
 const EbmlCallbacks KaxBlock::ClassInfos(KaxBlock::Create, KaxBlock_TheId, "Block", KaxBlock_Context);
+const EbmlCallbacks KaxSimpleBlock::ClassInfos(KaxSimpleBlock::Create, KaxSimpleBlock_TheId, "SimpleBlock", KaxSimpleBlock_Context);
 const EbmlCallbacks KaxBlockDuration::ClassInfos(KaxBlockDuration::Create, KaxBlockDuration_TheId, "BlockDuration", KaxBlockDuration_Context);
 #if MATROSKA_VERSION >= 2
 const EbmlCallbacks KaxBlockVirtual::ClassInfos(KaxBlockVirtual::Create, KaxBlockVirtual_TheId, "BlockVirtual", KaxBlockVirtual_Context);
@@ -125,17 +128,17 @@
 	bValidValue = ToClone.bValidValue;
 }
 
-bool KaxBlock::ValidateSize() const
+bool KaxInternalBlock::ValidateSize() const
 {
 	return (Size >= 4); /// for the moment
 }
 
-KaxBlock::~KaxBlock()
+KaxInternalBlock::~KaxInternalBlock()
 {
 	ReleaseFrames();
 }
 
-KaxBlock::KaxBlock(const KaxBlock & ElementToClone)
+KaxInternalBlock::KaxInternalBlock(const KaxInternalBlock & ElementToClone)
  :EbmlBinary(ElementToClone)
  ,myBuffers(ElementToClone.myBuffers.size())
  ,Timecode(ElementToClone.Timecode)
@@ -179,7 +182,7 @@
 	\todo hardcoded limit of the number of frames in a lace should be a parameter
 	\return true if more frames can be added to this Block
 */
-bool KaxBlock::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing, bool invisible)
+bool KaxInternalBlock::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing, bool invisible)
 {
 	bValueIsSet = true;
 	if (myBuffers.size() == 0) {
@@ -204,7 +207,7 @@
 /*!
        \return Returns the lacing type that produces the smallest footprint.
 */
-LacingType KaxBlock::GetBestLacingType() const {
+LacingType KaxInternalBlock::GetBestLacingType() const {
 	int XiphLacingSize, EbmlLacingSize, i;
 	bool SameSize = true;
 
@@ -229,10 +232,10 @@
 		return LACING_EBML;
 }
 
-uint64 KaxBlock::UpdateSize(bool bSaveDefault, bool bForceRender)
+uint64 KaxInternalBlock::UpdateSize(bool bSaveDefault, bool bForceRender)
 {
 	LacingType LacingHere;
-	assert(Data == NULL); // Data is not used for KaxBlock
+	assert(Data == NULL); // Data is not used for KaxInternalBlock
 	assert(TrackNumber < 0x4000); // no more allowed for the moment
 	unsigned int i;
 
@@ -321,7 +324,7 @@
 	\todo more optimisation is possible (render the Block head and don't copy the buffer in memory, care should be taken with the allocation of Data)
 	\todo the actual timecode to write should be retrieved from the Cluster from here
 */
-uint32 KaxBlock::RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault)
+uint32 KaxInternalBlock::RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault)
 {
 	if (myBuffers.size() == 0) {
 		return 0;
@@ -457,7 +460,7 @@
 	return Size;
 }
 
-uint64 KaxBlock::ReadInternalHead(IOCallback & input)
+uint64 KaxInternalBlock::ReadInternalHead(IOCallback & input)
 {
 	binary Buffer[5], *cursor = Buffer;
 	uint64 Result = input.read(cursor, 4);
@@ -493,7 +496,7 @@
 /*!
 	\todo better zero copy handling
 */
-uint64 KaxBlock::ReadData(IOCallback & input, ScopeMode ReadFully)
+uint64 KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully)
 {
 	uint64 Result;
 
@@ -774,14 +777,14 @@
 uint64 KaxBlockGroup::GlobalTimecode() const
 {
 	assert(ParentCluster != NULL); // impossible otherwise
-	KaxBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(KaxBlock::ClassInfos));
+	KaxInternalBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(KaxBlock::ClassInfos));
 	return MyBlock.GlobalTimecode();
 
 }
 
 uint16 KaxBlockGroup::TrackNumber() const
 {
-	KaxBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(KaxBlock::ClassInfos));
+	KaxInternalBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(KaxBlock::ClassInfos));
 	return MyBlock.TrackNum();
 }
 
@@ -820,11 +823,11 @@
 
 void KaxBlockGroup::ReleaseFrames()
 {
-	KaxBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(KaxBlock::ClassInfos));
+	KaxInternalBlock & MyBlock = *static_cast<KaxBlock *>(this->FindElt(KaxBlock::ClassInfos));
 	MyBlock.ReleaseFrames();
 }
 
-void KaxBlock::ReleaseFrames()
+void KaxInternalBlock::ReleaseFrames()
 {
 	// free the allocated Frames
 	int i;
@@ -857,7 +860,7 @@
 	return true;
 }
 
-void KaxBlock::SetParent(KaxCluster & aParentCluster)
+void KaxInternalBlock::SetParent(KaxCluster & aParentCluster)
 {
 	ParentCluster = &aParentCluster;
 	if (bLocalTimecodeUsed) {
@@ -866,7 +869,7 @@
 	}
 }
 
-int64 KaxBlock::GetDataPosition(size_t FrameNumber)
+int64 KaxInternalBlock::GetDataPosition(size_t FrameNumber)
 {
 	int64 _Result = -1;
 
@@ -884,7 +887,7 @@
 	return _Result;
 }
 
-int64 KaxBlock::GetFrameSize(size_t FrameNumber)
+int64 KaxInternalBlock::GetFrameSize(size_t FrameNumber)
 {
 	int64 _Result = -1;
 

Modified: trunk/libmatroska/src/KaxCluster.cpp
===================================================================
--- trunk/libmatroska/src/KaxCluster.cpp	2005-10-02 15:16:53 UTC (rev 1208)
+++ trunk/libmatroska/src/KaxCluster.cpp	2005-10-06 21:20:42 UTC (rev 1209)
@@ -3,7 +3,7 @@
 **
 ** <file/class description>
 **
-** Copyright (C) 2002-2004 Steve Lhomme.  All rights reserved.
+** Copyright (C) 2002-2005 Steve Lhomme.  All rights reserved.
 **
 ** This library is free software; you can redistribute it and/or
 ** modify it under the terms of the GNU Lesser General Public
@@ -39,12 +39,13 @@
 // sub elements
 START_LIBMATROSKA_NAMESPACE
 
-EbmlSemantic KaxCluster_ContextList[5] =
+EbmlSemantic KaxCluster_ContextList[6] =
 {
 	EbmlSemantic(true,  true,  KaxClusterTimecode::ClassInfos),
 	EbmlSemantic(false, true,  KaxClusterSilentTracks::ClassInfos),
 	EbmlSemantic(false, true,  KaxClusterPrevSize::ClassInfos),
 	EbmlSemantic(true,  false, KaxBlockGroup::ClassInfos),
+	EbmlSemantic(true,  false, KaxSimpleBlock::ClassInfos),
 	EbmlSemantic(false, true,  KaxClusterPosition::ClassInfos),
 };