[x265] [PATCH 4 of 4] level: signal general_one_picture_only_constraint_flag correctly

Steve Borho steve at borho.org
Fri Jul 3 20:44:01 CEST 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1435949027 18000
#      Fri Jul 03 13:43:47 2015 -0500
# Node ID 1162fb0b99f82d32529f396e3afb6966cc38ec02
# Parent  be3daf3b4a61b048f43daab56f1476cebdcdd156
level: signal general_one_picture_only_constraint_flag correctly

and when general_one_picture_only_constraint_flag is set,
general_intra_constraint_flag should also be set, irrespective of keyframe
interval. Note that this flag can only be signaled correctly when the user
specifies the frame count in param.totalFrames as 1

diff -r be3daf3b4a61 -r 1162fb0b99f8 source/common/slice.h
--- a/source/common/slice.h	Fri Jul 03 12:52:24 2015 -0500
+++ b/source/common/slice.h	Fri Jul 03 13:43:47 2015 -0500
@@ -111,6 +111,7 @@
     bool     frameOnlyConstraintFlag;
     bool     profileCompatibilityFlag[32];
     bool     intraConstraintFlag;
+    bool     onePictureOnlyConstraintFlag;
     bool     lowerBitRateConstraintFlag;
     int      profileIdc;
     int      levelIdc;
diff -r be3daf3b4a61 -r 1162fb0b99f8 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Fri Jul 03 12:52:24 2015 -0500
+++ b/source/encoder/entropy.cpp	Fri Jul 03 13:43:47 2015 -0500
@@ -214,7 +214,7 @@
         WRITE_FLAG(csp == X265_CSP_I420 || csp == X265_CSP_I400,                         "general_max_420chroma_constraint_flag");
         WRITE_FLAG(csp == X265_CSP_I400,                                                 "general_max_monochrome_constraint_flag");
         WRITE_FLAG(ptl.intraConstraintFlag,        "general_intra_constraint_flag");
-        WRITE_FLAG(0,                              "general_one_picture_only_constraint_flag");
+        WRITE_FLAG(ptl.onePictureOnlyConstraintFlag,"general_one_picture_only_constraint_flag");
         WRITE_FLAG(ptl.lowerBitRateConstraintFlag, "general_lower_bit_rate_constraint_flag");
         WRITE_CODE(0 , 16, "XXX_reserved_zero_35bits[0..15]");
         WRITE_CODE(0 , 16, "XXX_reserved_zero_35bits[16..31]");
diff -r be3daf3b4a61 -r 1162fb0b99f8 source/encoder/level.cpp
--- a/source/encoder/level.cpp	Fri Jul 03 12:52:24 2015 -0500
+++ b/source/encoder/level.cpp	Fri Jul 03 13:43:47 2015 -0500
@@ -61,21 +61,33 @@
 /* determine minimum decoder level required to decode the described video */
 void determineLevel(const x265_param &param, VPS& vps)
 {
+    vps.ptl.onePictureOnlyConstraintFlag = param.totalFrames == 1;
+    vps.ptl.intraConstraintFlag = param.keyframeMax <= 1 || vps.ptl.onePictureOnlyConstraintFlag;
+    vps.ptl.bitDepthConstraint = param.internalBitDepth;
+    vps.ptl.chromaFormatConstraint = param.internalCsp;
+
+    /* TODO: figure out HighThroughput signaling, aka: HbrFactor in section A.4.2, only available
+     * for intra-only profiles (vps.ptl.intraConstraintFlag) */
+    vps.ptl.lowerBitRateConstraintFlag = true;
+
+    vps.maxTempSubLayers = param.bEnableTemporalSubLayers ? 2 : 1;
+    
     if (param.internalCsp == X265_CSP_I420 && param.internalBitDepth <= 10)
     {
         /* Probably an HEVC v1 profile, but must check to be sure */
         if (param.internalBitDepth <= 8)
         {
-            if (param.totalFrames == 1)
+            if (vps.ptl.onePictureOnlyConstraintFlag)
                 vps.ptl.profileIdc = Profile::MAINSTILLPICTURE;
-            else if (param.keyframeMax <= 1)
+            else if (vps.ptl.intraConstraintFlag)
                 vps.ptl.profileIdc = Profile::MAINREXT; /* Main Intra */
             else 
                 vps.ptl.profileIdc = Profile::MAIN;
         }
         else if (param.internalBitDepth <= 10)
         {
-            if (param.keyframeMax <= 1)
+            /* note there is no 10bit still picture profile */
+            if (vps.ptl.intraConstraintFlag)
                 vps.ptl.profileIdc = Profile::MAINREXT; /* Main10 Intra */
             else
                 vps.ptl.profileIdc = Profile::MAIN10;
@@ -88,7 +100,6 @@
 
     memset(vps.ptl.profileCompatibilityFlag, 0, sizeof(vps.ptl.profileCompatibilityFlag));
     vps.ptl.profileCompatibilityFlag[vps.ptl.profileIdc] = true;
-    vps.maxTempSubLayers = param.bEnableTemporalSubLayers ? 2 : 1;
     if (vps.ptl.profileIdc == Profile::MAIN10 && param.internalBitDepth == 8)
         vps.ptl.profileCompatibilityFlag[Profile::MAIN] = true;
     else if (vps.ptl.profileIdc == Profile::MAIN)
@@ -194,11 +205,6 @@
         break;
     }
 
-    vps.ptl.intraConstraintFlag = param.keyframeMax == 1;
-    vps.ptl.lowerBitRateConstraintFlag = true;
-    vps.ptl.bitDepthConstraint = param.internalBitDepth;
-    vps.ptl.chromaFormatConstraint = param.internalCsp;
-    
     static const char *profiles[] = { "None", "Main", "Main 10", "Main Still Picture", "RExt" };
     static const char *tiers[]    = { "Main", "High" };
 
@@ -210,7 +216,7 @@
     {
         if (vps.ptl.bitDepthConstraint > 12 && vps.ptl.intraConstraintFlag)
         {
-            if (param.totalFrames == 1)
+            if (vps.ptl.onePictureOnlyConstraintFlag)
             {
                 strcpy(profbuf, "Main 4:4:4 16 Still Picture");
                 bStillPicture = true;
@@ -218,6 +224,16 @@
             else
                 strcpy(profbuf, "Main 4:4:4 16");
         }
+        else if (param.internalCsp == X265_CSP_I420)
+        {
+            X265_CHECK(vps.ptl.intraConstraintFlag || vps.ptl.bitDepthConstraint > 10, "rext fail\n");
+            if (vps.ptl.bitDepthConstraint <= 8)
+                strcpy(profbuf, "Main");
+            else if (vps.ptl.bitDepthConstraint <= 10)
+                strcpy(profbuf, "Main 10");
+            else if (vps.ptl.bitDepthConstraint <= 12)
+                strcpy(profbuf, "Main 12");
+        }
         else if (param.internalCsp == X265_CSP_I422)
         {
             /* there is no Main 4:2:2 profile, so it must be signaled as Main10 4:2:2 */
@@ -230,21 +246,19 @@
         {
             if (vps.ptl.bitDepthConstraint <= 8)
             {
-                if (vps.ptl.intraConstraintFlag && param.totalFrames == 1)
+                if (vps.ptl.onePictureOnlyConstraintFlag)
                 {
                     strcpy(profbuf, "Main 4:4:4 Still Picture");
                     bStillPicture = true;
                 }
                 else
-                    strcpy(profbuf, "Main 4:4:4 8");
+                    strcpy(profbuf, "Main 4:4:4");
             }
             else if (vps.ptl.bitDepthConstraint <= 10)
                 strcpy(profbuf, "Main 4:4:4 10");
             else if (vps.ptl.bitDepthConstraint <= 12)
                 strcpy(profbuf, "Main 4:4:4 12");
         }
-        else if (vps.ptl.bitDepthConstraint <= 12)
-            strcpy(profbuf, "Main 12");
         else
             strcpy(profbuf, "Unknown");
 


More information about the x265-devel mailing list