Skip to content

Commit

Permalink
Parsing of my test stream now works!
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Feb 25, 2024
1 parent f3588e4 commit 97a4af5
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 23 deletions.
2 changes: 2 additions & 0 deletions YUViewLib/src/parser/HEVC/Extensions/dpb_size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void dpb_size::parse(SubByteReaderLogging & reader,
if (j > 0 && this->sub_layer_flag_info_present_flag[i])
this->sub_layer_dpb_info_present_flag[i][j] =
reader.readFlag(formatArray("sub_layer_dpb_info_present_flag", i, j));
if (j == 0)
this->sub_layer_dpb_info_present_flag[i][j] = true;
if (this->sub_layer_dpb_info_present_flag[i][j])
{
for (unsigned k = 0; k < NumLayersInIdList.at(currLsIdx); k++)
Expand Down
4 changes: 2 additions & 2 deletions YUViewLib/src/parser/HEVC/Extensions/rep_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void rep_format::parse(SubByteReaderLogging &reader)
chroma_format_vps_idc = reader.readBits("chroma_format_vps_idc", 2);
if (this->chroma_format_vps_idc == 3)
this->separate_colour_plane_vps_flag = reader.readFlag("separate_colour_plane_vps_flag");
this->bit_depth_vps_luma_minus8 = reader.readBits("bit_depth_vps_luma_minus8", 2);
this->bit_depth_vps_chroma_minus8 = reader.readBits("bit_depth_vps_chroma_minus8", 2);
this->bit_depth_vps_luma_minus8 = reader.readBits("bit_depth_vps_luma_minus8", 4);
this->bit_depth_vps_chroma_minus8 = reader.readBits("bit_depth_vps_chroma_minus8", 4);
}
this->conformance_window_vps_flag = reader.readFlag("conformance_window_vps_flag");
if (this->conformance_window_vps_flag)
Expand Down
25 changes: 16 additions & 9 deletions YUViewLib/src/parser/HEVC/Extensions/vps_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,20 @@ namespace parser::hevc

using namespace reader;

void vps_extension::parse(SubByteReaderLogging &reader,
const unsigned vps_max_layers_minus1,
const bool vps_base_layer_internal_flag,
const unsigned vps_max_sub_layers_minus1,
const unsigned vps_num_layer_sets_minus1,
const unsigned vps_num_hrd_parameters)
void vps_extension::parse(SubByteReaderLogging & reader,
const unsigned vps_max_layers_minus1,
const bool vps_base_layer_internal_flag,
const unsigned vps_max_sub_layers_minus1,
const unsigned vps_num_layer_sets_minus1,
const unsigned vps_num_hrd_parameters,
const umap_1d<unsigned> &NumLayersInIdListVPS,
const umap_2d<unsigned> &LayerSetLayerIdListVPS)
{
SubByteReaderLoggingSubLevel subLevel(reader, "vps_extension()");

this->NumLayersInIdList = NumLayersInIdListVPS;
this->LayerSetLayerIdList = LayerSetLayerIdListVPS;

if (vps_max_layers_minus1 > 0 && vps_base_layer_internal_flag)
profileTierLevel.parse(reader, false, vps_max_sub_layers_minus1);
this->splitting_flag = reader.readFlag("splitting_flag");
Expand Down Expand Up @@ -108,8 +113,8 @@ void vps_extension::parse(SubByteReaderLogging &reader,

if (this->NumIndependentLayers > 1)
this->num_add_layer_sets = reader.readUEV("num_add_layer_sets");
this->NumLayerSets = vps_num_layer_sets_minus1 + 1 + num_add_layer_sets;

this->NumLayersInIdList[0] = 1;
for (unsigned i = 0; i < this->num_add_layer_sets; i++)
{
for (unsigned j = 1; j < this->NumIndependentLayers; j++)
Expand All @@ -127,6 +132,9 @@ void vps_extension::parse(SubByteReaderLogging &reader,
for (unsigned i = 0; i <= this->MaxLayersMinus1; i++)
sub_layers_vps_max_minus1.push_back(
reader.readBits(formatArray("sub_layers_vps_max_minus1", i), 3));
else
for (unsigned i = 0; i <= this->MaxLayersMinus1; i++)
sub_layers_vps_max_minus1.push_back(vps_max_sub_layers_minus1);
this->calcualteValuesF10();

this->max_tid_ref_present_flag = reader.readFlag("max_tid_ref_present_flag");
Expand All @@ -150,7 +158,6 @@ void vps_extension::parse(SubByteReaderLogging &reader,
reader, this->vps_profile_present_flag[i], vps_max_sub_layers_minus1);
}

this->NumLayerSets = vps_num_layer_sets_minus1 + 1 + num_add_layer_sets;
if (this->NumLayerSets > 1)
{
this->num_add_olss = reader.readUEV("num_add_olss");
Expand All @@ -171,7 +178,7 @@ void vps_extension::parse(SubByteReaderLogging &reader,

if (i > vps_num_layer_sets_minus1 || this->defaultOutputLayerIdc == 2)
{
for (unsigned j = 0; j < this->NumLayersInIdList[this->OlsIdxToLsIdx[i]]; j++)
for (unsigned j = 0; j < NumLayersInIdList[this->OlsIdxToLsIdx[i]]; j++)
{
this->output_layer_flag[i][j] = reader.readFlag(formatArray("output_layer_flag", i, j));
this->OutputLayerFlag[i][j] = this->output_layer_flag[i][j];
Expand Down
4 changes: 3 additions & 1 deletion YUViewLib/src/parser/HEVC/Extensions/vps_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ class vps_extension
const bool vps_base_layer_internal_flag,
const unsigned vps_max_sub_layers_minus1,
const unsigned vps_num_layer_sets_minus1,
const unsigned vps_num_hrd_parameters);
const unsigned vps_num_hrd_parameters,
const umap_1d<unsigned> & NumLayersInIdListVPS,
const umap_2d<unsigned> & LayerSetLayerIdListVPS);

profile_tier_level profileTierLevel;
bool splitting_flag{};
Expand Down
29 changes: 25 additions & 4 deletions YUViewLib/src/parser/HEVC/video_parameter_set_rbsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ void video_parameter_set_rbsp::parse(SubByteReaderLogging &reader)
}

this->vps_max_layer_id = reader.readBits("vps_max_layer_id", 6);

this->vps_num_layer_sets_minus1 =
reader.readUEV("vps_num_layer_sets_minus1", Options().withCheckRange({0, 1023}));

for (unsigned int i = 1; i <= this->vps_num_layer_sets_minus1; i++)
for (unsigned int j = 0; j <= this->vps_max_layer_id; j++)
this->layer_id_included_flag->push_back(
reader.readFlag(formatArray("layer_id_included_flag", i)));
this->layer_id_included_flag[i][j] =
reader.readFlag(formatArray("layer_id_included_flag", i, j));

this->calculateValues7_3();

this->vps_timing_info_present_flag = reader.readFlag("vps_timing_info_present_flag");
if (this->vps_timing_info_present_flag)
Expand Down Expand Up @@ -118,7 +121,9 @@ void video_parameter_set_rbsp::parse(SubByteReaderLogging &reader)
this->vps_base_layer_internal_flag,
this->vps_max_sub_layers_minus1,
this->vps_num_layer_sets_minus1,
this->vps_num_hrd_parameters);
this->vps_num_hrd_parameters,
this->NumLayersInIdList,
this->LayerSetLayerIdList);

this->vps_extension2_flag = reader.readFlag("vps_extension2_flag");
if (this->vps_extension2_flag)
Expand All @@ -131,4 +136,20 @@ void video_parameter_set_rbsp::parse(SubByteReaderLogging &reader)
rbspTrailingBits.parse(reader);
}

} // namespace parser::hevc
void video_parameter_set_rbsp::calculateValues7_3()
{
this->NumLayersInIdList[0] = 1;
this->LayerSetLayerIdList[0][0] = 0;

for (unsigned i = 1; i <= this->vps_num_layer_sets_minus1; i++)
{
auto n = 0u;
for (unsigned m = 0; m <= this->vps_max_layer_id; m++)
if (this->layer_id_included_flag.count(i) == 1 &&
this->layer_id_included_flag.at(i).count(m) == 1 && this->layer_id_included_flag[i][m])
this->LayerSetLayerIdList[i][n++] = m;
this->NumLayersInIdList[i] = n;
}
}

} // namespace parser::hevc
18 changes: 11 additions & 7 deletions YUViewLib/src/parser/HEVC/video_parameter_set_rbsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ class video_parameter_set_rbsp : public NalRBSP

profile_tier_level profileTierLevel;

bool vps_sub_layer_ordering_info_present_flag{};
unsigned vps_max_dec_pic_buffering_minus1[7]{};
unsigned vps_max_num_reorder_pics[7]{};
unsigned vps_max_latency_increase_plus1[7]{};
unsigned vps_max_layer_id{};
unsigned vps_num_layer_sets_minus1{};
vector<bool> layer_id_included_flag[7]{};
bool vps_sub_layer_ordering_info_present_flag{};
unsigned vps_max_dec_pic_buffering_minus1[7]{};
unsigned vps_max_num_reorder_pics[7]{};
unsigned vps_max_latency_increase_plus1[7]{};
unsigned vps_max_layer_id{};
unsigned vps_num_layer_sets_minus1{};
umap_2d<bool> layer_id_included_flag{};

void calculateValues7_3();
umap_2d<unsigned> LayerSetLayerIdList;
umap_1d<unsigned> NumLayersInIdList;

bool vps_timing_info_present_flag{};
unsigned vps_num_units_in_tick{};
Expand Down

0 comments on commit 97a4af5

Please sign in to comment.