Skip to content

Commit 78f5c23

Browse files
committed
evc: decode profile and NAL unit types when dumping
1 parent c1400f5 commit 78f5c23

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

libheif/codecs/evc_boxes.cc

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ std::string Box_evcC::dump(Indent& indent) const
8686
sstr << Box::dump(indent);
8787
// TODO: decode more of this
8888
sstr << indent << "configurationVersion: " << ((int)m_configuration.configurationVersion) << "\n";
89-
sstr << indent << "profile_idc: " << ((int)m_configuration.profile_idc) << "\n";
89+
sstr << indent << "profile_idc: " << ((int)m_configuration.profile_idc)
90+
<< " (" << get_profile_as_text() << ")" << "\n";
9091
sstr << indent << "level_idc: " << ((int)m_configuration.level_idc) << "\n";
9192
sstr << indent << "toolset_idc_h: " << m_configuration.toolset_idc_h << "\n";
9293
sstr << indent << "toolset_idc_l: " << m_configuration.toolset_idc_l << "\n";
@@ -103,7 +104,8 @@ std::string Box_evcC::dump(Indent& indent) const
103104

104105
indent++;
105106
sstr << indent << "array_completeness: " << (array.array_completeness ? "true" : "false") << "\n"
106-
<< indent << "NAL_unit_type: " << ((int) array.NAL_unit_type) << "\n";
107+
<< indent << "NAL_unit_type: " << ((int) array.NAL_unit_type) << " ("
108+
<< get_NAL_unit_type_as_text(array.NAL_unit_type) << ")" << "\n";
107109

108110
for (const auto& unit : array.nal_units) {
109111
sstr << indent;
@@ -119,6 +121,23 @@ std::string Box_evcC::dump(Indent& indent) const
119121
return sstr.str();
120122
}
121123

124+
std::string Box_evcC::get_profile_as_text() const
125+
{
126+
switch (m_configuration.profile_idc)
127+
{
128+
case 0:
129+
return "Baseline";
130+
case 1:
131+
return "Main";
132+
case 2:
133+
return "Baseline Still";
134+
case 3:
135+
return "Main Still";
136+
default:
137+
return std::string("Unknown");
138+
}
139+
}
140+
122141
std::string Box_evcC::get_chroma_format_as_text() const
123142
{
124143
switch (m_configuration.chroma_format_idc)
@@ -136,6 +155,29 @@ std::string Box_evcC::get_chroma_format_as_text() const
136155
}
137156
}
138157

158+
std::string Box_evcC::get_NAL_unit_type_as_text(uint8_t nal_unit_type) const
159+
{
160+
switch (nal_unit_type)
161+
{
162+
case 0:
163+
return "NONIDR_NUT";
164+
case 1:
165+
return "IDR_NUT";
166+
case 24:
167+
return "SPS_NUT";
168+
case 25:
169+
return "PPS_NUT";
170+
case 26:
171+
return "APS_NUT";
172+
case 27:
173+
return "FD_NUT";
174+
case 28:
175+
return "SEI_NUT";
176+
default:
177+
return std::string("Unknown");
178+
}
179+
}
180+
139181
Error Box_evcC::write(StreamWriter& writer) const
140182
{
141183
size_t box_start = reserve_box_header_space(writer);

libheif/codecs/evc_boxes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ class Box_evcC : public Box {
8282

8383
std::vector<NalArray> m_nal_array;
8484

85+
std::string get_profile_as_text() const;
8586
std::string get_chroma_format_as_text() const;
87+
std::string get_NAL_unit_type_as_text(uint8_t nal_unit_type) const;
8688
};
8789

8890
#endif

tests/evc_box.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
TEST_CASE("evcC") {
3535
std::vector<uint8_t> byteArray{
3636
0x00, 0x00, 0x00, 0x3d, 0x65, 0x76, 0x63, 0x43,
37-
0x01, 0x00, 0xd7, 0x00, 0x00, 0x00, 0x00, 0x00,
37+
0x01, 0x02, 0xd7, 0x00, 0x00, 0x00, 0x00, 0x00,
3838
0x00, 0x00, 0x00, 0x52, 0x01, 0x40, 0x00, 0xf0,
3939
0x03, 0x02, 0x98, 0x00, 0x01, 0x00, 0x15, 0x32,
4040
0x00, 0x80, 0x6b, 0x80, 0x00, 0x00, 0x00, 0x00,
@@ -56,7 +56,7 @@ TEST_CASE("evcC") {
5656
std::shared_ptr<Box_evcC> evcC = std::dynamic_pointer_cast<Box_evcC>(box);
5757
Box_evcC::configuration configuration = evcC->get_configuration();
5858
REQUIRE(configuration.configurationVersion == 1);
59-
REQUIRE(configuration.profile_idc == 0);
59+
REQUIRE(configuration.profile_idc == 2);
6060
REQUIRE(configuration.level_idc == 215);
6161
REQUIRE(configuration.toolset_idc_h == 0);
6262
REQUIRE(configuration.toolset_idc_l == 0);
@@ -71,7 +71,7 @@ TEST_CASE("evcC") {
7171
REQUIRE(dumpResult == "Box: evcC -----\n"
7272
"size: 61 (header size: 8)\n"
7373
"configurationVersion: 1\n"
74-
"profile_idc: 0\n"
74+
"profile_idc: 2 (Baseline Still)\n"
7575
"level_idc: 215\n"
7676
"toolset_idc_h: 0\n"
7777
"toolset_idc_l: 0\n"
@@ -83,11 +83,11 @@ TEST_CASE("evcC") {
8383
"length_size: 4\n"
8484
"<array>\n"
8585
"| array_completeness: true\n"
86-
"| NAL_unit_type: 24\n"
86+
"| NAL_unit_type: 24 (SPS_NUT)\n"
8787
"| 32 00 80 6b 80 00 00 00 00 00 00 00 20 0a 08 0f 16 c0 00 54 00 \n"
8888
"<array>\n"
8989
"| array_completeness: true\n"
90-
"| NAL_unit_type: 25\n"
90+
"| NAL_unit_type: 25 (PPS_NUT)\n"
9191
"| 34 00 fb 00 \n");
9292

9393
StreamWriter writer;

0 commit comments

Comments
 (0)