| 51 | using namespace parser::reader; |
| 52 | |
| 53 | void picture_header_structure::parse(SubByteReaderLogging & reader, |
| 54 | VPSMap & vpsMap, |
| 55 | SPSMap & spsMap, |
| 56 | PPSMap & ppsMap, |
| 57 | std::shared_ptr<slice_layer_rbsp> sl) |
| 58 | { |
| 59 | SubByteReaderLoggingSubLevel subLevel(reader, "picture_header_structure"); |
| 60 | |
| 61 | this->ph_gdr_or_irap_pic_flag = reader.readFlag("ph_gdr_or_irap_pic_flag"); |
| 62 | this->ph_non_ref_pic_flag = reader.readFlag("ph_non_ref_pic_flag"); |
| 63 | if (this->ph_gdr_or_irap_pic_flag) |
| 64 | { |
| 65 | this->ph_gdr_pic_flag = reader.readFlag("ph_gdr_pic_flag"); |
| 66 | } |
| 67 | { |
| 68 | // if (this->ph_gdr_or_irap_pic_flag && !this->ph_gdr_pic_flag && vps_independent_layer_flag[ |
| 69 | // GeneralLayerIdx[ nuh_layer_id ] ] ) |
| 70 | // the value should be 0 |
| 71 | this->ph_inter_slice_allowed_flag = reader.readFlag("ph_inter_slice_allowed_flag"); |
| 72 | } |
| 73 | if (this->ph_inter_slice_allowed_flag) |
| 74 | { |
| 75 | this->ph_intra_slice_allowed_flag = reader.readFlag("ph_intra_slice_allowed_flag"); |
| 76 | } |
| 77 | this->ph_pic_parameter_set_id = |
| 78 | reader.readUEV("ph_pic_parameter_set_id", Options().withCheckRange({0, 63})); |
| 79 | |
| 80 | if (ppsMap.count(this->ph_pic_parameter_set_id) == 0) |
| 81 | throw std::logic_error("PPS with given ph_pic_parameter_set_id not found."); |
| 82 | auto pps = ppsMap[this->ph_pic_parameter_set_id]; |
| 83 | |
| 84 | if (spsMap.count(pps->pps_seq_parameter_set_id) == 0) |
| 85 | throw std::logic_error("SPS with given pps_seq_parameter_set_id not found."); |
| 86 | auto sps = spsMap[pps->pps_seq_parameter_set_id]; |
| 87 | |
| 88 | std::shared_ptr<video_parameter_set_rbsp> vps; |
| 89 | if (sps->sps_video_parameter_set_id > 0) |
| 90 | { |
| 91 | if (vpsMap.count(sps->sps_video_parameter_set_id) == 0) |
| 92 | throw std::logic_error("VPS with given sps_video_parameter_set_id not found."); |
| 93 | vps = vpsMap[sps->sps_video_parameter_set_id]; |
| 94 | } |
| 95 | else |
| 96 | { |
| 97 | vps = std::make_shared<video_parameter_set_rbsp>(); |
| 98 | } |
| 99 | |
| 100 | if (!sps->sps_gdr_enabled_flag && this->ph_gdr_pic_flag) |
| 101 | { |
| 102 | throw std::logic_error("When sps_gdr_enabled_flag is equal to 0, the value of ph_gdr_pic_flag " |
| 103 | "shall be equal to 0."); |
| 104 | } |
| 105 | |
| 106 | { |
| 107 | auto nrBits = sps->sps_log2_max_pic_order_cnt_lsb_minus4 + 4; |
| 108 | this->ph_pic_order_cnt_lsb = reader.readBits( |
| 109 | "ph_pic_order_cnt_lsb", nrBits, Options().withCheckRange({0, sps->MaxPicOrderCntLsb - 1})); |
| 110 | } |