Memory efficiency upgrade.

This commit is contained in:
Erik Zandvliet 2013-09-19 10:03:54 +02:00
parent 5ea87a37f7
commit 974861d993
3 changed files with 32 additions and 11 deletions

View file

@ -277,6 +277,9 @@ void DTSC::Stream::addPacket(JSON::Value & newPack){
for (JSON::ArrIter it = prevKey["parts"].ArrBegin(); it != prevKey["parts"].ArrEnd(); it++){
size += it->asInt();
}
prevKey["partsize"] = prevKey["parts"].size();
std::string tmpParts = JSON::encodeVector(prevKey["parts"].ArrBegin(), prevKey["parts"].ArrEnd());
prevKey["parts"] = tmpParts;
prevKey["size"] = size;
long long int bps = (double)prevKey["size"].asInt() / ((double)prevKey["len"].asInt() / 1000.0);
if (bps > metadata["tracks"][newTrack]["maxbps"].asInt()){
@ -549,7 +552,6 @@ DTSC::File & DTSC::File::operator =(const File & rhs){
strbuffer = rhs.strbuffer;
jsonbuffer = rhs.jsonbuffer;
metadata = rhs.metadata;
firstmetadata = rhs.firstmetadata;
currtime = rhs.currtime;
lastreadpos = rhs.lastreadpos;
headerSize = rhs.headerSize;
@ -605,11 +607,6 @@ JSON::Value & DTSC::File::getMeta(){
return metadata;
}
/// Returns the header metadata for this file as JSON::Value.
JSON::Value & DTSC::File::getFirstMeta(){
return firstmetadata;
}
/// (Re)writes the given string to the header area if the size is the same as the existing header.
/// Forces a write if force is set to true.
bool DTSC::File::writeHeader(std::string & header, bool force){
@ -694,9 +691,6 @@ void DTSC::File::readHeader(int pos){
}
metadata = JSON::fromDTMI(strbuffer);
}
if (pos == 0){
firstmetadata = metadata;
}
//if there is another header, read it and replace metadata with that one.
if (metadata.isMember("moreheader") && metadata["moreheader"].asInt() > 0){
if (metadata["moreheader"].asInt() < getBytePosEOF()){