[x265] [PATCH] Updated mcstf filter to use two reference frames for fast presets
Pavan Tarun Chakka Venkata
pavan.tarun at multicorewareinc.com
Tue Jul 9 06:58:10 UTC 2024
>From 9fa5285d5dcb13b9baa682627803150d4b49f3d5 Mon Sep 17 00:00:00 2001
From: Pavan Tarun <pavan.tarun at multicorewareinc.com>
Date: Tue, 2 Jul 2024 14:31:39 +0530
Subject: [PATCH] Updated mcstf filter to use two reference frames for fast
presets
---
source/common/frame.cpp | 1 +
source/common/param.cpp | 10 +++++++++-
source/encoder/encoder.cpp | 4 ++++
source/x265.h | 1 +
4 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/source/common/frame.cpp b/source/common/frame.cpp
index ae3773e..7947433 100644
--- a/source/common/frame.cpp
+++ b/source/common/frame.cpp
@@ -85,6 +85,7 @@ bool Frame::create(x265_param *param, float* quantOffsets)
if (m_param->bEnableTemporalFilter)
{
m_mcstf = new TemporalFilter;
+ m_mcstf->m_range = param->mcstfFrameRange;
m_mcstf->init(param);
m_fencPicSubsampled2 = new PicYuv;
diff --git a/source/common/param.cpp b/source/common/param.cpp
index e90b08e..5b29225 100755
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -183,6 +183,7 @@ void x265_param_default(x265_param* param)
param->bEnableSceneCutAwareQp = 0;
param->fwdMaxScenecutWindow = 1200;
param->bwdMaxScenecutWindow = 600;
+ param->mcstfFrameRange = 2;
for (int i = 0; i < 6; i++)
{
int deltas[6] = { 5, 4, 3, 2, 1, 0 };
@@ -417,6 +418,7 @@ int x265_param_default_preset(x265_param* param, const
char* preset, const char*
if (!strcmp(preset, "ultrafast"))
{
+ param->mcstfFrameRange = 1;
param->maxNumMergeCand = 2;
param->bIntraInBFrames = 0;
param->lookaheadDepth = 5;
@@ -441,6 +443,7 @@ int x265_param_default_preset(x265_param* param, const
char* preset, const char*
}
else if (!strcmp(preset, "superfast"))
{
+ param->mcstfFrameRange = 1;
param->maxNumMergeCand = 2;
param->bIntraInBFrames = 0;
param->lookaheadDepth = 10;
@@ -461,6 +464,7 @@ int x265_param_default_preset(x265_param* param, const
char* preset, const char*
}
else if (!strcmp(preset, "veryfast"))
{
+ param->mcstfFrameRange = 1;
param->maxNumMergeCand = 2;
param->limitReferences = 3;
param->bIntraInBFrames = 0;
@@ -474,6 +478,7 @@ int x265_param_default_preset(x265_param* param, const
char* preset, const char*
}
else if (!strcmp(preset, "faster"))
{
+ param->mcstfFrameRange = 1;
param->maxNumMergeCand = 2;
param->limitReferences = 3;
param->bIntraInBFrames = 0;
@@ -485,6 +490,7 @@ int x265_param_default_preset(x265_param* param, const
char* preset, const char*
}
else if (!strcmp(preset, "fast"))
{
+ param->mcstfFrameRange = 1;
param->maxNumMergeCand = 2;
param->limitReferences = 3;
param->bEnableEarlySkip = 0;
@@ -497,6 +503,7 @@ int x265_param_default_preset(x265_param* param, const
char* preset, const char*
}
else if (!strcmp(preset, "medium"))
{
+ param->mcstfFrameRange = 1;
/* defaults */
}
else if (!strcmp(preset, "slow"))
@@ -1674,7 +1681,7 @@ int x265_check_params(x265_param* param)
CHECK(param->edgeVarThreshold < 0.0f || param->edgeVarThreshold >
1.0f,
"Minimum edge density percentage for a CU should be an
integer between 0 to 100");
}
- CHECK(param->bframes && param->bframes >= param->lookaheadDepth &&
!param->rc.bStatRead,
+ CHECK(param->bframes && (param->bEnableTemporalFilter ?
(param->bframes > param->lookaheadDepth) : (param->bframes >=
param->lookaheadDepth)) && !param->rc.bStatRead,
"Lookahead depth must be greater than the max consecutive bframe
count");
CHECK(param->bframes < 0,
"bframe count should be greater than zero");
@@ -2558,6 +2565,7 @@ bool parseMaskingStrength(x265_param* p, const char*
value)
void x265_copy_params(x265_param* dst, x265_param* src)
{
+ dst->mcstfFrameRange = src->mcstfFrameRange;
dst->cpuid = src->cpuid;
dst->frameNumThreads = src->frameNumThreads;
if (src->numaPools) dst->numaPools = strdup(src->numaPools);
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index 8620a48..0f188e6 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -3907,6 +3907,10 @@ void Encoder::configure(x265_param *p)
p->limitReferences = 0;
}
+ if ((m_param->bEnableTemporalFilter) && (p->bframes < 5)){
+ x265_log(p, X265_LOG_WARNING, "Setting the number of B-frames to
5, as MCSTF filter is enabled.\n");
+ p->bframes = 5;
+ }
if ((p->bEnableTemporalSubLayers > 2) && !p->bframes)
{
x265_log(p, X265_LOG_WARNING, "B frames not enabled, temporal
sublayer disabled\n");
diff --git a/source/x265.h b/source/x265.h
index 4452526..c48b864 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -2268,6 +2268,7 @@ typedef struct x265_param
/*SBRC*/
int bEnableSBRC;
+ int mcstfFrameRange;
} x265_param;
/* x265_param_alloc:
--
1.8.3.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240709/17b6c18d/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Updated-mcstf-filter-to-use-two-reference-frames-for.patch
Type: application/octet-stream
Size: 5241 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20240709/17b6c18d/attachment.obj>
More information about the x265-devel
mailing list