[x265] [PATCH] Fix segmentation fault in scc
Anusuya Kumarasamy
anusuya.kumarasamy at multicorewareinc.com
Fri Sep 27 10:02:48 UTC 2024
>From 03db2eab9c3d38d3d9c2f5305a2d42ee2ca2035f Mon Sep 17 00:00:00 2001
From: AnusuyaKumarasamy <anusuya.kumarasamy at multicorewareinc.com>
Date: Fri, 20 Sep 2024 16:31:31 +0530
Subject: [PATCH 2/5] Fix segmentation fault in scc
---
source/common/cudata.cpp | 6 +++---
source/encoder/analysis.cpp | 2 +-
source/encoder/encoder.cpp | 6 ++++++
source/encoder/search.cpp | 8 ++++----
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/source/common/cudata.cpp b/source/common/cudata.cpp
index 23ceeaeaf..ae1fb4694 100644
--- a/source/common/cudata.cpp
+++ b/source/common/cudata.cpp
@@ -2378,9 +2378,9 @@ void CUData::getIntraBCMVPsEncOnly(uint32_t
absPartIdx, MV* MvPred, int& nbPred,
uint32_t m_numPartitionsInCtu = s_numPartInCUSize *
s_numPartInCUSize;
uint32_t m_frameWidthInCtus =
(m_slice->m_sps->picWidthInLumaSamples % m_slice->m_param->maxCUSize) ?
m_slice->m_sps->picWidthInLumaSamples / m_slice->m_param->maxCUSize + 1 :
m_slice->m_sps->picWidthInLumaSamples / m_slice->m_param->maxCUSize;
- uint32_t partIdxLT = m_absIdxInCTU + absPartIdx;
- uint32_t partIdxLB =
g_rasterToZscan[g_zscanToRaster[partIdxLT] + (height / 4 - 1) *
numPartInCUWidth];
- uint32_t partIdxRT =
g_rasterToZscan[g_zscanToRaster[partIdxLT] + width / 4 - 1];
+ uint32_t partIdxLT = m_absIdxInCTU;
+ uint32_t partIdxLB =
g_rasterToZscan[g_zscanToRaster[m_absIdxInCTU] + (((1 << (m_log2CUSize[0] -
LOG2_UNIT_SIZE - 1)) - 1) << LOG2_RASTER_SIZE)];
+ uint32_t partIdxRT =
g_rasterToZscan[g_zscanToRaster[partIdxLT] + (1 << (m_log2CUSize[0] -
LOG2_UNIT_SIZE)) - 1];
left = above = 0;
diff --git a/source/encoder/analysis.cpp b/source/encoder/analysis.cpp
index 53a19b29f..d60747cc0 100644
--- a/source/encoder/analysis.cpp
+++ b/source/encoder/analysis.cpp
@@ -3623,7 +3623,7 @@ void Analysis::checkBidir2Nx2N(Mode& inter2Nx2N,
Mode& bidir2Nx2N, const CUGeom&
CUData& cu = bidir2Nx2N.cu;
#if ENABLE_SCC_EXT
- if ((cu.is8x8BipredRestriction(inter2Nx2N.bestME[0][0].mv,
inter2Nx2N.bestME[0][1].mv, inter2Nx2N.bestME[0][0].ref,
inter2Nx2N.bestME[0][1].ref) ? (cu.m_cuDepth[0] == 3) :
cu.isBipredRestriction()) || inter2Nx2N.bestME[0][0].cost == MAX_UINT ||
inter2Nx2N.bestME[0][1].cost == MAX_UINT)
+ if ((cu.is8x8BipredRestriction(inter2Nx2N.bestME[0][0].mv,
inter2Nx2N.bestME[0][1].mv, inter2Nx2N.bestME[0][0].ref,
inter2Nx2N.bestME[0][1].ref) ? (1 << cu.m_log2CUSize[0] == 8) :
cu.isBipredRestriction()) || inter2Nx2N.bestME[0][0].cost == MAX_UINT ||
inter2Nx2N.bestME[0][1].cost == MAX_UINT)
#else
if (cu.isBipredRestriction() || inter2Nx2N.bestME[0][0].cost ==
MAX_UINT || inter2Nx2N.bestME[0][1].cost == MAX_UINT)
#endif
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index 82123606c..f4a998fa9 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -4715,6 +4715,12 @@ void Encoder::configure(x265_param *p)
p->keyframeMin = p->keyframeMax;
}
}
+
+ if (!!p->bEnableSCC && p->maxNumReferences == 1)
+ {
+ x265_log(p, X265_LOG_WARNING, "Screen Content Coding requies
maximum number of references should be atleast greater than 1.Increamenting
by one.\n");
+ p->maxNumReferences++;
+ }
}
void Encoder::readAnalysisFile(x265_analysis_data* analysis, int curPoc,
const x265_picture* picIn, int paramBytes)
diff --git a/source/encoder/search.cpp b/source/encoder/search.cpp
index 0df11b431..ebd85dd52 100644
--- a/source/encoder/search.cpp
+++ b/source/encoder/search.cpp
@@ -3503,7 +3503,7 @@ void Search::setIntraSearchRange(Mode& intraBCMode,
MV& pred, int puIdx, int roi
const uint32_t picWidth = m_slice->m_sps->picWidthInLumaSamples;
const uint32_t picHeight = m_slice->m_sps->picHeightInLumaSamples;
bool isFullFrameSearchrangeEnabled = false; // disabled by default
- if (cu.m_cuDepth[0] == 2 && cu.m_partSize[0] == SIZE_2Nx2N &&
isFullFrameSearchrangeEnabled)// full frame search
+ if (1 << cu.m_log2CUSize[0] == 16 && cu.m_partSize[0] == SIZE_2Nx2N &&
isFullFrameSearchrangeEnabled)// full frame search
{
srLeft = -1 * cuPelX;
srTop = -1 * cuPelY;
@@ -3513,7 +3513,7 @@ void Search::setIntraSearchRange(Mode& intraBCMode,
MV& pred, int puIdx, int roi
}
else
{
- const uint32_t searchWidthInCTUs = cu.m_cuDepth[0] == 3 ? 1 :
(isFullFrameSearchrangeEnabled) ? -1 : 1;
+ const uint32_t searchWidthInCTUs = 1 << cu.m_log2CUSize[0] == 8 ?
1 : (isFullFrameSearchrangeEnabled) ? -1 : 1;
uint32_t width = 0, maxWidth = searchWidthInCTUs * lcuWidth;
for (const CUData* pTestCU = cu.m_cuLeft;
width < maxWidth && pTestCU != NULL && pTestCU->m_slice !=
NULL;
@@ -3718,7 +3718,7 @@ bool Search::predIntraBCSearch(Mode& intraBCMode,
const CUGeom& cuGeom, bool bCh
if (ePartSize != SIZE_2Nx2N)
{
- if (log2ParallelMergeLevelMinus2 && ePartSize != SIZE_2Nx2N &&
cu.m_cuDepth[0] >= 3)
+ if (log2ParallelMergeLevelMinus2 && ePartSize != SIZE_2Nx2N &&
1 << cu.m_log2CUSize[0] >= 8)
{
cu.setPartSizeSubParts(SIZE_2Nx2N);
if (puIdx == 0)
@@ -4010,7 +4010,7 @@ bool Search::predMixedIntraBCInterSearch(Mode&
intraBCMixedMode, const CUGeom& c
if (ePartSize != SIZE_2Nx2N)
{
- if (log2ParallelMergeLevelMinus2 && ePartSize !=
SIZE_2Nx2N && cu.m_cuDepth[0] >= 3)
+ if (log2ParallelMergeLevelMinus2 && ePartSize !=
SIZE_2Nx2N && 1 << cu.m_log2CUSize[0] >= 8)
{
cu.setPartSizeSubParts(SIZE_2Nx2N);
if (partIdx == 0)
--
2.36.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240927/f5f825bc/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Fix-segmentation-fault-in-scc.patch
Type: application/octet-stream
Size: 5802 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240927/f5f825bc/attachment-0001.obj>
More information about the x265-devel
mailing list