[x265-commits] [x265] api: expose scaling lists and psy-rdoq as a CLI/API options

Steve Borho steve at borho.org
Mon Jul 28 03:03:40 CEST 2014


details:   http://hg.videolan.org/x265/rev/93a434014f5a
branches:  
changeset: 7579:93a434014f5a
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 10:49:53 2014 -0500
description:
api: expose scaling lists and psy-rdoq as a CLI/API options

psy-rdoq is not yet functional - option is ignored
move scaling list related globals to scalinglist.cpp from TComRom
Subject: [x265] quant: remove access methods for the class's own members

details:   http://hg.videolan.org/x265/rev/0625f303cd49
branches:  
changeset: 7580:0625f303cd49
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 00:21:58 2014 -0500
description:
quant: remove access methods for the class's own members
Subject: [x265] quant: remove get/set methods for scaling list enable flag

details:   http://hg.videolan.org/x265/rev/7435c0f166f6
branches:  
changeset: 7581:7435c0f166f6
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 00:31:11 2014 -0500
description:
quant: remove get/set methods for scaling list enable flag
Subject: [x265] quant: re-order header and improve comments

details:   http://hg.videolan.org/x265/rev/5758998128e1
branches:  
changeset: 7582:5758998128e1
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 00:42:05 2014 -0500
description:
quant: re-order header and improve comments
Subject: [x265] quant: QpParam class to struct

details:   http://hg.videolan.org/x265/rev/e4008f081c33
branches:  
changeset: 7583:e4008f081c33
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 00:45:01 2014 -0500
description:
quant: QpParam class to struct
Subject: [x265] quant: more coding style cleanup, update argument list in xGetCodedLevel comment

details:   http://hg.videolan.org/x265/rev/262af2694656
branches:  
changeset: 7584:262af2694656
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 00:55:51 2014 -0500
description:
quant: more coding style cleanup, update argument list in xGetCodedLevel comment
Subject: [x265] quant: remove default useTransformSkip argument value

details:   http://hg.videolan.org/x265/rev/2f52f5c4a913
branches:  
changeset: 7585:2f52f5c4a913
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 00:58:09 2014 -0500
description:
quant: remove default useTransformSkip argument value
Subject: [x265] quant: remove default curUseRDOQ argument value

details:   http://hg.videolan.org/x265/rev/250deb63f2ea
branches:  
changeset: 7586:250deb63f2ea
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 00:59:15 2014 -0500
description:
quant: remove default curUseRDOQ argument value
Subject: [x265] quant: use rem consistently for variables holding qp % 6

details:   http://hg.videolan.org/x265/rev/1b39a252efac
branches:  
changeset: 7587:1b39a252efac
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 01:04:46 2014 -0500
description:
quant: use rem consistently for variables holding qp % 6
Subject: [x265] quant: remove x prefixes from scaling list methods

details:   http://hg.videolan.org/x265/rev/991d931d9db4
branches:  
changeset: 7588:991d931d9db4
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 01:06:09 2014 -0500
description:
quant: remove x prefixes from scaling list methods
Subject: [x265] quant: replace xGetIEPRate() with a constant

details:   http://hg.videolan.org/x265/rev/96925cfd342d
branches:  
changeset: 7589:96925cfd342d
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 01:09:04 2014 -0500
description:
quant: replace xGetIEPRate() with a constant
Subject: [x265] quant: remove x prefixes from remaining methods; no logic change

details:   http://hg.videolan.org/x265/rev/82bd32283dd1
branches:  
changeset: 7590:82bd32283dd1
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 01:15:41 2014 -0500
description:
quant: remove x prefixes from remaining methods; no logic change
Subject: [x265] quant: move quant/dequant/errScale buffer maintenance to scaling list class

details:   http://hg.videolan.org/x265/rev/57b57ec43838
branches:  
changeset: 7591:57b57ec43838
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 02:39:34 2014 -0500
description:
quant: move quant/dequant/errScale buffer maintenance to scaling list class

This was a wasteful duplication of compute and memory. It was always strange
that TComTrQuant had so many internal references to the ScalingList class, just
to build these arrays itself.

As part of this refactor, ScalingList now has checked mallocs.
Subject: [x265] scaling: move global arrays into class statics, rename

details:   http://hg.videolan.org/x265/rev/9ad7abfab9d1
branches:  
changeset: 7592:9ad7abfab9d1
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 13:37:39 2014 -0500
description:
scaling: move global arrays into class statics, rename
Subject: [x265] scaling: remove duplicate square-block size enums

details:   http://hg.videolan.org/x265/rev/0d2eb9d6d7e0
branches:  
changeset: 7593:0d2eb9d6d7e0
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 13:42:20 2014 -0500
description:
scaling: remove duplicate square-block size enums
Subject: [x265] level: signal level None if lossless coding - we have no bitrate control

details:   http://hg.videolan.org/x265/rev/74a5481eceb5
branches:  
changeset: 7594:74a5481eceb5
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 19:29:57 2014 -0500
description:
level: signal level None if lossless coding - we have no bitrate control
Subject: [x265] quant: simplify dequant, remove redundant invQuantScales array

details:   http://hg.videolan.org/x265/rev/28c7868814de
branches:  
changeset: 7595:28c7868814de
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 19:03:28 2014 -0500
description:
quant: simplify dequant, remove redundant invQuantScales array
Subject: [x265] quant: inline invTransformSkip

details:   http://hg.videolan.org/x265/rev/ec8f8d6e59d9
branches:  
changeset: 7596:ec8f8d6e59d9
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 19:08:08 2014 -0500
description:
quant: inline invTransformSkip
Subject: [x265] quant: inline transformSkip

details:   http://hg.videolan.org/x265/rev/67e62a4d520f
branches:  
changeset: 7597:67e62a4d520f
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 19:10:34 2014 -0500
description:
quant: inline transformSkip
Subject: [x265] quant: nits

details:   http://hg.videolan.org/x265/rev/ea63a67164e5
branches:  
changeset: 7598:ea63a67164e5
user:      Steve Borho <steve at borho.org>
date:      Sun Jul 27 19:15:14 2014 -0500
description:
quant: nits

diffstat:

 doc/reST/cli.rst                      |   30 +-
 source/CMakeLists.txt                 |    2 +-
 source/Lib/TLibCommon/TComRom.cpp     |   44 --
 source/Lib/TLibCommon/TComRom.h       |   57 ---
 source/Lib/TLibCommon/TComTrQuant.cpp |  523 ++++++++++-----------------------
 source/Lib/TLibCommon/TComTrQuant.h   |  173 ++++------
 source/Lib/TLibEncoder/TEncSearch.cpp |   21 +-
 source/common/param.cpp               |    8 +
 source/common/scalinglist.cpp         |  310 ++++++++++++++++---
 source/common/scalinglist.h           |   36 +-
 source/encoder/encoder.cpp            |   32 +-
 source/encoder/entropy.cpp            |    6 +-
 source/encoder/level.cpp              |    6 +-
 source/x265.cpp                       |    6 +-
 source/x265.h                         |   16 +
 15 files changed, 587 insertions(+), 683 deletions(-)

diffs (truncated from 2011 to 300 lines):

diff -r 00c127bd42e7 -r ea63a67164e5 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Sat Jul 26 23:41:51 2014 -0500
+++ b/doc/reST/cli.rst	Sun Jul 27 19:15:14 2014 -0500
@@ -274,6 +274,23 @@ Input Options
 	Specifying QP (integer) is optional, and if specified they are
 	clamped within the encoder to qpmin/qpmax.
 
+.. option:: --scaling-list <filename>
+
+	Quantization scaling lists. HEVC supports 6 quantization scaling
+	lists to be defined; one each for Y, Cb, Cr for intra prediction and
+	one each for inter prediction.
+
+	x265 does not use scaling lists by default, but this can also be
+	made explicit by :option:`--scaling-list` *off*.
+
+	HEVC specifies a default set of scaling lists which may be enabled
+	without requiring them to be signaled in the SPS. Those scaling
+	lists can be enabled via :option:`--scaling-list` *default*.
+    
+	All other strings indicate a filename containing custom scaling
+	lists in the HM format. The encode will abort if the file is not
+	parsed correctly. Custom lists must be signaled in the SPS
+
 .. option:: --lambda-file <filename>
 
 	Specify a text file containing values for x265_lambda_tab and
@@ -568,8 +585,17 @@ Mode decision / Analysis
 	Influence rate distortion optimizations to try to preserve the
 	energy of the source image in the encoded image, at the expense of
 	compression efficiency. 1.0 is a typical value. Default disabled. It
-	only has effect on presets which use full RDO-based decisions (slower,
-	veryslow and placebo)
+	only has effect on presets which use RDO-based decisions.  Experimental
+
+	**Range of values:** 0 .. 2.0
+
+.. option:: --psy-rdoq <float>
+
+	Influence the rate distortion optimized quantization by favoring
+	higher energy in the reconstructed image. This generally improves
+	perceived visual quality at the cost of lower quality metric scores.
+	It only has effect on slower presets which use RDO Quantization
+	(rd-levels 4 and 5). Experimental
 
 	**Range of values:** 0 .. 2.0
 
diff -r 00c127bd42e7 -r ea63a67164e5 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Sat Jul 26 23:41:51 2014 -0500
+++ b/source/CMakeLists.txt	Sun Jul 27 19:15:14 2014 -0500
@@ -19,7 +19,7 @@ include(CheckSymbolExists)
 include(CheckCXXCompilerFlag)
 
 # X265_BUILD must be incremented each time the public API is changed
-set(X265_BUILD 28)
+set(X265_BUILD 29)
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
                "${PROJECT_BINARY_DIR}/x265.def")
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
diff -r 00c127bd42e7 -r ea63a67164e5 source/Lib/TLibCommon/TComRom.cpp
--- a/source/Lib/TLibCommon/TComRom.cpp	Sat Jul 26 23:41:51 2014 -0500
+++ b/source/Lib/TLibCommon/TComRom.cpp	Sun Jul 27 19:15:14 2014 -0500
@@ -216,16 +216,6 @@ const int16_t g_chromaFilter[8][NTAPS_CH
     { -2, 10, 58, -2 }
 };
 
-const int g_quantScales[6] =
-{
-    26214, 23302, 20560, 18396, 16384, 14564
-};
-
-const int g_invQuantScales[6] =
-{
-    40, 45, 51, 57, 64, 72
-};
-
 const int16_t g_t4[4][4] =
 {
     { 64, 64, 64, 64 },
@@ -428,40 +418,6 @@ const uint8_t g_minInGroup[10] = { 0, 1,
 // Rice parameters for absolute transform levels
 const uint8_t g_goRiceRange[5] = { 7, 14, 26, 46, 78 };
 
-//const uint8_t g_goRicePrefixLen[5] = { 8, 7, 6, 5, 4 };
-
-int g_quantTSDefault4x4[16] =
-{
-    16, 16, 16, 16,
-    16, 16, 16, 16,
-    16, 16, 16, 16,
-    16, 16, 16, 16
-};
-
-int g_quantIntraDefault8x8[64] =
-{
-    16, 16, 16, 16, 17, 18, 21, 24,
-    16, 16, 16, 16, 17, 19, 22, 25,
-    16, 16, 17, 18, 20, 22, 25, 29,
-    16, 16, 18, 21, 24, 27, 31, 36,
-    17, 17, 20, 24, 30, 35, 41, 47,
-    18, 19, 22, 27, 35, 44, 54, 65,
-    21, 22, 25, 31, 41, 54, 70, 88,
-    24, 25, 29, 36, 47, 65, 88, 115
-};
-
-int g_quantInterDefault8x8[64] =
-{
-    16, 16, 16, 16, 17, 18, 20, 24,
-    16, 16, 16, 17, 18, 20, 24, 25,
-    16, 16, 17, 18, 20, 24, 25, 28,
-    16, 17, 18, 20, 24, 25, 28, 33,
-    17, 18, 20, 24, 25, 28, 33, 41,
-    18, 20, 24, 25, 28, 33, 41, 54,
-    20, 24, 25, 28, 33, 41, 54, 71,
-    24, 25, 28, 33, 41, 54, 71, 91
-};
-
 const int g_winUnitX[] = { 1, 2, 2, 1 };
 const int g_winUnitY[] = { 1, 2, 1, 1 };
 
diff -r 00c127bd42e7 -r ea63a67164e5 source/Lib/TLibCommon/TComRom.h
--- a/source/Lib/TLibCommon/TComRom.h	Sat Jul 26 23:41:51 2014 -0500
+++ b/source/Lib/TLibCommon/TComRom.h	Sun Jul 27 19:15:14 2014 -0500
@@ -108,8 +108,6 @@ extern const uint32_t g_puOffset[8];
 #define SHIFT_INV_1ST          7 // Shift after first inverse transform stage
 #define SHIFT_INV_2ND         12 // Shift after second inverse transform stage
 
-extern const int g_quantScales[6];     // Q(QP%6)
-extern const int g_invQuantScales[6];  // IQ(QP%6)
 extern const int16_t g_t4[4][4];
 extern const int16_t g_t8[8][8];
 extern const int16_t g_t16[16][16];
@@ -169,61 +167,6 @@ extern const uint8_t g_goRiceRange[5];  
 
 extern uint8_t g_convertToBit[MAX_CU_SIZE + 1]; // from width to log2(width)-2
 
-static const char MatrixType[4][6][20] =
-{
-    {
-        "INTRA4X4_LUMA",
-        "INTRA4X4_CHROMAU",
-        "INTRA4X4_CHROMAV",
-        "INTER4X4_LUMA",
-        "INTER4X4_CHROMAU",
-        "INTER4X4_CHROMAV"
-    },
-    {
-        "INTRA8X8_LUMA",
-        "INTRA8X8_CHROMAU",
-        "INTRA8X8_CHROMAV",
-        "INTER8X8_LUMA",
-        "INTER8X8_CHROMAU",
-        "INTER8X8_CHROMAV"
-    },
-    {
-        "INTRA16X16_LUMA",
-        "INTRA16X16_CHROMAU",
-        "INTRA16X16_CHROMAV",
-        "INTER16X16_LUMA",
-        "INTER16X16_CHROMAU",
-        "INTER16X16_CHROMAV"
-    },
-    {
-        "INTRA32X32_LUMA",
-        "INTER32X32_LUMA",
-    },
-};
-static const char MatrixType_DC[4][12][22] =
-{
-    {},
-    {},
-    {
-        "INTRA16X16_LUMA_DC",
-        "INTRA16X16_CHROMAU_DC",
-        "INTRA16X16_CHROMAV_DC",
-        "INTER16X16_LUMA_DC",
-        "INTER16X16_CHROMAU_DC",
-        "INTER16X16_CHROMAV_DC"
-    },
-    {
-        "INTRA32X32_LUMA_DC",
-        "INTER32X32_LUMA_DC",
-    },
-};
-extern int g_quantIntraDefault8x8[64];
-extern int g_quantIntraDefault16x16[256];
-extern int g_quantIntraDefault32x32[1024];
-extern int g_quantInterDefault8x8[64];
-extern int g_quantInterDefault16x16[256];
-extern int g_quantInterDefault32x32[1024];
-extern int g_quantTSDefault4x4[16];
 
 // Map Luma samples to chroma samples
 extern const int g_winUnitX[MAX_CHROMA_FORMAT_IDC + 1];
diff -r 00c127bd42e7 -r ea63a67164e5 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Sat Jul 26 23:41:51 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Sun Jul 27 19:15:14 2014 -0500
@@ -31,10 +31,6 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-/** \file     TComTrQuant.cpp
-    \brief    transform and quantization class
-*/
-
 #include "common.h"
 #include "primitives.h"
 #include "frame.h"
@@ -43,54 +39,23 @@
 
 using namespace x265;
 
-typedef struct
+namespace {
+
+struct coeffGroupRDStats
 {
     int    nnzBeforePos0;
     double codedLevelAndDist; // distortion and level cost only
-    double uncodedDist;  // all zero coded block distortion
+    double uncodedDist;       // all zero coded block distortion
     double sigCost;
     double sigCost0;
-} coeffGroupRDStats;
+};
 
-//! \ingroup TLibCommon
-//! \{
-
-// ====================================================================================================================
-// Constants
-// ====================================================================================================================
-
-inline static int x265_min_fast(int x, int y)
+inline static int fastMin(int x, int y)
 {
     return y + ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))); // min(x, y)
 }
 
-// ====================================================================================================================
-// TComTrQuant class member functions
-// ====================================================================================================================
-
-TComTrQuant::TComTrQuant()
-{
-    m_resiDctCoeff = NULL;
-    memset(m_quantCoef, 0, sizeof(m_quantCoef));
-    memset(m_dequantCoef, 0, sizeof(m_dequantCoef));
-    memset(m_errScale, 0, sizeof(m_errScale));
-}
-
-bool TComTrQuant::init(bool useRDOQ)
-{
-    m_useRDOQ = useRDOQ;
-    m_resiDctCoeff = X265_MALLOC(coeff_t, MAX_CU_SIZE * MAX_CU_SIZE);
-    
-    return m_resiDctCoeff && initScalingList();
-}
-
-TComTrQuant::~TComTrQuant()
-{
-    X265_FREE(m_resiDctCoeff);
-    destroyScalingList();
-}
-
-static void denoiseDct(coeff_t* dctCoef, uint32_t* resSum, uint16_t* offset, int size)
+inline static void denoiseDct(coeff_t* dctCoef, uint32_t* resSum, uint16_t* offset, int size)
 {
     for (int i = 0; i < size; i++)
     {
@@ -103,6 +68,36 @@ static void denoiseDct(coeff_t* dctCoef,
     }
 }
 
+}
+
+TComTrQuant::TComTrQuant()
+{
+    m_resiDctCoeff = NULL;
+}
+
+bool TComTrQuant::init(bool useRDOQ, const ScalingList& scalingList)
+{
+    m_useRDOQ = useRDOQ;
+    m_scalingList = &scalingList;
+    m_resiDctCoeff = X265_MALLOC(coeff_t, MAX_CU_SIZE * MAX_CU_SIZE);
+    return m_resiDctCoeff;
+}
+
+TComTrQuant::~TComTrQuant()
+{
+    X265_FREE(m_resiDctCoeff);
+}
+
+void TComTrQuant::setQPforQuant(TComDataCU* cu)
+{
+    int qpy = cu->getQP(0);
+    int chFmt = cu->getChromaFormat();
+
+    m_qpParam[TEXT_LUMA].setQpParam(qpy + QP_BD_OFFSET);


More information about the x265-commits mailing list