[x265-commits] [x265] ignore .DS_Store files (Mac pocket lint)

Steve Borho steve at borho.org
Wed May 7 03:48:09 CEST 2014


details:   http://hg.videolan.org/x265/rev/075705aa41a9
branches:  
changeset: 6811:075705aa41a9
user:      Steve Borho <steve at borho.org>
date:      Mon May 05 23:26:59 2014 -0500
description:
ignore .DS_Store files (Mac pocket lint)
Subject: [x265] cmake: add CHECKED_BUILD option so we can add optional runtime checking

details:   http://hg.videolan.org/x265/rev/5c590a31734b
branches:  
changeset: 6812:5c590a31734b
user:      Steve Borho <steve at borho.org>
date:      Mon May 05 23:26:29 2014 -0500
description:
cmake: add CHECKED_BUILD option so we can add optional runtime checking
Subject: [x265] check: add checks for integer overflow in rdcost functions

details:   http://hg.videolan.org/x265/rev/2577eb2cbd20
branches:  
changeset: 6813:2577eb2cbd20
user:      Steve Borho <steve at borho.org>
date:      Tue May 06 00:06:11 2014 -0500
description:
check: add checks for integer overflow in rdcost functions
Subject: [x265] log: add the RateFactor for each frame to the csv file when using --crf mode

details:   http://hg.videolan.org/x265/rev/94803b73ba8a
branches:  
changeset: 6814:94803b73ba8a
user:      Gopu Govindaswamy
date:      Tue May 06 12:49:33 2014 +0530
description:
log: add the RateFactor for each frame to the csv file when using --crf mode
Subject: [x265] slicetype: avoid redundant call. intraSatd costs are updated in frameEncoder already

details:   http://hg.videolan.org/x265/rev/532c961b16f1
branches:  
changeset: 6815:532c961b16f1
user:      Aarthi Thirumalai
date:      Tue May 06 17:14:31 2014 +0530
description:
slicetype: avoid redundant call. intraSatd costs are updated in frameEncoder already
Subject: [x265] ratecontrol: avoid clipping QP multiple times when VBV is not enabled.

details:   http://hg.videolan.org/x265/rev/7d557d8819e9
branches:  
changeset: 6816:7d557d8819e9
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Tue May 06 15:31:18 2014 +0530
description:
ratecontrol: avoid clipping QP multiple times when VBV is not enabled.
Subject: [x265] ratecontrol: remove RateControl->qpNoVbv.

details:   http://hg.videolan.org/x265/rev/5d9220ec8c81
branches:  
changeset: 6817:5d9220ec8c81
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Tue May 06 15:34:19 2014 +0530
description:
ratecontrol: remove RateControl->qpNoVbv.

Less confusion, and we have whatever info we need in rce->qpNoVbv anyway
Subject: [x265] ratecontrol: remove repeat initialisations.

details:   http://hg.videolan.org/x265/rev/3974eafe528d
branches:  
changeset: 6818:3974eafe528d
user:      Deepthi Nandakumar <deepthi at multicorewareinc.com>
date:      Tue May 06 15:41:49 2014 +0530
description:
ratecontrol: remove repeat initialisations.
Subject: [x265] rest: add a page describing presets

details:   http://hg.videolan.org/x265/rev/110993a5ef10
branches:  stable
changeset: 6819:110993a5ef10
user:      Steve Borho <steve at borho.org>
date:      Tue May 06 20:45:07 2014 -0500
description:
rest: add a page describing presets
Subject: [x265] Merge with stable

details:   http://hg.videolan.org/x265/rev/ec4917459326
branches:  
changeset: 6820:ec4917459326
user:      Steve Borho <steve at borho.org>
date:      Tue May 06 20:45:27 2014 -0500
description:
Merge with stable
Subject: [x265] log: remove hyphen from signhide, so it matches param name

details:   http://hg.videolan.org/x265/rev/608267a4f634
branches:  
changeset: 6821:608267a4f634
user:      Steve Borho <steve at borho.org>
date:      Tue May 06 20:46:31 2014 -0500
description:
log: remove hyphen from signhide, so it matches param name

This is just to avoid confusion

diffstat:

 .hgignore                          |    1 +
 doc/reST/index.rst                 |    1 +
 doc/reST/presets.rst               |   85 ++++++++++++++
 source/CMakeLists.txt              |    5 +
 source/Lib/TLibCommon/TComPic.h    |    1 +
 source/Lib/TLibCommon/TComRdCost.h |   32 ++++-
 source/common/common.h             |   12 ++
 source/common/param.cpp            |    2 +-
 source/common/version.cpp          |   12 +-
 source/encoder/encoder.cpp         |   11 +-
 source/encoder/ratecontrol.cpp     |  211 +++++++++++++++++++-----------------
 source/encoder/ratecontrol.h       |    1 -
 source/encoder/slicetype.cpp       |    4 -
 13 files changed, 262 insertions(+), 116 deletions(-)

diffs (truncated from 571 to 300 lines):

diff -r c4adcaef8d1d -r 608267a4f634 .hgignore
--- a/.hgignore	Mon May 05 00:22:50 2014 -0500
+++ b/.hgignore	Tue May 06 20:46:31 2014 -0500
@@ -8,3 +8,4 @@ build/
 **.y4m
 **.out
 **.swp
+.DS_Store
diff -r c4adcaef8d1d -r 608267a4f634 doc/reST/index.rst
--- a/doc/reST/index.rst	Mon May 05 00:22:50 2014 -0500
+++ b/doc/reST/index.rst	Tue May 06 20:46:31 2014 -0500
@@ -6,3 +6,4 @@ x265 Documentation
    introduction
    cli
    threading
+   presets
diff -r c4adcaef8d1d -r 608267a4f634 doc/reST/presets.rst
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/reST/presets.rst	Tue May 06 20:46:31 2014 -0500
@@ -0,0 +1,85 @@
+*******
+Presets
+*******
+
+x265 has a number of predefined :option:`--preset` options that make
+trade-offs between encode speed (encoded frames per second) and
+compression efficiency (quality per bit in the bitstream).  The default
+preset is medium, it does a reasonably good job of finding the best
+possible quality without spending enourmous CPU cycles looking for the
+absolute most efficient way to achieve that quality.  As you go higher
+than medium, the encoder takes shortcuts to improve performance at the
+expense of quality and compression efficiency.  As you go lower than
+medium, the encoder tries harder and harder to achieve the best quailty
+per bit compression ratio.
+
+The presets adjust encoder parameters to affect these trade-offs.
+
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+|              | ultrafast | superfast | veryfast | faster | fast | medium | slow | slower | veryslow | placebo |
++==============+===========+===========+==========+========+======+========+======+========+==========+=========+
+| ctu          |   32      |    32     |   32     |  64    |  64  |   64   |  64  |  64    |   64     |   64    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| bframes      |    4      |     4     |    4     |   4    |  4   |    4   |  4   |   8    |    8     |    8    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| b-adapt      |    0      |     0     |    0     |   0    |  2   |    2   |  2   |   2    |    2     |    2    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| rc-lookahead |   10      |    10     |   15     |  15    |  15  |   20   |  25  |   30   |   40     |   60    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| scenecut     |    0      |    40     |   40     |  40    |  40  |   40   |  40  |   40   |   40     |   40    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| refs         |    1      |     1     |    1     |   1    |  3   |    3   |  3   |   3    |    5     |    5    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| me           |   dia     |   hex     |   hex    |  hex   | hex  |   hex  | star |  star  |   star   |   star  |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| merange      |   25      |    44     |   57     |  57    |  57  |   57   | 57   |  57    |   57     |   92    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| subme        |    0      |     1     |    1     |   2    |  2   |    2   |  3   |   3    |    4     |    5    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| rect         |    0      |     0     |    0     |   1    |  1   |    1   |  1   |   1    |    1     |    1    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| amp          |    0      |     0     |    0     |   0    |  0   |    1   |  1   |   1    |    1     |    1    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| max-merge    |    2      |     2     |    2     |   2    |  2   |    2   |  3   |   3    |    4     |    5    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| early-skip   |    1      |     1     |    1     |   1    |  0   |    0   |  0   |   0    |    0     |    0    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| fast-cbf     |    1      |     1     |    1     |   1    |  0   |    0   |  0   |   0    |    0     |    0    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| sao          |    0      |     1     |    1     |   1    |  1   |    1   |  1   |   1    |    1     |    1    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| signhide     |    0      |     1     |    1     |   1    |  1   |    1   |  1   |   1    |    1     |    1    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| weightp      |    0      |     0     |    1     |   1    |  1   |    1   |  1   |   1    |    1     |    1    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| aq-mode      |    0      |     0     |    1     |   1    |  1   |    1   |  1   |   1    |    1     |    1    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| cuTree       |    0      |     0     |    0     |   0    |  1   |    1   |  1   |   1    |    1     |    1    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| rdLevel      |    3      |     3     |    3     |   3    |  3   |    3   |  4   |   6    |    6     |    6    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| tu-intra     |    1      |     1     |    1     |   1    |  1   |    1   |  1   |   2    |    3     |    4    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+| tu-inter     |    1      |     1     |    1     |   1    |  1   |    1   |  1   |   2    |    3     |    4    |
++--------------+-----------+-----------+----------+--------+------+--------+------+--------+----------+---------+
+
+Placebo mode further enables transform-skip prediction analysis
+(lossless).
+
+Tuning
+======
+
+There are a few :option:`--tune` options available, which are applied
+after the preset.
+
++--------------+--------------------------------------+
+| --tune       | effect                               |
++==============+======================================+
+| psnr         | disables adaptive quant and cutree   |
++--------------+--------------------------------------+
+| ssim         | enables adaptive quant auto-mode     |
++--------------+--------------------------------------+
+| fastdecode   | no loop filters, no weighted pred    |
++--------------+--------------------------------------+
+| zerolatency  | no lookahead, no B frames, no cutree |
++--------------+--------------------------------------+
diff -r c4adcaef8d1d -r 608267a4f634 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Mon May 05 00:22:50 2014 -0500
+++ b/source/CMakeLists.txt	Tue May 06 20:46:31 2014 -0500
@@ -27,6 +27,11 @@ configure_file("${PROJECT_SOURCE_DIR}/x2
 
 SET(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
 
+option(CHECKED_BUILD "Enable run-time sanity checks (debugging)" OFF)
+if(CHECKED_BUILD)
+    add_definitions(-DCHECKED_BUILD=1)
+endif()
+
 # System architecture detection
 string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSPROC)
 set(X86_ALIASES x86 i386 i686 x86_64 amd64)
diff -r c4adcaef8d1d -r 608267a4f634 source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h	Mon May 05 00:22:50 2014 -0500
+++ b/source/Lib/TLibCommon/TComPic.h	Tue May 06 20:46:31 2014 -0500
@@ -116,6 +116,7 @@ public:
     double*               m_qpaRc;
     double                m_avgQpRc; //avg QP as decided by ratecontrol
     double                m_avgQpAq; //avg QP as decided by AQ in addition to ratecontrol
+    double                m_rateFactor; //calculated based on the Frame QP
 
     TComPic();
     virtual ~TComPic();
diff -r c4adcaef8d1d -r 608267a4f634 source/Lib/TLibCommon/TComRdCost.h
--- a/source/Lib/TLibCommon/TComRdCost.h	Mon May 05 00:22:50 2014 -0500
+++ b/source/Lib/TLibCommon/TComRdCost.h	Tue May 06 20:46:31 2014 -0500
@@ -80,15 +80,39 @@ public:
         m_crDistortionWeight = (uint64_t)floor(256.0 * crDistortionWeight);
     }
 
-    inline uint64_t calcRdCost(uint32_t distortion, uint32_t bits) { return distortion + ((bits * m_lambdaMotionSSE + 128) >> 8); }
+    inline uint64_t calcRdCost(uint32_t distortion, uint32_t bits)
+    {
+        X265_CHECK(abs(distortion + ((bits * m_lambdaMotionSSE + 128) >> 8)) -
+                      (distortion + (float)bits * m_lambdaMotionSSE / 256.0) < 2,
+                   "calcRdCost wrap detected dist: %d, bits %d, lambda: %d\n", distortion, bits, (int)m_lambdaMotionSSE);
+        return distortion + ((bits * m_lambdaMotionSSE + 128) >> 8);
+    }
 
-    inline uint64_t calcRdSADCost(uint32_t sadCost, uint32_t bits) { return sadCost + ((bits * m_lambdaMotionSAD + 128) >> 8); }
+    inline uint64_t calcRdSADCost(uint32_t sadCost, uint32_t bits)
+    {
+        X265_CHECK(abs(sadCost + ((bits * m_lambdaMotionSAD + 128) >> 8)) -
+                      (sadCost + (float)bits * m_lambdaMotionSAD / 256.0) < 2,
+                   "calcRdSADCost wrap detected dist: %d, bits %d, lambda: %d\n", sadCost, bits, (int)m_lambdaMotionSAD);
+        return sadCost + ((bits * m_lambdaMotionSAD + 128) >> 8);
+    }
 
     inline uint32_t getCost(uint32_t bits)                     { return (uint32_t)((bits * m_lambdaMotionSAD + 128) >> 8); }
 
-    inline uint32_t scaleChromaDistCb(uint32_t dist)           { return (uint32_t)(((dist * m_cbDistortionWeight) + 128) >> 8); }
+    inline uint32_t scaleChromaDistCb(uint32_t dist)
+    {
+        X265_CHECK(abs(((dist * m_cbDistortionWeight + 128) >> 8) -
+                      (float)dist * m_cbDistortionWeight / 256.0) < 2,
+                   "scaleChromaDistCb wrap detected dist: %d, lambda: %d\n", dist, (int)m_cbDistortionWeight);
+        return (uint32_t)(((dist * m_cbDistortionWeight) + 128) >> 8);
+    }
 
-    inline uint32_t scaleChromaDistCr(uint32_t dist)           { return (uint32_t)(((dist * m_crDistortionWeight) + 128) >> 8); }
+    inline uint32_t scaleChromaDistCr(uint32_t dist)
+    {
+        X265_CHECK(abs(((dist * m_crDistortionWeight + 128) >> 8) -
+                      (float)dist * m_crDistortionWeight / 256.0) < 2,
+                   "scaleChromaDistCr wrap detected dist: %d, lambda: %d\n", dist, (int)m_crDistortionWeight);
+        return (uint32_t)(((dist * m_crDistortionWeight) + 128) >> 8);
+    }
 };
 }
 //! \}
diff -r c4adcaef8d1d -r 608267a4f634 source/common/common.h
--- a/source/common/common.h	Mon May 05 00:22:50 2014 -0500
+++ b/source/common/common.h	Tue May 06 20:46:31 2014 -0500
@@ -64,6 +64,18 @@ extern "C" intptr_t x265_stack_align(voi
 
 #endif // if defined(__GNUC__)
 
+/* If compiled with CHECKED_BUILD perform run-time checks and log any that
+ * fail, both to stderr and to a file */
+#if CHECKED_BUILD
+#define X265_CHECK(expr, ...) if (!(expr)) { \
+    x265_log(NULL, X265_LOG_ERROR, __VA_ARGS__); \
+    FILE *fp = fopen("x265_check_failures.txt", "a"); \
+    if (fp) { fprintf(fp, "%s:%d\n", __FILE__, __LINE__); fprintf(fp, __VA_ARGS__); fclose(fp); } \
+}
+#else
+#define X265_CHECK(expr, ...)
+#endif
+
 #if HIGH_BIT_DEPTH
 typedef uint16_t pixel;
 typedef uint32_t sum_t;
diff -r c4adcaef8d1d -r 608267a4f634 source/common/param.cpp
--- a/source/common/param.cpp	Mon May 05 00:22:50 2014 -0500
+++ b/source/common/param.cpp	Tue May 06 20:46:31 2014 -0500
@@ -1099,7 +1099,7 @@ void x265_print_params(x265_param *param
         else
             fprintf(stderr, "sao-frame ");
     }
-    TOOLOPT(param->bEnableSignHiding, "sign-hide");
+    TOOLOPT(param->bEnableSignHiding, "signhide");
     if (param->bEnableTransformSkip)
     {
         if (param->bEnableTSkipFast)
diff -r c4adcaef8d1d -r 608267a4f634 source/common/version.cpp
--- a/source/common/version.cpp	Mon May 05 00:22:50 2014 -0500
+++ b/source/common/version.cpp	Tue May 06 20:46:31 2014 -0500
@@ -68,9 +68,15 @@
 #endif
 
 #if X86_64
-#define NVM_BITS          "[64 bit] "
+#define NVM_BITS        "[64 bit]"
 #else
-#define NVM_BITS          "[32 bit] "
+#define NVM_BITS        "[32 bit]"
+#endif
+
+#if CHECKED_BUILD
+#define CHECKED         "[CHECKED] "
+#else
+#define CHECKED         " "
 #endif
 
 #if HIGH_BIT_DEPTH
@@ -82,4 +88,4 @@ const int x265_max_bit_depth = 8;
 #endif
 
 const char *x265_version_str = XSTR(X265_VERSION);
-const char *x265_build_info_str = NVM_ONOS NVM_COMPILEDBY NVM_BITS BITDEPTH;
+const char *x265_build_info_str = NVM_ONOS NVM_COMPILEDBY NVM_BITS CHECKED BITDEPTH;
diff -r c4adcaef8d1d -r 608267a4f634 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Mon May 05 00:22:50 2014 -0500
+++ b/source/encoder/encoder.cpp	Tue May 06 20:46:31 2014 -0500
@@ -124,7 +124,12 @@ void Encoder::create()
             if (m_csvfpt)
             {
                 if (param->logLevel >= X265_LOG_DEBUG)
-                    fprintf(m_csvfpt, "Encode Order, Type, POC, QP, Bits, Y PSNR, U PSNR, V PSNR, YUV PSNR, SSIM, SSIM (dB), Encoding time, Elapsed time, List 0, List 1\n");
+                {
+                    fprintf(m_csvfpt, "Encode Order, Type, POC, QP, Bits, ");
+                    if (param->rc.rateControlMode == X265_RC_CRF)
+                        fprintf(m_csvfpt, "RateFactor, ");
+                    fprintf(m_csvfpt, "Y PSNR, U PSNR, V PSNR, YUV PSNR, SSIM, SSIM (dB), Encoding time, Elapsed time, List 0, List 1\n");
+                }
                 else
                     fprintf(m_csvfpt, "Command, Date/Time, Elapsed Time, FPS, Bitrate, Y PSNR, U PSNR, V PSNR, Global PSNR, SSIM, SSIM (dB), Version\n");
             }
@@ -898,6 +903,8 @@ void Encoder::finishFrameStats(TComPic* 
         char buf[1024];
         int p;
         p = sprintf(buf, "POC:%d %c QP %2.2lf(%d) %10d bits", poc, c, pic->m_avgQpAq, slice->getSliceQp(), (int)bits);
+        if (param->rc.rateControlMode == X265_RC_CRF)
+            p += sprintf(buf + p, " RF:%.3lf", pic->m_rateFactor);
         if (param->bEnablePsnr)
             p += sprintf(buf + p, " [Y:%6.2lf U:%6.2lf V:%6.2lf]", psnrY, psnrU, psnrV);
         if (param->bEnableSsim)
@@ -923,6 +930,8 @@ void Encoder::finishFrameStats(TComPic* 
         if (m_csvfpt)
         {
             fprintf(m_csvfpt, "%d, %c-SLICE, %4d, %2.2lf, %10d,", m_outputCount++, c, poc, pic->m_avgQpAq, (int)bits);
+            if (param->rc.rateControlMode == X265_RC_CRF)
+                fprintf(m_csvfpt, "%.3lf,", pic->m_rateFactor);
             double psnr = (psnrY * 6 + psnrU + psnrV) / 8;
             if (param->bEnablePsnr)
                 fprintf(m_csvfpt, "%.3lf, %.3lf, %.3lf, %.3lf,", psnrY, psnrU, psnrV, psnr);
diff -r c4adcaef8d1d -r 608267a4f634 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp	Mon May 05 00:22:50 2014 -0500
+++ b/source/encoder/ratecontrol.cpp	Tue May 06 20:46:31 2014 -0500
@@ -207,7 +207,6 @@ RateControl::RateControl(Encoder * _cfg)
     param->rc.rfConstant = Clip3((double)-QP_BD_OFFSET, (double)51, param->rc.rfConstant);
     param->rc.rfConstantMax = Clip3((double)-QP_BD_OFFSET, (double)51, param->rc.rfConstantMax);
     rateFactorMaxIncrement = 0;
-    vbvMinRate = 0;
 
     if (param->rc.rateControlMode == X265_RC_CRF)
     {
@@ -414,7 +413,6 @@ void RateControl::rateControlStart(TComP
         rce->qpaRc = pic->m_avgQpRc = pic->m_avgQpAq = q;
         /* copy value of lastRceq into thread local rce struct *to be used in RateControlEnd() */
         rce->qRceq = lastRceq;
-        rce->qpNoVbv = qpNoVbv;
         accumPQpUpdate();
     }
     else //CQP
@@ -491,8 +489,8 @@ double RateControl::rateEstimateQscale(T
             q += pbOffset / 2;
         else
             q += pbOffset;
-        qpNoVbv = q;
-        double qScale = x265_qp2qScale(qpNoVbv);
+        rce->qpNoVbv = q;


More information about the x265-commits mailing list