<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 22, 2017 at 10:43 AM, Divya Manivannan <span dir="ltr"><<a href="mailto:divya@multicorewareinc.com" target="_blank">divya@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 Divya Manivannan <<a href="mailto:divya@multicorewareinc.com">divya@multicorewareinc.com</a>><br>
# Date 1513250624 -19800<br>
#      Thu Dec 14 16:53:44 2017 +0530<br>
# Node ID 5723f3248cd24c8b9f670d503370f6<wbr>44dffe9a6f<br>
# Parent  7a6d244c922b5e9180a0e28363ce57<wbr>8bea0c1d02<br>
analysis: avoid copying lowres vbv data when vbv is disabled<br>
<br>
diff -r 7a6d244c922b -r 5723f3248cd2 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp        Thu Dec 21 09:09:46 2017 +0530<br>
+++ b/source/encoder/encoder.cpp        Thu Dec 14 16:53:44 2017 +0530<br>
@@ -1047,11 +1047,14 @@<br>
                 inFrame->m_lowres.sliceType = sliceType;<br>
                 inFrame->m_lowres.bKeyframe = !!inFrame->m_analysisData.<wbr>lookahead.keyframe;<br>
                 inFrame->m_lowres.<wbr>bLastMiniGopBFrame = !!inFrame->m_analysisData.<wbr>lookahead.lastMiniGopBFrame;<br>
-                int vbvCount = m_param->lookaheadDepth + m_param->bframes + 2;<br>
-                for (int index = 0; index < vbvCount; index++)<br>
+                if (m_rateControl->m_isVbv)<br>
                 {<br>
-                    inFrame->m_lowres.plannedSatd[<wbr>index] = inFrame->m_analysisData.<wbr>lookahead.plannedSatd[index];<br>
-                    inFrame->m_lowres.plannedType[<wbr>index] = inFrame->m_analysisData.<wbr>lookahead.plannedType[index];<br>
+                    int vbvCount = m_param->lookaheadDepth + m_param->bframes + 2;<br>
+                    for (int index = 0; index < vbvCount; index++)<br>
+                    {<br>
+                        inFrame->m_lowres.plannedSatd[<wbr>index] = inFrame->m_analysisData.<wbr>lookahead.plannedSatd[index];<br>
+                        inFrame->m_lowres.plannedType[<wbr>index] = inFrame->m_analysisData.<wbr>lookahead.plannedType[index];<br>
+                    }<br>
                 }<br>
             }<br>
         }<br>
@@ -1165,26 +1168,29 @@<br>
                         pic_out->analysisData.satdCost *= factor;<br>
                         pic_out->analysisData.<wbr>lookahead.keyframe = outFrame->m_lowres.bKeyframe;<br>
                         pic_out->analysisData.<wbr>lookahead.lastMiniGopBFrame = outFrame->m_lowres.<wbr>bLastMiniGopBFrame;<br>
-                        int vbvCount = m_param->lookaheadDepth + m_param->bframes + 2;<br>
-                        for (int index = 0; index < vbvCount; index++)<br>
+                        if (m_rateControl->m_isVbv)<br>
                         {<br>
-                            pic_out->analysisData.<wbr>lookahead.plannedSatd[index] = outFrame->m_lowres.<wbr>plannedSatd[index] * factor;<br>
-                            pic_out->analysisData.<wbr>lookahead.plannedType[index] = outFrame->m_lowres.<wbr>plannedType[index];<br>
+                            int vbvCount = m_param->lookaheadDepth + m_param->bframes + 2;<br>
+                            for (int index = 0; index < vbvCount; index++)<br>
+                            {<br>
+                                pic_out->analysisData.<wbr>lookahead.plannedSatd[index] = outFrame->m_lowres.<wbr>plannedSatd[index] * factor;<br>
+                                pic_out->analysisData.<wbr>lookahead.plannedType[index] = outFrame->m_lowres.<wbr>plannedType[index];<br>
+                            }<br>
+                            for (uint32_t index = 0; index < pic_out->analysisData.<wbr>numCuInHeight; index++)<br>
+                            {<br>
+                                outFrame->m_analysisData.<wbr>lookahead.intraSatdForVbv[<wbr>index] = outFrame->m_encData->m_<wbr>rowStat[index].intraSatdForVbv * factor;<br>
+                                outFrame->m_analysisData.<wbr>lookahead.satdForVbv[index] = outFrame->m_encData->m_<wbr>rowStat[index].satdForVbv * factor;<br>
+                            }<br>
+                            pic_out->analysisData.<wbr>lookahead.intraSatdForVbv = outFrame->m_analysisData.<wbr>lookahead.intraSatdForVbv;<br>
+                            pic_out->analysisData.<wbr>lookahead.satdForVbv = outFrame->m_analysisData.<wbr>lookahead.satdForVbv;<br>
+                            for (uint32_t index = 0; index < pic_out->analysisData.<wbr>numCUsInFrame; index++)<br>
+                            {<br>
+                                outFrame->m_analysisData.<wbr>lookahead.intraVbvCost[index] = outFrame->m_encData->m_cuStat[<wbr>index].intraVbvCost * factor;<br>
+                                outFrame->m_analysisData.<wbr>lookahead.vbvCost[index] = outFrame->m_encData->m_cuStat[<wbr>index].vbvCost * factor;<br>
+                            }<br>
+                            pic_out->analysisData.<wbr>lookahead.intraVbvCost = outFrame->m_analysisData.<wbr>lookahead.intraVbvCost;<br>
+                            pic_out->analysisData.<wbr>lookahead.vbvCost = outFrame->m_analysisData.<wbr>lookahead.vbvCost;<br>
                         }<br>
-                        for (uint32_t index = 0; index < pic_out->analysisData.<wbr>numCuInHeight; index++)<br>
-                        {<br>
-                            outFrame->m_analysisData.<wbr>lookahead.intraSatdForVbv[<wbr>index] = outFrame->m_encData->m_<wbr>rowStat[index].intraSatdForVbv * factor;<br>
-                            outFrame->m_analysisData.<wbr>lookahead.satdForVbv[index] = outFrame->m_encData->m_<wbr>rowStat[index].satdForVbv * factor;<br>
-                        }<br>
-                        pic_out->analysisData.<wbr>lookahead.intraSatdForVbv = outFrame->m_analysisData.<wbr>lookahead.intraSatdForVbv;<br>
-                        pic_out->analysisData.<wbr>lookahead.satdForVbv = outFrame->m_analysisData.<wbr>lookahead.satdForVbv;<br>
-                        for (uint32_t index = 0; index < pic_out->analysisData.<wbr>numCUsInFrame; index++)<br>
-                        {<br>
-                            outFrame->m_analysisData.<wbr>lookahead.intraVbvCost[index] = outFrame->m_encData->m_cuStat[<wbr>index].intraVbvCost * factor;<br>
-                            outFrame->m_analysisData.<wbr>lookahead.vbvCost[index] = outFrame->m_encData->m_cuStat[<wbr>index].vbvCost * factor;<br>
-                        }<br>
-                        pic_out->analysisData.<wbr>lookahead.intraVbvCost = outFrame->m_analysisData.<wbr>lookahead.intraVbvCost;<br>
-                        pic_out->analysisData.<wbr>lookahead.vbvCost = outFrame->m_analysisData.<wbr>lookahead.vbvCost;<br>
                     }<br>
                     writeAnalysisFile(&pic_out-><wbr>analysisData, *outFrame->m_encData);<br>
                     if (m_param->bUseAnalysisFile)<br>
@@ -1351,15 +1357,18 @@<br>
             if (m_param->analysisReuseMode == X265_ANALYSIS_LOAD && m_param->bDisableLookahead)<br>
             {<br>
                 frameEnc->m_dts = frameEnc->m_analysisData.<wbr>lookahead.dts;<br>
-                for (uint32_t index = 0; index < frameEnc->m_analysisData.<wbr>numCuInHeight; index++)<br>
+                if (m_rateControl->m_isVbv)<br>
                 {<br>
-                    frameEnc->m_encData->m_<wbr>rowStat[index].intraSatdForVbv = frameEnc->m_analysisData.<wbr>lookahead.intraSatdForVbv[<wbr>index];<br>
-                    frameEnc->m_encData->m_<wbr>rowStat[index].satdForVbv = frameEnc->m_analysisData.<wbr>lookahead.satdForVbv[index];<br>
-                }<br>
-                for (uint32_t index = 0; index < frameEnc->m_analysisData.<wbr>numCUsInFrame; index++)<br>
-                {<br>
-                    frameEnc->m_encData->m_cuStat[<wbr>index].intraVbvCost = frameEnc->m_analysisData.<wbr>lookahead.intraVbvCost[index];<br>
-                    frameEnc->m_encData->m_cuStat[<wbr>index].vbvCost = frameEnc->m_analysisData.<wbr>lookahead.vbvCost[index];<br>
+                    for (uint32_t index = 0; index < frameEnc->m_analysisData.<wbr>numCuInHeight; index++)<br>
+                    {<br>
+                        frameEnc->m_encData->m_<wbr>rowStat[index].intraSatdForVbv = frameEnc->m_analysisData.<wbr>lookahead.intraSatdForVbv[<wbr>index];<br>
+                        frameEnc->m_encData->m_<wbr>rowStat[index].satdForVbv = frameEnc->m_analysisData.<wbr>lookahead.satdForVbv[index];<br>
+                    }<br>
+                    for (uint32_t index = 0; index < frameEnc->m_analysisData.<wbr>numCUsInFrame; index++)<br>
+                    {<br>
+                        frameEnc->m_encData->m_cuStat[<wbr>index].intraVbvCost = frameEnc->m_analysisData.<wbr>lookahead.intraVbvCost[index];<br>
+                        frameEnc->m_encData->m_cuStat[<wbr>index].vbvCost = frameEnc->m_analysisData.<wbr>lookahead.vbvCost[index];<br>
+                    }<br>
                 }<br>
             }<br>
             if (m_param->searchMethod == X265_SEA && frameEnc->m_lowres.sliceType != X265_TYPE_B)<br>
@@ -3032,7 +3041,7 @@<br>
 {<br>
     X265_CHECK(analysis-><wbr>sliceType, "invalid slice type\n");<br>
     analysis->interData = analysis->intraData = NULL;<br>
-    if (m_param->bDisableLookahead)<br>
+    if (m_param->bDisableLookahead && m_rateControl->m_isVbv)<br>
     {<br>
         CHECKED_MALLOC_ZERO(analysis-><wbr>lookahead.intraSatdForVbv, uint32_t, analysis->numCuInHeight);<br>
         CHECKED_MALLOC_ZERO(analysis-><wbr>lookahead.satdForVbv, uint32_t, analysis->numCuInHeight);<br>
@@ -3106,7 +3115,7 @@<br>
<br>
 void Encoder::freeAnalysis(x265_<wbr>analysis_data* analysis)<br>
 {<br>
-    if (m_param->bDisableLookahead)<br>
+    if (m_param->bDisableLookahead && m_rateControl->m_isVbv)<br>
     {<br>
         X265_FREE(analysis->lookahead.<wbr>satdForVbv);<br>
         X265_FREE(analysis->lookahead.<wbr>intraSatdForVbv);<br>
@@ -3312,7 +3321,7 @@<br>
<br>
     /* Memory is allocated for inter and intra analysis data based on the slicetype */<br>
     allocAnalysis(analysis);<br>
-    if (m_param->bDisableLookahead)<br>
+    if (m_param->bDisableLookahead && m_rateControl->m_isVbv)<br>
     {<br>
         X265_FREAD(analysis-><wbr>lookahead.intraVbvCost, sizeof(uint32_t), analysis->numCUsInFrame, m_analysisFile, picData->lookahead.<wbr>intraVbvCost);<br>
         X265_FREAD(analysis-><wbr>lookahead.vbvCost, sizeof(uint32_t), analysis->numCUsInFrame, m_analysisFile, picData->lookahead.vbvCost);<br>
<br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
<br></blockquote></div><br></div><div class="gmail_extra">Thanks, Pushed.</div></div>