title: libx265 motion compensation and CU traverse
body: <p>I'm trying to play with the H.265 motion compensation and search (HEVC- libx265 implementation from here: <a href="https://bitbucket.org/multicoreware/x265/downloads" rel="nofollow noreferrer">https://bitbucket.org/multicoreware/x265/downloads</a>). I need to slightly extend the edge extension search, and fill the macro block with left-most pixels as if my sample videos are like cylinder (rightmost is connected to leftmost).</p>
  
  <p>What I need to do is basically this:</p>
  
  <p><a href="https://i.stack.imgur.com/KnzT1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KnzT1.png" alt="enter image description here"></a></p>
  
  <p>One way to do that is to modify the edge extension area (which is already in the code, in the <code>frameFilter.cpp</code>), and do that for rightmost and fill parts of blocks which are out with leftmost pixels. I identified the piece of code here which apparently is responsible for that. Can someone help me with implementing this feature?</p>
  
  <pre><code>if ((col == 0) | (col == m_frameFilter-&gt;m_numCols - 1))
      {
          // TODO: improve by process on Left or Right only
          primitives.extendRowBorder(reconPic-&gt;getLumaAddr(m_rowAddr), stride, reconPic-&gt;m_picWidth, realH, reconPic-&gt;m_lumaMarginX);
  
          if (m_frameFilter-&gt;m_param-&gt;internalCsp != X265_CSP_I400)
          {
              primitives.extendRowBorder(reconPic-&gt;getCbAddr(m_rowAddr), strideC, reconPic-&gt;m_picWidth &gt;&gt; hChromaShift, realH &gt;&gt; vChromaShift, reconPic-&gt;m_chromaMarginX);
              primitives.extendRowBorder(reconPic-&gt;getCrAddr(m_rowAddr), strideC, reconPic-&gt;m_picWidth &gt;&gt; hChromaShift, realH &gt;&gt; vChromaShift, reconPic-&gt;m_chromaMarginX);
          }
      }
  
      // Extra Left and Right border on first and last CU
      if ((col == 0) | (col == m_frameFilter-&gt;m_numCols - 1))
      {
          copySizeY += lumaMarginX;
          copySizeC += chromaMarginX;
      }
  
      // First column need extension left padding area and first CU
      if (col == 0)
      {
          pixY -= lumaMarginX;
          pixU -= chromaMarginX;
          pixV -= chromaMarginX;
      }
  </code></pre>