From 178c40869fd5c9c08834e3f94c48da30123039cd Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Tue, 20 Feb 2024 11:42:23 +0100 Subject: [PATCH] Add parsing of SPS extensions --- .../HEVC/Extensions/sps_3d_extension.cpp | 78 +++++++++++++++++ .../parser/HEVC/Extensions/sps_3d_extension.h | 65 +++++++++++++++ .../Extensions/sps_multilayer_extension.cpp | 47 +++++++++++ .../Extensions/sps_multilayer_extension.h | 51 ++++++++++++ .../HEVC/Extensions/sps_range_extension.cpp | 60 ++++++++++++++ .../HEVC/Extensions/sps_range_extension.h | 59 +++++++++++++ .../HEVC/Extensions/sps_scc_extension.cpp | 83 +++++++++++++++++++ .../HEVC/Extensions/sps_scc_extension.h | 62 ++++++++++++++ .../parser/HEVC/seq_parameter_set_rbsp.cpp | 34 ++++++-- .../src/parser/HEVC/seq_parameter_set_rbsp.h | 12 ++- 10 files changed, 542 insertions(+), 9 deletions(-) create mode 100644 YUViewLib/src/parser/HEVC/Extensions/sps_3d_extension.cpp create mode 100644 YUViewLib/src/parser/HEVC/Extensions/sps_3d_extension.h create mode 100644 YUViewLib/src/parser/HEVC/Extensions/sps_multilayer_extension.cpp create mode 100644 YUViewLib/src/parser/HEVC/Extensions/sps_multilayer_extension.h create mode 100644 YUViewLib/src/parser/HEVC/Extensions/sps_range_extension.cpp create mode 100644 YUViewLib/src/parser/HEVC/Extensions/sps_range_extension.h create mode 100644 YUViewLib/src/parser/HEVC/Extensions/sps_scc_extension.cpp create mode 100644 YUViewLib/src/parser/HEVC/Extensions/sps_scc_extension.h diff --git a/YUViewLib/src/parser/HEVC/Extensions/sps_3d_extension.cpp b/YUViewLib/src/parser/HEVC/Extensions/sps_3d_extension.cpp new file mode 100644 index 000000000..376c33268 --- /dev/null +++ b/YUViewLib/src/parser/HEVC/Extensions/sps_3d_extension.cpp @@ -0,0 +1,78 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * Copyright (C) 2015 Institut f�r Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sps_3d_extension.h" + +#include + +namespace parser::hevc +{ + +using namespace reader; + +void sps_3d_extension::parse(SubByteReaderLogging &reader) +{ + SubByteReaderLoggingSubLevel subLevel(reader, "sps_3d_extension()"); + + for (int d = 0; d <= 1; d++) + { + this->iv_di_mc_enabled_flag[d] = reader.readFlag(formatArray("iv_di_mc_enabled_flag", d)); + this->iv_mv_scal_enabled_flag[d] = reader.readFlag(formatArray("iv_mv_scal_enabled_flag", d)); + if (d == 0) + { + this->log2_ivmc_sub_pb_size_minus3[d] = + reader.readUEV(formatArray("log2_ivmc_sub_pb_size_minus3", d)); + this->iv_res_pred_enabled_flag[d] = + reader.readFlag(formatArray("iv_res_pred_enabled_flag", d)); + this->depth_ref_enabled_flag[d] = reader.readFlag(formatArray("depth_ref_enabled_flag", d)); + this->vsp_mc_enabled_flag[d] = reader.readFlag(formatArray("vsp_mc_enabled_flag", d)); + this->dbbp_enabled_flag[d] = reader.readFlag(formatArray("dbbp_enabled_flag", d)); + } + else + { + this->tex_mc_enabled_flag[d] = reader.readFlag(formatArray("tex_mc_enabled_flag", d)); + this->log2_texmc_sub_pb_size_minus3[d] = + reader.readUEV(formatArray("log2_texmc_sub_pb_size_minus3", d)); + this->intra_contour_enabled_flag[d] = + reader.readFlag(formatArray("intra_contour_enabled_flag", d)); + this->intra_dc_only_wedge_enabled_flag[d] = + reader.readFlag(formatArray("intra_dc_only_wedge_enabled_flag", d)); + this->cqt_cu_part_pred_enabled_flag[d] = + reader.readFlag(formatArray("cqt_cu_part_pred_enabled_flag", d)); + this->inter_dc_only_enabled_flag[d] = + reader.readFlag(formatArray("inter_dc_only_enabled_flag", d)); + this->skip_intra_enabled_flag[d] = reader.readFlag(formatArray("skip_intra_enabled_flag", d)); + } + } +} + +} // namespace parser::hevc diff --git a/YUViewLib/src/parser/HEVC/Extensions/sps_3d_extension.h b/YUViewLib/src/parser/HEVC/Extensions/sps_3d_extension.h new file mode 100644 index 000000000..9ca49bba9 --- /dev/null +++ b/YUViewLib/src/parser/HEVC/Extensions/sps_3d_extension.h @@ -0,0 +1,65 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * Copyright (C) 2015 Institut f�r Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "parser/common/SubByteReaderLogging.h" + +namespace parser::hevc +{ + +// I.7.3.2.2.5 Sequence parameter set 3D extension syntax +class sps_3d_extension +{ +public: + sps_3d_extension() {} + + void parse(reader::SubByteReaderLogging &reader); + + bool iv_di_mc_enabled_flag[2]{}; + bool iv_mv_scal_enabled_flag[2]{}; + unsigned log2_ivmc_sub_pb_size_minus3[2]{}; + bool iv_res_pred_enabled_flag[2]{}; + bool depth_ref_enabled_flag[2]{}; + bool vsp_mc_enabled_flag[2]{}; + bool dbbp_enabled_flag[2]{}; + + bool tex_mc_enabled_flag[2]{}; + unsigned log2_texmc_sub_pb_size_minus3[2]{}; + bool intra_contour_enabled_flag[2]{}; + bool intra_dc_only_wedge_enabled_flag[2]{}; + bool cqt_cu_part_pred_enabled_flag[2]{}; + bool inter_dc_only_enabled_flag[2]{}; + bool skip_intra_enabled_flag[2]{}; +}; + +} // namespace parser::hevc diff --git a/YUViewLib/src/parser/HEVC/Extensions/sps_multilayer_extension.cpp b/YUViewLib/src/parser/HEVC/Extensions/sps_multilayer_extension.cpp new file mode 100644 index 000000000..f7269c08b --- /dev/null +++ b/YUViewLib/src/parser/HEVC/Extensions/sps_multilayer_extension.cpp @@ -0,0 +1,47 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * Copyright (C) 2015 Institut f�r Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sps_multilayer_extension.h" + +namespace parser::hevc +{ + +using namespace reader; + +void sps_multilayer_extension::parse(SubByteReaderLogging &reader) +{ + SubByteReaderLoggingSubLevel subLevel(reader, "sps_multilayer_extension()"); + + this->inter_view_mv_vert_constraint_flag = reader.readFlag("inter_view_mv_vert_constraint_flag"); +} + +} // namespace parser::hevc diff --git a/YUViewLib/src/parser/HEVC/Extensions/sps_multilayer_extension.h b/YUViewLib/src/parser/HEVC/Extensions/sps_multilayer_extension.h new file mode 100644 index 000000000..8a8a2dda8 --- /dev/null +++ b/YUViewLib/src/parser/HEVC/Extensions/sps_multilayer_extension.h @@ -0,0 +1,51 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * Copyright (C) 2015 Institut f�r Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "parser/common/SubByteReaderLogging.h" + +namespace parser::hevc +{ + +// F.7.3.2.2.4 Sequence parameter set multilayer extension syntax +class sps_multilayer_extension +{ +public: + sps_multilayer_extension() {} + + void parse(reader::SubByteReaderLogging &reader); + + bool inter_view_mv_vert_constraint_flag{}; +}; + +} // namespace parser::hevc diff --git a/YUViewLib/src/parser/HEVC/Extensions/sps_range_extension.cpp b/YUViewLib/src/parser/HEVC/Extensions/sps_range_extension.cpp new file mode 100644 index 000000000..eda25c13c --- /dev/null +++ b/YUViewLib/src/parser/HEVC/Extensions/sps_range_extension.cpp @@ -0,0 +1,60 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * Copyright (C) 2015 Institut f�r Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sps_range_extension.h" + +namespace parser::hevc +{ + +using namespace reader; + +void sps_range_extension::parse(SubByteReaderLogging &reader) +{ + SubByteReaderLoggingSubLevel subLevel(reader, "sps_range_extension()"); + + this->transform_skip_rotation_enabled_flag = + reader.readFlag("transform_skip_rotation_enabled_flag"); + this->transform_skip_context_enabled_flag = + reader.readFlag("transform_skip_context_enabled_flag"); + this->implicit_rdpcm_enabled_flag = reader.readFlag("implicit_rdpcm_enabled_flag"); + this->explicit_rdpcm_enabled_flag = reader.readFlag("explicit_rdpcm_enabled_flag"); + this->extended_precision_processing_flag = reader.readFlag("extended_precision_processing_flag"); + this->intra_smoothing_disabled_flag = reader.readFlag("intra_smoothing_disabled_flag"); + this->high_precision_offsets_enabled_flag = + reader.readFlag("high_precision_offsets_enabled_flag"); + this->persistent_rice_adaptation_enabled_flag = + reader.readFlag("persistent_rice_adaptation_enabled_flag"); + this->cabac_bypass_alignment_enabled_flag = + reader.readFlag("cabac_bypass_alignment_enabled_flag"); +} + +} // namespace parser::hevc diff --git a/YUViewLib/src/parser/HEVC/Extensions/sps_range_extension.h b/YUViewLib/src/parser/HEVC/Extensions/sps_range_extension.h new file mode 100644 index 000000000..853f407e7 --- /dev/null +++ b/YUViewLib/src/parser/HEVC/Extensions/sps_range_extension.h @@ -0,0 +1,59 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * Copyright (C) 2015 Institut f�r Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "parser/common/SubByteReaderLogging.h" + +namespace parser::hevc +{ + +// 7.3.2.2.2 Sequence parameter set range extension syntax +class sps_range_extension +{ +public: + sps_range_extension() {} + + void parse(reader::SubByteReaderLogging &reader); + + bool transform_skip_rotation_enabled_flag{}; + bool transform_skip_context_enabled_flag{}; + bool implicit_rdpcm_enabled_flag{}; + bool explicit_rdpcm_enabled_flag{}; + bool extended_precision_processing_flag{}; + bool intra_smoothing_disabled_flag{}; + bool high_precision_offsets_enabled_flag{}; + bool persistent_rice_adaptation_enabled_flag{}; + bool cabac_bypass_alignment_enabled_flag{}; +}; + +} // namespace parser::hevc diff --git a/YUViewLib/src/parser/HEVC/Extensions/sps_scc_extension.cpp b/YUViewLib/src/parser/HEVC/Extensions/sps_scc_extension.cpp new file mode 100644 index 000000000..6569a623e --- /dev/null +++ b/YUViewLib/src/parser/HEVC/Extensions/sps_scc_extension.cpp @@ -0,0 +1,83 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * Copyright (C) 2015 Institut f�r Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "sps_scc_extension.h" + +#include + +namespace parser::hevc +{ + +using namespace reader; + +void sps_scc_extension::parse(SubByteReaderLogging &reader, + const unsigned chroma_format_idc, + const unsigned bitDepthLuma, + const unsigned bitDepthChroma) +{ + SubByteReaderLoggingSubLevel subLevel(reader, "sps_scc_extension()"); + + this->sps_curr_pic_ref_enabled_flag = reader.readFlag("sps_curr_pic_ref_enabled_flag"); + this->palette_mode_enabled_flag = reader.readFlag("palette_mode_enabled_flag"); + if (this->palette_mode_enabled_flag) + { + this->palette_max_size = reader.readUEV("palette_max_size"); + this->delta_palette_max_predictor_size = reader.readUEV("delta_palette_max_predictor_size"); + this->sps_palette_predictor_initializers_present_flag = + reader.readFlag("sps_palette_predictor_initializers_present_flag"); + if (this->sps_palette_predictor_initializers_present_flag) + { + this->sps_num_palette_predictor_initializers_minus1 = + reader.readUEV("sps_num_palette_predictor_initializers_minus1"); + const auto numComps = (chroma_format_idc == 0) ? 1 : 3; + for (int comp = 0; comp < numComps; comp++) + { + for (int i = 0; i <= this->sps_num_palette_predictor_initializers_minus1; i++) + { + // There is an issue in the HEVC spec here. It is missing the number of bits that are used + // to code this symbol. From the SCC reference software I was able to deduce that it + // should be equal to the number for bit_depth signaled in the SPS for the component. + const int numBits = (comp == 0) ? bitDepthLuma : bitDepthChroma; + + sps_palette_predictor_initializer[comp][i] = + reader.readBits(formatArray("sps_palette_predictor_initializer", comp, i), numBits); + } + } + } + } + this->motion_vector_resolution_control_idc = + reader.readBits("motion_vector_resolution_control_idc", 2); + this->intra_boundary_filtering_disabled_flag = + reader.readFlag("intra_boundary_filtering_disabled_flag"); +} + +} // namespace parser::hevc diff --git a/YUViewLib/src/parser/HEVC/Extensions/sps_scc_extension.h b/YUViewLib/src/parser/HEVC/Extensions/sps_scc_extension.h new file mode 100644 index 000000000..ea839b30b --- /dev/null +++ b/YUViewLib/src/parser/HEVC/Extensions/sps_scc_extension.h @@ -0,0 +1,62 @@ +/* This file is part of YUView - The YUV player with advanced analytics toolset + * + * Copyright (C) 2015 Institut f�r Nachrichtentechnik, RWTH Aachen University, GERMANY + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + * + * You must obey the GNU General Public License in all respects for all + * of the code used other than OpenSSL. If you modify file(s) with this + * exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do + * so, delete this exception statement from your version. If you delete + * this exception statement from all source files in the program, then + * also delete it here. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "parser/common/SubByteReaderLogging.h" + +namespace parser::hevc +{ + +// 7.3.2.2.3 Sequence parameter set screen content coding extension syntax +class sps_scc_extension +{ +public: + sps_scc_extension() {} + + void parse(reader::SubByteReaderLogging &reader, + const unsigned chroma_format_idc, + const unsigned bitDepthLuma, + const unsigned bitDepthChroma); + + bool sps_curr_pic_ref_enabled_flag{}; + bool palette_mode_enabled_flag{}; + unsigned palette_max_size{}; + unsigned delta_palette_max_predictor_size{}; + bool sps_palette_predictor_initializers_present_flag{}; + unsigned sps_num_palette_predictor_initializers_minus1{}; + umap_2d sps_palette_predictor_initializer; + unsigned motion_vector_resolution_control_idc{}; + bool intra_boundary_filtering_disabled_flag{}; +}; + +} // namespace parser::hevc diff --git a/YUViewLib/src/parser/HEVC/seq_parameter_set_rbsp.cpp b/YUViewLib/src/parser/HEVC/seq_parameter_set_rbsp.cpp index b4cb307aa..e9ffcb82a 100644 --- a/YUViewLib/src/parser/HEVC/seq_parameter_set_rbsp.cpp +++ b/YUViewLib/src/parser/HEVC/seq_parameter_set_rbsp.cpp @@ -50,7 +50,7 @@ void seq_parameter_set_rbsp::parse(SubByteReaderLogging & reader, if (nalUnitHeader.nuh_layer_id == 0) this->sps_max_sub_layers_minus1 = reader.readBits("sps_max_sub_layers_minus1", 3); else - this->sps_ext_or_max_sub_layers_minus1 = reader.readBits("sps_max_sub_layers_minus1", 3); + this->sps_ext_or_max_sub_layers_minus1 = reader.readBits("sps_ext_or_max_sub_layers_minus1", 3); const auto MultiLayerExtSpsFlag = (nalUnitHeader.nuh_layer_id != 0 && this->sps_ext_or_max_sub_layers_minus1 == 7); @@ -100,10 +100,10 @@ void seq_parameter_set_rbsp::parse(SubByteReaderLogging & reader, this->bit_depth_chroma_minus8 = reader.readUEV("bit_depth_chroma_minus8"); } + this->log2_max_pic_order_cnt_lsb_minus4 = reader.readUEV("log2_max_pic_order_cnt_lsb_minus4"); + if (!MultiLayerExtSpsFlag) { - this->log2_max_pic_order_cnt_lsb_minus4 = reader.readUEV("log2_max_pic_order_cnt_lsb_minus4"); - this->sps_sub_layer_ordering_info_present_flag = reader.readFlag("sps_sub_layer_ordering_info_present_flag"); for (unsigned i = @@ -192,21 +192,39 @@ void seq_parameter_set_rbsp::parse(SubByteReaderLogging & reader, this->sps_range_extension_flag = reader.readFlag("sps_range_extension_flag"); this->sps_multilayer_extension_flag = reader.readFlag("sps_multilayer_extension_flag"); this->sps_3d_extension_flag = reader.readFlag("sps_3d_extension_flag"); - this->sps_extension_5bits = reader.readBits("sps_extension_5bits", 5); + this->sps_scc_extension_flag = reader.readFlag("sps_scc_extension_flag"); + this->sps_extension_4bits = reader.readBits("sps_extension_4bits", 4); } // Now the extensions follow ... // This would also be interesting but later. if (this->sps_range_extension_flag) - reader.logArbitrary("sps_range_extension()", "", "", "", "Not implemented yet..."); + this->rangeExtension.parse(reader); if (this->sps_multilayer_extension_flag) - reader.logArbitrary("sps_multilayer_extension()", "", "", "", "Not implemented yet..."); + this->multilayerExtension.parse(reader); if (this->sps_3d_extension_flag) - reader.logArbitrary("sps_3d_extension()", "", "", "", "Not implemented yet..."); + this->extension3D.parse(reader); + + if (this->sps_scc_extension_flag) + { + if (MultiLayerExtSpsFlag) + { + // For multiview, the bit depths would have to be obtained from the main SPS ... + // Is this even possible to combine SCC with Multiview? + reader.logArbitrary("sps_scc_extension()", "", "", "", "Not supported for Multiview..."); + } + else + { + this->sccExtension.parse(reader, + this->chroma_format_idc, + this->bit_depth_luma_minus8 + 8, + this->bit_depth_chroma_minus8 + 8); + } + } - if (this->sps_extension_5bits != 0) + if (this->sps_extension_4bits != 0) reader.logArbitrary("sps_extension_data_flag()", "", "", "", "Not implemented yet..."); // rbspTrailingBits.parse(reader); diff --git a/YUViewLib/src/parser/HEVC/seq_parameter_set_rbsp.h b/YUViewLib/src/parser/HEVC/seq_parameter_set_rbsp.h index 727036471..63841fbd9 100644 --- a/YUViewLib/src/parser/HEVC/seq_parameter_set_rbsp.h +++ b/YUViewLib/src/parser/HEVC/seq_parameter_set_rbsp.h @@ -32,6 +32,10 @@ #pragma once +#include "Extensions/sps_3d_extension.h" +#include "Extensions/sps_multilayer_extension.h" +#include "Extensions/sps_range_extension.h" +#include "Extensions/sps_scc_extension.h" #include "NalUnitHEVC.h" #include "parser/common/SubByteReaderLogging.h" #include "profile_tier_level.h" @@ -110,7 +114,8 @@ class seq_parameter_set_rbsp : public NalRBSP bool sps_range_extension_flag{}; bool sps_multilayer_extension_flag{}; bool sps_3d_extension_flag{}; - unsigned sps_extension_5bits{}; + bool sps_scc_extension_flag{}; + unsigned sps_extension_4bits{}; rbsp_trailing_bits rbspTrailingBits; @@ -129,6 +134,11 @@ class seq_parameter_set_rbsp : public NalRBSP bool update_rep_format_flag{}; unsigned sps_rep_format_idx{}; + sps_range_extension rangeExtension{}; + sps_multilayer_extension multilayerExtension{}; + sps_3d_extension extension3D{}; + sps_scc_extension sccExtension{}; + // Get the actual size of the image that will be returned. Internally the image might be bigger. unsigned get_conformance_cropping_width() const {