changeset 11998:59c02e68410f draft

Add max-ausize-factor option to control the maximum AU size defined in specification
author Divya Manivannan <divya@multicorewareinc.com>
date Tue, 27 Feb 2018 15:50:42 +0530
parents 4c0d8a22625d
children 613d9f443769
files doc/reST/cli.rst source/CMakeLists.txt source/common/param.cpp source/encoder/ratecontrol.cpp source/x265.h source/x265cli.h
diffstat 6 files changed, 20 insertions(+-), 1 deletions(-) [+]
line wrap: on
line diff
--- a/doc/reST/cli.rst	Thu Jan 25 11:37:21 2018 +0530
+++ b/doc/reST/cli.rst	Tue Feb 27 15:50:42 2018 +0530
@@ -1857,6 +1857,11 @@ other levels.
 	the more bits it will try to spend on signaling information (motion
 	vectors and splits) and less on residual. This feature is intended
 	for experimentation.
+	
+.. option:: --max-ausize-factor <float>
+
+        It controls the maximum AU size defined in specification. It represents
+        the percentage of maximum AU size used. Default is 1. Range is 0.5 to 1.
 
 Loop filters
 ============
--- a/source/CMakeLists.txt	Thu Jan 25 11:37:21 2018 +0530
+++ b/source/CMakeLists.txt	Tue Feb 27 15:50:42 2018 +0530
@@ -29,7 +29,7 @@ option(NATIVE_BUILD "Target the build CP
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 152)
+set(X265_BUILD 153)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
--- a/source/common/param.cpp	Thu Jan 25 11:37:21 2018 +0530
+++ b/source/common/param.cpp	Tue Feb 27 15:50:42 2018 +0530
@@ -295,6 +295,7 @@ void x265_param_default(x265_param* para
     param->forceFlush = 0;
     param->bDisableLookahead = 0;
     param->bCopyPicToFrame = 1;
+    param->maxAUSizeFactor = 1;
 
     /* DCT Approximations */
     param->bLowPassDct = 0;
@@ -1012,6 +1013,7 @@ int x265_param_parse(x265_param* p, cons
         OPT("analysis-save") p->analysisSave = strdup(value);
         OPT("analysis-load") p->analysisLoad = strdup(value);
         OPT("radl") p->radl = atoi(value);
+        OPT("max-ausize-factor") p->maxAUSizeFactor = atof(value);
         else
             return X265_PARAM_BAD_NAME;
     }
@@ -1367,6 +1369,8 @@ int x265_check_params(x265_param* param)
         "Invalid refine-inter value, refine-inter levels 0 to 3 supported");
     CHECK(param->intraRefine > 4 || param->intraRefine < 0,
         "Invalid refine-intra value, refine-intra levels 0 to 3 supported");
+    CHECK(param->maxAUSizeFactor < 0.5 || param->maxAUSizeFactor > 1.0,
+        "Supported factor for controlling max AU size is from 0.5 to 1");
 #if !X86_64
     CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 || param->sourceHeight > 480),
         "SEA motion search does not support resolutions greater than 480p in 32 bit build");
@@ -1740,6 +1744,7 @@ char *x265_param2string(x265_param* p, i
     BOOL(p->bLowPassDct, "lowpass-dct");
     s += sprintf(s, " refine-mv-type=%d", p->bMVType);
     s += sprintf(s, " copy-pic=%d", p->bCopyPicToFrame);
+    s += sprintf(s, " max-ausize-factor=%.1f", p->maxAUSizeFactor);
 #undef BOOL
     return buf;
 }
--- a/source/encoder/ratecontrol.cpp	Thu Jan 25 11:37:21 2018 +0530
+++ b/source/encoder/ratecontrol.cpp	Tue Feb 27 15:50:42 2018 +0530
@@ -1302,6 +1302,7 @@ int RateControl::rateControlStart(Frame*
                 /* 1.5 * MaxLumaSr * (AuCpbRemovalTime[ n ] - AuCpbRemovalTime[ n - 1 ]) / MinCr */
                 rce->frameSizeMaximum = 8 * 1.5 * enc->m_vps.ptl.maxLumaSrForLevel * m_frameDuration / mincr;
             }
+            rce->frameSizeMaximum *= m_param->maxAUSizeFactor;
         }
     }
     if (!m_isAbr && m_2pass && m_param->rc.rateControlMode == X265_RC_CRF)
--- a/source/x265.h	Thu Jan 25 11:37:21 2018 +0530
+++ b/source/x265.h	Tue Feb 27 15:50:42 2018 +0530
@@ -1548,6 +1548,11 @@ typedef struct x265_param
 
     /*Number of RADL pictures allowed in front of IDR*/
     int radl;
+
+    /* This value controls the maximum AU size defined in specification
+     * It represents the percentage of maximum AU size used.
+     * Default is 1 (which is 100%). Range is 0.5 to 1. */
+    double maxAUSizeFactor;
 } x265_param;
 
 /* x265_param_alloc:
--- a/source/x265cli.h	Thu Jan 25 11:37:21 2018 +0530
+++ b/source/x265cli.h	Tue Feb 27 15:50:42 2018 +0530
@@ -293,6 +293,7 @@ static const struct option long_options[
     { "refine-mv-type", required_argument, NULL, 0 },
     { "copy-pic",             no_argument, NULL, 0 },
     { "no-copy-pic",          no_argument, NULL, 0 },
+    { "max-ausize-factor", required_argument, NULL, 0 },
     { 0, 0, 0, 0 },
     { 0, 0, 0, 0 },
     { 0, 0, 0, 0 },
@@ -516,6 +517,8 @@ static void showHelp(x265_param *param)
     H1("                                 MAX_MAX_QP+1 floats for lambda table, then again for lambda2 table\n");
     H1("                                 Blank lines and lines starting with hash(#) are ignored\n");
     H1("                                 Comma is considered to be white-space\n");
+    H0("   --max-ausize-factor <float>   This value controls the maximum AU size defined in specification.\n");
+    H0("                                 It represents the percentage of maximum AU size used. Default %.1f\n", param->maxAUSizeFactor);
     H0("\nLoop filters (deblock and SAO):\n");
     H0("   --[no-]deblock                Enable Deblocking Loop Filter, optionally specify tC:Beta offsets Default %s\n", OPT(param->bEnableLoopFilter));
     H0("   --[no-]sao                    Enable Sample Adaptive Offset. Default %s\n", OPT(param->bEnableSAO));