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

Method getExtradata

YUViewLib/src/parser/AVC/ParserAnnexBAVC.cpp:644–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642}
643
644QByteArray ParserAnnexBAVC::getExtradata()
645{
646 // Convert the SPS and PPS that we found in the bitstream to the libavformat avcc format (see
647 // avc.c)
648 ByteVector e;
649 e.push_back((unsigned char)1); /* version */
650
651 // Get the first SPS and PPS
652 std::shared_ptr<seq_parameter_set_rbsp> sps;
653 std::shared_ptr<pic_parameter_set_rbsp> pps;
654 ByteVector spsData;
655 ByteVector ppsData;
656 for (auto nal : this->nalUnitsForSeeking)
657 {
658 if (nal->header.nal_unit_type == NalType::SPS)
659 {
660 sps = std::dynamic_pointer_cast<seq_parameter_set_rbsp>(nal->rbsp);
661 spsData = nal->rawData;
662 }
663 if (nal->header.nal_unit_type == NalType::PPS)
664 {
665 pps = std::dynamic_pointer_cast<pic_parameter_set_rbsp>(nal->rbsp);
666 ppsData = nal->rawData;
667 }
668
669 if (sps && pps)
670 break;
671 }
672
673 if (!sps || !pps)
674 return {};
675
676 // Add profile, compatibility and level
677 int profile_compat = 0;
678 if (sps->seqParameterSetData.constraint_set0_flag)
679 profile_compat += 128;
680 if (sps->seqParameterSetData.constraint_set1_flag)
681 profile_compat += 64;
682 if (sps->seqParameterSetData.constraint_set2_flag)
683 profile_compat += 32;
684 if (sps->seqParameterSetData.constraint_set3_flag)
685 profile_compat += 16;
686 if (sps->seqParameterSetData.constraint_set4_flag)
687 profile_compat += 8;
688 if (sps->seqParameterSetData.constraint_set5_flag)
689 profile_compat += 4;
690
691 e.push_back(sps->seqParameterSetData.profile_idc);
692 e.push_back(profile_compat);
693 e.push_back(sps->seqParameterSetData.level_idc);
694
695 e.push_back((unsigned char)255); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */
696 e.push_back((unsigned char)225); /* 3 bits reserved (111) + 5 bits number of sps (00001) */
697
698 // Write SPS
699 while (spsData.back() == 0)
700 spsData.pop_back();
701 auto dataSizeSPS = spsData.size() - getStartCodeOffset(spsData);

Callers 1

runParsingOfFileMethod · 0.45

Calls 2

getStartCodeOffsetFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected