Commit fd16fb7d authored by Steve Lhomme's avatar Steve Lhomme

introduce the CRC reading (not checking anything yet) on demand (new param)

git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/foundation_src@492 a6f86f6d-0131-4f8e-9e7b-e335508773d5
parent 574d131a
......@@ -129,7 +129,7 @@ typedef struct ebml_element_vmt
{
nodetree_vmt Base;
bool_t (*ValidateSize)(const void*);
err_t (*ReadData)(void*, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope);
err_t (*ReadData)(void*, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC);
#if defined(CONFIG_EBML_WRITING)
err_t (*RenderData)(void*, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered);
#endif
......@@ -145,7 +145,7 @@ typedef struct ebml_element_vmt
} ebml_element_vmt;
#define EBML_ElementValidateSize(p) VMT_FUNC(p,ebml_element_vmt)->ValidateSize(p)
#define EBML_ElementReadData(p,s,c,d,e) VMT_FUNC(p,ebml_element_vmt)->ReadData(p,s,c,d,e)
#define EBML_ElementReadData(p,i,c,d,s,r) VMT_FUNC(p,ebml_element_vmt)->ReadData(p,i,c,d,s,r)
#define EBML_ElementRenderData(p,s,f,k,r) VMT_FUNC(p,ebml_element_vmt)->RenderData(p,s,f,k,r)
#define EBML_ElementIsDefaultValue(p) VMT_FUNC(p,ebml_element_vmt)->IsDefaultValue(p)
#define EBML_ElementUpdateSize(p,k,f) VMT_FUNC(p,ebml_element_vmt)->UpdateSize(p,k,f)
......@@ -155,6 +155,7 @@ typedef struct ebml_element_vmt
typedef struct ebml_master
{
ebml_element Base;
int CheckSumStatus; // 0: not set, 1: requested/invalid, 2: verified
} ebml_master;
......@@ -252,6 +253,8 @@ EBML_DLL void EBML_MasterErase(ebml_master *Element);
EBML_DLL void EBML_MasterMandatory(ebml_master *Element, bool_t SetDefault); // add the mandatory elements
EBML_DLL bool_t EBML_MasterCheckMandatory(const ebml_master *Element, bool_t SetDefault);
EBML_DLL void EBML_MasterSort(ebml_master *Element, arraycmp Cmp, const void* CmpParam);
EBML_DLL void EBML_MasterUseChecksum(ebml_master *Element, bool_t Use);
EBML_DLL bool_t EBML_MasterIsChecksumValid(const ebml_master *Element);
#define EBML_MasterGetChild(e,c) EBML_MasterFindFirstElt(e,c,1,1)
#define EBML_MasterFindChild(e,c) EBML_MasterFindFirstElt((ebml_master*)e,c,0,0)
#define EBML_MasterChildren(p) ((ebml_element*)NodeTree_Children(p))
......
......@@ -27,7 +27,7 @@
*/
#include "ebml/ebml.h"
static err_t ReadData(ebml_binary *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadData(ebml_binary *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
err_t Result;
......
......@@ -35,12 +35,14 @@ struct ebml_crc
uint32_t CRC;
};
const uint32_t CRC32_NEGL = 0xffffffffL;
static bool_t ValidateSize(const ebml_element *p)
{
return EBML_ElementIsFiniteSize(p) && (p->DataSize == 4);
}
static err_t ReadData(ebml_crc *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadData(ebml_crc *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
err_t Result;
uint32_t CRCbuffer;
......@@ -69,9 +71,21 @@ static ebml_crc *Copy(const ebml_crc *Element, const void *Cookie)
return Result;
}
static err_t Create(ebml_crc *Element)
{
Element->CRC = CRC32_NEGL;
return ERR_NONE;
}
META_START(EBMLCRC_Class,EBML_CRC_CLASS)
META_CLASS(SIZE,sizeof(ebml_crc))
META_CLASS(CREATE,Create)
META_VMT(TYPE_FUNC,ebml_element_vmt,ValidateSize,ValidateSize)
META_VMT(TYPE_FUNC,ebml_element_vmt,ReadData,ReadData)
META_VMT(TYPE_FUNC,ebml_element_vmt,Copy,Copy)
META_END(EBML_ELEMENT_CLASS)
bool_t EBML_CRCMatches(ebml_element *CRC, const uint8_t *Buf, size_t Size)
{
return 1;
}
\ No newline at end of file
/*
* $Id$
* Copyright (c) 2008, Matroska Foundation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Matroska Foundation nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY The Matroska Foundation ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL The Matroska Foundation BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __LIBEBML_CRC_H
#define __LIBEBML_CRC_H
extern bool_t EBML_CRCMatches(ebml_element *CRC, const uint8_t *Buf, size_t Size);
#endif /* __LIBEBML_CRC_H */
\ No newline at end of file
......@@ -48,7 +48,7 @@ static bool_t ValidateSize(const ebml_element *p)
return EBML_ElementIsFiniteSize(p) && (p->DataSize == 8 || p->DataSize == 0);
}
static err_t ReadData(ebml_date *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadData(ebml_date *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
err_t Result;
int DataSize;
......
......@@ -26,6 +26,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ebml/ebml.h"
#include "ebmlcrc.h"
ebml_element *EBML_MasterAddElt(ebml_master *Element, const ebml_context *Context, bool_t SetDefault)
{
......@@ -221,10 +222,13 @@ static void PostCreate(ebml_master *Element)
EBML_MasterMandatory(Element,1); // TODO: should it force the default value ?
}
static err_t ReadData(ebml_master *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadData(ebml_master *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
int UpperEltFound = 0;
bool_t bFirst = 1;
ebml_element *SubElement;
stream *ReadStream = Input;
array CrcBuffer;
// remove all existing elements, including the mandatory ones...
NodeTree_Clear((nodetree*)Element);
......@@ -247,16 +251,44 @@ static err_t ReadData(ebml_master *Element, stream *Input, const ebml_parser_con
{
if (!AllowDummyElt && EBML_ElementIsDummy(SubElement)) {
// TODO: this should never happen
EBML_ElementSkipData(SubElement,Input,&Context,NULL,AllowDummyElt);
EBML_ElementSkipData(SubElement,ReadStream,&Context,NULL,AllowDummyElt);
NodeDelete((node*)SubElement); // forget this unknown element
}
else
{
if (EBML_ElementReadData(SubElement,Input,&Context,AllowDummyElt, Scope)==ERR_NONE)
if (bFirst && DepthCheckCRC && Scope!=SCOPE_NO_DATA && SubElement->Context->Id==EBML_ContextEbmlCrc32.Id)
{
if (EBML_ElementIsFiniteSize((ebml_element*)Element))
{
// read the rest of the element in memory to avoid reading it a second time later
ArrayInit(&CrcBuffer);
if (ArrayResize(&CrcBuffer, (size_t)(EBML_ElementPositionEnd((ebml_element*)Element) - EBML_ElementPositionEnd(SubElement)), 0))
{
ReadStream = (stream*)NodeCreate(Element, MEMSTREAM_CLASS);
if (ReadStream==NULL)
{
ReadStream=Input; // revert back to normal reading
ArrayClear(&CrcBuffer);
}
else
{
Node_Set(ReadStream, MEMSTREAM_DATA, ARRAYBEGIN(CrcBuffer,uint8_t), ARRAYCOUNT(CrcBuffer,uint8_t));
Stream_Seek(Input,EBML_ElementPositionEnd(SubElement),SEEK_SET);
if (Stream_Read(Input, ARRAYBEGIN(CrcBuffer,uint8_t), ARRAYCOUNT(CrcBuffer,uint8_t), NULL)!=ERR_NONE)
{
ReadStream=Input; // revert back to normal reading
ArrayClear(&CrcBuffer);
}
}
}
}
bFirst = 0;
}
if (EBML_ElementReadData(SubElement,ReadStream,&Context,AllowDummyElt, Scope, DepthCheckCRC?DepthCheckCRC-1:0)==ERR_NONE)
{
EBML_MasterAppend(Element,SubElement);
// just in case
EBML_ElementSkipData(SubElement,Input,&Context,NULL,AllowDummyElt);
EBML_ElementSkipData(SubElement,ReadStream,&Context,NULL,AllowDummyElt);
}
else
{
......@@ -284,21 +316,17 @@ static err_t ReadData(ebml_master *Element, stream *Input, const ebml_parser_con
goto processCrc;// this level is finished
}
SubElement = EBML_FindNextElement(Input,&Context,&UpperEltFound,AllowDummyElt);
SubElement = EBML_FindNextElement(ReadStream,&Context,&UpperEltFound,AllowDummyElt);
}
}
processCrc:
#ifdef TODO
for (Index=0; Index<ElementList.size(); Index++) {
if (ElementList[Index]->Generic().GlobalId == EbmlCrc32::ClassInfos.GlobalId) {
bChecksumUsed = true;
// remove the element
Checksum = *(static_cast<EbmlCrc32*>(ElementList[Index]));
delete ElementList[Index];
Remove(Index--);
}
}
#endif
if (ReadStream!=Input)
{
Element->CheckSumStatus = EBML_CRCMatches(SubElement, ARRAYBEGIN(CrcBuffer,uint8_t), ARRAYCOUNT(CrcBuffer,uint8_t))?2:1;
StreamClose(ReadStream);
ArrayClear(&CrcBuffer);
}
Element->Base.bValueIsSet = 1;
if (UpperEltFound>0) // move back to the upper element beginning so that the next loop can find it
{
......@@ -308,6 +336,16 @@ processCrc:
return ERR_NONE;
}
void EBML_MasterUseChecksum(ebml_master *Element, bool_t Use)
{
Element->CheckSumStatus = 1;
}
bool_t EBML_MasterIsChecksumValid(const ebml_master *Element)
{
return (Element->CheckSumStatus!=1);
}
#if defined(CONFIG_EBML_WRITING)
static err_t RenderData(ebml_element *Element, stream *Output, bool_t bForceRender, bool_t bWithDefault, filepos_t *Rendered)
{
......@@ -325,7 +363,7 @@ static err_t RenderData(ebml_element *Element, stream *Output, bool_t bForceRend
}
#ifdef TODO
if (!bChecksumUsed) { // old school
if (!Element->bChecksumUsed) { // old school
#endif
for (i=EBML_MasterChildren(Element);i;i=EBML_MasterNext(i))
{
......@@ -368,7 +406,7 @@ static ebml_element *Copy(const ebml_master *Element, const void *Cookie)
Result->Base.ElementPosition = Element->Base.ElementPosition;
Result->Base.SizeLength = Element->Base.SizeLength;
Result->Base.SizePosition = Element->Base.SizePosition;
Result->bChecksumUsed = Element->bChecksumUsed;
Result->CheckSumStatus = Element->CheckSumStatus;
for (i=EBML_MasterChildren(Element);i;i=EBML_MasterNext(i))
{
Elt = EBML_ElementCopy(i,Cookie);
......
......@@ -27,7 +27,7 @@
*/
#include "ebml/ebml.h"
static err_t ReadDataInt(ebml_integer *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadDataInt(ebml_integer *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
err_t Result;
char Buffer[8];
......@@ -61,7 +61,7 @@ failed:
return Result;
}
static err_t ReadDataSignedInt(ebml_integer *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadDataSignedInt(ebml_integer *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
err_t Result;
char Buffer[8];
......@@ -202,7 +202,7 @@ static bool_t ValidateSizeFloat(const ebml_element *p)
return EBML_ElementIsFiniteSize(p) && (p->DataSize == 8 || p->DataSize == 4);
}
static err_t ReadDataFloat(ebml_float *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadDataFloat(ebml_float *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
uint8_t Value[8];
err_t Result;
......
......@@ -67,7 +67,7 @@ void EBML_StringGet(ebml_string *Element,tchar_t *Out, size_t OutLen)
}
}
static err_t ReadData(ebml_string *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadData(ebml_string *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
err_t Result;
char *Buffer;
......
......@@ -37,7 +37,7 @@ static filepos_t UpdateSize(ebml_element *Element, bool_t bWithDefault, bool_t b
return Element->DataSize;
}
static err_t ReadData(ebml_element *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadData(ebml_element *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
EBML_ElementSkipData(Element,Input,ParserContext,NULL,AllowDummyElt);
return ERR_NONE;
......
......@@ -3,7 +3,7 @@
GROUP ebml2_group
{
PROJECT_NAME "libebml2"
PROJECT_VERSION 0.9.11
PROJECT_VERSION 0.10.0
PROJECT_VENDOR "Matroska Foundation"
EXPDEFINE HAS_EBML2
......@@ -35,6 +35,7 @@ GROUP ebml2_group
SOURCE ebmlcrc.c {class EBMLCRC_Class}
SOURCE ebmldate.c {class EBMLDate_Class}
SOURCE ebmlvoid.c {class EBMLVoid_Class}
HEADER ebmlcrc.h
}
DLL ebml2
......
......@@ -3,7 +3,7 @@
PROJECT matroska2
{
PROJECT_NAME "libmatroska2"
PROJECT_VERSION 0.9.17
PROJECT_VERSION 0.10.0
PROJECT_VENDOR "Matroska Foundation"
}
......
......@@ -26,11 +26,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define MATROSKA_BLOCK_READ_TRACK 0x100
#define MATROSKA_BLOCK_READ_SEGMENTINFO 0x101
#define MATROSKA_BLOCK_READ_TRACK 0x180
#define MATROSKA_BLOCK_READ_SEGMENTINFO 0x181
#if defined(CONFIG_EBML_WRITING)
#define MATROSKA_BLOCK_WRITE_TRACK 0x102
#define MATROSKA_BLOCK_WRITE_SEGMENTINFO 0x103
#define MATROSKA_BLOCK_WRITE_TRACK 0x182
#define MATROSKA_BLOCK_WRITE_SEGMENTINFO 0x183
#endif
struct matroska_block
......
......@@ -1594,14 +1594,14 @@ static err_t SetBlockGroupParent(ebml_master *Element, void* Parent, void* Befor
return Result;
}
static err_t ReadBigBinaryData(ebml_binary *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
static err_t ReadBigBinaryData(ebml_binary *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope, size_t DepthCheckCRC)
{
if (Scope == SCOPE_PARTIAL_DATA)
{
EBML_ElementSkipData((ebml_element*)Element,Input,ParserContext,NULL,AllowDummyElt);
return ERR_NONE;
}
return INHERITED(Element,ebml_element_vmt,MATROSKA_BIGBINARY_CLASS)->ReadData(Element, Input, ParserContext, AllowDummyElt, Scope);
return INHERITED(Element,ebml_element_vmt,MATROSKA_BIGBINARY_CLASS)->ReadData(Element, Input, ParserContext, AllowDummyElt, Scope, DepthCheckCRC);
}
static err_t ReadBlockData(matroska_block *Element, stream *Input, const ebml_parser_context *ParserContext, bool_t AllowDummyElt, int Scope)
......
......@@ -536,7 +536,7 @@ static ebml_element *CheckMatroskaHead(const ebml_element *Head, const ebml_pars
{
if (SubElement->Context->Id == EBML_ContextReadVersion.Id)
{
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA)!=ERR_NONE)
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA,0)!=ERR_NONE)
{
TextPrintf(StdErr,T("Error reading\r\n"));
break;
......@@ -549,7 +549,7 @@ static ebml_element *CheckMatroskaHead(const ebml_element *Head, const ebml_pars
}
else if (SubElement->Context->Id == EBML_ContextMaxIdLength.Id)
{
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA)!=ERR_NONE)
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA,0)!=ERR_NONE)
{
TextPrintf(StdErr,T("Error reading\r\n"));
break;
......@@ -562,7 +562,7 @@ static ebml_element *CheckMatroskaHead(const ebml_element *Head, const ebml_pars
}
else if (SubElement->Context->Id == EBML_ContextMaxSizeLength.Id)
{
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA)!=ERR_NONE)
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA,0)!=ERR_NONE)
{
TextPrintf(StdErr,T("Error reading\r\n"));
break;
......@@ -575,7 +575,7 @@ static ebml_element *CheckMatroskaHead(const ebml_element *Head, const ebml_pars
}
else if (SubElement->Context->Id == EBML_ContextDocType.Id)
{
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA)!=ERR_NONE)
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA,0)!=ERR_NONE)
{
TextPrintf(StdErr,T("Error reading\r\n"));
break;
......@@ -596,7 +596,7 @@ static ebml_element *CheckMatroskaHead(const ebml_element *Head, const ebml_pars
}
else if (SubElement->Context->Id == EBML_ContextDocTypeReadVersion.Id)
{
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA)!=ERR_NONE)
if (EBML_ElementReadData(SubElement,Input,NULL,0,SCOPE_ALL_DATA,0)!=ERR_NONE)
{
TextPrintf(StdErr,T("Error reading\r\n"));
break;
......@@ -1351,38 +1351,38 @@ int main(int argc, const char *argv[])
ShowProgress((ebml_element*)RLevel1,(ebml_element*)RSegment,1,Unsafe?3:2);
if (RLevel1->Base.Context->Id == MATROSKA_ContextSegmentInfo.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,0)==ERR_NONE)
RSegmentInfo = RLevel1;
}
else if (RLevel1->Base.Context->Id == MATROSKA_ContextTracks.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,0)==ERR_NONE)
RTrackInfo = RLevel1;
}
else if (!Live && RLevel1->Base.Context->Id == MATROSKA_ContextChapters.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,0)==ERR_NONE)
RChapters = RLevel1;
}
else if (!Live && RLevel1->Base.Context->Id == MATROSKA_ContextTags.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,0)==ERR_NONE)
RTags = RLevel1;
}
else if (!Live && RLevel1->Base.Context->Id == MATROSKA_ContextCues.Id && KeepCues)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,0)==ERR_NONE)
RCues = RLevel1;
}
else if (!Live && RLevel1->Base.Context->Id == MATROSKA_ContextAttachments.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,0)==ERR_NONE)
RAttachments = RLevel1;
}
else if (RLevel1->Base.Context->Id == MATROSKA_ContextCluster.Id)
{
// only partially read the Cluster data (not the data inside the blocks)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_PARTIAL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_PARTIAL_DATA,0)==ERR_NONE)
{
ArrayAppend(&RClusters,&RLevel1,sizeof(RLevel1),256);
// remove MATROSKA_ContextClusterPosition and MATROSKA_ContextClusterPrevSize until supported
......
......@@ -905,7 +905,7 @@ int main(int argc, const char *argv[])
TextWrite(StdErr,T("."));
if (EBML_ElementReadData(EbmlHead,Input,&RContext,0,SCOPE_ALL_DATA)!=ERR_NONE)
if (EBML_ElementReadData(EbmlHead,Input,&RContext,0,SCOPE_ALL_DATA, 1)!=ERR_NONE)
{
Result = OutputError(4,T("Could not read the EBML head"));
goto exit;
......@@ -982,7 +982,7 @@ int main(int argc, const char *argv[])
{
if (RLevel1->Base.Context->Id == MATROSKA_ContextCluster.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,0,SCOPE_PARTIAL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,0,SCOPE_PARTIAL_DATA,4)==ERR_NONE)
{
ArrayAppend(&RClusters,&RLevel1,sizeof(RLevel1),256);
NodeTree_SetParent(RLevel1, RSegment, NULL);
......@@ -1004,7 +1004,7 @@ int main(int argc, const char *argv[])
EBML_ElementSkipData((ebml_element*)RLevel1, Input, &RSegmentContext, NULL, 1);
NodeDelete((node*)RLevel1);
}
else if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
else if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,1)==ERR_NONE)
{
if (!RSeekHead)
RSeekHead = RLevel1;
......@@ -1028,7 +1028,7 @@ int main(int argc, const char *argv[])
}
else if (RLevel1->Base.Context->Id == MATROSKA_ContextSegmentInfo.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,1)==ERR_NONE)
{
if (RSegmentInfo != NULL)
Result |= OutputError(0x110,T("Extra SegmentInfo found at %") TPRId64 T(" (size %") TPRId64 T(")"),RLevel1->Base.ElementPosition,RLevel1->Base.DataSize);
......@@ -1056,7 +1056,7 @@ int main(int argc, const char *argv[])
}
else if (RLevel1->Base.Context->Id == MATROSKA_ContextTracks.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,2)==ERR_NONE)
{
if (RTrackInfo != NULL)
Result |= OutputError(0x120,T("Extra TrackInfo found at %") TPRId64 T(" (size %") TPRId64 T(")"),RLevel1->Base.ElementPosition,RLevel1->Base.DataSize);
......@@ -1125,7 +1125,7 @@ int main(int argc, const char *argv[])
EBML_ElementSkipData((ebml_element*)RLevel1, Input, &RSegmentContext, NULL, 1);
NodeDelete((node*)RLevel1);
}
else if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
else if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,1)==ERR_NONE)
{
if (RCues != NULL)
Result |= OutputError(0x130,T("Extra Cues found at %") TPRId64 T(" (size %") TPRId64 T(")"),RLevel1->Base.ElementPosition,RLevel1->Base.DataSize);
......@@ -1152,7 +1152,7 @@ int main(int argc, const char *argv[])
EBML_ElementSkipData((ebml_element*)RLevel1, Input, &RSegmentContext, NULL, 1);
NodeDelete((node*)RLevel1);
}
else if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
else if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,3)==ERR_NONE)
{
if (RChapters != NULL)
Result |= OutputError(0x140,T("Extra Chapters found at %") TPRId64 T(" (size %") TPRId64 T(")"),RLevel1->Base.ElementPosition,RLevel1->Base.DataSize);
......@@ -1173,7 +1173,7 @@ int main(int argc, const char *argv[])
}
else if (RLevel1->Base.Context->Id == MATROSKA_ContextTags.Id)
{
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,3)==ERR_NONE)
{
if (RTags != NULL)
Result |= OutputError(0x150,T("Extra Tags found at %") TPRId64 T(" (size %") TPRId64 T(")"),RLevel1->Base.ElementPosition,RLevel1->Base.DataSize);
......@@ -1200,7 +1200,7 @@ int main(int argc, const char *argv[])
EBML_ElementSkipData((ebml_element*)RLevel1, Input, &RSegmentContext, NULL, 1);
NodeDelete((node*)RLevel1);
}
else if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA)==ERR_NONE)
else if (EBML_ElementReadData(RLevel1,Input,&RSegmentContext,1,SCOPE_ALL_DATA,2)==ERR_NONE)
{
if (RAttachments != NULL)
Result |= OutputError(0x160,T("Extra Attachments found at %") TPRId64 T(" (size %") TPRId64 T(")"),RLevel1->Base.ElementPosition,RLevel1->Base.DataSize);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment