[x265-commits] [x265] sao: cleanup, remove unnecessary rdoInit, no output change

Deepthi Nandakumar deepthi at multicorewareinc.com
Fri Jul 3 20:57:46 CEST 2015


details:   http://hg.videolan.org/x265/rev/1867f1703846
branches:  
changeset: 10758:1867f1703846
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Fri Jul 03 09:45:14 2015 +0530
description:
sao: cleanup, remove unnecessary rdoInit, no output change
Subject: [x265] param: expose param.totalFrames as param_parse option name 'total-frames'

details:   http://hg.videolan.org/x265/rev/e1dd87538258
branches:  
changeset: 10759:e1dd87538258
user:      Steve Borho <steve at borho.org>
date:      Fri Jul 03 12:46:06 2015 -0500
description:
param: expose param.totalFrames as param_parse option name 'total-frames'

This way API users can get the still picture profiles signaled correctly, if
they so desire
Subject: [x265] level: detect still picture profile based on just -f 1, other fixes

details:   http://hg.videolan.org/x265/rev/54a840194c3b
branches:  
changeset: 10760:54a840194c3b
user:      Steve Borho <steve at borho.org>
date:      Fri Jul 03 12:50:06 2015 -0500
description:
level: detect still picture profile based on just -f 1, other fixes

If a single frame encode is specified, then we do not need to check whether
the keyframe interval has been set to 0 or 1, we know the single frame will be
an IDR.

Also, fixes to detect Main10-Intra correctly and fixes for handling some very
improbable edge cases (greater than 12-bits)
Subject: [x265] docs: further improve profile determination documentation

details:   http://hg.videolan.org/x265/rev/be3daf3b4a61
branches:  
changeset: 10761:be3daf3b4a61
user:      Steve Borho <steve at borho.org>
date:      Fri Jul 03 12:52:24 2015 -0500
description:
docs: further improve profile determination documentation
Subject: [x265] level: signal general_one_picture_only_constraint_flag correctly

details:   http://hg.videolan.org/x265/rev/1162fb0b99f8
branches:  
changeset: 10762:1162fb0b99f8
user:      Steve Borho <steve at borho.org>
date:      Fri Jul 03 13:43:47 2015 -0500
description:
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

diffstat:

 doc/reST/cli.rst           |  89 +++++++++++++++++++++++++++++++--------------
 source/common/param.cpp    |   1 +
 source/common/slice.h      |   1 +
 source/encoder/entropy.cpp |   2 +-
 source/encoder/level.cpp   |  78 ++++++++++++++++++++++++---------------
 source/encoder/sao.cpp     |  30 +++++---------
 source/encoder/sao.h       |   1 -
 7 files changed, 122 insertions(+), 80 deletions(-)

diffs (truncated from 342 to 300 lines):

diff -r de61709ccf56 -r 1162fb0b99f8 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Thu Jul 02 16:49:08 2015 -0700
+++ b/doc/reST/cli.rst	Fri Jul 03 13:43:47 2015 -0500
@@ -354,6 +354,13 @@ frame counts) are only applicable to the
 
 	**CLI ONLY**
 
+.. option:: --total-frames <integer>
+
+	The number of frames intended to be encoded.  It may be left
+	unspecified, but when it is specified rate control can make use of
+	this information. It is also used to determine if an encode is
+	actually a stillpicture profile encode (single frame)
+
 .. option:: --dither
 
 	Enable high quality downscaling. Dithering is based on the diffusion
@@ -445,22 +452,45 @@ Profile, Level, Tier
 	profile.  May abort the encode if the specified profile is
 	impossible to be supported by the compile options chosen for the
 	encoder (a high bit depth encoder will be unable to output
-	bitstreams compliant with Main or Mains-Still-Picture).
+	bitstreams compliant with Main or MainStillPicture).
 
-	Note: Main12 presets are extremely unstable, do not use them yet.
-	      And Main16 is not supported at all.
+	The first version of the HEVC specification only described Main,
+	Main10, and MainStillPicture. All other profiles were added by the
+	Range Extensions additions in HEVC version two.
 
-	API users must use x265_param_apply_profile() after configuring
+	8bit profiles::
+
+	main, main-intra, mainstillpicture (or msp for short)
+	main444-8 main444-intra main444-stillpicture
+
+	10bit profiles::
+
+	main10, main10-intra
+	main422-10, main422-10-intra
+	main444-10, main444-10-intra
+
+	12bit profiles::
+
+	main12, main12-intra
+	main422-12, main422-12-intra
+	main444-12, main444-12-intra
+
+	16bit profiles::
+
+	main444-16-intra main444-16-stillpicture
+
+	**CLI ONLY**
+
+	API users must call x265_param_apply_profile() after configuring
 	their param structure. Any changes made to the param structure after
 	this call might make the encode non-compliant.
 
-	**Values:** main, main10, mainstillpicture, msp
-				main-intra main10-intra main444-8 main444-intra main444-stillpicture
-				main422-10 main422-10-intra main444-10 main444-10-intra main12 main12-intra
-				main422-12 main422-12-intra main444-12 main444-12-intra
-				main444-16-intra main444-16-stillpicture
+.. note::
 
-	**CLI ONLY**
+	All 12bit presets are extremely unstable, do not use them yet.
+	16bit is not supported at all, but those profiles are included
+	because it is possible for libx265 to make bitstreams compatible
+	with them.
 
 .. option:: --level-idc <integer|float>
 
@@ -536,26 +566,27 @@ Profile, Level, Tier
 	parameters to meet those requirements but it will never raise
 	them. It may enable VBV constraints on a CRF encode.
 
-	Also note that x265 determines the decoder requirement level in
-	three steps.  First, the user configures an x265_param structure
-	with their suggested encoder options and then optionally calls
-	x265_param_apply_profile() to enforce a specific profile (main,
-	main10, etc). Second, an encoder is created from this x265_param
-	instance and the :option:`--level-idc` and :option:`--high-tier`
-	parameters are used to reduce bitrate or other features in order to
-	enforce the target level. Finally, the encoder re-examines the final
-	set of parameters and detects the actual minimum decoder requirement
-	level and this is what is signaled in the bitstream headers. The
-	detected decoder level will only use High tier if the user specified
-	a High tier level.
+	Also note that x265 determines the decoder requirement profile and
+	level in three steps.  First, the user configures an x265_param
+	structure with their suggested encoder options and then optionally
+	calls x265_param_apply_profile() to enforce a specific profile
+	(main, main10, etc). Second, an encoder is created from this
+	x265_param instance and the :option:`--level-idc` and
+	:option:`--high-tier` parameters are used to reduce bitrate or other
+	features in order to enforce the target level. Finally, the encoder
+	re-examines the final set of parameters and detects the actual
+	minimum decoder requirement level and this is what is signaled in
+	the bitstream headers. The detected decoder level will only use High
+	tier if the user specified a High tier level.
 
-	Lastly, x265 will signal an all-intra encode using the appropriate
-	range extension intra profile, unless it knows that the encode will
-	be a single frame in which case it will signal a Still Picture
-	profile if one is appropriate. However, it makes this determination
-	based on param.totalFrames but this parameter is not always set.
-	Particularly when the CLI is used in stdin streaming mode or when
-	used by third-party applications.
+	The signaled profile will be determined by the encoder's internal
+	bitdepth and input color space. If :option:`--keyint` is 0 or 1,
+	then an intra variant of the profile will be signaled.
+
+	If :option:`--total-frames` is 1, then a stillpicture variant will
+	be signaled, but this parameter is not always set by applications,
+	particularly not when the CLI uses stdin streaming or when libx265
+	is used by third-party applications.
 
 
 Mode decision / Analysis
diff -r de61709ccf56 -r 1162fb0b99f8 source/common/param.cpp
--- a/source/common/param.cpp	Thu Jul 02 16:49:08 2015 -0700
+++ b/source/common/param.cpp	Fri Jul 03 13:43:47 2015 -0500
@@ -582,6 +582,7 @@ int x265_param_parse(x265_param* p, cons
         }
     }
     OPT("cu-stats") p->bLogCuStats = atobool(value);
+    OPT("total-frames") p->totalFrames = atoi(value);
     OPT("annexb") p->bAnnexB = atobool(value);
     OPT("repeat-headers") p->bRepeatHeaders = atobool(value);
     OPT("wpp") p->bEnableWavefront = atobool(value);
diff -r de61709ccf56 -r 1162fb0b99f8 source/common/slice.h
--- a/source/common/slice.h	Thu Jul 02 16:49:08 2015 -0700
+++ b/source/common/slice.h	Fri Jul 03 13:43:47 2015 -0500
@@ -111,6 +111,7 @@ struct ProfileTierLevel
     bool     frameOnlyConstraintFlag;
     bool     profileCompatibilityFlag[32];
     bool     intraConstraintFlag;
+    bool     onePictureOnlyConstraintFlag;
     bool     lowerBitRateConstraintFlag;
     int      profileIdc;
     int      levelIdc;
diff -r de61709ccf56 -r 1162fb0b99f8 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Thu Jul 02 16:49:08 2015 -0700
+++ b/source/encoder/entropy.cpp	Fri Jul 03 13:43:47 2015 -0500
@@ -214,7 +214,7 @@ void Entropy::codeProfileTier(const Prof
         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 de61709ccf56 -r 1162fb0b99f8 source/encoder/level.cpp
--- a/source/encoder/level.cpp	Thu Jul 02 16:49:08 2015 -0700
+++ b/source/encoder/level.cpp	Fri Jul 03 13:43:47 2015 -0500
@@ -61,23 +61,37 @@ LevelSpec levels[] =
 /* 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)
     {
-        if (param.internalBitDepth == 8)
+        /* Probably an HEVC v1 profile, but must check to be sure */
+        if (param.internalBitDepth <= 8)
         {
-            if (param.keyframeMax <= 1)
-            {
-                if (param.totalFrames == 1)
-                    vps.ptl.profileIdc = Profile::MAINSTILLPICTURE;
-                else
-                    vps.ptl.profileIdc = Profile::MAINREXT; /* Main Intra */
-            }
+            if (vps.ptl.onePictureOnlyConstraintFlag)
+                vps.ptl.profileIdc = Profile::MAINSTILLPICTURE;
+            else if (vps.ptl.intraConstraintFlag)
+                vps.ptl.profileIdc = Profile::MAINREXT; /* Main Intra */
             else 
                 vps.ptl.profileIdc = Profile::MAIN;
         }
-        else if (param.internalBitDepth == 10)
-            vps.ptl.profileIdc = Profile::MAIN10;
+        else if (param.internalBitDepth <= 10)
+        {
+            /* 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;
+        }
     }
     else
         vps.ptl.profileIdc = Profile::MAINREXT;
@@ -191,11 +205,6 @@ void determineLevel(const x265_param &pa
         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" };
 
@@ -205,8 +214,29 @@ void determineLevel(const x265_param &pa
     bool bStillPicture = false;
     if (vps.ptl.profileIdc == Profile::MAINREXT)
     {
-        if (param.internalCsp == X265_CSP_I422)
+        if (vps.ptl.bitDepthConstraint > 12 && vps.ptl.intraConstraintFlag)
         {
+            if (vps.ptl.onePictureOnlyConstraintFlag)
+            {
+                strcpy(profbuf, "Main 4:4:4 16 Still Picture");
+                bStillPicture = true;
+            }
+            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 */
             if (param.internalBitDepth <= 10)
                 strcpy(profbuf, "Main 4:2:2 10");
             else if (vps.ptl.bitDepthConstraint <= 12)
@@ -216,31 +246,19 @@ void determineLevel(const x265_param &pa
         {
             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.intraConstraintFlag && param.totalFrames == 1)
-                {
-                    strcpy(profbuf, "Main 4:4:4 16 Still Picture");
-                    bStillPicture = true;
-                }
-                else
-                    strcpy(profbuf, "Main 4:4:4 16");
-            }
         }
-        else if (vps.ptl.bitDepthConstraint <= 12)
-            strcpy(profbuf, "Main 12");
         else
             strcpy(profbuf, "Unknown");
 
diff -r de61709ccf56 -r 1162fb0b99f8 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Thu Jul 02 16:49:08 2015 -0700
+++ b/source/encoder/sao.cpp	Fri Jul 03 13:43:47 2015 -0500
@@ -223,14 +223,19 @@ void SAO::startSlice(Frame* frame, Entro
         frame->m_encData->m_saoParam = saoParam;
     }
 
-    rdoSaoUnitRowInit(saoParam);
+    saoParam->bSaoFlag[0] = true;
+    saoParam->bSaoFlag[1] = true;
 
-    // NOTE: Disable SAO automatic turn-off when frame parallelism is
-    // enabled for output exact independent of frame thread count
-    if (m_param->frameNumThreads > 1)
+    m_numNoSao[0] = 0; // Luma
+    m_numNoSao[1] = 0; // Chroma
+
+    // NOTE: Allow SAO automatic turn-off only when frame parallelism is disabled.


More information about the x265-commits mailing list