diff --git a/YUViewLib/src/parser/AVC/HRD.cpp b/YUViewLib/src/parser/AVC/HRD.cpp index 853a46dbe..64f5deb18 100644 --- a/YUViewLib/src/parser/AVC/HRD.cpp +++ b/YUViewLib/src/parser/AVC/HRD.cpp @@ -76,11 +76,11 @@ void HRD::addAU(size_t auBits, const auto SchedSelIdx = 0; const auto initial_cpb_removal_delay = - lastBufferingPeriodSEI->initial_cpb_removal_delay[SchedSelIdx]; + lastBufferingPeriodSEI->initial_cpb_removal_delay.at(SchedSelIdx); const auto initial_cpb_removal_delay_offset = - lastBufferingPeriodSEI->initial_cpb_removal_delay_offset[SchedSelIdx]; + lastBufferingPeriodSEI->initial_cpb_removal_delay_offset.at(SchedSelIdx); - const bool cbr_flag = vuiParam.nalHrdParameters.cbr_flag[SchedSelIdx]; + const bool cbr_flag = vuiParam.nalHrdParameters.cbr_flag.at(SchedSelIdx); // TODO: Investigate the difference between our results and the results from stream-Eye // I noticed that the results from stream eye differ by a (seemingly random) additional diff --git a/YUViewLib/src/parser/AVC/ParserAnnexBAVC.cpp b/YUViewLib/src/parser/AVC/ParserAnnexBAVC.cpp index e062f2820..d0bcbd626 100644 --- a/YUViewLib/src/parser/AVC/ParserAnnexBAVC.cpp +++ b/YUViewLib/src/parser/AVC/ParserAnnexBAVC.cpp @@ -364,8 +364,9 @@ ParserAnnexBAVC::parseAndAddNALUnit(int currentSliceIntra = isRandomAccess; currentSliceType = to_string(newSliceHeader->slice_type); - DEBUG_AVC("ParserAnnexBAVC::parseAndAddNALUnit Parsed Slice POC " - << newSliceHeader->globalPOC); + DEBUG_AVC("ParserAnnexBAVC::parseAndAddNALUnit Parsed Slice (" + << QString::fromStdString(NalTypeMapper.getName(nalAVC->header.nal_unit_type)) + << ") POC " << newSliceHeader->globalPOC); parseResult.nalTypeName = "Slice(POC " + std::to_string(newSliceHeader->globalPOC) + ") "; } else if (nalAVC->header.nal_unit_type == NalType::CODED_SLICE_DATA_PARTITION_B) diff --git a/YUViewLib/src/parser/AVC/nal_unit_header.h b/YUViewLib/src/parser/AVC/nal_unit_header.h index 83c7753d9..cb8edc91b 100644 --- a/YUViewLib/src/parser/AVC/nal_unit_header.h +++ b/YUViewLib/src/parser/AVC/nal_unit_header.h @@ -32,6 +32,7 @@ #pragma once +#include "common/EnumMapper.h" #include "parser/common/SubByteReaderLogging.h" namespace parser::avc @@ -66,6 +67,32 @@ enum class NalType RESERVED_23 }; +const EnumMapper + NalTypeMapper({{NalType::UNSPECIFIED, "UNSPECIFIED"}, + {NalType::CODED_SLICE_NON_IDR, "CODED_SLICE_NON_IDR"}, + {NalType::CODED_SLICE_DATA_PARTITION_A, "CODED_SLICE_DATA_PARTITION_A"}, + {NalType::CODED_SLICE_DATA_PARTITION_B, "CODED_SLICE_DATA_PARTITION_B"}, + {NalType::CODED_SLICE_DATA_PARTITION_C, "CODED_SLICE_DATA_PARTITION_C"}, + {NalType::CODED_SLICE_IDR, "CODED_SLICE_IDR"}, + {NalType::SEI, "SEI"}, + {NalType::SPS, "SPS"}, + {NalType::PPS, "PPS"}, + {NalType::AUD, "AUD"}, + {NalType::END_OF_SEQUENCE, "END_OF_SEQUENCE"}, + {NalType::END_OF_STREAM, "END_OF_STREAM"}, + {NalType::FILLER, "FILLER"}, + {NalType::SPS_EXT, "SPS_EXT"}, + {NalType::PREFIX_NAL, "PREFIX_NAL"}, + {NalType::SUBSET_SPS, "SUBSET_SPS"}, + {NalType::DEPTH_PARAMETER_SET, "DEPTH_PARAMETER_SET"}, + {NalType::RESERVED_17, "RESERVED_17"}, + {NalType::RESERVED_18, "RESERVED_18"}, + {NalType::CODED_SLICE_AUX, "CODED_SLICE_AUX"}, + {NalType::CODED_SLICE_EXTENSION, "CODED_SLICE_EXTENSION"}, + {NalType::CODED_SLICE_EXTENSION_DEPTH_MAP, "CODED_SLICE_EXTENSION_DEPTH_MAP"}, + {NalType::RESERVED_22, "RESERVED_22"}, + {NalType::RESERVED_23, "RESERVED_23"}}); + class nal_unit_header { public: diff --git a/YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp b/YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp index 2e5a84c63..2a86d1242 100644 --- a/YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp +++ b/YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp @@ -301,12 +301,19 @@ ParserAVFormat::parseByteVectorAnnexBStartCodes(ByteVector & d { auto itNextStartCode = getNextNalStart(itStartCode); auto nalData = ByteVector(itStartCode + sizeStartCode, itNextStartCode); - auto parseResult = - this->annexBParser->parseAndAddNALUnit(nalID++, nalData, packetBitrateEntry, {}, item); - if (parseResult.success && parseResult.bitrateEntry) - this->bitratePlotModel->addBitratePoint(this->videoStreamIndex, *parseResult.bitrateEntry); - if (parseResult.success && parseResult.nalTypeName) - naNames[*parseResult.nalTypeName]++; + try + { + auto parseResult = + this->annexBParser->parseAndAddNALUnit(nalID++, nalData, packetBitrateEntry, {}, item); + if (parseResult.success && parseResult.bitrateEntry) + this->bitratePlotModel->addBitratePoint(this->videoStreamIndex, *parseResult.bitrateEntry); + if (parseResult.success && parseResult.nalTypeName) + naNames[*parseResult.nalTypeName]++; + } + catch (const std::exception &) + { + DEBUG_AVFORMAT("ParserAVFormat::parseByteVectorAnnexBStartCodes Parsing of NAL failed"); + } itStartCode = itNextStartCode; } return naNames; diff --git a/YUViewLib/src/parser/ParserAnnexB.cpp b/YUViewLib/src/parser/ParserAnnexB.cpp index 7a63174bb..3414f3438 100644 --- a/YUViewLib/src/parser/ParserAnnexB.cpp +++ b/YUViewLib/src/parser/ParserAnnexB.cpp @@ -66,9 +66,9 @@ bool ParserAnnexB::addFrameToList(int poc, if (f.poc == poc) return false; - if (pocOfFirstRandomAccessFrame == -1 && randomAccessPoint) - pocOfFirstRandomAccessFrame = poc; - if (poc >= pocOfFirstRandomAccessFrame) + if (!this->pocOfFirstRandomAccessFrame && randomAccessPoint) + this->pocOfFirstRandomAccessFrame = poc; + if (poc >= this->pocOfFirstRandomAccessFrame.value()) { // We don't add frames which we can not decode because they are before the first RA (I) frame AnnexBFrame newFrame; diff --git a/YUViewLib/src/parser/ParserAnnexB.h b/YUViewLib/src/parser/ParserAnnexB.h index feeba40e0..800202783 100644 --- a/YUViewLib/src/parser/ParserAnnexB.h +++ b/YUViewLib/src/parser/ParserAnnexB.h @@ -153,7 +153,7 @@ class ParserAnnexB : public Parser std::shared_ptr root, std::optional nalStartEndPos); - int pocOfFirstRandomAccessFrame{-1}; + std::optional pocOfFirstRandomAccessFrame{}; // Save general information about the file here struct stream_info_type