<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 3, 2014 at 6:46 AM, <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 <a href="mailto:ashok@multicorewareinc.com">ashok@multicorewareinc.com</a><br>
# Date 1388753178 -19800<br>
# Fri Jan 03 18:16:18 2014 +0530<br>
# Node ID f83443bbae4d5b0e98bc85e011d8a4f4fe0bce95<br>
# Parent 019ad3c515b3219497dfa51bd8f8c3a709b7ec5d<br>
Modify FrameFilter structure to support multiple color space formats<br>
<br>
diff -r 019ad3c515b3 -r f83443bbae4d source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Fri Jan 03 18:14:34 2014 +0530<br>
+++ b/source/encoder/encoder.cpp Fri Jan 03 18:16:18 2014 +0530<br>
@@ -1288,6 +1288,8 @@<br>
bEnableRDOQTS = 0;<br>
}<br>
<br>
+ m_csp = _param->internalCsp;<br>
+<br>
//====== Coding Tools ========<br>
<br>
uint32_t tuQTMaxLog2Size = g_convertToBit[_param->maxCUSize] + 2 - 1;<br>
diff -r 019ad3c515b3 -r f83443bbae4d source/encoder/frameencoder.cpp<br>
--- a/source/encoder/frameencoder.cpp Fri Jan 03 18:14:34 2014 +0530<br>
+++ b/source/encoder/frameencoder.cpp Fri Jan 03 18:16:18 2014 +0530<br>
@@ -330,11 +330,11 @@<br>
// instead we weight the distortion of chroma.<br>
int chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb();<br>
int qpc = Clip3(0, 70, 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>
+ double cbWeight = pow(2.0, (qp - g_chromaScale[slice->getSPS()->getChromaFormatIdc()][qpc])); // takes into account of the chroma qp mapping and chroma qp Offset</blockquote><div><br></div><div>the color space ID should be cached to make this code more readable </div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr();<br>
qpc = Clip3(0, 70, 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 crWeight = pow(2.0, (qp - g_chromaScale[slice->getSPS()->getChromaFormatIdc()][qpc])); // takes into account of the chroma qp mapping and chroma qp Offset<br>
double chromaLambda = lambda / crWeight;<br>
<br>
m_rows[row].m_search.setQPLambda(qp, lambda, chromaLambda);<br>
@@ -371,10 +371,10 @@<br>
int qpc;<br>
int chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb();<br>
qpc = Clip3(0, 70, 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>
+ double cbWeight = pow(2.0, (qp - g_chromaScale[slice->getSPS()->getChromaFormatIdc()][qpc])); // takes into account of the chroma qp mapping and chroma qp Offset<br>
chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr();<br>
qpc = Clip3(0, 70, 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 crWeight = pow(2.0, (qp - g_chromaScale[slice->getSPS()->getChromaFormatIdc()][qpc])); // takes into account of the chroma qp mapping and chroma qp Offset<br>
double chromaLambda = lambda / crWeight;<br>
<br>
TComPicYuv *fenc = slice->getPic()->getPicYuvOrg();<br>
diff -r 019ad3c515b3 -r f83443bbae4d source/encoder/framefilter.cpp<br>
--- a/source/encoder/framefilter.cpp Fri Jan 03 18:14:34 2014 +0530<br>
+++ b/source/encoder/framefilter.cpp Fri Jan 03 18:16:18 2014 +0530<br>
@@ -64,6 +64,9 @@<br>
m_cfg = top;<br>
m_numRows = numRows;<br>
<br>
+ m_hChromaShift = CHROMA_H_SHIFT(m_cfg->getColorFormat());<br>
+ m_vChromaShift = CHROMA_V_SHIFT(m_cfg->getColorFormat());<br>
+<br>
// NOTE: for sao only, I write this code because I want to exact match with HM's bug bitstream<br>
m_rdGoOnSbacCoderRow0 = rdGoOnSbacCoder;<br>
<br>
@@ -77,7 +80,7 @@<br>
m_sao.setSaoLcuBoundary(top->param.saoLcuBoundary);<br>
m_sao.setSaoLcuBasedOptimization(top->param.saoLcuBasedOptimization);<br>
m_sao.setMaxNumOffsetsPerPic(top->getMaxNumOffsetsPerPic());<br>
- m_sao.create(top->param.sourceWidth, top->param.sourceHeight, g_maxCUWidth, g_maxCUHeight);<br>
+ m_sao.create(top->param.sourceWidth, top->param.sourceHeight, g_maxCUWidth, g_maxCUHeight, m_cfg->getColorFormat());<br>
m_sao.createEncBuffer();<br>
}<br>
<br>
@@ -222,8 +225,8 @@<br>
<br>
// Border extend Left and Right<br>
primitives.extendRowBorder(recon->getLumaAddr(lineStartCUAddr), recon->getStride(), recon->getWidth(), realH, recon->getLumaMarginX());<br>
- primitives.extendRowBorder(recon->getCbAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> 1, realH >> 1, recon->getChromaMarginX());<br>
- primitives.extendRowBorder(recon->getCrAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> 1, realH >> 1, recon->getChromaMarginX());<br>
+ primitives.extendRowBorder(recon->getCbAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> m_hChromaShift, realH >> m_vChromaShift, recon->getChromaMarginX());<br>
+ primitives.extendRowBorder(recon->getCrAddr(lineStartCUAddr), recon->getCStride(), recon->getWidth() >> m_hChromaShift, realH >> m_vChromaShift, recon->getChromaMarginX());<br>
<br>
// Border extend Top<br>
if (row == 0)<br>
@@ -252,8 +255,8 @@<br>
const intptr_t stride = recon->getStride();<br>
const intptr_t strideC = recon->getCStride();<br>
pixel *pixY = recon->getLumaAddr(lineStartCUAddr) - recon->getLumaMarginX() + (realH - 1) * stride;<br>
- pixel *pixU = recon->getCbAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> 1) - 1) * strideC;<br>
- pixel *pixV = recon->getCrAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> 1) - 1) * strideC;<br>
+ pixel *pixU = recon->getCbAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> m_vChromaShift) - 1) * strideC;<br>
+ pixel *pixV = recon->getCrAddr(lineStartCUAddr) - recon->getChromaMarginX() + ((realH >> m_vChromaShift) - 1) * strideC;<br>
<br>
for (int y = 0; y < recon->getLumaMarginY(); y++)<br>
{<br>
@@ -290,8 +293,8 @@<br>
<br>
uint64_t ssdY = computeSSD(orig->getLumaAddr(cuAddr), recon->getLumaAddr(cuAddr), stride, width, height);<br>
<br>
- height >>= 1;<br>
- width >>= 1;<br>
+ height >>= m_vChromaShift;<br>
+ width >>= m_hChromaShift;<br>
stride = recon->getCStride();<br>
<br>
uint64_t ssdU = computeSSD(orig->getCbAddr(cuAddr), recon->getCbAddr(cuAddr), stride, width, height);<br>
@@ -337,8 +340,8 @@<br>
<br>
updateMD5Plane(m_pic->m_state[0], recon->getLumaAddr(cuAddr), width, height, stride);<br>
<br>
- width >>= 1;<br>
- height >>= 1;<br>
+ width >>= m_hChromaShift;<br>
+ height >>= m_vChromaShift;<br>
stride = recon->getCStride();<br>
<br>
updateMD5Plane(m_pic->m_state[1], recon->getCbAddr(cuAddr), width, height, stride);<br>
@@ -356,8 +359,8 @@<br>
}<br>
updateCRC(recon->getLumaAddr(cuAddr), m_pic->m_crc[0], height, width, stride);<br>
<br>
- width >>= 1;<br>
- height >>= 1;<br>
+ width >>= m_hChromaShift;<br>
+ height >>= m_vChromaShift;<br>
stride = recon->getCStride();<br>
<br>
updateCRC(recon->getCbAddr(cuAddr), m_pic->m_crc[1], height, width, stride);<br>
@@ -374,10 +377,10 @@<br>
m_pic->m_checksum[0] = m_pic->m_checksum[1] = m_pic->m_checksum[2] = 0;<br>
}<br>
updateChecksum(recon->getLumaAddr(), m_pic->m_checksum[0], height, width, stride, row, cuHeight);<br>
- width >>= 1;<br>
- height >>= 1;<br>
+ width >>= m_hChromaShift;<br>
+ height >>= m_vChromaShift;<br>
stride = recon->getCStride();<br>
- cuHeight >>= 1;<br>
+ cuHeight >>= m_vChromaShift;<br>
updateChecksum(recon->getCbAddr(), m_pic->m_checksum[1], height, width, stride, row, cuHeight);<br>
updateChecksum(recon->getCrAddr(), m_pic->m_checksum[2], height, width, stride, row, cuHeight);<br>
}<br>
diff -r 019ad3c515b3 -r f83443bbae4d source/encoder/framefilter.h<br>
--- a/source/encoder/framefilter.h Fri Jan 03 18:14:34 2014 +0530<br>
+++ b/source/encoder/framefilter.h Fri Jan 03 18:16:18 2014 +0530<br>
@@ -59,6 +59,9 @@<br>
TEncCfg* m_cfg;<br>
TComPic* m_pic;<br>
<br>
+ int m_hChromaShift;<br>
+ int m_vChromaShift;<br>
+<br>
public:<br>
<br>
TComLoopFilter m_loopFilter;<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>