| 230 | } |
| 231 | |
| 232 | void StatisticsFileCSV::loadStatisticData(StatisticsData &statisticsData, int poc, int typeID) |
| 233 | { |
| 234 | if (!this->file.isOk()) |
| 235 | return; |
| 236 | |
| 237 | try |
| 238 | { |
| 239 | statisticsData.setFrameIndex(poc); |
| 240 | |
| 241 | if (this->pocTypeFileposMap.count(poc) == 0 || this->pocTypeFileposMap[poc].count(typeID) == 0) |
| 242 | { |
| 243 | // There are no statistics in the file for the given frame and index. |
| 244 | statisticsData[typeID] = {}; |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | auto startPos = this->pocTypeFileposMap[poc][typeID]; |
| 249 | if (this->fileSortedByPOC) |
| 250 | { |
| 251 | // If the statistics file is sorted by POC we have to start at the first entry of this POC and |
| 252 | // parse the file until another POC is encountered. If this is not done, some information from |
| 253 | // a different typeID could be ignored during parsing. |
| 254 | |
| 255 | // Get the position of the first line with the given frameIdx |
| 256 | startPos = std::numeric_limits<qint64>::max(); |
| 257 | for (const auto &typeEntry : this->pocTypeFileposMap[poc]) |
| 258 | if (typeEntry.second < startPos) |
| 259 | startPos = typeEntry.second; |
| 260 | } |
| 261 | |
| 262 | QTextStream in(this->file.getQFile()); |
| 263 | in.seek(startPos); |
| 264 | |
| 265 | while (!in.atEnd()) |
| 266 | { |
| 267 | // read one line |
| 268 | auto aLine = in.readLine(); |
| 269 | auto rowItemList = parseCSVLine(aLine, ';'); |
| 270 | |
| 271 | if (rowItemList[0].isEmpty()) |
| 272 | continue; |
| 273 | |
| 274 | auto pocRow = rowItemList[0].toInt(); |
| 275 | auto type = rowItemList[5].toInt(); |
| 276 | |
| 277 | // if there is a new POC, we are done here! |
| 278 | if (pocRow != poc) |
| 279 | break; |
| 280 | // if there is a new type and this is a non interleaved file, we are done here. |
| 281 | if (!this->fileSortedByPOC && type != typeID) |
| 282 | break; |
| 283 | |
| 284 | int values[4] = {0}; |
| 285 | |
| 286 | values[0] = rowItemList[6].toInt(); |
| 287 | |
| 288 | bool vectorData = false; |
| 289 | bool lineData = false; // or a vector specified by 2 points |