From 416020d46e7a6f8e5e5e5197247bc708672e221e Mon Sep 17 00:00:00 2001
From: Frank Bossen <fbossen@gmail.com>
Date: Sat, 1 Aug 2020 07:35:08 -0400
Subject: [PATCH] Fix profile handling

In encoder, when automatically selecting profile, choose a still
picture profile when the level is 15.5 and a single picture is to
be encoded.
In decoder, don't check for single picture constraint when looking
up profiles.
---
 source/App/EncoderApp/EncAppCfg.cpp       | 19 +++++++++++++++++--
 source/Lib/CommonLib/ProfileLevelTier.cpp |  6 ++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp
index 13c8b4cbb..70f217b71 100644
--- a/source/App/EncoderApp/EncAppCfg.cpp
+++ b/source/App/EncoderApp/EncAppCfg.cpp
@@ -2575,7 +2575,14 @@ int EncAppCfg::xAutoDetermineProfile()
   case ChromaFormat::CHROMA_420:
     if (maxBitDepth <= 10)
     {
-      m_profile = m_maxLayers > 1 ? Profile::MULTILAYER_MAIN_10 : Profile::MAIN_10;
+      if (m_level == Level::LEVEL15_5 && m_framesToBeEncoded == 1)
+      {
+        m_profile = m_maxLayers > 1 ? Profile::MULTILAYER_MAIN_10_STILL_PICTURE : Profile::MAIN_10_STILL_PICTURE;
+      }
+      else
+      {
+        m_profile = m_maxLayers > 1 ? Profile::MULTILAYER_MAIN_10 : Profile::MAIN_10;
+      }
     }
     break;
 
@@ -2583,7 +2590,15 @@ int EncAppCfg::xAutoDetermineProfile()
   case ChromaFormat::CHROMA_444:
     if (maxBitDepth <= 10)
     {
-      m_profile = m_maxLayers > 1 ? Profile::MULTILAYER_MAIN_10_444 : Profile::MAIN_10_444;
+      if (m_level == Level::LEVEL15_5 && m_framesToBeEncoded == 1)
+      {
+        m_profile =
+          m_maxLayers > 1 ? Profile::MULTILAYER_MAIN_10_444_STILL_PICTURE : Profile::MAIN_10_444_STILL_PICTURE;
+      }
+      else
+      {
+        m_profile = m_maxLayers > 1 ? Profile::MULTILAYER_MAIN_10_444 : Profile::MAIN_10_444;
+      }
     }
     break;
 
diff --git a/source/Lib/CommonLib/ProfileLevelTier.cpp b/source/Lib/CommonLib/ProfileLevelTier.cpp
index c759ff228..d224cbe79 100644
--- a/source/Lib/CommonLib/ProfileLevelTier.cpp
+++ b/source/Lib/CommonLib/ProfileLevelTier.cpp
@@ -145,10 +145,16 @@ ProfileLevelTierFeatures::extractPTLInformation(const SPS &sps)
   m_tier = spsPtl.getTierFlag();
 
   // Identify the profile from the profile Idc, and possibly other constraints.
+#if !JVET_S_PROFILES
   bool onePictureOnlyConstraintFlag=spsPtl.getConstraintInfo()->getOnePictureOnlyConstraintFlag();
+#endif
   for(int32_t i=0; validProfiles[i].profile != Profile::NONE; i++)
   {
+#if JVET_S_PROFILES
+    if (spsPtl.getProfileIdc() == validProfiles[i].profile)
+#else
     if (spsPtl.getProfileIdc() == validProfiles[i].profile && !(validProfiles[i].onePictureOnlyFlagMustBe1 && !onePictureOnlyConstraintFlag))
+#endif
     {
       m_pProfile = &(validProfiles[i]);
       break;
-- 
GitLab