[x265-commits] [x265] lowres: pull lowres motion compensation and residual cost...
Steve Borho
steve at borho.org
Thu Nov 7 22:54:58 CET 2013
details: http://hg.videolan.org/x265/rev/9668c5b6373a
branches:
changeset: 4937:9668c5b6373a
user: Steve Borho <steve at borho.org>
date: Thu Nov 07 14:59:27 2013 -0600
description:
lowres: pull lowres motion compensation and residual costs into lowres struct
Subject: [x265] lowres: move ReferencePlanes from mv.h to lowres.h
details: http://hg.videolan.org/x265/rev/dac2888cbf4c
branches:
changeset: 4938:dac2888cbf4c
user: Steve Borho <steve at borho.org>
date: Thu Nov 07 15:04:49 2013 -0600
description:
lowres: move ReferencePlanes from mv.h to lowres.h
Subject: [x265] lowres: reorder members of Lowres struct for clarity
details: http://hg.videolan.org/x265/rev/5563bd58c1e3
branches:
changeset: 4939:5563bd58c1e3
user: Steve Borho <steve at borho.org>
date: Thu Nov 07 15:23:22 2013 -0600
description:
lowres: reorder members of Lowres struct for clarity
Subject: [x265] vec: remove use of deleted primitive for 16bpp
details: http://hg.videolan.org/x265/rev/014e3303ad3d
branches:
changeset: 4940:014e3303ad3d
user: Steve Borho <steve at borho.org>
date: Thu Nov 07 15:53:39 2013 -0600
description:
vec: remove use of deleted primitive for 16bpp
diffstat:
source/common/lowres.h | 90 +++++++++++++++++++++++++++++++----
source/common/mv.h | 17 ------
source/common/vec/blockcopy-sse3.cpp | 1 -
source/encoder/motion.cpp | 34 ++----------
source/encoder/reference.h | 1 +
source/encoder/slicetype.cpp | 51 ++------------------
6 files changed, 92 insertions(+), 102 deletions(-)
diffs (truncated from 317 to 300 lines):
diff -r cb24ed71905d -r 014e3303ad3d source/common/lowres.h
--- a/source/common/lowres.h Thu Nov 07 13:13:47 2013 +0800
+++ b/source/common/lowres.h Thu Nov 07 15:53:39 2013 -0600
@@ -29,24 +29,86 @@
#include "mv.h"
namespace x265 {
+// private namespace
+
class TComPic;
+class TComPicYuv;
+struct ReferencePlanes
+{
+ ReferencePlanes() : isWeighted(false), isLowres(false) {}
+
+ pixel* fpelPlane;
+ pixel* lowresPlane[4];
+ pixel* unweightedFPelPlane;
+
+ bool isWeighted;
+ bool isLowres;
+ int lumaStride;
+ int weight;
+ int offset;
+ int shift;
+ int round;
+
+ /* lowres motion compensation, you must provide a buffer and stride for QPEL averaged pixels
+ * in case QPEL is required. Else it returns a pointer to the HPEL pixels */
+ inline pixel *lowresMC(intptr_t blockOffset, const MV& qmv, pixel *buf, intptr_t& outstride)
+ {
+ if ((qmv.x | qmv.y) & 1)
+ {
+ int hpelA = (qmv.y & 2) | ((qmv.x & 2) >> 1);
+ pixel *frefA = lowresPlane[hpelA] + blockOffset + (qmv.x >> 2) + (qmv.y >> 2) * lumaStride;
+
+ MV qmvB = qmv + MV((qmv.x & 1) * 2, (qmv.y & 1) * 2);
+ int hpelB = (qmvB.y & 2) | ((qmvB.x & 2) >> 1);
+
+ pixel *frefB = lowresPlane[hpelB] + blockOffset + (qmvB.x >> 2) + (qmvB.y >> 2) * lumaStride;
+ primitives.pixelavg_pp[LUMA_8x8](buf, outstride, frefA, lumaStride, frefB, lumaStride, 32);
+ return buf;
+ }
+ else
+ {
+ outstride = lumaStride;
+ int hpel = (qmv.y & 2) | ((qmv.x & 2) >> 1);
+ return lowresPlane[hpel] + blockOffset + (qmv.x >> 2) + (qmv.y >> 2) * lumaStride;
+ }
+ }
+
+ inline int lowresQPelCost(pixel *fenc, intptr_t blockOffset, const MV& qmv, pixelcmp_t comp)
+ {
+ if ((qmv.x | qmv.y) & 1)
+ {
+ ALIGN_VAR_16(pixel, subpelbuf[8 * 8]);
+ int hpelA = (qmv.y & 2) | ((qmv.x & 2) >> 1);
+ pixel *frefA = lowresPlane[hpelA] + blockOffset + (qmv.x >> 2) + (qmv.y >> 2) * lumaStride;
+ MV qmvB = qmv + MV((qmv.x & 1) * 2, (qmv.y & 1) * 2);
+ int hpelB = (qmvB.y & 2) | ((qmvB.x & 2) >> 1);
+ pixel *frefB = lowresPlane[hpelB] + blockOffset + (qmvB.x >> 2) + (qmvB.y >> 2) * lumaStride;
+ primitives.pixelavg_pp[LUMA_8x8](subpelbuf, 8, frefA, lumaStride, frefB, lumaStride, 32);
+ return comp(fenc, FENC_STRIDE, subpelbuf, 8);
+ }
+ else
+ {
+ int hpel = (qmv.y & 2) | ((qmv.x & 2) >> 1);
+ pixel *fref = lowresPlane[hpel] + blockOffset + (qmv.x >> 2) + (qmv.y >> 2) * lumaStride;
+ return comp(fenc, FENC_STRIDE, fref, lumaStride);
+ }
+ }
+};
+
+/* lowres buffers, sizes and strides */
struct Lowres : public ReferencePlanes
{
- /* lowres buffers, sizes and strides */
pixel *buffer[4];
- double *qpAqOffset; // qp Aq offset values for each Cu
- int *invQscaleFactor; // qScale values for qp Aq Offsets
- int width; // width of lowres frame in pixels
- int lines; // height of lowres frame in pixel lines
- int frameNum; // Presentation frame number
- int sliceType; // Slice type decided by lookahead
- int leadingBframes; // number of leading B frames for P or I
- uint64_t wp_ssd[3]; // This is different than m_SSDY, this is sum(pixel^2) - sum(pixel)^2 for entire frame
- uint64_t wp_sum[3];
+
+ int frameNum; // Presentation frame number
+ int sliceType; // Slice type decided by lookahead
+ int width; // width of lowres frame in pixels
+ int lines; // height of lowres frame in pixel lines
+ int leadingBframes; // number of leading B frames for P or I
bool bIntraCalculated;
- bool bScenecut; // Set to false if the frame cannot possibly be part of a real scenecut.
+ bool bScenecut; // Set to false if the frame cannot possibly be part of a real scenecut.
bool bKeyframe;
bool bLastMiniGopBFrame;
@@ -61,6 +123,12 @@ struct Lowres : public ReferencePlanes
int32_t *lowresMvCosts[2][X265_BFRAME_MAX + 1];
MV *lowresMvs[2][X265_BFRAME_MAX + 1];
+ /* rate control / adaptive quant data */
+ double *qpAqOffset; // qp Aq offset values for each Cu
+ int *invQscaleFactor; // qScale values for qp Aq Offsets
+ uint64_t wp_ssd[3]; // This is different than SSDY, this is sum(pixel^2) - sum(pixel)^2 for entire frame
+ uint64_t wp_sum[3];
+
void create(TComPic *pic, int bframes, int32_t *aqMode);
void destroy(int bframes);
void init(TComPicYuv *orig, int poc, int sliceType, int bframes);
diff -r cb24ed71905d -r 014e3303ad3d source/common/mv.h
--- a/source/common/mv.h Thu Nov 07 13:13:47 2013 +0800
+++ b/source/common/mv.h Thu Nov 07 15:53:39 2013 -0600
@@ -99,23 +99,6 @@ public:
return x >= _min.x && x <= _max.x && y >= _min.y && y <= _max.y;
}
};
-
-struct ReferencePlanes
-{
- ReferencePlanes() : isWeighted(false), isLowres(false) {}
-
- pixel* fpelPlane;
- pixel* lowresPlane[4];
- pixel* unweightedFPelPlane;
-
- bool isWeighted;
- bool isLowres;
- int lumaStride;
- int weight;
- int offset;
- int shift;
- int round;
-};
}
#endif // ifndef X265_MV_H
diff -r cb24ed71905d -r 014e3303ad3d source/common/vec/blockcopy-sse3.cpp
--- a/source/common/vec/blockcopy-sse3.cpp Thu Nov 07 13:13:47 2013 +0800
+++ b/source/common/vec/blockcopy-sse3.cpp Thu Nov 07 15:53:39 2013 -0600
@@ -387,7 +387,6 @@ void Setup_Vec_BlockCopyPrimitives_sse3(
#if HIGH_BIT_DEPTH
// At high bit depth, a pixel is a short
- p.blockcpy_sc = (blockcpy_sc_t)blockcopy_sp;
p.pixeladd_pp = (pixeladd_pp_t)pixeladd_ss;
p.pixeladd_ss = pixeladd_ss;
#else
diff -r cb24ed71905d -r 014e3303ad3d source/encoder/motion.cpp
--- a/source/encoder/motion.cpp Thu Nov 07 13:13:47 2013 +0800
+++ b/source/encoder/motion.cpp Thu Nov 07 15:53:39 2013 -0600
@@ -21,11 +21,12 @@
* For more information, contact us at licensing at multicorewareinc.com.
*****************************************************************************/
+#include "TLibCommon/TComRom.h"
#include "primitives.h"
#include "common.h"
+#include "lowres.h"
#include "motion.h"
#include "x265.h"
-#include "TLibCommon/TComRom.h"
#include <string.h>
#include <stdio.h>
@@ -532,27 +533,6 @@ void MotionEstimate::StarPatternSearch(R
}
}
-static inline int lowresQPelCost(ReferencePlanes *ref, pixel *fenc, intptr_t blockOffset, const MV& qmv, pixelcmp_t comp)
-{
- if ((qmv.x | qmv.y) & 1)
- {
- ALIGN_VAR_16(pixel, subpelbuf[8 * 8]);
- int hpelA = (qmv.y & 2) | ((qmv.x & 2) >> 1);
- pixel *frefA = ref->lowresPlane[hpelA] + blockOffset + (qmv.x >> 2) + (qmv.y >> 2) * ref->lumaStride;
- MV qmvB = qmv + MV((qmv.x & 1) * 2, (qmv.y & 1) * 2);
- int hpelB = (qmvB.y & 2) | ((qmvB.x & 2) >> 1);
- pixel *frefB = ref->lowresPlane[hpelB] + blockOffset + (qmvB.x >> 2) + (qmvB.y >> 2) * ref->lumaStride;
- primitives.pixelavg_pp[LUMA_8x8](subpelbuf, 8, frefA, ref->lumaStride, frefB, ref->lumaStride, 32);
- return comp(fenc, FENC_STRIDE, subpelbuf, 8);
- }
- else
- {
- int hpel = (qmv.y & 2) | ((qmv.x & 2) >> 1);
- pixel *fref = ref->lowresPlane[hpel] + blockOffset + (qmv.x >> 2) + (qmv.y >> 2) * ref->lumaStride;
- return comp(fenc, FENC_STRIDE, fref, ref->lumaStride);
- }
-}
-
int MotionEstimate::motionEstimate(ReferencePlanes *ref,
const MV & mvmin,
const MV & mvmax,
@@ -584,7 +564,7 @@ int MotionEstimate::motionEstimate(Refer
int bprecost;
if (ref->isLowres)
- bprecost = lowresQPelCost(ref, fenc, blockOffset, pmv, sad);
+ bprecost = ref->lowresQPelCost(fenc, blockOffset, pmv, sad);
else
bprecost = subpelCompare(ref, pmv, sad);
@@ -615,7 +595,7 @@ int MotionEstimate::motionEstimate(Refer
{
int cost;
if (ref->isLowres)
- cost = lowresQPelCost(ref, fenc, blockOffset, m, sad) + mvcost(m);
+ cost = ref->lowresQPelCost(fenc, blockOffset, m, sad) + mvcost(m);
else
cost = subpelCompare(ref, m, sad) + mvcost(m);
@@ -1083,17 +1063,17 @@ me_hex2:
for (int i = 1; i <= wl.hpel_dirs; i++)
{
MV qmv = bmv + square1[i] * 2;
- cost = lowresQPelCost(ref, fenc, blockOffset, qmv, sad) + mvcost(qmv);
+ cost = ref->lowresQPelCost(fenc, blockOffset, qmv, sad) + mvcost(qmv);
COPY2_IF_LT(bcost, cost, bdir, i);
}
bmv += square1[bdir] * 2;
- bcost = lowresQPelCost(ref, fenc, blockOffset, bmv, satd) + mvcost(bmv);
+ bcost = ref->lowresQPelCost(fenc, blockOffset, bmv, satd) + mvcost(bmv);
bdir = 0;
for (int i = 1; i <= wl.qpel_dirs; i++)
{
MV qmv = bmv + square1[i];
- cost = lowresQPelCost(ref, fenc, blockOffset, qmv, satd) + mvcost(qmv);
+ cost = ref->lowresQPelCost(fenc, blockOffset, qmv, satd) + mvcost(qmv);
COPY2_IF_LT(bcost, cost, bdir, i);
}
bmv += square1[bdir];
diff -r cb24ed71905d -r 014e3303ad3d source/encoder/reference.h
--- a/source/encoder/reference.h Thu Nov 07 13:13:47 2013 +0800
+++ b/source/encoder/reference.h Thu Nov 07 15:53:39 2013 -0600
@@ -25,6 +25,7 @@
#define X265_REFERENCE_H
#include "primitives.h"
+#include "lowres.h"
#include "mv.h"
namespace x265 {
diff -r cb24ed71905d -r 014e3303ad3d source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp Thu Nov 07 13:13:47 2013 +0800
+++ b/source/encoder/slicetype.cpp Thu Nov 07 15:53:39 2013 -0600
@@ -359,61 +359,20 @@ void LookaheadRow::estimateCUCost(int cu
}
if (bBidir)
{
- pixel subpelbuf1[X265_LOWRES_CU_SIZE * X265_LOWRES_CU_SIZE], subpelbuf2[X265_LOWRES_CU_SIZE * X265_LOWRES_CU_SIZE];
- pixel *src0, *src1;
- intptr_t stride0, stride1;
- if (((*fenc_mvs[0]).x | (*fenc_mvs[0]).y) & 1)
- {
- int hpelA = ((*fenc_mvs[0]).y & 2) | (((*fenc_mvs[0]).x & 2) >> 1);
- pixel *frefA = fref0->lowresPlane[hpelA] + pelOffset + ((*fenc_mvs[0]).x >> 2) + ((*fenc_mvs[0]).y >> 2) * fref0->lumaStride;
-
- MV qmvB = (*fenc_mvs[0]) + MV(((*fenc_mvs[0]).x & 1) * 2, ((*fenc_mvs[0]).y & 1) * 2);
- int hpelB = (qmvB.y & 2) | ((qmvB.x & 2) >> 1);
- pixel *frefB = fref0->lowresPlane[hpelB] + pelOffset + (qmvB.x >> 2) + (qmvB.y >> 2) * fref0->lumaStride;
-
- primitives.pixelavg_pp[LUMA_8x8](subpelbuf1, X265_LOWRES_CU_SIZE, frefA, fref0->lumaStride, frefB, fref0->lumaStride, 32);
- src0 = subpelbuf1;
- stride0 = X265_LOWRES_CU_SIZE;
- }
- else
- {
- /* FPEL/HPEL */
- int hpel = ((*fenc_mvs[0]).y & 2) | (((*fenc_mvs[0]).x & 2) >> 1);
- src0 = fref0->lowresPlane[hpel] + pelOffset + ((*fenc_mvs[0]).x >> 2) + ((*fenc_mvs[0]).y >> 2) * fref0->lumaStride;
- stride0 = fref0->lumaStride;
- }
- if (((*fenc_mvs[1]).x | (*fenc_mvs[1]).y) & 1)
- {
- int hpelA = ((*fenc_mvs[1]).y & 2) | (((*fenc_mvs[1]).x & 2) >> 1);
- pixel *frefA = fref1->lowresPlane[hpelA] + pelOffset + ((*fenc_mvs[1]).x >> 2) + ((*fenc_mvs[1]).y >> 2) * fref1->lumaStride;
-
- MV qmvB = (*fenc_mvs[1]) + MV(((*fenc_mvs[1]).x & 1) * 2, ((*fenc_mvs[1]).y & 1) * 2);
- int hpelB = (qmvB.y & 2) | ((qmvB.x & 2) >> 1);
- pixel *frefB = fref1->lowresPlane[hpelB] + pelOffset + (qmvB.x >> 2) + (qmvB.y >> 2) * fref1->lumaStride;
-
- primitives.pixelavg_pp[LUMA_8x8](subpelbuf2, X265_LOWRES_CU_SIZE, frefA, fref1->lumaStride, frefB, fref1->lumaStride, 32);
- src1 = subpelbuf2;
- stride1 = X265_LOWRES_CU_SIZE;
- }
- else
- {
- int hpel = ((*fenc_mvs[1]).y & 2) | (((*fenc_mvs[1]).x & 2) >> 1);
- src1 = fref1->lowresPlane[hpel] + pelOffset + ((*fenc_mvs[1]).x >> 2) + ((*fenc_mvs[1]).y >> 2) * fref1->lumaStride;
- stride1 = fref1->lumaStride;
- }
+ pixel subpelbuf0[X265_LOWRES_CU_SIZE * X265_LOWRES_CU_SIZE], subpelbuf1[X265_LOWRES_CU_SIZE * X265_LOWRES_CU_SIZE];
+ intptr_t stride0 = X265_LOWRES_CU_SIZE, stride1 = X265_LOWRES_CU_SIZE;
+ pixel *src0 = fref0->lowresMC(pelOffset, *fenc_mvs[0], subpelbuf0, stride0);
+ pixel *src1 = fref1->lowresMC(pelOffset, *fenc_mvs[1], subpelbuf1, stride1);
More information about the x265-commits
mailing list