[x265] [PATCH] Add flag to enable/disable temporal MVP

Nicolas Morey-Chaisemartin nmorey at kalray.eu
Mon Oct 27 19:50:02 CET 2014


# HG changeset patch
# User Nicolas Morey-Chaisemartin <nmorey at kalray.eu>
# Date 1414074805 -7200
#      Thu Oct 23 15:33:25 2014 +0200

Add flag to enable/disable temporal MVP

---
  source/CMakeLists.txt      | 2 +-
  source/common/cudata.cpp   | 4 ++--
  source/common/param.cpp    | 2 ++
  source/common/slice.h      | 1 +
  source/encoder/encoder.cpp | 1 +
  source/encoder/entropy.cpp | 7 ++++---
  source/x265.h              | 3 +++
  7 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 5e59f61..4644501 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -27,7 +27,7 @@ include(CheckSymbolExists)
  include(CheckCXXCompilerFlag)
  
  # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 34)
+set(X265_BUILD 35)
  configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                 "${PROJECT_BINARY_DIR}/x265.def")
  configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff --git a/source/common/cudata.cpp b/source/common/cudata.cpp
index fec2a8d..f288bf5 100644
--- a/source/common/cudata.cpp
+++ b/source/common/cudata.cpp
@@ -1534,7 +1534,7 @@ uint32_t CUData::getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, MV
                  return maxNumMergeCand;
          }
      }
-    // TMVP always enabled
+    if (m_slice->m_sps->bTemporalMVPEnabled)
      {
          MV colmv;
          uint32_t partIdxRB;
@@ -1763,7 +1763,7 @@ int CUData::fillMvpCand(uint32_t partIdx, uint32_t partAddr, int picList, int re
              return numMvc;
      }
  
-    // TMVP always enabled
+    if (m_slice->m_sps->bTemporalMVPEnabled)
      {
          uint32_t absPartAddr = m_absIdxInCTU + partAddr;
          MV colmv;
diff --git a/source/common/param.cpp b/source/common/param.cpp
index 3ff7edb..4ced165 100644
--- a/source/common/param.cpp
+++ b/source/common/param.cpp
@@ -161,6 +161,7 @@ void x265_param_default(x265_param *param)
      param->bEnableTransformSkip = 0;
      param->bEnableTSkipFast = 0;
      param->maxNumReferences = 3;
+    param->bEnableTemporalMvp = 1;
  
      /* Loop Filter */
      param->bEnableLoopFilter = 1;
@@ -1167,6 +1168,7 @@ void x265_print_params(x265_param *param)
      TOOLOPT(param->bEnableConstrainedIntra, "cip");
      TOOLOPT(param->bIntraInBFrames, "b-intra");
      TOOLOPT(param->bEnableFastIntra, "fast-intra");
+    TOOLOPT(param->bEnableTemporalMvp, "tmvp");
      if (param->bEnableTransformSkip)
          fprintf(stderr, "tskip%s ", param->bEnableTSkipFast ? "-fast" : "");
      TOOLOPT(param->bCULossless, "cu-lossless");
diff --git a/source/common/slice.h b/source/common/slice.h
index 9944aa2..bd0ba63 100644
--- a/source/common/slice.h
+++ b/source/common/slice.h
@@ -232,6 +232,7 @@ struct SPS
      int      numReorderPics;
  
      bool     bUseStrongIntraSmoothing; // use param
+    bool     bTemporalMVPEnabled;
  
      Window   conformanceWindow;
      VUI      vuiParameters;
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp
index fe3daa4..341705c 100644
--- a/source/encoder/encoder.cpp
+++ b/source/encoder/encoder.cpp
@@ -1223,6 +1223,7 @@ void Encoder::initSPS(SPS *sps)
      sps->numReorderPics = m_vps.numReorderPics;
  
      sps->bUseStrongIntraSmoothing = m_param->bEnableStrongIntraSmoothing;
+    sps->bTemporalMVPEnabled = m_param->bEnableTemporalMvp;
  
      VUI& vui = sps->vuiParameters;
      vui.aspectRatioInfoPresentFlag = !!m_param->vui.aspectRatioIdc;
diff --git a/source/encoder/entropy.cpp b/source/encoder/entropy.cpp
index ff11db6..f62fdad 100644
--- a/source/encoder/entropy.cpp
+++ b/source/encoder/entropy.cpp
@@ -124,7 +124,7 @@ void Entropy::codeSPS(const SPS& sps, const ScalingList& scalingList, const Prof
      WRITE_UVLC(0, "num_short_term_ref_pic_sets");
      WRITE_FLAG(0, "long_term_ref_pics_present_flag");
  
-    WRITE_FLAG(1, "sps_temporal_mvp_enable_flag");
+    WRITE_FLAG(sps.bTemporalMVPEnabled, "sps_temporal_mvp_enable_flag");
      WRITE_FLAG(sps.bUseStrongIntraSmoothing, "sps_strong_intra_smoothing_enable_flag");
  
      WRITE_FLAG(1, "vui_parameters_present_flag");
@@ -402,7 +402,8 @@ void Entropy::codeSliceHeader(const Slice& slice, FrameData& encData)
          WRITE_FLAG(0, "short_term_ref_pic_set_sps_flag");
          codeShortTermRefPicSet(slice.m_rps);
  
-        WRITE_FLAG(1, "slice_temporal_mvp_enable_flag");
+        if (slice.m_sps->bTemporalMVPEnabled)
+            WRITE_FLAG(1, "slice_temporal_mvp_enable_flag");
      }
      const SAOParam *saoParam = encData.m_saoParam;
      if (slice.m_sps->bUseSAO)
@@ -437,7 +438,7 @@ void Entropy::codeSliceHeader(const Slice& slice, FrameData& encData)
      if (slice.isInterB())
          WRITE_FLAG(0, "mvd_l1_zero_flag");
  
-    // TMVP always enabled
+    if (slice.m_sps->bTemporalMVPEnabled)
      {
          if (slice.m_sliceType == B_SLICE)
              WRITE_FLAG(slice.m_colFromL0Flag, "collocated_from_l0_flag");
diff --git a/source/x265.h b/source/x265.h
index 6ed0764..b2bdd61 100644
--- a/source/x265.h
+++ b/source/x265.h
@@ -628,6 +628,9 @@ typedef struct x265_param
       * the performance but the less compression efficiency. Default is 3 */
      uint32_t  maxNumMergeCand;
  
+    /* Disable availability of temporal motion vector for AMVP */
+    int bEnableTemporalMvp;
+
      /* Enable weighted prediction in P slices.  This enables weighting analysis
       * in the lookahead, which influences slice decisions, and enables weighting
       * analysis in the main encoder which allows P reference samples to have a
-- 
Nicolas Morey Chaisemartin
Phone : +33 6 42 46 68 87


More information about the x265-devel mailing list