<div dir="ltr">Please omit the patch series. I am resending them with a sign-off.<div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><i><font face="georgia, serif">Thanks and Regards,</font></i></div><div><i><b><font face="georgia, serif">Snehaa.G</font></b></i></div></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 2, 2022 at 1:47 PM Snehaa Giridharan <<a href="mailto:snehaa@multicorewareinc.com">snehaa@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"><div>From f95697a7dac4f59581ec1fe0bbb2e7ff32722889 Mon Sep 17 00:00:00 2001</div><div>From: ashok2022 <<a href="mailto:ashok@multicorewareinc.com" target="_blank">ashok@multicorewareinc.com</a>></div><div>Date: Fri, 21 Oct 2022 20:31:57 +0530</div><div>Subject: [PATCH] Remove existing histogram based scene change algorithm</div><div><br></div><div>---</div><div> doc/reST/cli.rst | 20 +-</div><div> source/common/common.h | 2 -</div><div> source/common/frame.cpp | 2 -</div><div> source/common/lowres.cpp | 6 +-</div><div> source/common/lowres.h | 9 +-</div><div> source/common/param.cpp | 33 +--</div><div> source/encoder/encoder.cpp | 405 +-------------------------------</div><div> source/encoder/encoder.h | 18 --</div><div> source/encoder/frameencoder.cpp | 2 +-</div><div> source/encoder/slicetype.cpp | 97 ++------</div><div> source/encoder/slicetype.h | 3 +-</div><div> source/x265.h | 10 -</div><div> source/x265cli.cpp | 1 -</div><div> source/x265cli.h | 3 -</div><div> 14 files changed, 34 insertions(+), 577 deletions(-)</div><div><br></div><div>diff --git a/doc/reST/cli.rst b/doc/reST/cli.rst</div><div>index 9fa12fa92..2437a09da 100755</div><div>--- a/doc/reST/cli.rst</div><div>+++ b/doc/reST/cli.rst</div><div>@@ -1474,24 +1474,10 @@ Slice decision options</div><div> </div><div> .. option:: --hist-scenecut, --no-hist-scenecut</div><div> </div><div>-<span style="white-space:pre-wrap"> </span>Indicates that scenecuts need to be detected using luma edge and chroma histograms.</div><div>-<span style="white-space:pre-wrap"> </span>:option:`--hist-scenecut` enables scenecut detection using the histograms.</div><div>-<span style="white-space:pre-wrap"> </span>It also uses the intra and inter cost info to arrive at a scenecut decision from the default scenecut method.</div><div>-<span style="white-space:pre-wrap"> </span>:option:`--no-hist-scenecut` disables histogram based scenecut algorithm.</div><div>+<span style="white-space:pre-wrap"> </span>Scenecuts detected based on histogram, intensity and variance of the picture.</div><div>+<span style="white-space:pre-wrap"> </span>:option:`--hist-scenecut` enables or :option:`--no-hist-scenecut` disables scenecut detection based on</div><div>+<span style="white-space:pre-wrap"> </span>histogram.</div><div> <span style="white-space:pre-wrap"> </span></div><div>-.. option:: --hist-threshold <0.0..1.0></div><div>-</div><div>-<span style="white-space:pre-wrap"> </span>This value represents the threshold for normalized SAD of edge histograms used in scenecut detection.</div><div>-<span style="white-space:pre-wrap"> </span>This requires :option:`--hist-scenecut` to be enabled. For example, a value of 0.2 indicates that a frame with normalized SAD value </div><div>-<span style="white-space:pre-wrap"> </span>greater than 0.2 against the previous frame as scenecut. </div><div>-<span style="white-space:pre-wrap"> </span>Increasing the threshold reduces the number of scenecuts detected.</div><div>-<span style="white-space:pre-wrap"> </span>Default 0.03.</div><div>-</div><div>-.. option:: --traditional-scenecut, --no-traditional-scenecut</div><div>-</div><div>-<span style="white-space:pre-wrap"> </span>Enable traditional scenecut detection using intra and inter cost when :option:`--hist-scenecut` is used.</div><div>-<span style="white-space:pre-wrap"> </span>Default enabled.</div><div>-</div><div> .. option:: --radl <integer></div><div> <span style="white-space:pre-wrap"> </span></div><div> <span style="white-space:pre-wrap"> </span>Number of RADL pictures allowed infront of IDR. Requires closed gop interval.</div><div>diff --git a/source/common/common.h b/source/common/common.h</div><div>index fad2229e7..7212f3496 100644</div><div>--- a/source/common/common.h</div><div>+++ b/source/common/common.h</div><div>@@ -130,7 +130,6 @@ typedef uint64_t sum2_t;</div><div> typedef uint64_t pixel4;</div><div> typedef int64_t ssum2_t;</div><div> #define SHIFT_TO_BITPLANE 9</div><div>-#define HISTOGRAM_BINS 1024</div><div> #define BRIGHTNESS_THRESHOLD 120 // The threshold above which a pixel is bright</div><div> #else</div><div> typedef uint8_t pixel;</div><div>@@ -139,7 +138,6 @@ typedef uint32_t sum2_t;</div><div> typedef uint32_t pixel4;</div><div> typedef int32_t ssum2_t; // Signed sum</div><div> #define SHIFT_TO_BITPLANE 7</div><div>-#define HISTOGRAM_BINS 256</div><div> #define BRIGHTNESS_THRESHOLD 30 // The threshold above which a pixel is bright</div><div> #endif // if HIGH_BIT_DEPTH</div><div> </div><div>diff --git a/source/common/frame.cpp b/source/common/frame.cpp</div><div>index e1bdc39b6..f51270bf0 100644</div><div>--- a/source/common/frame.cpp</div><div>+++ b/source/common/frame.cpp</div><div>@@ -181,8 +181,6 @@ fail:</div><div> bool Frame::createSubSample()</div><div> {</div><div> </div><div>- //m_param = param;</div><div>-</div><div> m_fencPicSubsampled2 = new PicYuv;</div><div> m_fencPicSubsampled4 = new PicYuv;</div><div> </div><div>diff --git a/source/common/lowres.cpp b/source/common/lowres.cpp</div><div>index 5e7718e7e..56b98b364 100644</div><div>--- a/source/common/lowres.cpp</div><div>+++ b/source/common/lowres.cpp</div><div>@@ -238,7 +238,7 @@ void Lowres::destroy()</div><div> X265_FREE(edgeInclined);</div><div> X265_FREE(qpAqMotionOffset);</div><div> X265_FREE(blockVariance);</div><div>- X265_FREE(lowresEdgePlane);</div><div>+</div><div> if (maxAQDepth > 0)</div><div> {</div><div> for (uint32_t d = 0; d < 4; d++)</div><div>@@ -270,10 +270,6 @@ void Lowres::init(PicYuv *origPic, int poc)</div><div> indB = 0;</div><div> memset(costEst, -1, sizeof(costEst));</div><div> memset(weightedCostDelta, 0, sizeof(weightedCostDelta));</div><div>- interPCostPercDiff = 0.0;</div><div>- intraCostPercDiff = 0.0;</div><div>- m_bIsMaxThres = false;</div><div>- m_bIsHardScenecut = false;</div><div> </div><div> if (qpAqOffset && invQscaleFactor)</div><div> memset(costEstAq, -1, sizeof(costEstAq));</div><div>diff --git a/source/common/lowres.h b/source/common/lowres.h</div><div>index 03d713edb..8adb93a81 100644</div><div>--- a/source/common/lowres.h</div><div>+++ b/source/common/lowres.h</div><div>@@ -217,13 +217,13 @@ struct Lowres : public ReferencePlanes</div><div> double* qpAqOffset; // AQ QP offset values for each 16x16 CU</div><div> double* qpCuTreeOffset; // cuTree QP offset values for each 16x16 CU</div><div> double* qpAqMotionOffset;</div><div>- int* invQscaleFactor; // qScale values for qp Aq Offsets</div><div>+ int* invQscaleFactor; // qScale values for qp Aq Offsets</div><div> int* invQscaleFactor8x8; // temporary buffer for qg-size 8</div><div> uint32_t* blockVariance;</div><div> uint64_t wp_ssd[3]; // This is different than SSDY, this is sum(pixel^2) - sum(pixel)^2 for entire frame</div><div> uint64_t wp_sum[3];</div><div> double frameVariance;</div><div>- int* edgeInclined;</div><div>+ int* edgeInclined;</div><div> </div><div> </div><div> /* cutree intermediate data */</div><div>@@ -237,11 +237,6 @@ struct Lowres : public ReferencePlanes</div><div> uint16_t* propagateCost;</div><div> double weightedCostDelta[X265_BFRAME_MAX + 2];</div><div> ReferencePlanes weightedRef[X265_BFRAME_MAX + 2];</div><div>- /* For hist-based scenecut */</div><div>- bool m_bIsMaxThres;</div><div>- double interPCostPercDiff;</div><div>- double intraCostPercDiff;</div><div>- bool m_bIsHardScenecut;</div><div> </div><div> bool create(x265_param* param, PicYuv *origPic, uint32_t qgSize);</div><div> void destroy();</div><div>diff --git a/source/common/param.cpp b/source/common/param.cpp</div><div>index 00fe84900..5de4361af 100755</div><div>--- a/source/common/param.cpp</div><div>+++ b/source/common/param.cpp</div><div>@@ -170,9 +170,7 @@ void x265_param_default(x265_param* param)</div><div> param->bFrameAdaptive = X265_B_ADAPT_TRELLIS;</div><div> param->bBPyramid = 1;</div><div> param->scenecutThreshold = 40; /* Magic number pulled in from x264 */</div><div>- param->edgeTransitionThreshold = 0.03;</div><div> param->bHistBasedSceneCut = 0;</div><div>- param->bEnableTradScdInHscd = 1;</div><div> param->lookaheadSlices = 8;</div><div> param->lookaheadThreads = 0;</div><div> param->scenecutBias = 5.0;</div><div>@@ -609,7 +607,6 @@ int x265_param_default_preset(x265_param* param, const char* preset, const char*</div><div> param->lookaheadDepth = 0;</div><div> param->scenecutThreshold = 0;</div><div> param->bHistBasedSceneCut = 0;</div><div>- param->bEnableTradScdInHscd = 1;</div><div> param->rc.cuTree = 0;</div><div> param->frameNumThreads = 1;</div><div> }</div><div>@@ -964,8 +961,6 @@ int x265_param_parse(x265_param* p, const char* name, const char* value)</div><div> {</div><div> bError = false;</div><div> p->scenecutThreshold = atoi(value);</div><div>- p->bHistBasedSceneCut = 0;</div><div>- p->bEnableTradScdInHscd = 1;</div><div> }</div><div> }</div><div> OPT("temporal-layers") p->bEnableTemporalSubLayers = atobool(value);</div><div>@@ -1233,22 +1228,7 @@ int x265_param_parse(x265_param* p, const char* name, const char* value)</div><div> OPT("opt-ref-list-length-pps") p->bOptRefListLengthPPS = atobool(value);</div><div> OPT("multi-pass-opt-rps") p->bMultiPassOptRPS = atobool(value);</div><div> OPT("scenecut-bias") p->scenecutBias = atof(value);</div><div>- OPT("hist-scenecut")</div><div>- {</div><div>- p->bHistBasedSceneCut = atobool(value);</div><div>- if (bError)</div><div>- {</div><div>- bError = false;</div><div>- p->bHistBasedSceneCut = 0;</div><div>- }</div><div>- if (p->bHistBasedSceneCut)</div><div>- {</div><div>- bError = false;</div><div>- p->scenecutThreshold = 0;</div><div>- }</div><div>- }</div><div>- OPT("hist-threshold") p->edgeTransitionThreshold = atof(value);</div><div>- OPT("traditional-scenecut") p->bEnableTradScdInHscd = atobool(value);</div><div>+ OPT("hist-scenecut") p->bHistBasedSceneCut = atobool(value);</div><div> OPT("rskip-edge-threshold") p->edgeVarThreshold = atoi(value)/100.0f;</div><div> OPT("lookahead-threads") p->lookaheadThreads = atoi(value);</div><div> OPT("opt-cu-delta-qp") p->bOptCUDeltaQP = atobool(value);</div><div>@@ -1786,8 +1766,6 @@ int x265_check_params(x265_param* param)</div><div> "scenecutThreshold must be greater than 0");</div><div> CHECK(param->scenecutBias < 0 || 100 < param->scenecutBias,</div><div> "scenecut-bias must be between 0 and 100");</div><div>- CHECK(param->edgeTransitionThreshold < 0.0 || 1.0 < param->edgeTransitionThreshold,</div><div>- "hist-threshold must be between 0.0 and 1.0");</div><div> CHECK(param->radl < 0 || param->radl > param->bframes,</div><div> "radl must be between 0 and bframes");</div><div> CHECK(param->rdPenalty < 0 || param->rdPenalty > 2,</div><div>@@ -2001,8 +1979,8 @@ void x265_print_params(x265_param* param)</div><div> x265_log(param, X265_LOG_INFO, "Keyframe min / max / scenecut / bias : %d / %d / %d / %.2lf \n",</div><div> param->keyframeMin, param->keyframeMax, param->scenecutThreshold, param->scenecutBias * 100);</div><div> else if (param->bHistBasedSceneCut && param->keyframeMax != INT_MAX) </div><div>- x265_log(param, X265_LOG_INFO, "Keyframe min / max / scenecut / edge threshold : %d / %d / %d / %.2lf\n",</div><div>- param->keyframeMin, param->keyframeMax, param->bHistBasedSceneCut, param->edgeTransitionThreshold);</div><div>+ x265_log(param, X265_LOG_INFO, "Keyframe min / max / scenecut : %d / %d / %d / %.2lf\n",</div><div>+ param->keyframeMin, param->keyframeMax, param->bHistBasedSceneCut);</div><div> else if (param->keyframeMax == INT_MAX)</div><div> x265_log(param, X265_LOG_INFO, "Keyframe min / max / scenecut : disabled\n");</div><div> </div><div>@@ -2179,8 +2157,6 @@ char *x265_param2string(x265_param* p, int padx, int pady)</div><div> s += sprintf(s, " lookahead-slices=%d", p->lookaheadSlices);</div><div> s += sprintf(s, " scenecut=%d", p->scenecutThreshold);</div><div> BOOL(p->bHistBasedSceneCut, "hist-scenecut");</div><div>- if (p->bHistBasedSceneCut)</div><div>- BOOL(p->bEnableTradScdInHscd, "traditional-scenecut");</div><div> s += sprintf(s, " radl=%d", p->radl);</div><div> BOOL(p->bEnableHRDConcatFlag, "splice");</div><div> BOOL(p->bIntraRefresh, "intra-refresh");</div><div>@@ -2334,7 +2310,6 @@ char *x265_param2string(x265_param* p, int padx, int pady)</div><div> BOOL(p->bOptRefListLengthPPS, "opt-ref-list-length-pps");</div><div> BOOL(p->bMultiPassOptRPS, "multi-pass-opt-rps");</div><div> s += sprintf(s, " scenecut-bias=%.2f", p->scenecutBias);</div><div>- s += sprintf(s, " hist-threshold=%.2f", p->edgeTransitionThreshold);</div><div> BOOL(p->bOptCUDeltaQP, "opt-cu-delta-qp");</div><div> BOOL(p->bAQMotion, "aq-motion");</div><div> BOOL(p->rc.frameSegment, "sbrc");</div><div>@@ -2500,7 +2475,6 @@ void x265_copy_params(x265_param* dst, x265_param* src)</div><div> dst->lookaheadThreads = src->lookaheadThreads;</div><div> dst->scenecutThreshold = src->scenecutThreshold;</div><div> dst->bHistBasedSceneCut = src->bHistBasedSceneCut;</div><div>- dst->bEnableTradScdInHscd = src->bEnableTradScdInHscd;</div><div> dst->bIntraRefresh = src->bIntraRefresh;</div><div> dst->maxCUSize = src->maxCUSize;</div><div> dst->minCUSize = src->minCUSize;</div><div>@@ -2671,7 +2645,6 @@ void x265_copy_params(x265_param* dst, x265_param* src)</div><div> dst->bOptRefListLengthPPS = src->bOptRefListLengthPPS;</div><div> dst->bMultiPassOptRPS = src->bMultiPassOptRPS;</div><div> dst->scenecutBias = src->scenecutBias;</div><div>- dst->edgeTransitionThreshold = src->edgeTransitionThreshold;</div><div> dst->gopLookahead = src->lookaheadDepth;</div><div> dst->bOptCUDeltaQP = src->bOptCUDeltaQP;</div><div> dst->analysisMultiPassDistortion = src->analysisMultiPassDistortion;</div><div>diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp</div><div>index c24507e5a..0fea6553c 100644</div><div>--- a/source/encoder/encoder.cpp</div><div>+++ b/source/encoder/encoder.cpp</div><div>@@ -168,11 +168,6 @@ Encoder::Encoder()</div><div> m_prevTonemapPayload.payload = NULL;</div><div> m_startPoint = 0;</div><div> m_saveCTUSize = 0;</div><div>- m_edgePic = NULL;</div><div>- m_edgeHistThreshold = 0;</div><div>- m_chromaHistThreshold = 0.0;</div><div>- m_scaledEdgeThreshold = 0.0;</div><div>- m_scaledChromaThreshold = 0.0;</div><div> m_zoneIndex = 0;</div><div> m_origPicBuffer = 0;</div><div> }</div><div>@@ -251,34 +246,6 @@ void Encoder::create()</div><div> }</div><div> }</div><div> </div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- uint32_t planeSize = (m_param->sourceWidth >> x265_cli_csps[p->internalCsp].width[0]) * (m_param->sourceHeight >> x265_cli_csps[m_param->internalCsp].height[0]);</div><div>- uint32_t pixelbytes = m_param->internalBitDepth > 8 ? 2 : 1;</div><div>- m_edgePic = X265_MALLOC(pixel, planeSize * pixelbytes);</div><div>- m_edgeHistThreshold = m_param->edgeTransitionThreshold;</div><div>- m_chromaHistThreshold = x265_min(m_edgeHistThreshold * 10.0, MAX_SCENECUT_THRESHOLD);</div><div>- m_scaledEdgeThreshold = x265_min(m_edgeHistThreshold * SCENECUT_STRENGTH_FACTOR, MAX_SCENECUT_THRESHOLD);</div><div>- m_scaledChromaThreshold = x265_min(m_chromaHistThreshold * SCENECUT_STRENGTH_FACTOR, MAX_SCENECUT_THRESHOLD);</div><div>- if (m_param->sourceBitDepth != m_param->internalBitDepth)</div><div>- {</div><div>- int size = m_param->sourceWidth * m_param->sourceHeight;</div><div>- int hshift = CHROMA_H_SHIFT(m_param->internalCsp);</div><div>- int vshift = CHROMA_V_SHIFT(m_param->internalCsp);</div><div>- int widthC = m_param->sourceWidth >> hshift;</div><div>- int heightC = m_param->sourceHeight >> vshift;</div><div>-</div><div>- m_inputPic[0] = X265_MALLOC(pixel, size);</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- for (int j = 1; j < 3; j++)</div><div>- {</div><div>- m_inputPic[j] = X265_MALLOC(pixel, widthC * heightC);</div><div>- }</div><div>- }</div><div>- }</div><div>- }</div><div>-</div><div> // Do not allow WPP if only one row or fewer than 3 columns, it is pointless and unstable</div><div> if (rows == 1 || cols < 3)</div><div> {</div><div>@@ -927,26 +894,6 @@ void Encoder::destroy()</div><div> }</div><div> }</div><div> </div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- if (m_edgePic != NULL)</div><div>- {</div><div>- X265_FREE_ZERO(m_edgePic);</div><div>- }</div><div>-</div><div>- if (m_param->sourceBitDepth != m_param->internalBitDepth)</div><div>- {</div><div>- X265_FREE_ZERO(m_inputPic[0]);</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- for (int i = 1; i < 3; i++)</div><div>- {</div><div>- X265_FREE_ZERO(m_inputPic[i]);</div><div>- }</div><div>- }</div><div>- }</div><div>- }</div><div>-</div><div> for (int i = 0; i < m_param->frameNumThreads; i++)</div><div> {</div><div> if (m_frameEncoder[i])</div><div>@@ -1414,217 +1361,6 @@ void Encoder::copyPicture(x265_picture *dest, const x265_picture *src)</div><div> dest->planes[2] = (char*)dest->planes[1] + src->stride[1] * (src->height >> x265_cli_csps[src->colorSpace].height[1]);</div><div> }</div><div> </div><div>-bool Encoder::computeHistograms(x265_picture *pic)</div><div>-{</div><div>- pixel *src = NULL, *planeV = NULL, *planeU = NULL;</div><div>- uint32_t widthC, heightC;</div><div>- int hshift, vshift;</div><div>-</div><div>- hshift = CHROMA_H_SHIFT(pic->colorSpace);</div><div>- vshift = CHROMA_V_SHIFT(pic->colorSpace);</div><div>- widthC = pic->width >> hshift;</div><div>- heightC = pic->height >> vshift;</div><div>-</div><div>- if (pic->bitDepth == X265_DEPTH)</div><div>- {</div><div>- src = (pixel*)pic->planes[0];</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- planeU = (pixel*)pic->planes[1];</div><div>- planeV = (pixel*)pic->planes[2];</div><div>- }</div><div>- }</div><div>- else if (pic->bitDepth == 8 && X265_DEPTH > 8)</div><div>- {</div><div>- int shift = (X265_DEPTH - 8);</div><div>- uint8_t *yChar, *uChar, *vChar;</div><div>-</div><div>- yChar = (uint8_t*)pic->planes[0];</div><div>- primitives.planecopy_cp(yChar, pic->stride[0] / sizeof(*yChar), m_inputPic[0], pic->stride[0] / sizeof(*yChar), pic->width, pic->height, shift);</div><div>- src = m_inputPic[0];</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- uChar = (uint8_t*)pic->planes[1];</div><div>- vChar = (uint8_t*)pic->planes[2];</div><div>- primitives.planecopy_cp(uChar, pic->stride[1] / sizeof(*uChar), m_inputPic[1], pic->stride[1] / sizeof(*uChar), widthC, heightC, shift);</div><div>- primitives.planecopy_cp(vChar, pic->stride[2] / sizeof(*vChar), m_inputPic[2], pic->stride[2] / sizeof(*vChar), widthC, heightC, shift);</div><div>- planeU = m_inputPic[1];</div><div>- planeV = m_inputPic[2];</div><div>- }</div><div>- }</div><div>- else</div><div>- {</div><div>- uint16_t *yShort, *uShort, *vShort;</div><div>- /* mask off bits that are supposed to be zero */</div><div>- uint16_t mask = (1 << X265_DEPTH) - 1;</div><div>- int shift = abs(pic->bitDepth - X265_DEPTH);</div><div>-</div><div>- yShort = (uint16_t*)pic->planes[0];</div><div>- uShort = (uint16_t*)pic->planes[1];</div><div>- vShort = (uint16_t*)pic->planes[2];</div><div>-</div><div>- if (pic->bitDepth > X265_DEPTH)</div><div>- {</div><div>- /* shift right and mask pixels to final size */</div><div>- primitives.planecopy_sp(yShort, pic->stride[0] / sizeof(*yShort), m_inputPic[0], pic->stride[0] / sizeof(*yShort), pic->width, pic->height, shift, mask);</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- primitives.planecopy_sp(uShort, pic->stride[1] / sizeof(*uShort), m_inputPic[1], pic->stride[1] / sizeof(*uShort), widthC, heightC, shift, mask);</div><div>- primitives.planecopy_sp(vShort, pic->stride[2] / sizeof(*vShort), m_inputPic[2], pic->stride[2] / sizeof(*vShort), widthC, heightC, shift, mask);</div><div>- }</div><div>- }</div><div>- else /* Case for (pic.bitDepth < X265_DEPTH) */</div><div>- {</div><div>- /* shift left and mask pixels to final size */</div><div>- primitives.planecopy_sp_shl(yShort, pic->stride[0] / sizeof(*yShort), m_inputPic[0], pic->stride[0] / sizeof(*yShort), pic->width, pic->height, shift, mask);</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- primitives.planecopy_sp_shl(uShort, pic->stride[1] / sizeof(*uShort), m_inputPic[1], pic->stride[1] / sizeof(*uShort), widthC, heightC, shift, mask);</div><div>- primitives.planecopy_sp_shl(vShort, pic->stride[2] / sizeof(*vShort), m_inputPic[2], pic->stride[2] / sizeof(*vShort), widthC, heightC, shift, mask);</div><div>- }</div><div>- }</div><div>-</div><div>- src = m_inputPic[0];</div><div>- planeU = m_inputPic[1];</div><div>- planeV = m_inputPic[2];</div><div>- }</div><div>-</div><div>- size_t bufSize = sizeof(pixel) * m_planeSizes[0];</div><div>- memset(m_edgePic, 0, bufSize);</div><div>-</div><div>- if (!computeEdge(m_edgePic, src, NULL, pic->width, pic->height, pic->width, false, 1))</div><div>- {</div><div>- x265_log(m_param, X265_LOG_ERROR, "Failed to compute edge!");</div><div>- return false;</div><div>- }</div><div>-</div><div>- pixel pixelVal;</div><div>- int32_t *edgeHist = m_curEdgeHist;</div><div>- memset(edgeHist, 0, EDGE_BINS * sizeof(int32_t));</div><div>- for (uint32_t i = 0; i < m_planeSizes[0]; i++)</div><div>- {</div><div>- if (m_edgePic[i])</div><div>- edgeHist[1]++;</div><div>- else</div><div>- edgeHist[0]++;</div><div>- }</div><div>-</div><div>- /* Y Histogram Calculation */</div><div>- int32_t *yHist = m_curYUVHist[0];</div><div>- memset(yHist, 0, HISTOGRAM_BINS * sizeof(int32_t));</div><div>- for (uint32_t i = 0; i < m_planeSizes[0]; i++)</div><div>- {</div><div>- pixelVal = src[i];</div><div>- yHist[pixelVal]++;</div><div>- }</div><div>-</div><div>- if (pic->colorSpace != X265_CSP_I400)</div><div>- {</div><div>- /* U Histogram Calculation */</div><div>- int32_t *uHist = m_curYUVHist[1];</div><div>- memset(uHist, 0, sizeof(m_curYUVHist[1]));</div><div>- for (uint32_t i = 0; i < m_planeSizes[1]; i++)</div><div>- {</div><div>- pixelVal = planeU[i];</div><div>- uHist[pixelVal]++;</div><div>- }</div><div>-</div><div>- /* V Histogram Calculation */</div><div>- pixelVal = 0;</div><div>- int32_t *vHist = m_curYUVHist[2];</div><div>- memset(vHist, 0, sizeof(m_curYUVHist[2]));</div><div>- for (uint32_t i = 0; i < m_planeSizes[2]; i++)</div><div>- {</div><div>- pixelVal = planeV[i];</div><div>- vHist[pixelVal]++;</div><div>- }</div><div>- }</div><div>- return true;</div><div>-}</div><div>-</div><div>-void Encoder::computeHistogramSAD(double *normalizedMaxUVSad, double *normalizedEdgeSad, int curPoc)</div><div>-{</div><div>-</div><div>- if (curPoc == 0)</div><div>- { /* first frame is scenecut by default no sad computation for the same. */</div><div>- *normalizedMaxUVSad = 0.0;</div><div>- *normalizedEdgeSad = 0.0;</div><div>- }</div><div>- else</div><div>- {</div><div>- /* compute sum of absolute differences of histogram bins of chroma and luma edge response between the current and prev pictures. */</div><div>- int32_t edgeHistSad = 0;</div><div>- int32_t uHistSad = 0;</div><div>- int32_t vHistSad = 0;</div><div>- double normalizedUSad = 0.0;</div><div>- double normalizedVSad = 0.0;</div><div>-</div><div>- for (int j = 0; j < HISTOGRAM_BINS; j++)</div><div>- {</div><div>- if (j < 2)</div><div>- {</div><div>- edgeHistSad += abs(m_curEdgeHist[j] - m_prevEdgeHist[j]);</div><div>- }</div><div>- uHistSad += abs(m_curYUVHist[1][j] - m_prevYUVHist[1][j]);</div><div>- vHistSad += abs(m_curYUVHist[2][j] - m_prevYUVHist[2][j]);</div><div>- }</div><div>- *normalizedEdgeSad = normalizeRange(edgeHistSad, 0, 2 * m_planeSizes[0], 0.0, 1.0);</div><div>- normalizedUSad = normalizeRange(uHistSad, 0, 2 * m_planeSizes[1], 0.0, 1.0);</div><div>- normalizedVSad = normalizeRange(vHistSad, 0, 2 * m_planeSizes[2], 0.0, 1.0);</div><div>- *normalizedMaxUVSad = x265_max(normalizedUSad, normalizedVSad);</div><div>- }</div><div>-</div><div>- /* store histograms of previous frame for reference */</div><div>- memcpy(m_prevEdgeHist, m_curEdgeHist, sizeof(m_curEdgeHist));</div><div>- memcpy(m_prevYUVHist, m_curYUVHist, sizeof(m_curYUVHist));</div><div>-}</div><div>-</div><div>-double Encoder::normalizeRange(int32_t value, int32_t minValue, int32_t maxValue, double rangeStart, double rangeEnd)</div><div>-{</div><div>- return (double)(value - minValue) * (rangeEnd - rangeStart) / (maxValue - minValue) + rangeStart;</div><div>-}</div><div>-</div><div>-void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double maxUVSad, double edgeSad, bool& isMaxThres, bool& isHardSC)</div><div>-{</div><div>- double minEdgeT = m_edgeHistThreshold * MIN_EDGE_FACTOR;</div><div>- double minChromaT = minEdgeT * SCENECUT_CHROMA_FACTOR;</div><div>- double maxEdgeT = m_edgeHistThreshold * MAX_EDGE_FACTOR;</div><div>- double maxChromaT = maxEdgeT * SCENECUT_CHROMA_FACTOR;</div><div>- pic->frameData.bScenecut = false;</div><div>-</div><div>- if (pic->poc == 0)</div><div>- {</div><div>- /* for first frame */</div><div>- pic->frameData.bScenecut = false;</div><div>- bDup = false;</div><div>- }</div><div>- else</div><div>- {</div><div>- if (edgeSad == 0.0 && maxUVSad == 0.0)</div><div>- {</div><div>- bDup = true;</div><div>- }</div><div>- else if (edgeSad < minEdgeT && maxUVSad < minChromaT)</div><div>- {</div><div>- pic->frameData.bScenecut = false;</div><div>- }</div><div>- else if (edgeSad > maxEdgeT && maxUVSad > maxChromaT)</div><div>- {</div><div>- pic->frameData.bScenecut = true;</div><div>- isMaxThres = true;</div><div>- isHardSC = true;</div><div>- }</div><div>- else if (edgeSad > m_scaledEdgeThreshold || maxUVSad >= m_scaledChromaThreshold</div><div>- || (edgeSad > m_edgeHistThreshold && maxUVSad >= m_chromaHistThreshold))</div><div>- {</div><div>- pic->frameData.bScenecut = true;</div><div>- bDup = false;</div><div>- if (edgeSad > m_scaledEdgeThreshold || maxUVSad >= m_scaledChromaThreshold)</div><div>- isHardSC = true;</div><div>- }</div><div>- }</div><div>-}</div><div>-</div><div> bool Encoder::isFilterThisframe(uint8_t sliceTypeConfig, int curSliceType)</div><div> {</div><div> uint8_t newSliceType = 0;</div><div>@@ -1737,10 +1473,7 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)</div><div> const x265_picture* inputPic = NULL;</div><div> static int written = 0, read = 0;</div><div> bool dontRead = false;</div><div>- bool bdropFrame = false;</div><div> bool dropflag = false;</div><div>- bool isMaxThres = false;</div><div>- bool isHardSC = false;</div><div> </div><div> if (m_exportedPic)</div><div> {</div><div>@@ -1758,25 +1491,6 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)</div><div> </div><div> if ((pic_in && (!m_param->chunkEnd || (m_encodedFrameNum < m_param->chunkEnd))) || (m_param->bEnableFrameDuplication && !pic_in && (read < written)))</div><div> {</div><div>- if (m_param->bHistBasedSceneCut && pic_in)</div><div>- {</div><div>- x265_picture *pic = (x265_picture *) pic_in;</div><div>-</div><div>- if (pic->poc == 0)</div><div>- {</div><div>- /* for entire encode compute the chroma plane sizes only once */</div><div>- for (int i = 0; i < x265_cli_csps[m_param->internalCsp].planes; i++)</div><div>- m_planeSizes[i] = (pic->width >> x265_cli_csps[m_param->internalCsp].width[i]) * (pic->height >> x265_cli_csps[m_param->internalCsp].height[i]);</div><div>- }</div><div>-</div><div>- if (computeHistograms(pic))</div><div>- {</div><div>- double maxUVSad = 0.0, edgeSad = 0.0;</div><div>- computeHistogramSAD(&maxUVSad, &edgeSad, pic_in->poc);</div><div>- findSceneCuts(pic, bdropFrame, maxUVSad, edgeSad, isMaxThres, isHardSC);</div><div>- }</div><div>- }</div><div>-</div><div> if ((m_param->bEnableFrameDuplication && !pic_in && (read < written)))</div><div> dontRead = true;</div><div> else</div><div>@@ -1820,20 +1534,7 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)</div><div> written++;</div><div> }</div><div> </div><div>- if (m_param->bEnableFrameDuplication && m_param->bHistBasedSceneCut)</div><div>- {</div><div>- if (!bdropFrame && m_dupBuffer[1]->dupPic->frameData.bScenecut == false)</div><div>- {</div><div>- psnrWeight = ComputePSNR(m_dupBuffer[0]->dupPic, m_dupBuffer[1]->dupPic, m_param);</div><div>- if (psnrWeight >= m_param->dupThreshold)</div><div>- dropflag = true;</div><div>- }</div><div>- else</div><div>- {</div><div>- dropflag = true;</div><div>- }</div><div>- }</div><div>- else if (m_param->bEnableFrameDuplication)</div><div>+ if (m_param->bEnableFrameDuplication)</div><div> {</div><div> psnrWeight = ComputePSNR(m_dupBuffer[0]->dupPic, m_dupBuffer[1]->dupPic, m_param);</div><div> if (psnrWeight >= m_param->dupThreshold)</div><div>@@ -1916,12 +1617,6 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)</div><div> }</div><div> }</div><div> }</div><div>- if (m_param->recursionSkipMode == EDGE_BASED_RSKIP && m_param->bHistBasedSceneCut)</div><div>- {</div><div>- pixel* src = m_edgePic;</div><div>- primitives.planecopy_pp_shr(src, inFrame->m_fencPic->m_picWidth, inFrame->m_edgeBitPic, inFrame->m_fencPic->m_stride,</div><div>- inFrame->m_fencPic->m_picWidth, inFrame->m_fencPic->m_picHeight, 0);</div><div>- }</div><div> }</div><div> else</div><div> {</div><div>@@ -1950,13 +1645,6 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)</div><div> inFrame->m_poc = ++m_pocLast;</div><div> inFrame->m_userData = inputPic->userData;</div><div> inFrame->m_pts = inputPic->pts;</div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- inFrame->m_lowres.bScenecut = (inputPic->frameData.bScenecut == 1) ? true : false;</div><div>- inFrame->m_lowres.m_bIsMaxThres = isMaxThres;</div><div>- if (m_param->radl && m_param->keyframeMax != m_param->keyframeMin)</div><div>- inFrame->m_lowres.m_bIsHardScenecut = isHardSC;</div><div>- }</div><div> </div><div> if ((m_param->bEnableSceneCutAwareQp & BACKWARD) && m_param->rc.bStatRead)</div><div> {</div><div>@@ -1974,16 +1662,7 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)</div><div> }</div><div> }</div><div> }</div><div>- if (m_param->bHistBasedSceneCut && m_param->analysisSave)</div><div>- {</div><div>- memcpy(inFrame->m_analysisData.edgeHist, m_curEdgeHist, EDGE_BINS * sizeof(int32_t));</div><div>- memcpy(inFrame->m_analysisData.yuvHist[0], m_curYUVHist[0], HISTOGRAM_BINS *sizeof(int32_t));</div><div>- if (inputPic->colorSpace != X265_CSP_I400)</div><div>- {</div><div>- memcpy(inFrame->m_analysisData.yuvHist[1], m_curYUVHist[1], HISTOGRAM_BINS * sizeof(int32_t));</div><div>- memcpy(inFrame->m_analysisData.yuvHist[2], m_curYUVHist[2], HISTOGRAM_BINS * sizeof(int32_t));</div><div>- }</div><div>- }</div><div>+</div><div> inFrame->m_forceqp = inputPic->forceqp;</div><div> inFrame->m_param = (m_reconfigure || m_reconfigureRc) ? m_latestParam : m_param;</div><div> inFrame->m_picStruct = inputPic->picStruct;</div><div>@@ -2242,16 +1921,6 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)</div><div> pic_out->analysisData.poc = pic_out->poc;</div><div> pic_out->analysisData.sliceType = pic_out->sliceType;</div><div> pic_out->analysisData.bScenecut = outFrame->m_lowres.bScenecut;</div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- memcpy(pic_out->analysisData.edgeHist, outFrame->m_analysisData.edgeHist, EDGE_BINS * sizeof(int32_t));</div><div>- memcpy(pic_out->analysisData.yuvHist[0], outFrame->m_analysisData.yuvHist[0], HISTOGRAM_BINS * sizeof(int32_t));</div><div>- if (pic_out->colorSpace != X265_CSP_I400)</div><div>- {</div><div>- memcpy(pic_out->analysisData.yuvHist[1], outFrame->m_analysisData.yuvHist[1], HISTOGRAM_BINS * sizeof(int32_t));</div><div>- memcpy(pic_out->analysisData.yuvHist[2], outFrame->m_analysisData.yuvHist[2], HISTOGRAM_BINS * sizeof(int32_t));</div><div>- }</div><div>- }</div><div> pic_out->analysisData.satdCost = outFrame->m_lowres.satdCost;</div><div> pic_out->analysisData.numCUsInFrame = outFrame->m_analysisData.numCUsInFrame;</div><div> pic_out->analysisData.numPartitions = outFrame->m_analysisData.numPartitions;</div><div>@@ -2736,7 +2405,7 @@ int Encoder::encode(const x265_picture* pic_in, x265_picture* pic_out)</div><div> for (int i = 0; i < frameEnc->m_mcstf->m_numRef; i++)</div><div> {</div><div> TemporalFilterRefPicInfo *ref = &curEncoder->m_mcstfRefList[i];</div><div>- ref->slicetype = m_lookahead->FindSliceType(frameEnc->m_poc + ref->origOffset);</div><div>+ ref->slicetype = m_lookahead->findSliceType(frameEnc->m_poc + ref->origOffset);</div><div> Frame* dpbframePtr = m_dpb->m_picList.getPOC(frameEnc->m_poc + ref->origOffset);</div><div> if (dpbframePtr != NULL)</div><div> {</div><div>@@ -3031,18 +2700,7 @@ void Encoder::printSummary()</div><div> (float)100.0 * m_numLumaWPBiFrames / m_analyzeB.m_numPics,</div><div> (float)100.0 * m_numChromaWPBiFrames / m_analyzeB.m_numPics);</div><div> }</div><div>- int pWithB = 0;</div><div>- for (int i = 0; i <= m_param->bframes; i++)</div><div>- pWithB += m_lookahead->m_histogram[i];</div><div> </div><div>- if (pWithB)</div><div>- {</div><div>- int p = 0;</div><div>- for (int i = 0; i <= m_param->bframes; i++)</div><div>- p += sprintf(buffer + p, "%.1f%% ", 100. * m_lookahead->m_histogram[i] / pWithB);</div><div>-</div><div>- x265_log(m_param, X265_LOG_INFO, "consecutive B-frames: %s\n", buffer);</div><div>- }</div><div> if (m_param->bLossless)</div><div> {</div><div> float frameSize = (float)(m_param->sourceWidth - m_sps.conformanceWindow.rightOffset) *</div><div>@@ -3949,7 +3607,6 @@ void Encoder::configure(x265_param *p)</div><div> p->keyframeMax = INT_MAX;</div><div> p->scenecutThreshold = 0;</div><div> p->bHistBasedSceneCut = 0;</div><div>- p->bEnableTradScdInHscd = 1;</div><div> }</div><div> else if (p->keyframeMax <= 1)</div><div> {</div><div>@@ -3964,7 +3621,6 @@ void Encoder::configure(x265_param *p)</div><div> p->bframes = 0;</div><div> p->scenecutThreshold = 0;</div><div> p->bHistBasedSceneCut = 0;</div><div>- p->bEnableTradScdInHscd = 1;</div><div> p->bFrameAdaptive = 0;</div><div> p->rc.cuTree = 0;</div><div> p->bEnableWeightedPred = 0;</div><div>@@ -4701,18 +4357,6 @@ void Encoder::configure(x265_param *p)</div><div> if (m_param->searchRange != m_param->hmeRange[2])</div><div> m_param->searchRange = m_param->hmeRange[2];</div><div> }</div><div>-</div><div>- if (p->bHistBasedSceneCut && !p->edgeTransitionThreshold)</div><div>- {</div><div>- p->edgeTransitionThreshold = 0.03;</div><div>- x265_log(p, X265_LOG_WARNING, "using default threshold %.2lf for scene cut detection.\n", p->edgeTransitionThreshold);</div><div>- }</div><div>-</div><div>- if (!p->bHistBasedSceneCut && !p->bEnableTradScdInHscd)</div><div>- {</div><div>- p->bEnableTradScdInHscd = 1;</div><div>- x265_log(p, X265_LOG_WARNING, "option --no-traditional-scenecut requires --hist-scenecut to be enabled.\n");</div><div>- }</div><div> }</div><div> </div><div> void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x265_picture* picIn, int paramBytes)</div><div>@@ -4773,16 +4417,6 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x</div><div> analysis->frameRecordSize = frameRecordSize;</div><div> X265_FREAD(&analysis->sliceType, sizeof(int), 1, m_analysisFileIn, &(picData->sliceType));</div><div> X265_FREAD(&analysis->bScenecut, sizeof(int), 1, m_analysisFileIn, &(picData->bScenecut));</div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- X265_FREAD(&analysis->edgeHist, sizeof(int32_t), EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);</div><div>- X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);</div><div>- X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);</div><div>- }</div><div>- }</div><div> X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileIn, &(picData->satdCost));</div><div> X265_FREAD(&numCUsLoad, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));</div><div> X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));</div><div>@@ -5105,16 +4739,6 @@ void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, const x</div><div> analysis->frameRecordSize = frameRecordSize;</div><div> X265_FREAD(&analysis->sliceType, sizeof(int), 1, m_analysisFileIn, &(picData->sliceType));</div><div> X265_FREAD(&analysis->bScenecut, sizeof(int), 1, m_analysisFileIn, &(picData->bScenecut));</div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- X265_FREAD(&analysis->edgeHist, sizeof(int32_t), EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);</div><div>- X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);</div><div>- X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);</div><div>- }</div><div>- }</div><div> X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileIn, &(picData->satdCost));</div><div> X265_FREAD(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));</div><div> X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));</div><div>@@ -5731,6 +5355,7 @@ void Encoder::computeDistortionOffset(x265_analysis_data* analysis)</div><div> distortionData->highDistortionCtuCount++;</div><div> }</div><div> }</div><div>+</div><div> void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc, int sliceType)</div><div> {</div><div> </div><div>@@ -5880,17 +5505,6 @@ void Encoder::writeAnalysisFile(x265_analysis_data* analysis, FrameData &curEncD</div><div> /* calculate frameRecordSize */</div><div> analysis->frameRecordSize = sizeof(analysis->frameRecordSize) + sizeof(depthBytes) + sizeof(analysis->poc) + sizeof(analysis->sliceType) +</div><div> sizeof(analysis->numCUsInFrame) + sizeof(analysis->numPartitions) + sizeof(analysis->bScenecut) + sizeof(analysis->satdCost);</div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- analysis->frameRecordSize += sizeof(analysis->edgeHist);</div><div>- analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;</div><div>- analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;</div><div>- }</div><div>- }</div><div>-</div><div> if (analysis->sliceType > X265_TYPE_I)</div><div> {</div><div> numDir = (analysis->sliceType == X265_TYPE_P) ? 1 : 2;</div><div>@@ -6035,17 +5649,6 @@ void Encoder::writeAnalysisFile(x265_analysis_data* analysis, FrameData &curEncD</div><div> X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFileOut);</div><div> X265_FWRITE(&analysis->sliceType, sizeof(int), 1, m_analysisFileOut);</div><div> X265_FWRITE(&analysis->bScenecut, sizeof(int), 1, m_analysisFileOut);</div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- X265_FWRITE(&analysis->edgeHist, sizeof(int32_t), EDGE_BINS, m_analysisFileOut);</div><div>- X265_FWRITE(&analysis->yuvHist[0], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileOut);</div><div>- if (m_param->internalCsp != X265_CSP_I400)</div><div>- {</div><div>- X265_FWRITE(&analysis->yuvHist[1], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileOut);</div><div>- X265_FWRITE(&analysis->yuvHist[2], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileOut);</div><div>- }</div><div>- }</div><div>-</div><div> X265_FWRITE(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileOut);</div><div> X265_FWRITE(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFileOut);</div><div> X265_FWRITE(&analysis->numPartitions, sizeof(int), 1, m_analysisFileOut);</div><div>diff --git a/source/encoder/encoder.h b/source/encoder/encoder.h</div><div>index 669154da3..06a01e21c 100644</div><div>--- a/source/encoder/encoder.h</div><div>+++ b/source/encoder/encoder.h</div><div>@@ -257,19 +257,6 @@ public:</div><div> int m_bToneMap; // Enables tone-mapping</div><div> int m_enableNal;</div><div> </div><div>- /* For histogram based scene-cut detection */</div><div>- pixel* m_edgePic;</div><div>- pixel* m_inputPic[3];</div><div>- int32_t m_curYUVHist[3][HISTOGRAM_BINS];</div><div>- int32_t m_prevYUVHist[3][HISTOGRAM_BINS];</div><div>- int32_t m_curEdgeHist[2];</div><div>- int32_t m_prevEdgeHist[2];</div><div>- uint32_t m_planeSizes[3];</div><div>- double m_edgeHistThreshold;</div><div>- double m_chromaHistThreshold;</div><div>- double m_scaledEdgeThreshold;</div><div>- double m_scaledChromaThreshold;</div><div>-</div><div> #ifdef ENABLE_HDR10_PLUS</div><div> const hdr10plus_api *m_hdr10plus_api;</div><div> uint8_t **m_cim;</div><div>@@ -379,11 +366,6 @@ public:</div><div> </div><div> void copyPicture(x265_picture *dest, const x265_picture *src);</div><div> </div><div>- bool computeHistograms(x265_picture *pic);</div><div>- void computeHistogramSAD(double *maxUVNormalizedSAD, double *edgeNormalizedSAD, int curPoc);</div><div>- double normalizeRange(int32_t value, int32_t minValue, int32_t maxValue, double rangeStart, double rangeEnd);</div><div>- void findSceneCuts(x265_picture *pic, bool& bDup, double m_maxUVSADVal, double m_edgeSADVal, bool& isMaxThres, bool& isHardSC);</div><div>-</div><div> void initRefIdx();</div><div> void analyseRefIdx(int *numRefIdx);</div><div> void updateRefIdx();</div><div>diff --git a/source/encoder/frameencoder.cpp b/source/encoder/frameencoder.cpp</div><div>index 6f567b9cf..1ce0d393c 100644</div><div>--- a/source/encoder/frameencoder.cpp</div><div>+++ b/source/encoder/frameencoder.cpp</div><div>@@ -471,7 +471,7 @@ void FrameEncoder::compressFrame()</div><div> m_ssimCnt = 0;</div><div> memset(&(m_frame->m_encData->m_frameStats), 0, sizeof(m_frame->m_encData->m_frameStats));</div><div> </div><div>- if (!m_param->bHistBasedSceneCut && m_param->rc.aqMode != X265_AQ_EDGE && m_param->recursionSkipMode == EDGE_BASED_RSKIP)</div><div>+ if (m_param->rc.aqMode != X265_AQ_EDGE && m_param->recursionSkipMode == EDGE_BASED_RSKIP)</div><div> {</div><div> int height = m_frame->m_fencPic->m_picHeight;</div><div> int width = m_frame->m_fencPic->m_picWidth;</div><div>diff --git a/source/encoder/slicetype.cpp b/source/encoder/slicetype.cpp</div><div>index ae908e626..1ff5abcc8 100644</div><div>--- a/source/encoder/slicetype.cpp</div><div>+++ b/source/encoder/slicetype.cpp</div><div>@@ -519,7 +519,7 @@ void LookaheadTLD::calcAdaptiveQuantFrame(Frame *curFrame, x265_param* param)</div><div> if (curFrame->m_frameSegment == X265_AQ_EDGE )</div><div> edgeFilter(curFrame, param);</div><div> </div><div>- if (curFrame->m_frameSegment == X265_AQ_EDGE && !param->bHistBasedSceneCut && param->recursionSkipMode == EDGE_BASED_RSKIP)</div><div>+ if (curFrame->m_frameSegment == X265_AQ_EDGE && param->recursionSkipMode == EDGE_BASED_RSKIP)</div><div> {</div><div> pixel* src = curFrame->m_edgePic + curFrame->m_fencPic->m_lumaMarginY * curFrame->m_fencPic->m_stride + curFrame->m_fencPic->m_lumaMarginX;</div><div> primitives.planecopy_pp_shr(src, curFrame->m_fencPic->m_stride, curFrame->m_edgeBitPic,</div><div>@@ -1050,7 +1050,6 @@ Lookahead::Lookahead(x265_param *param, ThreadPool* pool)</div><div> m_countPreLookahead = 0;</div><div> #endif</div><div> </div><div>- memset(m_histogram, 0, sizeof(m_histogram));</div><div> }</div><div> </div><div> #if DETAILED_CU_STATS</div><div>@@ -1098,6 +1097,7 @@ void Lookahead::stopJobs()</div><div> m_pool[i].stopWorkers();</div><div> }</div><div> }</div><div>+</div><div> void Lookahead::destroy()</div><div> {</div><div> // these two queues will be empty unless the encode was aborted</div><div>@@ -1571,7 +1571,7 @@ void Lookahead::slicetypeDecide()</div><div> m_param->rc.cuTree || m_param->scenecutThreshold || m_param->bHistBasedSceneCut ||</div><div> (m_param->lookaheadDepth && m_param->rc.vbvBufferSize)))</div><div> {</div><div>- if(!m_param->rc.bStatRead)</div><div>+ if (!m_param->rc.bStatRead)</div><div> slicetypeAnalyse(frames, false);</div><div> bool bIsVbv = m_param->rc.vbvBufferSize > 0 && m_param->rc.vbvMaxBitrate > 0;</div><div> if ((m_param->analysisLoad && m_param->scaleFactor && bIsVbv) || m_param->bliveVBV2pass)</div><div>@@ -1652,12 +1652,9 @@ void Lookahead::slicetypeDecide()</div><div> }</div><div> if (frm.sliceType == X265_TYPE_IDR && frm.bScenecut && isClosedGopRadl)</div><div> {</div><div>- if (!m_param->bHistBasedSceneCut || (m_param->bHistBasedSceneCut && frm.m_bIsHardScenecut))</div><div>- {</div><div>- for (int i = bframes; i < bframes + m_param->radl; i++)</div><div>- list[i]->m_lowres.sliceType = X265_TYPE_B;</div><div>- list[(bframes + m_param->radl)]->m_lowres.sliceType = X265_TYPE_IDR;</div><div>- }</div><div>+ for (int i = bframes; i < bframes + m_param->radl; i++)</div><div>+ list[i]->m_lowres.sliceType = X265_TYPE_B;</div><div>+ list[(bframes + m_param->radl)]->m_lowres.sliceType = X265_TYPE_IDR;</div><div> }</div><div> if (frm.sliceType == X265_TYPE_IDR)</div><div> {</div><div>@@ -1722,7 +1719,6 @@ void Lookahead::slicetypeDecide()</div><div> list[bframes - 1]->m_lowres.bLastMiniGopBFrame = true;</div><div> list[bframes]->m_lowres.leadingBframes = bframes;</div><div> m_lastNonB = &list[bframes]->m_lowres;</div><div>- m_histogram[bframes]++;</div><div> </div><div> /* insert a bref into the sequence */</div><div> if (m_param->bBPyramid && bframes > 1 && !brefs)</div><div>@@ -2082,46 +2078,10 @@ void Lookahead::slicetypeAnalyse(Lowres **frames, bool bKeyframe)</div><div> int numAnalyzed = numFrames;</div><div> bool isScenecut = false;</div><div> </div><div>- /* Temporal computations for scenecut detection */</div><div>- if (m_param->bHistBasedSceneCut && m_param->bEnableTradScdInHscd)</div><div>- {</div><div>- for (int i = numFrames - 1; i > 0; i--)</div><div>- {</div><div>- if (frames[i]->interPCostPercDiff > 0.0)</div><div>- continue;</div><div>- int64_t interCost = frames[i]->costEst[1][0];</div><div>- int64_t intraCost = frames[i]->costEst[0][0];</div><div>- if (interCost < 0 || intraCost < 0)</div><div>- continue;</div><div>- int times = 0;</div><div>- double averagePcost = 0.0, averageIcost = 0.0;</div><div>- for (int j = i - 1; j >= 0 && times < 5; j--, times++)</div><div>- {</div><div>- if (frames[j]->costEst[0][0] > 0 && frames[j]->costEst[1][0] > 0)</div><div>- {</div><div>- averageIcost += frames[j]->costEst[0][0];</div><div>- averagePcost += frames[j]->costEst[1][0];</div><div>- }</div><div>- else</div><div>- times--;</div><div>- }</div><div>- if (times)</div><div>- {</div><div>- averageIcost = averageIcost / times;</div><div>- averagePcost = averagePcost / times;</div><div>- frames[i]->interPCostPercDiff = abs(interCost - averagePcost) / X265_MIN(interCost, averagePcost) * 100;</div><div>- frames[i]->intraCostPercDiff = abs(intraCost - averageIcost) / X265_MIN(intraCost, averageIcost) * 100;</div><div>- }</div><div>- }</div><div>- }</div><div>+ isScenecut = scenecut(frames, 0, 1, true, origNumFrames);</div><div> </div><div> /* When scenecut threshold is set, use scenecut detection for I frame placements */</div><div>- if (!m_param->bHistBasedSceneCut || (m_param->bHistBasedSceneCut && m_param->bEnableTradScdInHscd && frames[1]->bScenecut))</div><div>- isScenecut = scenecut(frames, 0, 1, true, origNumFrames);</div><div>- else if (m_param->bHistBasedSceneCut && frames[1]->bScenecut)</div><div>- isScenecut = true;</div><div>-</div><div>- if (isScenecut && (m_param->bHistBasedSceneCut || m_param->scenecutThreshold))</div><div>+ if (m_param->scenecutThreshold && isScenecut)</div><div> {</div><div> frames[1]->sliceType = X265_TYPE_I;</div><div> return;</div><div>@@ -2132,17 +2092,13 @@ void Lookahead::slicetypeAnalyse(Lowres **frames, bool bKeyframe)</div><div> m_extendGopBoundary = false;</div><div> for (int i = m_param->bframes + 1; i < origNumFrames; i += m_param->bframes + 1)</div><div> {</div><div>- if (!m_param->bHistBasedSceneCut || (m_param->bHistBasedSceneCut && m_param->bEnableTradScdInHscd && frames[i + 1]->bScenecut))</div><div>- scenecut(frames, i, i + 1, true, origNumFrames);</div><div>+ scenecut(frames, i, i + 1, true, origNumFrames);</div><div> </div><div> for (int j = i + 1; j <= X265_MIN(i + m_param->bframes + 1, origNumFrames); j++)</div><div> {</div><div>- if (frames[j]->bScenecut)</div><div>+ if (frames[j]->bScenecut && scenecutInternal(frames, j - 1, j, true))</div><div> {</div><div>- if (m_param->bEnableTradScdInHscd)</div><div>- m_extendGopBoundary = scenecutInternal(frames, j - 1, j, true);</div><div>- else</div><div>- m_extendGopBoundary = true;</div><div>+ m_extendGopBoundary = true;</div><div> break;</div><div> }</div><div> }</div><div>@@ -2249,10 +2205,8 @@ void Lookahead::slicetypeAnalyse(Lowres **frames, bool bKeyframe)</div><div> {</div><div> for (int j = 1; j < numBFrames + 1; j++)</div><div> {</div><div>- bool isNextScenecut = false;</div><div>- if (!m_param->bHistBasedSceneCut || (m_param->bHistBasedSceneCut && frames[j + 1]->bScenecut))</div><div>- isNextScenecut = scenecut(frames, j, j + 1, false, origNumFrames);</div><div>- if (isNextScenecut || (bForceRADL && frames[j]->frameNum == preRADL))</div><div>+ if (scenecut(frames, j, j + 1, false, origNumFrames) ||</div><div>+ (bForceRADL && (frames[j]->frameNum == preRADL)))</div><div> {</div><div> frames[j]->sliceType = X265_TYPE_P;</div><div> numAnalyzed = j;</div><div>@@ -2318,9 +2272,10 @@ bool Lookahead::scenecut(Lowres **frames, int p0, int p1, bool bRealScenecut, in</div><div> /* Where A and B are scenes: AAAAAABBBAAAAAA</div><div> * If BBB is shorter than (maxp1-p0), it is detected as a flash</div><div> * and not considered a scenecut. */</div><div>+</div><div> for (int cp1 = p1; cp1 <= maxp1; cp1++)</div><div> {</div><div>- if (!scenecutInternal(frames, p0, cp1, false) && !m_param->bHistBasedSceneCut)</div><div>+ if (!scenecutInternal(frames, p0, cp1, false))</div><div> {</div><div> /* Any frame in between p0 and cur_p1 cannot be a real scenecut. */</div><div> for (int i = cp1; i > p0; i--)</div><div>@@ -2329,7 +2284,7 @@ bool Lookahead::scenecut(Lowres **frames, int p0, int p1, bool bRealScenecut, in</div><div> noScenecuts = false;</div><div> }</div><div> }</div><div>- else if ((m_param->bHistBasedSceneCut && frames[cp1]->m_bIsMaxThres) || scenecutInternal(frames, cp1 - 1, cp1, false))</div><div>+ else if (scenecutInternal(frames, cp1 - 1, cp1, false))</div><div> {</div><div> /* If current frame is a Scenecut from p0 frame as well as Scenecut from</div><div> * preceeding frame, mark it as a Scenecut */</div><div>@@ -2390,9 +2345,6 @@ bool Lookahead::scenecut(Lowres **frames, int p0, int p1, bool bRealScenecut, in</div><div> </div><div> if (!frames[p1]->bScenecut)</div><div> return false;</div><div>- /* Check only scene transitions if max threshold */</div><div>- if (m_param->bHistBasedSceneCut && frames[p1]->m_bIsMaxThres)</div><div>- return frames[p1]->bScenecut;</div><div> </div><div> return scenecutInternal(frames, p0, p1, bRealScenecut);</div><div> }</div><div>@@ -2410,19 +2362,8 @@ bool Lookahead::scenecutInternal(Lowres **frames, int p0, int p1, bool bRealScen</div><div> /* magic numbers pulled out of thin air */</div><div> float threshMin = (float)(threshMax * 0.25);</div><div> double bias = m_param->scenecutBias;</div><div>- if (m_param->bHistBasedSceneCut)</div><div>- {</div><div>- double minT = TEMPORAL_SCENECUT_THRESHOLD * (1 + m_param->edgeTransitionThreshold);</div><div>- if (frame->interPCostPercDiff > minT || frame->intraCostPercDiff > minT)</div><div>- {</div><div>- if (bRealScenecut && frame->bScenecut)</div><div>- x265_log(m_param, X265_LOG_DEBUG, "scene cut at %d \n", frame->frameNum);</div><div>- return frame->bScenecut;</div><div>- }</div><div>- else</div><div>- return false;</div><div>- }</div><div>- else if (bRealScenecut)</div><div>+</div><div>+ if (bRealScenecut)</div><div> {</div><div> if (m_param->keyframeMin == m_param->keyframeMax)</div><div> threshMin = threshMax;</div><div>@@ -2479,7 +2420,7 @@ void Lookahead::slicetypePath(Lowres **frames, int length, char(*best_paths)[X26</div><div> }</div><div> </div><div> // Find slicetype of the frame with poc # in lookahead buffer</div><div>-int Lookahead::FindSliceType(int poc)</div><div>+int Lookahead::findSliceType(int poc)</div><div> {</div><div> int out_slicetype = X265_TYPE_AUTO;</div><div> if (m_filled)</div><div>diff --git a/source/encoder/slicetype.h b/source/encoder/slicetype.h</div><div>index 52b55a4a8..490e7ba1a 100644</div><div>--- a/source/encoder/slicetype.h</div><div>+++ b/source/encoder/slicetype.h</div><div>@@ -124,7 +124,6 @@ public:</div><div> </div><div> /* pre-lookahead */</div><div> int m_fullQueueSize;</div><div>- int m_histogram[X265_BFRAME_MAX + 1];</div><div> int m_lastKeyframe;</div><div> int m_8x8Width;</div><div> int m_8x8Height;</div><div>@@ -174,7 +173,7 @@ public:</div><div> </div><div> void getEstimatedPictureCost(Frame *pic);</div><div> void setLookaheadQueue();</div><div>- int FindSliceType(int poc);</div><div>+ int findSliceType(int poc);</div><div> </div><div> protected:</div><div> </div><div>diff --git a/source/x265.h b/source/x265.h</div><div>index e0be6a25a..4f1c52d56 100644</div><div>--- a/source/x265.h</div><div>+++ b/source/x265.h</div><div>@@ -1895,12 +1895,6 @@ typedef struct x265_param</div><div> /* The offset by which QP is incremented for non-referenced inter-frames after a scenecut when bEnableSceneCutAwareQp is 1 or 3. */</div><div> double fwdNonRefQpDelta;</div><div> </div><div>- /* A genuine threshold used for histogram based scene cut detection.</div><div>- * This threshold determines whether a frame is a scenecut or not</div><div>- * when compared against the edge and chroma histogram sad values.</div><div>- * Default 0.03. Range: Real number in the interval (0,1). */</div><div>- double edgeTransitionThreshold;</div><div>-</div><div> /* Enables histogram based scenecut detection algorithm to detect scenecuts. Default disabled */</div><div> int bHistBasedSceneCut;</div><div> </div><div>@@ -1990,10 +1984,6 @@ typedef struct x265_param</div><div> * NAL at the end of every Coded Video Sequence. Default false */</div><div> int bEnableEndOfSequence;</div><div> </div><div>- /* Flag to turn on/off traditional scenecut detection in histogram based scenecut detection.</div><div>- * When false, only spatial properties are used for scenecut detection. Default true */</div><div>- int bEnableTradScdInHscd;</div><div>-</div><div> /* Film Grain Characteristic file */</div><div> char* filmGrain;</div><div> </div><div>diff --git a/source/x265cli.cpp b/source/x265cli.cpp</div><div>index d7e6e95c1..54479ef2f 100755</div><div>--- a/source/x265cli.cpp</div><div>+++ b/source/x265cli.cpp</div><div>@@ -174,7 +174,6 @@ namespace X265_NS {</div><div> H1(" --scenecut-bias <0..100.0> Bias for scenecut detection. Default %.2f\n", param->scenecutBias);</div><div> H0(" --hist-scenecut Enables histogram based scene-cut detection using histogram based algorithm.\n");</div><div> H0(" --no-hist-scenecut Disables histogram based scene-cut detection using histogram based algorithm.\n");</div><div>- H1(" --hist-threshold <0.0..1.0> Luma Edge histogram's Normalized SAD threshold for histogram based scenecut detection Default %.2f\n", param->edgeTransitionThreshold);</div><div> H0(" --[no-]fades Enable detection and handling of fade-in regions. Default %s\n", OPT(param->bEnableFades));</div><div> H1(" --scenecut-aware-qp <0..3> Enable increasing QP for frames inside the scenecut window around scenecut. Default %s\n", OPT(param->bEnableSceneCutAwareQp));</div><div> H1(" 0 - Disabled\n");</div><div>diff --git a/source/x265cli.h b/source/x265cli.h</div><div>index 84c3adf25..eea47f168 100644</div><div>--- a/source/x265cli.h</div><div>+++ b/source/x265cli.h</div><div>@@ -143,9 +143,6 @@ static const struct option long_options[] =</div><div> { "scenecut-bias", required_argument, NULL, 0 },</div><div> { "hist-scenecut", no_argument, NULL, 0},</div><div> { "no-hist-scenecut", no_argument, NULL, 0},</div><div>- { "hist-threshold", required_argument, NULL, 0},</div><div>- { "traditional-scenecut", no_argument, NULL, 0},</div><div>- { "no-traditional-scenecut", no_argument, NULL, 0},</div><div> { "fades", no_argument, NULL, 0 },</div><div> { "no-fades", no_argument, NULL, 0 },</div><div> { "scenecut-aware-qp", required_argument, NULL, 0 },</div><div>-- </div><div>2.34.1.windows.1</div><div><br></div><div><div dir="ltr"><div dir="ltr"><div><i><font face="georgia, serif">Thanks and Regards,</font></i></div><div><i><font face="georgia, serif"><b>Snehaa.G</b><br>Video Codec Engineer,<br>Media & AI analytics<br><a href="https://multicorewareinc.com/" target="_blank"><img src="https://ci3.googleusercontent.com/mail-sig/AIorK4yEumXeQ2mgcFAR2us9INa7z3rCbl8ordut3fbdeIbuPv0n3EA75Or1rHs0neGaI0WM8mFPz1g"></a><br><span></span><span></span><br></font></i></div></div></div></div></div></div>
</blockquote></div>