<div dir="ltr"><div># HG changeset patch</div><div># User Deepthi Nandakumar <<a href="mailto:deepthi@multicorewareinc.com">deepthi@multicorewareinc.com</a>></div><div># Date 1464874032 -19800</div><div>#      Thu Jun 02 18:57:12 2016 +0530</div><div># Node ID 64cf1830b03410048070641fb0ac6da6f41a42b1</div><div># Parent  6098ba3e0cf16b110cff3b2519ce2d997ecac396</div><div>level: fix bug in level and tier determination (#refs 278)</div><div><br></div><div>This patch changes the behaviour of tier determination (and sometimes level as</div><div>a side-effect), and hence bumping up build number to warn users. High-tier is</div><div>"allowed" by default, and --no-high-tier tells the encoder to never choose high</div><div>tier.</div><div><br></div><div>diff -r 6098ba3e0cf1 -r 64cf1830b034 doc/reST/cli.rst</div><div>--- a/doc/reST/cli.rst<span class="" style="white-space:pre">  </span>Tue May 31 14:06:55 2016 +0100</div><div>+++ b/doc/reST/cli.rst<span class="" style="white-space:pre">       </span>Thu Jun 02 18:57:12 2016 +0530</div><div>@@ -522,16 +522,14 @@</div><div> </div><div> .. option:: --high-tier, --no-high-tier</div><div> </div><div>-<span class="" style="white-space:pre">      </span>If :option:`--level-idc` has been specified, the option adds the</div><div>-<span class="" style="white-space:pre">  </span>intention to support the High tier of that level. If your specified</div><div>-<span class="" style="white-space:pre">       </span>level does not support a High tier, a warning is issued and this</div><div>-<span class="" style="white-space:pre">  </span>modifier flag is ignored. If :option:`--level-idc` has been specified,</div><div>-<span class="" style="white-space:pre">    </span>but not --high-tier, then the encoder will attempt to encode at the </div><div>-<span class="" style="white-space:pre">     </span>specified level, main tier first, turning on high tier only if </div><div>-<span class="" style="white-space:pre">  </span>necessary and available at that level.</div><div>+<span class="" style="white-space:pre">    </span>If :option:`--level-idc` has been specified, --high-tier allows the</div><div>+<span class="" style="white-space:pre">       </span>support of high tier at that level. The encoder will first attempt to encode </div><div>+<span class="" style="white-space:pre">    </span>at the specified level, main tier first, turning on high tier only if </div><div>+<span class="" style="white-space:pre">   </span>necessary and available at that level.If your requested level does not </div><div>+<span class="" style="white-space:pre">  </span>support a High tier, high tier will not be supported. If --no-high-tier </div><div>+<span class="" style="white-space:pre"> </span>has been specified, then the encoder will attempt to encode only at the main tier.</div><div> </div><div>-<span class="" style="white-space:pre">       </span>If :option:`--level-idc` has not been specified, this argument is</div><div>-<span class="" style="white-space:pre"> </span>ignored.</div><div>+<span class="" style="white-space:pre">  </span>Default: enabled</div><div> </div><div> .. option:: --ref <1..16></div><div> </div><div>diff -r 6098ba3e0cf1 -r 64cf1830b034 source/CMakeLists.txt</div><div>--- a/source/CMakeLists.txt<span class="" style="white-space:pre">     </span>Tue May 31 14:06:55 2016 +0100</div><div>+++ b/source/CMakeLists.txt<span class="" style="white-space:pre">  </span>Thu Jun 02 18:57:12 2016 +0530</div><div>@@ -30,7 +30,7 @@</div><div> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)</div><div> </div><div> # X265_BUILD must be incremented each time the public API is changed</div><div>-set(X265_BUILD 84)</div><div>+set(X265_BUILD 85)</div><div> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in">x265.def.in</a>"</div><div>                "${PROJECT_BINARY_DIR}/x265.def")</div><div> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in">x265_config.h.in</a>"</div><div>diff -r 6098ba3e0cf1 -r 64cf1830b034 source/common/param.cpp</div><div>--- a/source/common/param.cpp<span class="" style="white-space:pre"> </span>Tue May 31 14:06:55 2016 +0100</div><div>+++ b/source/common/param.cpp<span class="" style="white-space:pre">        </span>Thu Jun 02 18:57:12 2016 +0530</div><div>@@ -121,9 +121,9 @@</div><div>     /* Source specifications */</div><div>     param->internalBitDepth = X265_DEPTH;</div><div>     param->internalCsp = X265_CSP_I420;</div><div>-    param->levelIdc = 0;</div><div>+    param->levelIdc = 0; //Auto-detect level</div><div>     param->uhdBluray = 0;</div><div>-    param->bHighTier = 0;</div><div>+    param->bHighTier = 1; //Allow high tier by default</div><div>     param->interlaceMode = 0;</div><div>     param->bAnnexB = 1;</div><div>     param->bRepeatHeaders = 0;</div><div>diff -r 6098ba3e0cf1 -r 64cf1830b034 source/encoder/level.cpp</div><div>--- a/source/encoder/level.cpp<span class="" style="white-space:pre"> </span>Tue May 31 14:06:55 2016 +0100</div><div>+++ b/source/encoder/level.cpp<span class="" style="white-space:pre">       </span>Thu Jun 02 18:57:12 2016 +0530</div><div>@@ -198,7 +198,7 @@</div><div>             CHECK_RANGE((uint32_t)param.rc.vbvBufferSize, levels[i].maxCpbSizeMain, levels[i].maxCpbSizeHigh))</div><div>         {</div><div>             /* The bitrate or buffer size are out of range for Main tier, but in</div><div>-             * range for High tier. If the user requested High tier then give</div><div>+             * range for High tier. If the user allowed High tier then give</div><div>              * them High tier at this level.  Otherwise allow the loop to</div><div>              * progress to the Main tier of the next level */</div><div>             if (param.bHighTier)</div><div>@@ -209,8 +209,9 @@</div><div>         else</div><div>             vps.ptl.tierFlag = Level::MAIN;</div><div> #undef CHECK_RANGE</div><div>-        if (param.uhdBluray || param.bHighTier)</div><div>+        if (param.uhdBluray)</div><div>             vps.ptl.tierFlag = Level::HIGH;</div><div>+</div><div>         vps.ptl.levelIdc = levels[i].levelEnum;</div><div>         vps.ptl.minCrForLevel = levels[i].minCompressionRatio;</div><div>         vps.ptl.maxLumaSrForLevel = levels[i].maxLumaSamplesPerSecond;</div><div>@@ -306,12 +307,9 @@</div><div>     }</div><div> </div><div>     LevelSpec& l = levels[level];</div><div>-    bool highTier = !!param.bHighTier;</div><div>-    if (highTier && l.maxBitrateHigh == MAX_UINT)</div><div>-    {</div><div>-        highTier = false;</div><div>-        x265_log(&param, X265_LOG_WARNING, "Level %s has no High tier, using Main tier\n", <a href="http://l.name">l.name</a>);</div><div>-    }</div><div>+</div><div>+    //highTier is allowed for this level and has not been explicitly disabled. This does not mean it is the final chosen tier</div><div>+    bool allowHighTier = l.maxBitrateHigh < MAX_UINT && param.bHighTier;</div><div> </div><div>     uint32_t lumaSamples = param.sourceWidth * param.sourceHeight;</div><div>     uint32_t samplesPerSec = (uint32_t)(lumaSamples * ((double)param.fpsNum / param.fpsDenom));</div><div>@@ -333,23 +331,27 @@</div><div>         return false;</div><div>     }</div><div> </div><div>-    if ((uint32_t)param.rc.vbvMaxBitrate > (highTier ? l.maxBitrateHigh : l.maxBitrateMain))</div><div>+    /* Adjustments of Bitrate, VBV buffer size, refs will be triggered only if specified params do not fit </div><div>+     * within the max limits of that level (high tier if allowed, main otherwise)</div><div>+     */</div><div>+</div><div>+    if ((uint32_t)param.rc.vbvMaxBitrate > (allowHighTier ? l.maxBitrateHigh : l.maxBitrateMain))</div><div>     {</div><div>-        param.rc.vbvMaxBitrate = highTier ? l.maxBitrateHigh : l.maxBitrateMain;</div><div>+        param.rc.vbvMaxBitrate = allowHighTier ? l.maxBitrateHigh : l.maxBitrateMain;</div><div>         x265_log(&param, X265_LOG_WARNING, "lowering VBV max bitrate to %dKbps\n", param.rc.vbvMaxBitrate);</div><div>     }</div><div>-    if ((uint32_t)param.rc.vbvBufferSize > (highTier ? l.maxCpbSizeHigh : l.maxCpbSizeMain))</div><div>+    if ((uint32_t)param.rc.vbvBufferSize > (allowHighTier ? l.maxCpbSizeHigh : l.maxCpbSizeMain))</div><div>     {</div><div>-        param.rc.vbvBufferSize = highTier ? l.maxCpbSizeHigh : l.maxCpbSizeMain;</div><div>+        param.rc.vbvBufferSize = allowHighTier ? l.maxCpbSizeHigh : l.maxCpbSizeMain;</div><div>         x265_log(&param, X265_LOG_WARNING, "lowering VBV buffer size to %dKb\n", param.rc.vbvBufferSize);</div><div>     }</div><div> </div><div>     switch (param.rc.rateControlMode)</div><div>     {</div><div>     case X265_RC_ABR:</div><div>-        if ((uint32_t)param.rc.bitrate > (highTier ? l.maxBitrateHigh : l.maxBitrateMain))</div><div>+        if ((uint32_t)param.rc.bitrate > (allowHighTier ? l.maxBitrateHigh : l.maxBitrateMain))</div><div>         {</div><div>-            param.rc.bitrate = l.maxBitrateHigh;</div><div>+            param.rc.bitrate =  allowHighTier ? l.maxBitrateHigh : l.maxBitrateMain;</div><div>             x265_log(&param, X265_LOG_WARNING, "lowering target bitrate to High tier limit of %dKbps\n", param.rc.bitrate);</div><div>         }</div><div>         break;</div><div>@@ -362,9 +364,9 @@</div><div>         if (!param.rc.vbvBufferSize || !param.rc.vbvMaxBitrate)</div><div>         {</div><div>             if (!param.rc.vbvMaxBitrate)</div><div>-                param.rc.vbvMaxBitrate = highTier ? l.maxBitrateHigh : l.maxBitrateMain;</div><div>+                param.rc.vbvMaxBitrate = allowHighTier ? l.maxBitrateHigh : l.maxBitrateMain;</div><div>             if (!param.rc.vbvBufferSize)</div><div>-                param.rc.vbvBufferSize = highTier ? l.maxCpbSizeHigh : l.maxCpbSizeMain;</div><div>+                param.rc.vbvBufferSize = allowHighTier ? l.maxCpbSizeHigh : l.maxCpbSizeMain;</div><div>             x265_log(&param, X265_LOG_WARNING, "Specifying a decoder level with constant rate factor rate-control requires\n");</div><div>             x265_log(&param, X265_LOG_WARNING, "enabling VBV with vbv-bufsize=%dkb vbv-maxrate=%dkbps. VBV outputs are non-deterministic!\n",</div><div>                      param.rc.vbvBufferSize, param.rc.vbvMaxBitrate);</div><div><br></div><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</div>