[x265] [PATCH 2 of 3] MotionReference class with weighted frames
deepthidevaki at multicorewareinc.com
deepthidevaki at multicorewareinc.com
Tue Jul 30 13:39:50 CEST 2013
# HG changeset patch
# User Deepthi Devaki
# Date 1375183553 -19800
# Node ID 25b74f97e87324d065c10a25d2c5ee85b1db4792
# Parent 9e7928fc81d7bdf95f35f90e09349b016b8e4582
MotionReference class with weighted frames
diff -r 9e7928fc81d7 -r 25b74f97e873 source/common/reference.cpp
--- a/source/common/reference.cpp Tue Jul 30 16:54:06 2013 +0530
+++ b/source/common/reference.cpp Tue Jul 30 16:55:53 2013 +0530
@@ -38,7 +38,7 @@
#error "Must define atomic operations for this compiler"
#endif
-MotionReference::MotionReference(TComPicYuv* pic, ThreadPool *pool)
+MotionReference::MotionReference(TComPicYuv* pic, ThreadPool *pool, wpScalingParam *w)
: JobProvider(pool)
{
m_reconPic = pic;
@@ -59,14 +59,39 @@
/* Create buffers for Hpel/Qpel Planes */
size_t padwidth = width + pic->m_lumaMarginX * 2;
size_t padheight = height + pic->m_lumaMarginY * 2;
- for (int i = 0; i < 4; i++)
+
+ if(w!=NULL)
{
- for (int j = 0; j < 4; j++)
+ for (int i = 0; i < 4; i++)
{
- if (i == 0 && j == 0)
- continue;
- m_lumaPlane[i][j] = (pixel*)X265_MALLOC(pixel, padwidth * padheight) + m_startPad;
+ for (int j = 0; j < 4; j++)
+ {
+ m_lumaPlane[i][j] = (pixel*)X265_MALLOC(pixel, padwidth * padheight) + m_startPad;
+ }
}
+
+ //Initialization of weight parameters
+ m_weight = w->inputWeight;
+ m_offset = w->inputOffset * (1 << (g_bitDepth - 8));
+ m_shift = w->log2WeightDenom;
+ m_round = (w->log2WeightDenom >= 1) ? (1 << (w->log2WeightDenom - 1)) : (0);
+ m_isWeighted = true;
+ }
+ else
+ {
+
+ for (int i = 0; i < 4; i++)
+ {
+ for (int j = 0; j < 4; j++)
+ {
+ if (i == 0 && j == 0)
+ continue;
+ m_lumaPlane[i][j] = (pixel*)X265_MALLOC(pixel, padwidth * padheight) + m_startPad;
+ }
+ }
+
+ m_isWeighted = false;
+ m_weight = 0;
}
}
@@ -78,7 +103,7 @@
{
for (int j = 0; j < 4; j++)
{
- if (i == 0 && j == 0)
+ if (i == 0 && j == 0 && !m_isWeighted)
continue;
if (m_lumaPlane[i][j])
{
@@ -105,7 +130,23 @@
/* This one function call generates the four intermediate (short) planes for each
* QPEL offset in the horizontal direction. At the same time it outputs the three
* Y=0 output (padded pixel) planes since they require no vertical interpolation */
- primitives.filterHmulti(srcPtr, m_lumaStride, // source buffer
+ if(m_isWeighted)
+ {
+ primitives.filterHwghtd(srcPtr, m_lumaStride, // source buffer
+ intPtrF, intPtrA, intPtrB, intPtrC, m_intStride, // 4 intermediate HPEL buffers
+ m_lumaPlane[0][0] + bufOffset,
+ m_lumaPlane[1][0] + bufOffset,
+ m_lumaPlane[2][0] + bufOffset,
+ m_lumaPlane[3][0] + bufOffset, m_lumaStride, // 3 (x=n, y=0) output buffers (no V interp)
+ m_filterWidth + (2 * s_intMarginX), // filter dimensions with margins
+ m_filterHeight + (2 * s_intMarginY),
+ m_reconPic->m_lumaMarginX - s_tmpMarginX - s_intMarginX, // pixel extension margins
+ m_reconPic->m_lumaMarginY - s_tmpMarginY - s_intMarginY,
+ m_weight, m_round, m_shift, m_offset);
+ }
+ else
+ {
+ primitives.filterHmulti(srcPtr, m_lumaStride, // source buffer
intPtrF, intPtrA, intPtrB, intPtrC, m_intStride, // 4 intermediate HPEL buffers
m_lumaPlane[1][0] + bufOffset,
m_lumaPlane[2][0] + bufOffset,
@@ -114,6 +155,7 @@
m_filterHeight + (2 * s_intMarginY),
m_reconPic->m_lumaMarginX - s_tmpMarginX - s_intMarginX, // pixel extension margins
m_reconPic->m_lumaMarginY - s_tmpMarginY - s_intMarginY);
+ }
}
if (!m_pool)
@@ -173,5 +215,12 @@
pixel *dstPtr2 = m_lumaPlane[x][2] - s_tmpMarginY * m_lumaStride - s_tmpMarginX;
pixel *dstPtr3 = m_lumaPlane[x][3] - s_tmpMarginY * m_lumaStride - s_tmpMarginX;
- primitives.filterVmulti(intPtr, m_intStride, dstPtr1, dstPtr2, dstPtr3, m_lumaStride, m_filterWidth, m_filterHeight, m_reconPic->m_lumaMarginX - s_tmpMarginX, m_reconPic->m_lumaMarginY - s_tmpMarginY);
+ if(m_isWeighted)
+ {
+ primitives.filterVwghtd(intPtr, m_intStride, dstPtr1, dstPtr2, dstPtr3, m_lumaStride, m_filterWidth, m_filterHeight, m_reconPic->m_lumaMarginX - s_tmpMarginX, m_reconPic->m_lumaMarginY - s_tmpMarginY, m_weight, m_round, m_shift, m_offset);
+ }
+ else
+ {
+ primitives.filterVmulti(intPtr, m_intStride, dstPtr1, dstPtr2, dstPtr3, m_lumaStride, m_filterWidth, m_filterHeight, m_reconPic->m_lumaMarginX - s_tmpMarginX, m_reconPic->m_lumaMarginY - s_tmpMarginY);
+ }
}
diff -r 9e7928fc81d7 -r 25b74f97e873 source/common/reference.h
--- a/source/common/reference.h Tue Jul 30 16:54:06 2013 +0530
+++ b/source/common/reference.h Tue Jul 30 16:55:53 2013 +0530
@@ -27,6 +27,7 @@
#include "primitives.h"
#include "threading.h"
#include "threadpool.h"
+#include "TLibCommon/TComSlice.h"
class TComPicYuv;
@@ -37,7 +38,7 @@
{
public:
- MotionReference(TComPicYuv*, ThreadPool *);
+ MotionReference(TComPicYuv*, ThreadPool *, wpScalingParam* w = NULL );
~MotionReference();
@@ -49,6 +50,8 @@
int m_lumaStride;
MotionReference *m_next;
+ int m_weight;
+ bool m_isWeighted;
protected:
@@ -75,6 +78,10 @@
int m_filterHeight;
short *m_intermediateValues;
+ int m_offset;
+ int m_shift;
+ int m_round;
+
MotionReference& operator =(const MotionReference&);
};
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-2.patch
Type: text/x-patch
Size: 6296 bytes
Desc: not available
URL: <http://mailman.videolan.org/private/x265-devel/attachments/20130730/d0998a42/attachment-0001.bin>
More information about the x265-devel
mailing list