[x265] [PATCH] Add option hme-range to modify search range for HME levels L0, L1 and L2

Aruna Matheswaran aruna at multicorewareinc.com
Mon Dec 2 14:35:35 CET 2019


Pushed to default branch.

On Mon, Dec 2, 2019 at 5:37 PM Pooja Venkatesan <pooja at multicorewareinc.com>
wrote:

> Hi Aruna,
> I have incorporated the changes suggested by you. Thanks and PFA the
> modified patch.
>
> # HG changeset patch
> # User Pooja Venkatesan <pooja at multicorewareinc.com>
> # Date 1568196486 -19800
> #      Wed Sep 11 15:38:06 2019 +0530
> # Node ID 7685a9d072a229f41813f7d61a53c82d019911ec
> # Parent  f8a38d6ef1ebbaf928fae6c34c17dd4c65fda485
> Add option hme-range to modify search range for HME levels L0, L1 and L2.
>
> diff -r f8a38d6ef1eb -r 7685a9d072a2 doc/reST/cli.rst
> --- a/doc/reST/cli.rst Thu Nov 28 18:37:53 2019 +0530
> +++ b/doc/reST/cli.rst Wed Sep 11 15:38:06 2019 +0530
> @@ -1290,6 +1290,12 @@
>         which will apply to all levels. Default is hex,umh,umh for
>         levels 0,1,2 respectively.
>
> +.. option:: --hme-range <integer>,<integer>,<integer>
> +
> + Search range for HME level 0, 1 and 2.
> + The Search Range for each HME level must be between 0 and
> 32768(excluding).
> + Default search range is 16,32,48 for level 0,1,2 respectively.
> +
>  Spatial/intra options
>  =====================
>
> diff -r f8a38d6ef1eb -r 7685a9d072a2 source/CMakeLists.txt
> --- a/source/CMakeLists.txt Thu Nov 28 18:37:53 2019 +0530
> +++ b/source/CMakeLists.txt Wed Sep 11 15:38:06 2019 +0530
> @@ -29,7 +29,7 @@
>  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 183)
> +set(X265_BUILD 184)
>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>                 "${PROJECT_BINARY_DIR}/x265.def")
>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
> diff -r f8a38d6ef1eb -r 7685a9d072a2 source/common/param.cpp
> --- a/source/common/param.cpp Thu Nov 28 18:37:53 2019 +0530
> +++ b/source/common/param.cpp Wed Sep 11 15:38:06 2019 +0530
> @@ -210,6 +210,9 @@
>      param->bEnableHME = 0;
>      param->hmeSearchMethod[0] = X265_HEX_SEARCH;
>      param->hmeSearchMethod[1] = param->hmeSearchMethod[2] =
> X265_UMH_SEARCH;
> +    param->hmeRange[0] = 16;
> +    param->hmeRange[1] = 32;
> +    param->hmeRange[2] = 48;
>      param->bSourceReferenceEstimation = 0;
>      param->limitTU = 0;
>      param->dynamicRd = 0;
> @@ -1344,6 +1347,11 @@
>              }
>              p->bEnableHME = true;
>          }
> +        OPT("hme-range")
> +        {
> +            sscanf(value, "%d,%d,%d", &p->hmeRange[0], &p->hmeRange[1],
> &p->hmeRange[2]);
> +            p->bEnableHME = true;
> +        }
>          else
>              return X265_PARAM_BAD_NAME;
>      }
> @@ -1734,6 +1742,9 @@
>          "Invalid scenecut Window duration. Value must be between 0 and
> 1000(inclusive)");
>      CHECK(param->maxQpDelta < 0 || param->maxQpDelta > 10,
>          "Invalid maxQpDelta value. Value must be between 0 and 10
> (inclusive)");
> +    for(int level = 0; level < 3; level++)
> +        CHECK(param->hmeRange[level] < 0 || param->hmeRange[level] >=
> 32768,
> +            "Search Range for HME levels must be between 0 and 32768");
>  #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");
> @@ -2019,7 +2030,10 @@
>          s += sprintf(s, " dup-threshold=%d", p->dupThreshold);
>      BOOL(p->bEnableHME, "hme");
>      if (p->bEnableHME)
> +    {
>          s += sprintf(s, " Level 0,1,2=%d,%d,%d", p->hmeSearchMethod[0],
> p->hmeSearchMethod[1], p->hmeSearchMethod[2]);
> +        s += sprintf(s, " merange L0,L1,L2=%d,%d,%d", p->hmeRange[0],
> p->hmeRange[1], p->hmeRange[2]);
> +    }
>      BOOL(p->bEnableWeightedPred, "weightp");
>      BOOL(p->bEnableWeightedBiPred, "weightb");
>      BOOL(p->bSourceReferenceEstimation, "analyze-src-pics");
> @@ -2320,7 +2334,10 @@
>      if (src->bEnableHME)
>      {
>          for (int level = 0; level < 3; level++)
> +        {
>              dst->hmeSearchMethod[level] = src->hmeSearchMethod[level];
> +            dst->hmeRange[level] = src->hmeRange[level];
> +        }
>      }
>      dst->bEnableWeightedBiPred = src->bEnableWeightedBiPred;
>      dst->bEnableWeightedPred = src->bEnableWeightedPred;
> diff -r f8a38d6ef1eb -r 7685a9d072a2 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp Thu Nov 28 18:37:53 2019 +0530
> +++ b/source/encoder/encoder.cpp Wed Sep 11 15:38:06 2019 +0530
> @@ -4079,10 +4079,14 @@
>              x265_log(p, X265_LOG_WARNING, "Source height < 540p is too
> low for HME. Disabling HME.\n");
>              p->bEnableHME = 0;
>          }
> -        if (m_param->bEnableHME && m_param->searchMethod !=
> m_param->hmeSearchMethod[2])
> -        {
> +    }
> +
> +    if (m_param->bEnableHME)
> +    {
> +        if (m_param->searchMethod != m_param->hmeSearchMethod[2])
>              m_param->searchMethod = m_param->hmeSearchMethod[2];
> -        }
> +        if (m_param->searchRange != m_param->hmeRange[2])
> +            m_param->searchRange = m_param->hmeRange[2];
>      }
>
>     if (p->bHistBasedSceneCut && !p->edgeTransitionThreshold)
> diff -r f8a38d6ef1eb -r 7685a9d072a2 source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp Thu Nov 28 18:37:53 2019 +0530
> +++ b/source/encoder/slicetype.cpp Wed Sep 11 15:38:06 2019 +0530
> @@ -3240,12 +3240,13 @@
>              }
>          }
>
> +        int searchRange = m_lookahead.m_param->bEnableHME ? (hme ?
> m_lookahead.m_param->hmeRange[0] : m_lookahead.m_param->hmeRange[1]) :
> s_merange;
>          /* ME will never return a cost larger than the cost @MVP, so we
> do not
>           * have to check that ME cost is more than the estimated merge
> cost */
>          if(!hme)
> -            fencCost = tld.me.motionEstimate(fref, mvmin, mvmax, mvp, 0,
> NULL, s_merange, *fencMV, m_lookahead.m_param->maxSlices);
> +            fencCost = tld.me.motionEstimate(fref, mvmin, mvmax, mvp, 0,
> NULL, searchRange, *fencMV, m_lookahead.m_param->maxSlices);
>          else
> -            fencCost = tld.me.motionEstimate(fref, mvmin, mvmax, mvp, 0,
> NULL, s_merange, *fencMV, m_lookahead.m_param->maxSlices,
> fref->lowerResPlane[0]);
> +            fencCost = tld.me.motionEstimate(fref, mvmin, mvmax, mvp, 0,
> NULL, searchRange, *fencMV, m_lookahead.m_param->maxSlices,
> fref->lowerResPlane[0]);
>          if (skipCost < 64 && skipCost < fencCost && bBidir)
>          {
>              fencCost = skipCost;
> diff -r f8a38d6ef1eb -r 7685a9d072a2 source/x265.h
> --- a/source/x265.h Thu Nov 28 18:37:53 2019 +0530
> +++ b/source/x265.h Wed Sep 11 15:38:06 2019 +0530
> @@ -1856,6 +1856,9 @@
>
>      /* Enables histogram based scenecut detection algorithm to detect
> scenecuts. Default disabled */
>      int      bHistBasedSceneCut;
> +
> +    /* Enable HME search ranges for L0, L1 and L2 respectively. */
> +    int       hmeRange[3];
>  } x265_param;
>
>  /* x265_param_alloc:
> diff -r f8a38d6ef1eb -r 7685a9d072a2 source/x265cli.h
> --- a/source/x265cli.h Thu Nov 28 18:37:53 2019 +0530
> +++ b/source/x265cli.h Wed Sep 11 15:38:06 2019 +0530
> @@ -351,6 +351,7 @@
>  #endif
>      { "cll", no_argument, NULL, 0 },
>      { "no-cll", no_argument, NULL, 0 },
> +    { "hme-range", required_argument, NULL, 0 },
>      { 0, 0, 0, 0 },
>      { 0, 0, 0, 0 },
>      { 0, 0, 0, 0 },
> @@ -479,6 +480,7 @@
>      H1("   --[no-]temporal-mvp           Enable temporal MV predictors.
> Default %s\n", OPT(param->bEnableTemporalMvp));
>      H1("   --[no-]hme                    Enable Hierarchical Motion
> Estimation. Default %s\n", OPT(param->bEnableHME));
>      H1("   --hme-search <string>         Motion search-method for HME
> L0,L1 and L2. Default(L0,L1,L2) is %d,%d,%d\n", param->hmeSearchMethod[0],
> param->hmeSearchMethod[1], param->hmeSearchMethod[2]);
> +    H1("   --hme-range <int>,<int>,<int> Motion search-range for HME
> L0,L1 and L2. Default(L0,L1,L2) is %d,%d,%d\n", param->hmeRange[0],
> param->hmeRange[1], param->hmeRange[2]);
>      H0("\nSpatial / intra options:\n");
>      H0("   --[no-]strong-intra-smoothing Enable strong intra smoothing
> for 32x32 blocks. Default %s\n", OPT(param->bEnableStrongIntraSmoothing));
>      H0("   --[no-]constrained-intra      Constrained intra prediction
> (use only intra coded reference pixels) Default %s\n",
> OPT(param->bEnableConstrainedIntra));
>
> On Sun, Dec 1, 2019 at 10:53 PM Aruna Matheswaran <
> aruna at multicorewareinc.com> wrote:
>
>>
>>
>> On Fri, Nov 29, 2019 at 10:06 PM Pooja Venkatesan <
>> pooja at multicorewareinc.com> wrote:
>>
>>> # HG changeset patch
>>> # User Pooja Venkatesan <pooja at multicorewareinc.com>
>>> # Date 1568196486 -19800
>>> #      Wed Sep 11 15:38:06 2019 +0530
>>> # Node ID c31884e780444d00ee7a25ccbb32a9b9fd52f47a
>>> # Parent  4a29e0c5bfaf30aaed2c5224bcba1f464d68de83
>>> Add option hme-range to modify search range for HME levels L0, L1 and L2.
>>>
>>> diff -r 4a29e0c5bfaf -r c31884e78044 doc/reST/cli.rst
>>> --- a/doc/reST/cli.rst Fri Nov 08 15:30:50 2019 +0530
>>> +++ b/doc/reST/cli.rst Wed Sep 11 15:38:06 2019 +0530
>>> @@ -1290,6 +1290,11 @@
>>>         which will apply to all levels. Default is hex,umh,umh for
>>>         levels 0,1,2 respectively.
>>>
>>> +.. option:: --hme-range <integer>,<integer>,<integer>
>>> +
>>> + Search range for HME level 0, 1 and 2.
>>> + Default search range is 16,32,48 for level 0,1,2 respectively.
>>> +
>>>
>> Please specify the search range allowed at each level.
>>
>>>  Spatial/intra options
>>>  =====================
>>>
>>> diff -r 4a29e0c5bfaf -r c31884e78044 source/CMakeLists.txt
>>> --- a/source/CMakeLists.txt Fri Nov 08 15:30:50 2019 +0530
>>> +++ b/source/CMakeLists.txt Wed Sep 11 15:38:06 2019 +0530
>>> @@ -29,7 +29,7 @@
>>>  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 183)
>>> +set(X265_BUILD 184)
>>>  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
>>>                 "${PROJECT_BINARY_DIR}/x265.def")
>>>  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
>>> diff -r 4a29e0c5bfaf -r c31884e78044 source/common/param.cpp
>>> --- a/source/common/param.cpp Fri Nov 08 15:30:50 2019 +0530
>>> +++ b/source/common/param.cpp Wed Sep 11 15:38:06 2019 +0530
>>> @@ -210,6 +210,9 @@
>>>      param->bEnableHME = 0;
>>>      param->hmeSearchMethod[0] = X265_HEX_SEARCH;
>>>      param->hmeSearchMethod[1] = param->hmeSearchMethod[2] =
>>> X265_UMH_SEARCH;
>>> +    param->hmeRange[0] = 16;
>>> +    param->hmeRange[1] = 32;
>>> +    param->hmeRange[2] = 48;
>>>      param->bSourceReferenceEstimation = 0;
>>>      param->limitTU = 0;
>>>      param->dynamicRd = 0;
>>> @@ -1344,6 +1347,11 @@
>>>              }
>>>              p->bEnableHME = true;
>>>          }
>>> +        OPT("hme-range")
>>> +        {
>>> +            sscanf(value, "%d,%d,%d", &p->hmeRange[0], &p->hmeRange[1],
>>> &p->hmeRange[2]);
>>> +            p->bEnableHME = true;
>>> +        }
>>>          else
>>>              return X265_PARAM_BAD_NAME;
>>>      }
>>> @@ -1734,6 +1742,9 @@
>>>          "Invalid scenecut Window duration. Value must be between 0 and
>>> 1000(inclusive)");
>>>      CHECK(param->maxQpDelta < 0 || param->maxQpDelta > 10,
>>>          "Invalid maxQpDelta value. Value must be between 0 and 10
>>> (inclusive)");
>>>
>> +    for(int level=0; level < 3; level++)
>>>
>> Indentation issue here.
>>
>>> +        CHECK(param->hmeRange[level] < 0 || param->hmeRange[level] >=
>>> 32768,
>>> +            "Search Range for HME levels must be between 0 and 32768");
>>>  #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");
>>> @@ -2018,8 +2029,10 @@
>>>      if(p->bEnableFrameDuplication)
>>>          s += sprintf(s, " dup-threshold=%d", p->dupThreshold);
>>>      BOOL(p->bEnableHME, "hme");
>>> -    if (p->bEnableHME)
>>> +    if (p->bEnableHME){
>>>
>> Indentation issue.
>>
>>>          s += sprintf(s, " Level 0,1,2=%d,%d,%d", p->hmeSearchMethod[0],
>>> p->hmeSearchMethod[1], p->hmeSearchMethod[2]);
>>> +        s += sprintf(s, " merange L0,L1,L2=%d,%d,%d", p->hmeRange[0],
>>> p->hmeRange[1], p->hmeRange[2]);
>>> +    }
>>>      BOOL(p->bEnableWeightedPred, "weightp");
>>>      BOOL(p->bEnableWeightedBiPred, "weightb");
>>>      BOOL(p->bSourceReferenceEstimation, "analyze-src-pics");
>>> @@ -2320,7 +2333,10 @@
>>>      if (src->bEnableHME)
>>>      {
>>>          for (int level = 0; level < 3; level++)
>>> +        {
>>>              dst->hmeSearchMethod[level] = src->hmeSearchMethod[level];
>>> +            dst->hmeRange[level] = src->hmeRange[level];
>>> +        }
>>>      }
>>>      dst->bEnableWeightedBiPred = src->bEnableWeightedBiPred;
>>>      dst->bEnableWeightedPred = src->bEnableWeightedPred;
>>> diff -r 4a29e0c5bfaf -r c31884e78044 source/encoder/encoder.cpp
>>> --- a/source/encoder/encoder.cpp Fri Nov 08 15:30:50 2019 +0530
>>> +++ b/source/encoder/encoder.cpp Wed Sep 11 15:38:06 2019 +0530
>>> @@ -4077,11 +4077,12 @@
>>>              x265_log(p, X265_LOG_WARNING, "Source height < 540p is too
>>> low for HME. Disabling HME.\n");
>>>              p->bEnableHME = 0;
>>>          }
>>> -        if (m_param->bEnableHME && m_param->searchMethod !=
>>> m_param->hmeSearchMethod[2])
>>> -        {
>>> -            m_param->searchMethod = m_param->hmeSearchMethod[2];
>>> -        }
>>> -    }
>>> +    }
>>> +
>>> +    if (m_param->bEnableHME && m_param->searchMethod !=
>>> m_param->hmeSearchMethod[2])
>>> +        m_param->searchMethod = m_param->hmeSearchMethod[2];
>>> +    if (m_param->bEnableHME && m_param->searchRange !=
>>> m_param->hmeRange[2])
>>> +        m_param->searchRange = m_param->hmeRange[2];
>>>
>> Could avoid redundant checks on m_param->bEnableHME.
>>
>>
>>>     if (p->bHistBasedSceneCut && !p->edgeTransitionThreshold)
>>>     {
>>> diff -r 4a29e0c5bfaf -r c31884e78044 source/encoder/slicetype.cpp
>>> --- a/source/encoder/slicetype.cpp Fri Nov 08 15:30:50 2019 +0530
>>> +++ b/source/encoder/slicetype.cpp Wed Sep 11 15:38:06 2019 +0530
>>> @@ -3240,12 +3240,13 @@
>>>              }
>>>          }
>>>
>>> +        int searchRange = m_lookahead.m_param->bEnableHME ? (hme ?
>>> m_lookahead.m_param->hmeRange[0] : m_lookahead.m_param->hmeRange[1]) :
>>> s_merange;
>>>          /* ME will never return a cost larger than the cost @MVP, so we
>>> do not
>>>           * have to check that ME cost is more than the estimated merge
>>> cost */
>>>          if(!hme)
>>> -            fencCost = tld.me.motionEstimate(fref, mvmin, mvmax, mvp,
>>> 0, NULL, s_merange, *fencMV, m_lookahead.m_param->maxSlices);
>>> +            fencCost = tld.me.motionEstimate(fref, mvmin, mvmax, mvp,
>>> 0, NULL, searchRange, *fencMV, m_lookahead.m_param->maxSlices);
>>>          else
>>> -            fencCost = tld.me.motionEstimate(fref, mvmin, mvmax, mvp,
>>> 0, NULL, s_merange, *fencMV, m_lookahead.m_param->maxSlices,
>>> fref->lowerResPlane[0]);
>>> +            fencCost = tld.me.motionEstimate(fref, mvmin, mvmax, mvp,
>>> 0, NULL, searchRange, *fencMV, m_lookahead.m_param->maxSlices,
>>> fref->lowerResPlane[0]);
>>>          if (skipCost < 64 && skipCost < fencCost && bBidir)
>>>          {
>>>              fencCost = skipCost;
>>> diff -r 4a29e0c5bfaf -r c31884e78044 source/x265.h
>>> --- a/source/x265.h Fri Nov 08 15:30:50 2019 +0530
>>> +++ b/source/x265.h Wed Sep 11 15:38:06 2019 +0530
>>> @@ -1856,6 +1856,9 @@
>>>
>>>      /* Enables histogram based scenecut detection algorithm to detect
>>> scenecuts. Default disabled */
>>>      int      bHistBasedSceneCut;
>>> +
>>> +    /* Enable HME search ranges for L0, L1 and L2 respectively. */
>>> +    int       hmeRange[3];
>>>  } x265_param;
>>>
>>>  /* x265_param_alloc:
>>> diff -r 4a29e0c5bfaf -r c31884e78044 source/x265cli.h
>>> --- a/source/x265cli.h Fri Nov 08 15:30:50 2019 +0530
>>> +++ b/source/x265cli.h Wed Sep 11 15:38:06 2019 +0530
>>> @@ -351,6 +351,7 @@
>>>  #endif
>>>      { "cll", no_argument, NULL, 0 },
>>>      { "no-cll", no_argument, NULL, 0 },
>>> +    { "hme-range", required_argument, NULL, 0 },
>>>      { 0, 0, 0, 0 },
>>>      { 0, 0, 0, 0 },
>>>      { 0, 0, 0, 0 },
>>> @@ -479,6 +480,7 @@
>>>      H1("   --[no-]temporal-mvp           Enable temporal MV predictors.
>>> Default %s\n", OPT(param->bEnableTemporalMvp));
>>>      H1("   --[no-]hme                    Enable Hierarchical Motion
>>> Estimation. Default %s\n", OPT(param->bEnableHME));
>>>      H1("   --hme-search <string>         Motion search-method for HME
>>> L0,L1 and L2. Default(L0,L1,L2) is %d,%d,%d\n", param->hmeSearchMethod[0],
>>> param->hmeSearchMethod[1], param->hmeSearchMethod[2]);
>>> +    H1("   --hme-range <int>,<int>,<int> Motion search-range for HME
>>> L0,L1 and L2. Default(L0,L1,L2) is %d,%d,%d\n", param->hmeRange[0],
>>> param->hmeRange[1], param->hmeRange[2]);
>>>      H0("\nSpatial / intra options:\n");
>>>      H0("   --[no-]strong-intra-smoothing Enable strong intra smoothing
>>> for 32x32 blocks. Default %s\n", OPT(param->bEnableStrongIntraSmoothing));
>>>      H0("   --[no-]constrained-intra      Constrained intra prediction
>>> (use only intra coded reference pixels) Default %s\n",
>>> OPT(param->bEnableConstrainedIntra));
>>> _______________________________________________
>>> x265-devel mailing list
>>> x265-devel at videolan.org
>>> https://mailman.videolan.org/listinfo/x265-devel
>>>
>>
>>
>> --
>> Regards,
>> *Aruna Matheswaran,*
>> Video Codec Engineer,
>> Media & AI analytics BU,
>>
>>
>>
>> _______________________________________________
>> x265-devel mailing list
>> x265-devel at videolan.org
>> https://mailman.videolan.org/listinfo/x265-devel
>>
>

-- 
Regards,
*Aruna Matheswaran,*
Video Codec Engineer,
Media & AI analytics BU,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20191202/8fab60ab/attachment-0001.html>


More information about the x265-devel mailing list