<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 2, 2020 at 6:53 PM Mahesh Pittala <<a href="mailto:mahesh@multicorewareinc.com">mahesh@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"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 1, 2020 at 7:09 PM Aruna Matheswaran <<a href="mailto:aruna@multicorewareinc.com" target="_blank">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"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 31, 2020 at 7:38 PM Mahesh Pittala <<a href="mailto:mahesh@multicorewareinc.com" target="_blank">mahesh@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"><div dir="ltr">From 812cccaa864da47dcf9567dccb81c9fef220c626 Mon Sep 17 00:00:00 2001<br>From: maheshpittala <<a href="mailto:mahesh@multicorewareinc.com" target="_blank">mahesh@multicorewareinc.com</a>><br>Date: Sat, 1 Aug 2020 14:52:48 +0530<br>Subject: [PATCH 1/1] Add support for reusing cutree offsets in all reuse<br> levels 1,2,5<br><br>Depth information required to load cutree offsets so writing depth information<br>but not using in reuse level 1<br></div></blockquote><div>[AM] Will this restrict reuse-level 1 from sharing analysis info across non-dyadic resolutions? </div></div></div></blockquote><div>No </div></div></div></blockquote><div>[AM] I don't see the logic for cutree sharing between non dyadic resolutions either. Am I missing anything? </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">---<br> source/abrEncApp.cpp Â  Â  Â  Â | Â 23 ++--<br> source/encoder/analysis.cpp | Â  2 +-<br> source/encoder/api.cpp Â  Â  Â | Â 53 +++++---<br> source/encoder/encoder.cpp Â | 239 +++++++++++++++++++++---------------<br> 4 files changed, 188 insertions(+), 129 deletions(-)<br><br>diff --git a/source/abrEncApp.cpp b/source/abrEncApp.cpp<br>index fa62ebf63..e26d3adfc 100644<br>--- a/source/abrEncApp.cpp<br>+++ b/source/abrEncApp.cpp<br>@@ -330,15 +330,16 @@ namespace X265_NS {<br> <br>  Â  Â  Â  Â if (src->sliceType == X265_TYPE_IDR || src->sliceType == X265_TYPE_I)<br>  Â  Â  Â  Â {<br>- Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel < 2)<br>- Â  Â  Â  Â  Â  Â  Â  Â goto ret;<br>  Â  Â  Â  Â  Â  Â x265_analysis_intra_data *intraDst, *intraSrc;<br>  Â  Â  Â  Â  Â  Â intraDst = (x265_analysis_intra_data*)m_analysisInfo->intraData;<br>  Â  Â  Â  Â  Â  Â intraSrc = (x265_analysis_intra_data*)src->intraData;<br>- Â  Â  Â  Â  Â  Â memcpy(intraDst->depth, intraSrc->depth, sizeof(uint8_t) * src->depthBytes);<br>- Â  Â  Â  Â  Â  Â memcpy(intraDst->modes, intraSrc->modes, sizeof(uint8_t) * src->numCUsInFrame * src->numPartitions);<br>- Â  Â  Â  Â  Â  Â memcpy(intraDst->partSizes, intraSrc->partSizes, sizeof(char) * src->depthBytes);<br>- Â  Â  Â  Â  Â  Â memcpy(intraDst->chromaModes, intraSrc->chromaModes, sizeof(uint8_t) * src->depthBytes);<br>+ Â  Â  Â  Â  Â  Â memcpy(intraDst->depth, intraSrc->depth, sizeof(uint8_t)* src->depthBytes);<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â memcpy(intraDst->modes, intraSrc->modes, sizeof(uint8_t)* src->numCUsInFrame * src->numPartitions);<br>+ Â  Â  Â  Â  Â  Â  Â  Â memcpy(intraDst->partSizes, intraSrc->partSizes, sizeof(char)* src->depthBytes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â memcpy(intraDst->chromaModes, intraSrc->chromaModes, sizeof(uint8_t)* src->depthBytes);<br>+ Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â memcpy(intraDst->cuQPOff, intraSrc->cuQPOff, sizeof(int8_t) * src->depthBytes);<br>  Â  Â  Â  Â }<br>@@ -347,13 +348,12 @@ namespace X265_NS {<br>  Â  Â  Â  Â  Â  Â bool bIntraInInter = (src->sliceType == X265_TYPE_P || m_param->bIntraInBFrames);<br>  Â  Â  Â  Â  Â  Â int numDir = src->sliceType == X265_TYPE_P ? 1 : 2;<br>  Â  Â  Â  Â  Â  Â memcpy(m_analysisInfo->wt, src->wt, sizeof(WeightParam) * 3 * numDir);<br>- Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel < 2)<br>- Â  Â  Â  Â  Â  Â  Â  Â goto ret;<br>  Â  Â  Â  Â  Â  Â x265_analysis_inter_data *interDst, *interSrc;<br>  Â  Â  Â  Â  Â  Â interDst = (x265_analysis_inter_data*)m_analysisInfo->interData;<br>  Â  Â  Â  Â  Â  Â interSrc = (x265_analysis_inter_data*)src->interData;<br>- Â  Â  Â  Â  Â  Â memcpy(interDst->depth, interSrc->depth, sizeof(uint8_t) * src->depthBytes);<br>- Â  Â  Â  Â  Â  Â memcpy(interDst->modes, interSrc->modes, sizeof(uint8_t) * src->depthBytes);<br>+ Â  Â  Â  Â  Â  Â memcpy(interDst->depth, interSrc->depth, sizeof(uint8_t)* src->depthBytes);<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â memcpy(interDst->modes, interSrc->modes, sizeof(uint8_t)* src->depthBytes);<br>  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â memcpy(interDst->cuQPOff, interSrc->cuQPOff, sizeof(int8_t) * src->depthBytes);<br>  Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 4)<br>@@ -378,11 +378,10 @@ namespace X265_NS {<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â  Â  }<br>  Â  Â  Â  Â  Â  Â }<br>- Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel != 10)<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel != 10 && m_param->analysisSaveReuseLevel > 1)<br>  Â  Â  Â  Â  Â  Â  Â  Â memcpy(interDst->ref, interSrc->ref, sizeof(int32_t) * src->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir);<br>  Â  Â  Â  Â }<br> <br>-ret:<br>  Â  Â  Â  Â //increment analysis Write counter <br>  Â  Â  Â  Â m_parent->m_analysisWriteCnt[m_id].incr();<br>  Â  Â  Â  Â m_parent->m_analysisWrite[m_id][index].incr();<br>diff --git a/source/encoder/analysis.cpp b/source/encoder/analysis.cpp<br>index 157bae8cd..351d8a3c8 100644<br>--- a/source/encoder/analysis.cpp<br>+++ b/source/encoder/analysis.cpp<br>@@ -3645,7 +3645,7 @@ int Analysis::calculateQpforCuSize(const CUData& ctu, const CUGeom& cuGeom, int3<br>  Â  Â  Â  Â  Â  Â qp += distortionData->offset[ctu.m_cuAddr];<br>  Â  Â }<br> <br>- Â  Â if (m_param->analysisLoadReuseLevel == 10 && m_param->rc.cuTree)<br>+ Â  Â if (m_param->analysisLoadReuseLevel >= 1 && m_param->rc.cuTree)<br></div></blockquote><div>[AM] Shall replace this check with "if (m_param->analysisLoadReuseLevel && m_param->rc.cuTree)" </div></div></div></blockquote><div>I will change it </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">  Â  Â {<br>  Â  Â  Â  Â int cuIdx = (ctu.m_cuAddr * ctu.m_numPartitions) + cuGeom.absPartIdx;<br>  Â  Â  Â  Â if (ctu.m_slice->m_sliceType == I_SLICE)<br>diff --git a/source/encoder/api.cpp b/source/encoder/api.cpp<br>index a986355e0..4ef3f04bc 100644<br>--- a/source/encoder/api.cpp<br>+++ b/source/encoder/api.cpp<br>@@ -813,35 +813,41 @@ void x265_alloc_analysis_data(x265_param *param, x265_analysis_data* analysis)<br>  Â  Â  Â  Â CHECKED_MALLOC_ZERO(analysis->wt, x265_weight_param, numPlanes * numDir);<br> <br>  Â  Â //Allocate memory for intraData pointer<br>- Â  Â if ((maxReuseLevel > 1) || isMultiPassOpt)<br>+ Â  Â if ((maxReuseLevel > 0) || isMultiPassOpt)<br>  Â  Â {<br>  Â  Â  Â  Â CHECKED_MALLOC_ZERO(intraData, x265_analysis_intra_data, 1);<br>  Â  Â  Â  Â CHECKED_MALLOC(intraData->depth, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>  Â  Â }<br></div></blockquote><div>[AM] If cutree offsets and CU depths are shared in all the reuse levels, can we change the order of analysis data write/read such that CU depth and cutree write/read happens in the common section? By doing this you can eliminate the "reuse-level > 0" check all over the code.</div></div></div></blockquote><div>CU depths are shared from reuse-leve 2 in code, no info about CU depths in doc. I have enabled cutree offsets sharing in all reuse levels,</div></div></div></blockquote><div>[AM] Sorry, I don't get your point. Could you please elaborate? </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> <br>- Â  Â if (maxReuseLevel > 1)<br>+ Â  Â if (maxReuseLevel > 0)<br>  Â  Â {<br>- Â  Â  Â  Â CHECKED_MALLOC_ZERO(intraData->modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>- Â  Â  Â  Â CHECKED_MALLOC_ZERO(intraData->partSizes, char, analysis->numPartitions * analysis->numCUsInFrame);<br>- Â  Â  Â  Â CHECKED_MALLOC_ZERO(intraData->chromaModes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â if (maxReuseLevel > 1)<br>+ Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(intraData->modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(intraData->partSizes, char, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(intraData->chromaModes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â }<br>  Â  Â  Â  Â if (param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(intraData->cuQPOff, int8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>  Â  Â }<br>  Â  Â analysis->intraData = intraData;<br> <br>- Â  Â if ((maxReuseLevel > 1) || isMultiPassOpt)<br>+ Â  Â if ((maxReuseLevel > 0) || isMultiPassOpt)<br>  Â  Â {<br>  Â  Â  Â  Â //Allocate memory for interData pointer based on ReuseLevels<br>  Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData, x265_analysis_inter_data, 1);<br>  Â  Â  Â  Â CHECKED_MALLOC(interData->depth, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>- Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>-<br>  Â  Â  Â  Â if (param->rc.cuTree && !isMultiPassOpt)<br>  Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->cuQPOff, int8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>- Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->mvpIdx[0], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>- Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->mvpIdx[1], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>- Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->mv[0], x265_analysis_MV, analysis->numPartitions * analysis->numCUsInFrame);<br>- Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->mv[1], x265_analysis_MV, analysis->numPartitions * analysis->numCUsInFrame);<br>+<br>+ Â  Â  Â  Â if (maxReuseLevel > 1)<br>+ Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->mvpIdx[0], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->mvpIdx[1], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->mv[0], x265_analysis_MV, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â  Â  Â CHECKED_MALLOC_ZERO(interData->mv[1], x265_analysis_MV, analysis->numPartitions * analysis->numCUsInFrame);<br>+ Â  Â  Â  Â }<br>  Â  Â }<br> <br>  Â  Â if (maxReuseLevel > 4)<br>@@ -915,9 +921,12 @@ void x265_free_analysis_data(x265_param *param, x265_analysis_data* analysis)<br>  Â  Â  Â  Â X265_FREE((analysis->intraData)->depth);<br>  Â  Â  Â  Â if (!isMultiPassOpt)<br>  Â  Â  Â  Â {<br>- Â  Â  Â  Â  Â  Â X265_FREE((analysis->intraData)->modes);<br>- Â  Â  Â  Â  Â  Â X265_FREE((analysis->intraData)->partSizes);<br>- Â  Â  Â  Â  Â  Â X265_FREE((analysis->intraData)->chromaModes);<br>+ Â  Â  Â  Â  Â  Â if (maxReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FREE((analysis->intraData)->modes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FREE((analysis->intraData)->partSizes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FREE((analysis->intraData)->chromaModes);<br>+ Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â if (param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â X265_FREE((analysis->intraData)->cuQPOff);<br>  Â  Â  Â  Â }<br>@@ -929,13 +938,17 @@ void x265_free_analysis_data(x265_param *param, x265_analysis_data* analysis)<br>  Â  Â if (analysis->interData)<br>  Â  Â {<br>  Â  Â  Â  Â X265_FREE((analysis->interData)->depth);<br>- Â  Â  Â  Â X265_FREE((analysis->interData)->modes);<br>  Â  Â  Â  Â if (!isMultiPassOpt && param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â X265_FREE((analysis->interData)->cuQPOff);<br>- Â  Â  Â  Â X265_FREE((analysis->interData)->mvpIdx[0]);<br>- Â  Â  Â  Â X265_FREE((analysis->interData)->mvpIdx[1]);<br>- Â  Â  Â  Â X265_FREE((analysis->interData)->mv[0]);<br>- Â  Â  Â  Â X265_FREE((analysis->interData)->mv[1]);<br>+<br>+ Â  Â  Â  Â if (maxReuseLevel > 1)<br>+ Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â X265_FREE((analysis->interData)->modes);<br>+ Â  Â  Â  Â  Â  Â X265_FREE((analysis->interData)->mvpIdx[0]);<br>+ Â  Â  Â  Â  Â  Â X265_FREE((analysis->interData)->mvpIdx[1]);<br>+ Â  Â  Â  Â  Â  Â X265_FREE((analysis->interData)->mv[0]);<br>+ Â  Â  Â  Â  Â  Â X265_FREE((analysis->interData)->mv[1]);<br>+ Â  Â  Â  Â }<br> <br>  Â  Â  Â  Â if (maxReuseLevel > 4)<br>  Â  Â  Â  Â {<br>diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp<br>index cf7bfb98d..c87feb84a 100644<br>--- a/source/encoder/encoder.cpp<br>+++ b/source/encoder/encoder.cpp<br>@@ -4448,8 +4448,6 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â {<br>  Â  Â  Â  Â if (m_param->bAnalysisType == HEVC_INFO)<br>  Â  Â  Â  Â  Â  Â return;<br>- Â  Â  Â  Â if (m_param->analysisLoadReuseLevel < 2)<br>- Â  Â  Â  Â  Â  Â return;<br> <br>  Â  Â  Â  Â uint8_t *tempBuf = NULL, *depthBuf = NULL, *modeBuf = NULL, *partSizes = NULL;<br>  Â  Â  Â  Â int8_t *cuQPBuf = NULL;<br>@@ -4462,8 +4460,11 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â cuQPBuf = X265_MALLOC(int8_t, depthBytes);<br> <br>  Â  Â  Â  Â X265_FREAD(depthBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->depth);<br>- Â  Â  Â  Â X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->chromaModes);<br>- Â  Â  Â  Â X265_FREAD(partSizes, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->partSizes);<br>+ Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->chromaModes);<br>+ Â  Â  Â  Â  Â  Â X265_FREAD(partSizes, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->partSizes);<br>+ Â  Â  Â  Â }<br>  Â  Â  Â  Â if (m_param->rc.cuTree) { X265_FREAD(cuQPBuf, sizeof(int8_t), depthBytes, m_analysisFileIn, intraPic->cuQPOff); }<br> <br>  Â  Â  Â  Â size_t count = 0;<br>@@ -4478,38 +4479,40 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â partSizes[d] = SIZE_2Nx2N;<br>  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->depth[count], depthBuf[d], bytes);<br>- Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->chromaModes[count], modeBuf[d], bytes);<br>- Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->partSizes[count], partSizes[d], bytes);<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->chromaModes[count], modeBuf[d], bytes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->partSizes[count], partSizes[d], bytes);<br>+ Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->cuQPOff[count], cuQPBuf[d], bytes);<br>  Â  Â  Â  Â  Â  Â count += bytes;<br>  Â  Â  Â  Â }<br>-<br>- Â  Â  Â  Â if (!m_param->scaleFactor)<br>- Â  Â  Â  Â {<br>- Â  Â  Â  Â  Â  Â X265_FREAD((analysis->intraData)->modes, sizeof(uint8_t), numCUsLoad * analysis->numPartitions, m_analysisFileIn, intraPic->modes);<br>- Â  Â  Â  Â }<br>- Â  Â  Â  Â else<br>+ Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>  Â  Â  Â  Â {<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>+ Â  Â  Â  Â  Â  Â if (!m_param->scaleFactor)<br>+ Â  Â  Â  Â  Â  Â {<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, 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>  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â X265_FREE(cuQPBuf);<br>  Â  Â  Â  Â X265_FREE(tempBuf);<br>  Â  Â  Â  Â consumedBytes += frameRecordSize;<br>  Â  Â }<br>-<br>  Â  Â else<br>  Â  Â {<br>  Â  Â  Â  Â uint32_t numDir = analysis->sliceType == X265_TYPE_P ? 1 : 2;<br>  Â  Â  Â  Â uint32_t numPlanes = m_param->internalCsp == X265_CSP_I400 ? 1 : 3;<br>  Â  Â  Â  Â X265_FREAD((WeightParam*)analysis->wt, sizeof(WeightParam), numPlanes * numDir, m_analysisFileIn, (picIn->analysisData.wt));<br>- Â  Â  Â  Â if (m_param->analysisLoadReuseLevel < 2)<br>- Â  Â  Â  Â  Â  Â return;<br> <br>  Â  Â  Â  Â uint8_t *tempBuf = NULL, *depthBuf = NULL, *modeBuf = NULL, *partSize = NULL, *mergeFlag = NULL;<br>  Â  Â  Â  Â uint8_t *interDir = NULL, *chromaDir = NULL, *mvpIdx[2];<br>@@ -4539,9 +4542,11 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â  Â  Â cuQPBuf = X265_MALLOC(int8_t, depthBytes);<br> <br>  Â  Â  Â  Â  Â  Â X265_FREAD(depthBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, interPic->depth);<br>- Â  Â  Â  Â  Â  Â X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, interPic->modes);<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, interPic->modes);<br>  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree) { X265_FREAD(cuQPBuf, sizeof(int8_t), depthBytes, m_analysisFileIn, interPic->cuQPOff); }<br> <br>+<br>  Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 4)<br>  Â  Â  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â  Â  Â partSize = modeBuf + depthBytes;<br>@@ -4577,9 +4582,13 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->scaleFactor && modeBuf[d] == MODE_INTRA && depthBuf[d] == 0)<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â depthBuf[d] = 1;<br>  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->interData)->depth[count], depthBuf[d], bytes);<br>- Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->interData)->modes[count], modeBuf[d], bytes);<br>+<br>+ Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->interData)->modes[count], modeBuf[d], bytes);<br>+<br>  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->interData)->cuQPOff[count], cuQPBuf[d], bytes);<br>+<br>  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 4)<br>  Â  Â  Â  Â  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->scaleFactor && modeBuf[d] == MODE_INTRA && partSize[d] == SIZE_NxN)<br>@@ -4643,7 +4652,7 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â }<br>- Â  Â  Â  Â else<br>+ Â  Â  Â  Â else if (m_param->analysisLoadReuseLevel > 1)<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>@@ -4810,9 +4819,6 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br> <br>  Â  Â if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)<br>  Â  Â {<br>- Â  Â  Â  Â if (m_param->analysisLoadReuseLevel < 2)<br>- Â  Â  Â  Â  Â  Â return;<br>-<br>  Â  Â  Â  Â uint8_t *tempBuf = NULL, *depthBuf = NULL, *modeBuf = NULL, *partSizes = NULL;<br>  Â  Â  Â  Â int8_t *cuQPBuf = NULL;<br> <br>@@ -4824,8 +4830,12 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â cuQPBuf = X265_MALLOC(int8_t, depthBytes);<br> <br>  Â  Â  Â  Â X265_FREAD(depthBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->depth);<br>- Â  Â  Â  Â X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->chromaModes);<br>- Â  Â  Â  Â X265_FREAD(partSizes, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->partSizes);<br>+<br>+ Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->chromaModes);<br>+ Â  Â  Â  Â  Â  Â X265_FREAD(partSizes, sizeof(uint8_t), depthBytes, m_analysisFileIn, intraPic->partSizes);<br>+ Â  Â  Â  Â }<br>  Â  Â  Â  Â if (m_param->rc.cuTree) { X265_FREAD(cuQPBuf, sizeof(int8_t), depthBytes, m_analysisFileIn, intraPic->cuQPOff); }<br> <br>  Â  Â  Â  Â uint32_t count = 0;<br>@@ -4838,36 +4848,45 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â  Â  Â bytes /= 4;<br>  Â  Â  Â  Â  Â  Â  Â  Â numCTUCopied = 4;<br>  Â  Â  Â  Â  Â  Â }<br>- Â  Â  Â  Â  Â  Â if (partSizes[d] == SIZE_NxN)<br>- Â  Â  Â  Â  Â  Â  Â  Â partSizes[d] = SIZE_2Nx2N;<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â if (partSizes[d] == SIZE_NxN)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â partSizes[d] = SIZE_2Nx2N;<br>+ Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â if ((depthBuf[d] > 1 && m_param->maxCUSize == 64) || (depthBuf[d] && m_param->maxCUSize != 64))<br>  Â  Â  Â  Â  Â  Â  Â  Â depthBuf[d]--;<br> <br>  Â  Â  Â  Â  Â  Â for (int numCTU = 0; numCTU < numCTUCopied; numCTU++)<br>  Â  Â  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->depth[count], depthBuf[d], bytes);<br>- Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->chromaModes[count], modeBuf[d], bytes);<br>- Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->partSizes[count], partSizes[d], bytes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->chromaModes[count], modeBuf[d], bytes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->partSizes[count], partSizes[d], bytes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->cuQPOff[count], cuQPBuf[d], bytes);<br>+<br>  Â  Â  Â  Â  Â  Â  Â  Â count += bytes;<br>  Â  Â  Â  Â  Â  Â  Â  Â d += getCUIndex(&cuLoc, &count, bytes, 1);<br>  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â }<br>-<br>- Â  Â  Â  Â cuLoc.evenRowIndex = 0;<br>- Â  Â  Â  Â cuLoc.oddRowIndex = m_param->num4x4Partitions * cuLoc.widthInCU;<br>- Â  Â  Â  Â cuLoc.switchCondition = 0;<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>- Â  Â  Â  Â uint32_t cnt = 0;<br>- Â  Â  Â  Â for (uint32_t ctu32Idx = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++)<br>+ Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>  Â  Â  Â  Â {<br>- Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>- Â  Â  Â  Â  Â  Â cnt += factor;<br>- Â  Â  Â  Â  Â  Â ctu32Idx += getCUIndex(&cuLoc, &cnt, factor, 0);<br>+ Â  Â  Â  Â  Â  Â cuLoc.evenRowIndex = 0;<br>+ Â  Â  Â  Â  Â  Â cuLoc.oddRowIndex = m_param->num4x4Partitions * cuLoc.widthInCU;<br>+ Â  Â  Â  Â  Â  Â cuLoc.switchCondition = 0;<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>+ Â  Â  Â  Â  Â  Â uint32_t cnt = 0;<br>+ Â  Â  Â  Â  Â  Â for (uint32_t ctu32Idx = 0; ctu32Idx < analysis->numCUsInFrame * scaledNumPartition; ctu32Idx++)<br>+ Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->intraData)->modes[cnt], tempLumaBuf[ctu32Idx], factor);<br>+ Â  Â  Â  Â  Â  Â  Â  Â cnt += factor;<br>+ Â  Â  Â  Â  Â  Â  Â  Â ctu32Idx += getCUIndex(&cuLoc, &cnt, factor, 0);<br>+ Â  Â  Â  Â  Â  Â }<br>+ Â  Â  Â  Â  Â  Â X265_FREE(tempLumaBuf);<br>  Â  Â  Â  Â }<br>- Â  Â  Â  Â X265_FREE(tempLumaBuf);<br>  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â X265_FREE(cuQPBuf);<br>  Â  Â  Â  Â X265_FREE(tempBuf);<br>@@ -4879,8 +4898,6 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â uint32_t numDir = analysis->sliceType == X265_TYPE_P ? 1 : 2;<br>  Â  Â  Â  Â uint32_t numPlanes = m_param->internalCsp == X265_CSP_I400 ? 1 : 3;<br>  Â  Â  Â  Â X265_FREAD((WeightParam*)analysis->wt, sizeof(WeightParam), numPlanes * numDir, m_analysisFileIn, (picIn->analysisData.wt));<br>- Â  Â  Â  Â if (m_param->analysisLoadReuseLevel < 2)<br>- Â  Â  Â  Â  Â  Â return;<br> <br>  Â  Â  Â  Â uint8_t *tempBuf = NULL, *depthBuf = NULL, *modeBuf = NULL, *partSize = NULL, *mergeFlag = NULL;<br>  Â  Â  Â  Â uint8_t *interDir = NULL, *chromaDir = NULL, *mvpIdx[2];<br>@@ -4904,8 +4921,10 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â cuQPBuf = X265_MALLOC(int8_t, depthBytes);<br> <br>  Â  Â  Â  Â X265_FREAD(depthBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, interPic->depth);<br>- Â  Â  Â  Â X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, interPic->modes);<br>+ Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â X265_FREAD(modeBuf, sizeof(uint8_t), depthBytes, m_analysisFileIn, interPic->modes);<br>  Â  Â  Â  Â if (m_param->rc.cuTree) { X265_FREAD(cuQPBuf, sizeof(int8_t), depthBytes, m_analysisFileIn, interPic->cuQPOff); }<br>+<br>  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 4)<br>  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â partSize = modeBuf + depthBytes;<br>@@ -4953,7 +4972,9 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â for (int numCTU = 0; numCTU < numCTUCopied; numCTU++)<br>  Â  Â  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->interData)->depth[count], writeDepth, bytes);<br>- Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->interData)->modes[count], modeBuf[d], bytes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->interData)->modes[count], modeBuf[d], bytes);<br>+<br>  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memset(&(analysis->interData)->cuQPOff[count], cuQPBuf[d], bytes);<br>  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisLoadReuseLevel == 10 && bIntraInInter)<br>@@ -5045,7 +5066,7 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x<br>  Â  Â  Â  Â  Â  Â  Â  Â X265_FREE(tempLumaBuf);<br>  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â }<br>- Â  Â  Â  Â else<br>+            else if (m_param->analysisLoadReuseLevel > 1)<br>  Â  Â  Â  Â  Â  Â X265_FREAD((analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileIn, interPic->ref);<br> <br>  Â  Â  Â  Â consumedBytes += frameRecordSize;<br>@@ -5155,6 +5176,8 @@ int Encoder::validateAnalysisData(x265_analysis_validate* saveParam, int writeFl<br>  Â  Â  Â  Â  Â  Â isIncompatibleReuseLevel = true;<br>  Â  Â  Â  Â else if ((loadLevel >= 2 && loadLevel <= 4) && (saveLevel < 2 || saveLevel > 6))<br>  Â  Â  Â  Â  Â  Â isIncompatibleReuseLevel = true;<br>+ Â  Â  Â  Â else if (loadLevel == 1 && saveLevel < 1)<br>+ Â  Â  Â  Â  Â  Â isIncompatibleReuseLevel = true;<br>  Â  Â  Â  Â else if (!saveLevel)<br>  Â  Â  Â  Â  Â  Â isIncompatibleReuseLevel = true;<br> <br>@@ -5167,7 +5190,7 @@ int Encoder::validateAnalysisData(x265_analysis_validate* saveParam, int writeFl<br> <br>  Â  Â  Â  Â int bcutree;<br>  Â  Â  Â  Â X265_FREAD(&bcutree, sizeof(int), 1, m_analysisFileIn, &(saveParam->cuTree));<br>- Â  Â  Â  Â if (loadLevel == 10 && m_param->rc.cuTree && (!bcutree || saveLevel < 2))<br>+ Â  Â  Â  Â if (loadLevel >= 1 && m_param->rc.cuTree && (!bcutree || saveLevel < 1))<br>  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â x265_log(NULL, X265_LOG_ERROR, "Error reading cu-tree info. Disabling cutree offsets. \n");<br>  Â  Â  Â  Â  Â  Â m_param->rc.cuTree = 0;<br>@@ -5510,7 +5533,7 @@ void Encoder::writeAnalysisFile(x265_analysis_data* analysis, FrameData &curEncD<br>  Â  Â  Â  Â analysis->frameRecordSize += analysis->numCUsInFrame * sizeof(sse_t);<br>  Â  Â }<br> <br>- Â  Â if (m_param->analysisSaveReuseLevel > 1)<br>+ Â  Â if (m_param->analysisSaveReuseLevel > 0)<br>  Â  Â {<br> <br>  Â  Â  Â  Â if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)<br>@@ -5529,18 +5552,21 @@ void Encoder::writeAnalysisFile(x265_analysis_data* analysis, FrameData &curEncD<br>  Â  Â  Â  Â  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â depth = ctu->m_cuDepth[absPartIdx];<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â intraDataCTU->depth[depthBytes] = depth;<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â mode = ctu->m_chromaIntraDir[absPartIdx];<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â intraDataCTU->chromaModes[depthBytes] = mode;<br> <br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â mode = ctu->m_chromaIntraDir[absPartIdx];<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â intraDataCTU->chromaModes[depthBytes] = mode;<br>-<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â partSize = ctu->m_partSize[absPartIdx];<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â intraDataCTU->partSizes[depthBytes] = partSize;<br>-<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â partSize = ctu->m_partSize[absPartIdx];<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â intraDataCTU->partSizes[depthBytes] = partSize;<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â intraDataCTU->cuQPOff[depthBytes] = (int8_t)(ctu->m_qpAnalysis[absPartIdx] - baseQP);<br>+<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â absPartIdx += ctu->m_numPartitions >> (depth * 2);<br>  Â  Â  Â  Â  Â  Â  Â  Â }<br>- Â  Â  Â  Â  Â  Â  Â  Â memcpy(&intraDataCTU->modes[ctu->m_cuAddr * ctu->m_numPartitions], ctu->m_lumaIntraDir, sizeof(uint8_t)* ctu->m_numPartitions);<br>+ Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memcpy(&intraDataCTU->modes[ctu->m_cuAddr * ctu->m_numPartitions], ctu->m_lumaIntraDir, sizeof(uint8_t)* ctu->m_numPartitions);<br>  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â }<br>  Â  Â  Â  Â else<br>@@ -5561,12 +5587,14 @@ void Encoder::writeAnalysisFile(x265_analysis_data* analysis, FrameData &curEncD<br>  Â  Â  Â  Â  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â depth = ctu->m_cuDepth[absPartIdx];<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â interDataCTU->depth[depthBytes] = depth;<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â predMode = ctu->m_predMode[absPartIdx];<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel != 10 && ctu->m_refIdx[1][absPartIdx] != -1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â predMode = 4; // used as indicator if the block is coded as bidir<br> <br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â predMode = ctu->m_predMode[absPartIdx];<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel != 10 && ctu->m_refIdx[1][absPartIdx] != -1)<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â predMode = 4; // used as indicator if the block is coded as bidir<br>-<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â interDataCTU->modes[depthBytes] = predMode;<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â interDataCTU->modes[depthBytes] = predMode;<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â interDataCTU->cuQPOff[depthBytes] = (int8_t)(ctu->m_qpAnalysis[absPartIdx] - baseQP);<br> <br>@@ -5603,17 +5631,22 @@ void Encoder::writeAnalysisFile(x265_analysis_data* analysis, FrameData &curEncD<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â memcpy(&intraDataCTU->modes[ctu->m_cuAddr * ctu->m_numPartitions], ctu->m_lumaIntraDir, sizeof(uint8_t)* ctu->m_numPartitions);<br>  Â  Â  Â  Â  Â  Â }<br>  Â  Â  Â  Â }<br>-<br>- Â  Â  Â  Â if ((analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I) && m_param->rc.cuTree)<br>+ Â  Â  Â  Â if ((analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I) && m_param->rc.cuTree && m_param->analysisSaveReuseLevel == 1)<br>+ Â  Â  Â  Â  Â  Â analysis->frameRecordSize += depthBytes + (sizeof(int8_t)* depthBytes);<br>+ Â  Â  Â  Â else if ((analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I) && m_param->analysisSaveReuseLevel == 1)<br>+ Â  Â  Â  Â  Â  Â analysis->frameRecordSize += depthBytes;<br>+ Â  Â  Â  Â else if ((analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I) && m_param->rc.cuTree)<br>  Â  Â  Â  Â  Â  Â analysis->frameRecordSize += sizeof(uint8_t)* analysis->numCUsInFrame * analysis->numPartitions + depthBytes * 3 + (sizeof(int8_t) * depthBytes);<br>  Â  Â  Â  Â else if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)<br>  Â  Â  Â  Â  Â  Â analysis->frameRecordSize += sizeof(uint8_t)* analysis->numCUsInFrame * analysis->numPartitions + depthBytes * 3;<br>  Â  Â  Â  Â else<br>  Â  Â  Â  Â {<br>  Â  Â  Â  Â  Â  Â /* Add sizeof depth, modes, partSize, cuQPOffset, mergeFlag */<br>- Â  Â  Â  Â  Â  Â analysis->frameRecordSize += depthBytes * 2;<br>+ Â  Â  Â  Â  Â  Â analysis->frameRecordSize += depthBytes;<br>  Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>- Â  Â  Â  Â  Â  Â analysis->frameRecordSize += (sizeof(int8_t) * depthBytes);<br>+ Â  Â  Â  Â  Â  Â  Â  Â analysis->frameRecordSize += (sizeof(int8_t) * depthBytes);<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 1)<br>+ Â  Â  Â  Â  Â  Â  Â  Â analysis->frameRecordSize += depthBytes;<br>  Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 4)<br>  Â  Â  Â  Â  Â  Â  Â  Â analysis->frameRecordSize += (depthBytes * 2);<br> <br>@@ -5627,7 +5660,7 @@ void Encoder::writeAnalysisFile(x265_analysis_data* analysis, FrameData &curEncD<br>  Â  Â  Â  Â  Â  Â  Â  Â if (bIntraInInter)<br>  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â analysis->frameRecordSize += sizeof(uint8_t)* analysis->numCUsInFrame * analysis->numPartitions + depthBytes;<br>  Â  Â  Â  Â  Â  Â }<br>- Â  Â  Â  Â  Â  Â else<br>+ Â  Â  Â  Â  Â  Â else if (m_param->analysisSaveReuseLevel > 1)<br>  Â  Â  Â  Â  Â  Â  Â  Â analysis->frameRecordSize += sizeof(int32_t)* analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir;<br>  Â  Â  Â  Â }<br>  Â  Â  Â  Â analysis->depthBytes = depthBytes;<br>@@ -5661,44 +5694,58 @@ void Encoder::writeAnalysisFile(x265_analysis_data* analysis, FrameData &curEncD<br>  Â  Â  Â  Â X265_FWRITE((WeightParam*)analysis->wt, sizeof(WeightParam), numPlanes * numDir, m_analysisFileOut);<br> <br>  Â  Â if (m_param->analysisSaveReuseLevel < 2)<br>- Â  Â  Â  Â return;<br>-<br>- Â  Â if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)<br>  Â  Â {<br>- Â  Â  Â  Â X265_FWRITE((analysis->intraData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â X265_FWRITE((analysis->intraData)->chromaModes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â X265_FWRITE((analysis->intraData)->partSizes, sizeof(char), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â if (m_param->rc.cuTree)<br>- Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->cuQPOff, sizeof(int8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â X265_FWRITE((analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileOut);<br>+ Â  Â  Â  Â if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)<br>+ Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->cuQPOff, sizeof(int8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â }<br>+ Â  Â  Â  Â else<br>+ Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->cuQPOff, sizeof(int8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â }<br>  Â  Â }<br>  Â  Â else<br>  Â  Â {<br>- Â  Â  Â  Â X265_FWRITE((analysis->interData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â X265_FWRITE((analysis->interData)->modes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â if (m_param->rc.cuTree)<br>- Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->cuQPOff, sizeof(int8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 4)<br>+ Â  Â  Â  Â if (analysis->sliceType == X265_TYPE_IDR || analysis->sliceType == X265_TYPE_I)<br>  Â  Â  Â  Â {<br>- Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->partSize, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->mergeFlag, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel == 10)<br>+ Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->chromaModes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->partSizes, sizeof(char), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->cuQPOff, sizeof(int8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileOut);<br>+ Â  Â  Â  Â }<br>+ Â  Â  Â  Â else<br>+ Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->depth, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->modes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â if (m_param->rc.cuTree)<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->cuQPOff, sizeof(int8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 4)<br>  Â  Â  Â  Â  Â  Â {<br>- Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->interDir, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â  Â  Â  Â  Â if (bIntraInInter) X265_FWRITE((analysis->intraData)->chromaModes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â  Â  Â  Â  Â for (uint32_t dir = 0; dir < numDir; dir++)<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->partSize, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->mergeFlag, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel == 10)<br>  Â  Â  Â  Â  Â  Â  Â  Â {<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->mvpIdx[dir], sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->refIdx[dir], sizeof(int8_t), depthBytes, m_analysisFileOut);<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->mv[dir], sizeof(MV), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->interDir, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (bIntraInInter) X265_FWRITE((analysis->intraData)->chromaModes, sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â for (uint32_t dir = 0; dir < numDir; dir++)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â {<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->mvpIdx[dir], sizeof(uint8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->refIdx[dir], sizeof(int8_t), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->mv[dir], sizeof(MV), depthBytes, m_analysisFileOut);<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â }<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â if (bIntraInInter)<br>+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileOut);<br>  Â  Â  Â  Â  Â  Â  Â  Â }<br>- Â  Â  Â  Â  Â  Â  Â  Â if (bIntraInInter)<br>- Â  Â  Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->intraData)->modes, sizeof(uint8_t), analysis->numCUsInFrame * analysis->numPartitions, m_analysisFileOut);<br>  Â  Â  Â  Â  Â  Â }<br>+ Â  Â  Â  Â  Â  Â if (m_param->analysisSaveReuseLevel > 1 && m_param->analysisSaveReuseLevel != 10)<br>+ Â  Â  Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileOut);<br>  Â  Â  Â  Â }<br>- Â  Â  Â  Â if (m_param->analysisSaveReuseLevel != 10)<br>- Â  Â  Â  Â  Â  Â X265_FWRITE((analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFileOut);<br>-<br>  Â  Â }<br> #undef X265_FWRITE<br> }<br>-- <br>2.18.2<br><br></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><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></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><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></div>