[x265] [PATCH] analysis: avoid copying lowres vbv data when vbv is disabled

Ashok Kumar Mishra ashok at multicorewareinc.com
Fri Dec 22 09:08:03 CET 2017


On Fri, Dec 22, 2017 at 10:43 AM, Divya Manivannan <
divya at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Divya Manivannan <divya at multicorewareinc.com>
> # Date 1513250624 -19800
> #      Thu Dec 14 16:53:44 2017 +0530
> # Node ID 5723f3248cd24c8b9f670d503370f644dffe9a6f
> # Parent  7a6d244c922b5e9180a0e28363ce578bea0c1d02
> analysis: avoid copying lowres vbv data when vbv is disabled
>
> diff -r 7a6d244c922b -r 5723f3248cd2 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp        Thu Dec 21 09:09:46 2017 +0530
> +++ b/source/encoder/encoder.cpp        Thu Dec 14 16:53:44 2017 +0530
> @@ -1047,11 +1047,14 @@
>                  inFrame->m_lowres.sliceType = sliceType;
>                  inFrame->m_lowres.bKeyframe = !!inFrame->m_analysisData.
> lookahead.keyframe;
>                  inFrame->m_lowres.bLastMiniGopBFrame =
> !!inFrame->m_analysisData.lookahead.lastMiniGopBFrame;
> -                int vbvCount = m_param->lookaheadDepth + m_param->bframes
> + 2;
> -                for (int index = 0; index < vbvCount; index++)
> +                if (m_rateControl->m_isVbv)
>                  {
> -                    inFrame->m_lowres.plannedSatd[index] =
> inFrame->m_analysisData.lookahead.plannedSatd[index];
> -                    inFrame->m_lowres.plannedType[index] =
> inFrame->m_analysisData.lookahead.plannedType[index];
> +                    int vbvCount = m_param->lookaheadDepth +
> m_param->bframes + 2;
> +                    for (int index = 0; index < vbvCount; index++)
> +                    {
> +                        inFrame->m_lowres.plannedSatd[index] =
> inFrame->m_analysisData.lookahead.plannedSatd[index];
> +                        inFrame->m_lowres.plannedType[index] =
> inFrame->m_analysisData.lookahead.plannedType[index];
> +                    }
>                  }
>              }
>          }
> @@ -1165,26 +1168,29 @@
>                          pic_out->analysisData.satdCost *= factor;
>                          pic_out->analysisData.lookahead.keyframe =
> outFrame->m_lowres.bKeyframe;
>                          pic_out->analysisData.lookahead.lastMiniGopBFrame
> = outFrame->m_lowres.bLastMiniGopBFrame;
> -                        int vbvCount = m_param->lookaheadDepth +
> m_param->bframes + 2;
> -                        for (int index = 0; index < vbvCount; index++)
> +                        if (m_rateControl->m_isVbv)
>                          {
> -                            pic_out->analysisData.lookahead.plannedSatd[index]
> = outFrame->m_lowres.plannedSatd[index] * factor;
> -                            pic_out->analysisData.lookahead.plannedType[index]
> = outFrame->m_lowres.plannedType[index];
> +                            int vbvCount = m_param->lookaheadDepth +
> m_param->bframes + 2;
> +                            for (int index = 0; index < vbvCount; index++)
> +                            {
> +                                pic_out->analysisData.lookahead.plannedSatd[index]
> = outFrame->m_lowres.plannedSatd[index] * factor;
> +                                pic_out->analysisData.lookahead.plannedType[index]
> = outFrame->m_lowres.plannedType[index];
> +                            }
> +                            for (uint32_t index = 0; index <
> pic_out->analysisData.numCuInHeight; index++)
> +                            {
> +                                outFrame->m_analysisData.
> lookahead.intraSatdForVbv[index] = outFrame->m_encData->m_rowStat[index].intraSatdForVbv
> * factor;
> +                                outFrame->m_analysisData.lookahead.satdForVbv[index]
> = outFrame->m_encData->m_rowStat[index].satdForVbv * factor;
> +                            }
> +                            pic_out->analysisData.lookahead.intraSatdForVbv
> = outFrame->m_analysisData.lookahead.intraSatdForVbv;
> +                            pic_out->analysisData.lookahead.satdForVbv =
> outFrame->m_analysisData.lookahead.satdForVbv;
> +                            for (uint32_t index = 0; index <
> pic_out->analysisData.numCUsInFrame; index++)
> +                            {
> +                                outFrame->m_analysisData.lookahead.intraVbvCost[index]
> = outFrame->m_encData->m_cuStat[index].intraVbvCost * factor;
> +                                outFrame->m_analysisData.lookahead.vbvCost[index]
> = outFrame->m_encData->m_cuStat[index].vbvCost * factor;
> +                            }
> +                            pic_out->analysisData.lookahead.intraVbvCost
> = outFrame->m_analysisData.lookahead.intraVbvCost;
> +                            pic_out->analysisData.lookahead.vbvCost =
> outFrame->m_analysisData.lookahead.vbvCost;
>                          }
> -                        for (uint32_t index = 0; index <
> pic_out->analysisData.numCuInHeight; index++)
> -                        {
> -                            outFrame->m_analysisData.
> lookahead.intraSatdForVbv[index] = outFrame->m_encData->m_rowStat[index].intraSatdForVbv
> * factor;
> -                            outFrame->m_analysisData.lookahead.satdForVbv[index]
> = outFrame->m_encData->m_rowStat[index].satdForVbv * factor;
> -                        }
> -                        pic_out->analysisData.lookahead.intraSatdForVbv
> = outFrame->m_analysisData.lookahead.intraSatdForVbv;
> -                        pic_out->analysisData.lookahead.satdForVbv =
> outFrame->m_analysisData.lookahead.satdForVbv;
> -                        for (uint32_t index = 0; index <
> pic_out->analysisData.numCUsInFrame; index++)
> -                        {
> -                            outFrame->m_analysisData.lookahead.intraVbvCost[index]
> = outFrame->m_encData->m_cuStat[index].intraVbvCost * factor;
> -                            outFrame->m_analysisData.lookahead.vbvCost[index]
> = outFrame->m_encData->m_cuStat[index].vbvCost * factor;
> -                        }
> -                        pic_out->analysisData.lookahead.intraVbvCost =
> outFrame->m_analysisData.lookahead.intraVbvCost;
> -                        pic_out->analysisData.lookahead.vbvCost =
> outFrame->m_analysisData.lookahead.vbvCost;
>                      }
>                      writeAnalysisFile(&pic_out->analysisData,
> *outFrame->m_encData);
>                      if (m_param->bUseAnalysisFile)
> @@ -1351,15 +1357,18 @@
>              if (m_param->analysisReuseMode == X265_ANALYSIS_LOAD &&
> m_param->bDisableLookahead)
>              {
>                  frameEnc->m_dts = frameEnc->m_analysisData.lookahead.dts;
> -                for (uint32_t index = 0; index < frameEnc->m_analysisData.numCuInHeight;
> index++)
> +                if (m_rateControl->m_isVbv)
>                  {
> -                    frameEnc->m_encData->m_rowStat[index].intraSatdForVbv
> = frameEnc->m_analysisData.lookahead.intraSatdForVbv[index];
> -                    frameEnc->m_encData->m_rowStat[index].satdForVbv =
> frameEnc->m_analysisData.lookahead.satdForVbv[index];
> -                }
> -                for (uint32_t index = 0; index < frameEnc->m_analysisData.numCUsInFrame;
> index++)
> -                {
> -                    frameEnc->m_encData->m_cuStat[index].intraVbvCost =
> frameEnc->m_analysisData.lookahead.intraVbvCost[index];
> -                    frameEnc->m_encData->m_cuStat[index].vbvCost =
> frameEnc->m_analysisData.lookahead.vbvCost[index];
> +                    for (uint32_t index = 0; index <
> frameEnc->m_analysisData.numCuInHeight; index++)
> +                    {
> +                        frameEnc->m_encData->m_rowStat[index].intraSatdForVbv
> = frameEnc->m_analysisData.lookahead.intraSatdForVbv[index];
> +                        frameEnc->m_encData->m_rowStat[index].satdForVbv
> = frameEnc->m_analysisData.lookahead.satdForVbv[index];
> +                    }
> +                    for (uint32_t index = 0; index <
> frameEnc->m_analysisData.numCUsInFrame; index++)
> +                    {
> +                        frameEnc->m_encData->m_cuStat[index].intraVbvCost
> = frameEnc->m_analysisData.lookahead.intraVbvCost[index];
> +                        frameEnc->m_encData->m_cuStat[index].vbvCost =
> frameEnc->m_analysisData.lookahead.vbvCost[index];
> +                    }
>                  }
>              }
>              if (m_param->searchMethod == X265_SEA &&
> frameEnc->m_lowres.sliceType != X265_TYPE_B)
> @@ -3032,7 +3041,7 @@
>  {
>      X265_CHECK(analysis->sliceType, "invalid slice type\n");
>      analysis->interData = analysis->intraData = NULL;
> -    if (m_param->bDisableLookahead)
> +    if (m_param->bDisableLookahead && m_rateControl->m_isVbv)
>      {
>          CHECKED_MALLOC_ZERO(analysis->lookahead.intraSatdForVbv,
> uint32_t, analysis->numCuInHeight);
>          CHECKED_MALLOC_ZERO(analysis->lookahead.satdForVbv, uint32_t,
> analysis->numCuInHeight);
> @@ -3106,7 +3115,7 @@
>
>  void Encoder::freeAnalysis(x265_analysis_data* analysis)
>  {
> -    if (m_param->bDisableLookahead)
> +    if (m_param->bDisableLookahead && m_rateControl->m_isVbv)
>      {
>          X265_FREE(analysis->lookahead.satdForVbv);
>          X265_FREE(analysis->lookahead.intraSatdForVbv);
> @@ -3312,7 +3321,7 @@
>
>      /* Memory is allocated for inter and intra analysis data based on the
> slicetype */
>      allocAnalysis(analysis);
> -    if (m_param->bDisableLookahead)
> +    if (m_param->bDisableLookahead && m_rateControl->m_isVbv)
>      {
>          X265_FREAD(analysis->lookahead.intraVbvCost, sizeof(uint32_t),
> analysis->numCUsInFrame, m_analysisFile, picData->lookahead.intraVbvCost);
>          X265_FREAD(analysis->lookahead.vbvCost, sizeof(uint32_t),
> analysis->numCUsInFrame, m_analysisFile, picData->lookahead.vbvCost);
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
>
Thanks, Pushed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20171222/9b62135e/attachment-0001.html>


More information about the x265-devel mailing list