-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #565 from IENT/bugfix/multiviewHEVCParsing
Add support and fix multiview HEVC parsing
- Loading branch information
Showing
51 changed files
with
3,150 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
YUViewLib/src/parser/HEVC/Extensions/colour_mapping_octants.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* This file is part of YUView - The YUV player with advanced analytics toolset | ||
* <https://github.com/IENT/YUView> | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "colour_mapping_octants.h" | ||
|
||
#include <parser/common/Functions.h> | ||
|
||
namespace parser::hevc | ||
{ | ||
|
||
using namespace reader; | ||
|
||
void colour_mapping_octants::parse(SubByteReaderLogging &reader, | ||
const unsigned cm_octant_depth, | ||
const unsigned cm_y_part_num_log2, | ||
const unsigned CMResLSBits, | ||
const unsigned inpDepth, | ||
const unsigned idxY, | ||
const unsigned idxCb, | ||
const unsigned idxCr, | ||
const unsigned inpLength) | ||
{ | ||
std::string subLevelName = "colour_mapping_octants("; | ||
subLevelName += "inpDepth=" + std::to_string(inpDepth); | ||
subLevelName += ", idxY=" + std::to_string(idxY); | ||
subLevelName += ", idxCb=" + std::to_string(idxCb); | ||
subLevelName += ", idxCr=" + std::to_string(idxCr); | ||
subLevelName += ", inpLength=" + std::to_string(inpLength); | ||
subLevelName += ")"; | ||
|
||
SubByteReaderLoggingSubLevel subLevel(reader, subLevelName); | ||
|
||
// F.7.4.3.3.5 (F-43) | ||
const auto PartNumY = 1u << cm_y_part_num_log2; | ||
|
||
if (inpDepth < cm_octant_depth) | ||
this->split_octant_flag = reader.readFlag("split_octant_flag"); | ||
if (this->split_octant_flag) | ||
{ | ||
for (int k = 0; k < 2; k++) | ||
{ | ||
for (int m = 0; m < 2; m++) | ||
{ | ||
for (int n = 0; n < 2; n++) | ||
{ | ||
this->colourMappingOctants = std::make_unique<array3d<colour_mapping_octants, 2, 2, 2>>(); | ||
(*this->colourMappingOctants)[k][m][n].parse(reader, | ||
cm_octant_depth, | ||
cm_y_part_num_log2, | ||
CMResLSBits, | ||
inpDepth + 1, | ||
idxY + PartNumY * k * inpLength / 2, | ||
idxCb + m * inpLength / 2, | ||
idxCr + n * inpLength / 2, | ||
inpLength / 2); | ||
} | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
for (unsigned i = 0; i < PartNumY; i++) | ||
{ | ||
const auto idxShiftY = idxY + (i << (cm_octant_depth - inpDepth)); | ||
for (unsigned j = 0; j < 4; j++) | ||
{ | ||
this->coded_res_flag[idxShiftY][idxCb][idxCr][j] = | ||
reader.readFlag(formatArray("coded_res_flag", idxShiftY, idxCb, idxCr, j)); | ||
if (this->coded_res_flag[idxShiftY][idxCb][idxCr][j]) | ||
{ | ||
for (unsigned c = 0; c < 3; c++) | ||
{ | ||
this->res_coeff_q[idxShiftY][idxCb][idxCr][j][c] = | ||
reader.readUEV(formatArray("res_coeff_q", idxShiftY, idxCb, idxCr, j, c)); | ||
if (CMResLSBits == 0) | ||
this->res_coeff_r[idxShiftY][idxCb][idxCr][j][c] = 0; | ||
else | ||
this->res_coeff_r[idxShiftY][idxCb][idxCr][j][c] = reader.readBits( | ||
formatArray("res_coeff_r", idxShiftY, idxCb, idxCr, j, c), CMResLSBits); | ||
if (this->res_coeff_q[idxShiftY][idxCb][idxCr][j][c] || | ||
this->res_coeff_r[idxShiftY][idxCb][idxCr][j][c]) | ||
this->res_coeff_s[idxShiftY][idxCb][idxCr][j][c] = | ||
reader.readFlag(formatArray("res_coeff_s", idxShiftY, idxCb, idxCr, j, c)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} // namespace parser::hevc |
66 changes: 66 additions & 0 deletions
66
YUViewLib/src/parser/HEVC/Extensions/colour_mapping_octants.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* This file is part of YUView - The YUV player with advanced analytics toolset | ||
* <https://github.com/IENT/YUView> | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "parser/common/SubByteReaderLogging.h" | ||
|
||
namespace parser::hevc | ||
{ | ||
|
||
// F.7.3.2.3.6 Colour mapping octants syntax | ||
class colour_mapping_octants | ||
{ | ||
public: | ||
colour_mapping_octants() {} | ||
|
||
void parse(reader::SubByteReaderLogging &reader, | ||
const unsigned cm_octant_depth, | ||
const unsigned cm_y_part_num_log2, | ||
const unsigned CMResLSBits, | ||
const unsigned inpDepth, | ||
const unsigned idxY, | ||
const unsigned idxCb, | ||
const unsigned idxCr, | ||
const unsigned inpLength); | ||
|
||
bool split_octant_flag{}; | ||
|
||
std::unique_ptr<array3d<colour_mapping_octants, 2, 2, 2>> colourMappingOctants; | ||
|
||
umap_4d<bool> coded_res_flag; | ||
umap_5d<unsigned> res_coeff_q; | ||
umap_5d<unsigned> res_coeff_r; | ||
umap_5d<unsigned> res_coeff_s; | ||
}; | ||
|
||
} // namespace parser::hevc |
81 changes: 81 additions & 0 deletions
81
YUViewLib/src/parser/HEVC/Extensions/colour_mapping_table.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* This file is part of YUView - The YUV player with advanced analytics toolset | ||
* <https://github.com/IENT/YUView> | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "colour_mapping_table.h" | ||
|
||
#include <parser/common/Functions.h> | ||
|
||
namespace parser::hevc | ||
{ | ||
|
||
using namespace reader; | ||
|
||
void colour_mapping_table::parse(SubByteReaderLogging &reader) | ||
{ | ||
SubByteReaderLoggingSubLevel subLevel(reader, "colour_mapping_table()"); | ||
|
||
this->num_cm_ref_layers_minus1 = reader.readUEV("num_cm_ref_layers_minus1"); | ||
for (unsigned i = 0; i <= this->num_cm_ref_layers_minus1; i++) | ||
this->cm_ref_layer_id.push_back(reader.readBits(formatArray("cm_ref_layer_id", i), 6)); | ||
this->cm_octant_depth = reader.readBits("cm_octant_depth", 2); | ||
this->cm_y_part_num_log2 = reader.readBits("cm_y_part_num_log2", 2); | ||
this->luma_bit_depth_cm_input_minus8 = reader.readUEV("luma_bit_depth_cm_input_minus8"); | ||
this->chroma_bit_depth_cm_input_minus8 = reader.readUEV("chroma_bit_depth_cm_input_minus8"); | ||
this->luma_bit_depth_cm_output_minus8 = reader.readUEV("luma_bit_depth_cm_output_minus8"); | ||
this->chroma_bit_depth_cm_output_minus8 = reader.readUEV("chroma_bit_depth_cm_output_minus8"); | ||
this->cm_res_quant_bits = reader.readBits("cm_res_quant_bits", 2); | ||
this->cm_delta_flc_bits_minus1 = reader.readBits("cm_delta_flc_bits_minus1", 2); | ||
if (this->cm_octant_depth == 1) | ||
{ | ||
this->cm_adapt_threshold_u_delta = reader.readSEV("cm_adapt_threshold_u_delta"); | ||
this->cm_adapt_threshold_v_delta = reader.readSEV("cm_adapt_threshold_v_delta"); | ||
} | ||
|
||
const auto BitDepthCmInputY = 8 + this->luma_bit_depth_cm_input_minus8; | ||
const auto BitDepthCmOutputY = 8 + luma_bit_depth_cm_output_minus8; | ||
const auto CMResLSBits = | ||
std::max(0u, | ||
(10 + BitDepthCmInputY - BitDepthCmOutputY - this->cm_res_quant_bits - | ||
(this->cm_delta_flc_bits_minus1 + 1))); | ||
|
||
this->colourMappingOctants.parse(reader, | ||
this->cm_octant_depth, | ||
cm_y_part_num_log2, | ||
CMResLSBits, | ||
0, | ||
0, | ||
0, | ||
0, | ||
1 << this->cm_octant_depth); | ||
} | ||
|
||
} // namespace parser::hevc |
64 changes: 64 additions & 0 deletions
64
YUViewLib/src/parser/HEVC/Extensions/colour_mapping_table.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* This file is part of YUView - The YUV player with advanced analytics toolset | ||
* <https://github.com/IENT/YUView> | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "colour_mapping_octants.h" | ||
#include "parser/common/SubByteReaderLogging.h" | ||
|
||
namespace parser::hevc | ||
{ | ||
|
||
// F.7.3.2.3.5 General colour mapping table syntax | ||
class colour_mapping_table | ||
{ | ||
public: | ||
colour_mapping_table() {} | ||
|
||
void parse(reader::SubByteReaderLogging &reader); | ||
|
||
unsigned num_cm_ref_layers_minus1{}; | ||
vector<unsigned> cm_ref_layer_id; | ||
unsigned cm_octant_depth{}; | ||
unsigned cm_y_part_num_log2{}; | ||
unsigned luma_bit_depth_cm_input_minus8{}; | ||
unsigned chroma_bit_depth_cm_input_minus8{}; | ||
unsigned luma_bit_depth_cm_output_minus8{}; | ||
unsigned chroma_bit_depth_cm_output_minus8{}; | ||
unsigned cm_res_quant_bits{}; | ||
unsigned cm_delta_flc_bits_minus1{}; | ||
int cm_adapt_threshold_u_delta{}; | ||
int cm_adapt_threshold_v_delta{}; | ||
colour_mapping_octants colourMappingOctants{}; | ||
}; | ||
|
||
} // namespace parser::hevc |
Oops, something went wrong.