[x265] [PATCH 7/14] Motion compensate and apply bilateral filter on mctf frames
Snehaa Giridharan
snehaa at multicorewareinc.com
Wed Oct 19 07:30:15 UTC 2022
>From c6ba808838338d4c4e7c1bf1e364c44cd32608ee Mon Sep 17 00:00:00 2001
From: ashok2022 <ashok at multicorewareinc.com>
Date: Wed, 21 Sep 2022 18:18:48 +0530
Subject: [PATCH] Motion compensate and apply bilateral filter on mctf frames
---
source/encoder/frameencoder.cpp | 43 +++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/source/encoder/frameencoder.cpp
b/source/encoder/frameencoder.cpp
index 9dc9242f6..0a44eb22f 100644
--- a/source/encoder/frameencoder.cpp
+++ b/source/encoder/frameencoder.cpp
@@ -34,6 +34,7 @@
#include "common.h"
#include "slicetype.h"
#include "nal.h"
+#include "temporalfilter.h"
namespace X265_NS {
void weightAnalyse(Slice& slice, Frame& frame, x265_param& param);
@@ -101,6 +102,14 @@ void FrameEncoder::destroy()
delete m_rce.picTimingSEI;
delete m_rce.hrdTiming;
}
+
+ if (m_param->bEnableGopBasedTemporalFilter)
+ {
+ for (int i = 0; i < (m_frameEncTF->s_range << 1); i++)
+ m_frameEncTF->destroyRefPicInfo(&m_mcstfRefList[i]);
+
+ delete m_frameEncTF;
+ }
}
bool FrameEncoder::init(Encoder *top, int numRows, int numCols)
@@ -195,6 +204,16 @@ bool FrameEncoder::init(Encoder *top, int numRows, int
numCols)
m_sliceAddrBits = (uint16_t)(tmp + 1);
}
+ if (m_param->bEnableGopBasedTemporalFilter)
+ {
+ m_frameEncTF = new TemporalFilter();
+ if (m_frameEncTF)
+ m_frameEncTF->init(m_param);
+
+ for (int i = 0; i < (m_frameEncTF->s_range << 1); i++)
+ ok &= !!m_frameEncTF->createRefPicInfo(&m_mcstfRefList[i],
m_param);
+ }
+
return ok;
}
@@ -579,6 +598,13 @@ void FrameEncoder::compressFrame()
int qp = m_top->m_rateControl->rateControlStart(m_frame, &m_rce,
m_top);
m_rce.newQp = qp;
+ if (m_param->bEnableGopBasedTemporalFilter)
+ {
+ m_frameEncTF->m_QP = qp;
+ double overallStrength = 0.95;
+ m_frameEncTF->bilateralFilter(m_frame, m_mcstfRefList,
overallStrength);
+ }
+
if (m_nr)
{
if (qp > QP_MAX_SPEC && m_frame->m_param->rc.vbvBufferSize)
@@ -946,6 +972,23 @@ void FrameEncoder::compressFrame()
if (m_param->bDynamicRefine && m_top->m_startPoint <=
m_frame->m_encodeOrder) //Avoid collecting data that will not be used by
future frames.
collectDynDataFrame();
+ if (m_param->bEnableGopBasedTemporalFilter &&
m_top->isFilterThisframe(m_frame->m_mcstf->m_sliceTypeConfig,
m_frame->m_lowres.sliceType))
+ {
+ //Reset the MCTF context in Frame Encoder and Frame
+ for (int i = 0; i < (m_frameEncTF->s_range << 1); i++)
+ {
+ memset(m_mcstfRefList[i].mvs0, 0, sizeof(MV) *
((m_param->sourceWidth / 16) * (m_param->sourceHeight / 16)));
+ memset(m_mcstfRefList[i].mvs1, 0, sizeof(MV) *
((m_param->sourceWidth / 16) * (m_param->sourceHeight / 16)));
+ memset(m_mcstfRefList[i].mvs2, 0, sizeof(MV) *
((m_param->sourceWidth / 16) * (m_param->sourceHeight / 16)));
+ memset(m_mcstfRefList[i].mvs, 0, sizeof(MV) *
((m_param->sourceWidth / 4) * (m_param->sourceHeight / 4)));
+ memset(m_mcstfRefList[i].noise, 0, sizeof(int) *
((m_param->sourceWidth / 4) * (m_param->sourceHeight / 4)));
+ memset(m_mcstfRefList[i].error, 0, sizeof(int) *
((m_param->sourceWidth / 4) * (m_param->sourceHeight / 4)));
+
+ m_frame->m_mcstf->m_numRef = 0;
+ }
+ }
+
+
if (m_param->rc.bStatWrite)
{
int totalI = 0, totalP = 0, totalSkip = 0;
--
2.34.1.windows.1
*Thanks and Regards,*
*Snehaa.GVideo Codec Engineer,Media & AI analytics
<https://multicorewareinc.com/>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20221019/919c5d6b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mcstf_patch_07.diff
Type: application/octet-stream
Size: 3560 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20221019/919c5d6b/attachment.obj>
More information about the x265-devel
mailing list