[x265] [PATCH] LookAhead: Created the new DataStructure for lookahead, Downscaled the i/p frame and Created the MotionReference
gopu at multicorewareinc.com
gopu at multicorewareinc.com
Thu Aug 1 12:17:03 CEST 2013
# HG changeset patch
# User ggopu
# Date 1375352201 -19800
# Node ID c14cecae9d2860386df8653f33615035f976838a
# Parent 6a66dfc449bc0de03db82a590210b911d6787394
LookAhead: Created the new DataStructure for lookahead, Downscaled the i/p frame and Created the MotionReference
diff -r 6a66dfc449bc -r c14cecae9d28 source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp Thu Aug 01 11:33:03 2013 +0530
+++ b/source/Lib/TLibCommon/TComPic.cpp Thu Aug 01 15:46:41 2013 +0530
@@ -73,6 +73,17 @@
/* store display window parameters with picture */
m_defaultDisplayWindow = defaultDisplayWindow;
+
+ /* generates the lowres */
+ m_lookahead.width = m_origPicYuv->getWidth() / 2;
+ m_lookahead.lines = m_origPicYuv->getHeight() / 2;
+ m_lookahead.stride = m_lookahead.width + 2 * m_origPicYuv->getLumaMarginX();
+
+ /* allocate the buffer for lowres */
+ for (int i = 0; i < 4; i++)
+ {
+ m_lookahead.buffer[i] = (Pel*)X265_MALLOC(Pel, m_lookahead.stride * (m_lookahead.lines + 2 * m_origPicYuv->getLumaMarginY()));
+ }
}
Void TComPic::destroy()
diff -r 6a66dfc449bc -r c14cecae9d28 source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h Thu Aug 01 11:33:03 2013 +0530
+++ b/source/Lib/TLibCommon/TComPic.h Thu Aug 01 15:46:41 2013 +0530
@@ -68,6 +68,8 @@
public:
+ x265::Lookahead m_lookahead;
+
TComPic();
virtual ~TComPic();
diff -r 6a66dfc449bc -r c14cecae9d28 source/Lib/TLibCommon/TComPicYuv.h
--- a/source/Lib/TLibCommon/TComPicYuv.h Thu Aug 01 11:33:03 2013 +0530
+++ b/source/Lib/TLibCommon/TComPicYuv.h Thu Aug 01 15:46:41 2013 +0530
@@ -97,15 +97,14 @@
Bool m_bIsBorderExtended;
-protected:
-
- Void xExtendPicCompBorder(Pel* recon, Int stride, Int width, Int height, Int marginX, Int marginY);
public:
TComPicYuv();
virtual ~TComPicYuv();
+ Void xExtendPicCompBorder(Pel* recon, Int stride, Int width, Int height, Int marginX, Int marginY);
+
// ------------------------------------------------------------------------------------------------
// Memory management
// ------------------------------------------------------------------------------------------------
@@ -130,7 +129,9 @@
Int getCStride() { return m_strideC; }
- Int getLumaMargin() { return m_lumaMarginX; }
+ Int getLumaMarginX() { return m_lumaMarginX; }
+
+ Int getLumaMarginY() { return m_lumaMarginY; }
Int getChromaMargin() { return m_chromaMarginX; }
diff -r 6a66dfc449bc -r c14cecae9d28 source/Lib/TLibEncoder/TEncTop.cpp
--- a/source/Lib/TLibEncoder/TEncTop.cpp Thu Aug 01 11:33:03 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncTop.cpp Thu Aug 01 15:46:41 2013 +0530
@@ -162,6 +162,22 @@
pic->getPicYuvOrg()->copyFromPicture(*picture);
pic->getPicYuvRec()->clearExtendedFlag();
pic->getSlice()->setReferenced(true);
+
+ /* Until Lookahead implementation complete */
+ if (!true)
+ {
+ x265::Lookahead &lookahead = pic->m_lookahead;
+ /* downscale the luma planes */
+ x265::primitives.frame_init_lowres_core(pic->getPicYuvOrg()->getLumaAddr(), lookahead.buffer[0], lookahead.buffer[1], lookahead.buffer[2], lookahead.buffer[3], pic->getPicYuvOrg()->getStride(), lookahead.stride, lookahead.width, lookahead.lines);
+
+ for (int i = 0; i < 4; i++)
+ {
+ pic->getPicYuvOrg()->xExtendPicCompBorder(lookahead.buffer[i], lookahead.stride, lookahead.width, lookahead.lines, pic->getPicYuvOrg()->getLumaMarginX(), pic->getPicYuvOrg()->getLumaMarginY());
+ }
+
+ lookahead.mref = new x265::MotionReference(pic->getPicYuvOrg(), x265::ThreadPool::getThreadPool());
+ lookahead.mref->generateReferencePlanesLookAhead(pic->m_lookahead);
+ }
return;
}
}
diff -r 6a66dfc449bc -r c14cecae9d28 source/common/CMakeLists.txt
--- a/source/common/CMakeLists.txt Thu Aug 01 11:33:03 2013 +0530
+++ b/source/common/CMakeLists.txt Thu Aug 01 15:46:41 2013 +0530
@@ -45,7 +45,7 @@
md5.cpp md5.h
TShortYUV.cpp TShortYUV.h mv.h
reference.cpp reference.h
- common.cpp common.h)
+ common.cpp common.h lookahead.h)
if(ENABLE_PRIMITIVES_VEC)
add_subdirectory(vec)
diff -r 6a66dfc449bc -r c14cecae9d28 source/common/common.h
--- a/source/common/common.h Thu Aug 01 11:33:03 2013 +0530
+++ b/source/common/common.h Thu Aug 01 15:46:41 2013 +0530
@@ -94,6 +94,7 @@
#define X265_MAX3(a, b, c) X265_MAX((a), X265_MAX((b), (c)))
#define X265_MIN4(a, b, c, d) X265_MIN((a), X265_MIN3((b), (c), (d)))
#define X265_MAX4(a, b, c, d) X265_MAX((a), X265_MAX3((b), (c), (d)))
+#define X265_BFRAME_MAX 16
#define ENABLE_CYCLE_COUNTERS 0
#if ENABLE_CYCLE_COUNTERS
diff -r 6a66dfc449bc -r c14cecae9d28 source/common/lookahead.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/common/lookahead.h Thu Aug 01 15:46:41 2013 +0530
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Gopu Govindaswamy <gopu at multicorewareinc.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing at multicorewareinc.com.
+ *****************************************************************************/
+
+#include "x265.h"
+#include "common.h"
+
+namespace x265 {
+class MotionReference;
+
+typedef struct
+{
+ int costEst[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
+ int costEstaq[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
+ int *rowSatds[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2];
+ int intraMbs[X265_BFRAME_MAX + 2];
+ uint16_t(*lowresCosts[X265_BFRAME_MAX + 2][X265_BFRAME_MAX + 2]);
+ int *lowresmvCosts[2][X265_BFRAME_MAX + 1];
+ uint16_t *invQscaleFactor;
+ int16_t(*lowresMvs[2][X265_BFRAME_MAX + 1])[2];
+}LookaheadFrame;
+
+typedef struct
+{
+ pixel *buffer[4];
+ int stride;
+ int width;
+ int lines;
+ MotionReference *mref;
+ LookaheadFrame *frames;
+}Lookahead;
+}
diff -r 6a66dfc449bc -r c14cecae9d28 source/common/reference.cpp
--- a/source/common/reference.cpp Thu Aug 01 11:33:03 2013 +0530
+++ b/source/common/reference.cpp Thu Aug 01 15:46:41 2013 +0530
@@ -227,3 +227,26 @@
m_reconPic->m_lumaMarginX - s_tmpMarginX, m_reconPic->m_lumaMarginY - s_tmpMarginY);
}
}
+
+void MotionReference::generateReferencePlanesLookAhead(Lookahead look)
+{
+ m_lumaPlane[0][0] = look.buffer[0];
+ m_lumaPlane[1][0] = look.buffer[0];
+ m_lumaPlane[0][1] = look.buffer[0];
+ m_lumaPlane[1][1] = look.buffer[0];
+
+ m_lumaPlane[2][0] = look.buffer[1];
+ m_lumaPlane[3][0] = look.buffer[1];
+ m_lumaPlane[2][1] = look.buffer[1];
+ m_lumaPlane[3][1] = look.buffer[1];
+
+ m_lumaPlane[0][2] = look.buffer[2];
+ m_lumaPlane[1][2] = look.buffer[2];
+ m_lumaPlane[0][3] = look.buffer[2];
+ m_lumaPlane[1][3] = look.buffer[2];
+
+ m_lumaPlane[2][2] = look.buffer[3];
+ m_lumaPlane[3][2] = look.buffer[3];
+ m_lumaPlane[2][3] = look.buffer[3];
+ m_lumaPlane[3][3] = look.buffer[3];
+}
diff -r 6a66dfc449bc -r c14cecae9d28 source/common/reference.h
--- a/source/common/reference.h Thu Aug 01 11:33:03 2013 +0530
+++ b/source/common/reference.h Thu Aug 01 15:46:41 2013 +0530
@@ -27,6 +27,7 @@
#include "primitives.h"
#include "threading.h"
#include "threadpool.h"
+#include "lookahead.h"
class TComPicYuv;
struct WpScalingParam;
@@ -40,6 +41,7 @@
public:
MotionReference(TComPicYuv*, ThreadPool *, wpScalingParam* w = NULL);
+ void generateReferencePlanesLookAhead(Lookahead);
~MotionReference();
More information about the x265-devel
mailing list