START_LIBMATROSKA_NAMESPACE KaxSegment::KaxSegment(EBML_EXTRA_DEF) :EbmlMaster(EBML_CLASS_SEMCONTEXT(KaxSegment) EBML_DEF_SEP EBML_EXTRA_CALL) { SetSizeLength(5); // mandatory min size support (for easier updating) (2^(7*5)-2 = 32Go) SetSizeInfinite(); // by default a segment is big and the size is unknown in advance }
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(); }
filepos_t EbmlMaster::WriteHead(IOCallback & output, int nSizeLength, bool bWithDefault) { SetSizeLength(nSizeLength); return RenderHead(output, false, bWithDefault); }
KaxSegment::KaxSegment() :EbmlMaster(KaxSegment_Context) { SetSizeLength(5); // mandatory min size support (for easier updating) (2^(7*5)-2 = 32Go) SetSizeInfinite(); // by default a segment is big and the size is unknown in advance }