[x265] [PATCH 1 of 2] Adding function applyWeight in MotionRefernce

shazeb at multicorewareinc.com shazeb at multicorewareinc.com
Tue Oct 1 10:25:14 CEST 2013


# HG changeset patch
# User Shazeb Nawaz Khan <shazeb at multicorewareinc.com>
# Date 1380615387 -19800
#      Tue Oct 01 13:46:27 2013 +0530
# Node ID b8fa0fa81997e668ad983618c2ccf9d76d75f83c
# Parent  051ccb452f2442ec9c054e2c8758df1843058bab
Adding function applyWeight in MotionRefernce...

to generate weighted full pel pixels for one or more rows

diff -r 051ccb452f24 -r b8fa0fa81997 source/common/reference.cpp
--- a/source/common/reference.cpp	Tue Oct 01 11:53:41 2013 +0530
+++ b/source/common/reference.cpp	Tue Oct 01 13:46:27 2013 +0530
@@ -62,6 +62,7 @@
     m_startPad = pic->m_lumaMarginY * lumaStride + pic->m_lumaMarginX;
     m_next = NULL;
     isWeighted = false;
+    m_numWeightedRows = 0;
 
     if (w)
     {
@@ -69,7 +70,6 @@
         int height = pic->getHeight();
         size_t padwidth = width + pic->m_lumaMarginX * 2;
         size_t padheight = height + pic->m_lumaMarginY * 2;
-
         setWeight(*w);
         fpelPlane = (pixel*)X265_MALLOC(pixel,  padwidth * padheight);
         if (fpelPlane) fpelPlane += m_startPad;
@@ -88,3 +88,46 @@
     if (isWeighted && fpelPlane)
         X265_FREE(fpelPlane - m_startPad);
 }
+
+void MotionReference::applyWeight(TComPic* ref, int rows, int numRows)
+{
+    TComPicYuv* pic = ref->getPicYuvRec();
+    int marginX = pic->m_lumaMarginX;
+    int marginY = pic->m_lumaMarginY;
+    pixel* src = (pixel*) pic->getLumaAddr() + (m_numWeightedRows * (int)g_maxCUHeight * lumaStride);
+    int width = pic->getWidth();
+    int height = ((rows - m_numWeightedRows) * g_maxCUHeight);
+    if (rows == numRows - 1)
+        height = ((pic->getHeight() % g_maxCUHeight) ? (pic->getHeight() % g_maxCUHeight) : g_maxCUHeight);
+    size_t dstStride = lumaStride;
+
+    // Computing weighted CU rows
+    int shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+    shift = shift + shiftNum;
+    round = shift ? (1 << (shift - 1)) : 0;
+    primitives.weightpUniPixel(src, fpelPlane, lumaStride, dstStride, width, height, weight, round, shift, offset);
+
+    // Extending Left & Right
+    primitives.extendRowBorder(fpelPlane, dstStride, width, height, marginX);
+
+    // Extending Above
+    if (m_numWeightedRows == 0)
+    {
+        pixel *pixY = fpelPlane - marginX;
+        for (int y = 0; y < marginY; y++)
+        {
+            memcpy(pixY - (y + 1) * dstStride, pixY, dstStride * sizeof(pixel));
+        }
+    }
+
+    // Extending Bottom
+    if (rows == (numRows - 1))
+    {
+        pixel *pixY = fpelPlane - marginX + (pic->getHeight() - 1) * dstStride;
+        for (int y = 0; y < marginY; y++)
+        {
+            memcpy(pixY + (y + 1) * dstStride, pixY, dstStride * sizeof(pixel));
+        }
+    }
+    m_numWeightedRows = rows;
+}
diff -r 051ccb452f24 -r b8fa0fa81997 source/common/reference.h
--- a/source/common/reference.h	Tue Oct 01 11:53:41 2013 +0530
+++ b/source/common/reference.h	Tue Oct 01 13:46:27 2013 +0530
@@ -60,9 +60,11 @@
     MotionReference();
     ~MotionReference();
     int  init(TComPicYuv*, wpScalingParam* w = NULL);
+    void applyWeight(TComPic* src, int rows, int numRows);
 
     MotionReference *m_next;
     TComPicYuv      *m_reconPic;
+    int              m_numWeightedRows;
 
 protected:
 


More information about the x265-devel mailing list