<div dir="ltr"><span style="font-size:12.8px">Please ignore the this patch. I'll resend this patch with few minor corrections.</span><br><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks</span></div><div><span style="font-size:12.8px">Ashok</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 19, 2015 at 3:33 PM, <span dir="ltr"><<a href="mailto:ashok@multicorewareinc.com" target="_blank">ashok@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Ashok Kumar Mishra<<a href="mailto:ashok@multicorewareinc.com">ashok@multicorewareinc.com</a>><br>
# Date 1446119115 -19800<br>
# Thu Oct 29 17:15:15 2015 +0530<br>
# Node ID 4a273947c8d54b4de3c05e0e04c9c915f554e6e5<br>
# Parent f722fb55404bb80b26a55ba0a0a1b98d8f20b362<br>
SAO: initialize bottom and right line numbers to be skipped for SAO statistics calculation only once<br>
<br>
diff -r f722fb55404b -r 4a273947c8d5 source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp Wed Nov 18 12:28:03 2015 +0530<br>
+++ b/source/encoder/frameencoder.cpp Thu Oct 29 17:15:15 2015 +0530<br>
@@ -1091,7 +1091,7 @@<br>
<br>
/* SAO parameter estimation using non-deblocked pixels for CTU bottom and right boundary areas */<br>
if (m_param->bEnableSAO && m_param->bSaoNonDeblocked)<br>
- m_frameFilter.m_sao.calcSaoStatsCu_BeforeDblk(m_frame, col, row);<br>
+ m_frameFilter.m_sao.calcPreDeblockSaoStatsCu(m_frame, col, row);<br>
<br>
if (m_param->bEnableWavefront && curRow.completed >= 2 && row < m_numRows - 1 &&<br>
(!m_bAllRowsStop || intRow + 1 < m_vbvResetTriggerRow))<br>
diff -r f722fb55404b -r 4a273947c8d5 source/encoder/sao.cpp<br>
--- a/source/encoder/sao.cpp Wed Nov 18 12:28:03 2015 +0530<br>
+++ b/source/encoder/sao.cpp Thu Oct 29 17:15:15 2015 +0530<br>
@@ -138,6 +138,68 @@<br>
CHECKED_MALLOC(m_countPreDblk, PerPlane, numCtu);<br>
CHECKED_MALLOC(m_offsetOrgPreDblk, PerPlane, numCtu);<br>
<br>
+ for (int typeIdc = 0; typeIdc < MAX_NUM_SAO_TYPE; typeIdc++)<br>
+ {<br>
+ m_skipLinesR[TEXT_LUMA][typeIdc] = 5;<br>
+ m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 3;<br>
+<br>
+ m_skipLinesB[TEXT_LUMA ][typeIdc] = 4;<br>
+ m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 2;<br>
+<br>
+ if (!m_param->bSaoNonDeblocked)<br>
+ {<br>
+ for (int typeIdc = 0; typeIdc < MAX_NUM_SAO_TYPE; typeIdc++)<br>
+ {<br>
+ m_skipLinesR[TEXT_LUMA][typeIdc] = 5;<br>
+ m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 3;<br>
+<br>
+ m_skipLinesB[TEXT_LUMA ][typeIdc] = 4;<br>
+ m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 2;<br>
+ }<br>
+ }<br>
+ else<br>
+ {<br>
+ for (int typeIdc = 0; typeIdc < MAX_NUM_SAO_TYPE; typeIdc++)<br>
+ {<br>
+ switch (typeIdc)<br>
+ {<br>
+ case SAO_EO_0:<br>
+ m_skipLinesR[TEXT_LUMA ][typeIdc] = 5;<br>
+ m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 3;<br>
+<br>
+ m_skipLinesB[TEXT_LUMA ][typeIdc] = 3;<br>
+ m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 1;<br>
+ break;<br>
+ case SAO_EO_1:<br>
+ m_skipLinesR[TEXT_LUMA][typeIdc] = 4;<br>
+ m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 2;<br>
+<br>
+ m_skipLinesB[TEXT_LUMA][typeIdc] = 4;<br>
+ m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 2;<br>
+ break;<br>
+ case SAO_EO_2:<br>
+ case SAO_EO_3:<br>
+ m_skipLinesR[TEXT_LUMA][typeIdc] = 5;<br>
+ m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 3;<br>
+<br>
+ m_skipLinesB[TEXT_LUMA][typeIdc] = 4;<br>
+ m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 2;<br>
+ break;<br>
+ case SAO_BO:<br>
+ m_skipLinesR[TEXT_LUMA][typeIdc] = 4;<br>
+ m_skipLinesR[TEXT_CHROMA_U][typeIdc] = m_skipLinesR[TEXT_CHROMA_V][typeIdc] = 2;<br>
+<br>
+ m_skipLinesB[TEXT_LUMA][typeIdc] = 3;<br>
+ m_skipLinesB[TEXT_CHROMA_U][typeIdc] = m_skipLinesB[TEXT_CHROMA_V][typeIdc] = 1;<br>
+ break;<br>
+ default:<br>
+ X265_CHECK(0, "Not a supported type");<br>
+ break;<br>
+ }<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
m_clipTable = &(m_clipTableBase[rangeExt]);<br>
<br>
for (int i = 0; i < rangeExt; i++)<br>
@@ -701,14 +763,9 @@<br>
ctuWidth = rpelx - lpelx;<br>
ctuHeight = bpely - tpely;<br>
<br>
- int startX;<br>
- int startY;<br>
- int endX;<br>
- int endY;<br>
-<br>
- const int plane_offset = plane ? 2 : 0;<br>
- int skipB = 4;<br>
- int skipR = 5;<br>
+ int startX, startY, endX, endY;<br>
+ int* skipLinesR = m_skipLinesR[plane];<br>
+ int* skipLinesB = m_skipLinesB[plane];<br>
<br>
int8_t _upBuff[2 * (MAX_CU_SIZE + 16 + 16)], *upBuff1 = _upBuff + 16, *upBufft = upBuff1 + (MAX_CU_SIZE + 16 + 16);<br>
<br>
@@ -738,14 +795,8 @@<br>
<br>
// SAO_BO:<br>
{<br>
- if (m_param->bSaoNonDeblocked)<br>
- {<br>
- skipB = 3;<br>
- skipR = 4;<br>
- }<br>
-<br>
- endX = (rpelx == picWidth) ? ctuWidth : ctuWidth - skipR + plane_offset;<br>
- endY = (bpely == picHeight) ? ctuHeight : ctuHeight - skipB + plane_offset;<br>
+ endX = (rpelx == picWidth) ? ctuWidth : ctuWidth - skipLinesR[SAO_BO];<br>
+ endY = (bpely == picHeight) ? ctuHeight : ctuHeight - skipLinesB[SAO_BO];<br>
<br>
primitives.saoCuStatsBO(diff, rec0, stride, endX, endY, m_offsetOrg[plane][SAO_BO], m_count[plane][SAO_BO]);<br>
}<br>
@@ -753,31 +804,19 @@<br>
{<br>
// SAO_EO_0: // dir: -<br>
{<br>
- if (m_param->bSaoNonDeblocked)<br>
- {<br>
- skipB = 3;<br>
- skipR = 5;<br>
- }<br>
+ startX = !lpelx;<br>
+ endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipLinesR[SAO_EO_0];<br>
<br>
- startX = !lpelx;<br>
- endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipR + plane_offset;<br>
-<br>
- primitives.saoCuStatsE0(diff + startX, rec0 + startX, stride, endX - startX, ctuHeight - skipB + plane_offset, m_offsetOrg[plane][SAO_EO_0], m_count[plane][SAO_EO_0]);<br>
+ primitives.saoCuStatsE0(diff + startX, rec0 + startX, stride, endX - startX, ctuHeight - skipLinesB[SAO_EO_0], m_offsetOrg[plane][SAO_EO_0], m_count[plane][SAO_EO_0]);<br>
}<br>
<br>
// SAO_EO_1: // dir: |<br>
{<br>
- if (m_param->bSaoNonDeblocked)<br>
- {<br>
- skipB = 4;<br>
- skipR = 4;<br>
- }<br>
-<br>
rec = rec0;<br>
<br>
startY = !tpely;<br>
- endX = (rpelx == picWidth) ? ctuWidth : ctuWidth - skipR + plane_offset;<br>
- endY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipB + plane_offset;<br>
+ endX = (rpelx == picWidth) ? ctuWidth : ctuWidth - skipLinesR[SAO_EO_1];<br>
+ endY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipLinesB[SAO_EO_1];<br>
if (!tpely)<br>
{<br>
rec += stride;<br>
@@ -790,20 +829,14 @@<br>
<br>
// SAO_EO_2: // dir: 135<br>
{<br>
- if (m_param->bSaoNonDeblocked)<br>
- {<br>
- skipB = 4;<br>
- skipR = 5;<br>
- }<br>
-<br>
fenc = fenc0;<br>
rec = rec0;<br>
<br>
startX = !lpelx;<br>
- endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipR + plane_offset;<br>
+ endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipLinesR[SAO_EO_2];<br>
<br>
startY = !tpely;<br>
- endY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipB + plane_offset;<br>
+ endY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipLinesB[SAO_EO_2];<br>
if (!tpely)<br>
{<br>
fenc += stride;<br>
@@ -817,20 +850,14 @@<br>
<br>
// SAO_EO_3: // dir: 45<br>
{<br>
- if (m_param->bSaoNonDeblocked)<br>
- {<br>
- skipB = 4;<br>
- skipR = 5;<br>
- }<br>
-<br>
fenc = fenc0;<br>
rec = rec0;<br>
<br>
startX = !lpelx;<br>
- endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipR + plane_offset;<br>
+ endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipLinesR[SAO_EO_3];<br>
<br>
startY = !tpely;<br>
- endY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipB + plane_offset;<br>
+ endY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipLinesB[SAO_EO_3];<br>
<br>
if (!tpely)<br>
{<br>
@@ -845,11 +872,9 @@<br>
}<br>
}<br>
<br>
-void SAO::calcSaoStatsCu_BeforeDblk(Frame* frame, int idxX, int idxY)<br>
+void SAO::calcPreDeblockSaoStatsCu(Frame* frame, int idxX, int idxY)<br>
{<br>
int addr = idxX + m_numCuInWidth * idxY;<br>
-<br>
- int x, y;<br>
const CUData* cu = frame->m_encData->getPicCTU(addr);<br>
const PicYuv* reconPic = m_frame->m_reconPic;<br>
const pixel* fenc;<br>
@@ -866,16 +891,10 @@<br>
ctuWidth = rpelx - lpelx;<br>
ctuHeight = bpely - tpely;<br>
<br>
- int startX;<br>
- int startY;<br>
- int endX;<br>
- int endY;<br>
- int firstX, firstY;<br>
+ int startX, startY, endX, endY, firstX, firstY;<br>
int32_t* stats;<br>
int32_t* count;<br>
<br>
- int skipB, skipR;<br>
-<br>
int32_t _upBuff1[MAX_CU_SIZE + 2], *upBuff1 = _upBuff1 + 1;<br>
int32_t _upBufft[MAX_CU_SIZE + 2], *upBufft = _upBufft + 1;<br>
<br>
@@ -884,7 +903,6 @@<br>
memset(m_countPreDblk[addr], 0, sizeof(PerPlane));<br>
memset(m_offsetOrgPreDblk[addr], 0, sizeof(PerPlane));<br>
<br>
- int plane_offset = 0;<br>
for (int plane = 0; plane < NUM_PLANE; plane++)<br>
{<br>
if (plane == 1)<br>
@@ -900,11 +918,10 @@<br>
bpely >>= m_vChromaShift;<br>
}<br>
<br>
+ int* skipLinesR = m_skipLinesR[plane];<br>
+ int* skipLinesB = m_skipLinesB[plane];<br>
+<br>
// SAO_BO:<br>
-<br>
- skipB = 3 - plane_offset;<br>
- skipR = 4 - plane_offset;<br>
-<br>
stats = m_offsetOrgPreDblk[addr][plane][SAO_BO];<br>
count = m_countPreDblk[addr][plane][SAO_BO];<br>
<br>
@@ -913,12 +930,12 @@<br>
fenc = fenc0;<br>
rec = rec0;<br>
<br>
- startX = (rpelx == picWidth) ? ctuWidth : ctuWidth - skipR;<br>
- startY = (bpely == picHeight) ? ctuHeight : ctuHeight - skipB;<br>
+ startX = (rpelx == picWidth) ? ctuWidth : ctuWidth - skipLinesR[SAO_BO];<br>
+ startY = (bpely == picHeight) ? ctuHeight : ctuHeight - skipLinesB[SAO_BO];<br>
<br>
- for (y = 0; y < ctuHeight; y++)<br>
+ for (int y = 0; y < ctuHeight; y++)<br>
{<br>
- for (x = (y < startY ? startX : 0); x < ctuWidth; x++)<br>
+ for (int x = (y < startY ? startX : 0); x < ctuWidth; x++)<br>
{<br>
int classIdx = 1 + (rec[x] >> boShift);<br>
stats[classIdx] += (fenc[x] - rec[x]);<br>
@@ -931,24 +948,21 @@<br>
<br>
// SAO_EO_0: // dir: -<br>
{<br>
- skipB = 3 - plane_offset;<br>
- skipR = 5 - plane_offset;<br>
-<br>
stats = m_offsetOrgPreDblk[addr][plane][SAO_EO_0];<br>
count = m_countPreDblk[addr][plane][SAO_EO_0];<br>
<br>
fenc = fenc0;<br>
rec = rec0;<br>
<br>
- startX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipR;<br>
- startY = (bpely == picHeight) ? ctuHeight : ctuHeight - skipB;<br>
+ startX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipLinesR[SAO_EO_0];<br>
+ startY = (bpely == picHeight) ? ctuHeight : ctuHeight - skipLinesB[SAO_EO_0];<br>
firstX = !lpelx;<br>
// endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth;<br>
endX = ctuWidth - 1; // not refer right CTU<br>
<br>
- for (y = 0; y < ctuHeight; y++)<br>
+ for (int y = 0; y < ctuHeight; y++)<br>
{<br>
- x = (y < startY ? startX : firstX);<br>
+ int x = (y < startY ? startX : firstX);<br>
int signLeft = signOf(rec[x] - rec[x - 1]);<br>
for (; x < endX; x++)<br>
{<br>
@@ -967,17 +981,14 @@<br>
<br>
// SAO_EO_1: // dir: |<br>
{<br>
- skipB = 4 - plane_offset;<br>
- skipR = 4 - plane_offset;<br>
-<br>
stats = m_offsetOrgPreDblk[addr][plane][SAO_EO_1];<br>
count = m_countPreDblk[addr][plane][SAO_EO_1];<br>
<br>
fenc = fenc0;<br>
rec = rec0;<br>
<br>
- startX = (rpelx == picWidth) ? ctuWidth : ctuWidth - skipR;<br>
- startY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipB;<br>
+ startX = (rpelx == picWidth) ? ctuWidth : ctuWidth - skipLinesR[SAO_EO_1];<br>
+ startY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipLinesB[SAO_EO_1];<br>
firstY = !tpely;<br>
// endY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight;<br>
endY = ctuHeight - 1; // not refer below CTU<br>
@@ -987,12 +998,12 @@<br>
rec += stride;<br>
}<br>
<br>
- for (x = startX; x < ctuWidth; x++)<br>
+ for (int x = startX; x < ctuWidth; x++)<br>
upBuff1[x] = signOf(rec[x] - rec[x - stride]);<br>
<br>
- for (y = firstY; y < endY; y++)<br>
+ for (int y = firstY; y < endY; y++)<br>
{<br>
- for (x = (y < startY - 1 ? startX : 0); x < ctuWidth; x++)<br>
+ for (int x = (y < startY - 1 ? startX : 0); x < ctuWidth; x++)<br>
{<br>
int signDown = signOf(rec[x] - rec[x + stride]);<br>
int edgeType = signDown + upBuff1[x] + 2;<br>
@@ -1012,17 +1023,14 @@<br>
<br>
// SAO_EO_2: // dir: 135<br>
{<br>
- skipB = 4 - plane_offset;<br>
- skipR = 5 - plane_offset;<br>
-<br>
stats = m_offsetOrgPreDblk[addr][plane][SAO_EO_2];<br>
count = m_countPreDblk[addr][plane][SAO_EO_2];<br>
<br>
fenc = fenc0;<br>
rec = rec0;<br>
<br>
- startX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipR;<br>
- startY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipB;<br>
+ startX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipLinesR[SAO_EO_2];<br>
+ startY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipLinesB[SAO_EO_2];<br>
firstX = !lpelx;<br>
firstY = !tpely;<br>
// endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth;<br>
@@ -1035,12 +1043,12 @@<br>
rec += stride;<br>
}<br>
<br>
- for (x = startX; x < endX; x++)<br>
+ for (int x = startX; x < endX; x++)<br>
upBuff1[x] = signOf(rec[x] - rec[x - stride - 1]);<br>
<br>
- for (y = firstY; y < endY; y++)<br>
+ for (int y = firstY; y < endY; y++)<br>
{<br>
- x = (y < startY - 1 ? startX : firstX);<br>
+ int x = (y < startY - 1 ? startX : firstX);<br>
upBufft[x] = signOf(rec[x + stride] - rec[x - 1]);<br>
for (; x < endX; x++)<br>
{<br>
@@ -1064,17 +1072,14 @@<br>
<br>
// SAO_EO_3: // dir: 45<br>
{<br>
- skipB = 4 - plane_offset;<br>
- skipR = 5 - plane_offset;<br>
-<br>
stats = m_offsetOrgPreDblk[addr][plane][SAO_EO_3];<br>
count = m_countPreDblk[addr][plane][SAO_EO_3];<br>
<br>
fenc = fenc0;<br>
rec = rec0;<br>
<br>
- startX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipR;<br>
- startY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipB;<br>
+ startX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipLinesR[SAO_EO_3];<br>
+ startY = (bpely == picHeight) ? ctuHeight - 1 : ctuHeight - skipLinesB[SAO_EO_3];<br>
firstX = !lpelx;<br>
firstY = !tpely;<br>
// endX = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth;<br>
@@ -1087,12 +1092,12 @@<br>
rec += stride;<br>
}<br>
<br>
- for (x = startX - 1; x < endX; x++)<br>
+ for (int x = startX - 1; x < endX; x++)<br>
upBuff1[x] = signOf(rec[x] - rec[x - stride + 1]);<br>
<br>
- for (y = firstY; y < endY; y++)<br>
+ for (int y = firstY; y < endY; y++)<br>
{<br>
- for (x = (y < startY - 1 ? startX : firstX); x < endX; x++)<br>
+ for (int x = (y < startY - 1 ? startX : firstX); x < endX; x++)<br>
{<br>
int signDown = signOf(rec[x] - rec[x + stride - 1]);<br>
int edgeType = signDown + upBuff1[x] + 2;<br>
@@ -1111,7 +1116,6 @@<br>
fenc += stride;<br>
}<br>
}<br>
- plane_offset = 2;<br>
}<br>
}<br>
<br>
diff -r f722fb55404b -r 4a273947c8d5 source/encoder/sao.h<br>
--- a/source/encoder/sao.h Wed Nov 18 12:28:03 2015 +0530<br>
+++ b/source/encoder/sao.h Thu Oct 29 17:15:15 2015 +0530<br>
@@ -97,6 +97,9 @@<br>
pixel* m_tmpL1;<br>
pixel* m_tmpL2;<br>
<br>
+ int m_skipLinesR[MAX_NUM_COMPONENT][MAX_NUM_SAO_TYPE];<br>
+ int m_skipLinesB[MAX_NUM_COMPONENT][MAX_NUM_SAO_TYPE];<br>
+<br>
public:<br>
<br>
struct SAOContexts<br>
@@ -136,7 +139,7 @@<br>
void copySaoUnit(SaoCtuParam* saoUnitDst, const SaoCtuParam* saoUnitSrc);<br>
<br>
void calcSaoStatsCu(int addr, int plane);<br>
- void calcSaoStatsCu_BeforeDblk(Frame* pic, int idxX, int idxY);<br>
+ void calcPreDeblockSaoStatsCu(Frame* pic, int idxX, int idxY);<br>
<br>
void saoComponentParamDist(SAOParam* saoParam, int addr, int addrUp, int addrLeft, SaoCtuParam mergeSaoParam[2], double* mergeDist);<br>
void sao2ChromaParamDist(SAOParam* saoParam, int addr, int addrUp, int addrLeft, SaoCtuParam mergeSaoParam[][2], double* mergeDist);<br>
</blockquote></div><br></div>