| 267 | } |
| 268 | |
| 269 | ParserAnnexB::ParseResult |
| 270 | ParserAnnexBVVC::parseAndAddNALUnit(int nalID, |
| 271 | const ByteVector & data, |
| 272 | std::optional<BitratePlotModel::BitrateEntry> bitrateEntry, |
| 273 | std::optional<pairUint64> nalStartEndPosFile, |
| 274 | std::shared_ptr<TreeItem> parent) |
| 275 | { |
| 276 | ParserAnnexB::ParseResult parseResult; |
| 277 | parseResult.success = true; |
| 278 | |
| 279 | if (nalID == -1 && data.empty()) |
| 280 | { |
| 281 | if (this->parsingState.currentAU.poc != -1) |
| 282 | { |
| 283 | parseResult.bitrateEntry = createBitrateEntryForAU(this->parsingState, bitrateEntry); |
| 284 | if (!this->handleNewAU(this->parsingState)) |
| 285 | { |
| 286 | DEBUG_VVC("Error handling last AU"); |
| 287 | parseResult.success = false; |
| 288 | } |
| 289 | } |
| 290 | return parseResult; |
| 291 | } |
| 292 | |
| 293 | // Skip the NAL unit header |
| 294 | int readOffset = 0; |
| 295 | if (data.at(0) == (char)0 && data.at(1) == (char)0 && data.at(2) == (char)1) |
| 296 | readOffset = 3; |
| 297 | else if (data.at(0) == (char)0 && data.at(1) == (char)0 && data.at(2) == (char)0 && |
| 298 | data.at(3) == (char)1) |
| 299 | readOffset = 4; |
| 300 | |
| 301 | // Use the given tree item. If it is not set, use the nalUnitMode (if active). |
| 302 | // Create a new TreeItem root for the NAL unit. We don't set data (a name) for this item |
| 303 | // yet. We want to parse the item and then set a good description. |
| 304 | std::shared_ptr<TreeItem> nalRoot; |
| 305 | if (parent) |
| 306 | nalRoot = parent->createChildItem(); |
| 307 | else if (packetModel->rootItem) |
| 308 | nalRoot = packetModel->rootItem->createChildItem(); |
| 309 | |
| 310 | if (nalRoot) |
| 311 | ParserAnnexB::logNALSize(data, nalRoot, nalStartEndPosFile); |
| 312 | |
| 313 | reader::SubByteReaderLogging reader(data, nalRoot, "", readOffset); |
| 314 | |
| 315 | std::string specificDescription; |
| 316 | auto nalVVC = std::make_shared<vvc::NalUnitVVC>(nalID, nalStartEndPosFile); |
| 317 | auto updatedParsingState = this->parsingState; |
| 318 | try |
| 319 | { |
| 320 | nalVVC->header.parse(reader); |
| 321 | |
| 322 | auto nalType = nalVVC->header.nal_unit_type; |
| 323 | specificDescription = " " + NalTypeMapper.getName(nalType); |
| 324 | |
| 325 | if (updatedParsingState.NoOutputBeforeRecoveryFlag.count(nalVVC->header.nuh_layer_id) == 0) |
| 326 | updatedParsingState.NoOutputBeforeRecoveryFlag[nalVVC->header.nuh_layer_id] = true; |
no test coverage detected