[x265] [PATCH 07/10] search range optimization - 1

Anusuya Kumarasamy anusuya.kumarasamy at multicorewareinc.com
Mon Nov 11 14:20:29 UTC 2024


>From 1b4c75031d7ebe6a52fd87f3b1850d924067189c Mon Sep 17 00:00:00 2001
From: Karam Singh <karam.singh at multicorewareinc.com>
Date: Thu, 24 Oct 2024 18:04:04 +0530
Subject: [PATCH 07/10] search range optimization - 1

---
 source/common/param.cpp          | 6 ++++++
 source/common/temporalfilter.cpp | 8 ++++----
 source/common/temporalfilter.h   | 2 +-
 source/encoder/slicetype.cpp     | 6 +++---
 source/x265.h                    | 4 ++++
 5 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/source/common/param.cpp b/source/common/param.cpp
index 1beb3c056..195937f5e 100755
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -418,6 +418,9 @@ void x265_param_default(x265_param* param)
     /* MCSTF */
     param->bEnableTemporalFilter = 0;
     param->temporalFilterStrength = 0.95;
+    param->searchRangeForLayer0 = 3;
+    param->searchRangeForLayer1 = 3;
+    param->searchRangeForLayer2 = 3;

     /*Alpha Channel Encoding*/
     param->bEnableAlpha = 0;
@@ -2985,6 +2988,9 @@ void x265_copy_params(x265_param* dst, x265_param*
src)
     dst->bField = src->bField;
     dst->bEnableTemporalFilter = src->bEnableTemporalFilter;
     dst->temporalFilterStrength = src->temporalFilterStrength;
+    dst->searchRangeForLayer0 = src->searchRangeForLayer0;
+    dst->searchRangeForLayer1 = src->searchRangeForLayer1;
+    dst->searchRangeForLayer2 = src->searchRangeForLayer2;
     dst->confWinRightOffset = src->confWinRightOffset;
     dst->confWinBottomOffset = src->confWinBottomOffset;
     dst->bliveVBV2pass = src->bliveVBV2pass;
diff --git a/source/common/temporalfilter.cpp
b/source/common/temporalfilter.cpp
index 7c1be767e..521e367c8 100644
--- a/source/common/temporalfilter.cpp
+++ b/source/common/temporalfilter.cpp
@@ -649,10 +649,10 @@ void TemporalFilter::bilateralFilter(Frame* frame,
 }

 void TemporalFilter::motionEstimationLuma(MV *mvs, uint32_t mvStride,
pixel* src,int stride, int height, int width, pixel* buf, int blockSize,
-    MV *previous, uint32_t prevMvStride, int factor)
+    int sRange, MV* previous, uint32_t prevMvStride, int factor)
 {

-    int range = 5;
+    int range = sRange;


     const int stepSize = blockSize;
@@ -675,7 +675,7 @@ void TemporalFilter::motionEstimationLuma(MV *mvs,
uint32_t mvStride, pixel* src

             if (previous == NULL)
             {
-                range = 8;
+                range = sRange;
             }
             else
             {
@@ -893,7 +893,7 @@ void TemporalFilter::motionEstimationLumaDoubleRes(MV
*mvs, uint32_t mvStride, P
             }

             prevBest = best;
-            int doubleRange = 3 * 4;
+            int doubleRange = 1 * 4;
             for (int y2 = prevBest.y - doubleRange; y2 <= prevBest.y +
doubleRange; y2 += 4)
             {
                 for (int x2 = prevBest.x - doubleRange; x2 <= prevBest.x +
doubleRange; x2 += 4)
diff --git a/source/common/temporalfilter.h b/source/common/temporalfilter.h
index 1cd8028c7..3e03d7737 100644
--- a/source/common/temporalfilter.h
+++ b/source/common/temporalfilter.h
@@ -155,7 +155,7 @@ namespace X265_NS {

         void bilateralFilter(Frame* frame, TemporalFilterRefPicInfo*
mctfRefList, double overallStrength);

-        void motionEstimationLuma(MV *mvs, uint32_t mvStride, pixel* src,
int stride, int height, int width, pixel* buf, int bs,
+        void motionEstimationLuma(MV *mvs, uint32_t mvStride, pixel* src,
int stride, int height, int width, pixel* buf, int bs, int sRange,
             MV *previous = 0, uint32_t prevmvStride = 0, int factor = 1);

         void motionEstimationLumaDoubleRes(MV *mvs, uint32_t mvStride,
PicYuv *orig, PicYuv *buffer, int blockSize,
diff --git a/source/encoder/slicetype.cpp b/source/encoder/slicetype.cpp
index bd9f0793a..5fd885227 100644
--- a/source/encoder/slicetype.cpp
+++ b/source/encoder/slicetype.cpp
@@ -1801,9 +1801,9 @@ void Lookahead::estimatelowresmotion(Frame* curframe)
     {
         TemporalFilterRefPicInfo * ref = &curframe->m_mcstfRefList[i - 1];

-        curframe->m_mcstf->motionEstimationLuma(ref->mvs0,
ref->mvsStride0, curframe->m_lowres.lowerResPlane[0],
(curframe->m_lowres.lumaStride / 2), (curframe->m_lowres.lines / 2),
(curframe->m_lowres.width / 2), ref->lowerRes, 16);
-        curframe->m_mcstf->motionEstimationLuma(ref->mvs1,
ref->mvsStride1, curframe->m_lowres.lowresPlane[0],
(curframe->m_lowres.lumaStride), (curframe->m_lowres.lines),
(curframe->m_lowres.width), ref->lowres, 16, ref->mvs0, ref->mvsStride0, 2);
-        curframe->m_mcstf->motionEstimationLuma(ref->mvs2,
ref->mvsStride2, curframe->m_fencPic->m_picOrg[0],
curframe->m_fencPic->m_stride, curframe->m_fencPic->m_picHeight,
curframe->m_fencPic->m_picWidth, ref->picBuffer->m_picOrg[0], 16,
ref->mvs1, ref->mvsStride1, 2);
+        curframe->m_mcstf->motionEstimationLuma(ref->mvs0,
ref->mvsStride0, curframe->m_lowres.lowerResPlane[0],
(curframe->m_lowres.lumaStride / 2), (curframe->m_lowres.lines / 2),
(curframe->m_lowres.width / 2), ref->lowerRes, 16,
m_param->searchRangeForLayer2);
+        curframe->m_mcstf->motionEstimationLuma(ref->mvs1,
ref->mvsStride1, curframe->m_lowres.lowresPlane[0],
(curframe->m_lowres.lumaStride), (curframe->m_lowres.lines),
(curframe->m_lowres.width), ref->lowres, 16, m_param->searchRangeForLayer1,
ref->mvs0, ref->mvsStride0, 2);
+        curframe->m_mcstf->motionEstimationLuma(ref->mvs2,
ref->mvsStride2, curframe->m_fencPic->m_picOrg[0],
curframe->m_fencPic->m_stride, curframe->m_fencPic->m_picHeight,
curframe->m_fencPic->m_picWidth, ref->picBuffer->m_picOrg[0], 16,
m_param->searchRangeForLayer0, ref->mvs1, ref->mvsStride1, 2);
         curframe->m_mcstf->motionEstimationLumaDoubleRes(ref->mvs,
ref->mvsStride, curframe->m_fencPic, ref->picBuffer, 8, ref->mvs2,
ref->mvsStride2, 1, ref->error);
     }

diff --git a/source/x265.h b/source/x265.h
index 13c4a47e2..b4dceb406 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -2314,6 +2314,10 @@ typedef struct x265_param
     /*Motion compensated temporal filter*/
     int      bEnableTemporalFilter;
     double   temporalFilterStrength;
+    /*Search Range for L0, L1 and L2 in MCTF*/
+    int      searchRangeForLayer0;
+    int      searchRangeForLayer1;
+    int      searchRangeForLayer2;

     /*SBRC*/
     int      bEnableSBRC;
-- 
2.36.0.windows.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20241111/5a42661e/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-search-range-optimization-1.patch
Type: application/octet-stream
Size: 6320 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20241111/5a42661e/attachment.obj>


More information about the x265-devel mailing list