<div dir="ltr"><div>Steve,<br><br></div>allocRecon is now being called unconditionally, so a recon frame gets allocated for every single frame, as opposed to an available frame being chosen from the DPB freeList?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 4, 2015 at 9:03 AM, 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"># HG changeset patch<br>
# User Steve Borho <<a href="mailto:steve@borho.org">steve@borho.org</a>><br>
# Date 1438642558 18000<br>
#      Mon Aug 03 17:55:58 2015 -0500<br>
# Node ID 02e84edaa14399a3a68ade8617c63422f51a305b<br>
# Parent  1f161d9c6e35e32998d38ebf5b6dec96f1ef43e2<br>
slice: prep work for per-numa recon picture copies<br>
<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 reconstructed pictures are now allocated by the frame encoder worker thread<br>
making them socket-local. The per-node structures devolve to a single pointer<br>
de-reference when NUMA support is not compiled in, minimizing the impact when<br>
the feature is disabled.<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>
Later commits will make the PicYuv buffers per-NUMA node and copy reconstructed<br>
pixels between nodes on demand.<br>
<br>
diff -r 1f161d9c6e35 -r 02e84edaa143 source/common/cudata.cpp<br>
--- a/source/common/cudata.cpp  Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/cudata.cpp  Mon Aug 03 17:55:58 2015 -0500<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 1f161d9c6e35 -r 02e84edaa143 source/common/deblock.cpp<br>
--- a/source/common/deblock.cpp Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/deblock.cpp Mon Aug 03 17:55:58 2015 -0500<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>
@@ -366,7 +366,7 @@<br>
<br>
 void Deblock::edgeFilterLuma(const CUData* cuQ, uint32_t absPartIdx, uint32_t depth, int32_t dir, int32_t edge, const uint8_t blockStrength[])<br>
 {<br>
-    PicYuv* reconPic = cuQ->m_encData->m_reconPic;<br>
+    PicYuv* reconPic = cuQ->m_encData->getOutputRecon();<br>
     pixel* src = reconPic->getLumaAddr(cuQ->m_cuAddr, absPartIdx);<br>
     intptr_t stride = reconPic->m_stride;<br>
     const PPS* pps = cuQ->m_slice->m_pps;<br>
@@ -474,7 +474,7 @@<br>
                 : ((g_zscanToPelY[absPartIdx] + edge * UNIT_SIZE) >> cuQ->m_vChromaShift)) % DEBLOCK_SMALLEST_BLOCK == 0,<br>
                "invalid edge\n");<br>
<br>
-    PicYuv* reconPic = cuQ->m_encData->m_reconPic;<br>
+    PicYuv* reconPic = cuQ->m_encData->getOutputRecon();<br>
     intptr_t stride = reconPic->m_strideC;<br>
     intptr_t srcOffset = reconPic->getChromaAddrOffset(cuQ->m_cuAddr, absPartIdx);<br>
     bool bCheckNoFilter = pps->bTransquantBypassEnabled;<br>
diff -r 1f161d9c6e35 -r 02e84edaa143 source/common/frame.cpp<br>
--- a/source/common/frame.cpp   Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/frame.cpp   Mon Aug 03 17:55:58 2015 -0500<br>
@@ -35,7 +35,6 @@<br>
     m_reconRowCount.set(0);<br>
     m_countRefEncoders = 0;<br>
     m_encData = NULL;<br>
-    m_reconPic = NULL;<br>
     m_next = NULL;<br>
     m_prev = NULL;<br>
     m_param = NULL;<br>
@@ -54,26 +53,13 @@<br>
 bool Frame::allocEncodeData(x265_param *param, const SPS& sps)<br>
 {<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>
-    if (ok)<br>
-    {<br>
-        /* initialize right border of m_reconpicYuv as SAO may read beyond the<br>
-         * end of the picture accessing uninitialized pixels */<br>
-        int maxHeight = sps.numCuInHeight * g_maxCUSize;<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>
-    return ok;<br>
+    return m_encData->create(*param, sps);<br>
 }<br>
<br>
 /* prepare to re-use a FrameData instance to encode a new picture */<br>
 void Frame::reinit(const SPS& sps)<br>
 {<br>
     m_bChromaExtended = false;<br>
-    m_reconPic = m_encData->m_reconPic;<br>
     m_encData->reinit(sps);<br>
 }<br>
<br>
@@ -93,12 +79,5 @@<br>
         m_fencPic = NULL;<br>
     }<br>
<br>
-    if (m_reconPic)<br>
-    {<br>
-        m_reconPic->destroy();<br>
-        delete m_reconPic;<br>
-        m_reconPic = NULL;<br>
-    }<br>
-<br>
     m_lowres.destroy();<br>
 }<br>
diff -r 1f161d9c6e35 -r 02e84edaa143 source/common/frame.h<br>
--- a/source/common/frame.h     Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/frame.h     Mon Aug 03 17:55:58 2015 -0500<br>
@@ -41,10 +41,9 @@<br>
 {<br>
 public:<br>
<br>
-    /* These two items will be NULL until the Frame begins to be encoded, at which point<br>
-     * it will be assigned a FrameData instance, which comes with a reconstructed image PicYuv */<br>
+    /* will be NULL until the Frame begins to be encoded, at which point it will<br>
+     * be assigned a FrameData instance */<br>
     FrameData*             m_encData;<br>
-    PicYuv*                m_reconPic;<br>
<br>
     /* Data associated with x265_picture */<br>
     PicYuv*                m_fencPic;<br>
diff -r 1f161d9c6e35 -r 02e84edaa143 source/common/framedata.cpp<br>
--- a/source/common/framedata.cpp       Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/framedata.cpp       Mon Aug 03 17:55:58 2015 -0500<br>
@@ -22,24 +22,39 @@<br>
 *****************************************************************************/<br>
<br>
 #include "framedata.h"<br>
+#include "threadpool.h"<br>
 #include "picyuv.h"<br>
<br>
 using namespace X265_NS;<br>
<br>
+PerNodeRecon::~PerNodeRecon()<br>
+{<br>
+    if (reconPic)<br>
+    {<br>
+        reconPic->destroy();<br>
+        delete reconPic;<br>
+    }<br>
+}<br>
+<br>
 FrameData::FrameData()<br>
 {<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>
+#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7) || HAVE_LIBNUMA<br>
+    m_nodes = new PerNodeRecon[ThreadPool::getNumaNodeCount()];<br>
+#else<br>
+    m_nodes = new PerNodeRecon[1];<br>
+#endif<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>
@@ -54,11 +69,51 @@<br>
 {<br>
     memset(m_cuStat, 0, sps.numCUsInFrame * sizeof(*m_cuStat));<br>
     memset(m_rowStat, 0, sps.numCuInHeight * sizeof(*m_rowStat));<br>
+#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7) || HAVE_LIBNUMA<br>
+    for (int i = 0; i < ThreadPool::getNumaNodeCount(); i++)<br>
+        m_nodes[i].rows = 0;<br>
+#else<br>
+    m_nodes->rows = 0;<br>
+#endif<br>
+}<br>
+<br>
+bool FrameData::allocRecon(const SPS& sps, int node)<br>
+{<br>
+    if (m_nodes[node].reconPic)<br>
+        return true;<br>
+<br>
+    ScopedLock s(m_nodes[node].copyLock);<br>
+<br>
+    if (m_nodes[node].reconPic)<br>
+        return true;<br>
+<br>
+    PicYuv* reconPic = new PicYuv;<br>
+    m_nodes[node].reconPic = reconPic;<br>
+<br>
+    int maxHeight = sps.numCuInHeight * g_maxCUSize;<br>
+    if (reconPic->create(m_param->sourceWidth, m_param->sourceHeight, m_param->internalCsp))<br>
+    {<br>
+        /* initialize right border of recon PicYuv as SAO may read beyond the end<br>
+         * of the picture accessing uninitialized pixels */<br>
+        memset(reconPic->m_picOrg[0], 0, sizeof(pixel) * reconPic->m_stride * maxHeight);<br>
+        memset(reconPic->m_picOrg[1], 0, sizeof(pixel) * reconPic->m_strideC * (maxHeight >> reconPic->m_vChromaShift));<br>
+        memset(reconPic->m_picOrg[2], 0, sizeof(pixel) * reconPic->m_strideC * (maxHeight >> reconPic->m_vChromaShift));<br>
+<br>
+        /* use pre-calculated cu/pu offsets cached in the SPS structure */<br>
+        reconPic->m_cuOffsetC = sps.cuOffsetC;<br>
+        reconPic->m_cuOffsetY = sps.cuOffsetY;<br>
+        reconPic->m_buOffsetC = sps.buOffsetC;<br>
+        reconPic->m_buOffsetY = sps.buOffsetY;<br>
+        return true;<br>
+    }<br>
+<br>
+    return false;<br>
 }<br>
<br>
 void FrameData::destroy()<br>
 {<br>
     delete [] m_picCTU;<br>
+    delete [] m_nodes;<br>
     delete m_slice;<br>
     delete m_saoParam;<br>
<br>
diff -r 1f161d9c6e35 -r 02e84edaa143 source/common/framedata.h<br>
--- a/source/common/framedata.h Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/framedata.h Mon Aug 03 17:55:58 2015 -0500<br>
@@ -27,6 +27,7 @@<br>
 #include "common.h"<br>
 #include "slice.h"<br>
 #include "cudata.h"<br>
+#include "threading.h"<br>
<br>
 namespace X265_NS {<br>
 // private namespace<br>
@@ -83,6 +84,21 @@<br>
     }<br>
 };<br>
<br>
+struct PerNodeRecon<br>
+{<br>
+    PicYuv*    reconPic;<br>
+    Lock       copyLock;<br>
+    int        rows;<br>
+<br>
+    PerNodeRecon()<br>
+    {<br>
+        rows = 0;<br>
+        reconPic = NULL;<br>
+    }<br>
+<br>
+    ~PerNodeRecon();<br>
+};<br>
+<br>
 /* Per-frame data that is used during encodes and referenced while the picture<br>
  * is available for reference. A FrameData instance is attached to a Frame as it<br>
  * comes out of the lookahead. Frames which are not being encoded do not have a<br>
@@ -93,13 +109,14 @@<br>
 class FrameData<br>
 {<br>
 public:<br>
+    PerNodeRecon*  m_nodes;<br>
+    int            m_ownerNode;        /* NUMA node of writing frame encoder */<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>
     bool           m_bHasReferences;   /* used during DPB/RPS updates */<br>
     int            m_frameEncoderID;   /* the ID of the FrameEncoder encoding this frame */<br>
     JobProvider*   m_jobProvider;<br>
@@ -142,11 +159,23 @@<br>
<br>
     FrameData();<br>
<br>
-    bool create(x265_param *param, const SPS& sps);<br>
+    bool create(const x265_param& param, const SPS& sps);<br>
+    bool allocRecon(const SPS& sps, int node);<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>
+#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7) || HAVE_LIBNUMA<br>
+    /* this function should only be called by worker threads which are encoding this particular<br>
+     * frame. workers which are using this frame as a motion reference should use their slice's<br>
+     * m_refReconPicList[][] array instead. Its pointers will always reference a buffer which<br>
+     * was allocated on their local socket */<br>
+    /* TODO: X265_CHECK that current node == m_ownerNode */<br>
+    inline PicYuv* getOutputRecon() { return m_nodes[m_ownerNode].reconPic; }<br>
+#else<br>
+    inline PicYuv* getOutputRecon() { return m_nodes->reconPic; }<br>
+#endif<br>
 };<br>
 }<br>
<br>
diff -r 1f161d9c6e35 -r 02e84edaa143 source/common/predict.cpp<br>
--- a/source/common/predict.cpp Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/predict.cpp Mon Aug 03 17:55:58 2015 -0500<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->getOutputRecon();<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->getOutputRecon();<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 1f161d9c6e35 -r 02e84edaa143 source/common/slice.cpp<br>
--- a/source/common/slice.cpp   Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/slice.cpp   Mon Aug 03 17:55:58 2015 -0500<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 1f161d9c6e35 -r 02e84edaa143 source/common/slice.h<br>
--- a/source/common/slice.h     Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/common/slice.h     Mon Aug 03 17:55:58 2015 -0500<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>
+    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>
<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 1f161d9c6e35 -r 02e84edaa143 source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp       Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/analysis.cpp       Mon Aug 03 17:55:58 2015 -0500<br>
@@ -173,8 +173,8 @@<br>
         if (!m_param->rdLevel)<br>
         {<br>
             /* In RD Level 0/1, copy source pixels into the reconstructed block so<br>
-            * they are available for intra predictions */<br>
-            m_modeDepth[0].fencYuv.copyToPicYuv(*m_frame->m_reconPic, ctu.m_cuAddr, 0);<br>
+             * they are available for intra predictions */<br>
+            m_modeDepth[0].fencYuv.copyToPicYuv(*m_frame->m_encData->getOutputRecon(), ctu.m_cuAddr, 0);<br>
<br>
             compressInterCU_rd0_4(ctu, cuGeom, qp);<br>
<br>
@@ -337,7 +337,7 @@<br>
     /* Copy best data to encData CTU and recon */<br>
     md.bestMode->cu.copyToPic(depth);<br>
     if (md.bestMode != &md.pred[PRED_SPLIT])<br>
-        md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_reconPic, parentCTU.m_cuAddr, cuGeom.absPartIdx);<br>
+        md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_encData->getOutputRecon(), parentCTU.m_cuAddr, cuGeom.absPartIdx);<br>
 }<br>
<br>
 void Analysis::PMODE::processTasks(int workerThreadId)<br>
@@ -747,7 +747,7 @@<br>
     /* Copy best data to encData CTU and recon */<br>
     md.bestMode->cu.copyToPic(depth);<br>
     if (md.bestMode != &md.pred[PRED_SPLIT])<br>
-        md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_reconPic, cuAddr, cuGeom.absPartIdx);<br>
+        md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_encData->getOutputRecon(), cuAddr, cuGeom.absPartIdx);<br>
 }<br>
<br>
 uint32_t Analysis::compressInterCU_rd0_4(const CUData& parentCTU, const CUGeom& cuGeom, int32_t qp)<br>
@@ -757,6 +757,8 @@<br>
     ModeDepth& md = m_modeDepth[depth];<br>
     md.bestMode = NULL;<br>
<br>
+    PicYuv& reconPic = *m_frame->m_encData->getOutputRecon();<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>
@@ -1356,7 +1358,7 @@<br>
     /* Copy best data to encData CTU and recon */<br>
     X265_CHECK(md.bestMode->ok(), "best mode is not ok");<br>
     md.bestMode->cu.copyToPic(depth);<br>
-    md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_reconPic, parentCTU.m_cuAddr, cuGeom.absPartIdx);<br>
+    md.bestMode->reconYuv.copyToPicYuv(*m_frame->m_encData->getOutputRecon(), parentCTU.m_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_encData->getOutputRecon();<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 1f161d9c6e35 -r 02e84edaa143 source/encoder/dpb.cpp<br>
--- a/source/encoder/dpb.cpp    Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/dpb.cpp    Mon Aug 03 17:55:58 2015 -0500<br>
@@ -47,16 +47,12 @@<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>
-<br>
-        m_picSymFreeList->m_reconPic->destroy();<br>
-        delete m_picSymFreeList->m_reconPic;<br>
-<br>
-        delete m_picSymFreeList;<br>
-        m_picSymFreeList = next;<br>
+        FrameData* next = m_frameDataFreeList->m_freeListNext;<br>
+        m_frameDataFreeList->destroy();<br>
+        delete m_frameDataFreeList;<br>
+        m_frameDataFreeList = next;<br>
     }<br>
 }<br>
<br>
@@ -79,10 +75,9 @@<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>
     }<br>
 }<br>
@@ -171,7 +166,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 1f161d9c6e35 -r 02e84edaa143 source/encoder/dpb.h<br>
--- a/source/encoder/dpb.h      Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/dpb.h      Mon Aug 03 17:55:58 2015 -0500<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 1f161d9c6e35 -r 02e84edaa143 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp        Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/encoder.cpp        Mon Aug 03 17:55:58 2015 -0500<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>
     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>
@@ -538,7 +534,7 @@<br>
<br>
             if (pic_out)<br>
             {<br>
-                PicYuv *recpic = outFrame->m_reconPic;<br>
+                PicYuv *recpic = outFrame->m_encData->getOutputRecon();<br>
                 pic_out->poc = slice->m_poc;<br>
                 pic_out->bitDepth = X265_DEPTH;<br>
                 pic_out->userData = outFrame->m_userData;<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>
@@ -1054,7 +1046,7 @@<br>
<br>
 void Encoder::finishFrameStats(Frame* curFrame, FrameEncoder *curEncoder, uint64_t bits, x265_frame_stats* frameStats)<br>
 {<br>
-    PicYuv* reconPic = curFrame->m_reconPic;<br>
+    PicYuv *reconPic = curFrame->m_encData->getOutputRecon();<br>
<br>
     //===== calculate PSNR =====<br>
     int width  = reconPic->m_picWidth - m_sps.conformanceWindow.rightOffset;<br>
diff -r 1f161d9c6e35 -r 02e84edaa143 source/encoder/encoder.h<br>
--- a/source/encoder/encoder.h  Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/encoder.h  Mon Aug 03 17:55:58 2015 -0500<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 1f161d9c6e35 -r 02e84edaa143 source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp   Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/frameencoder.cpp   Mon Aug 03 17:55:58 2015 -0500<br>
@@ -329,6 +329,16 @@<br>
     if (m_frame->m_lowres.bKeyframe && m_param->bRepeatHeaders)<br>
         m_top->getStreamHeaders(m_nalList, m_entropyCoder, m_bs);<br>
<br>
+#if (defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7) || HAVE_LIBNUMA<br>
+    int numaNode = 0; // 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>
+    m_frame->m_encData->allocRecon(m_top->m_sps, numaNode); /* TODO: bail if failure */<br>
+    m_frame->m_encData->m_ownerNode = numaNode;<br>
+<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>
@@ -357,7 +367,9 @@<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_refFrameList[l][ref]->m_encData->allocRecon(m_top->m_sps, numaNode); /* TODO: bail if failure */<br>
+            slice->m_refReconPicList[l][ref] = slice->m_refFrameList[l][ref]->m_encData->m_nodes[numaNode].reconPic;<br>
+            m_mref[l][ref].init(slice->m_refReconPicList[l][ref], w, *m_param);<br>
         }<br>
     }<br>
<br>
@@ -477,7 +489,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>
@@ -501,12 +513,14 @@<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>
                         reconRowCount = refpic->m_reconRowCount.waitForChange(reconRowCount);<br>
<br>
+                    /* TODO: if refpic->m_encData->m_ownerNode != numaNode, copy rows */<br>
+<br>
                     if ((bUseWeightP || bUseWeightB) && m_mref[l][ref].isWeighted)<br>
                         m_mref[l][ref].applyWeight(row + m_refLagRows, m_numRows);<br>
                 }<br>
@@ -540,12 +554,14 @@<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>
                             reconRowCount = refpic->m_reconRowCount.waitForChange(reconRowCount);<br>
<br>
+                        /* TODO: if refpic->m_encData->m_ownerNode != numaNode, copy rows */<br>
+<br>
                         if ((bUseWeightP || bUseWeightB) && m_mref[l][ref].isWeighted)<br>
                             m_mref[list][ref].applyWeight(i + m_refLagRows, m_numRows);<br>
                     }<br>
@@ -697,7 +713,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 1f161d9c6e35 -r 02e84edaa143 source/encoder/framefilter.cpp<br>
--- a/source/encoder/framefilter.cpp    Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/framefilter.cpp    Mon Aug 03 17:55:58 2015 -0500<br>
@@ -160,7 +160,7 @@<br>
<br>
 void FrameFilter::processRowPost(int row)<br>
 {<br>
-    PicYuv *reconPic = m_frame->m_reconPic;<br>
+    PicYuv *reconPic = m_frame->m_encData->getOutputRecon();<br>
     const uint32_t numCols = m_frame->m_encData->m_slice->m_sps->numCuInWidth;<br>
     const uint32_t lineStartCUAddr = row * numCols;<br>
     const int realH = getCUHeight(row);<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 stride1 = reconPic->m_stride;<br>
+        intptr_t stride2 = m_frame->m_fencPic->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>
@@ -407,7 +407,7 @@<br>
     int size = cu->m_log2CUSize[absPartIdx] - 2;<br>
     uint32_t cuAddr = cu->m_cuAddr;<br>
<br>
-    PicYuv* reconPic = frame.m_reconPic;<br>
+    PicYuv* reconPic = frame.m_encData->getOutputRecon();<br>
     PicYuv* fencPic  = frame.m_fencPic;<br>
<br>
     pixel* dst = reconPic->getLumaAddr(cuAddr, absPartIdx);<br>
diff -r 1f161d9c6e35 -r 02e84edaa143 source/encoder/ratecontrol.cpp<br>
--- a/source/encoder/ratecontrol.cpp    Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/ratecontrol.cpp    Mon Aug 03 17:55:58 2015 -0500<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 1f161d9c6e35 -r 02e84edaa143 source/encoder/sao.cpp<br>
--- a/source/encoder/sao.cpp    Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/sao.cpp    Mon Aug 03 17:55:58 2015 -0500<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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 1f161d9c6e35 -r 02e84edaa143 source/encoder/search.cpp<br>
--- a/source/encoder/search.cpp Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/search.cpp Mon Aug 03 17:55:58 2015 -0500<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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_encData->getOutputRecon();<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 1f161d9c6e35 -r 02e84edaa143 source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp      Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/slicetype.cpp      Mon Aug 03 17:55:58 2015 -0500<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 1f161d9c6e35 -r 02e84edaa143 source/encoder/weightPrediction.cpp<br>
--- a/source/encoder/weightPrediction.cpp       Mon Aug 03 14:56:21 2015 -0500<br>
+++ b/source/encoder/weightPrediction.cpp       Mon Aug 03 17:55:58 2015 -0500<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>
_______________________________________________<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>
</blockquote></div><br></div>