/*! \todo remove the hack for possible endianess pb (test on little & big endian) */ filepos_t EbmlFloat::ReadData(IOCallback & input, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { binary Buffer[20]; assert(GetSize() <= 20); input.readFully(Buffer, GetSize()); if (GetSize() == 4) { big_int32 TmpRead; TmpRead.Eval(Buffer); int32 tmpp = int32(TmpRead); float val; memcpy(&val, &tmpp, 4); Value = val; SetValueIsSet(); } else if (GetSize() == 8) { big_int64 TmpRead; TmpRead.Eval(Buffer); int64 tmpp = int64(TmpRead); double val; memcpy(&val, &tmpp, 8); Value = val; SetValueIsSet(); } } return GetSize(); }
filepos_t EbmlString::ReadData(IOCallback & input, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { if (GetSize() == 0) { Value = ""; SetValueIsSet(); } else { char *Buffer = new char[GetSize() + 1]; if (Buffer == NULL) { // unable to store the data, skip it input.setFilePointer(GetSize(), seek_current); } else { input.readFully(Buffer, GetSize()); if (Buffer[GetSize()-1] != '\0') { Buffer[GetSize()] = '\0'; } Value = Buffer; delete [] Buffer; SetValueIsSet(); } } } return GetSize(); }
/*! \todo remove the hack for possible endianess pb (test on little & big endian) */ uint64 EbmlFloat::ReadData(IOCallback & input, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { binary Buffer[20]; assert(Size <= 20); input.readFully(Buffer, Size); if (Size == 4) { big_int32 TmpRead; TmpRead.Eval(Buffer); int32 tmpp = int32(TmpRead); float val; memcpy(&val, &tmpp, 4); Value = val; bValueIsSet = true; } else if (Size == 8) { big_int64 TmpRead; TmpRead.Eval(Buffer); int64 tmpp = int64(TmpRead); double val; memcpy(&val, &tmpp, 8); Value = val; bValueIsSet = true; } } return Size; }
uint64 EbmlString::ReadData(IOCallback & input, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { if (Size == 0) { Value = ""; bValueIsSet = true; } else { char *Buffer = new char[Size + 1]; if (Buffer == NULL) { // unable to store the data, skip it input.setFilePointer(Size, seek_current); } else { input.readFully(Buffer, Size); if (Buffer[Size-1] != '\0') { Buffer[Size] = '\0'; } Value = Buffer; delete [] Buffer; bValueIsSet = true; } } } return Size; }
uint32 MemIOCallback::write(IOCallback & IOToRead, size_t Size) { if (dataBufferMemorySize < dataBufferPos + Size) { //We need more memory! dataBuffer = (binary *)realloc((void *)dataBuffer, dataBufferPos + Size); } IOToRead.readFully(&dataBuffer[dataBufferPos], Size); dataBufferTotalSize = Size; return Size; }
filepos_t EbmlUInteger::ReadData(IOCallback & input, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { binary Buffer[8]; input.readFully(Buffer, GetSize()); Value = 0; for (unsigned int i=0; i<GetSize(); i++) { Value <<= 8; Value |= Buffer[i]; } SetValueIsSet(); } return GetSize(); }
filepos_t EbmlDate::ReadData(IOCallback & input, ScopeMode ReadFully) { if ((ReadFully == SCOPE_NO_DATA) || (GetSize() == 0)) return GetSize(); assert(GetSize() == 8); binary Buffer[8]; input.readFully(Buffer, GetSize()); big_int64 b64; b64.Eval(Buffer); myDate = b64; SetValueIsSet(); return GetSize(); }
uint64 EbmlUInteger::ReadData(IOCallback & input, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { binary Buffer[8]; input.readFully(Buffer, Size); Value = 0; for (unsigned int i=0; i<Size; i++) { Value <<= 8; Value |= Buffer[i]; } bValueIsSet = true; } return Size; }
filepos_t EbmlCrc32::ReadData(IOCallback & input, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { binary *Buffer = new binary[GetSize()]; if (Buffer == NULL) { // impossible to read, skip it input.setFilePointer(GetSize(), seek_current); } else { input.readFully(Buffer, GetSize()); memcpy((void *)&m_crc_final, Buffer, 4); delete [] Buffer; SetValueIsSet(); } } return GetSize(); }
filepos_t EbmlSInteger::ReadData(IOCallback & input, ScopeMode ReadFully) { if (ReadFully != SCOPE_NO_DATA) { binary Buffer[8]; input.readFully(Buffer, GetSize()); if (Buffer[0] & 0x80) Value = -1; // this is a negative value else Value = 0; // this is a positive value for (unsigned int i=0; i<GetSize(); i++) { Value <<= 8; Value |= Buffer[i]; } SetValueIsSet(); } return GetSize(); }