From 72abb5578e36cfe77293aadbfdcb18edc511991d Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Sat, 7 Aug 2010 09:42:47 +0000 Subject: [PATCH] libmatroska: add KaxTrackDependency and related elements for combined stereo/3D tracks git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libmatroska@480 a6f86f6d-0131-4f8e-9e7b-e335508773d5 --- ChangeLog | 3 +- matroska/KaxTracks.h | 179 +++++++++++++++++++---------------- src/KaxTracks.cpp | 219 ++++++++++++++++++++++++------------------- 3 files changed, 220 insertions(+), 181 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a04648..8f6652c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,11 @@ -2010-07-xx robux4 +2010-08-xx robux4 New 1.1.0 version: - give access to the SetParent to KaxSimpleBlock as well - change the placement of a MATROSKA_DLL_API so that it actually works - remove all references to the old/outdated/previous tag system - add the possibility for a DataBuffer class to use its own internal memory - KaxCues::AddBlockGroup() was removed as it's broken beyond repair + - add KaxTrackDependency and related elements for combined stereo/3D tracks 2010-06-04 robux4/mosu New 1.0.0 version: diff --git a/matroska/KaxTracks.h b/matroska/KaxTracks.h index 6000099..a7a4b8f 100644 --- a/matroska/KaxTracks.h +++ b/matroska/KaxTracks.h @@ -1,81 +1,98 @@ -/**************************************************************************** -** libmatroska : parse Matroska files, see http://www.matroska.org/ -** -** -** -** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved. -** -** This file is part of libmatroska. -** -** This library is free software; you can redistribute it and/or -** modify it under the terms of the GNU Lesser General Public -** License as published by the Free Software Foundation; either -** 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, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public -** License along with this library; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -** -** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.** -** Contact license@matroska.org if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -/*! - \file - \version \$Id: KaxTracks.h,v 1.7 2004/04/14 23:26:17 robux4 Exp $ - \author Steve Lhomme -*/ -#ifndef LIBMATROSKA_TRACKS_H -#define LIBMATROSKA_TRACKS_H - -#include "matroska/KaxTypes.h" -#include "ebml/EbmlMaster.h" -#include "ebml/EbmlUInteger.h" -#include "matroska/KaxTrackEntryData.h" -#include "matroska/KaxDefines.h" - -using namespace LIBEBML_NAMESPACE; - -START_LIBMATROSKA_NAMESPACE - -DECLARE_MKX_MASTER(KaxTracks) -}; - -DECLARE_MKX_MASTER(KaxTrackEntry) - public: - EbmlUInteger & TrackNumber() const { return *(static_cast(FindElt(EBML_INFO(KaxTrackNumber)))); } - - void EnableLacing(bool bEnable = true); - - /*! - \note lacing set by default - */ - inline bool LacingEnabled() const { - KaxTrackFlagLacing * myLacing = static_cast(FindFirstElt(EBML_INFO(KaxTrackFlagLacing))); - return((myLacing == NULL) || (uint8(*myLacing) != 0)); - } - - void SetGlobalTimecodeScale(uint64 aGlobalTimecodeScale) { - mGlobalTimecodeScale = aGlobalTimecodeScale; - bGlobalTimecodeScaleIsSet = true; - } - uint64 GlobalTimecodeScale() const { - assert(bGlobalTimecodeScaleIsSet); - return mGlobalTimecodeScale; - } - - protected: - bool bGlobalTimecodeScaleIsSet; - uint64 mGlobalTimecodeScale; -}; - -END_LIBMATROSKA_NAMESPACE - -#endif // LIBMATROSKA_TRACKS_H +/**************************************************************************** +** libmatroska : parse Matroska files, see http://www.matroska.org/ +** +** +** +** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved. +** +** This file is part of libmatroska. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License as published by the Free Software Foundation; either +** 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, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public +** License along with this library; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +** +** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.** +** Contact license@matroska.org if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +/*! + \file + \version \$Id: KaxTracks.h,v 1.7 2004/04/14 23:26:17 robux4 Exp $ + \author Steve Lhomme +*/ +#ifndef LIBMATROSKA_TRACKS_H +#define LIBMATROSKA_TRACKS_H + +#include "matroska/KaxTypes.h" +#include "ebml/EbmlMaster.h" +#include "ebml/EbmlUInteger.h" +#include "matroska/KaxTrackEntryData.h" +#include "matroska/KaxDefines.h" + +using namespace LIBEBML_NAMESPACE; + +START_LIBMATROSKA_NAMESPACE + +DECLARE_MKX_MASTER(KaxTracks) +}; + +DECLARE_MKX_MASTER(KaxTrackEntry) + public: + EbmlUInteger & TrackNumber() const { return *(static_cast(FindElt(EBML_INFO(KaxTrackNumber)))); } + + void EnableLacing(bool bEnable = true); + + /*! + \note lacing set by default + */ + inline bool LacingEnabled() const { + KaxTrackFlagLacing * myLacing = static_cast(FindFirstElt(EBML_INFO(KaxTrackFlagLacing))); + return((myLacing == NULL) || (uint8(*myLacing) != 0)); + } + + void SetGlobalTimecodeScale(uint64 aGlobalTimecodeScale) { + mGlobalTimecodeScale = aGlobalTimecodeScale; + bGlobalTimecodeScaleIsSet = true; + } + uint64 GlobalTimecodeScale() const { + assert(bGlobalTimecodeScaleIsSet); + return mGlobalTimecodeScale; + } + + protected: + bool bGlobalTimecodeScaleIsSet; + uint64 mGlobalTimecodeScale; +}; + +#if MATROSKA_VERSION >= 2 +DECLARE_MKX_MASTER(KaxTrackDependency) +}; + +DECLARE_MKX_UINTEGER(KaxTrackDependencyType) +}; + +DECLARE_MKX_MASTER(KaxTrackDependencyItem) +}; + +DECLARE_MKX_UINTEGER(KaxTrackDependencyUID) +}; + +DECLARE_MKX_UINTEGER(KaxTrackDependencyStereoPos) +}; +#endif + +END_LIBMATROSKA_NAMESPACE + +#endif // LIBMATROSKA_TRACKS_H diff --git a/src/KaxTracks.cpp b/src/KaxTracks.cpp index dd549ad..81b77d5 100644 --- a/src/KaxTracks.cpp +++ b/src/KaxTracks.cpp @@ -1,99 +1,120 @@ -/**************************************************************************** -** libmatroska : parse Matroska files, see http://www.matroska.org/ -** -** -** -** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved. -** -** This file is part of libmatroska. -** -** This library is free software; you can redistribute it and/or -** modify it under the terms of the GNU Lesser General Public -** License as published by the Free Software Foundation; either -** 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, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** Lesser General Public License for more details. -** -** You should have received a copy of the GNU Lesser General Public -** License along with this library; if not, write to the Free Software -** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -** -** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.** -** Contact license@matroska.org if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ - -/*! - \file - \version \$Id: KaxTracks.cpp 1202 2005-08-30 14:39:01Z robux4 $ - \author Steve Lhomme -*/ -#include "matroska/KaxTracks.h" - -// sub elements -#include "matroska/KaxTrackEntryData.h" -#include "matroska/KaxTrackAudio.h" -#include "matroska/KaxTrackVideo.h" -#include "matroska/KaxContentEncoding.h" -#include "matroska/KaxContexts.h" -#include "matroska/KaxDefines.h" - -START_LIBMATROSKA_NAMESPACE - -DEFINE_START_SEMANTIC(KaxTracks) -DEFINE_SEMANTIC_ITEM(true, false, KaxTrackEntry) -DEFINE_END_SEMANTIC(KaxTracks) - -DEFINE_START_SEMANTIC(KaxTrackEntry) -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackNumber) -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackUID) -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackType) -#if MATROSKA_VERSION >= 2 -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackFlagEnabled) -#endif // MATROSKA_VERSION -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackFlagDefault) -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackFlagForced) -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackFlagLacing) -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackMinCache) -DEFINE_SEMANTIC_ITEM(false, true, KaxTrackMaxCache) -DEFINE_SEMANTIC_ITEM(false, true, KaxTrackDefaultDuration) -DEFINE_SEMANTIC_ITEM(true, true, KaxTrackTimecodeScale) -DEFINE_SEMANTIC_ITEM(true, true, KaxMaxBlockAdditionID) -DEFINE_SEMANTIC_ITEM(false, true, KaxTrackName) -DEFINE_SEMANTIC_ITEM(false, true, KaxTrackLanguage) -DEFINE_SEMANTIC_ITEM(true, true, KaxCodecID) -DEFINE_SEMANTIC_ITEM(false, true, KaxCodecPrivate) -DEFINE_SEMANTIC_ITEM(false, true, KaxCodecName) -DEFINE_SEMANTIC_ITEM(false, true, KaxTrackAttachmentLink) -#if MATROSKA_VERSION >= 2 -DEFINE_SEMANTIC_ITEM(false, true, KaxCodecSettings) -DEFINE_SEMANTIC_ITEM(false, false, KaxCodecInfoURL) -DEFINE_SEMANTIC_ITEM(false, false, KaxCodecDownloadURL) -DEFINE_SEMANTIC_ITEM(true, true, KaxCodecDecodeAll) -#endif // MATROSKA_VERSION -DEFINE_SEMANTIC_ITEM(false, false, KaxTrackOverlay) -DEFINE_SEMANTIC_ITEM(false, false, KaxTrackTranslate) -DEFINE_SEMANTIC_ITEM(false, true, KaxTrackAudio) -DEFINE_SEMANTIC_ITEM(false, true, KaxTrackVideo) -DEFINE_SEMANTIC_ITEM(false, true, KaxContentEncodings) -DEFINE_END_SEMANTIC(KaxTrackEntry) - -DEFINE_MKX_MASTER (KaxTracks, 0x1654AE6B, 4, KaxSegment, "Tracks"); -DEFINE_MKX_MASTER_CONS(KaxTrackEntry, 0xAE, 1, KaxTracks, "TrackEntry"); - -KaxTrackEntry::KaxTrackEntry(EBML_EXTRA_DEF) - :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxTrackEntry) EBML_DEF_SEP EBML_EXTRA_CALL) - ,bGlobalTimecodeScaleIsSet(false) -{} - -void KaxTrackEntry::EnableLacing(bool bEnable) -{ - KaxTrackFlagLacing & myLacing = GetChild(*this); - *(static_cast(&myLacing)) = bEnable ? 1 : 0; -} - -END_LIBMATROSKA_NAMESPACE +/**************************************************************************** +** libmatroska : parse Matroska files, see http://www.matroska.org/ +** +** +** +** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved. +** +** This file is part of libmatroska. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License as published by the Free Software Foundation; either +** 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, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public +** License along with this library; if not, write to the Free Software +** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +** +** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.** +** Contact license@matroska.org if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +/*! + \file + \version \$Id: KaxTracks.cpp 1202 2005-08-30 14:39:01Z robux4 $ + \author Steve Lhomme +*/ +#include "matroska/KaxTracks.h" + +// sub elements +#include "matroska/KaxTrackEntryData.h" +#include "matroska/KaxTrackAudio.h" +#include "matroska/KaxTrackVideo.h" +#include "matroska/KaxContentEncoding.h" +#include "matroska/KaxContexts.h" +#include "matroska/KaxDefines.h" + +START_LIBMATROSKA_NAMESPACE + +DEFINE_START_SEMANTIC(KaxTracks) +DEFINE_SEMANTIC_ITEM(true, false, KaxTrackEntry) +#if MATROSKA_VERSION >= 2 +DEFINE_SEMANTIC_ITEM(false, false, KaxTrackDependency) +#endif +DEFINE_END_SEMANTIC(KaxTracks) + +DEFINE_START_SEMANTIC(KaxTrackEntry) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackNumber) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackUID) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackType) +#if MATROSKA_VERSION >= 2 +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackFlagEnabled) +#endif // MATROSKA_VERSION +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackFlagDefault) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackFlagForced) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackFlagLacing) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackMinCache) +DEFINE_SEMANTIC_ITEM(false, true, KaxTrackMaxCache) +DEFINE_SEMANTIC_ITEM(false, true, KaxTrackDefaultDuration) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackTimecodeScale) +DEFINE_SEMANTIC_ITEM(true, true, KaxMaxBlockAdditionID) +DEFINE_SEMANTIC_ITEM(false, true, KaxTrackName) +DEFINE_SEMANTIC_ITEM(false, true, KaxTrackLanguage) +DEFINE_SEMANTIC_ITEM(true, true, KaxCodecID) +DEFINE_SEMANTIC_ITEM(false, true, KaxCodecPrivate) +DEFINE_SEMANTIC_ITEM(false, true, KaxCodecName) +DEFINE_SEMANTIC_ITEM(false, true, KaxTrackAttachmentLink) +#if MATROSKA_VERSION >= 2 +DEFINE_SEMANTIC_ITEM(false, true, KaxCodecSettings) +DEFINE_SEMANTIC_ITEM(false, false, KaxCodecInfoURL) +DEFINE_SEMANTIC_ITEM(false, false, KaxCodecDownloadURL) +DEFINE_SEMANTIC_ITEM(true, true, KaxCodecDecodeAll) +#endif // MATROSKA_VERSION +DEFINE_SEMANTIC_ITEM(false, false, KaxTrackOverlay) +DEFINE_SEMANTIC_ITEM(false, false, KaxTrackTranslate) +DEFINE_SEMANTIC_ITEM(false, true, KaxTrackAudio) +DEFINE_SEMANTIC_ITEM(false, true, KaxTrackVideo) +DEFINE_SEMANTIC_ITEM(false, true, KaxContentEncodings) +DEFINE_END_SEMANTIC(KaxTrackEntry) + +DEFINE_MKX_MASTER (KaxTracks, 0x1654AE6B, 4, KaxSegment, "Tracks"); +DEFINE_MKX_MASTER_CONS(KaxTrackEntry, 0xAE, 1, KaxTracks, "TrackEntry"); + +#if MATROSKA_VERSION >= 2 +DEFINE_START_SEMANTIC(KaxTrackDependency) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackDependencyType) +DEFINE_SEMANTIC_ITEM(true, false, KaxTrackDependencyItem) +DEFINE_END_SEMANTIC(KaxTrackDependency) + +DEFINE_START_SEMANTIC(KaxTrackDependencyItem) +DEFINE_SEMANTIC_ITEM(true, true, KaxTrackDependencyUID) +DEFINE_SEMANTIC_ITEM(false, true, KaxTrackDependencyStereoPos) +DEFINE_END_SEMANTIC(KaxTrackDependencyItem) + +DEFINE_MKX_MASTER (KaxTrackDependency, 0xE2, 1, KaxTracks, "TrackDependency"); +DEFINE_MKX_UINTEGER(KaxTrackDependencyType, 0xE3, 1, KaxTrackDependency, "TrackDependencyType"); +DEFINE_MKX_MASTER (KaxTrackDependencyItem, 0xE4, 1, KaxTrackDependency, "TrackDependencyItem"); +DEFINE_MKX_UINTEGER(KaxTrackDependencyUID, 0xE5, 1, KaxTrackDependencyItem, "TrackDependencyUID"); +DEFINE_MKX_UINTEGER(KaxTrackDependencyStereoPos, 0xE9, 1, KaxTrackDependencyItem, "TrackDependencyStereoPos"); +#endif + +KaxTrackEntry::KaxTrackEntry(EBML_EXTRA_DEF) + :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxTrackEntry) EBML_DEF_SEP EBML_EXTRA_CALL) + ,bGlobalTimecodeScaleIsSet(false) +{} + +void KaxTrackEntry::EnableLacing(bool bEnable) +{ + KaxTrackFlagLacing & myLacing = GetChild(*this); + *(static_cast(&myLacing)) = bEnable ? 1 : 0; +} + +END_LIBMATROSKA_NAMESPACE -- 2.40.0