[x265-commits] [x265] frameencoder: make m_ssimCnt an unsigned int
Steve Borho
steve at borho.org
Wed Jun 18 08:50:34 CEST 2014
details: http://hg.videolan.org/x265/rev/cd63ddf0e935
branches:
changeset: 7114:cd63ddf0e935
user: Steve Borho <steve at borho.org>
date: Wed Jun 18 01:03:49 2014 -0500
description:
frameencoder: make m_ssimCnt an unsigned int
Subject: [x265] pic: keep the recon TComPicYuv in the pool with the TComPicSym - another 10%
details: http://hg.videolan.org/x265/rev/e3418f7497e9
branches:
changeset: 7115:e3418f7497e9
user: Steve Borho <steve at borho.org>
date: Wed Jun 18 01:47:38 2014 -0500
description:
pic: keep the recon TComPicYuv in the pool with the TComPicSym - another 10%
diffstat:
source/Lib/TLibCommon/TComPic.cpp | 13 ++++++++-----
source/Lib/TLibCommon/TComPic.h | 2 +-
source/Lib/TLibCommon/TComPicSym.h | 2 ++
source/encoder/dpb.cpp | 1 +
source/encoder/encoder.cpp | 3 ++-
source/encoder/frameencoder.h | 2 +-
source/encoder/framefilter.cpp | 10 +++++-----
7 files changed, 20 insertions(+), 13 deletions(-)
diffs (162 lines):
diff -r a43a223a1294 -r e3418f7497e9 source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp Wed Jun 18 00:04:09 2014 -0500
+++ b/source/Lib/TLibCommon/TComPic.cpp Wed Jun 18 01:47:38 2014 -0500
@@ -87,13 +87,11 @@ bool TComPic::create(Encoder* top)
m_defaultDisplayWindow = top->m_defaultDisplayWindow;
m_origPicYuv = new TComPicYuv;
- m_reconPicYuv = new TComPicYuv;
- if (!m_origPicYuv || !m_reconPicYuv)
+ if (!m_origPicYuv)
return false;
bool ok = true;
ok &= m_origPicYuv->create(top->m_param->sourceWidth, top->m_param->sourceHeight, top->m_param->internalCsp, g_maxCUSize, g_maxCUDepth);
- ok &= m_reconPicYuv->create(top->m_param->sourceWidth, top->m_param->sourceHeight, top->m_param->internalCsp, g_maxCUSize, g_maxCUDepth);
ok &= m_lowres.create(m_origPicYuv, top->m_param->bframes, !!top->m_param->rc.aqMode);
bool isVbv = top->m_param->rc.vbvBufferSize > 0 && top->m_param->rc.vbvMaxBitrate > 0;
@@ -130,8 +128,13 @@ fail:
bool TComPic::allocPicSym(Encoder* top)
{
m_picSym = new TComPicSym;
- if (m_picSym)
- return m_picSym->create(top->m_param->sourceWidth, top->m_param->sourceHeight, top->m_param->internalCsp);
+ m_reconPicYuv = new TComPicYuv;
+ if (m_picSym && m_reconPicYuv)
+ {
+ m_picSym->m_reconPicYuv = m_reconPicYuv;
+ return m_picSym->create(top->m_param->sourceWidth, top->m_param->sourceHeight, top->m_param->internalCsp) &&
+ m_reconPicYuv->create(top->m_param->sourceWidth, top->m_param->sourceHeight, top->m_param->internalCsp, g_maxCUSize, g_maxCUDepth);
+ }
else
return false;
}
diff -r a43a223a1294 -r e3418f7497e9 source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h Wed Jun 18 00:04:09 2014 -0500
+++ b/source/Lib/TLibCommon/TComPic.h Wed Jun 18 01:47:38 2014 -0500
@@ -53,7 +53,6 @@ class TComPic
private:
TComPicYuv* m_origPicYuv;
- TComPicYuv* m_reconPicYuv;
Window m_conformanceWindow;
Window m_defaultDisplayWindow;
@@ -63,6 +62,7 @@ private:
public:
TComPicSym* m_picSym;
+ TComPicYuv* m_reconPicYuv;
int m_POC;
//** Frame Parallelism - notification between FrameEncoders of available motion reference rows **
diff -r a43a223a1294 -r e3418f7497e9 source/Lib/TLibCommon/TComPicSym.h
--- a/source/Lib/TLibCommon/TComPicSym.h Wed Jun 18 00:04:09 2014 -0500
+++ b/source/Lib/TLibCommon/TComPicSym.h Wed Jun 18 01:47:38 2014 -0500
@@ -48,6 +48,7 @@ namespace x265 {
struct SAOParam;
class TComSampleAdaptiveOffset;
+class TComPicYuv;
//! \ingroup TLibCommon
//! \{
@@ -79,6 +80,7 @@ private:
public:
TComPicSym* m_freeListNext;
+ TComPicYuv* m_reconPicYuv;
bool create(int picWidth, int picHeight, int picCsp);
void destroy();
diff -r a43a223a1294 -r e3418f7497e9 source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp Wed Jun 18 00:04:09 2014 -0500
+++ b/source/encoder/dpb.cpp Wed Jun 18 01:47:38 2014 -0500
@@ -78,6 +78,7 @@ void DPB::recycleUnreferenced()
pic->m_picSym->m_freeListNext = m_picSymFreeList;
m_picSymFreeList = pic->m_picSym;
pic->m_picSym = NULL;
+ pic->m_reconPicYuv = NULL;
}
}
}
diff -r a43a223a1294 -r e3418f7497e9 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp Wed Jun 18 00:04:09 2014 -0500
+++ b/source/encoder/encoder.cpp Wed Jun 18 01:47:38 2014 -0500
@@ -449,6 +449,7 @@ int Encoder::encode(bool flush, const x2
{
fenc->m_picSym = m_dpb->m_picSymFreeList;
m_dpb->m_picSymFreeList = m_dpb->m_picSymFreeList->m_freeListNext;
+ fenc->m_reconPicYuv = fenc->m_picSym->m_reconPicYuv;
}
else
{
@@ -873,7 +874,7 @@ void Encoder::finishFrameStats(TComPic*
}
double ssim = 0.0;
- if (m_param->bEnableSsim && curEncoder->m_ssimCnt > 0)
+ if (m_param->bEnableSsim && curEncoder->m_ssimCnt)
{
ssim = curEncoder->m_ssim / curEncoder->m_ssimCnt;
m_analyzeAll.addSsim(ssim);
diff -r a43a223a1294 -r e3418f7497e9 source/encoder/frameencoder.h
--- a/source/encoder/frameencoder.h Wed Jun 18 00:04:09 2014 -0500
+++ b/source/encoder/frameencoder.h Wed Jun 18 01:47:38 2014 -0500
@@ -161,7 +161,7 @@ public:
uint64_t m_SSDU;
uint64_t m_SSDV;
double m_ssim;
- int m_ssimCnt;
+ uint32_t m_ssimCnt;
MD5Context m_state[3];
uint32_t m_crc[3];
uint32_t m_checksum[3];
diff -r a43a223a1294 -r e3418f7497e9 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp Wed Jun 18 00:04:09 2014 -0500
+++ b/source/encoder/framefilter.cpp Wed Jun 18 01:47:38 2014 -0500
@@ -31,7 +31,7 @@
using namespace x265;
static uint64_t computeSSD(pixel *fenc, pixel *rec, int stride, int width, int height);
-static float calculateSSIM(pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2, int width, int height, void *buf, int32_t *cnt);
+static float calculateSSIM(pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2, int width, int height, void *buf, uint32_t& cnt);
// **************************************************************************
// * LoopFilter
@@ -305,14 +305,14 @@ void FrameFilter::processRowPost(int row
int bStart = (row == 0);
int minPixY = row * g_maxCUSize - 4 * !bStart;
int maxPixY = (row + 1) * g_maxCUSize - 4 * !bEnd;
- int ssim_cnt;
+ uint32_t ssim_cnt;
x265_emms();
/* SSIM is done for each row in blocks of 4x4 . The First blocks are offset by 2 pixels to the right
* to avoid alignment of ssim blocks with DCT blocks. */
minPixY += bStart ? 2 : -6;
m_frame->m_ssim += calculateSSIM(rec + 2 + minPixY * stride1, stride1, org + 2 + minPixY * stride2, stride2,
- m_param->sourceWidth - 2, maxPixY - minPixY, m_ssimBuf, &ssim_cnt);
+ m_param->sourceWidth - 2, maxPixY - minPixY, m_ssimBuf, ssim_cnt);
m_frame->m_ssimCnt += ssim_cnt;
}
if (m_param->decodedPictureHashSEI == 1)
@@ -473,7 +473,7 @@ static uint64_t computeSSD(pixel *fenc,
}
/* Function to calculate SSIM for each row */
-static float calculateSSIM(pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2, int width, int height, void *buf, int32_t* cnt)
+static float calculateSSIM(pixel *pix1, intptr_t stride1, pixel *pix2, intptr_t stride2, int width, int height, void *buf, uint32_t& cnt)
{
int z = 0;
float ssim = 0.0;
@@ -502,7 +502,7 @@ static float calculateSSIM(pixel *pix1,
}
}
- *cnt = (height - 1) * (width - 1);
+ cnt = (height - 1) * (width - 1);
return ssim;
}
More information about the x265-commits
mailing list