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