[x265] [PATCH 7 of 8] sao & deblock: modify to support 400 color space
mahesh at multicorewareinc.com
mahesh at multicorewareinc.com
Mon Dec 14 20:30:13 CET 2015
# HG changeset patch
# User Mahesh Pittala <mahesh at multicorewareinc.com>
# Date 1450020147 -19800
# Sun Dec 13 20:52:27 2015 +0530
# Node ID 0d093168ca335e0f90ff21d272841df51b17056b
# Parent baaed1362ececcd0d9f38720d1462f815c47165e
sao & deblock: modify to support 400 color space
diff -r baaed1362ece -r 0d093168ca33 source/common/deblock.cpp
--- a/source/common/deblock.cpp Sun Dec 13 20:46:00 2015 +0530
+++ b/source/common/deblock.cpp Sun Dec 13 20:52:27 2015 +0530
@@ -109,7 +109,7 @@
for (uint32_t e = 0; e < numUnits; e += partIdxIncr)
{
edgeFilterLuma(cu, absPartIdx, depth, dir, e, blockStrength);
- if (!((e0 + e) & chromaMask))
+ if (!((e0 + e) & chromaMask) && cu->m_chromaFormat != X265_CSP_I400)
edgeFilterChroma(cu, absPartIdx, depth, dir, e, blockStrength);
}
}
diff -r baaed1362ece -r 0d093168ca33 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp Sun Dec 13 20:46:00 2015 +0530
+++ b/source/encoder/sao.cpp Sun Dec 13 20:52:27 2015 +0530
@@ -107,7 +107,7 @@
const pixel rangeExt = maxY >> 1;
int numCtu = m_numCuInWidth * m_numCuInHeight;
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < (param->internalCsp != X265_CSP_I400 ? 3 : 1); i++)
{
CHECKED_MALLOC(m_tmpL1[i], pixel, g_maxCUSize + 1);
CHECKED_MALLOC(m_tmpL2[i], pixel, g_maxCUSize + 1);
@@ -214,11 +214,11 @@
/* allocate memory for SAO parameters */
void SAO::allocSaoParam(SAOParam* saoParam) const
{
+ int planes = (m_param->internalCsp != X265_CSP_I400) ? 3 : 1;
saoParam->numCuInWidth = m_numCuInWidth;
- saoParam->ctuParam[0] = new SaoCtuParam[m_numCuInHeight * m_numCuInWidth];
- saoParam->ctuParam[1] = new SaoCtuParam[m_numCuInHeight * m_numCuInWidth];
- saoParam->ctuParam[2] = new SaoCtuParam[m_numCuInHeight * m_numCuInWidth];
+ for (int i = 0; i < planes; i++)
+ saoParam->ctuParam[i] = new SaoCtuParam[m_numCuInHeight * m_numCuInWidth];
}
void SAO::startSlice(Frame* frame, Entropy& initState, int qp)
@@ -259,7 +259,7 @@
}
saoParam->bSaoFlag[0] = true;
- saoParam->bSaoFlag[1] = true;
+ saoParam->bSaoFlag[1] = m_param->internalCsp != X265_CSP_I400;
m_numNoSao[0] = 0; // Luma
m_numNoSao[1] = 0; // Chroma
@@ -982,7 +982,7 @@
memset(m_offsetOrgPreDblk[addr], 0, sizeof(PerPlane));
int plane_offset = 0;
- for (int plane = 0; plane < NUM_PLANE; plane++)
+ for (int plane = 0; plane < (frame->m_param->internalCsp != X265_CSP_I400 ? NUM_PLANE : 1); plane++)
{
if (plane == 1)
{
@@ -1283,8 +1283,8 @@
}
saoComponentParamDist(saoParam, addr, addrUp, addrLeft, &mergeSaoParam[0][0], mergeDist);
-
- sao2ChromaParamDist(saoParam, addr, addrUp, addrLeft, mergeSaoParam, mergeDist);
+ if (m_chromaFormat != X265_CSP_I400)
+ sao2ChromaParamDist(saoParam, addr, addrUp, addrLeft, mergeSaoParam, mergeDist);
if (saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1])
{
@@ -1336,8 +1336,9 @@
if (saoParam->ctuParam[0][addr].typeIdx < 0)
m_numNoSao[0]++;
- if (saoParam->ctuParam[1][addr].typeIdx < 0)
+ if (m_chromaFormat != X265_CSP_I400 && saoParam->ctuParam[1][addr].typeIdx < 0)
m_numNoSao[1]++;
+
m_entropyCoder.load(m_rdContexts.temp);
m_entropyCoder.store(m_rdContexts.cur);
}
@@ -1353,6 +1354,9 @@
const int addrUp = rowBaseAddr ? addr - m_numCuInWidth : -1;
const int addrLeft = idxX ? addr - 1 : -1;
+ bool chroma = m_param->internalCsp != X265_CSP_I400;
+ int planes = chroma ? 3 : 1;
+
m_entropyCoder.load(m_rdContexts.cur);
if (allowMerge[0])
m_entropyCoder.codeSaoMerge(0);
@@ -1375,9 +1379,8 @@
memset(m_offsetOrg, 0, sizeof(m_offsetOrg));
}
- saoParam->ctuParam[0][addr].reset();
- saoParam->ctuParam[1][addr].reset();
- saoParam->ctuParam[2][addr].reset();
+ for (int i = 0; i < planes; i++)
+ saoParam->ctuParam[i][addr].reset();
if (saoParam->bSaoFlag[0])
calcSaoStatsCu(addr, 0);
@@ -1389,8 +1392,8 @@
}
saoComponentParamDist(saoParam, addr, addrUp, addrLeft, &mergeSaoParam[0][0], mergeDist);
-
- sao2ChromaParamDist(saoParam, addr, addrUp, addrLeft, mergeSaoParam, mergeDist);
+ if (chroma)
+ sao2ChromaParamDist(saoParam, addr, addrUp, addrLeft, mergeSaoParam, mergeDist);
if (saoParam->bSaoFlag[0] || saoParam->bSaoFlag[1])
{
@@ -1401,7 +1404,7 @@
m_entropyCoder.codeSaoMerge(0);
if (allowMerge[1])
m_entropyCoder.codeSaoMerge(0);
- for (int plane = 0; plane < 3; plane++)
+ for (int plane = 0; plane < planes; plane++)
{
if (saoParam->bSaoFlag[plane > 0])
m_entropyCoder.codeSaoOffset(saoParam->ctuParam[plane][addr], plane);
@@ -1431,7 +1434,7 @@
SaoMergeMode mergeMode = mergeIdx ? SAO_MERGE_UP : SAO_MERGE_LEFT;
bestCost = mergeCost;
m_entropyCoder.store(m_rdContexts.temp);
- for (int plane = 0; plane < 3; plane++)
+ for (int plane = 0; plane < planes; plane++)
{
mergeSaoParam[plane][mergeIdx].mergeMode = mergeMode;
if (saoParam->bSaoFlag[plane > 0])
@@ -1442,7 +1445,7 @@
if (saoParam->ctuParam[0][addr].typeIdx < 0)
m_numNoSao[0]++;
- if (saoParam->ctuParam[1][addr].typeIdx < 0)
+ if (chroma && saoParam->ctuParam[1][addr].typeIdx < 0)
m_numNoSao[1]++;
m_entropyCoder.load(m_rdContexts.temp);
m_entropyCoder.store(m_rdContexts.cur);
More information about the x265-devel
mailing list