[x265] [PATCH 1 of 2] analysis-save/load: Enforce resolution and maxCUSize constraints in non-dyadic

Aruna Matheswaran aruna at multicorewareinc.com
Tue Jan 28 10:18:40 CET 2020


Pushed to default.

On Fri, Jan 24, 2020 at 11:12 AM Aruna Matheswaran <
aruna at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Aruna Matheswaran <aruna at multicorewareinc.com>
> # Date 1579629937 -19800
> #      Tue Jan 21 23:35:37 2020 +0530
> # Node ID ba9cb149de98b7ad753686d155155419d1ea1d50
> # Parent  acc5d16999e2faf6e75ecc1df9a01c1953ebaf8c
> analysis-save/load: Enforce resolution and maxCUSize constraints in
> non-dyadic
> analysis load only if analysis-load-reuse-level > 1.
>
> This patch removes resolution and maxCUSize constraints in
> analysis-load-reuse-level 1 as it re-uses only frame level info.
>
> It also fixes the encoder crashes that were present earlier due to
> 1) Unwanted analysis load validation failures in re-use level 10
> 2) Incorrect memory allocation for multi-pass-opt-analysis/distortion
>
> diff -r acc5d16999e2 -r ba9cb149de98 source/encoder/api.cpp
> --- a/source/encoder/api.cpp    Mon Jan 20 18:07:59 2020 +0530
> +++ b/source/encoder/api.cpp    Tue Jan 21 23:35:37 2020 +0530
> @@ -812,13 +812,14 @@
>      if (!isMultiPassOpt && !(param->bAnalysisType == AVC_INFO))
>          CHECKED_MALLOC_ZERO(analysis->wt, x265_weight_param, numPlanes *
> numDir);
>
> -    if (maxReuseLevel < 2)
> -        return;
> +    //Allocate memory for intraData pointer
> +    if ((maxReuseLevel > 1) || isMultiPassOpt)
> +    {
> +        CHECKED_MALLOC_ZERO(intraData, x265_analysis_intra_data, 1);
> +        CHECKED_MALLOC(intraData->depth, uint8_t, analysis->numPartitions
> * analysis->numCUsInFrame);
> +    }
>
> -    //Allocate memory for intraData pointer
> -    CHECKED_MALLOC_ZERO(intraData, x265_analysis_intra_data, 1);
> -    CHECKED_MALLOC(intraData->depth, uint8_t, analysis->numPartitions *
> analysis->numCUsInFrame);
> -    if (!isMultiPassOpt)
> +    if (maxReuseLevel > 1)
>      {
>          CHECKED_MALLOC_ZERO(intraData->modes, uint8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
>          CHECKED_MALLOC_ZERO(intraData->partSizes, char,
> analysis->numPartitions * analysis->numCUsInFrame);
> @@ -828,17 +829,20 @@
>      }
>      analysis->intraData = intraData;
>
> -    //Allocate memory for interData pointer based on ReuseLevels
> -    CHECKED_MALLOC_ZERO(interData, x265_analysis_inter_data, 1);
> -    CHECKED_MALLOC(interData->depth, uint8_t, analysis->numPartitions *
> analysis->numCUsInFrame);
> -    CHECKED_MALLOC_ZERO(interData->modes, uint8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
> +    if ((maxReuseLevel > 1) || isMultiPassOpt)
> +    {
> +        //Allocate memory for interData pointer based on ReuseLevels
> +        CHECKED_MALLOC_ZERO(interData, x265_analysis_inter_data, 1);
> +        CHECKED_MALLOC(interData->depth, uint8_t, analysis->numPartitions
> * analysis->numCUsInFrame);
> +        CHECKED_MALLOC_ZERO(interData->modes, uint8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
>
> -    if (param->rc.cuTree && !isMultiPassOpt)
> -        CHECKED_MALLOC_ZERO(interData->cuQPOff, int8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
> -    CHECKED_MALLOC_ZERO(interData->mvpIdx[0], uint8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
> -    CHECKED_MALLOC_ZERO(interData->mvpIdx[1], uint8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
> -    CHECKED_MALLOC_ZERO(interData->mv[0], x265_analysis_MV,
> analysis->numPartitions * analysis->numCUsInFrame);
> -    CHECKED_MALLOC_ZERO(interData->mv[1], x265_analysis_MV,
> analysis->numPartitions * analysis->numCUsInFrame);
> +        if (param->rc.cuTree && !isMultiPassOpt)
> +            CHECKED_MALLOC_ZERO(interData->cuQPOff, int8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
> +        CHECKED_MALLOC_ZERO(interData->mvpIdx[0], uint8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
> +        CHECKED_MALLOC_ZERO(interData->mvpIdx[1], uint8_t,
> analysis->numPartitions * analysis->numCUsInFrame);
> +        CHECKED_MALLOC_ZERO(interData->mv[0], x265_analysis_MV,
> analysis->numPartitions * analysis->numCUsInFrame);
> +        CHECKED_MALLOC_ZERO(interData->mv[1], x265_analysis_MV,
> analysis->numPartitions * analysis->numCUsInFrame);
> +    }
>
>      if (maxReuseLevel > 4)
>      {
> @@ -905,9 +909,6 @@
>      if (!isMultiPassOpt && analysis->wt && !(param->bAnalysisType ==
> AVC_INFO))
>          X265_FREE(analysis->wt);
>
> -    if (maxReuseLevel < 2)
> -        return;
> -
>      //Free memory for intraData pointers
>      if (analysis->intraData)
>      {
> diff -r acc5d16999e2 -r ba9cb149de98 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp        Mon Jan 20 18:07:59 2020 +0530
> +++ b/source/encoder/encoder.cpp        Tue Jan 21 23:35:37 2020 +0530
> @@ -4990,8 +4990,8 @@
>          X265_FREAD(&readValue, sizeof(int), 1, m_analysisFileIn,
> &(saveParam->maxCUSize));
>
>          bool isScaledRes = (2 * sourceHeight == curSourceHeight) && (2 *
> sourceWidth == curSourceWidth);
> -        if (!isScaledRes && (sourceHeight != curSourceHeight ||
> sourceWidth != curSourceWidth
> -                            || readValue != (int)m_param->maxCUSize ||
> m_param->scaleFactor))
> +        if (!isScaledRes && (m_param->analysisLoadReuseLevel > 1) &&
> (sourceHeight != curSourceHeight
> +            || sourceWidth != curSourceWidth || readValue !=
> (int)m_param->maxCUSize || m_param->scaleFactor))
>              error = true;
>          else if (isScaledRes && !m_param->scaleFactor)
>              error = true;
>


-- 
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/20200128/b75dcaf4/attachment.html>


More information about the x265-devel mailing list