From c0ccde0d566ca0810d63aa1a7dae93068e4417b4 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Mon, 26 Aug 2013 16:01:01 +0200 Subject: [PATCH] Fixed the optimize in the dtsc lib to be an actual optimize. --- lib/dtsc.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index 54a3a821..7e0204b6 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -806,6 +806,7 @@ void DTSC::File::seekNext(){ tmpPos.seekTime = ((long long unsigned int)ntohl(((int*)newHeader)[3])) << 32; tmpPos.seekTime += ntohl(((int*)newHeader)[4]); }else{ + tmpPos.seekTime = -1; for (JSON::ArrIter it = getTrackById(jsonbuffer["trackid"].asInt())["keys"].ArrBegin(); it != getTrackById(jsonbuffer["trackid"].asInt())["keys"].ArrEnd(); it++){ if ((*it)["time"].asInt() > jsonbuffer["time"].asInt()){ tmpPos.seekTime = (*it)["time"].asInt(); @@ -814,7 +815,20 @@ void DTSC::File::seekNext(){ } } } - currentPositions.insert(tmpPos); + if (tmpPos.seekTime != -1){ + bool insert = true; + for (std::set::iterator curPosIter = currentPositions.begin(); curPosIter != currentPositions.end(); curPosIter++){ + if ((*curPosIter).trackID == tmpPos.trackID && (*curPosIter).seekTime >= tmpPos.seekTime){ + insert = false; + break; + } + } + if (insert){ + currentPositions.insert(tmpPos); + }else{ + seek_time(jsonbuffer["time"].asInt() + 1, jsonbuffer["trackid"].asInt()); + } + } } } }