libmatroska: KaxCues::AddBlockGroup() was removed as it's broken beyond repair

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libmatroska@453 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
Steve Lhomme 2010-07-29 19:06:19 +00:00
parent 2be628cfe9
commit 5ebfbd2cda
5 changed files with 119 additions and 101 deletions

View File

@ -4,6 +4,7 @@ New 1.1.0 version:
- change the placement of a MATROSKA_DLL_API so that it actually works - change the placement of a MATROSKA_DLL_API so that it actually works
- remove all references to the old/outdated/previous tag system - remove all references to the old/outdated/previous tag system
- add the possibility for a DataBuffer class to use its own internal memory - add the possibility for a DataBuffer class to use its own internal memory
- KaxCues::AddBlockGroup() was removed as it's broken beyond repair
2010-06-04 robux4/mosu 2010-06-04 robux4/mosu
New 1.0.0 version: New 1.0.0 version:

View File

@ -312,6 +312,7 @@ class MATROSKA_DLL_API KaxSimpleBlock : public KaxInternalBlock {
}; };
#endif // MATROSKA_VERSION #endif // MATROSKA_VERSION
/// Placeholder class for either a BlockGroup or a SimpleBlock
class MATROSKA_DLL_API KaxBlockBlob { class MATROSKA_DLL_API KaxBlockBlob {
public: public:
KaxBlockBlob(BlockBlobType sblock_mode) :ParentCluster(NULL), SimpleBlockMode(sblock_mode) { KaxBlockBlob(BlockBlobType sblock_mode) :ParentCluster(NULL), SimpleBlockMode(sblock_mode) {

View File

@ -1,91 +1,91 @@
/**************************************************************************** /****************************************************************************
** libmatroska : parse Matroska files, see http://www.matroska.org/ ** libmatroska : parse Matroska files, see http://www.matroska.org/
** **
** <file/class description> ** <file/class description>
** **
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved. ** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
** **
** This file is part of libmatroska. ** This file is part of libmatroska.
** **
** This library is free software; you can redistribute it and/or ** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public ** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either ** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version. ** version 2.1 of the License, or (at your option) any later version.
** **
** This library is distributed in the hope that it will be useful, ** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of ** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details. ** Lesser General Public License for more details.
** **
** You should have received a copy of the GNU Lesser General Public ** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software ** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
** **
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.** ** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.**
** Contact license@matroska.org if any conditions of this licensing are ** Contact license@matroska.org if any conditions of this licensing are
** not clear to you. ** not clear to you.
** **
**********************************************************************/ **********************************************************************/
/*! /*!
\file \file
\version \$Id: KaxCues.h,v 1.7 2004/04/14 23:26:17 robux4 Exp $ \version \$Id: KaxCues.h,v 1.7 2004/04/14 23:26:17 robux4 Exp $
\author Steve Lhomme <robux4 @ users.sf.net> \author Steve Lhomme <robux4 @ users.sf.net>
*/ */
#ifndef LIBMATROSKA_CUES_H #ifndef LIBMATROSKA_CUES_H
#define LIBMATROSKA_CUES_H #define LIBMATROSKA_CUES_H
#include <vector> #include <vector>
#include "matroska/KaxTypes.h" #include "matroska/KaxTypes.h"
#include "ebml/EbmlMaster.h" #include "ebml/EbmlMaster.h"
#include "matroska/KaxBlock.h" #include "matroska/KaxBlock.h"
using namespace LIBEBML_NAMESPACE; using namespace LIBEBML_NAMESPACE;
START_LIBMATROSKA_NAMESPACE START_LIBMATROSKA_NAMESPACE
class KaxCuePoint; class KaxCuePoint;
DECLARE_MKX_MASTER(KaxCues) DECLARE_MKX_MASTER(KaxCues)
public: public:
~KaxCues(); ~KaxCues();
bool AddBlockGroup(const KaxBlockGroup & BlockReference); //bool AddBlockGroup(const KaxBlockGroup & BlockReference); // deprecated
bool AddBlockBlob(const KaxBlockBlob & BlockReference); bool AddBlockBlob(const KaxBlockBlob & BlockReference);
/*! /*!
\brief Indicate that the position for this Block is set \brief Indicate that the position for this Block is set
*/ */
void PositionSet(const KaxBlockGroup & BlockReference); void PositionSet(const KaxBlockGroup & BlockReference);
void PositionSet(const KaxBlockBlob & BlockReference); void PositionSet(const KaxBlockBlob & BlockReference);
/*! /*!
\brief override to sort by timecode/track \brief override to sort by timecode/track
*/ */
filepos_t Render(IOCallback & output, bool bSaveDefault = false) { filepos_t Render(IOCallback & output, bool bSaveDefault = false) {
Sort(); Sort();
return EbmlMaster::Render(output, bSaveDefault); return EbmlMaster::Render(output, bSaveDefault);
} }
uint64 GetTimecodePosition(uint64 aTimecode) const; uint64 GetTimecodePosition(uint64 aTimecode) const;
const KaxCuePoint * GetTimecodePoint(uint64 aTimecode) const; const KaxCuePoint * GetTimecodePoint(uint64 aTimecode) const;
void SetGlobalTimecodeScale(uint64 aGlobalTimecodeScale) { void SetGlobalTimecodeScale(uint64 aGlobalTimecodeScale) {
mGlobalTimecodeScale = aGlobalTimecodeScale; mGlobalTimecodeScale = aGlobalTimecodeScale;
bGlobalTimecodeScaleIsSet = true; bGlobalTimecodeScaleIsSet = true;
} }
uint64 GlobalTimecodeScale() const { uint64 GlobalTimecodeScale() const {
assert(bGlobalTimecodeScaleIsSet); assert(bGlobalTimecodeScaleIsSet);
return mGlobalTimecodeScale; return mGlobalTimecodeScale;
} }
protected: protected:
std::vector<const KaxBlockBlob *> myTempReferences; std::vector<const KaxBlockBlob *> myTempReferences;
bool bGlobalTimecodeScaleIsSet; bool bGlobalTimecodeScaleIsSet;
uint64 mGlobalTimecodeScale; uint64 mGlobalTimecodeScale;
}; };
END_LIBMATROSKA_NAMESPACE END_LIBMATROSKA_NAMESPACE
#endif // LIBMATROSKA_CUES_H #endif // LIBMATROSKA_CUES_H

View File

@ -51,22 +51,25 @@ KaxCues::~KaxCues()
{ {
assert(myTempReferences.size() == 0); // otherwise that means you have added references and forgot to set the position assert(myTempReferences.size() == 0); // otherwise that means you have added references and forgot to set the position
} }
/* deprecated and wrong
bool KaxCues::AddBlockGroup(const KaxBlockGroup & BlockRef) bool KaxCues::AddBlockGroup(const KaxBlockGroup & BlockRef)
{ {
// Do not add the element if it's already present. // Do not add the element if it's already present.
std::vector<const KaxBlockBlob *>::iterator ListIdx; std::vector<const KaxBlockBlob *>::iterator ListIdx;
KaxBlockBlob &BlockReference = *(new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE)); KaxBlockBlob *BlockReference = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE);
BlockReference.SetBlockGroup(*const_cast<KaxBlockGroup*>(&BlockRef)); BlockReference->SetBlockGroup(*const_cast<KaxBlockGroup*>(&BlockRef));
for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ListIdx++) for (ListIdx = myTempReferences.begin(); ListIdx != myTempReferences.end(); ListIdx++)
if (*ListIdx == &BlockReference) if (&(KaxBlockGroup&)*ListIdx == &BlockRef)
{
delete BlockReference;
return true; return true;
}
myTempReferences.push_back(&BlockReference); myTempReferences.push_back(BlockReference);
return true; return true;
} }
*/
bool KaxCues::AddBlockBlob(const KaxBlockBlob & BlockReference) bool KaxCues::AddBlockBlob(const KaxBlockBlob & BlockReference)
{ {
// Do not add the element if it's already present. // Do not add the element if it's already present.

View File

@ -252,13 +252,17 @@ int main(int argc, char **argv)
Clust1.AddFrame(MyTrack2, 23 * TIMECODE_SCALE, *data5, MyNewBlock); // to test with another track Clust1.AddFrame(MyTrack2, 23 * TIMECODE_SCALE, *data5, MyNewBlock); // to test with another track
// add the "real" block to the cue entries // add the "real" block to the cue entries
AllCues.AddBlockGroup(*MyLastBlockTrk1); KaxBlockBlob *Blob1 = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE);
Blob1->SetBlockGroup(*MyLastBlockTrk1);
AllCues.AddBlockBlob(*Blob1);
// frame for Track 2 // frame for Track 2
DataBuffer *data8 = new DataBuffer((binary *)"tttyyy", countof("tttyyy")); DataBuffer *data8 = new DataBuffer((binary *)"tttyyy", countof("tttyyy"));
Clust1.AddFrame(MyTrack2, 107 * TIMECODE_SCALE, *data8, MyNewBlock, *MyLastBlockTrk2); Clust1.AddFrame(MyTrack2, 107 * TIMECODE_SCALE, *data8, MyNewBlock, *MyLastBlockTrk2);
AllCues.AddBlockGroup(*MyNewBlock); KaxBlockBlob *Blob2 = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE);
Blob2->SetBlockGroup(*MyNewBlock);
AllCues.AddBlockBlob(*Blob2);
// frame with a past reference // frame with a past reference
DataBuffer *data4 = new DataBuffer((binary *)"tttyyy", countof("tttyyy")); DataBuffer *data4 = new DataBuffer((binary *)"tttyyy", countof("tttyyy"));
@ -275,7 +279,9 @@ int main(int argc, char **argv)
} }
} }
AllCues.AddBlockGroup(*MyLastBlockTrk1); KaxBlockBlob *Blob3 = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE);
Blob3->SetBlockGroup(*MyLastBlockTrk1);
AllCues.AddBlockBlob(*Blob3);
//AllCues.UpdateSize(); //AllCues.UpdateSize();
// simulate the writing of the stream : // simulate the writing of the stream :
@ -295,7 +301,9 @@ int main(int argc, char **argv)
DataBuffer *data2 = new DataBuffer((binary *)"tttyyy", countof("tttyyy")); DataBuffer *data2 = new DataBuffer((binary *)"tttyyy", countof("tttyyy"));
Clust2.AddFrame(MyTrack1, 350 * TIMECODE_SCALE, *data2, MyNewBlock, *MyLastBlockTrk1); Clust2.AddFrame(MyTrack1, 350 * TIMECODE_SCALE, *data2, MyNewBlock, *MyLastBlockTrk1);
AllCues.AddBlockGroup(*MyNewBlock); KaxBlockBlob *Blob4 = new KaxBlockBlob(BLOCK_BLOB_NO_SIMPLE);
Blob4->SetBlockGroup(*MyNewBlock);
AllCues.AddBlockBlob(*Blob4);
ClusterSize += Clust2.Render(out_file, AllCues, bWriteDefaultValues); ClusterSize += Clust2.Render(out_file, AllCues, bWriteDefaultValues);
Clust2.ReleaseFrames(); Clust2.ReleaseFrames();
@ -383,6 +391,11 @@ int main(int argc, char **argv)
MuxedFile.Close(1000); // 1000 ms MuxedFile.Close(1000); // 1000 ms
#endif // OLD #endif // OLD
out_file.close(); out_file.close();
delete Blob1;
delete Blob2;
delete Blob3;
delete Blob4;
} }
catch (exception & Ex) catch (exception & Ex)
{ {