[x265] [PATCH] api: rename SAO options and params for clarity

Steve Borho steve at borho.org
Thu Sep 25 19:04:29 CEST 2014


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1411664659 18000
#      Thu Sep 25 12:04:19 2014 -0500
# Node ID bef05615e5a427a0471e2ce926fe0fa6721d632d
# Parent  7dccbbed034970de161b361cd6e17ed4efca7226
api: rename SAO options and params for clarity

These two options were taken as-is from the original HM code and the HM itself
has renamed them recently because of the use of "LCU" which is no longer used
in the source code (the acronym CTU is preferred for the top-level coding
units)

old: --sao-lcu-opt=0|1        param->saoLcuBasedOptimization
new: --[no-]sao-frame         param->bSaoFrame

old: --sao-lcu-bounds=0|1     param->saoLcuBoundary
new: --[no-]sao-non-deblock   param->bSaoNonDeblocked

diff -r 7dccbbed0349 -r bef05615e5a4 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Wed Sep 24 18:26:45 2014 -0500
+++ b/doc/reST/cli.rst	Thu Sep 25 12:04:19 2014 -0500
@@ -947,20 +947,19 @@
 
 	Toggle Sample Adaptive Offset loop filter, default enabled
 
-.. option:: --sao-lcu-bounds <0|1>
+.. option:: --sao-non-deblock, --no-sao-non-deblock
 
-	How to handle depencency with deblocking filter
+	How to handle depencency between SAO and deblocking filter.
+	When enabled, non-deblocked pixels are used for SAO analysis. When
+	disabled, SAO analysis skips the right/bottom boundary areas.
+	Default: disabled
 
-	0. right/bottom boundary areas skipped **(default)**
-	1. non-deblocked pixels are used
+.. option:: --sao-frame, --no-sao-frame
 
-.. option:: --sao-lcu-opt <0|1>
+	If enabled, SAO performs frame level optimization. This option
+	severly limits frame parallelism and so can have a large negative
+	effect on performance. Default: disabled
 
-	Frame level or block level optimization
-
-	0. SAO picture-based optimization (prevents frame parallelism,
-	   effectively causes :option:`--frame-threads` 1)
-	1. SAO LCU-based optimization **(default)**
 
 VUI (Video Usability Information) options
 =========================================
diff -r 7dccbbed0349 -r bef05615e5a4 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Wed Sep 24 18:26:45 2014 -0500
+++ b/source/CMakeLists.txt	Thu Sep 25 12:04:19 2014 -0500
@@ -21,7 +21,7 @@
 include(CheckCXXCompilerFlag)
 
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 32)
+set(X265_BUILD 33)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 7dccbbed0349 -r bef05615e5a4 source/common/param.cpp
--- a/source/common/param.cpp	Wed Sep 24 18:26:45 2014 -0500
+++ b/source/common/param.cpp	Thu Sep 25 12:04:19 2014 -0500
@@ -168,8 +168,8 @@
 
     /* SAO Loop Filter */
     param->bEnableSAO = 1;
-    param->saoLcuBoundary = 0;
-    param->saoLcuBasedOptimization = 1;
+    param->bSaoNonDeblocked = 0;
+    param->bSaoFrame = 0;
 
     /* Coding Quality */
     param->cbQpOffset = 0;
@@ -624,8 +624,8 @@
     OPT("b-intra") p->bIntraInBFrames = atobool(value);
     OPT("lft") p->bEnableLoopFilter = atobool(value);
     OPT("sao") p->bEnableSAO = atobool(value);
-    OPT("sao-lcu-bounds") p->saoLcuBoundary = atoi(value);
-    OPT("sao-lcu-opt") p->saoLcuBasedOptimization = atoi(value);
+    OPT("sao-non-deblock") p->bSaoNonDeblocked = atobool(value);
+    OPT("sao-frame") p->bSaoFrame = atobool(value);
     OPT("ssim") p->bEnableSsim = atobool(value);
     OPT("psnr") p->bEnablePsnr = atobool(value);
     OPT("hash") p->decodedPictureHashSEI = atoi(value);
@@ -1166,12 +1166,8 @@
 
     TOOLOPT(param->bEnableLoopFilter, "lft");
     if (param->bEnableSAO)
-    {
-        if (param->saoLcuBasedOptimization)
-            fprintf(stderr, "sao-lcu ");
-        else
-            fprintf(stderr, "sao-frame ");
-    }
+        fprintf(stderr, "sao%s%s ", param->bSaoFrame        ? "-frame" : "",
+                                    param->bSaoNonDeblocked ? "-non-deblock" : "");
     TOOLOPT(param->bEnableSignHiding, "signhide");
     TOOLOPT(param->bCULossless, "cu-lossless");
     TOOLOPT(param->bEnableFastIntra, "fast-intra");
@@ -1244,8 +1240,8 @@
     BOOL(p->bEnableSignHiding, "signhide");
     BOOL(p->bEnableLoopFilter, "lft");
     BOOL(p->bEnableSAO, "sao");
-    s += sprintf(s, " sao-lcu-bounds=%d", p->saoLcuBoundary);
-    s += sprintf(s, " sao-lcu-opt=%d", p->saoLcuBasedOptimization);
+    BOOL(p->bSaoNonDeblocked, "sao-non-deblock");
+    BOOL(p->bSaoFrame, "sao-frame");
     BOOL(p->bBPyramid, "b-pyramid");
     BOOL(p->rc.cuTree, "cutree");
     s += sprintf(s, " rc=%s", p->rc.rateControlMode == X265_RC_ABR ? (
diff -r 7dccbbed0349 -r bef05615e5a4 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Wed Sep 24 18:26:45 2014 -0500
+++ b/source/encoder/encoder.cpp	Thu Sep 25 12:04:19 2014 -0500
@@ -1248,7 +1248,7 @@
         x265_log(p, X265_LOG_INFO, "Parallelism disabled, single thread mode\n");
         p->bEnableWavefront = 0;
     }
-    if (!p->saoLcuBasedOptimization && p->frameNumThreads > 1)
+    if (p->bSaoFrame && p->frameNumThreads > 1)
     {
         x265_log(p, X265_LOG_INFO, "Warning: picture-based SAO used with frame parallelism\n");
     }
diff -r 7dccbbed0349 -r bef05615e5a4 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Wed Sep 24 18:26:45 2014 -0500
+++ b/source/encoder/frameencoder.cpp	Thu Sep 25 12:04:19 2014 -0500
@@ -85,7 +85,7 @@
     m_param = top->m_param;
     m_numRows = numRows;
     m_numCols = numCols;
-    m_filterRowDelay = (m_param->bEnableSAO && m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary) ?
+    m_filterRowDelay = (m_param->bEnableSAO && !m_param->bSaoFrame && m_param->bSaoNonDeblocked) ?
                         2 : (m_param->bEnableSAO || m_param->bEnableLoopFilter ? 1 : 0);
     m_filterRowDelayCus = m_filterRowDelay * numCols;
 
@@ -323,7 +323,7 @@
         m_frameStats.percentSkip  = (double)totalSkip / totalCuCount;
     }
 
-    if (slice->m_sps->bUseSAO && !m_param->saoLcuBasedOptimization)
+    if (slice->m_sps->bUseSAO && m_param->bSaoFrame)
     {
         /* frame based SAO */
         m_frameFilter.m_sao.SAOProcess(m_frame->getPicSym()->m_saoParam);
@@ -802,7 +802,7 @@
         }
 
         // NOTE: do CU level Filter
-        if (m_param->bEnableSAO && m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary)
+        if (m_param->bEnableSAO && !m_param->bSaoFrame && m_param->bSaoNonDeblocked)
             // SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
             m_frameFilter.m_sao.calcSaoStatsCu_BeforeDblk(m_frame, col, row);
 
diff -r 7dccbbed0349 -r bef05615e5a4 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp	Wed Sep 24 18:26:45 2014 -0500
+++ b/source/encoder/framefilter.cpp	Thu Sep 25 12:04:19 2014 -0500
@@ -115,7 +115,7 @@
     SAOParam* saoParam = m_frame->getPicSym()->m_saoParam;
     if (m_param->bEnableSAO)
     {
-        if (m_param->saoLcuBasedOptimization)
+        if (!m_param->bSaoFrame)
         {
             m_sao.m_entropyCoder.load(m_frameEncoder->m_initSliceContext);
             m_sao.m_rdEntropyCoders[0][CI_NEXT_BEST].load(m_frameEncoder->m_initSliceContext);
@@ -138,7 +138,7 @@
 
     if (row == m_numRows - 1)
     {
-        if (m_param->bEnableSAO && m_param->saoLcuBasedOptimization)
+        if (m_param->bEnableSAO && !m_param->bSaoFrame)
         {
             m_sao.rdoSaoUnitRowEnd(saoParam, m_frame->getNumCUsInFrame());
 
diff -r 7dccbbed0349 -r bef05615e5a4 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Wed Sep 24 18:26:45 2014 -0500
+++ b/source/encoder/sao.cpp	Thu Sep 25 12:04:19 2014 -0500
@@ -1217,12 +1217,12 @@
     int isChroma = !!plane;
     int numSkipLine = isChroma ? 4 - (2 * m_vChromaShift) : 4;
 
-    if (!m_param->saoLcuBasedOptimization)
+    if (m_param->bSaoFrame)
         numSkipLine = 0;
 
     int numSkipLineRight = isChroma ? 5 - (2 * m_hChromaShift) : 5;
 
-    if (!m_param->saoLcuBasedOptimization)
+    if (m_param->bSaoFrame)
         numSkipLineRight = 0;
 
     picWidthTmp  = isLuma ? m_param->sourceWidth  : m_param->sourceWidth  >> m_hChromaShift;
@@ -1244,7 +1244,7 @@
     {
         const int boShift = X265_DEPTH - SAO_BO_BITS;
 
-        if (m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary)
+        if (!m_param->bSaoFrame && m_param->bSaoNonDeblocked)
         {
             numSkipLine      = isChroma ? 3 - (2 * m_vChromaShift) : 3;
             numSkipLineRight = isChroma ? 4 - (2 * m_hChromaShift) : 4;
@@ -1278,7 +1278,7 @@
     {
         //if (iSaoType == EO_0)
         {
-            if (m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary)
+            if (!m_param->bSaoFrame && m_param->bSaoNonDeblocked)
             {
                 numSkipLine      = isChroma ? 3 - (2 * m_vChromaShift) : 3;
                 numSkipLineRight = isChroma ? 5 - (2 * m_hChromaShift) : 5;
@@ -1311,7 +1311,7 @@
 
         //if (iSaoType == EO_1)
         {
-            if (m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary)
+            if (!m_param->bSaoFrame && m_param->bSaoNonDeblocked)
             {
                 numSkipLine      = isChroma ? 4 - (2 * m_vChromaShift) : 4;
                 numSkipLineRight = isChroma ? 4 - (2 * m_hChromaShift) : 4;
@@ -1352,7 +1352,7 @@
         }
         //if (iSaoType == EO_2)
         {
-            if (m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary)
+            if (!m_param->bSaoFrame && m_param->bSaoNonDeblocked)
             {
                 numSkipLine      = isChroma ? 4 - (2 * m_vChromaShift) : 4;
                 numSkipLineRight = isChroma ? 5 - (2 * m_hChromaShift) : 5;
@@ -1398,7 +1398,7 @@
         }
         //if (iSaoType == EO_3)
         {
-            if (m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary)
+            if (!m_param->bSaoFrame && m_param->bSaoNonDeblocked)
             {
                 numSkipLine      = isChroma ? 4 - (2 * m_vChromaShift) : 4;
                 numSkipLineRight = isChroma ? 5 - (2 * m_hChromaShift) : 5;
@@ -1812,7 +1812,7 @@
 /* Sample adaptive offset process */
 void SAO::SAOProcess(SAOParam *saoParam)
 {
-    X265_CHECK(!m_param->saoLcuBasedOptimization, "SAO LCU mode failure\n"); 
+    X265_CHECK(m_param->bSaoFrame, "SAO frame mode check failure\n"); 
     double costFinal = 0;
     saoParam->bSaoFlag[0] = true;
     saoParam->bSaoFlag[1] = false;
@@ -2005,7 +2005,7 @@
                 for (k = 0; k < MAX_NUM_SAO_CLASS; k++)
                 {
                     m_offset[compIdx][j][k] = 0;
-                    if (m_param->saoLcuBasedOptimization && m_param->saoLcuBoundary)
+                    if (!m_param->bSaoFrame && m_param->bSaoNonDeblocked)
                     {
                         m_count[compIdx][j][k] = m_countPreDblk[addr][compIdx][j][k];
                         m_offsetOrg[compIdx][j][k] = m_offsetOrgPreDblk[addr][compIdx][j][k];
diff -r 7dccbbed0349 -r bef05615e5a4 source/x265.cpp
--- a/source/x265.cpp	Wed Sep 24 18:26:45 2014 -0500
+++ b/source/x265.cpp	Thu Sep 25 12:04:19 2014 -0500
@@ -163,8 +163,8 @@
     { "lft",                  no_argument, NULL, 0 },
     { "no-sao",               no_argument, NULL, 0 },
     { "sao",                  no_argument, NULL, 0 },
-    { "sao-lcu-bounds", required_argument, NULL, 0 },
-    { "sao-lcu-opt",    required_argument, NULL, 0 },
+    { "sao-non-deblock",      no_argument, NULL, 0 },
+    { "sao-frame",            no_argument, NULL, 0 },
     { "no-ssim",              no_argument, NULL, 0 },
     { "ssim",                 no_argument, NULL, 0 },
     { "no-psnr",              no_argument, NULL, 0 },
@@ -456,8 +456,8 @@
     H0("\nLoop filters (deblock and SAO):\n");
     H0("   --[no-]lft                    Enable Deblocking Loop Filter. Default %s\n", OPT(param->bEnableLoopFilter));
     H0("   --[no-]sao                    Enable Sample Adaptive Offset. Default %s\n", OPT(param->bEnableSAO));
-    H0("   --sao-lcu-bounds <integer>    0: right/bottom boundary areas skipped  1: non-deblocked pixels are used. Default %d\n", param->saoLcuBoundary);
-    H0("   --sao-lcu-opt <integer>       0: SAO picture-based optimization, 1: SAO LCU-based optimization. Default %d\n", param->saoLcuBasedOptimization);
+    H0("   --[no-]sao-non-deblock        If enabled non-deblocked pixels are used, else right/bottom boundary areas skipped. Default %s\n", OPT(param->bSaoNonDeblocked));
+    H0("   --[no-]sao-frame              Use whole-picture SAO analysis, severely restricts frame parallelism. Default %s\n", OPT(param->bSaoFrame));
     H0("\nVUI options:\n");
     H0("   --sar <width:height|int>      Sample Aspect Ratio, the ratio of width to height of an individual pixel.\n");
     H0("                                 Choose from 0=undef, 1=1:1(\"square\"), 2=12:11, 3=10:11, 4=16:11,\n");
diff -r 7dccbbed0349 -r bef05615e5a4 source/x265.h
--- a/source/x265.h	Wed Sep 24 18:26:45 2014 -0500
+++ b/source/x265.h	Thu Sep 25 12:04:19 2014 -0500
@@ -729,16 +729,16 @@
     /* Note: when deblocking and SAO are both enabled, the loop filter CU lag is
      * only one row, as they operate in series o the same row. */
 
-    /* Select the method in which SAO deals with deblocking boundary pixels.  If
-     * 0 the right and bottom boundary areas are skipped. If 1, non-deblocked
-     * pixels are used entirely. Default is 0 */
-    int       saoLcuBoundary;
+    /* Select the method in which SAO deals with deblocking boundary pixels. 
+     * If false, the right and bottom boundary areas are skipped.
+     * If true, non-deblocked pixels are used entirely for SAO analysis.
+     * Default is false */
+    int       bSaoNonDeblocked;
 
-    /* Select the scope of the SAO optimization. If 0 SAO is performed over the
-     * entire output picture at once, this can severly restrict frame
-     * parallelism so it is not recommended for many-core machines.  If 1 SAO is
-     * performed on LCUs in series. Default is 1 */
-    int       saoLcuBasedOptimization;
+    /* If enabled SAO is performed on the entire picture at once. This can
+     * severely restrict frame parallelism so it is not recommended for
+     * many-core machines. Default is disabled */
+    int       bSaoFrame;
 
     /* Generally a small signed integer which offsets the QP used to quantize
      * the Cb chroma residual (delta from luma QP specified by rate-control).


More information about the x265-devel mailing list