<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="Generator" content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang="EN-US" link="blue" vlink="purple"><div class="WordSection1"><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Yes. This is an experimental feature, still in development.</span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> x265-devel [mailto:<a href="mailto:x265-devel-bounces@videolan.org">x265-devel-bounces@videolan.org</a>] <b>On Behalf Of </b>Deepthi Nandakumar<br><b>Sent:</b> Thursday, June 8, 2017 9:21 AM<br><b>To:</b> Development for x265<br><b>Subject:</b> Re: [x265] [PATCH 2 of 4] Reuse analysis info of low resolution for full resolution encoding</span></p><p class="MsoNormal"> </p><div><p class="MsoNormal">So, the general idea here is to reuse analysis data from lower resolution encodes (save mode) for higher resolution encodes (load mode). The compression efficiency loss here will always be higher, than, if you used high-res analysis data for low-res encodes. </p></div><div><p class="MsoNormal"> </p><div><p class="MsoNormal">On Fri, Jun 2, 2017 at 10:58 PM, <<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>> wrote:</p><p class="MsoNormal"># HG changeset patch<br># User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com">kavitha@multicorewareinc.com</a>><br># Date 1495615463 -19800<br># Wed May 24 14:14:23 2017 +0530<br># Node ID 802bb7ead1e0151a604bc293451c735990656162<br># Parent 404253434d33e99955aac29480ee16b8e939a64c<br>Reuse analysis info of low resolution for full resolution encoding.<br><br>New CLI option --scale-factor is added. This option should be coupled<br>with analysis-mode, --refine-level 10. It specifies the factor<br>by which input video of save mode should be scaled down.<br>Currently only scale-factor 2 is supported.<br><br>diff -r 404253434d33 -r 802bb7ead1e0 source/common/cudata.cpp<br>--- a/source/common/cudata.cpp Wed May 24 08:39:45 2017 +0530<br>+++ b/source/common/cudata.cpp Wed May 24 14:14:23 2017 +0530<br>@@ -28,6 +28,7 @@<br> #include "picyuv.h"<br> #include "mv.h"<br> #include "cudata.h"<br>+#define MAX_MV 1 << 14<br><br> using namespace X265_NS;<br><br>@@ -1623,6 +1624,11 @@<br> dir |= (1 << list);<br> candMvField[count][list].mv = colmv;<br> candMvField[count][list].refIdx = refIdx;<br>+ if (m_encData->m_param->scaleFactor && m_encData->m_param->analysisMode == X265_ANALYSIS_SAVE && m_log2CUSize[0] < 4)<br>+ {<br>+ MV dist(MAX_MV, MAX_MV);<br>+ candMvField[count][list].mv = dist;<br>+ }<br> }<br> }<br><br>@@ -1783,7 +1789,13 @@<br> int curRefPOC = m_slice->m_refPOCList[picList][refIdx];<br> int curPOC = m_slice->m_poc;<br><br>- pmv[numMvc++] = amvpCand[num++] = scaleMvByPOCDist(neighbours[MD_COLLOCATED].mv[picList], curPOC, curRefPOC, colPOC, colRefPOC);<br>+ if (m_encData->m_param->scaleFactor && m_encData->m_param->analysisMode == X265_ANALYSIS_SAVE && (m_log2CUSize[0] < 4))<br>+ {<br>+ MV dist(MAX_MV, MAX_MV);<br>+ pmv[numMvc++] = amvpCand[num++] = dist;<br>+ }<br>+ else<br>+ pmv[numMvc++] = amvpCand[num++] = scaleMvByPOCDist(neighbours[MD_COLLOCATED].mv[picList], curPOC, curRefPOC, colPOC, colRefPOC);<br> }<br> }<br><br>diff -r 404253434d33 -r 802bb7ead1e0 source/encoder/analysis.cpp<br>--- a/source/encoder/analysis.cpp Wed May 24 08:39:45 2017 +0530<br>+++ b/source/encoder/analysis.cpp Wed May 24 14:14:23 2017 +0530<br>@@ -2263,6 +2263,19 @@<br> mode.cu.m_mvd[list][pu.puAbsPartIdx] = mode.cu.m_mv[list][pu.puAbsPartIdx] - mvp;<br> }<br> }<br>+ else if(m_param->scaleFactor)<br>+ {<br>+ MVField candMvField[MRG_MAX_NUM_CANDS][2]; // double length for mv of both lists<br>+ uint8_t candDir[MRG_MAX_NUM_CANDS];<br>+ <a href="http://mode.cu">mode.cu</a>.getInterMergeCandidates(pu.puAbsPartIdx, part, candMvField, candDir);<br>+ mode.cu.m_mvpIdx[0][pu.puAbsPartIdx] = interDataCTU->mvpIdx[0][cuIdx + part];<br>+ uint8_t mvpIdx = mode.cu.m_mvpIdx[0][pu.puAbsPartIdx];<br>+ mode.cu.setPUInterDir(candDir[mvpIdx], pu.puAbsPartIdx, part);<br>+ mode.cu.setPUMv(0, candMvField[mvpIdx][0].mv, pu.puAbsPartIdx, part);<br>+ mode.cu.setPUMv(1, candMvField[mvpIdx][1].mv, pu.puAbsPartIdx, part);<br>+ mode.cu.setPURefIdx(0, (int8_t)candMvField[mvpIdx][0].refIdx, pu.puAbsPartIdx, part);<br>+ mode.cu.setPURefIdx(1, (int8_t)candMvField[mvpIdx][1].refIdx, pu.puAbsPartIdx, part);<br>+ }<br> }<br> motionCompensation(<a href="http://mode.cu" target="_blank">mode.cu</a>, pu, mode.predYuv, true, (m_csp != X265_CSP_I400 && m_frame->m_fencPic->m_picCsp != X265_CSP_I400));<br> }<br>diff -r 404253434d33 -r 802bb7ead1e0 source/encoder/encoder.cpp<br>--- a/source/encoder/encoder.cpp Wed May 24 08:39:45 2017 +0530<br>+++ b/source/encoder/encoder.cpp Wed May 24 14:14:23 2017 +0530<br>@@ -2839,6 +2839,11 @@<br> X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFile);<br> X265_FREAD(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFile);<br> X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFile);<br>+ int scaledNumPartition = analysis->numPartitions;<br>+ int factor = 1 << m_param->scaleFactor;<br>+<br>+ if (m_param->scaleFactor)<br>+ analysis->numPartitions *= factor;<br><br> /* Memory is allocated for inter and intra analysis data based on the slicetype */<br> allocAnalysis(analysis);<br>@@ -2862,12 +2867,31 @@<br> for (uint32_t d = 0; d < depthBytes; d++)<br> {<br> int bytes = analysis->numPartitions >> (depthBuf[d] * 2);<br>+ if (m_param->scaleFactor)<br>+ {<br>+ if (depthBuf[d] == 0)<br>+ depthBuf[d] = 1;<br>+ if (partSizes[d] == SIZE_NxN)<br>+ partSizes[d] = SIZE_2Nx2N;<br>+ }<br> memset(&((analysis_intra_data *)analysis->intraData)->depth[count], depthBuf[d], bytes);<br> memset(&((analysis_intra_data *)analysis->intraData)->chromaModes[count], modeBuf[d], bytes);<br> memset(&((analysis_intra_data *)analysis->intraData)->partSizes[count], partSizes[d], bytes);<br> count += bytes;<br> }<br>- X265_FREAD(((analysis_intra_data *)analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>+<br>+ if (!m_param->scaleFactor)<br>+ {<br>+ X265_FREAD(((analysis_intra_data *)analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>+ }<br>+ else<br>+ {<br>+ uint8_t *tempLumaBuf = X265_MALLOC(uint8_t, analysis->numCUsInFrame * scaledNumPartition);<br>+ X265_FREAD(tempLumaBuf, sizeof(uint8_t), analysis->numCUsInFrame * scaledNumPartition, m_analysisFile);<br>+ for (uint32_t ctu32Idx = 0, cnt = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++, cnt += factor)<br>+ memset(&((analysis_intra_data *)analysis->intraData)->modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>+ X265_FREE(tempLumaBuf);<br>+ }<br> X265_FREE(tempBuf);<br> consumedBytes += frameRecordSize;<br> }<br>@@ -2923,12 +2947,16 @@<br> for (uint32_t d = 0; d < depthBytes; d++)<br> {<br> int bytes = analysis->numPartitions >> (depthBuf[d] * 2);<br>+ if (m_param->scaleFactor && modeBuf[d] == MODE_INTRA && depthBuf[d] == 0)<br>+ depthBuf[d] = 1;<br> memset(&((analysis_inter_data *)analysis->interData)->depth[count], depthBuf[d], bytes);<br> memset(&((analysis_inter_data *)analysis->interData)->modes[count], modeBuf[d], bytes);<br> if (m_param->analysisRefineLevel > 4)<br> {<br>+ if (m_param->scaleFactor && modeBuf[d] == MODE_INTRA && partSize[d] == SIZE_NxN)<br>+ partSize[d] = SIZE_2Nx2N;<br> memset(&((analysis_inter_data *)analysis->interData)->partSize[count], partSize[d], bytes);<br>- int numPU = nbPartsTable[(int)partSize[d]];<br>+ int numPU = (modeBuf[d] == MODE_INTRA) ? 1 : nbPartsTable[(int)partSize[d]];<br> for (int pu = 0; pu < numPU; pu++)<br> {<br> if (pu) d++;<br>@@ -2940,6 +2968,11 @@<br> {<br> ((analysis_inter_data *)analysis->interData)->mvpIdx[i][count + pu] = mvpIdx[i][d];<br> ((analysis_inter_data *)analysis->interData)->refIdx[i][count + pu] = refIdx[i][d];<br>+ if (m_param->scaleFactor)<br>+ {<br>+ mv[i][d].x *= (int16_t)m_param->scaleFactor;<br>+ mv[i][d].y *= (int16_t)m_param->scaleFactor;<br>+ }<br> memcpy(&((analysis_inter_data *)analysis->interData)->mv[i][count + pu], &mv[i][d], sizeof(MV));<br> }<br> }<br>@@ -2961,7 +2994,20 @@<br> X265_FREE(mv[i]);<br> }<br> if (bIntraInInter)<br>- X265_FREAD(((analysis_intra_data *)analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>+ {<br>+ if (!m_param->scaleFactor)<br>+ {<br>+ X265_FREAD(((analysis_intra_data *)analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFile);<br>+ }<br>+ else<br>+ {<br>+ uint8_t *tempLumaBuf = X265_MALLOC(uint8_t, analysis->numCUsInFrame * scaledNumPartition);<br>+ X265_FREAD(tempLumaBuf, sizeof(uint8_t), analysis->numCUsInFrame * scaledNumPartition, m_analysisFile);<br>+ for (uint32_t ctu32Idx = 0, cnt = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++, cnt += factor)<br>+ memset(&((analysis_intra_data *)analysis->intraData)->modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>+ X265_FREE(tempLumaBuf);<br>+ }<br>+ }<br> }<br> else<br> X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);<br>@@ -3183,7 +3229,7 @@<br> interDataCTU->partSize[depthBytes] = partSize;<br><br> /* Store per PU data */<br>- uint32_t numPU = nbPartsTable[(int)partSize];<br>+ uint32_t numPU = (predMode == MODE_INTRA) ? 1 : nbPartsTable[(int)partSize];<br> for (uint32_t puIdx = 0; puIdx < numPU; puIdx++)<br> {<br> uint32_t puabsPartIdx = ctu->getPUOffset(puIdx, absPartIdx) + absPartIdx;<br>diff -r 404253434d33 -r 802bb7ead1e0 source/encoder/slicetype.cpp<br>--- a/source/encoder/slicetype.cpp Wed May 24 08:39:45 2017 +0530<br>+++ b/source/encoder/slicetype.cpp Wed May 24 14:14:23 2017 +0530<br>@@ -893,7 +893,7 @@<br> if (m_param->rc.cuTree && !m_param->rc.bStatRead)<br> /* update row satds based on cutree offsets */<br> curFrame->m_lowres.satdCost = frameCostRecalculate(frames, p0, p1, b);<br>- else if (m_param->analysisMode != X265_ANALYSIS_LOAD)<br>+ else if (m_param->analysisMode != X265_ANALYSIS_LOAD || m_param->scaleFactor)<br> {<br> if (m_param->rc.aqMode)<br> curFrame->m_lowres.satdCost = curFrame->m_lowres.costEstAq[b - p0][p1 - b];<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></p></div><p class="MsoNormal"><br><br clear="all"></p><div><p class="MsoNormal"> </p></div><p class="MsoNormal">-- </p><div><p class="MsoNormal">Deepthi</p></div></div></div></body></html>