Skip to content

Truly independent web browser

LibMediaCodecs+Tests: Resolve HEVC Main Still Picture to Main

Zaggy1024b6cd2337c1cd
diff --git a/Libraries/LibMediaCodecs/Codecs/H265.cpp b/Libraries/LibMediaCodecs/Codecs/H265.cpp
index a5211ae7f38..5da737e9a6d 100644
--- a/Libraries/LibMediaCodecs/Codecs/H265.cpp
+++ b/Libraries/LibMediaCodecs/Codecs/H265.cpp
@@ -596,13 +596,16 @@ Optional<H265::Profile> H265::Parameters::profile() const
// are the most constrained profiles a record was captured for, so a claim to either settles the answer.
static constexpr u32 MAIN_COMPATIBILITY_FLAG = 1u << 1;
static constexpr u32 MAIN_10_COMPATIBILITY_FLAG = 1u << 2;
- if ((profile_compatibility_flags & MAIN_COMPATIBILITY_FLAG) != 0)
+ // ITU-T H.265 (07/2024), A.3.2: Main decoders also decode streams that conform to the Main Still Picture profile.
+ static constexpr u32 MAIN_STILL_PICTURE_COMPATIBILITY_FLAG = 1u << 3;
+ if ((profile_compatibility_flags & (MAIN_COMPATIBILITY_FLAG | MAIN_STILL_PICTURE_COMPATIBILITY_FLAG)) != 0)
return Profile::Main;
if ((profile_compatibility_flags & MAIN_10_COMPATIBILITY_FLAG) != 0)
return Profile::Main10;
switch (profile_idc) {
case 1:
+ case 3:
return Profile::Main;
case 2:
return Profile::Main10;
diff --git a/Tests/LibMedia/TestCodecConfigurations.cpp b/Tests/LibMedia/TestCodecConfigurations.cpp
index 4bf075b5bba..b6a8f655002 100644
--- a/Tests/LibMedia/TestCodecConfigurations.cpp
+++ b/Tests/LibMedia/TestCodecConfigurations.cpp
@@ -874,11 +874,14 @@ TEST_CASE(h265_profiles_cover_the_ones_that_only_constrain_others)
expect_claimed_profile(2, { 0x90, 0, 0, 0, 0, 0 }, (1u << 1) | (1u << 2), Profile::Main);
// Naming Main 10 without claiming Main leaves it at Main 10.
expect_claimed_profile(2, { 0x90, 0, 0, 0, 0, 0 }, 1u << 2, Profile::Main10);
+ // Main decoders decode Main Still Picture streams, whether they name the profile or only claim it.
+ expect_claimed_profile(3, { 0x90, 0, 0, 0, 0, 0 }, 0, Profile::Main);
+ expect_claimed_profile(4, { 0x99, 0x88, 0, 0, 0, 0 }, 1u << 3, Profile::Main);
// A profile space other than zero names a different set of profiles entirely.
EXPECT(!profile_of(1, 1, { 0x90, 0, 0, 0, 0, 0 }).has_value());
// Profiles no record was captured for are left unanswerable.
- for (u8 profile_idc : { 0, 3, 5, 9, 11 })
+ for (u8 profile_idc : { 0, 5, 9, 11 })
EXPECT(!profile_of(0, profile_idc, { 0x90, 0, 0, 0, 0, 0 }).has_value());
// Monochrome and bit depths beyond 12 have no record to answer with.
EXPECT(!profile_of(0, 4, { 0x9e, 0x40, 0, 0, 0, 0 }).has_value());