MCPcopy Create free account
hub / github.com/IENT/YUView / parseAndAddNALUnit

Method parseAndAddNALUnit

YUViewLib/src/parser/HEVC/ParserAnnexBHEVC.cpp:272–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272ParserAnnexB::ParseResult
273ParserAnnexBHEVC::parseAndAddNALUnit(int nalID,
274 const ByteVector & data,
275 std::optional<BitratePlotModel::BitrateEntry> bitrateEntry,
276 std::optional<pairUint64> nalStartEndPosFile,
277 std::shared_ptr<TreeItem> parent)
278{
279 ParserAnnexB::ParseResult parseResult;
280
281 if (nalID == -1 && data.empty())
282 {
283 if (curFramePOC != -1)
284 {
285 // Save the info of the last frame
286 if (!this->addFrameToList(curFramePOC, curFrameFileStartEndPos, curFrameIsRandomAccess))
287 {
288 throw std::logic_error("Error - POC " + std::to_string(curFramePOC) +
289 " alread in the POC list.");
290 }
291 if (curFrameFileStartEndPos)
292 DEBUG_HEVC("ParserAnnexBHEVC::parseAndAddNALUnit Adding start/end "
293 << curFrameFileStartEndPos->first << "/" << curFrameFileStartEndPos->second
294 << " - POC " << curFramePOC << (curFrameIsRandomAccess ? " - ra" : ""));
295 else
296 DEBUG_HEVC("ParserAnnexBHEVC::parseAndAddNALUnit Adding start/end NA/NA - POC "
297 << curFramePOC << (curFrameIsRandomAccess ? " - ra" : ""));
298 }
299 // The file ended
300 return parseResult;
301 }
302
303 // Use the given tree item. If it is not set, use the nalUnitMode (if active).
304 // Create a new TreeItem root for the NAL unit. We don't set data (a name) for this item
305 // yet. We want to parse the item and then set a good description.
306 std::shared_ptr<TreeItem> nalRoot;
307 if (parent)
308 nalRoot = parent->createChildItem();
309 else if (packetModel->rootItem)
310 nalRoot = packetModel->rootItem->createChildItem();
311
312 if (nalRoot)
313 ParserAnnexB::logNALSize(data, nalRoot, nalStartEndPosFile);
314
315 reader::SubByteReaderLogging reader(data, nalRoot, "", getStartCodeOffset(data));
316
317 std::string specificDescription;
318 auto nalHEVC = std::make_shared<NalUnitHEVC>(nalID, nalStartEndPosFile);
319
320 bool first_slice_segment_in_pic_flag = false;
321 bool currentSliceIntra = false;
322 std::string currentSliceType;
323 try
324 {
325 nalHEVC->header.parse(reader);
326 specificDescription = " " + NalTypeMapper.getName(nalHEVC->header.nal_unit_type);
327
328 if (nalHEVC->header.nal_unit_type == NalType::VPS_NUT)
329 {

Callers

nothing calls this directly

Calls 15

getStartCodeOffsetFunction · 0.85
addFrameToListMethod · 0.80
createChildItemMethod · 0.80
isIRAPMethod · 0.80
isRASLMethod · 0.80
isRADLMethod · 0.80
setPropertiesMethod · 0.80
to_stringFunction · 0.70
parseMethod · 0.45
getNameMethod · 0.45
isSliceMethod · 0.45

Tested by

no test coverage detected