From fe173d132d3bc3248e97cd13e3fa458819b52d0b Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Tue, 19 Mar 2024 17:16:28 +0100 Subject: [PATCH] Add parsing of three_dimensional_reference_displays_info --- YUViewLib/src/parser/HEVC/SEI/sei_message.cpp | 5 +- ...ee_dimensional_reference_displays_info.cpp | 102 ++++++++++++++++++ ...hree_dimensional_reference_displays_info.h | 69 ++++++++++++ 3 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 YUViewLib/src/parser/HEVC/SEI/three_dimensional_reference_displays_info.cpp create mode 100644 YUViewLib/src/parser/HEVC/SEI/three_dimensional_reference_displays_info.h diff --git a/YUViewLib/src/parser/HEVC/SEI/sei_message.cpp b/YUViewLib/src/parser/HEVC/SEI/sei_message.cpp index 9cc37adf8..0c659cd2a 100644 --- a/YUViewLib/src/parser/HEVC/SEI/sei_message.cpp +++ b/YUViewLib/src/parser/HEVC/SEI/sei_message.cpp @@ -38,9 +38,10 @@ #include "content_light_level_info.h" #include "mastering_display_colour_volume.h" #include "parser/common/SubByteReaderLoggingOptions.h" -#include #include "pic_timing.h" +#include "three_dimensional_reference_displays_info.h" #include "user_data_unregistered.h" +#include namespace parser::hevc { @@ -234,6 +235,8 @@ sei_message::parsePayloadData(bool reparse, this->payload = std::make_shared(); else if (this->payloadType == 147) this->payload = std::make_shared(); + else if (this->payloadType == 176) + this->payload = std::make_shared(); else this->payload = std::make_shared(); } diff --git a/YUViewLib/src/parser/HEVC/SEI/three_dimensional_reference_displays_info.cpp b/YUViewLib/src/parser/HEVC/SEI/three_dimensional_reference_displays_info.cpp new file mode 100644 index 000000000..24e24ac74 --- /dev/null +++ b/YUViewLib/src/parser/HEVC/SEI/three_dimensional_reference_displays_info.cpp @@ -0,0 +1,102 @@ +/* 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 "three_dimensional_reference_displays_info.h" + +#include + +namespace parser::hevc +{ + +using namespace reader; + +SEIParsingResult three_dimensional_reference_displays_info::parse( + reader::SubByteReaderLogging & reader, + bool reparse, + VPSMap & vpsMap, + SPSMap & spsMap, + std::shared_ptr associatedSPS) +{ + (void)reparse; + (void)vpsMap; + (void)spsMap; + (void)associatedSPS; + + SubByteReaderLoggingSubLevel subLevel(reader, "three_dimensional_reference_displays_info"); + + this->prec_ref_display_width = reader.readUEV("prec_ref_display_width"); + this->ref_viewing_distance_flag = reader.readFlag("ref_viewing_distance_flag"); + if (this->ref_viewing_distance_flag) + this->prec_ref_viewing_dist = reader.readUEV("prec_ref_viewing_dist"); + this->num_ref_displays_minus1 = reader.readUEV("num_ref_displays_minus1"); + for (unsigned i = 0; i <= num_ref_displays_minus1; ++i) + { + this->left_view_id.push_back(reader.readUEV(formatArray("left_view_id", i))); + this->right_view_id.push_back(reader.readUEV(formatArray("right_view_id", i))); + this->exponent_ref_display_width.push_back( + reader.readBits(formatArray("exponent_ref_display_width", i), 6)); + + const auto refDispWidthBits = + this->exponent_ref_display_width.at(i) == 0 + ? std::max(0ull, this->prec_ref_display_width - 30) + : std::max(0ull, + this->exponent_ref_display_width.at(i) + this->prec_ref_display_width - 31); + this->mantissa_ref_display_width.push_back( + reader.readBits(formatArray("mantissa_ref_display_width", i), refDispWidthBits)); + + if (this->ref_viewing_distance_flag) + { + this->exponent_ref_viewing_distance.push_back( + reader.readBits(formatArray("exponent_ref_viewing_distance", i), 6)); + + const auto refViewDistBits = exponent_ref_viewing_distance.at(i) == 0 + ? std::max(0ull, this->prec_ref_viewing_dist - 30) + : std::max(0ull, + this->exponent_ref_viewing_distance.at(i) + + this->prec_ref_viewing_dist - 31); + this->mantissa_ref_viewing_distance.push_back( + reader.readBits(formatArray("mantissa_ref_viewing_distance", i), refViewDistBits)); + } + this->additional_shift_present_flag.push_back( + reader.readFlag(formatArray("additional_shift_present_flag", i))); + if (this->additional_shift_present_flag.at(i)) + this->num_sample_shift_plus512[i] = + reader.readBits(formatArray("num_sample_shift_plus512", i), 10); + } + + this->three_dimensional_reference_displays_extension_flag = + reader.readFlag("three_dimensional_reference_displays_extension_flag"); + + return SEIParsingResult::OK; +} + +} // namespace parser::hevc \ No newline at end of file diff --git a/YUViewLib/src/parser/HEVC/SEI/three_dimensional_reference_displays_info.h b/YUViewLib/src/parser/HEVC/SEI/three_dimensional_reference_displays_info.h new file mode 100644 index 000000000..250702680 --- /dev/null +++ b/YUViewLib/src/parser/HEVC/SEI/three_dimensional_reference_displays_info.h @@ -0,0 +1,69 @@ +/* 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" +#include "sei_message.h" + +namespace parser::hevc +{ + +class three_dimensional_reference_displays_info : public sei_payload +{ +public: + three_dimensional_reference_displays_info() = default; + + SEIParsingResult parse(reader::SubByteReaderLogging & reader, + bool reparse, + VPSMap & vpsMap, + SPSMap & spsMap, + std::shared_ptr associatedSPS) override; + + uint64_t prec_ref_display_width{}; + bool ref_viewing_distance_flag{}; + uint64_t prec_ref_viewing_dist{}; + uint64_t num_ref_displays_minus1{}; + + vector left_view_id; + vector right_view_id; + vector exponent_ref_display_width; + vector mantissa_ref_display_width; + vector exponent_ref_viewing_distance; + vector mantissa_ref_viewing_distance; + vector additional_shift_present_flag; + umap_1d num_sample_shift_plus512; + + bool three_dimensional_reference_displays_extension_flag{}; +}; + +} // namespace parser::hevc \ No newline at end of file