| 577 | } |
| 578 | |
| 579 | std::optional<ParserAnnexB::SeekData> ParserAnnexBAVC::getSeekData(int iFrameNr) |
| 580 | { |
| 581 | if (iFrameNr >= int(this->getNumberPOCs()) || iFrameNr < 0) |
| 582 | return {}; |
| 583 | |
| 584 | auto seekPOC = this->getFramePOC(unsigned(iFrameNr)); |
| 585 | |
| 586 | // Collect the active parameter sets |
| 587 | using NalMap = std::map<unsigned, std::shared_ptr<NalUnitAVC>>; |
| 588 | NalMap activeSPSNal; |
| 589 | NalMap activePPSNal; |
| 590 | |
| 591 | for (auto nal : this->nalUnitsForSeeking) |
| 592 | { |
| 593 | if (nal->header.nal_unit_type == NalType::CODED_SLICE_IDR || |
| 594 | nal->header.nal_unit_type == NalType::CODED_SLICE_NON_IDR || |
| 595 | nal->header.nal_unit_type == NalType::CODED_SLICE_DATA_PARTITION_A) |
| 596 | { |
| 597 | int globalPOC{}; |
| 598 | if (nal->header.nal_unit_type == NalType::CODED_SLICE_IDR || |
| 599 | nal->header.nal_unit_type == NalType::CODED_SLICE_NON_IDR) |
| 600 | { |
| 601 | auto slice = std::dynamic_pointer_cast<slice_layer_without_partitioning_rbsp>(nal->rbsp); |
| 602 | globalPOC = slice->sliceHeader->globalPOC; |
| 603 | } |
| 604 | else if (nal->header.nal_unit_type == NalType::CODED_SLICE_DATA_PARTITION_A) |
| 605 | { |
| 606 | auto slice = std::dynamic_pointer_cast<slice_data_partition_a_layer_rbsp>(nal->rbsp); |
| 607 | globalPOC = slice->sliceHeader->globalPOC; |
| 608 | } |
| 609 | |
| 610 | if (globalPOC == seekPOC) |
| 611 | { |
| 612 | // Seek here |
| 613 | ParserAnnexB::SeekData seekData; |
| 614 | if (nal->filePosStartEnd) |
| 615 | seekData.filePos = nal->filePosStartEnd->first; |
| 616 | |
| 617 | // Get the bitstream of all active parameter sets |
| 618 | for (const auto &nalMap : {activeSPSNal, activePPSNal}) |
| 619 | { |
| 620 | for (auto const &entry : nalMap) |
| 621 | seekData.parameterSets.push_back(entry.second->rawData); |
| 622 | } |
| 623 | |
| 624 | return seekData; |
| 625 | } |
| 626 | } |
| 627 | else if (nal->header.nal_unit_type == NalType::SPS) |
| 628 | { |
| 629 | // Add sps (replace old one if existed) |
| 630 | auto sps = std::dynamic_pointer_cast<seq_parameter_set_rbsp>(nal->rbsp); |
| 631 | activeSPSNal[sps->seqParameterSetData.seq_parameter_set_id] = nal; |
| 632 | } |
| 633 | else if (nal->header.nal_unit_type == NalType::PPS) |
| 634 | { |
| 635 | // Add pps (replace old one if existed) |
| 636 | auto pps = std::dynamic_pointer_cast<pic_parameter_set_rbsp>(nal->rbsp); |
nothing calls this directly
no test coverage detected