Fix several gcc warnings occurring with -Wextra
Warnings fixed are: - warning: type qualifiers ignored on function return type [-Wignored-qualifiers] - warning: unused parameter ... [-Wunused-parameter] - warning: comparison is always true due to limited range of data type [-Wtype-limits] git-svn-id: https://matroska.svn.sourceforge.net/svnroot/matroska/trunk/libebml@822 a6f86f6d-0131-4f8e-9e7b-e335508773d5
This commit is contained in:
parent
ffeea955a0
commit
88cdc30938
12
ebml/Debug.h
12
ebml/Debug.h
@ -109,14 +109,14 @@ private:
|
||||
class EBML_DLL_API ADbg
|
||||
{
|
||||
public:
|
||||
ADbg(int level = 0){}
|
||||
ADbg(int /* level */ = 0){}
|
||||
virtual ~ADbg() {}
|
||||
|
||||
inline int OutPut(int level, const char * format,...) const {
|
||||
inline int OutPut(int /* level */, const char * /* format */,...) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int OutPut(const char * format,...) const {
|
||||
inline int OutPut(const char * /* format */,...) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -124,11 +124,11 @@ public:
|
||||
return level;
|
||||
}
|
||||
|
||||
inline bool setIncludeTime(const bool included = true) {
|
||||
inline bool setIncludeTime(const bool /* included */ = true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool setDebugFile(const char * NewFilename) {
|
||||
inline bool setDebugFile(const char * /* NewFilename */) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool setUseFile(const bool usefile = true) {
|
||||
inline bool setUseFile(const bool /* usefile */ = true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ DECLARE_EBML_BINARY(EbmlCrc32)
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline unsigned int GetAlignment(T *dummy=NULL) // VC60 workaround
|
||||
inline unsigned int GetAlignment(T */* dummy */=NULL) // VC60 workaround
|
||||
{
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
|
||||
return __alignof(T);
|
||||
@ -131,7 +131,7 @@ inline bool IsAlignedOn(const void *p, unsigned int alignment)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline bool IsAligned(const void *p, T *dummy=NULL) // VC60 workaround
|
||||
inline bool IsAligned(const void *p, T */* dummy */=NULL) // VC60 workaround
|
||||
{
|
||||
return IsAlignedOn(p, GetAlignment<T>());
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class EBML_DLL_API EbmlDate : public EbmlElement {
|
||||
/*!
|
||||
\note no Default date handled
|
||||
*/
|
||||
filepos_t UpdateSize(bool bWithDefault = false, bool bForceRender = false) {
|
||||
filepos_t UpdateSize(bool /* bWithDefault = false */, bool /* bForceRender = false */) {
|
||||
if(!ValueIsSet())
|
||||
SetSize_(0);
|
||||
else
|
||||
|
@ -79,12 +79,12 @@ class EBML_DLL_API EbmlFloat : public EbmlElement {
|
||||
|
||||
virtual bool IsSmallerThan(const EbmlElement *Cmp) const;
|
||||
|
||||
operator const float() const;
|
||||
operator const double() const;
|
||||
operator float() const;
|
||||
operator double() const;
|
||||
|
||||
void SetDefaultValue(double);
|
||||
|
||||
const double DefaultVal() const;
|
||||
double DefaultVal() const;
|
||||
|
||||
bool IsDefaultValue() const {
|
||||
return (DefaultISset() && Value == DefaultValue);
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
DECLARE_EBML_MASTER(EbmlHead)
|
||||
DECLARE_EBML_MASTER(EbmlHead)
|
||||
public:
|
||||
EbmlHead(const EbmlHead & ElementToClone) : EbmlMaster(ElementToClone) {}
|
||||
|
||||
|
@ -66,7 +66,7 @@ EbmlBinary::~EbmlBinary(void) {
|
||||
EbmlBinary::operator const binary &() const {return *Data;}
|
||||
|
||||
|
||||
filepos_t EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
filepos_t EbmlBinary::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
output.writeFully(Data,GetSize());
|
||||
|
||||
@ -76,7 +76,7 @@ filepos_t EbmlBinary::RenderData(IOCallback & output, bool bForceRender, bool bW
|
||||
/*!
|
||||
\note no Default binary value handled
|
||||
*/
|
||||
uint64 EbmlBinary::UpdateSize(bool bWithDefault, bool bForceRender)
|
||||
uint64 EbmlBinary::UpdateSize(bool /* bWithDefault */, bool /* bForceRender */)
|
||||
{
|
||||
return GetSize();
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ bool EbmlCrc32::CheckElementCRC32(EbmlElement &ElementToCRC)
|
||||
return CheckCRC(m_crc_final, memoryBuffer.GetDataBuffer(), memoryBuffer.GetDataBufferSize());
|
||||
};
|
||||
|
||||
filepos_t EbmlCrc32::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
filepos_t EbmlCrc32::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
filepos_t Result = 4;
|
||||
|
||||
|
@ -65,7 +65,7 @@ filepos_t EbmlDate::ReadData(IOCallback & input, ScopeMode ReadFully)
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
filepos_t EbmlDate::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
filepos_t EbmlDate::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
if (GetSize() != 0) {
|
||||
assert(GetSize() == 8);
|
||||
|
@ -655,7 +655,7 @@ bool EbmlElement::CompareElements(const EbmlElement *A, const EbmlElement *B)
|
||||
return false;
|
||||
}
|
||||
|
||||
void EbmlElement::Read(EbmlStream & inDataStream, const EbmlSemanticContext & Context, int & UpperEltFound, EbmlElement * & FoundElt, bool AllowDummyElt, ScopeMode ReadFully)
|
||||
void EbmlElement::Read(EbmlStream & inDataStream, const EbmlSemanticContext & /* Context */, int & /* UpperEltFound */, EbmlElement * & /* FoundElt */, bool /* AllowDummyElt */, ScopeMode ReadFully)
|
||||
{
|
||||
ReadData(inDataStream.I_O(), ReadFully);
|
||||
}
|
||||
|
@ -67,21 +67,21 @@ void EbmlFloat::SetDefaultValue(double aValue)
|
||||
SetDefaultIsSet();
|
||||
}
|
||||
|
||||
const double EbmlFloat::DefaultVal() const
|
||||
double EbmlFloat::DefaultVal() const
|
||||
{
|
||||
assert(DefaultISset());
|
||||
return DefaultValue;
|
||||
}
|
||||
|
||||
EbmlFloat::operator const float() const {return float(Value);}
|
||||
EbmlFloat::operator const double() const {return double(Value);}
|
||||
EbmlFloat::operator float() const {return float(Value);}
|
||||
EbmlFloat::operator double() const {return double(Value);}
|
||||
|
||||
|
||||
/*!
|
||||
\todo handle exception on errors
|
||||
\todo handle 10 bits precision
|
||||
*/
|
||||
filepos_t EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
filepos_t EbmlFloat::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
assert(GetSize() == 4 || GetSize() == 8);
|
||||
|
||||
@ -102,7 +102,7 @@ filepos_t EbmlFloat::RenderData(IOCallback & output, bool bForceRender, bool bWi
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
uint64 EbmlFloat::UpdateSize(bool bWithDefault, bool bForceRender)
|
||||
uint64 EbmlFloat::UpdateSize(bool bWithDefault, bool /* bForceRender */)
|
||||
{
|
||||
if (!bWithDefault && IsDefaultValue())
|
||||
return 0;
|
||||
|
@ -167,7 +167,7 @@ filepos_t EbmlMaster::WriteHead(IOCallback & output, int nSizeLength, bool bWith
|
||||
/*!
|
||||
\todo this code is very suspicious !
|
||||
*/
|
||||
filepos_t EbmlMaster::ReadData(IOCallback & input, ScopeMode ReadFully)
|
||||
filepos_t EbmlMaster::ReadData(IOCallback & input, ScopeMode /* ReadFully */)
|
||||
{
|
||||
input.setFilePointer(GetSize(), seek_current);
|
||||
return GetSize();
|
||||
|
@ -63,7 +63,7 @@ EbmlSInteger::operator int64() {return Value;}
|
||||
/*!
|
||||
\todo handle exception on errors
|
||||
*/
|
||||
filepos_t EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
filepos_t EbmlSInteger::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
binary FinalData[8]; // we don't handle more than 64 bits integers
|
||||
unsigned int i;
|
||||
@ -82,7 +82,7 @@ filepos_t EbmlSInteger::RenderData(IOCallback & output, bool bForceRender, bool
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
uint64 EbmlSInteger::UpdateSize(bool bWithDefault, bool bForceRender)
|
||||
uint64 EbmlSInteger::UpdateSize(bool bWithDefault, bool /* bForceRender */)
|
||||
{
|
||||
if (!bWithDefault && IsDefaultValue())
|
||||
return 0;
|
||||
|
@ -87,7 +87,7 @@ const std::string & EbmlString::DefaultVal() const
|
||||
/*!
|
||||
\todo handle exception on errors
|
||||
*/
|
||||
filepos_t EbmlString::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
filepos_t EbmlString::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
filepos_t Result;
|
||||
output.writeFully(Value.c_str(), Value.length());
|
||||
@ -122,7 +122,7 @@ EbmlString & EbmlString::operator=(const std::string & NewString)
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint64 EbmlString::UpdateSize(bool bWithDefault, bool bForceRender)
|
||||
uint64 EbmlString::UpdateSize(bool bWithDefault, bool /* bForceRender */)
|
||||
{
|
||||
if (!bWithDefault && IsDefaultValue())
|
||||
return 0;
|
||||
|
@ -79,7 +79,7 @@ EbmlUInteger::operator uint64() const {return Value;}
|
||||
/*!
|
||||
\todo handle exception on errors
|
||||
*/
|
||||
filepos_t EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
filepos_t EbmlUInteger::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
binary FinalData[8]; // we don't handle more than 64 bits integers
|
||||
|
||||
@ -97,7 +97,7 @@ filepos_t EbmlUInteger::RenderData(IOCallback & output, bool bForceRender, bool
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
uint64 EbmlUInteger::UpdateSize(bool bWithDefault, bool bForceRender)
|
||||
uint64 EbmlUInteger::UpdateSize(bool bWithDefault, bool /* bForceRender */)
|
||||
{
|
||||
if (!bWithDefault && IsDefaultValue())
|
||||
return 0;
|
||||
|
@ -183,7 +183,7 @@ void UTFstring::UpdateFromUCS2()
|
||||
Size++;
|
||||
} else if (_Data[i] < 0x800) {
|
||||
Size += 2;
|
||||
} else if (_Data[i] < 0x10000) {
|
||||
} else {
|
||||
Size += 3;
|
||||
}
|
||||
}
|
||||
@ -195,7 +195,7 @@ void UTFstring::UpdateFromUCS2()
|
||||
} else if (_Data[i] < 0x800) {
|
||||
tmpStr[Size++] = 0xC0 | (_Data[i] >> 6);
|
||||
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
|
||||
} else if (_Data[i] < 0x10000) {
|
||||
} else {
|
||||
tmpStr[Size++] = 0xE0 | (_Data[i] >> 12);
|
||||
tmpStr[Size++] = 0x80 | ((_Data[i] >> 6) & 0x3F);
|
||||
tmpStr[Size++] = 0x80 | (_Data[i] & 0x3F);
|
||||
@ -256,7 +256,7 @@ const UTFstring & EbmlUnicodeString::DefaultVal() const
|
||||
\note limited to UCS-2
|
||||
\todo handle exception on errors
|
||||
*/
|
||||
filepos_t EbmlUnicodeString::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
filepos_t EbmlUnicodeString::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
uint32 Result = Value.GetUTF8().length();
|
||||
|
||||
@ -291,7 +291,7 @@ EbmlUnicodeString & EbmlUnicodeString::operator=(const UTFstring & NewString)
|
||||
/*!
|
||||
\note limited to UCS-2
|
||||
*/
|
||||
uint64 EbmlUnicodeString::UpdateSize(bool bWithDefault, bool bForceRender)
|
||||
uint64 EbmlUnicodeString::UpdateSize(bool bWithDefault, bool /* bForceRender */)
|
||||
{
|
||||
if (!bWithDefault && IsDefaultValue())
|
||||
return 0;
|
||||
|
276
src/EbmlVoid.cpp
276
src/EbmlVoid.cpp
@ -1,138 +1,138 @@
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** 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: EbmlVoid.cpp 1232 2005-10-15 15:56:52Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#include "ebml/EbmlVoid.h"
|
||||
#include "ebml/EbmlContexts.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
DEFINE_EBML_CLASS_GLOBAL(EbmlVoid, 0xEC, 1, "EBMLVoid");
|
||||
|
||||
EbmlVoid::EbmlVoid()
|
||||
{
|
||||
SetValueIsSet();
|
||||
}
|
||||
|
||||
filepos_t EbmlVoid::RenderData(IOCallback & output, bool bForceRender, bool bWithDefault)
|
||||
{
|
||||
// write dummy data by 4KB chunks
|
||||
static binary DummyBuf[4*1024];
|
||||
|
||||
uint64 SizeToWrite = GetSize();
|
||||
while (SizeToWrite > 4*1024)
|
||||
{
|
||||
output.writeFully(DummyBuf, 4*1024);
|
||||
SizeToWrite -= 4*1024;
|
||||
}
|
||||
output.writeFully(DummyBuf, SizeToWrite);
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
|
||||
{
|
||||
EltToReplaceWith.UpdateSize(bWithDefault);
|
||||
if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
|
||||
// the element can't be written here !
|
||||
return INVALID_FILEPOS_T;
|
||||
}
|
||||
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
|
||||
// there is not enough space to put a filling element
|
||||
return INVALID_FILEPOS_T;
|
||||
}
|
||||
|
||||
uint64 CurrentPosition = output.getFilePointer();
|
||||
|
||||
output.setFilePointer(GetElementPosition());
|
||||
EltToReplaceWith.Render(output, bWithDefault);
|
||||
|
||||
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) {
|
||||
// fill the rest with another void element
|
||||
EbmlVoid aTmp;
|
||||
aTmp.SetSize_(HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() - 1); // 1 is the length of the Void ID
|
||||
int HeadBefore = aTmp.HeadSize();
|
||||
aTmp.SetSize_(aTmp.GetSize() - CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()));
|
||||
int HeadAfter = aTmp.HeadSize();
|
||||
if (HeadBefore != HeadAfter) {
|
||||
aTmp.SetSizeLength(CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()) - (HeadAfter - HeadBefore));
|
||||
}
|
||||
aTmp.RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
|
||||
}
|
||||
|
||||
if (ComeBackAfterward) {
|
||||
output.setFilePointer(CurrentPosition);
|
||||
}
|
||||
|
||||
return GetSize() + HeadSize();
|
||||
}
|
||||
|
||||
uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
|
||||
{
|
||||
// EltToVoid.UpdateSize(bWithDefault);
|
||||
if (EltToVoid.GetElementPosition() == 0) {
|
||||
// this element has never been written
|
||||
return 0;
|
||||
}
|
||||
if (EltToVoid.GetSize() + EltToVoid.HeadSize() <2) {
|
||||
// the element can't be written here !
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64 CurrentPosition = output.getFilePointer();
|
||||
|
||||
output.setFilePointer(EltToVoid.GetElementPosition());
|
||||
|
||||
// compute the size of the voided data based on the original one
|
||||
SetSize(EltToVoid.GetSize() + EltToVoid.HeadSize() - 1); // 1 for the ID
|
||||
SetSize(GetSize() - CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()));
|
||||
// make sure we handle even the strange cases
|
||||
//uint32 A1 = GetSize() + HeadSize();
|
||||
//uint32 A2 = EltToVoid.GetSize() + EltToVoid.HeadSize();
|
||||
if (GetSize() + HeadSize() != EltToVoid.GetSize() + EltToVoid.HeadSize()) {
|
||||
SetSize(GetSize()-1);
|
||||
SetSizeLength(CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()) + 1);
|
||||
}
|
||||
|
||||
if (GetSize() != 0) {
|
||||
RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
|
||||
}
|
||||
|
||||
if (ComeBackAfterward) {
|
||||
output.setFilePointer(CurrentPosition);
|
||||
}
|
||||
|
||||
return EltToVoid.GetSize() + EltToVoid.HeadSize();
|
||||
}
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
/****************************************************************************
|
||||
** libebml : parse EBML files, see http://embl.sourceforge.net/
|
||||
**
|
||||
** <file/class description>
|
||||
**
|
||||
** Copyright (C) 2002-2010 Steve Lhomme. All rights reserved.
|
||||
**
|
||||
** This file is part of libebml.
|
||||
**
|
||||
** 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: EbmlVoid.cpp 1232 2005-10-15 15:56:52Z robux4 $
|
||||
\author Steve Lhomme <robux4 @ users.sf.net>
|
||||
*/
|
||||
#include "ebml/EbmlVoid.h"
|
||||
#include "ebml/EbmlContexts.h"
|
||||
|
||||
START_LIBEBML_NAMESPACE
|
||||
|
||||
DEFINE_EBML_CLASS_GLOBAL(EbmlVoid, 0xEC, 1, "EBMLVoid");
|
||||
|
||||
EbmlVoid::EbmlVoid()
|
||||
{
|
||||
SetValueIsSet();
|
||||
}
|
||||
|
||||
filepos_t EbmlVoid::RenderData(IOCallback & output, bool /* bForceRender */, bool /* bWithDefault */)
|
||||
{
|
||||
// write dummy data by 4KB chunks
|
||||
static binary DummyBuf[4*1024];
|
||||
|
||||
uint64 SizeToWrite = GetSize();
|
||||
while (SizeToWrite > 4*1024)
|
||||
{
|
||||
output.writeFully(DummyBuf, 4*1024);
|
||||
SizeToWrite -= 4*1024;
|
||||
}
|
||||
output.writeFully(DummyBuf, SizeToWrite);
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
uint64 EbmlVoid::ReplaceWith(EbmlElement & EltToReplaceWith, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
|
||||
{
|
||||
EltToReplaceWith.UpdateSize(bWithDefault);
|
||||
if (HeadSize() + GetSize() < EltToReplaceWith.GetSize() + EltToReplaceWith.HeadSize()) {
|
||||
// the element can't be written here !
|
||||
return INVALID_FILEPOS_T;
|
||||
}
|
||||
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() == 1) {
|
||||
// there is not enough space to put a filling element
|
||||
return INVALID_FILEPOS_T;
|
||||
}
|
||||
|
||||
uint64 CurrentPosition = output.getFilePointer();
|
||||
|
||||
output.setFilePointer(GetElementPosition());
|
||||
EltToReplaceWith.Render(output, bWithDefault);
|
||||
|
||||
if (HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() > 1) {
|
||||
// fill the rest with another void element
|
||||
EbmlVoid aTmp;
|
||||
aTmp.SetSize_(HeadSize() + GetSize() - EltToReplaceWith.GetSize() - EltToReplaceWith.HeadSize() - 1); // 1 is the length of the Void ID
|
||||
int HeadBefore = aTmp.HeadSize();
|
||||
aTmp.SetSize_(aTmp.GetSize() - CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()));
|
||||
int HeadAfter = aTmp.HeadSize();
|
||||
if (HeadBefore != HeadAfter) {
|
||||
aTmp.SetSizeLength(CodedSizeLength(aTmp.GetSize(), aTmp.GetSizeLength(), aTmp.IsFiniteSize()) - (HeadAfter - HeadBefore));
|
||||
}
|
||||
aTmp.RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
|
||||
}
|
||||
|
||||
if (ComeBackAfterward) {
|
||||
output.setFilePointer(CurrentPosition);
|
||||
}
|
||||
|
||||
return GetSize() + HeadSize();
|
||||
}
|
||||
|
||||
uint64 EbmlVoid::Overwrite(const EbmlElement & EltToVoid, IOCallback & output, bool ComeBackAfterward, bool bWithDefault)
|
||||
{
|
||||
// EltToVoid.UpdateSize(bWithDefault);
|
||||
if (EltToVoid.GetElementPosition() == 0) {
|
||||
// this element has never been written
|
||||
return 0;
|
||||
}
|
||||
if (EltToVoid.GetSize() + EltToVoid.HeadSize() <2) {
|
||||
// the element can't be written here !
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64 CurrentPosition = output.getFilePointer();
|
||||
|
||||
output.setFilePointer(EltToVoid.GetElementPosition());
|
||||
|
||||
// compute the size of the voided data based on the original one
|
||||
SetSize(EltToVoid.GetSize() + EltToVoid.HeadSize() - 1); // 1 for the ID
|
||||
SetSize(GetSize() - CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()));
|
||||
// make sure we handle even the strange cases
|
||||
//uint32 A1 = GetSize() + HeadSize();
|
||||
//uint32 A2 = EltToVoid.GetSize() + EltToVoid.HeadSize();
|
||||
if (GetSize() + HeadSize() != EltToVoid.GetSize() + EltToVoid.HeadSize()) {
|
||||
SetSize(GetSize()-1);
|
||||
SetSizeLength(CodedSizeLength(GetSize(), GetSizeLength(), IsFiniteSize()) + 1);
|
||||
}
|
||||
|
||||
if (GetSize() != 0) {
|
||||
RenderHead(output, false, bWithDefault); // the rest of the data is not rewritten
|
||||
}
|
||||
|
||||
if (ComeBackAfterward) {
|
||||
output.setFilePointer(CurrentPosition);
|
||||
}
|
||||
|
||||
return EltToVoid.GetSize() + EltToVoid.HeadSize();
|
||||
}
|
||||
|
||||
END_LIBEBML_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user