<div dir="ltr">Pushed the series into default branch.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 31, 2020 at 11:25 AM Aruna Matheswaran <<a href="mailto:aruna@multicorewareinc.com">aruna@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"># HG changeset patch<br>
# User Aruna Matheswaran <<a href="mailto:aruna@multicorewareinc.com" target="_blank">aruna@multicorewareinc.com</a>><br>
# Date 1582708235 -19800<br>
#      Wed Feb 26 14:40:35 2020 +0530<br>
# Node ID 7ebf4b9369b3037370a73be24f5f1bd93cce7822<br>
# Parent  7ae7c9767f14b7d093c2023235066b370aecc4ce<br>
analysis-save/load: Fix incorrect frame data propagation in multi-level reuse.<br>
<br>
diff -r 7ae7c9767f14 -r 7ebf4b9369b3 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp        Wed Feb 26 14:21:50 2020 +0530<br>
+++ b/source/encoder/encoder.cpp        Wed Feb 26 14:40:35 2020 +0530<br>
@@ -3866,29 +3866,30 @@<br>
         }<br>
         else<br>
         {<br>
-            if (fread(&m_conformanceWindow.rightOffset, sizeof(int), 1, m_analysisFileIn) != 1)<br>
+            int rightOffset, bottomOffset;<br>
+            if (fread(&rightOffset, sizeof(int), 1, m_analysisFileIn) != 1)<br>
             {<br>
                 x265_log(NULL, X265_LOG_ERROR, "Error reading analysis data. Conformance window right offset missing\n");<br>
                 m_aborted = true;<br>
             }<br>
-            else if (m_conformanceWindow.rightOffset && p->analysisLoadReuseLevel > 1)<br>
+            else if (rightOffset && p->analysisLoadReuseLevel > 1)<br>
             {<br>
                 int scaleFactor = p->scaleFactor < 2 ? 1 : p->scaleFactor;<br>
-                padsize = m_conformanceWindow.rightOffset * scaleFactor;<br>
+                padsize = rightOffset * scaleFactor;<br>
                 p->sourceWidth += padsize;<br>
                 m_conformanceWindow.bEnabled = true;<br>
                 m_conformanceWindow.rightOffset = padsize;<br>
             }<br>
<br>
-            if (fread(&m_conformanceWindow.bottomOffset, sizeof(int), 1, m_analysisFileIn) != 1)<br>
+            if (fread(&bottomOffset, sizeof(int), 1, m_analysisFileIn) != 1)<br>
             {<br>
                 x265_log(NULL, X265_LOG_ERROR, "Error reading analysis data. Conformance window bottom offset missing\n");<br>
                 m_aborted = true;<br>
             }<br>
-            else if (m_conformanceWindow.bottomOffset && p->analysisLoadReuseLevel > 1)<br>
+            else if (bottomOffset && p->analysisLoadReuseLevel > 1)<br>
             {<br>
                 int scaleFactor = p->scaleFactor < 2 ? 1 : p->scaleFactor;<br>
-                padsize = m_conformanceWindow.bottomOffset * scaleFactor;<br>
+                padsize = bottomOffset * scaleFactor;<br>
                 p->sourceHeight += padsize;<br>
                 m_conformanceWindow.bEnabled = true;<br>
                 m_conformanceWindow.bottomOffset = padsize;<br>
@@ -4304,18 +4305,27 @@<br>
         }<br>
     }<br>
<br>
+    uint32_t numCUsLoad, numCUsInHeightLoad;<br>
+<br>
     /* Now arrived at the right frame, read the record */<br>
     analysis->poc = poc;<br>
     analysis->frameRecordSize = frameRecordSize;<br>
     X265_FREAD(&analysis->sliceType, sizeof(int), 1, m_analysisFileIn, &(picData->sliceType));<br>
     X265_FREAD(&analysis->bScenecut, sizeof(int), 1, m_analysisFileIn, &(picData->bScenecut));<br>
     X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileIn, &(picData->satdCost));<br>
-    X265_FREAD(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));<br>
+    X265_FREAD(&numCUsLoad, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));<br>
     X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));<br>
<br>
+    /* Update analysis info to save current settings */<br>
+    uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;<br>
+    uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> m_param->maxLog2CUSize;<br>
+    uint32_t numCUsInFrame = widthInCU * heightInCU;<br>
+    analysis->numCUsInFrame = numCUsInFrame;<br>
+    analysis->numCuInHeight = heightInCU;<br>
+<br>
     if (m_param->bDisableLookahead)<br>
     {<br>
-        X265_FREAD(&analysis->numCuInHeight, sizeof(uint32_t), 1, m_analysisFileIn, &(picData->numCuInHeight));<br>
+        X265_FREAD(&numCUsInHeightLoad, sizeof(uint32_t), 1, m_analysisFileIn, &(picData->numCuInHeight));<br>
         X265_FREAD(&analysis->lookahead, sizeof(x265_lookahead_data), 1, m_analysisFileIn, &(picData->lookahead));<br>
     }<br>
     int scaledNumPartition = analysis->numPartitions;<br>
@@ -4328,16 +4338,16 @@<br>
<br>
     if (m_param->ctuDistortionRefine == CTU_DISTORTION_INTERNAL)<br>
     {<br>
-        X265_FREAD((analysis->distortionData)->ctuDistortion, sizeof(sse_t), analysis->numCUsInFrame, m_analysisFileIn, picDistortion);<br>
+        X265_FREAD((analysis->distortionData)->ctuDistortion, sizeof(sse_t), numCUsLoad, m_analysisFileIn, picDistortion);<br>
         computeDistortionOffset(analysis);<br>
     }<br>
     if (m_param->bDisableLookahead && m_rateControl->m_isVbv)<br>
     {<br>
         size_t vbvCount = m_param->lookaheadDepth + m_param->bframes + 2;<br>
-        X265_FREAD(analysis->lookahead.intraVbvCost, sizeof(uint32_t), analysis->numCUsInFrame, m_analysisFileIn, picData->lookahead.intraVbvCost);<br>
-        X265_FREAD(analysis->lookahead.vbvCost, sizeof(uint32_t), analysis->numCUsInFrame, m_analysisFileIn, picData->lookahead.vbvCost);<br>
-        X265_FREAD(analysis->lookahead.satdForVbv, sizeof(uint32_t), analysis->numCuInHeight, m_analysisFileIn, picData->lookahead.satdForVbv);<br>
-        X265_FREAD(analysis->lookahead.intraSatdForVbv, sizeof(uint32_t), analysis->numCuInHeight, m_analysisFileIn, picData->lookahead.intraSatdForVbv);<br>
+        X265_FREAD(analysis->lookahead.intraVbvCost, sizeof(uint32_t), numCUsLoad, m_analysisFileIn, picData->lookahead.intraVbvCost);<br>
+        X265_FREAD(analysis->lookahead.vbvCost, sizeof(uint32_t), numCUsLoad, m_analysisFileIn, picData->lookahead.vbvCost);<br>
+        X265_FREAD(analysis->lookahead.satdForVbv, sizeof(uint32_t), numCUsInHeightLoad, m_analysisFileIn, picData->lookahead.satdForVbv);<br>
+        X265_FREAD(analysis->lookahead.intraSatdForVbv, sizeof(uint32_t), numCUsInHeightLoad, m_analysisFileIn, picData->lookahead.intraSatdForVbv);<br>
         X265_FREAD(analysis->lookahead.plannedSatd, sizeof(int64_t), vbvCount, m_analysisFileIn, picData->lookahead.plannedSatd);<br>
<br>
         if (m_param->scaleFactor)<br>
@@ -4345,12 +4355,12 @@<br>
             for (uint64_t index = 0; index < vbvCount; index++)<br>
                 analysis->lookahead.plannedSatd[index] *= factor;<br>
<br>
-            for (uint32_t i = 0; i < analysis->numCuInHeight; i++)<br>
+            for (uint32_t i = 0; i < numCUsInHeightLoad; i++)<br>
             {<br>
                 analysis->lookahead.satdForVbv[i] *= factor;<br>
                 analysis->lookahead.intraSatdForVbv[i] *= factor;<br>
             }<br>
-            for (uint32_t i = 0; i < analysis->numCUsInFrame; i++)<br>
+            for (uint32_t i = 0; i < numCUsLoad; i++)<br>
             {<br>
                 analysis->lookahead.vbvCost[i] *= factor;<br>
                 analysis->lookahead.intraVbvCost[i] *= factor;<br>
@@ -4400,13 +4410,13 @@<br>
<br>
         if (!m_param->scaleFactor)<br>
         {<br>
-            X265_FREAD((analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<br>
+            X265_FREAD((analysis->intraData)->modes, sizeof(uint8_t), numCUsLoad * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<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_analysisFileIn, intraPic->modes);<br>
-            for (uint32_t ctu32Idx = 0, cnt = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++, cnt += factor)<br>
+            uint8_t *tempLumaBuf = X265_MALLOC(uint8_t, numCUsLoad * scaledNumPartition);<br>
+            X265_FREAD(tempLumaBuf, sizeof(uint8_t), numCUsLoad * scaledNumPartition, m_analysisFileIn, intraPic->modes);<br>
+            for (uint32_t ctu32Idx = 0, cnt = 0; ctu32Idx < numCUsLoad * scaledNumPartition; ctu32Idx++, cnt += factor)<br>
                 memset(&(analysis->intraData)->modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>
             X265_FREE(tempLumaBuf);<br>
         }<br>
@@ -4440,7 +4450,7 @@<br>
         }<br>
         if (m_param->bAnalysisType == HEVC_INFO)<br>
         {<br>
-            depthBytes = analysis->numCUsInFrame * analysis->numPartitions;<br>
+            depthBytes = numCUsLoad * analysis->numPartitions;<br>
             memcpy(((x265_analysis_inter_data *)analysis->interData)->depth, interPic->depth, depthBytes);<br>
         }<br>
         else<br>
@@ -4544,25 +4554,26 @@<br>
             {<br>
                 if (!m_param->scaleFactor)<br>
                 {<br>
-                    X265_FREAD((analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<br>
+                    X265_FREAD((analysis->intraData)->modes, sizeof(uint8_t), numCUsLoad * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<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_analysisFileIn, intraPic->modes);<br>
-                    for (uint32_t ctu32Idx = 0, cnt = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++, cnt += factor)<br>
+                    uint8_t *tempLumaBuf = X265_MALLOC(uint8_t, numCUsLoad * scaledNumPartition);<br>
+                    X265_FREAD(tempLumaBuf, sizeof(uint8_t), numCUsLoad * scaledNumPartition, m_analysisFileIn, intraPic->modes);<br>
+                    for (uint32_t ctu32Idx = 0, cnt = 0; ctu32Idx < numCUsLoad * scaledNumPartition; ctu32Idx++, cnt += factor)<br>
                         memset(&(analysis->intraData)->modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>
                     X265_FREE(tempLumaBuf);<br>
                 }<br>
             }<br>
         }<br>
         else<br>
-            X265_FREAD((analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileIn, interPic->ref);<br>
+            X265_FREAD((analysis->interData)->ref, sizeof(int32_t), numCUsLoad * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileIn, interPic->ref);<br>
<br>
         consumedBytes += frameRecordSize;<br>
         if (numDir == 1)<br>
             totalConsumedBytes = consumedBytes;<br>
     }<br>
+<br>
 #undef X265_FREAD<br>
 }<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><font face="georgia, serif">Regards,</font><div><b><font face="georgia, serif">Aruna Matheswaran,</font></b></div><div><font face="georgia, serif">Video Codec Engineer,</font></div><div><font face="georgia, serif">Media & AI analytics BU,</font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" width="96" height="36" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><span><span style="font-size:11pt;font-family:Arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><span style="border:none;display:inline-block;overflow:hidden;width:153px;height:58px"><img src="https://lh5.googleusercontent.com/gjX5cPNIZgwUrhfqkTwQUZWztIKmmo0qs3kbwvkS5H-bDVE2ftte9pMTVnFLSjOcjYWLtfc6_OGpxW4vraLg2r5QAIf1Q3MpldFDgWtzK_gXi8ptw5B3joIbsGL6mxj-JRdjHzT5" style="margin-left: 0px; margin-top: 0px;"></span></span></span><font face="georgia, serif"><br></font></div><div><font face="georgia, serif"><br></font></div></div></div></div></div></div></div></div></div>