<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 31, 2013 at 6:36 AM, Aarthi Thirumalai <span dir="ltr"><<a href="mailto:aarthi@multicorewareinc.com" target="_blank">aarthi@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 Aarthi Thirumalai<br>
# Date 1383219394 -19800<br>
# Thu Oct 31 17:06:34 2013 +0530<br>
# Node ID 0e321e5dd34869c0054a5c218cd14e5dfd30fd38<br>
# Parent 9a0da4e6d9e363e383eae7243f0c64026a5f6d00<br>
aq: set qp, lambda for every CU in the row before processing the CU<br>
<br>
enabled bUseDQP flag when AQ is mode is ON.<br>
<br>
diff -r 9a0da4e6d9e3 -r 0e321e5dd348 source/Lib/TLibCommon/TComDataCU.cpp<br>
--- a/source/Lib/TLibCommon/TComDataCU.cpp Thu Oct 31 15:10:34 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComDataCU.cpp Thu Oct 31 17:06:34 2013 +0530<br>
@@ -246,7 +246,7 @@<br>
m_totalDistortion = 0;<br>
m_totalBits = 0;<br>
m_numPartitions = pic->getNumPartInCU();<br>
-<br>
+ int qp = pic->m_lowres.m_invQscaleFactor ? pic->getCU(getAddr())->getQP(0) : m_slice->getSliceQp();<br>
for (int i = 0; i < 4; i++)<br>
{<br>
m_avgCost[i] = 0;<br>
@@ -304,7 +304,7 @@<br>
memset(m_height + firstElement, g_maxCUHeight, numElements * sizeof(*m_height));<br>
memset(m_mvpNum[0] + firstElement, -1, numElements * sizeof(*m_mvpNum[0]));<br>
memset(m_mvpNum[1] + firstElement, -1, numElements * sizeof(*m_mvpNum[1]));<br>
- memset(m_qp + firstElement, getSlice()->getSliceQp(), numElements * sizeof(*m_qp));<br>
+ memset(m_qp + firstElement, qp, numElements * sizeof(*m_qp));<br>
memset(m_bMergeFlags + firstElement, false, numElements * sizeof(*m_bMergeFlags));<br>
memset(m_mergeIndex + firstElement, 0, numElements * sizeof(*m_mergeIndex));<br>
memset(m_lumaIntraDir + firstElement, DC_IDX, numElements * sizeof(*m_lumaIntraDir));<br>
diff -r 9a0da4e6d9e3 -r 0e321e5dd348 source/Lib/TLibEncoder/TEncCu.cpp<br>
--- a/source/Lib/TLibEncoder/TEncCu.cpp Thu Oct 31 15:10:34 2013 +0530<br>
+++ b/source/Lib/TLibEncoder/TEncCu.cpp Thu Oct 31 17:06:34 2013 +0530<br>
@@ -1691,7 +1691,8 @@<br>
<br>
if (cu->getSlice()->getPPS()->getUseDQP() && (g_maxCUWidth >> depth) >= cu->getSlice()->getPPS()->getMinCuDQPSize())<br>
{<br>
- cu->setQPSubParts(cu->getRefQP(0), 0, depth); // set QP to default QP<br>
+ if (!cu->getCbf(0, TEXT_LUMA, 0) && !cu->getCbf(0, TEXT_CHROMA_U, 0) && !cu->getCbf(0, TEXT_CHROMA_V, 0))<br>
+ cu->setQPSubParts(cu->getRefQP(0), 0, depth); // set QP to default QP<br>
}<br>
}<br>
<br>
diff -r 9a0da4e6d9e3 -r 0e321e5dd348 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Thu Oct 31 15:10:34 2013 +0530<br>
+++ b/source/encoder/encoder.cpp Thu Oct 31 17:06:34 2013 +0530<br>
@@ -784,7 +784,7 @@<br>
void Encoder::initPPS(TComPPS *pps)<br>
{<br>
pps->setConstrainedIntraPred(param.bEnableConstrainedIntra);<br>
- bool bUseDQP = (getMaxCuDQPDepth() > 0) ? true : false;<br>
+ bool bUseDQP = ((getMaxCuDQPDepth() > 0) || param.rc.aqMode) ? true : false;<br>
<br>
int lowestQP = -(6 * (X265_DEPTH - 8)); //m_cSPS.getQpBDOffsetY();<br>
<br>
diff -r 9a0da4e6d9e3 -r 0e321e5dd348 source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp Thu Oct 31 15:10:34 2013 +0530<br>
+++ b/source/encoder/frameencoder.cpp Thu Oct 31 17:06:34 2013 +0530<br>
@@ -306,6 +306,40 @@<br>
while (m_threadActive);<br>
}<br>
<br>
+void FrameEncoder::setLambda(int qp , int row)<br>
+{<br>
+ TComSlice* slice = m_pic->getSlice();<br>
+ double lambda = 0;<br>
+ if (m_pic->getSlice()->getSliceType() == I_SLICE)<br>
+ {<br>
+ lambda = X265_MAX(1, x265_lambda2_tab_I[qp]);<br>
+ }<br>
+ else<br>
+ {<br>
+ lambda = X265_MAX(1, x265_lambda2_non_I[qp]);<br>
+ }<br>
+<br>
+ // for RDO<br>
+ // in RdCost there is only one lambda because the luma and chroma bits are not separated,<br>
+ // instead we weight the distortion of chroma.<br>
+ int qpc;<br>
+ int chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb();<br>
+ qpc = Clip3(0, 57, qp + chromaQPOffset);<br>
+ double cbWeight = pow(2.0, (qp - g_chromaScale[qpc])); // takes into account of the chroma qp mapping and chroma qp Offset<br>
+ chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr();<br>
+ qpc = Clip3(0, 57, qp + chromaQPOffset);<br>
+ double crWeight = pow(2.0, (qp - g_chromaScale[qpc])); // takes into account of the chroma qp mapping and chroma qp Offset<br>
+ double chromaLambda = lambda / crWeight;<br>
+ TComPicYuv *fenc = slice->getPic()->getPicYuvOrg();<br>
+ m_rows[row].m_search.setQPLambda(qp, lambda, chromaLambda);<br>
+ m_rows[row].m_search.m_me.setSourcePlane(fenc->getLumaAddr(), fenc->getStride());<br>
+ m_rows[row].m_rdCost.setLambda(lambda);<br>
+ m_rows[row].m_rdCost.setCbDistortionWeight(cbWeight);<br>
+ m_rows[row].m_rdCost.setCrDistortionWeight(crWeight);<br>
+ m_frameFilter.m_sao.lumaLambda = lambda;<br>
+ m_frameFilter.m_sao.chromaLambda = chromaLambda;<br></blockquote><div><br></div><div>queued, but I'm not very sure about these two lines. Since SAO only has one lambda value, it should probably use the slice global lambda rather than the last row's lambda.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
void FrameEncoder::compressFrame()<br>
{<br>
PPAScopeEvent(FrameEncoder_compressFrame);<br>
@@ -1042,8 +1076,12 @@<br>
codeRow.m_entropyCoder.resetEntropy();<br>
<br>
TEncSbac *bufSbac = (m_cfg->param.bEnableWavefront && col == 0 && row > 0) ? &m_rows[row - 1].m_bufferSbacCoder : NULL;<br>
- int qp = calcQpForCu(m_pic, cuAddr);<br>
- cu->setQP(0,(char)qp);<br>
+ if (m_cfg->param.rc.aqMode)<br>
+ {<br>
+ int qp = calcQpForCu(m_pic, cuAddr);<br>
+ cu->setQP(0, (char)qp);<br>
+ setLambda(qp, row);<br>
+ }<br>
codeRow.processCU(cu, m_pic->getSlice(), bufSbac, m_cfg->param.bEnableWavefront && col == 1);<br>
<br>
// TODO: Keep atomic running totals for rate control?<br>
diff -r 9a0da4e6d9e3 -r 0e321e5dd348 source/encoder/frameencoder.h<br>
--- a/source/encoder/frameencoder.h Thu Oct 31 15:10:34 2013 +0530<br>
+++ b/source/encoder/frameencoder.h Thu Oct 31 17:06:34 2013 +0530<br>
@@ -149,7 +149,7 @@<br>
<br>
/* blocks until worker thread is done, returns encoded picture and bitstream */<br>
TComPic *getEncodedPicture(NALUnitEBSP **nalunits);<br>
-<br>
+ void setLambda(int qp , int row);<br>
// worker thread<br>
void threadMain();<br>
<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>