[x265] [PATCH RFC] pps: simplify loop filter configuration and signaling

Steve Borho steve at borho.org
Thu Jul 17 09:38:57 CEST 2014


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1405582706 18000
#      Thu Jul 17 02:38:26 2014 -0500
# Node ID cef8e22586d59024c3bc58f9710864a0e0341cfd
# Parent  f0d157944c556ab6ea77060b5c49093e356664df
pps: simplify loop filter configuration and signaling

Today we really only have one param (enable/disable). I am assuming that at some
point in the future we will make the deblocking offsets tunable, so I am
leaving those two fields in the PPS and treating them as if they might have
been configured.

The HM functions for signaling the deblocking state are seriously convoluted,
but I believe I have distilled the correct sequences for the three general
states of: (ON, OFF, ON w/ custom offsets)

diff -r f0d157944c55 -r cef8e22586d5 source/Lib/TLibCommon/TComSlice.h
--- a/source/Lib/TLibCommon/TComSlice.h	Thu Jul 17 00:37:00 2014 -0500
+++ b/source/Lib/TLibCommon/TComSlice.h	Thu Jul 17 02:38:26 2014 -0500
@@ -272,11 +272,9 @@
     bool     bCabacInitPresent;
     uint32_t encCABACTableIdx;          // Used to transmit table selection across slices
 
-    bool     bDeblockingFilterControlPresent;
-    bool     bDeblockingFilterOverrideEnabled;
-    bool     bPicDisableDeblockingFilter;
-    int      deblockingFilterBetaOffsetDiv2;
-    int      deblockingFilterTcOffsetDiv2;
+    bool     bDeblockDisabled;
+    int      deblockBetaOffset;
+    int      deblockTCOffset;
 };
 
 typedef struct wpScalingParam
diff -r f0d157944c55 -r cef8e22586d5 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Jul 17 00:37:00 2014 -0500
+++ b/source/encoder/encoder.cpp	Thu Jul 17 02:38:26 2014 -0500
@@ -1206,15 +1206,9 @@
     pps->bTransformSkipEnabled = m_param->bEnableTransformSkip;
     pps->bSignHideEnabled = m_param->bEnableSignHiding;
 
-    m_loopFilterOffsetInPPS = 0;
-    m_loopFilterBetaOffsetDiv2 = 0;
-    m_loopFilterTcOffsetDiv2 = 0;
-
-    pps->bDeblockingFilterControlPresent = !m_param->bEnableLoopFilter;
-    pps->bPicDisableDeblockingFilter = !m_param->bEnableLoopFilter;
-    pps->bDeblockingFilterOverrideEnabled = !m_loopFilterOffsetInPPS;
-    pps->deblockingFilterBetaOffsetDiv2 = m_loopFilterBetaOffset;
-    pps->deblockingFilterTcOffsetDiv2 = m_loopFilterTcOffset;
+    pps->bDeblockDisabled = !m_param->bEnableLoopFilter;
+    pps->deblockBetaOffset = 0; // TODO: make these params?
+    pps->deblockTCOffset = 0;
 
     // options affected by parallelization
     pps->bEntropyCodingSyncEnabled = m_param->bEnableWavefront;
diff -r f0d157944c55 -r cef8e22586d5 source/encoder/encoder.h
--- a/source/encoder/encoder.h	Thu Jul 17 00:37:00 2014 -0500
+++ b/source/encoder/encoder.h	Thu Jul 17 02:38:26 2014 -0500
@@ -130,12 +130,6 @@
     uint32_t           m_quadtreeTULog2MaxSize;
     uint32_t           m_quadtreeTULog2MinSize;
 
-    //====== Loop/Deblock Filter ========
-    bool               m_loopFilterOffsetInPPS;
-    int                m_loopFilterBetaOffset;
-    int                m_loopFilterBetaOffsetDiv2;
-    int                m_loopFilterTcOffset;
-    int                m_loopFilterTcOffsetDiv2;
     int                m_maxNumOffsetsPerPic;
 
     //====== Quality control ========
diff -r f0d157944c55 -r cef8e22586d5 source/encoder/entropy.cpp
--- a/source/encoder/entropy.cpp	Thu Jul 17 00:37:00 2014 -0500
+++ b/source/encoder/entropy.cpp	Thu Jul 17 02:38:26 2014 -0500
@@ -728,17 +728,24 @@
     WRITE_FLAG(pps->bEntropyCodingSyncEnabled, "entropy_coding_sync_enabled_flag");
     WRITE_FLAG(1,                              "loop_filter_across_slices_enabled_flag");
 
-    WRITE_FLAG(pps->bDeblockingFilterControlPresent, "deblocking_filter_control_present_flag");
-    if (pps->bDeblockingFilterControlPresent)
+    if (pps->bDeblockDisabled)
     {
-        WRITE_FLAG(pps->bDeblockingFilterOverrideEnabled, "deblocking_filter_override_enabled_flag");
-        WRITE_FLAG(pps->bPicDisableDeblockingFilter,      "pps_disable_deblocking_filter_flag");
-        if (!pps->bPicDisableDeblockingFilter)
-        {
-            WRITE_SVLC(pps->deblockingFilterBetaOffsetDiv2, "pps_beta_offset_div2");
-            WRITE_SVLC(pps->deblockingFilterTcOffsetDiv2,   "pps_tc_offset_div2");
-        }
+        /* must signal disable bit each slice */
+        WRITE_FLAG(1, "deblocking_filter_control_present_flag");   // enable slice deblock control section
+        WRITE_FLAG(0, "deblocking_filter_override_enabled_flag");  // disable slice offset-override data
+        WRITE_FLAG(1, "pps_disable_deblocking_filter_flag");       // enable slice deblock-disable flag
     }
+    else if (pps->deblockBetaOffset || pps->deblockTCOffset)
+    {
+        /* signal offsets here, allow per-slice adjustments */
+        WRITE_FLAG(1, "deblocking_filter_control_present_flag");   // enable slice deblock control section
+        WRITE_FLAG(1, "deblocking_filter_override_enabled_flag");  // enable per-slice override data
+        WRITE_FLAG(0, "pps_disable_deblocking_filter_flag");       // disable slice deblock-disable flag
+        WRITE_SVLC(pps->deblockBetaOffset >> 1, "pps_beta_offset_div2");
+        WRITE_SVLC(pps->deblockTCOffset >> 1,   "pps_tc_offset_div2");
+    }
+    else
+        WRITE_FLAG(0, "deblocking_filter_control_present_flag");   // default enabled
 
     WRITE_FLAG(scalingList->m_bDataPresent, "pps_scaling_list_data_present_flag");
     if (scalingList->m_bDataPresent)
@@ -1102,19 +1109,15 @@
     int code = slice->getSliceQp() - 26;
     WRITE_SVLC(code, "slice_qp_delta");
 
-    if (slice->getPPS()->bDeblockingFilterControlPresent)
+    if (slice->getPPS()->bDeblockDisabled)
+        WRITE_FLAG(1, "slice_disable_deblocking_filter_flag");
+    else if (slice->getPPS()->deblockBetaOffset || slice->getPPS()->deblockTCOffset)
     {
-        if (slice->getPPS()->bDeblockingFilterOverrideEnabled)
-            WRITE_FLAG(slice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag");
-
+        WRITE_FLAG(slice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag");
         if (slice->getDeblockingFilterOverrideFlag())
         {
-            WRITE_FLAG(slice->getDeblockingFilterDisable(), "slice_disable_deblocking_filter_flag");
-            if (!slice->getDeblockingFilterDisable())
-            {
-                WRITE_SVLC(slice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2");
-                WRITE_SVLC(slice->getDeblockingFilterTcOffsetDiv2(),   "slice_tc_offset_div2");
-            }
+            WRITE_SVLC(slice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2");
+            WRITE_SVLC(slice->getDeblockingFilterTcOffsetDiv2(),   "slice_tc_offset_div2");
         }
     }
 
diff -r f0d157944c55 -r cef8e22586d5 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Thu Jul 17 00:37:00 2014 -0500
+++ b/source/encoder/frameencoder.cpp	Thu Jul 17 02:38:26 2014 -0500
@@ -191,23 +191,12 @@
 
     slice->setReferenced(m_isReferenced);
 
-    if (slice->getPPS()->bDeblockingFilterControlPresent)
-    {
-        slice->setDeblockingFilterOverrideFlag(!m_top->m_loopFilterOffsetInPPS);
-        slice->setDeblockingFilterDisable(!m_param->bEnableLoopFilter);
-        if (!slice->getDeblockingFilterDisable())
-        {
-            slice->setDeblockingFilterBetaOffsetDiv2(m_top->m_loopFilterBetaOffset);
-            slice->setDeblockingFilterTcOffsetDiv2(m_top->m_loopFilterTcOffset);
-        }
-    }
-    else
-    {
-        slice->setDeblockingFilterOverrideFlag(false);
-        slice->setDeblockingFilterDisable(false);
-        slice->setDeblockingFilterBetaOffsetDiv2(0);
-        slice->setDeblockingFilterTcOffsetDiv2(0);
-    }
+    /* if param->bEnableLoopFilter was false, only the slice filter-disalbe flag
+     * will be signaled as 1. Else if filter offsets were provided in the PPS,
+     * each slice will be given the option to signal overrides for them */
+    slice->setDeblockingFilterOverrideFlag(false);
+    slice->setDeblockingFilterBetaOffsetDiv2(0);
+    slice->setDeblockingFilterTcOffsetDiv2(0);
 
     slice->setMaxNumMergeCand(m_param->maxNumMergeCand);
 }


More information about the x265-devel mailing list