<div dir="ltr">Hi Soundariya,<div><br></div><div>I have a general comment on the patch. I dont think we need 1 * EDGE_BINS or 1 * HISTOGRAM_BINS during memcpy or fread operations. Please optimize that everywhere in the patch.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 12, 2020 at 1:28 PM Soundariya Ranin Venkatesh <<a href="mailto:soundariya@multicorewareinc.com">soundariya@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">[AM] Why 1024 bins even for 8-bit input? Can we instead allocate memory dynamically in x265_alloc_analysis_data()? <div>Since the computation of histogram is happening before x265_alloc_analysis_data(), it is not possible to allocate dynamically <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 12, 2020 at 12:17 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 Wed, May 6, 2020 at 11:31 AM Soundariya Ranin Venkatesh <<a href="mailto:soundariya@multicorewareinc.com" target="_blank">soundariya@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">Incorporated the review comments given<div># HG changeset patch<br># User Soundariya <<a href="mailto:soundariya@multicorewareinc.com" target="_blank">soundariya@multicorewareinc.com</a>><br># Date 1587447270 -19800<br># Tue Apr 21 11:04:30 2020 +0530<br># Node ID ce128262e4e250c8fa071b51eb67b7ddaa13e62a<br># Parent 303ff9e4546d0052e7a4d359323f0aca84eedd68<br>Store histogram of Y, U, V and Y's edge in analysis file.<br><br>Enables the application to compute Y Histogram and store Histogram of Y, U, V Channel<br>and Y's Edge in analysis file at all reuse levels when --hist-scenecut is enabled.<br><br>diff -r 303ff9e4546d -r ce128262e4e2 source/CMakeLists.txt<br>--- a/source/CMakeLists.txt Wed Apr 15 18:44:54 2020 +0530<br>+++ b/source/CMakeLists.txt Tue Apr 21 11:04:30 2020 +0530<br>@@ -29,7 +29,7 @@<br> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br> # X265_BUILD must be incremented each time the public API is changed<br>-set(X265_BUILD 191)<br>+set(X265_BUILD 192)<br></div></div></blockquote><div>[AM] Build number has changed now. Please rebase the patch on the tip and update X265_BUILD </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> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in" target="_blank">x265.def.in</a>"<br> "${PROJECT_BINARY_DIR}/x265.def")<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in" target="_blank">x265_config.h.in</a>"<br>diff -r 303ff9e4546d -r ce128262e4e2 source/encoder/encoder.cpp<br>--- a/source/encoder/encoder.cpp Wed Apr 15 18:44:54 2020 +0530<br>+++ b/source/encoder/encoder.cpp Tue Apr 21 11:04:30 2020 +0530<br>@@ -1448,22 +1448,29 @@<br> <br> pixel pixelVal;<br> int32_t *edgeHist = m_curEdgeHist;<br>- memset(edgeHist, 0, 2 * sizeof(int32_t));<br>- for (int64_t i = 0; i < m_planeSizes[0]; i++)<br>+ memset(edgeHist, 0, EDGE_BINS * sizeof(int32_t));<br>+ for (uint32_t i = 0; i < m_planeSizes[0]; i++)<br> {<br> if (!m_edgePic[i])<br> edgeHist[0]++;<br> else<br> edgeHist[1]++;<br> }<br>+ /* Y Histogram Calculation */<br>+ int32_t* yHist = m_curYUVHist[0];<br>+ memset(yHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>+ for (uint32_t i = 0; i < m_planeSizes[0]; i++)<br>+ {<br>+ pixelVal = src[i];<br>+ yHist[pixelVal]++;<br>+ }<br> <br> if (pic->colorSpace != X265_CSP_I400)<br> {<br> /* U Histogram Calculation */<br>- int32_t *uHist = m_curUVHist[0];<br>+ int32_t *uHist = m_curYUVHist[1];<br> memset(uHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>-<br>- for (int64_t i = 0; i < m_planeSizes[1]; i++)<br>+ for (uint32_t i = 0; i < m_planeSizes[1]; i++)<br> {<br> pixelVal = planeU[i];<br> uHist[pixelVal]++;<br>@@ -1473,10 +1480,9 @@<br> if (planeCount == 3)<br></div></div></blockquote><div>[AM] Please remove these incorrect plane checks though it is not introduced in your patch. </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> {<br> pixelVal = 0;<br>- int32_t *vHist = m_curUVHist[1];<br>+ int32_t *vHist = m_curYUVHist[2];<br> memset(vHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>-<br>- for (int64_t i = 0; i < m_planeSizes[2]; i++)<br>+ for (uint32_t i = 0; i < m_planeSizes[2]; i++)<br> {<br> pixelVal = planeV[i];<br> vHist[pixelVal]++;<br>@@ -1488,7 +1494,7 @@<br> }<br> else<br> { /* in case of bi planar color space */<br>- memcpy(m_curMaxUVHist, m_curUVHist[0], HISTOGRAM_BINS * sizeof(int32_t));<br>+ memcpy(m_curMaxUVHist, m_curYUVHist[1], HISTOGRAM_BINS * sizeof(int32_t));<br> }<br> }<br> return true;<br>@@ -1794,6 +1800,16 @@<br> {<br> inFrame->m_lowres.bScenecut = (inputPic->frameData.bScenecut == 1) ? true : false;<br> }<br>+ if (m_param->bHistBasedSceneCut && m_param->analysisSave)<br>+ {<br>+ memcpy(inFrame->m_analysisData.edgeHist, m_curEdgeHist, EDGE_BINS * sizeof(int32_t));<br>+ memcpy(inFrame->m_analysisData.yuvHist[0], m_curYUVHist[0], 1 * HISTOGRAM_BINS *sizeof(int32_t));<br>+ if (inputPic->colorSpace != X265_CSP_I400)<br>+ {<br>+ memcpy(inFrame->m_analysisData.yuvHist[1], m_curYUVHist[1], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ memcpy(inFrame->m_analysisData.yuvHist[2], m_curYUVHist[2], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ }<br>+ }<br> inFrame->m_forceqp = inputPic->forceqp;<br> inFrame->m_param = (m_reconfigure || m_reconfigureRc) ? m_latestParam : m_param;<br> inFrame->m_picStruct = inputPic->picStruct;<br>@@ -1999,6 +2015,16 @@<br> pic_out->analysisData.poc = pic_out->poc;<br> pic_out->analysisData.sliceType = pic_out->sliceType;<br> pic_out->analysisData.bScenecut = outFrame->m_lowres.bScenecut;<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ memcpy(pic_out->analysisData.edgeHist, outFrame->m_analysisData.edgeHist, EDGE_BINS * sizeof(int32_t));<br>+ memcpy(pic_out->analysisData.yuvHist[0], outFrame->m_analysisData.yuvHist[0], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ if (pic_out->colorSpace != X265_CSP_I400)<br>+ {<br>+ memcpy(pic_out->analysisData.yuvHist[1], outFrame->m_analysisData.yuvHist[1], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ memcpy(pic_out->analysisData.yuvHist[2], outFrame->m_analysisData.yuvHist[2], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ }<br>+ }<br> pic_out->analysisData.satdCost = outFrame->m_lowres.satdCost;<br> pic_out->analysisData.numCUsInFrame = outFrame->m_analysisData.numCUsInFrame;<br> pic_out->analysisData.numPartitions = outFrame->m_analysisData.numPartitions;<br>@@ -4312,6 +4338,16 @@<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>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FREAD(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);<br>+ X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);<br>+ X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);<br>+ }<br>+ }<br> X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileIn, &(picData->satdCost));<br> X265_FREAD(&numCUsLoad, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));<br> X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));<br>@@ -4634,6 +4670,16 @@<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>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FREAD(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);<br>+ X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);<br>+ X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);<br>+ }<br>+ }<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(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));<br>@@ -5399,6 +5445,17 @@<br> /* calculate frameRecordSize */<br> analysis->frameRecordSize = sizeof(analysis->frameRecordSize) + sizeof(depthBytes) + sizeof(analysis->poc) + sizeof(analysis->sliceType) +<br> sizeof(analysis->numCUsInFrame) + sizeof(analysis->numPartitions) + sizeof(analysis->bScenecut) + sizeof(analysis->satdCost);<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ analysis->frameRecordSize += sizeof(analysis->edgeHist);<br>+ analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;<br>+ analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;<br>+ }<br>+ }<br>+<br> if (analysis->sliceType > X265_TYPE_I)<br> {<br> numDir = (analysis->sliceType == X265_TYPE_P) ? 1 : 2;<br>@@ -5543,6 +5600,17 @@<br> X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->sliceType, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->bScenecut, sizeof(int), 1, m_analysisFileOut);<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FWRITE(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileOut);<br>+ X265_FWRITE(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FWRITE(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ X265_FWRITE(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ }<br>+ }<br>+<br> X265_FWRITE(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->numPartitions, sizeof(int), 1, m_analysisFileOut);<br>diff -r 303ff9e4546d -r ce128262e4e2 source/encoder/encoder.h<br>--- a/source/encoder/encoder.h Wed Apr 15 18:44:54 2020 +0530<br>+++ b/source/encoder/encoder.h Tue Apr 21 11:04:30 2020 +0530<br>@@ -256,7 +256,7 @@<br> /* For histogram based scene-cut detection */<br> pixel* m_edgePic;<br> pixel* m_inputPic[3];<br>- int32_t m_curUVHist[2][HISTOGRAM_BINS];<br>+ int32_t m_curYUVHist[3][HISTOGRAM_BINS];<br> int32_t m_curMaxUVHist[HISTOGRAM_BINS];<br> int32_t m_prevMaxUVHist[HISTOGRAM_BINS];<br> int32_t m_curEdgeHist[2];<br>diff -r 303ff9e4546d -r ce128262e4e2 source/x265.h<br>--- a/source/x265.h Wed Apr 15 18:44:54 2020 +0530<br>+++ b/source/x265.h Tue Apr 21 11:04:30 2020 +0530<br>@@ -204,6 +204,9 @@<br> }x265_analysis_distortion_data;<br> <br> #define MAX_NUM_REF 16<br>+#define EDGE_BINS 2<br>+#define MAX_HIST_BINS 1024<br></div></div></blockquote><div>[AM] Why 1024 bins even for 8-bit input? Can we instead allocate memory dynamically in x265_alloc_analysis_data()? </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>+<br> /* Stores all analysis data for a single frame */<br> typedef struct x265_analysis_data<br> {<br>@@ -214,6 +217,8 @@<br> uint32_t numCUsInFrame;<br> uint32_t numPartitions;<br> uint32_t depthBytes;<br>+ int32_t edgeHist[EDGE_BINS];<br>+ int32_t yuvHist[3][MAX_HIST_BINS];<br> int bScenecut;<br> x265_weight_param* wt;<br> x265_analysis_inter_data* interData;<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 30, 2020 at 7:58 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 Wed, Apr 29, 2020 at 1:08 PM Soundariya Ranin Venkatesh <<a href="mailto:soundariya@multicorewareinc.com" target="_blank">soundariya@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">Please ignore the previous mail.<div><br><div># HG changeset patch<br># User Soundariya <<a href="mailto:soundariya@multicorewareinc.com" target="_blank">soundariya@multicorewareinc.com</a>><br># Date 1587447270 -19800<br># Tue Apr 21 11:04:30 2020 +0530<br># Node ID dee5b22792169e885a50c110dfff93dedb709369<br># Parent 6bb2d88029c2e13fa13b5b053aa725d4fa84a084<br>Store histogram of Y, U, V and Y's edge in analysis file.<br><br>Enables the application to compute Y Histogram and store Histogram of Y, U, V Channel<br>and Y's Edge in analysis file at all reuse levels when --hist-scenecut is enabled.<br><br></div></div></div></blockquote><div>[AM] The patch fails to apply cleanly on the tip. </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><div><br>diff -r 6bb2d88029c2 -r dee5b2279216 source/CMakeLists.txt<br>--- a/source/CMakeLists.txt Thu Apr 09 13:09:15 2020 +0530<br>+++ b/source/CMakeLists.txt Tue Apr 21 11:04:30 2020 +0530<br>@@ -29,7 +29,7 @@<br> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br> # X265_BUILD must be incremented each time the public API is changed<br>-set(X265_BUILD 191)<br>+set(X265_BUILD 192)<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in" target="_blank">x265.def.in</a>"<br> "${PROJECT_BINARY_DIR}/x265.def")<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in" target="_blank">x265_config.h.in</a>"<br>diff -r 6bb2d88029c2 -r dee5b2279216 source/abrEncApp.cpp<br>--- a/source/abrEncApp.cpp Thu Apr 09 13:09:15 2020 +0530<br>+++ b/source/abrEncApp.cpp Tue Apr 21 11:04:30 2020 +0530<br>@@ -542,7 +542,7 @@<br> pic->pts = srcPic->pts;<br> pic->dts = srcPic->dts;<br> pic->reorderedPts = srcPic->reorderedPts;<br>- pic->poc = srcPic->poc;<br>+ pic->width = srcPic->width;<br> pic->analysisData = srcPic->analysisData;<br> pic->userSEI = srcPic->userSEI;<br> pic->stride[0] = srcPic->stride[0];<br>diff -r 6bb2d88029c2 -r dee5b2279216 source/common/common.h<br>--- a/source/common/common.h Thu Apr 09 13:09:15 2020 +0530<br>+++ b/source/common/common.h Tue Apr 21 11:04:30 2020 +0530<br>@@ -130,7 +130,6 @@<br> typedef uint64_t pixel4;<br> typedef int64_t ssum2_t;<br> #define SHIFT_TO_BITPLANE 9<br>-#define HISTOGRAM_BINS 1024<br> #else<br> typedef uint8_t pixel;<br> typedef uint16_t sum_t;<br>@@ -138,7 +137,6 @@<br> typedef uint32_t pixel4;<br> typedef int32_t ssum2_t; // Signed sum<br> #define SHIFT_TO_BITPLANE 7<br>-#define HISTOGRAM_BINS 256<br> #endif // if HIGH_BIT_DEPTH<br> <br> #if X265_DEPTH < 10<br>diff -r 6bb2d88029c2 -r dee5b2279216 source/encoder/encoder.cpp<br>--- a/source/encoder/encoder.cpp Thu Apr 09 13:09:15 2020 +0530<br>+++ b/source/encoder/encoder.cpp Tue Apr 21 11:04:30 2020 +0530<br>@@ -1448,22 +1448,29 @@<br> <br> pixel pixelVal;<br> int32_t *edgeHist = m_curEdgeHist;<br>- memset(edgeHist, 0, 2 * sizeof(int32_t));<br>- for (int64_t i = 0; i < m_planeSizes[0]; i++)<br>+ memset(edgeHist, 0, EDGE_BINS * sizeof(int32_t));<br>+ for (uint32_t i = 0; i < m_planeSizes[0]; i++)<br> {<br> if (!m_edgePic[i])<br> edgeHist[0]++;<br> else<br> edgeHist[1]++;<br> }<br>+ /* Y Histogram Calculation */<br>+ int32_t* yHist = m_curYUVHist[0];<br>+ memset(yHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>+ for (uint32_t i = 0; i < m_planeSizes[0]; i++)<br>+ {<br>+ pixelVal = src[i];<br>+ yHist[pixelVal]++;<br>+ }<br> <br> if (pic->colorSpace != X265_CSP_I400)<br> {<br> /* U Histogram Calculation */<br>- int32_t *uHist = m_curUVHist[0];<br>+ int32_t *uHist = m_curYUVHist[1];<br> memset(uHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>-<br>- for (int64_t i = 0; i < m_planeSizes[1]; i++)<br>+ for (uint32_t i = 0; i < m_planeSizes[1]; i++)<br> {<br> pixelVal = planeU[i];<br> uHist[pixelVal]++;<br>@@ -1473,10 +1480,9 @@<br> if (planeCount == 3)<br> { </div></div></div></blockquote><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><div> pixelVal = 0;<br>- int32_t *vHist = m_curUVHist[1];<br>+ int32_t *vHist = m_curYUVHist[2];<br> memset(vHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>-<br>- for (int64_t i = 0; i < m_planeSizes[2]; i++)<br>+ for (uint32_t i = 0; i < m_planeSizes[2]; i++)<br> {<br> pixelVal = planeV[i];<br> vHist[pixelVal]++;<br>@@ -1488,7 +1494,7 @@<br> }<br> else<br> { /* in case of bi planar color space */<br>- memcpy(m_curMaxUVHist, m_curUVHist[0], HISTOGRAM_BINS * sizeof(int32_t));<br>+ memcpy(m_curMaxUVHist, m_curYUVHist[1], HISTOGRAM_BINS * sizeof(int32_t));<br> }<br> }<br> return true;<br>@@ -1794,6 +1800,18 @@<br> {<br> inFrame->m_lowres.bScenecut = (inputPic->frameData.bScenecut == 1) ? true : false;<br> }<br>+ if (m_param->bHistBasedSceneCut && m_param->analysisSave)<br>+ {<br>+ memcpy(inFrame->m_analysisData.edgeHist, m_curEdgeHist, EDGE_BINS * sizeof(int32_t));<br>+ memcpy(inFrame->m_analysisData.yuvHist[0], m_curYUVHist[0], 1 * HISTOGRAM_BINS *sizeof(int32_t));<br>+ if (inputPic->colorSpace != X265_CSP_I400)<br>+ {<br>+ memcpy(inFrame->m_analysisData.yuvHist[1], m_curYUVHist[1], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br></div></div></div></blockquote><div>[AM] This check is incorrect. Even bi-planar frames have U and V streams.</div><div>Please remove this check everywhere. </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><div>+ memcpy(inFrame->m_analysisData.yuvHist[2], m_curYUVHist[2], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ }<br>+ }<br> inFrame->m_forceqp = inputPic->forceqp;<br> inFrame->m_param = (m_reconfigure || m_reconfigureRc) ? m_latestParam : m_param;<br> inFrame->m_picStruct = inputPic->picStruct;<br>@@ -1999,6 +2017,18 @@<br> pic_out->analysisData.poc = pic_out->poc;<br> pic_out->analysisData.sliceType = pic_out->sliceType;<br> pic_out->analysisData.bScenecut = outFrame->m_lowres.bScenecut;<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ memcpy(pic_out->analysisData.edgeHist, outFrame->m_analysisData.edgeHist, EDGE_BINS * sizeof(int32_t));<br>+ memcpy(pic_out->analysisData.yuvHist[0], outFrame->m_analysisData.yuvHist[0], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ if (pic_out->colorSpace != X265_CSP_I400)<br>+ {<br>+ memcpy(pic_out->analysisData.yuvHist[1], outFrame->m_analysisData.yuvHist[1], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ memcpy(pic_out->analysisData.yuvHist[2], outFrame->m_analysisData.yuvHist[2], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ }<br>+ }<br> pic_out->analysisData.satdCost = outFrame->m_lowres.satdCost;<br> pic_out->analysisData.numCUsInFrame = outFrame->m_analysisData.numCUsInFrame;<br> pic_out->analysisData.numPartitions = outFrame->m_analysisData.numPartitions;<br>@@ -4312,6 +4342,20 @@<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>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FREAD(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);<br>+ X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ {<br>+ X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);<br>+ }<br>+ }<br>+ }<br> X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileIn, &(picData->satdCost));<br> X265_FREAD(&numCUsLoad, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));<br> X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));<br>@@ -4634,6 +4678,20 @@<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>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FREAD(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);<br>+ X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ {<br>+ X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);<br>+ }<br>+ }<br>+ }<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(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));<br>@@ -5398,6 +5456,19 @@<br> /* calculate frameRecordSize */<br> analysis->frameRecordSize = sizeof(analysis->frameRecordSize) + sizeof(depthBytes) + sizeof(analysis->poc) + sizeof(analysis->sliceType) +<br> sizeof(analysis->numCUsInFrame) + sizeof(analysis->numPartitions) + sizeof(analysis->bScenecut) + sizeof(analysis->satdCost);<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ analysis->frameRecordSize += sizeof(analysis->edgeHist);<br>+ analysis->frameRecordSize += sizeof(analysis->yuvHist[0]);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ analysis->frameRecordSize += sizeof(analysis->yuvHist[1]);<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ analysis->frameRecordSize += sizeof(analysis->yuvHist[2]);<br>+ }<br>+ }<br>+<br> if (analysis->sliceType > X265_TYPE_I)<br> {<br> numDir = (analysis->sliceType == X265_TYPE_P) ? 1 : 2;<br>@@ -5542,6 +5613,19 @@<br> X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->sliceType, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->bScenecut, sizeof(int), 1, m_analysisFileOut);<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FWRITE(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileOut);<br>+ X265_FWRITE(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FWRITE(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ X265_FWRITE(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ }<br>+ }<br>+<br> X265_FWRITE(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->numPartitions, sizeof(int), 1, m_analysisFileOut);<br>diff -r 6bb2d88029c2 -r dee5b2279216 source/encoder/encoder.h<br>--- a/source/encoder/encoder.h Thu Apr 09 13:09:15 2020 +0530<br>+++ b/source/encoder/encoder.h Tue Apr 21 11:04:30 2020 +0530<br>@@ -256,7 +256,7 @@<br> /* For histogram based scene-cut detection */<br> pixel* m_edgePic;<br> pixel* m_inputPic[3];<br>- int32_t m_curUVHist[2][HISTOGRAM_BINS];<br>+ int32_t m_curYUVHist[3][HISTOGRAM_BINS];<br> int32_t m_curMaxUVHist[HISTOGRAM_BINS];<br> int32_t m_prevMaxUVHist[HISTOGRAM_BINS];<br> int32_t m_curEdgeHist[2];<br>diff -r 6bb2d88029c2 -r dee5b2279216 source/x265.h<br>--- a/source/x265.h Thu Apr 09 13:09:15 2020 +0530<br>+++ b/source/x265.h Tue Apr 21 11:04:30 2020 +0530<br>@@ -203,6 +203,13 @@<br> }x265_analysis_distortion_data;<br> <br> #define MAX_NUM_REF 16<br>+#define EDGE_BINS 2<br>+#if HIGH_BIT_DEPTH<br>+ #define HISTOGRAM_BINS 1024<br>+#else<br>+ #define HISTOGRAM_BINS 256<br>+#endif<br>+<br></div></div></div></blockquote><div>[AM] Having build-depth based operations in application won't work for multi-lib builds. I see a crash with this patch in multi-lib builds if the input and output depths are different.</div><div>Please check that and fix 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><div> /* Stores all analysis data for a single frame */<br> typedef struct x265_analysis_data<br> {<br>@@ -213,6 +220,8 @@<br> uint32_t numCUsInFrame;<br> uint32_t numPartitions;<br> uint32_t depthBytes;<br>+ int32_t edgeHist[EDGE_BINS];<br>+ int32_t yuvHist[3][HISTOGRAM_BINS];<br> int bScenecut;<br> x265_weight_param* wt;<br> x265_analysis_inter_data* interData;<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 28, 2020 at 4:26 PM Soundariya Ranin Venkatesh <<a href="mailto:soundariya@multicorewareinc.com" target="_blank">soundariya@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"># HG changeset patch<br># User Soundariya <<a href="mailto:soundariya@multicorewareinc.com" target="_blank">soundariya@multicorewareinc.com</a>><br># Date 1587447270 -19800<br># Tue Apr 21 11:04:30 2020 +0530<br># Node ID 07fa08c180a7469419fce9d1542fdf004a32ff7e<br># Parent c6d2ee54761a878efa956b3ccbbaeb56ef8ac5c9<br>Store histogram of Y, U, V and Y's edge in analysis file.<br><br>Enables the application to compute Y Histogram and store Histogram of Y, U, V Channel<br>and Y's Edge in analysis file at all reuse levels when --hist-scenecut is enabled.<br><br>diff -r c6d2ee54761a -r 07fa08c180a7 source/CMakeLists.txt<br>--- a/source/CMakeLists.txt Tue Apr 28 13:51:40 2020 +0530<br>+++ b/source/CMakeLists.txt Tue Apr 21 11:04:30 2020 +0530<br>@@ -29,7 +29,7 @@<br> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br> # X265_BUILD must be incremented each time the public API is changed<br>-set(X265_BUILD 191)<br>+set(X265_BUILD 192)<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in" target="_blank">x265.def.in</a>"<br> "${PROJECT_BINARY_DIR}/x265.def")<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in" target="_blank">x265_config.h.in</a>"<br>diff -r c6d2ee54761a -r 07fa08c180a7 source/common/common.h<br>--- a/source/common/common.h Tue Apr 28 13:51:40 2020 +0530<br>+++ b/source/common/common.h Tue Apr 21 11:04:30 2020 +0530<br>@@ -130,7 +130,6 @@<br> typedef uint64_t pixel4;<br> typedef int64_t ssum2_t;<br> #define SHIFT_TO_BITPLANE 9<br>-#define HISTOGRAM_BINS 1024<br> #else<br> typedef uint8_t pixel;<br> typedef uint16_t sum_t;<br>@@ -138,7 +137,6 @@<br> typedef uint32_t pixel4;<br> typedef int32_t ssum2_t; // Signed sum<br> #define SHIFT_TO_BITPLANE 7<br>-#define HISTOGRAM_BINS 256<br> #endif // if HIGH_BIT_DEPTH<br> <br> #if X265_DEPTH < 10<br>diff -r c6d2ee54761a -r 07fa08c180a7 source/encoder/encoder.cpp<br>--- a/source/encoder/encoder.cpp Tue Apr 28 13:51:40 2020 +0530<br>+++ b/source/encoder/encoder.cpp Tue Apr 21 11:04:30 2020 +0530<br>@@ -1448,7 +1448,7 @@<br> <br> pixel pixelVal;<br> int32_t *edgeHist = m_curEdgeHist;<br>- memset(edgeHist, 0, 2 * sizeof(int32_t));<br>+ memset(edgeHist, 0, EDGE_BINS * sizeof(int32_t));<br> for (int64_t i = 0; i < m_planeSizes[0]; i++)<br> {<br> if (!m_edgePic[i])<br>@@ -1456,13 +1456,20 @@<br> else<br> edgeHist[1]++;<br> }<br>+ /* Y Histogram Calculation */<br>+ int32_t* yHist = m_curYUVHist[0];<br>+ memset(yHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>+ for (int64_t i = 0; i < m_planeSizes[0]; i++)<br>+ {<br>+ pixelVal = src[i];<br>+ yHist[pixelVal]++;<br>+ }<br> <br> if (pic->colorSpace != X265_CSP_I400)<br> {<br> /* U Histogram Calculation */<br>- int32_t *uHist = m_curUVHist[0];<br>+ int32_t *uHist = m_curYUVHist[1];<br> memset(uHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>-<br> for (int64_t i = 0; i < m_planeSizes[1]; i++)<br> {<br> pixelVal = planeU[i];<br>@@ -1473,9 +1480,8 @@<br> if (planeCount == 3)<br> {<br> pixelVal = 0;<br>- int32_t *vHist = m_curUVHist[1];<br>+ int32_t *vHist = m_curYUVHist[2];<br> memset(vHist, 0, HISTOGRAM_BINS * sizeof(int32_t));<br>-<br> for (int64_t i = 0; i < m_planeSizes[2]; i++)<br> {<br> pixelVal = planeV[i];<br>@@ -1488,7 +1494,7 @@<br> }<br> else<br> { /* in case of bi planar color space */<br>- memcpy(m_curMaxUVHist, m_curUVHist[0], HISTOGRAM_BINS * sizeof(int32_t));<br>+ memcpy(m_curMaxUVHist, m_curYUVHist[1], HISTOGRAM_BINS * sizeof(int32_t));<br> }<br> }<br> return true;<br>@@ -1794,6 +1800,18 @@<br> {<br> inFrame->m_lowres.bScenecut = (inputPic->frameData.bScenecut == 1) ? true : false;<br> }<br>+ if (m_param->bHistBasedSceneCut && m_param->analysisSave)<br>+ {<br>+ memcpy(inFrame->m_analysisData.edgeHist, m_curEdgeHist, EDGE_BINS * sizeof(int32_t));<br>+ memcpy(inFrame->m_analysisData.yuvHist[0], m_curYUVHist[0], 1 * HISTOGRAM_BINS *sizeof(int32_t));<br>+ if (inputPic->colorSpace != X265_CSP_I400)<br>+ {<br>+ memcpy(inFrame->m_analysisData.yuvHist[1], m_curYUVHist[1], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if(planeCount == 3)<br>+ memcpy(inFrame->m_analysisData.yuvHist[2], m_curYUVHist[2], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ }<br>+ }<br> inFrame->m_forceqp = inputPic->forceqp;<br> inFrame->m_param = (m_reconfigure || m_reconfigureRc) ? m_latestParam : m_param;<br> inFrame->m_picStruct = inputPic->picStruct;<br>@@ -1999,6 +2017,18 @@<br> pic_out->analysisData.poc = pic_out->poc;<br> pic_out->analysisData.sliceType = pic_out->sliceType;<br> pic_out->analysisData.bScenecut = outFrame->m_lowres.bScenecut;<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ memcpy(pic_out->analysisData.edgeHist, outFrame->m_analysisData.edgeHist, EDGE_BINS * sizeof(int32_t));<br>+ memcpy(pic_out->analysisData.yuvHist[0], outFrame->m_analysisData.yuvHist[0], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ if (pic_out->colorSpace != X265_CSP_I400)<br>+ {<br>+ memcpy(pic_out->analysisData.yuvHist[1], outFrame->m_analysisData.yuvHist[1], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ memcpy(pic_out->analysisData.yuvHist[2], outFrame->m_analysisData.yuvHist[2], 1 * HISTOGRAM_BINS * sizeof(int32_t));<br>+ }<br>+ }<br> pic_out->analysisData.satdCost = outFrame->m_lowres.satdCost;<br> pic_out->analysisData.numCUsInFrame = outFrame->m_analysisData.numCUsInFrame;<br> pic_out->analysisData.numPartitions = outFrame->m_analysisData.numPartitions;<br>@@ -4312,6 +4342,18 @@<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>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FREAD(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);<br>+ X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);<br>+ }<br>+ }<br> X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileIn, &(picData->satdCost));<br> X265_FREAD(&numCUsLoad, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));<br> X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));<br>@@ -4634,6 +4676,18 @@<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>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FREAD(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);<br>+ X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);<br>+ }<br>+ }<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(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));<br>@@ -5398,6 +5452,19 @@<br> /* calculate frameRecordSize */<br> analysis->frameRecordSize = sizeof(analysis->frameRecordSize) + sizeof(depthBytes) + sizeof(analysis->poc) + sizeof(analysis->sliceType) +<br> sizeof(analysis->numCUsInFrame) + sizeof(analysis->numPartitions) + sizeof(analysis->bScenecut) + sizeof(analysis->satdCost);<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ analysis->frameRecordSize += sizeof(analysis->edgeHist);<br>+ analysis->frameRecordSize += sizeof(analysis->yuvHist[0]);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ analysis->frameRecordSize += sizeof(analysis->yuvHist[1]);<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ analysis->frameRecordSize += sizeof(analysis->yuvHist[2]);<br>+ }<br>+ }<br>+<br> if (analysis->sliceType > X265_TYPE_I)<br> {<br> numDir = (analysis->sliceType == X265_TYPE_P) ? 1 : 2;<br>@@ -5542,6 +5609,19 @@<br> X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->sliceType, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->bScenecut, sizeof(int), 1, m_analysisFileOut);<br>+ if (m_param->bHistBasedSceneCut)<br>+ {<br>+ X265_FWRITE(&analysis->edgeHist, sizeof(int32_t), 1 * EDGE_BINS, m_analysisFileOut);<br>+ X265_FWRITE(&analysis->yuvHist[0], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ if (m_param->internalCsp != X265_CSP_I400)<br>+ {<br>+ X265_FWRITE(&analysis->yuvHist[1], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;<br>+ if (planeCount == 3)<br>+ X265_FWRITE(&analysis->yuvHist[2], sizeof(int32_t), 1 * HISTOGRAM_BINS, m_analysisFileOut);<br>+ }<br>+ }<br>+<br> X265_FWRITE(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFileOut);<br> X265_FWRITE(&analysis->numPartitions, sizeof(int), 1, m_analysisFileOut);<br>diff -r c6d2ee54761a -r 07fa08c180a7 source/encoder/encoder.h<br>--- a/source/encoder/encoder.h Tue Apr 28 13:51:40 2020 +0530<br>+++ b/source/encoder/encoder.h Tue Apr 21 11:04:30 2020 +0530<br>@@ -256,7 +256,7 @@<br> /* For histogram based scene-cut detection */<br> pixel* m_edgePic;<br> pixel* m_inputPic[3];<br>- int32_t m_curUVHist[2][HISTOGRAM_BINS];<br>+ int32_t m_curYUVHist[3][HISTOGRAM_BINS];<br> int32_t m_curMaxUVHist[HISTOGRAM_BINS];<br> int32_t m_prevMaxUVHist[HISTOGRAM_BINS];<br> int32_t m_curEdgeHist[2];<br>diff -r c6d2ee54761a -r 07fa08c180a7 source/x265.h<br>--- a/source/x265.h Tue Apr 28 13:51:40 2020 +0530<br>+++ b/source/x265.h Tue Apr 21 11:04:30 2020 +0530<br>@@ -203,6 +203,13 @@<br> }x265_analysis_distortion_data;<br> <br> #define MAX_NUM_REF 16<br>+#define EDGE_BINS 2<br>+#if HIGH_BIT_DEPTH<br>+ #define HISTOGRAM_BINS 1024<br>+#else<br>+ #define HISTOGRAM_BINS 256<br>+#endif<br>+<br> /* Stores all analysis data for a single frame */<br> typedef struct x265_analysis_data<br> {<br>@@ -213,6 +220,8 @@<br> uint32_t numCUsInFrame;<br> uint32_t numPartitions;<br> uint32_t depthBytes;<br>+ int32_t edgeHist[2];<br>+ int32_t yuvHist[3][HISTOGRAM_BINS];<br> int bScenecut;<br> x265_weight_param* wt;<br> x265_analysis_inter_data* interData;<br><div><br></div>-- <br><div dir="ltr"><div dir="ltr">Thanks & Regards,<div>Soundariya</div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr">Thanks & Regards,<div>Soundariya</div></div></div>
</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>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr">Thanks & Regards,<div>Soundariya</div></div></div>
</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>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr">Thanks & Regards,<div>Soundariya</div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><b style="background-color:rgb(255,255,255)"><font color="#0b5394">With Regards,</font></b><div><b style="background-color:rgb(255,255,255)"><font color="#0b5394">Srikanth Kurapati.</font></b></div></div></div>