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