[x265] [PATCH] framepp: Loopfilter cleanup and control by --lpf

Min Chen chenm003 at 163.com
Mon Aug 5 15:12:47 CEST 2013


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1375708174 -28800
# Node ID 2d4e3c4604e3e982446b5f3e62cbedf999babd7a
# Parent  48c6641e19de62b2640ef7d149435fba362d7d81
framepp: Loopfilter cleanup and control by --lpf

diff -r 48c6641e19de -r 2d4e3c4604e3 source/Lib/TLibCommon/TComLoopFilter.cpp
--- a/source/Lib/TLibCommon/TComLoopFilter.cpp	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/Lib/TLibCommon/TComLoopFilter.cpp	Mon Aug 05 21:09:34 2013 +0800
@@ -273,8 +273,8 @@
     UInt uiWidthInBaseUnits  = trWidth / (g_maxCUWidth >> g_maxCUDepth);
     UInt uiHeightInBaseUnits = trHeight / (g_maxCUWidth >> g_maxCUDepth);
 
-    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, EDGE_VER, 0, m_stLFCUParam.bInternalEdge, uiWidthInBaseUnits, uiHeightInBaseUnits);
-    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, EDGE_HOR, 0, m_stLFCUParam.bInternalEdge, uiWidthInBaseUnits, uiHeightInBaseUnits);
+    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, EDGE_VER, 0, true, uiWidthInBaseUnits, uiHeightInBaseUnits);
+    xSetEdgefilterMultiple(cu, absTUPartIdx, depth, EDGE_HOR, 0, true, uiWidthInBaseUnits, uiHeightInBaseUnits);
 }
 
 Void TComLoopFilter::xSetEdgefilterPU(TComDataCU* cu, UInt absZOrderIdx)
@@ -298,38 +298,38 @@
     }
     case SIZE_2NxN:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, uiHHeightInBaseUnits, m_stLFCUParam.bInternalEdge);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, uiHHeightInBaseUnits, true);
         break;
     }
     case SIZE_Nx2N:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, uiHWidthInBaseUnits, m_stLFCUParam.bInternalEdge);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, uiHWidthInBaseUnits, true);
         break;
     }
     case SIZE_NxN:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, uiHWidthInBaseUnits, m_stLFCUParam.bInternalEdge);
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, uiHHeightInBaseUnits, m_stLFCUParam.bInternalEdge);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, uiHWidthInBaseUnits, true);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, uiHHeightInBaseUnits, true);
         break;
     }
     case SIZE_2NxnU:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, uiQHeightInBaseUnits, m_stLFCUParam.bInternalEdge);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, uiQHeightInBaseUnits, true);
         break;
     }
     case SIZE_2NxnD:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, uiHeightInBaseUnits - uiQHeightInBaseUnits, m_stLFCUParam.bInternalEdge);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_HOR, uiHeightInBaseUnits - uiQHeightInBaseUnits, true);
         break;
     }
     case SIZE_nLx2N:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, uiQWidthInBaseUnits, m_stLFCUParam.bInternalEdge);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, uiQWidthInBaseUnits, true);
         break;
     }
     case SIZE_nRx2N:
     {
-        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, uiWidthInBaseUnits - uiQWidthInBaseUnits, m_stLFCUParam.bInternalEdge);
+        xSetEdgefilterMultiple(cu, absZOrderIdx, depth, EDGE_VER, uiWidthInBaseUnits - uiQWidthInBaseUnits, true);
         break;
     }
     default:
@@ -347,7 +347,8 @@
     TComDataCU* pcTempCU;
     UInt        uiTempPartIdx;
 
-    m_stLFCUParam.bInternalEdge = !cu->getSlice()->getDeblockingFilterDisable();
+    // We can't here when DeblockingDisable flag is true
+    assert(!cu->getSlice()->getDeblockingFilterDisable());
 
     if ((uiX == 0) || cu->getSlice()->getDeblockingFilterDisable())
     {
diff -r 48c6641e19de -r 2d4e3c4604e3 source/Lib/TLibCommon/TComLoopFilter.h
--- a/source/Lib/TLibCommon/TComLoopFilter.h	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/Lib/TLibCommon/TComLoopFilter.h	Mon Aug 05 21:09:34 2013 +0800
@@ -49,7 +49,6 @@
 /// parameters for deblocking filter
 typedef struct _LFCUParam
 {
-    Bool bInternalEdge;                   ///< indicates internal edge
     Bool bLeftEdge;                       ///< indicates left edge
     Bool bTopEdge;                        ///< indicates top edge
 } LFCUParam;
diff -r 48c6641e19de -r 2d4e3c4604e3 source/Lib/TLibEncoder/TEncGOP.cpp
--- a/source/Lib/TLibEncoder/TEncGOP.cpp	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncGOP.cpp	Mon Aug 05 21:09:34 2013 +0800
@@ -574,8 +574,11 @@
         }
 
         //-- Loop filter
-        loopFilter->setCfg(m_pps.getLoopFilterAcrossTilesEnabledFlag());
-        loopFilter->loopFilterPic(pic);
+        if (m_cfg->param.bEnableLoopFilter)
+        {
+            loopFilter->setCfg(m_pps.getLoopFilterAcrossTilesEnabledFlag());
+            loopFilter->loopFilterPic(pic);
+        }
 
         if (m_sps.getUseSAO())
         {
diff -r 48c6641e19de -r 2d4e3c4604e3 source/Lib/TLibEncoder/TEncSlice.cpp
--- a/source/Lib/TLibEncoder/TEncSlice.cpp	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSlice.cpp	Mon Aug 05 21:09:34 2013 +0800
@@ -255,8 +255,8 @@
     {
         slice->getPPS()->setDeblockingFilterOverrideEnabledFlag(!m_cfg->getLoopFilterOffsetInPPS());
         slice->setDeblockingFilterOverrideFlag(!m_cfg->getLoopFilterOffsetInPPS());
-        slice->getPPS()->setPicDisableDeblockingFilterFlag(m_cfg->getLoopFilterDisable());
-        slice->setDeblockingFilterDisable(m_cfg->getLoopFilterDisable());
+        slice->getPPS()->setPicDisableDeblockingFilterFlag(!m_cfg->param.bEnableLoopFilter);
+        slice->setDeblockingFilterDisable(!m_cfg->param.bEnableLoopFilter);
         if (!slice->getDeblockingFilterDisable())
         {
             if (!m_cfg->getLoopFilterOffsetInPPS() && sliceType != I_SLICE)
diff -r 48c6641e19de -r 2d4e3c4604e3 source/common/common.cpp
--- a/source/common/common.cpp	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/common/common.cpp	Mon Aug 05 21:09:34 2013 +0800
@@ -126,6 +126,7 @@
     param->bEnableRectInter = 1;
     param->bEnableRDO = 1;
     param->qp = 32;
+    param->bEnableLoopFilter = 1;
     param->bEnableSAO = 1;
     param->bEnableWavefront = 1;
     param->saoLcuBasedOptimization = 1;
@@ -338,6 +339,7 @@
     else
         fprintf(stderr, "no-rdo ");
     TOOLOPT(param->bEnableRDOQ, "rdoq");
+    TOOLOPT(param->bEnableLoopFilter, "lpf");
     if (param->bEnableSAO)
     {
         TOOLOPT(param->bEnableSAO, "sao");
diff -r 48c6641e19de -r 2d4e3c4604e3 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/encoder/encoder.cpp	Mon Aug 05 21:09:34 2013 +0800
@@ -191,12 +191,12 @@
 
     //====== Enforce these hard coded settings before initializeGOP() to
     //       avoid a valgrind warning
-    m_bLoopFilterDisable = 0;
+    m_bLoopFilterDisable = !_param->bEnableLoopFilter;
     m_loopFilterOffsetInPPS = 0;
     m_loopFilterBetaOffsetDiv2 = 0;
     m_loopFilterTcOffsetDiv2 = 0;
     m_loopFilterAcrossTilesEnabledFlag = 1;
-    m_deblockingFilterControlPresent = 0;
+    m_deblockingFilterControlPresent = m_bLoopFilterDisable;
 
     //====== HM Settings not exposed for configuration ======
     initializeGOP(_param);
diff -r 48c6641e19de -r 2d4e3c4604e3 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/encoder/frameencoder.cpp	Mon Aug 05 21:09:34 2013 +0800
@@ -155,7 +155,10 @@
         m_sao.destroy();
         m_sao.destroyEncBuffer();
     }
-    m_loopFilter.destroy();
+    if (m_cfg->param.bEnableLoopFilter)
+    {
+        m_loopFilter.destroy();
+    }
 }
 
 void FrameEncoder::init(TEncTop *top, int numRows)
@@ -173,7 +176,10 @@
         m_sao.create(top->param.sourceWidth, top->param.sourceHeight, g_maxCUWidth, g_maxCUHeight);
         m_sao.createEncBuffer();
     }
-    m_loopFilter.create(g_maxCUDepth);
+    if (top->param.bEnableLoopFilter)
+    {
+        m_loopFilter.create(g_maxCUDepth);
+    }
 
     m_rows = new CTURow[m_numRows];
     for (int i = 0; i < m_numRows; ++i)
diff -r 48c6641e19de -r 2d4e3c4604e3 source/x265.h
--- a/source/x265.h	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/x265.h	Mon Aug 05 21:09:34 2013 +0800
@@ -202,6 +202,9 @@
     int       bEnableTSkipFast;                ///< enable fast intra transform skipping
     int       bEnableRDOQTS;                   ///< enable RD optimized quantization when transform skip is selected
 
+    // loop filter
+    int       bEnableLoopFilter;               ///< Disable Loop Filter
+
     // SAO loop filter
     int       bEnableSAO;                      ///< Enable SAO filter
     int       saoLcuBoundary;                  ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
diff -r 48c6641e19de -r 2d4e3c4604e3 source/x265opts.h
--- a/source/x265opts.h	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/x265opts.h	Mon Aug 05 21:09:34 2013 +0800
@@ -79,6 +79,10 @@
 OPT("signhide",        param->bEnableSignHiding,            no_argument, 0, "Hide sign bit of one coeff per TU (rdo)")
 OPT("no-signhide",     param->bEnableSignHiding,            no_argument, 0, "Disable hide sign bit of one coeff per TU (rdo)")
 
+HELP("Loop filter:")
+OPT("lpf",             param->bEnableLoopFilter,            no_argument, 0, "Enable Loop Filter")
+OPT("no-lpf",          param->bEnableLoopFilter,            no_argument, 0, "Disable Loop Filter")
+
 HELP("Sample Adaptive Offset loop filter:")
 OPT("sao",             param->bEnableSAO,                   no_argument, 0, "Enable Sample Adaptive Offset")
 OPT("no-sao",          param->bEnableSAO,                   no_argument, 0, "Disable Sample Adaptive Offset")



More information about the x265-devel mailing list