<div dir="ltr">Thanks for the comments - I've fixed your nits and the destructor fix now. I'd sent another patch after fixing the incorrect merge, but have new edits on top from your comments. Will send that too now.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Pradeep Ramachandran, PhD<div>Solution Architect,</div><div>Multicoreware Inc.</div><div>Ph:   +91 99627 82018</div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Aug 12, 2015 at 1:23 PM, Steve Borho <span dir="ltr"><<a href="mailto:steve@borho.org" target="_blank">steve@borho.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 08/12, Pradeep wrote:<br>
> # HG changeset patch<br>
> # User Pradeep<br>
> # Date 1439332317 0<br>
> #      Tue Aug 11 22:31:57 2015 +0000<br>
> # Node ID 1b2e5e8ccb850d83bfae57b5e2dec623330f558d<br>
> # Parent  faecefdb2ae90c031dfda5c11d14b9ba7005257b<br>
> cleanup: simplify slice ref lists; moving shared offset buffers into SPS<br>
><br>
> Stripping down Steve's experimental patches into separate patches<br>
><br>
> Part 1:<br>
> Rename slice.m_refPicList to m_refFrameList since it is an array of Frame<br>
> pointers, and make a new slice.m_refReconPicList array which points directly<br>
> to the motion reference PicYuv buffers (bypassing the Frame structure)<br>
><br>
> The shared offset buffers were moved from the top-level encoder into the SPS<br>
> structure so the FrameData functions could use them directly (avoiding a major<br>
> layering violations). The offset buffers are computed based on SPS values, so it<br>
> seems minimally ugly to keep them there.<br>
><br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/common/cudata.cpp<br>
> --- a/source/common/cudata.cpp        Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/common/cudata.cpp        Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -1676,7 +1676,7 @@<br>
>          if (tempRefIdx != -1)<br>
>          {<br>
>              uint32_t cuAddr = neighbours[MD_COLLOCATED].cuAddr[picList];<br>
> -            const Frame* colPic = m_slice->m_refPicList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];<br>
> +            const Frame* colPic = m_slice->m_refFrameList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];<br>
>              const CUData* colCU = colPic->m_encData->getPicCTU(cuAddr);<br>
><br>
>              // Scale the vector<br>
> @@ -1857,7 +1857,7 @@<br>
><br>
>  bool CUData::getColMVP(MV& outMV, int& outRefIdx, int picList, int cuAddr, int partUnitIdx) const<br>
>  {<br>
> -    const Frame* colPic = m_slice->m_refPicList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];<br>
> +    const Frame* colPic = m_slice->m_refFrameList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];<br>
>      const CUData* colCU = colPic->m_encData->getPicCTU(cuAddr);<br>
><br>
>      uint32_t absPartAddr = partUnitIdx & TMVP_UNIT_MASK;<br>
> @@ -1892,7 +1892,7 @@<br>
>  // Cache the collocated MV.<br>
>  bool CUData::getCollocatedMV(int cuAddr, int partUnitIdx, InterNeighbourMV *neighbour) const<br>
>  {<br>
> -    const Frame* colPic = m_slice->m_refPicList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];<br>
> +    const Frame* colPic = m_slice->m_refFrameList[m_slice->isInterB() && !m_slice->m_colFromL0Flag][m_slice->m_colRefIdx];<br>
>      const CUData* colCU = colPic->m_encData->getPicCTU(cuAddr);<br>
><br>
>      uint32_t absPartAddr = partUnitIdx & TMVP_UNIT_MASK;<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/common/deblock.cpp<br>
> --- a/source/common/deblock.cpp       Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/common/deblock.cpp       Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -209,8 +209,8 @@<br>
>      const Slice* const sliceQ = cuQ->m_slice;<br>
>      const Slice* const sliceP = cuP->m_slice;<br>
><br>
> -    const Frame* refP0 = sliceP->getRefPic(0, cuP->m_refIdx[0][partP]);<br>
> -    const Frame* refQ0 = sliceQ->getRefPic(0, cuQ->m_refIdx[0][partQ]);<br>
> +    const Frame* refP0 = sliceP->m_refFrameList[0][cuP->m_refIdx[0][partP]];<br>
> +    const Frame* refQ0 = sliceQ->m_refFrameList[0][cuQ->m_refIdx[0][partQ]];<br>
>      const MV& mvP0 = refP0 ? cuP->m_mv[0][partP] : zeroMv;<br>
>      const MV& mvQ0 = refQ0 ? cuQ->m_mv[0][partQ] : zeroMv;<br>
><br>
> @@ -221,8 +221,8 @@<br>
>      }<br>
><br>
>      // (sliceQ->isInterB() || sliceP->isInterB())<br>
> -    const Frame* refP1 = sliceP->getRefPic(1, cuP->m_refIdx[1][partP]);<br>
> -    const Frame* refQ1 = sliceQ->getRefPic(1, cuQ->m_refIdx[1][partQ]);<br>
> +    const Frame* refP1 = sliceP->m_refFrameList[1][cuP->m_refIdx[1][partP]];<br>
> +    const Frame* refQ1 = sliceQ->m_refFrameList[1][cuQ->m_refIdx[1][partQ]];<br>
>      const MV& mvP1 = refP1 ? cuP->m_mv[1][partP] : zeroMv;<br>
>      const MV& mvQ1 = refQ1 ? cuQ->m_mv[1][partQ] : zeroMv;<br>
><br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/common/frame.cpp<br>
> --- a/source/common/frame.cpp Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/common/frame.cpp Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -56,7 +56,7 @@<br>
>      m_encData = new FrameData;<br>
>      m_reconPic = new PicYuv;<br>
>      m_encData->m_reconPic = m_reconPic;<br>
> -    bool ok = m_encData->create(param, sps) && m_reconPic->create(param->sourceWidth, param->sourceHeight, param->internalCsp);<br>
> +    bool ok = m_encData->create(*param, sps) && m_reconPic->create(param->sourceWidth, param->sourceHeight, param->internalCsp);<br>
>      if (ok)<br>
>      {<br>
>          /* initialize right border of m_reconpicYuv as SAO may read beyond the<br>
> @@ -65,6 +65,12 @@<br>
>          memset(m_reconPic->m_picOrg[0], 0, sizeof(pixel) * m_reconPic->m_stride * maxHeight);<br>
>          memset(m_reconPic->m_picOrg[1], 0, sizeof(pixel) * m_reconPic->m_strideC * (maxHeight >> m_reconPic->m_vChromaShift));<br>
>          memset(m_reconPic->m_picOrg[2], 0, sizeof(pixel) * m_reconPic->m_strideC * (maxHeight >> m_reconPic->m_vChromaShift));<br>
> +<br>
> +        /* use pre-calculated cu/pu offsets cached in the SPS structure */<br>
> +        m_reconPic->m_cuOffsetC = sps.cuOffsetC;<br>
> +        m_reconPic->m_cuOffsetY = sps.cuOffsetY;<br>
> +        m_reconPic->m_buOffsetC = sps.buOffsetC;<br>
> +        m_reconPic->m_buOffsetY = sps.buOffsetY;<br>
>      }<br>
>      return ok;<br>
>  }<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/common/framedata.cpp<br>
> --- a/source/common/framedata.cpp     Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/common/framedata.cpp     Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -31,15 +31,15 @@<br>
>      memset(this, 0, sizeof(*this));<br>
>  }<br>
><br>
> -bool FrameData::create(x265_param *param, const SPS& sps)<br>
> +bool FrameData::create(const x265_param& param, const SPS& sps)<br>
>  {<br>
> -    m_param = param;<br>
> +    m_param = &param;<br>
>      m_slice  = new Slice;<br>
>      m_picCTU = new CUData[sps.numCUsInFrame];<br>
><br>
> -    m_cuMemPool.create(0, param->internalCsp, sps.numCUsInFrame);<br>
> +    m_cuMemPool.create(0, param.internalCsp, sps.numCUsInFrame);<br>
>      for (uint32_t ctuAddr = 0; ctuAddr < sps.numCUsInFrame; ctuAddr++)<br>
> -        m_picCTU[ctuAddr].initialize(m_cuMemPool, 0, param->internalCsp, ctuAddr);<br>
> +        m_picCTU[ctuAddr].initialize(m_cuMemPool, 0, param.internalCsp, ctuAddr);<br>
><br>
>      CHECKED_MALLOC(m_cuStat, RCStatCU, sps.numCUsInFrame);<br>
>      CHECKED_MALLOC(m_rowStat, RCStatRow, sps.numCuInHeight);<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/common/framedata.h<br>
> --- a/source/common/framedata.h       Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/common/framedata.h       Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -96,7 +96,7 @@<br>
><br>
>      Slice*         m_slice;<br>
>      SAOParam*      m_saoParam;<br>
> -    x265_param*    m_param;<br>
> +    const x265_param* m_param;<br>
><br>
>      FrameData*     m_freeListNext;<br>
>      PicYuv*        m_reconPic;<br>
> @@ -142,11 +142,11 @@<br>
><br>
>      FrameData();<br>
><br>
> -    bool create(x265_param *param, const SPS& sps);<br>
> +    bool create(const x265_param& param, const SPS& sps);<br>
>      void reinit(const SPS& sps);<br>
>      void destroy();<br>
><br>
> -    CUData* getPicCTU(uint32_t ctuAddr) { return &m_picCTU[ctuAddr]; }<br>
> +    inline CUData* getPicCTU(uint32_t ctuAddr) { return &m_picCTU[ctuAddr]; }<br>
>  };<br>
>  }<br>
><br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/common/predict.cpp<br>
> --- a/source/common/predict.cpp       Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/common/predict.cpp       Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -109,18 +109,18 @@<br>
>              ShortYuv& shortYuv = m_predShortYuv[0];<br>
><br>
>              if (bLuma)<br>
> -                predInterLumaShort(pu, shortYuv, *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> +                predInterLumaShort(pu, shortYuv, *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
>              if (bChroma)<br>
> -                predInterChromaShort(pu, shortYuv, *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> +                predInterChromaShort(pu, shortYuv, *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
><br>
>              addWeightUni(pu, predYuv, shortYuv, wv0, bLuma, bChroma);<br>
>          }<br>
>          else<br>
>          {<br>
>              if (bLuma)<br>
> -                predInterLumaPixel(pu, predYuv, *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> +                predInterLumaPixel(pu, predYuv, *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
>              if (bChroma)<br>
> -                predInterChromaPixel(pu, predYuv, *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> +                predInterChromaPixel(pu, predYuv, *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
>          }<br>
>      }<br>
>      else<br>
> @@ -179,13 +179,13 @@<br>
><br>
>              if (bLuma)<br>
>              {<br>
> -                predInterLumaShort(pu, m_predShortYuv[0], *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> -                predInterLumaShort(pu, m_predShortYuv[1], *cu.m_slice->m_refPicList[1][refIdx1]->m_reconPic, mv1);<br>
> +                predInterLumaShort(pu, m_predShortYuv[0], *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
> +                predInterLumaShort(pu, m_predShortYuv[1], *cu.m_slice->m_refReconPicList[1][refIdx1], mv1);<br>
>              }<br>
>              if (bChroma)<br>
>              {<br>
> -                predInterChromaShort(pu, m_predShortYuv[0], *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> -                predInterChromaShort(pu, m_predShortYuv[1], *cu.m_slice->m_refPicList[1][refIdx1]->m_reconPic, mv1);<br>
> +                predInterChromaShort(pu, m_predShortYuv[0], *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
> +                predInterChromaShort(pu, m_predShortYuv[1], *cu.m_slice->m_refReconPicList[1][refIdx1], mv1);<br>
>              }<br>
><br>
>              if (pwp0 && pwp1 && (pwp0->bPresentFlag || pwp1->bPresentFlag))<br>
> @@ -203,18 +203,18 @@<br>
>                  ShortYuv& shortYuv = m_predShortYuv[0];<br>
><br>
>                  if (bLuma)<br>
> -                    predInterLumaShort(pu, shortYuv, *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> +                    predInterLumaShort(pu, shortYuv, *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
>                  if (bChroma)<br>
> -                    predInterChromaShort(pu, shortYuv, *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> +                    predInterChromaShort(pu, shortYuv, *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
><br>
>                  addWeightUni(pu, predYuv, shortYuv, wv0, bLuma, bChroma);<br>
>              }<br>
>              else<br>
>              {<br>
>                  if (bLuma)<br>
> -                    predInterLumaPixel(pu, predYuv, *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> +                    predInterLumaPixel(pu, predYuv, *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
>                  if (bChroma)<br>
> -                    predInterChromaPixel(pu, predYuv, *cu.m_slice->m_refPicList[0][refIdx0]->m_reconPic, mv0);<br>
> +                    predInterChromaPixel(pu, predYuv, *cu.m_slice->m_refReconPicList[0][refIdx0], mv0);<br>
>              }<br>
>          }<br>
>          else<br>
> @@ -230,18 +230,18 @@<br>
>                  ShortYuv& shortYuv = m_predShortYuv[0];<br>
><br>
>                  if (bLuma)<br>
> -                    predInterLumaShort(pu, shortYuv, *cu.m_slice->m_refPicList[1][refIdx1]->m_reconPic, mv1);<br>
> +                    predInterLumaShort(pu, shortYuv, *cu.m_slice->m_refReconPicList[1][refIdx1], mv1);<br>
>                  if (bChroma)<br>
> -                    predInterChromaShort(pu, shortYuv, *cu.m_slice->m_refPicList[1][refIdx1]->m_reconPic, mv1);<br>
> +                    predInterChromaShort(pu, shortYuv, *cu.m_slice->m_refReconPicList[1][refIdx1], mv1);<br>
><br>
>                  addWeightUni(pu, predYuv, shortYuv, wv0, bLuma, bChroma);<br>
>              }<br>
>              else<br>
>              {<br>
>                  if (bLuma)<br>
> -                    predInterLumaPixel(pu, predYuv, *cu.m_slice->m_refPicList[1][refIdx1]->m_reconPic, mv1);<br>
> +                    predInterLumaPixel(pu, predYuv, *cu.m_slice->m_refReconPicList[1][refIdx1], mv1);<br>
>                  if (bChroma)<br>
> -                    predInterChromaPixel(pu, predYuv, *cu.m_slice->m_refPicList[1][refIdx1]->m_reconPic, mv1);<br>
> +                    predInterChromaPixel(pu, predYuv, *cu.m_slice->m_refReconPicList[1][refIdx1], mv1);<br>
>              }<br>
>          }<br>
>      }<br>
> @@ -600,8 +600,9 @@<br>
>      int tuSize = 1 << intraNeighbors.log2TrSize;<br>
>      int tuSize2 = tuSize << 1;<br>
><br>
> -    pixel* adiOrigin = cu.m_encData->m_reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + puAbsPartIdx);<br>
> -    intptr_t picStride = cu.m_encData->m_reconPic->m_stride;<br>
> +    PicYuv* reconPic = cu.m_encData->m_reconPic;<br>
> +    pixel* adiOrigin = reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + puAbsPartIdx);<br>
> +    intptr_t picStride = reconPic->m_stride;<br>
><br>
>      fillReferenceSamples(adiOrigin, picStride, intraNeighbors, intraNeighbourBuf[0]);<br>
><br>
> @@ -648,8 +649,9 @@<br>
><br>
>  void Predict::initAdiPatternChroma(const CUData& cu, const CUGeom& cuGeom, uint32_t puAbsPartIdx, const IntraNeighbors& intraNeighbors, uint32_t chromaId)<br>
>  {<br>
> -    const pixel* adiOrigin = cu.m_encData->m_reconPic->getChromaAddr(chromaId, cu.m_cuAddr, cuGeom.absPartIdx + puAbsPartIdx);<br>
> -    intptr_t picStride = cu.m_encData->m_reconPic->m_strideC;<br>
> +    PicYuv* reconPic = cu.m_encData->m_reconPic;<br>
> +    const pixel* adiOrigin = reconPic->getChromaAddr(chromaId, cu.m_cuAddr, cuGeom.absPartIdx + puAbsPartIdx);<br>
> +    intptr_t picStride = reconPic->m_strideC;<br>
><br>
>      fillReferenceSamples(adiOrigin, picStride, intraNeighbors, intraNeighbourBuf[0]);<br>
><br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/common/slice.cpp<br>
> --- a/source/common/slice.cpp Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/common/slice.cpp Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -33,7 +33,9 @@<br>
>  {<br>
>      if (m_sliceType == I_SLICE)<br>
>      {<br>
> -        memset(m_refPicList, 0, sizeof(m_refPicList));<br>
> +        memset(m_refFrameList, 0, sizeof(m_refFrameList));<br>
> +        memset(m_refReconPicList, 0, sizeof(m_refReconPicList));<br>
> +        memset(m_refPOCList, 0, sizeof(m_refPOCList));<br>
>          m_numRefIdx[1] = m_numRefIdx[0] = 0;<br>
>          return;<br>
>      }<br>
> @@ -106,13 +108,13 @@<br>
>      {<br>
>          cIdx = rIdx % numPocTotalCurr;<br>
>          X265_CHECK(cIdx >= 0 && cIdx < numPocTotalCurr, "RPS index check fail\n");<br>
> -        m_refPicList[0][rIdx] = rpsCurrList0[cIdx];<br>
> +        m_refFrameList[0][rIdx] = rpsCurrList0[cIdx];<br>
>      }<br>
><br>
>      if (m_sliceType != B_SLICE)<br>
>      {<br>
>          m_numRefIdx[1] = 0;<br>
> -        memset(m_refPicList[1], 0, sizeof(m_refPicList[1]));<br>
> +        memset(m_refFrameList[1], 0, sizeof(m_refFrameList[1]));<br>
>      }<br>
>      else<br>
>      {<br>
> @@ -120,13 +122,13 @@<br>
>          {<br>
>              cIdx = rIdx % numPocTotalCurr;<br>
>              X265_CHECK(cIdx >= 0 && cIdx < numPocTotalCurr, "RPS index check fail\n");<br>
> -            m_refPicList[1][rIdx] = rpsCurrList1[cIdx];<br>
> +            m_refFrameList[1][rIdx] = rpsCurrList1[cIdx];<br>
>          }<br>
>      }<br>
><br>
>      for (int dir = 0; dir < 2; dir++)<br>
>          for (int numRefIdx = 0; numRefIdx < m_numRefIdx[dir]; numRefIdx++)<br>
> -            m_refPOCList[dir][numRefIdx] = m_refPicList[dir][numRefIdx]->m_poc;<br>
> +            m_refPOCList[dir][numRefIdx] = m_refFrameList[dir][numRefIdx]->m_poc;<br>
>  }<br>
><br>
>  void Slice::disableWeights()<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/common/slice.h<br>
> --- a/source/common/slice.h   Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/common/slice.h   Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -31,6 +31,7 @@<br>
><br>
>  class Frame;<br>
>  class PicList;<br>
> +class PicYuv;<br>
>  class MotionReference;<br>
><br>
>  enum SliceType<br>
> @@ -209,6 +210,13 @@<br>
><br>
>  struct SPS<br>
>  {<br>
> +    /* cached PicYuv offset arrays, shared by all instances of<br>
> +    * PicYuv created by this encoder */<br>
<br>
</div></div>w/s nit. editors generally mangle multi-line comments when they are<br>
pasted.<br>
<span class=""><br>
> +    intptr_t* cuOffsetY;<br>
> +    intptr_t* cuOffsetC;<br>
> +    intptr_t* buOffsetY;<br>
> +    intptr_t* buOffsetC;<br>
> +<br>
>      int      chromaFormatIdc;        // use param<br>
>      uint32_t picWidthInLumaSamples;  // use param<br>
>      uint32_t picHeightInLumaSamples; // use param<br>
> @@ -242,6 +250,11 @@<br>
><br>
>      Window   conformanceWindow;<br>
>      VUI      vuiParameters;<br>
> +<br>
> +    SPS()<br>
> +    {<br>
> +        memset(this, 0, sizeof(*this));<br>
> +    }<br>
<br>
</span>These offset buffers are still created and initalized by<br>
PicYuv::createOffsets(), we should move the alloc/init/free logic into<br>
the SPS class (in a later patch).<br>
<div><div class="h5"><br>
>  };<br>
><br>
>  struct PPS<br>
> @@ -321,7 +334,8 @@<br>
>      uint32_t    m_colRefIdx;       // never modified<br>
><br>
>      int         m_numRefIdx[2];<br>
> -    Frame*      m_refPicList[2][MAX_NUM_REF + 1];<br>
> +    Frame*      m_refFrameList[2][MAX_NUM_REF + 1];<br>
> +    PicYuv*     m_refReconPicList[2][MAX_NUM_REF + 1];<br>
>      int         m_refPOCList[2][MAX_NUM_REF + 1];<br>
><br>
>      uint32_t    m_maxNumMergeCand; // use param<br>
> @@ -332,14 +346,9 @@<br>
>          m_lastIDR = 0;<br>
>          m_sLFaseFlag = true;<br>
>          m_numRefIdx[0] = m_numRefIdx[1] = 0;<br>
> -        for (int i = 0; i < MAX_NUM_REF; i++)<br>
> -        {<br>
> -            m_refPicList[0][i] = NULL;<br>
> -            m_refPicList[1][i] = NULL;<br>
> -            m_refPOCList[0][i] = 0;<br>
> -            m_refPOCList[1][i] = 0;<br>
> -        }<br>
> -<br>
> +        memset(m_refFrameList, 0, sizeof(m_refFrameList));<br>
> +        memset(m_refReconPicList, 0, sizeof(m_refReconPicList));<br>
> +        memset(m_refPOCList, 0, sizeof(m_refPOCList));<br>
>          disableWeights();<br>
>      }<br>
><br>
> @@ -347,8 +356,6 @@<br>
><br>
>      void setRefPicList(PicList& picList);<br>
><br>
> -    const Frame* getRefPic(int list, int refIdx) const { return refIdx >= 0 ? m_refPicList[list][refIdx] : NULL; }<br>
> -<br>
>      bool getRapPicFlag() const<br>
>      {<br>
>          return m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/analysis.cpp<br>
> --- a/source/encoder/analysis.cpp     Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/analysis.cpp     Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -757,6 +757,8 @@<br>
>      ModeDepth& md = m_modeDepth[depth];<br>
>      md.bestMode = NULL;<br>
><br>
> +    PicYuv& reconPic = *m_frame->m_reconPic;<br>
> +<br>
>      bool mightSplit = !(cuGeom.flags & CUGeom::LEAF);<br>
>      bool mightNotSplit = !(cuGeom.flags & CUGeom::SPLIT_MANDATORY);<br>
>      uint32_t minDepth = topSkipMinDepth(parentCTU, cuGeom);<br>
> @@ -1051,7 +1053,7 @@<br>
>                          residualTransformQuantIntra(*md.bestMode, cuGeom, 0, 0, tuDepthRange);<br>
>                          getBestIntraModeChroma(*md.bestMode, cuGeom);<br>
>                          residualQTIntraChroma(*md.bestMode, cuGeom, 0, 0);<br>
> -                        md.bestMode->reconYuv.copyFromPicYuv(*m_frame->m_reconPic, cu.m_cuAddr, cuGeom.absPartIdx); // TODO:<br>
> +                        md.bestMode->reconYuv.copyFromPicYuv(reconPic, cu.m_cuAddr, cuGeom.absPartIdx); // TODO:<br>
>                      }<br>
>                  }<br>
>              }<br>
> @@ -1107,7 +1109,7 @@<br>
>      X265_CHECK(md.bestMode->ok(), "best mode is not ok");<br>
>      md.bestMode->cu.copyToPic(depth);<br>
>      if (m_param->rdLevel)<br>
> -        md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_reconPic, cuAddr, cuGeom.absPartIdx);<br>
> +        md.bestMode->reconYuv.copyToPicYuv(reconPic, cuAddr, cuGeom.absPartIdx);<br>
><br>
>      return refMask;<br>
>  }<br>
> @@ -1851,6 +1853,8 @@<br>
><br>
>      cu.copyFromPic(ctu, cuGeom);<br>
><br>
> +    PicYuv& reconPic = *m_frame->m_reconPic;<br>
> +<br>
>      Yuv& fencYuv = m_modeDepth[cuGeom.depth].fencYuv;<br>
>      if (cuGeom.depth)<br>
>          m_modeDepth[0].fencYuv.copyPartToYuv(fencYuv, absPartIdx);<br>
> @@ -1906,7 +1910,6 @@<br>
>          /* residualTransformQuantInter() wrote transformed residual back into<br>
>           * resiYuv. Generate the recon pixels by adding it to the prediction */<br>
><br>
> -        PicYuv& reconPic = *m_frame->m_reconPic;<br>
>          if (cu.m_cbf[0][0])<br>
>              <a href="http://primitives.cu" rel="noreferrer" target="_blank">primitives.cu</a>[sizeIdx].add_ps(reconPic.getLumaAddr(cu.m_cuAddr, absPartIdx), reconPic.m_stride,<br>
>                                            predY, resiYuv.m_buf[0], predYuv.m_size, resiYuv.m_size);<br>
> @@ -1969,7 +1972,7 @@<br>
>      if (m_slice->m_numRefIdx[0])<br>
>      {<br>
>          numRefs++;<br>
> -        const CUData& cu = *m_slice->m_refPicList[0][0]->m_encData->getPicCTU(parentCTU.m_cuAddr);<br>
> +        const CUData& cu = *m_slice->m_refFrameList[0][0]->m_encData->getPicCTU(parentCTU.m_cuAddr);<br>
>          previousQP = cu.m_qp[0];<br>
>          if (!cu.m_cuDepth[cuGeom.absPartIdx])<br>
>              return 0;<br>
> @@ -1983,7 +1986,7 @@<br>
>      if (m_slice->m_numRefIdx[1])<br>
>      {<br>
>          numRefs++;<br>
> -        const CUData& cu = *m_slice->m_refPicList[1][0]->m_encData->getPicCTU(parentCTU.m_cuAddr);<br>
> +        const CUData& cu = *m_slice->m_refFrameList[1][0]->m_encData->getPicCTU(parentCTU.m_cuAddr);<br>
>          if (!cu.m_cuDepth[cuGeom.absPartIdx])<br>
>              return 0;<br>
>          for (uint32_t i = 0; i < cuGeom.numPartitions; i += 4)<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/dpb.cpp<br>
> --- a/source/encoder/dpb.cpp  Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/dpb.cpp  Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -47,16 +47,16 @@<br>
>          delete curFrame;<br>
>      }<br>
><br>
> -    while (m_picSymFreeList)<br>
> +    while (m_frameDataFreeList)<br>
>      {<br>
> -        FrameData* next = m_picSymFreeList->m_freeListNext;<br>
> -        m_picSymFreeList->destroy();<br>
> +        FrameData* next = m_frameDataFreeList->m_freeListNext;<br>
> +        m_frameDataFreeList->destroy();<br>
><br>
> -        m_picSymFreeList->m_reconPic->destroy();<br>
> -        delete m_picSymFreeList->m_reconPic;<br>
> +        m_frameDataFreeList->m_reconPic->destroy();<br>
> +        delete m_frameDataFreeList->m_reconPic;<br>
><br>
> -        delete m_picSymFreeList;<br>
> -        m_picSymFreeList = next;<br>
> +        delete m_frameDataFreeList;<br>
> +        m_frameDataFreeList = next;<br>
>      }<br>
>  }<br>
><br>
> @@ -79,8 +79,8 @@<br>
>              iterFrame = m_picList.first();<br>
><br>
>              m_freeList.pushBack(*curFrame);<br>
> -            curFrame->m_encData->m_freeListNext = m_picSymFreeList;<br>
> -            m_picSymFreeList = curFrame->m_encData;<br>
> +            curFrame->m_encData->m_freeListNext = m_frameDataFreeList;<br>
> +            m_frameDataFreeList = curFrame->m_encData;<br>
>              curFrame->m_encData = NULL;<br>
>              curFrame->m_reconPic = NULL;<br>
>          }<br>
> @@ -171,7 +171,7 @@<br>
>      {<br>
>          for (int ref = 0; ref < slice->m_numRefIdx[l]; ref++)<br>
>          {<br>
> -            Frame *refpic = slice->m_refPicList[l][ref];<br>
> +            Frame *refpic = slice->m_refFrameList[l][ref];<br>
>              ATOMIC_INC(&refpic->m_countRefEncoders);<br>
>          }<br>
>      }<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/dpb.h<br>
> --- a/source/encoder/dpb.h    Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/dpb.h    Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -46,14 +46,14 @@<br>
>      bool               m_bTemporalSublayer;<br>
>      PicList            m_picList;<br>
>      PicList            m_freeList;<br>
> -    FrameData*         m_picSymFreeList;<br>
> +    FrameData*         m_frameDataFreeList;<br>
><br>
>      DPB(x265_param *param)<br>
>      {<br>
>          m_lastIDR = 0;<br>
>          m_pocCRA = 0;<br>
>          m_bRefreshPending = false;<br>
> -        m_picSymFreeList = NULL;<br>
> +        m_frameDataFreeList = NULL;<br>
>          m_maxRefL0 = param->maxNumReferences;<br>
>          m_maxRefL1 = param->bBPyramid ? 2 : 1;<br>
>          m_bOpenGOP = param->bOpenGOP;<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/encoder.cpp<br>
> --- a/source/encoder/encoder.cpp      Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/encoder.cpp      Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -66,10 +66,6 @@<br>
>      m_outputCount = 0;<br>
>      m_param = NULL;<br>
>      m_latestParam = NULL;<br>
> -    m_cuOffsetY = NULL;<br>
> -    m_cuOffsetC = NULL;<br>
> -    m_buOffsetY = NULL;<br>
> -    m_buOffsetC = NULL;<br>
>      m_threadPool = NULL;<br>
>      m_analysisFile = NULL;<br>
>      for (int i = 0; i < X265_MAX_FRAME_THREADS; i++)<br>
> @@ -318,10 +314,10 @@<br>
>          delete m_rateControl;<br>
>      }<br>
><br>
> -    X265_FREE(m_cuOffsetY);<br>
> -    X265_FREE(m_cuOffsetC);<br>
> -    X265_FREE(m_buOffsetY);<br>
> -    X265_FREE(m_buOffsetC);<br>
> +    X265_FREE(m_sps.cuOffsetY);<br>
> +    X265_FREE(m_sps.cuOffsetC);<br>
> +    X265_FREE(m_sps.buOffsetY);<br>
> +    X265_FREE(m_sps.buOffsetC);<br>
<br>
</div></div>these free calls should be in an SPS destructor.<br>
<div><div class="h5"><br>
>      if (m_analysisFile)<br>
>          fclose(m_analysisFile);<br>
> @@ -416,12 +412,12 @@<br>
>                  /* the first PicYuv created is asked to generate the CU and block unit offset<br>
>                   * arrays which are then shared with all subsequent PicYuv (orig and recon)<br>
>                   * allocated by this top level encoder */<br>
> -                if (m_cuOffsetY)<br>
> +                if (m_sps.cuOffsetY)<br>
>                  {<br>
> -                    inFrame->m_fencPic->m_cuOffsetC = m_cuOffsetC;<br>
> -                    inFrame->m_fencPic->m_cuOffsetY = m_cuOffsetY;<br>
> -                    inFrame->m_fencPic->m_buOffsetC = m_buOffsetC;<br>
> -                    inFrame->m_fencPic->m_buOffsetY = m_buOffsetY;<br>
> +                    inFrame->m_fencPic->m_cuOffsetC = m_sps.cuOffsetC;<br>
> +                    inFrame->m_fencPic->m_cuOffsetY = m_sps.cuOffsetY;<br>
> +                    inFrame->m_fencPic->m_buOffsetC = m_sps.buOffsetC;<br>
> +                    inFrame->m_fencPic->m_buOffsetY = m_sps.buOffsetY;<br>
>                  }<br>
>                  else<br>
>                  {<br>
> @@ -435,10 +431,10 @@<br>
>                      }<br>
>                      else<br>
>                      {<br>
> -                        m_cuOffsetC = inFrame->m_fencPic->m_cuOffsetC;<br>
> -                        m_cuOffsetY = inFrame->m_fencPic->m_cuOffsetY;<br>
> -                        m_buOffsetC = inFrame->m_fencPic->m_buOffsetC;<br>
> -                        m_buOffsetY = inFrame->m_fencPic->m_buOffsetY;<br>
> +                        m_sps.cuOffsetC = inFrame->m_fencPic->m_cuOffsetC;<br>
> +                        m_sps.cuOffsetY = inFrame->m_fencPic->m_cuOffsetY;<br>
> +                        m_sps.buOffsetC = inFrame->m_fencPic->m_buOffsetC;<br>
> +                        m_sps.buOffsetY = inFrame->m_fencPic->m_buOffsetY;<br>
>                      }<br>
>                  }<br>
>              }<br>
> @@ -633,10 +629,10 @@<br>
>          if (frameEnc && !pass)<br>
>          {<br>
>              /* give this frame a FrameData instance before encoding */<br>
> -            if (m_dpb->m_picSymFreeList)<br>
> +            if (m_dpb->m_frameDataFreeList)<br>
>              {<br>
> -                frameEnc->m_encData = m_dpb->m_picSymFreeList;<br>
> -                m_dpb->m_picSymFreeList = m_dpb->m_picSymFreeList->m_freeListNext;<br>
> +                frameEnc->m_encData = m_dpb->m_frameDataFreeList;<br>
> +                m_dpb->m_frameDataFreeList = m_dpb->m_frameDataFreeList->m_freeListNext;<br>
>                  frameEnc->reinit(m_sps);<br>
>              }<br>
>              else<br>
> @@ -647,10 +643,6 @@<br>
>                  slice->m_pps = &m_pps;<br>
>                  slice->m_maxNumMergeCand = m_param->maxNumMergeCand;<br>
>                  slice->m_endCUAddr = slice->realEndAddress(m_sps.numCUsInFrame * NUM_4x4_PARTITIONS);<br>
> -                frameEnc->m_reconPic->m_cuOffsetC = m_cuOffsetC;<br>
> -                frameEnc->m_reconPic->m_cuOffsetY = m_cuOffsetY;<br>
> -                frameEnc->m_reconPic->m_buOffsetC = m_buOffsetC;<br>
> -                frameEnc->m_reconPic->m_buOffsetY = m_buOffsetY;<br>
>              }<br>
><br>
>              curEncoder->m_rce.encodeOrder = m_encodedFrameNum++;<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/encoder.h<br>
> --- a/source/encoder/encoder.h        Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/encoder.h        Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -93,13 +93,6 @@<br>
>      int                m_numPools;<br>
>      int                m_curEncoder;<br>
><br>
> -    /* cached PicYuv offset arrays, shared by all instances of<br>
> -     * PicYuv created by this encoder */<br>
> -    intptr_t*          m_cuOffsetY;<br>
> -    intptr_t*          m_cuOffsetC;<br>
> -    intptr_t*          m_buOffsetY;<br>
> -    intptr_t*          m_buOffsetC;<br>
> -<br>
>      /* Collect statistics globally */<br>
>      EncStats           m_analyzeAll;<br>
>      EncStats           m_analyzeI;<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/frameencoder.cpp<br>
> --- a/source/encoder/frameencoder.cpp Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/frameencoder.cpp Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -35,10 +35,6 @@<br>
>  #include "slicetype.h"<br>
>  #include "nal.h"<br>
><br>
<br>
</div></div>it seems you had some unrelated local changes in your working directory,<br>
probably caused by an update that required a merge.<br>
<div><div class="h5"><br>
> -#if HAVE_LIBNUMA<br>
> -#include <numa.h><br>
> -#endif<br>
> -<br>
>  namespace X265_NS {<br>
>  void weightAnalyse(Slice& slice, Frame& frame, x265_param& param);<br>
><br>
> @@ -333,28 +329,6 @@<br>
>      if (m_frame->m_lowres.bKeyframe && m_param->bRepeatHeaders)<br>
>          m_top->getStreamHeaders(m_nalList, m_entropyCoder, m_bs);<br>
><br>
> -<<<<<<< local<br>
> -#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7) || HAVE_LIBNUMA<br>
> -    int numaNode = m_pool ? m_pool->m_numaNode : 0;<br>
> -#else<br>
> -    int numaNode = 0;<br>
> -#endif<br>
> -<br>
> -    /* Claim this frame as being encoded by this NUMA node */<br>
> -    // FIXME - Trying to see if copying recon to all NUMA nodes is better<br>
> -    // m_frame->m_encData->allocRecon(m_top->m_sps, numaNode); /* TODO: bail if failure */<br>
> -    for (int i = 0; i < ThreadPool::getNumaNodeCount(); i++)<br>
> -    {<br>
> -        // TODO - Fix for non-numa and windows<br>
> -        numa_set_preferred(i) ;<br>
> -        m_frame->m_encData->allocRecon(m_top->m_sps, i); /* TODO: bail if failure */<br>
> -    }<br>
> -    // TODO - Fix for non-numa and windows<br>
> -    numa_set_preferred(numaNode) ;<br>
> -    m_frame->m_encData->m_ownerNode = numaNode;<br>
> -<br>
> -=======<br>
> ->>>>>>> other<br>
>      // Weighted Prediction parameters estimation.<br>
>      bool bUseWeightP = slice->m_sliceType == P_SLICE && slice->m_pps->bUseWeightPred;<br>
>      bool bUseWeightB = slice->m_sliceType == B_SLICE && slice->m_pps->bUseWeightedBiPred;<br>
> @@ -383,7 +357,8 @@<br>
>              WeightParam *w = NULL;<br>
>              if ((bUseWeightP || bUseWeightB) && slice->m_weightPredTable[l][ref][0].bPresentFlag)<br>
>                  w = slice->m_weightPredTable[l][ref];<br>
> -            m_mref[l][ref].init(slice->m_refPicList[l][ref]->m_reconPic, w, *m_param);<br>
> +            slice->m_refReconPicList[l][ref] = slice->m_refFrameList[l][ref]->m_reconPic;<br>
> +            m_mref[l][ref].init(slice->m_refReconPicList[l][ref], w, *m_param);<br>
>          }<br>
>      }<br>
><br>
> @@ -503,7 +478,7 @@<br>
>      /* CQP and CRF (without capped VBV) doesn't use mid-frame statistics to<br>
>       * tune RateControl parameters for other frames.<br>
>       * Hence, for these modes, update m_startEndOrder and unlock RC for previous threads waiting in<br>
> -     * RateControlEnd here, after the slicecontexts are initialized. For the rest - ABR<br>
> +     * RateControlEnd here, after the slice contexts are initialized. For the rest - ABR<br>
>       * and VBV, unlock only after rateControlUpdateStats of this frame is called */<br>
>      if (m_param->rc.rateControlMode != X265_RC_ABR && !m_top->m_rateControl->m_isVbv)<br>
>      {<br>
> @@ -527,7 +502,7 @@<br>
>              {<br>
>                  for (int ref = 0; ref < slice->m_numRefIdx[l]; ref++)<br>
>                  {<br>
> -                    Frame *refpic = slice->m_refPicList[l][ref];<br>
> +                    Frame *refpic = slice->m_refFrameList[l][ref];<br>
><br>
>                      uint32_t reconRowCount = refpic->m_reconRowCount.get();<br>
>                      while ((reconRowCount != m_numRows) && (reconRowCount < row + m_refLagRows))<br>
> @@ -566,7 +541,7 @@<br>
>                      int list = l;<br>
>                      for (int ref = 0; ref < slice->m_numRefIdx[list]; ref++)<br>
>                      {<br>
> -                        Frame *refpic = slice->m_refPicList[list][ref];<br>
> +                        Frame *refpic = slice->m_refFrameList[list][ref];<br>
><br>
>                          uint32_t reconRowCount = refpic->m_reconRowCount.get();<br>
>                          while ((reconRowCount != m_numRows) && (reconRowCount < i + m_refLagRows))<br>
> @@ -723,7 +698,7 @@<br>
>      {<br>
>          for (int ref = 0; ref < slice->m_numRefIdx[l]; ref++)<br>
>          {<br>
> -            Frame *refpic = slice->m_refPicList[l][ref];<br>
> +            Frame *refpic = slice->m_refFrameList[l][ref];<br>
>              ATOMIC_DEC(&refpic->m_countRefEncoders);<br>
>          }<br>
>      }<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/framefilter.cpp<br>
> --- a/source/encoder/framefilter.cpp  Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/framefilter.cpp  Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -233,10 +233,10 @@<br>
>      }<br>
>      if (m_param->bEnableSsim && m_ssimBuf)<br>
>      {<br>
> -        pixel *rec = m_frame->m_reconPic->m_picOrg[0];<br>
> +        pixel *rec = reconPic->m_picOrg[0];<br>
>          pixel *fenc = m_frame->m_fencPic->m_picOrg[0];<br>
>          intptr_t stride1 = m_frame->m_fencPic->m_stride;<br>
> -        intptr_t stride2 = m_frame->m_reconPic->m_stride;<br>
> +        intptr_t stride2 = reconPic->m_stride;<br>
>          uint32_t bEnd = ((row + 1) == (this->m_numRows - 1));<br>
>          uint32_t bStart = (row == 0);<br>
>          uint32_t minPixY = row * g_maxCUSize - 4 * !bStart;<br>
<br>
</div></div>here you'll notice the original code had a bug. rec and stride1 are used<br>
together but rec us from reconPic and stride1 comes from fencPic. the<br>
bug is harmless since all PicYuv instances allocated by an encoder<br>
should have the same stride.<br>
<div class="HOEnZb"><div class="h5"><br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/ratecontrol.cpp<br>
> --- a/source/encoder/ratecontrol.cpp  Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/ratecontrol.cpp  Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -1345,10 +1345,10 @@<br>
>      {<br>
>          /* B-frames don't have independent rate control, but rather get the<br>
>           * average QP of the two adjacent P-frames + an offset */<br>
> -        Slice* prevRefSlice = m_curSlice->m_refPicList[0][0]->m_encData->m_slice;<br>
> -        Slice* nextRefSlice = m_curSlice->m_refPicList[1][0]->m_encData->m_slice;<br>
> -        double q0 = m_curSlice->m_refPicList[0][0]->m_encData->m_avgQpRc;<br>
> -        double q1 = m_curSlice->m_refPicList[1][0]->m_encData->m_avgQpRc;<br>
> +        Slice* prevRefSlice = m_curSlice->m_refFrameList[0][0]->m_encData->m_slice;<br>
> +        Slice* nextRefSlice = m_curSlice->m_refFrameList[1][0]->m_encData->m_slice;<br>
> +        double q0 = m_curSlice->m_refFrameList[0][0]->m_encData->m_avgQpRc;<br>
> +        double q1 = m_curSlice->m_refFrameList[1][0]->m_encData->m_avgQpRc;<br>
>          bool i0 = prevRefSlice->m_sliceType == I_SLICE;<br>
>          bool i1 = nextRefSlice->m_sliceType == I_SLICE;<br>
>          int dt0 = abs(m_curSlice->m_poc - prevRefSlice->m_poc);<br>
> @@ -1364,9 +1364,9 @@<br>
>                  q0 = q1;<br>
>              }<br>
>          }<br>
> -        if (prevRefSlice->m_sliceType == B_SLICE && IS_REFERENCED(m_curSlice->m_refPicList[0][0]))<br>
> +        if (prevRefSlice->m_sliceType == B_SLICE && IS_REFERENCED(m_curSlice->m_refFrameList[0][0]))<br>
>              q0 -= m_pbOffset / 2;<br>
> -        if (nextRefSlice->m_sliceType == B_SLICE && IS_REFERENCED(m_curSlice->m_refPicList[1][0]))<br>
> +        if (nextRefSlice->m_sliceType == B_SLICE && IS_REFERENCED(m_curSlice->m_refFrameList[1][0]))<br>
>              q1 -= m_pbOffset / 2;<br>
>          if (i0 && i1)<br>
>              q = (q0 + q1) / 2 + m_ipOffset;<br>
> @@ -1483,7 +1483,7 @@<br>
>               * Then bias the quant up or down if total size so far was far from<br>
>               * the target.<br>
>               * Result: Depending on the value of rate_tolerance, there is a<br>
> -             * tradeoff between quality and bitrate precision. But at large<br>
> +             * trade-off between quality and bitrate precision. But at large<br>
>               * tolerances, the bit distribution approaches that of 2pass. */<br>
><br>
>              double overflow = 1;<br>
> @@ -1832,7 +1832,7 @@<br>
>      double qScale = x265_qp2qScale(qpVbv);<br>
>      FrameData& curEncData = *curFrame->m_encData;<br>
>      int picType = curEncData.m_slice->m_sliceType;<br>
> -    Frame* refFrame = curEncData.m_slice->m_refPicList[0][0];<br>
> +    Frame* refFrame = curEncData.m_slice->m_refFrameList[0][0];<br>
><br>
>      uint32_t maxRows = curEncData.m_slice->m_sps->numCuInHeight;<br>
>      uint32_t maxCols = curEncData.m_slice->m_sps->numCuInWidth;<br>
> @@ -1921,7 +1921,7 @@<br>
>      updatePredictor(rce->rowPred[0], qScaleVbv, (double)rowSatdCost, encodedBits);<br>
>      if (curEncData.m_slice->m_sliceType == P_SLICE)<br>
>      {<br>
> -        Frame* refFrame = curEncData.m_slice->m_refPicList[0][0];<br>
> +        Frame* refFrame = curEncData.m_slice->m_refFrameList[0][0];<br>
>          if (qpVbv < refFrame->m_encData->m_rowStat[row].diagQp)<br>
>          {<br>
>              uint64_t intraRowSatdCost = curEncData.m_rowStat[row].diagIntraSatd;<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/sao.cpp<br>
> --- a/source/encoder/sao.cpp  Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/sao.cpp  Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -243,12 +243,13 @@<br>
>  void SAO::processSaoCu(int addr, int typeIdx, int plane)<br>
>  {<br>
>      int x, y;<br>
> -    const CUData* cu = m_frame->m_encData->getPicCTU(addr);<br>
> -    pixel* rec = m_frame->m_reconPic->getPlaneAddr(plane, addr);<br>
> -    intptr_t stride = plane ? m_frame->m_reconPic->m_strideC : m_frame->m_reconPic->m_stride;<br>
> +    PicYuv* reconPic = m_frame->m_reconPic;<br>
> +    pixel* rec = reconPic->getPlaneAddr(plane, addr);<br>
> +    intptr_t stride = plane ? reconPic->m_strideC : reconPic->m_stride;<br>
>      uint32_t picWidth  = m_param->sourceWidth;<br>
>      uint32_t picHeight = m_param->sourceHeight;<br>
> -    int ctuWidth  = g_maxCUSize;<br>
> +    const CUData* cu = m_frame->m_encData->getPicCTU(addr);<br>
> +    int ctuWidth = g_maxCUSize;<br>
>      int ctuHeight = g_maxCUSize;<br>
>      uint32_t lpelx = cu->m_cuPelX;<br>
>      uint32_t tpely = cu->m_cuPelY;<br>
> @@ -572,7 +573,8 @@<br>
>  /* Process SAO all units */<br>
>  void SAO::processSaoUnitRow(SaoCtuParam* ctuParam, int idxY, int plane)<br>
>  {<br>
> -    intptr_t stride = plane ? m_frame->m_reconPic->m_strideC : m_frame->m_reconPic->m_stride;<br>
> +    PicYuv* reconPic = m_frame->m_reconPic;<br>
> +    intptr_t stride = plane ? reconPic->m_strideC : reconPic->m_stride;<br>
>      uint32_t picWidth  = m_param->sourceWidth;<br>
>      int ctuWidth  = g_maxCUSize;<br>
>      int ctuHeight = g_maxCUSize;<br>
> @@ -585,12 +587,12 @@<br>
><br>
>      if (!idxY)<br>
>      {<br>
> -        pixel* rec = m_frame->m_reconPic->m_picOrg[plane];<br>
> +        pixel* rec = reconPic->m_picOrg[plane];<br>
>          memcpy(m_tmpU1[plane], rec, sizeof(pixel) * picWidth);<br>
>      }<br>
><br>
>      int addr = idxY * m_numCuInWidth;<br>
> -    pixel* rec = plane ? m_frame->m_reconPic->getChromaAddr(plane, addr) : m_frame->m_reconPic->getLumaAddr(addr);<br>
> +    pixel* rec = plane ? reconPic->getChromaAddr(plane, addr) : reconPic->getLumaAddr(addr);<br>
><br>
>      for (int i = 0; i < ctuHeight + 1; i++)<br>
>      {<br>
> @@ -635,7 +637,7 @@<br>
>          }<br>
>          else if (idxX != (m_numCuInWidth - 1))<br>
>          {<br>
> -            rec = plane ? m_frame->m_reconPic->getChromaAddr(plane, addr) : m_frame->m_reconPic->getLumaAddr(addr);<br>
> +            rec = plane ? reconPic->getChromaAddr(plane, addr) : reconPic->getLumaAddr(addr);<br>
><br>
>              for (int i = 0; i < ctuHeight + 1; i++)<br>
>              {<br>
> @@ -671,12 +673,13 @@<br>
>  /* Calculate SAO statistics for current CTU without non-crossing slice */<br>
>  void SAO::calcSaoStatsCu(int addr, int plane)<br>
>  {<br>
> +    const PicYuv* reconPic = m_frame->m_reconPic;<br>
>      const CUData* cu = m_frame->m_encData->getPicCTU(addr);<br>
>      const pixel* fenc0 = m_frame->m_fencPic->getPlaneAddr(plane, addr);<br>
> -    const pixel* rec0  = m_frame->m_reconPic->getPlaneAddr(plane, addr);<br>
> +    const pixel* rec0  = reconPic->getPlaneAddr(plane, addr);<br>
>      const pixel* fenc;<br>
>      const pixel* rec;<br>
> -    intptr_t stride = plane ? m_frame->m_reconPic->m_strideC : m_frame->m_reconPic->m_stride;<br>
> +    intptr_t stride = plane ? reconPic->m_strideC : reconPic->m_stride;<br>
>      uint32_t picWidth  = m_param->sourceWidth;<br>
>      uint32_t picHeight = m_param->sourceHeight;<br>
>      int ctuWidth  = g_maxCUSize;<br>
> @@ -825,9 +828,10 @@<br>
><br>
>      int x, y;<br>
>      const CUData* cu = frame->m_encData->getPicCTU(addr);<br>
> +    const PicYuv* reconPic = m_frame->m_reconPic;<br>
>      const pixel* fenc;<br>
>      const pixel* rec;<br>
> -    intptr_t stride = m_frame->m_reconPic->m_stride;<br>
> +    intptr_t stride = reconPic->m_stride;<br>
>      uint32_t picWidth  = m_param->sourceWidth;<br>
>      uint32_t picHeight = m_param->sourceHeight;<br>
>      int ctuWidth  = g_maxCUSize;<br>
> @@ -861,7 +865,7 @@<br>
>      {<br>
>          if (plane == 1)<br>
>          {<br>
> -            stride = frame->m_reconPic->m_strideC;<br>
> +            stride = reconPic->m_strideC;<br>
>              picWidth  >>= m_hChromaShift;<br>
>              picHeight >>= m_vChromaShift;<br>
>              ctuWidth  >>= m_hChromaShift;<br>
> @@ -881,7 +885,7 @@<br>
>          count = m_countPreDblk[addr][plane][SAO_BO];<br>
><br>
>          const pixel* fenc0 = m_frame->m_fencPic->getPlaneAddr(plane, addr);<br>
> -        const pixel* rec0  = m_frame->m_reconPic->getPlaneAddr(plane, addr);<br>
> +        const pixel* rec0 = reconPic->getPlaneAddr(plane, addr);<br>
>          fenc = fenc0;<br>
>          rec  = rec0;<br>
><br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/search.cpp<br>
> --- a/source/encoder/search.cpp       Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/search.cpp       Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -446,8 +446,9 @@<br>
>      }<br>
><br>
>      // set reconstruction for next intra prediction blocks if full TU prediction won<br>
> -    pixel*   picReconY = m_frame->m_reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + absPartIdx);<br>
> -    intptr_t picStride = m_frame->m_reconPic->m_stride;<br>
> +    PicYuv*  reconPic = m_frame->m_reconPic;<br>
> +    pixel*   picReconY = reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + absPartIdx);<br>
> +    intptr_t picStride = reconPic->m_stride;<br>
>      <a href="http://primitives.cu" rel="noreferrer" target="_blank">primitives.cu</a>[sizeIdx].copy_pp(picReconY, picStride, reconQt, reconQtStride);<br>
><br>
>      outCost.rdcost     += fullCost.rdcost;<br>
> @@ -611,8 +612,9 @@<br>
>      }<br>
><br>
>      // set reconstruction for next intra prediction blocks<br>
> -    pixel*   picReconY = m_frame->m_reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + absPartIdx);<br>
> -    intptr_t picStride = m_frame->m_reconPic->m_stride;<br>
> +    PicYuv*  reconPic = m_frame->m_reconPic;<br>
> +    pixel*   picReconY = reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + absPartIdx);<br>
> +    intptr_t picStride = reconPic->m_stride;<br>
>      <a href="http://primitives.cu" rel="noreferrer" target="_blank">primitives.cu</a>[sizeIdx].copy_pp(picReconY, picStride, reconQt, reconQtStride);<br>
><br>
>      outCost.rdcost += fullCost.rdcost;<br>
> @@ -661,8 +663,9 @@<br>
>          uint32_t sizeIdx   = log2TrSize - 2;<br>
>          <a href="http://primitives.cu" rel="noreferrer" target="_blank">primitives.cu</a>[sizeIdx].calcresidual(fenc, pred, residual, stride);<br>
><br>
> -        pixel*   picReconY = m_frame->m_reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + absPartIdx);<br>
> -        intptr_t picStride = m_frame->m_reconPic->m_stride;<br>
> +        PicYuv*  reconPic = m_frame->m_reconPic;<br>
> +        pixel*   picReconY = reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + absPartIdx);<br>
> +        intptr_t picStride = reconPic->m_stride;<br>
><br>
>          uint32_t numSig = m_quant.transformNxN(cu, fenc, stride, residual, stride, coeffY, log2TrSize, TEXT_LUMA, absPartIdx, false);<br>
>          if (numSig)<br>
> @@ -821,8 +824,9 @@<br>
>              coeff_t* coeffC        = m_rqt[qtLayer].coeffRQT[chromaId] + coeffOffsetC;<br>
>              pixel*   reconQt       = m_rqt[qtLayer].reconQtYuv.getChromaAddr(chromaId, absPartIdxC);<br>
>              uint32_t reconQtStride = m_rqt[qtLayer].reconQtYuv.m_csize;<br>
> -            pixel*   picReconC = m_frame->m_reconPic->getChromaAddr(chromaId, cu.m_cuAddr, cuGeom.absPartIdx + absPartIdxC);<br>
> -            intptr_t picStride = m_frame->m_reconPic->m_strideC;<br>
> +            PicYuv*  reconPic = m_frame->m_reconPic;<br>
> +            pixel*   picReconC = reconPic->getChromaAddr(chromaId, cu.m_cuAddr, cuGeom.absPartIdx + absPartIdxC);<br>
> +            intptr_t picStride = reconPic->m_strideC;<br>
><br>
>              uint32_t chromaPredMode = cu.m_chromaIntraDir[absPartIdxC];<br>
>              if (chromaPredMode == DM_CHROMA_IDX)<br>
> @@ -998,8 +1002,9 @@<br>
>              cu.setCbfPartRange(bCbf << tuDepth, ttype, absPartIdxC, tuIterator.absPartIdxStep);<br>
>              cu.setTransformSkipPartRange(bTSkip, ttype, absPartIdxC, tuIterator.absPartIdxStep);<br>
><br>
> -            pixel*   reconPicC = m_frame->m_reconPic->getChromaAddr(chromaId, cu.m_cuAddr, cuGeom.absPartIdx + absPartIdxC);<br>
> -            intptr_t picStride = m_frame->m_reconPic->m_strideC;<br>
> +            PicYuv*  reconPic = m_frame->m_reconPic;<br>
> +            pixel*   reconPicC = reconPic->getChromaAddr(chromaId, cu.m_cuAddr, cuGeom.absPartIdx + absPartIdxC);<br>
> +            intptr_t picStride = reconPic->m_strideC;<br>
>              <a href="http://primitives.cu" rel="noreferrer" target="_blank">primitives.cu</a>[sizeIdxC].copy_pp(reconPicC, picStride, reconQt, reconQtStride);<br>
><br>
>              outDist += bDist;<br>
> @@ -1108,8 +1113,9 @@<br>
>              int16_t* residual = resiYuv.getChromaAddr(chromaId, absPartIdxC);<br>
>              uint32_t coeffOffsetC  = absPartIdxC << (LOG2_UNIT_SIZE * 2 - (m_hChromaShift + m_vChromaShift));<br>
>              coeff_t* coeffC        = cu.m_trCoeff[ttype] + coeffOffsetC;<br>
> -            pixel*   picReconC = m_frame->m_reconPic->getChromaAddr(chromaId, cu.m_cuAddr, cuGeom.absPartIdx + absPartIdxC);<br>
> -            intptr_t picStride = m_frame->m_reconPic->m_strideC;<br>
> +            PicYuv*  reconPic = m_frame->m_reconPic;<br>
> +            pixel*   picReconC = reconPic->getChromaAddr(chromaId, cu.m_cuAddr, cuGeom.absPartIdx + absPartIdxC);<br>
> +            intptr_t picStride = reconPic->m_strideC;<br>
><br>
>              uint32_t chromaPredMode = cu.m_chromaIntraDir[absPartIdxC];<br>
>              if (chromaPredMode == DM_CHROMA_IDX)<br>
> @@ -1591,10 +1597,11 @@<br>
>               * output recon picture, so it cannot proceed in parallel with anything else when doing INTRA_NXN. Also<br>
>               * it is not updating m_rdContexts[depth].cur for the later PUs which I suspect is slightly wrong. I think<br>
>               * that the contexts should be tracked through each PU */<br>
> -            pixel*   dst         = m_frame->m_reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + absPartIdx);<br>
> -            uint32_t dststride   = m_frame->m_reconPic->m_stride;<br>
> -            const pixel*   src   = reconYuv->getLumaAddr(absPartIdx);<br>
> -            uint32_t srcstride   = reconYuv->m_size;<br>
> +            PicYuv*  reconPic = m_frame->m_reconPic;<br>
> +            pixel*   dst       = reconPic->getLumaAddr(cu.m_cuAddr, cuGeom.absPartIdx + absPartIdx);<br>
> +            uint32_t dststride = reconPic->m_stride;<br>
> +            const pixel*   src = reconYuv->getLumaAddr(absPartIdx);<br>
> +            uint32_t srcstride = reconYuv->m_size;<br>
>              <a href="http://primitives.cu" rel="noreferrer" target="_blank">primitives.cu</a>[log2TrSize - 2].copy_pp(dst, dststride, src, srcstride);<br>
>          }<br>
>      }<br>
> @@ -1757,15 +1764,16 @@<br>
>          if (!tuIterator.isLastSection())<br>
>          {<br>
>              uint32_t zorder    = cuGeom.absPartIdx + absPartIdxC;<br>
> -            uint32_t dststride = m_frame->m_reconPic->m_strideC;<br>
> +            PicYuv*  reconPic  = m_frame->m_reconPic;<br>
> +            uint32_t dststride = reconPic->m_strideC;<br>
>              const pixel* src;<br>
>              pixel* dst;<br>
><br>
> -            dst = m_frame->m_reconPic->getCbAddr(cu.m_cuAddr, zorder);<br>
> +            dst = reconPic->getCbAddr(cu.m_cuAddr, zorder);<br>
>              src = reconYuv.getCbAddr(absPartIdxC);<br>
>              primitives.chroma[m_csp].cu[size].copy_pp(dst, dststride, src, reconYuv.m_csize);<br>
><br>
> -            dst = m_frame->m_reconPic->getCrAddr(cu.m_cuAddr, zorder);<br>
> +            dst = reconPic->getCrAddr(cu.m_cuAddr, zorder);<br>
>              src = reconYuv.getCrAddr(absPartIdxC);<br>
>              primitives.chroma[m_csp].cu[size].copy_pp(dst, dststride, src, reconYuv.m_csize);<br>
>          }<br>
> @@ -1866,7 +1874,7 @@<br>
>  /* find the lowres motion vector from lookahead in middle of current PU */<br>
>  MV Search::getLowresMV(const CUData& cu, const PredictionUnit& pu, int list, int ref)<br>
>  {<br>
> -    int diffPoc = abs(m_slice->m_poc - m_slice->m_refPicList[list][ref]->m_poc);<br>
> +    int diffPoc = abs(m_slice->m_poc - m_slice->m_refPOCList[list][ref]);<br>
>      if (diffPoc > m_param->bframes + 1)<br>
>          /* poc difference is out of range for lookahead */<br>
>          return 0;<br>
> @@ -1906,7 +1914,7 @@<br>
>          else<br>
>          {<br>
>              cu.clipMv(mvCand);<br>
> -            predInterLumaPixel(pu, tmpPredYuv, *m_slice->m_refPicList[list][ref]->m_reconPic, mvCand);<br>
> +            predInterLumaPixel(pu, tmpPredYuv, *m_slice->m_refReconPicList[list][ref], mvCand);<br>
>              costs[i] = m_me.bufSAD(tmpPredYuv.getLumaAddr(pu.puAbsPartIdx), tmpPredYuv.m_size);<br>
>          }<br>
>      }<br>
> @@ -2197,8 +2205,8 @@<br>
>              }<br>
>              else<br>
>              {<br>
> -                PicYuv* refPic0 = slice->m_refPicList[0][bestME[0].ref]->m_reconPic;<br>
> -                PicYuv* refPic1 = slice->m_refPicList[1][bestME[1].ref]->m_reconPic;<br>
> +                PicYuv* refPic0 = slice->m_refReconPicList[0][bestME[0].ref];<br>
> +                PicYuv* refPic1 = slice->m_refReconPicList[1][bestME[1].ref];<br>
>                  Yuv* bidirYuv = m_rqt[cuGeom.depth].bidirPredYuv;<br>
><br>
>                  /* Generate reference subpels */<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/slicetype.cpp<br>
> --- a/source/encoder/slicetype.cpp    Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/slicetype.cpp    Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -714,16 +714,16 @@<br>
><br>
>      case P_SLICE:<br>
>          b = p1 = poc - l0poc;<br>
> -        frames[p0] = &slice->m_refPicList[0][0]->m_lowres;<br>
> +        frames[p0] = &slice->m_refFrameList[0][0]->m_lowres;<br>
>          frames[b] = &curFrame->m_lowres;<br>
>          break;<br>
><br>
>      case B_SLICE:<br>
>          b = poc - l0poc;<br>
>          p1 = b + l1poc - poc;<br>
> -        frames[p0] = &slice->m_refPicList[0][0]->m_lowres;<br>
> +        frames[p0] = &slice->m_refFrameList[0][0]->m_lowres;<br>
>          frames[b] = &curFrame->m_lowres;<br>
> -        frames[p1] = &slice->m_refPicList[1][0]->m_lowres;<br>
> +        frames[p1] = &slice->m_refFrameList[1][0]->m_lowres;<br>
>          break;<br>
><br>
>      default:<br>
> diff -r faecefdb2ae9 -r 1b2e5e8ccb85 source/encoder/weightPrediction.cpp<br>
> --- a/source/encoder/weightPrediction.cpp     Tue Aug 11 14:28:23 2015 +0000<br>
> +++ b/source/encoder/weightPrediction.cpp     Tue Aug 11 22:31:57 2015 +0000<br>
> @@ -259,7 +259,7 @@<br>
>      for (int list = 0; list < cache.numPredDir; list++)<br>
>      {<br>
>          WeightParam *weights = wp[list][0];<br>
> -        Frame *refFrame = slice.m_refPicList[list][0];<br>
> +        Frame *refFrame = slice.m_refFrameList[list][0];<br>
>          Lowres& refLowres = refFrame->m_lowres;<br>
>          int diffPoc = abs(curPoc - refFrame->m_poc);<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Steve Borho<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</font></span></blockquote></div><br></div>