[x265] [PATCH] analysis: simplify inter analysis structure to share more inter analysis data

Deepthi Nandakumar deepthi at multicorewareinc.com
Sun Jan 11 14:56:36 CET 2015


Pushed - with the following change

On Thu, Jan 8, 2015 at 5:35 PM, <gopu at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Gopu Govindaswamy <gopu at multicorewareinc.com>
> # Date 1419397499 -19800
> #      Wed Dec 24 10:34:59 2014 +0530
> # Node ID 24da7b0accdafb1f9e7e54182c114cb264d09bab
> # Parent  ee358bb8ea82a68c5efe56120f8a2657ff59c983
> analysis: simplify inter analysis structure to share more inter analysis
> data
>
> diff -r ee358bb8ea82 -r 24da7b0accda source/common/common.h
> --- a/source/common/common.h    Wed Jan 07 15:18:13 2015 +0530
> +++ b/source/common/common.h    Wed Dec 24 10:34:59 2014 +0530
> @@ -356,7 +356,7 @@
>  /* Stores inter (motion estimation) analysis data for a single frame */
>  struct analysis_inter_data
>  {
> -    int      ref;
> +    int32_t*    ref;
>  };
>
>  /* Stores intra analysis data for a single frame. This struct needs
> better packing */
> diff -r ee358bb8ea82 -r 24da7b0accda source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp       Wed Jan 07 15:18:13 2015 +0530
> +++ b/source/encoder/analysis.cpp       Wed Dec 24 10:34:59 2014 +0530
> @@ -133,9 +133,14 @@
>      uint32_t numPartition = ctu.m_numPartitions;
>      if (m_param->analysisMode)
>      {
> -        m_reuseIntraDataCTU = (analysis_intra_data
> *)m_frame->m_analysisData.intraData;
> -        int numPredDir = m_slice->isInterP() ? 1 : 2;
> -        m_reuseInterDataCTU = (analysis_inter_data
> *)m_frame->m_analysisData.interData + ctu.m_cuAddr *
> X265_MAX_PRED_MODE_PER_CTU * numPredDir;
> +        if (m_slice->m_sliceType == I_SLICE)
> +            m_reuseIntraDataCTU = (analysis_intra_data
> *)m_frame->m_analysisData.intraData;
> +        else
> +        {
> +            int numPredDir = m_slice->isInterP() ? 1 : 2;
> +            m_reuseInterDataCTU = (analysis_inter_data
> *)m_frame->m_analysisData.interData;
> +            reuseRef = &m_reuseInterDataCTU->ref[ctu.m_cuAddr *
> X265_MAX_PRED_MODE_PER_CTU * numPredDir];
> +        }
>      }
>
>      if (m_slice->m_sliceType == I_SLICE)
> @@ -1436,8 +1441,8 @@
>              MotionData* bestME = interMode.bestME[part];
>              for (int32_t i = 0; i < numPredDir; i++)
>              {
> -                bestME[i].ref = m_reuseInterDataCTU->ref;
> -                m_reuseInterDataCTU++;
> +                bestME[i].ref = *reuseRef;
> +                reuseRef++;
>              }
>          }
>      }
> @@ -1464,8 +1469,8 @@
>                  MotionData* bestME = interMode.bestME[puIdx];
>                  for (int32_t i = 0; i < numPredDir; i++)
>                  {
> -                    m_reuseInterDataCTU->ref = bestME[i].ref;
> -                    m_reuseInterDataCTU++;
> +                    *reuseRef = bestME[i].ref;
> +                    reuseRef++;
>                  }
>              }
>          }
> @@ -1491,8 +1496,8 @@
>              MotionData* bestME = interMode.bestME[puIdx];
>              for (int32_t i = 0; i < numPredDir; i++)
>              {
> -                bestME[i].ref = m_reuseInterDataCTU->ref;
> -                m_reuseInterDataCTU++;
> +                bestME[i].ref = *reuseRef;
> +                reuseRef++;
>              }
>          }
>      }
> @@ -1508,8 +1513,8 @@
>                  MotionData* bestME = interMode.bestME[puIdx];
>                  for (int32_t i = 0; i < numPredDir; i++)
>                  {
> -                    m_reuseInterDataCTU->ref = bestME[i].ref;
> -                    m_reuseInterDataCTU++;
> +                    *reuseRef = bestME[i].ref;
> +                    reuseRef++;
>                  }
>              }
>          }
> diff -r ee358bb8ea82 -r 24da7b0accda source/encoder/analysis.h
> --- a/source/encoder/analysis.h Wed Jan 07 15:18:13 2015 +0530
> +++ b/source/encoder/analysis.h Wed Dec 24 10:34:59 2014 +0530
> @@ -77,6 +77,7 @@
>      /* Analysis data for load/save modes, keeps getting incremented as
> CTU analysis proceeds and data is consumed or read */
>      analysis_intra_data* m_reuseIntraDataCTU;
>      analysis_inter_data* m_reuseInterDataCTU;
> +    int32_t* reuseRef;
>      Analysis();
>      bool create(ThreadLocalData* tld);
>      void destroy();
> diff -r ee358bb8ea82 -r 24da7b0accda source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp        Wed Jan 07 15:18:13 2015 +0530
> +++ b/source/encoder/encoder.cpp        Wed Dec 24 10:34:59 2014 +0530
> @@ -1576,7 +1576,8 @@
>      else
>      {
>          analysis_inter_data *interData =
> (analysis_inter_data*)analysis->interData;
> -        CHECKED_MALLOC(interData, analysis_inter_data,
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2);
> +        CHECKED_MALLOC_ZERO(interData, analysis_inter_data, 1);
> +        CHECKED_MALLOC(interData->ref, int32_t, analysis->numCUsInFrame *
> X265_MAX_PRED_MODE_PER_CTU * 2);
>          analysis->interData = interData;
>      }
>      return;
> @@ -1596,7 +1597,10 @@
>          X265_FREE(analysis->intraData);
>      }
>      else
> +    {
> +        X265_FREE(((analysis_inter_data*)analysis->interData)->ref);
>          X265_FREE(analysis->interData);
> +    }
>  }
>
>  void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc)
> @@ -1657,13 +1661,13 @@
>      }
>      else if (analysis->sliceType == X265_TYPE_P)
>      {
> -        X265_FREAD(analysis->interData, sizeof(analysis_inter_data),
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);
> +        X265_FREAD(((analysis_inter_data *)analysis->interData)->ref,
> sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU,
> m_analysisFile);
>          consumedBytes += frameRecordSize;
>          totalConsumedBytes = consumedBytes;
>      }
>      else
>      {
> -        X265_FREAD(analysis->interData, sizeof(analysis_inter_data),
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);
> +        X265_FREAD(((analysis_inter_data *)analysis->interData)->ref,
> sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2,
> m_analysisFile);
>          consumedBytes += frameRecordSize;
>      }
>  #undef X265_FREAD
> @@ -1687,9 +1691,9 @@
>      if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType ==
> X265_TYPE_I)
>          analysis->frameRecordSize += sizeof(uint8_t) *
> analysis->numCUsInFrame * analysis->numPartitions * 3;
>      else if (analysis->sliceType == X265_TYPE_P)
> -        analysis->frameRecordSize += sizeof(analysis_inter_data) *
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU;
> +        analysis->frameRecordSize += sizeof(int32_t) *
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU;
>      else
> -        analysis->frameRecordSize += sizeof(analysis_inter_data) *
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2;
> +        analysis->frameRecordSize += sizeof(int32_t) *
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2;
>
> The above change is not required, especially as I expect you'll add more
fields to analysis_inter_data shortly.


>      X265_FWRITE(&analysis->frameRecordSize, sizeof(uint32_t), 1,
> m_analysisFile);
>      X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFile);
> @@ -1705,11 +1709,11 @@
>      }
>      else if (analysis->sliceType == X265_TYPE_P)
>      {
> -        X265_FWRITE(analysis->interData, sizeof(analysis_inter_data),
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU, m_analysisFile);
> +        X265_FWRITE(((analysis_inter_data *)analysis->interData)->ref,
> sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU,
> m_analysisFile);
>      }
>      else
>      {
> -        X265_FWRITE(analysis->interData, sizeof(analysis_inter_data),
> analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2, m_analysisFile);
> +        X265_FWRITE(((analysis_inter_data *)analysis->interData)->ref,
> sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * 2,
> m_analysisFile);
>      }
>  #undef X265_FWRITE
>  }
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20150111/dfeefb96/attachment.html>


More information about the x265-devel mailing list