[x265-commits] [x265] encoder: fix binary mismatch for analysis load vs save wi...

Gopu Govindaswamy gopu at multicorewareinc.com
Thu Dec 4 03:12:54 CET 2014


details:   http://hg.videolan.org/x265/rev/50d2b92ecc89
branches:  
changeset: 8933:50d2b92ecc89
user:      Gopu Govindaswamy <gopu at multicorewareinc.com>
date:      Wed Dec 03 11:32:33 2014 +0530
description:
encoder: fix binary mismatch for analysis load vs save with same bitrate
Subject: [x265] constants: adjust lambda tabels for 10bit encodes (fixes #55)

details:   http://hg.videolan.org/x265/rev/014a1e0fb58b
branches:  
changeset: 8934:014a1e0fb58b
user:      Steve Borho <steve at borho.org>
date:      Wed Dec 03 10:34:23 2014 -0600
description:
constants: adjust lambda tabels for 10bit encodes (fixes #55)

Since samples are 10bits, where two bits of extra resolution has been added to
add more granularity, distortion also has two extra bits. A typical resolution
for this problem is to down-shift distortion by 2 bits everywhere, before
adding lambda * bits to calculate RD cost. Instead, we multiply lambda by 4
(essentially shift it up by two bits) so distortion and lambda * bits are both
at the higher scale.

lambda2 uses the square of the up-shifted lambda, so it has the doubled up-shift
same as the squared distortion values used for RDO.

Example output change:
./x265 /Volumes/video/sintel_trailer_2k_480p24.y4m o.bin --ssim --no-info

Main:          195.67 kb/s, SSIM Mean Y: 0.9833338 (17.782 dB)
Main10 before: 363.49 kb/s, SSIM Mean Y: 0.9888182 (19.515 dB)
Main10 after:  206.54 kb/s, SSIM Mean Y: 0.9855121 (18.390 dB)
Subject: [x265] doc: add support for reST generated man-pages (closes #89)

details:   http://hg.videolan.org/x265/rev/ff08fd9b294c
branches:  
changeset: 8935:ff08fd9b294c
user:      Steve Borho <steve at borho.org>
date:      Wed Dec 03 11:31:20 2014 -0600
description:
doc: add support for reST generated man-pages (closes #89)

This patch was attached to issue #89 by djcj
Subject: [x265] param: allow NR values from 1..99, clarify docs (closes #87)

details:   http://hg.videolan.org/x265/rev/21b869f9f706
branches:  
changeset: 8936:21b869f9f706
user:      Steve Borho <steve at borho.org>
date:      Wed Dec 03 11:44:05 2014 -0600
description:
param: allow NR values from 1..99, clarify docs (closes #87)
Subject: [x265] doc: fix typo (closes #83)

details:   http://hg.videolan.org/x265/rev/7192725cbb0a
branches:  
changeset: 8937:7192725cbb0a
user:      Steve Borho <steve at borho.org>
date:      Wed Dec 03 12:09:51 2014 -0600
description:
doc: fix typo (closes #83)
Subject: [x265] cmake: remove buggy workarounds for partial SIMD support (fixes #92)

details:   http://hg.videolan.org/x265/rev/d7b5e73fc91a
branches:  
changeset: 8938:d7b5e73fc91a
user:      Steve Borho <steve at borho.org>
date:      Wed Dec 03 19:50:54 2014 -0600
description:
cmake: remove buggy workarounds for partial SIMD support (fixes #92)

In the past, there were a number of primitives written in SIMD intrinsics that
could work without compiling with YASM. Most of those are now gone, and we
generally require YASM for SIMD support. This commit remoes support for using
the few remaining SIMD intrinsics without having YASM to provide
implementations of x265_emms(), x265_cpu_cpuid(), etc. Fixing a bug in the
process.

diffstat:

 doc/reST/Makefile            |  14 ++++++-
 doc/reST/cli.rst             |   4 +-
 doc/reST/conf.py             |   9 ++++
 doc/reST/x265.rst            |  49 ++++++++++++++++++++++++++
 source/common/CMakeLists.txt |  76 ++++++++++++++++++++-------------------
 source/common/constants.cpp  |  43 +++++++++++++++++++++++
 source/common/param.cpp      |   2 +-
 source/common/primitives.cpp |  82 +++++--------------------------------------
 source/encoder/encoder.cpp   |   2 +
 source/x265.cpp              |   2 +-
 source/x265.h                |   4 +-
 11 files changed, 172 insertions(+), 115 deletions(-)

diffs (truncated from 437 to 300 lines):

diff -r de54cffaecf2 -r d7b5e73fc91a doc/reST/Makefile
--- a/doc/reST/Makefile	Tue Dec 02 12:36:41 2014 -0600
+++ b/doc/reST/Makefile	Wed Dec 03 19:50:54 2014 -0600
@@ -13,7 +13,7 @@ PAPEROPT_a4     = -D latex_paper_size=a4
 PAPEROPT_letter = -D latex_paper_size=letter
 ALLSPHINXOPTS   = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
-.PHONY: help clean html web pickle htmlhelp qthelp qhc latex changes linkcheck
+.PHONY: help clean distclean html web pickle htmlhelp qthelp qhc latex changes linkcheck
 
 help:
 	@echo "Please use \`make <target>' where <target> is one of"
@@ -24,12 +24,16 @@ help:
 	@echo "  qthelp    to make HTML files and a qthelp project"
 	@echo "  qhc       to make QHC file"
 	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  man       to make manpages"
 	@echo "  changes   to make an overview over all changed/added/deprecated items"
 	@echo "  linkcheck to check all external links for integrity"
 
 clean:
 	-rm -rf build/*
 
+distclean: clean
+	-rmdir build/
+
 html:
 	mkdir -p build/html build/doctrees
 	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
@@ -83,6 +87,14 @@ latex:
 	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
 	      "run these through (pdf)latex."
 
+man:
+	mkdir -p build/man build/doctrees
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) build/man
+	@echo
+	@echo "Build finished; the manpages are in build/man."
+	@echo "Run \`man -l build/man/x265.1' or \`man -l build/man/libx265.3'" \
+	      "to view them."
+
 changes:
 	mkdir -p build/changes build/doctrees
 	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
diff -r de54cffaecf2 -r d7b5e73fc91a doc/reST/cli.rst
--- a/doc/reST/cli.rst	Tue Dec 02 12:36:41 2014 -0600
+++ b/doc/reST/cli.rst	Wed Dec 03 19:50:54 2014 -0600
@@ -937,7 +937,7 @@ Quality, rate control and rate distortio
 	numbers of frame threads. Outputs will be deterministic but the
 	outputs of -F2 will no longer match the outputs of -F3, etc.
 
-	**Values:** any value in range of 100 to 2000. Default disabled.
+	**Values:** any value in range of 0 to 2000. Default 0 (disabled).
 
 .. option:: --pass <integer>
 
@@ -1237,7 +1237,7 @@ VUI fields must be manually specified.
 	9. bt2020nc
 	10. bt2020c
 
-.. option:: --chromalocs <0..5>
+.. option:: --chromaloc <0..5>
 
 	Specify chroma sample location for 4:2:0 inputs. Consult the HEVC
 	specification for a description of these values. Default undefined
diff -r de54cffaecf2 -r d7b5e73fc91a doc/reST/conf.py
--- a/doc/reST/conf.py	Tue Dec 02 12:36:41 2014 -0600
+++ b/doc/reST/conf.py	Wed Dec 03 19:50:54 2014 -0600
@@ -15,3 +15,12 @@ copyright = u'2014 MulticoreWare Inc'
 
 # -- Options for HTML output ---------------------------------------------------
 html_theme = "default"
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'libx265', 'Full x265 Documentation',
+    ['MulticoreWare Inc'], 3),
+    ('x265', 'x265', 'x265 CLI Documentation',
+    ['MulticoreWare Inc'], 1)
+]
diff -r de54cffaecf2 -r d7b5e73fc91a doc/reST/x265.rst
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/reST/x265.rst	Wed Dec 03 19:50:54 2014 -0600
@@ -0,0 +1,49 @@
+x265 CLI Documentation
+######################
+
+
+SYNOPSIS
+========
+
+**x265** [options] infile [-o] outfile
+
+Bit depth: 8
+
+
+**x265-10bit** [options] infile [-o] outfile
+
+Bit depth: 10
+
+
+infile can be YUV or Y4M
+
+outfile is raw HEVC bitstream
+
+
+DESCRIPTION
+===========
+
+.. toctree::
+   :maxdepth: 2
+
+   introduction
+
+
+OPTIONS
+=======
+
+.. toctree::
+   :maxdepth: 2
+
+   cli
+   presets
+   lossless
+
+
+SEE ALSO
+========
+
+**libx265**\(3)
+
+Online documentation: http://x265.readthedocs.org/en/default/cli.html
+
diff -r de54cffaecf2 -r d7b5e73fc91a source/common/CMakeLists.txt
--- a/source/common/CMakeLists.txt	Tue Dec 02 12:36:41 2014 -0600
+++ b/source/common/CMakeLists.txt	Wed Dec 03 19:50:54 2014 -0600
@@ -1,44 +1,46 @@
 # vim: syntax=cmake
-set(SSE3  vec/dct-sse3.cpp)
-set(SSSE3 vec/dct-ssse3.cpp)
-set(SSE41 vec/dct-sse41.cpp)
-
-if(MSVC AND X86)
-    set(PRIMITIVES ${SSE3} ${SSSE3} ${SSE41})
-    set(WARNDISABLE "/wd4100") # unreferenced formal parameter
-    if(INTEL_CXX)
-        add_definitions(/Qwd111) # statement is unreachable
-        add_definitions(/Qwd128) # loop is unreachable
-        add_definitions(/Qwd177) # declared function is unused
-        add_definitions(/Qwd185) # dynamic initialization in unreachable code
-        add_definitions(/Qwd280) # conditional expression is constant
-    endif()
-    if(X64)
-        set_source_files_properties(${SSE3} ${SSSE3} ${SSE41} PROPERTIES COMPILE_FLAGS "${WARNDISABLE}")
-    else()
-        # x64 implies SSE4, so only add /arch:SSE2 if building for Win32
-        set_source_files_properties(${SSE3} ${SSSE3} ${SSE41} PROPERTIES COMPILE_FLAGS "${WARNDISABLE} /arch:SSE2")
-    endif()
-endif()
-if(GCC AND X86)
-    if(CLANG)
-        # llvm intrinsic headers cause shadow warnings
-        set(WARNDISABLE "-Wno-shadow -Wno-unused-parameter")
-    else()
-        set(WARNDISABLE "-Wno-unused-parameter")
-    endif()
-    if(INTEL_CXX OR CLANG OR (NOT CC_VERSION VERSION_LESS 4.3))
-        set(PRIMITIVES ${SSE3} ${SSSE3} ${SSE41})
-        set_source_files_properties(${SSE3}  PROPERTIES COMPILE_FLAGS "${WARNDISABLE} -msse3")
-        set_source_files_properties(${SSSE3} PROPERTIES COMPILE_FLAGS "${WARNDISABLE} -mssse3")
-        set_source_files_properties(${SSE41} PROPERTIES COMPILE_FLAGS "${WARNDISABLE} -msse4.1")
-    endif()
-endif()
-set(VEC_PRIMITIVES vec/vec-primitives.cpp ${PRIMITIVES})
-source_group(Intrinsics FILES ${VEC_PRIMITIVES})
 
 if(ENABLE_ASSEMBLY)
     set_source_files_properties(primitives.cpp PROPERTIES COMPILE_FLAGS -DENABLE_ASSEMBLY=1)
+
+    set(SSE3  vec/dct-sse3.cpp)
+    set(SSSE3 vec/dct-ssse3.cpp)
+    set(SSE41 vec/dct-sse41.cpp)
+
+    if(MSVC AND X86)
+        set(PRIMITIVES ${SSE3} ${SSSE3} ${SSE41})
+        set(WARNDISABLE "/wd4100") # unreferenced formal parameter
+        if(INTEL_CXX)
+            add_definitions(/Qwd111) # statement is unreachable
+            add_definitions(/Qwd128) # loop is unreachable
+            add_definitions(/Qwd177) # declared function is unused
+            add_definitions(/Qwd185) # dynamic initialization in unreachable code
+            add_definitions(/Qwd280) # conditional expression is constant
+        endif()
+        if(X64)
+            set_source_files_properties(${SSE3} ${SSSE3} ${SSE41} PROPERTIES COMPILE_FLAGS "${WARNDISABLE}")
+        else()
+            # x64 implies SSE4, so only add /arch:SSE2 if building for Win32
+            set_source_files_properties(${SSE3} ${SSSE3} ${SSE41} PROPERTIES COMPILE_FLAGS "${WARNDISABLE} /arch:SSE2")
+        endif()
+    endif()
+    if(GCC AND X86)
+        if(CLANG)
+            # llvm intrinsic headers cause shadow warnings
+            set(WARNDISABLE "-Wno-shadow -Wno-unused-parameter")
+        else()
+            set(WARNDISABLE "-Wno-unused-parameter")
+        endif()
+        if(INTEL_CXX OR CLANG OR (NOT CC_VERSION VERSION_LESS 4.3))
+            set(PRIMITIVES ${SSE3} ${SSSE3} ${SSE41})
+            set_source_files_properties(${SSE3}  PROPERTIES COMPILE_FLAGS "${WARNDISABLE} -msse3")
+            set_source_files_properties(${SSSE3} PROPERTIES COMPILE_FLAGS "${WARNDISABLE} -mssse3")
+            set_source_files_properties(${SSE41} PROPERTIES COMPILE_FLAGS "${WARNDISABLE} -msse4.1")
+        endif()
+    endif()
+    set(VEC_PRIMITIVES vec/vec-primitives.cpp ${PRIMITIVES})
+    source_group(Intrinsics FILES ${VEC_PRIMITIVES})
+
     set(C_SRCS asm-primitives.cpp pixel.h mc.h ipfilter8.h blockcopy8.h dct8.h loopfilter.h)
     set(A_SRCS pixel-a.asm const-a.asm cpu-a.asm ssd-a.asm mc-a.asm
                mc-a2.asm pixel-util8.asm blockcopy8.asm
diff -r de54cffaecf2 -r d7b5e73fc91a source/common/constants.cpp
--- a/source/common/constants.cpp	Tue Dec 02 12:36:41 2014 -0600
+++ b/source/common/constants.cpp	Wed Dec 03 19:50:54 2014 -0600
@@ -27,6 +27,47 @@
 
 namespace x265 {
 
+#if HIGH_BIT_DEPTH
+// lambda = pow(2, (double)q / 6 - 2) * (1 << (X265_DEPTH - 8));
+double x265_lambda_tab[QP_MAX_MAX + 1] =
+{
+    1.0000, 1.1225, 1.2599, 1.4142, 1.5874, 
+    1.7818, 2.0000, 2.2449, 2.5198, 2.8284, 
+    3.1748, 3.5636, 4.0000, 4.4898, 5.0397, 
+    5.6569, 6.3496, 7.1272, 8.0000, 8.9797, 
+    10.0794, 11.3137, 12.6992, 14.2544, 16.0000, 
+    17.9594, 20.1587, 22.6274, 25.3984, 28.5088, 
+    32.0000, 35.9188, 40.3175, 45.2548, 50.7968, 
+    57.0175, 64.0000, 71.8376, 80.6349, 90.5097, 
+    101.5937, 114.0350, 128.0000, 143.6751, 161.2699, 
+    181.0193, 203.1873, 228.0701, 256.0000, 287.3503, 
+    322.5398, 362.0387, 406.3747, 456.1401, 512.0000, 
+    574.7006, 645.0796, 724.0773, 812.7493, 912.2803, 
+    1024.0000, 1149.4011, 1290.1592, 1448.1547, 1625.4987, 
+    1824.5606, 2048.0000, 2298.8023, 2580.3183, 2896.3094,
+};
+
+// lambda2 = pow(lambda, 2) * scale (0.85);
+double x265_lambda2_tab[QP_MAX_MAX + 1] =
+{
+    0.8500, 1.0709, 1.3493, 1.7000, 2.1419, 
+    2.6986, 3.4000, 4.2837, 5.3972, 6.8000, 
+    8.5675, 10.7943, 13.6000, 17.1349, 21.5887, 
+    27.2000, 34.2699, 43.1773, 54.4000, 68.5397, 
+    86.3546, 108.8000, 137.0794, 172.7092, 217.6000, 
+    274.1588, 345.4185, 435.2000, 548.3176, 690.8369, 
+    870.4000, 1096.6353, 1381.6739, 1740.8000, 2193.2706, 
+    2763.3478, 3481.6000, 4386.5411, 5526.6955, 6963.2000, 
+    8773.0823, 11053.3910, 13926.4000, 17546.1645, 22106.7820, 
+    27852.8000, 35092.3290, 44213.5640, 55705.6000, 70184.6580, 
+    88427.1280, 111411.2000, 140369.3161, 176854.2561, 222822.4000, 
+    280738.6321, 353708.5122, 445644.8000, 561477.2643, 707417.0243, 
+    891289.6000, 1122954.5286, 1414834.0486, 1782579.2000, 2245909.0572, 
+    2829668.0973, 3565158.4000, 4491818.1144, 5659336.1946, 7130316.8000, 
+};
+
+#else /* !HIGH_BIT_DEPTH */
+
 // lambda = pow(2, (double)q / 6 - 2);
 double x265_lambda_tab[QP_MAX_MAX + 1] =
 {
@@ -65,6 +106,8 @@ double x265_lambda2_tab[QP_MAX_MAX + 1] 
     176854.2222, 222822.4000, 280738.6627, 353708.5368, 445644.7459
 };
 
+#endif
+
 const uint16_t x265_chroma_lambda2_offset_tab[MAX_CHROMA_LAMBDA_OFFSET+1] =
 {
        16,    20,    25,    32,    40,    50,
diff -r de54cffaecf2 -r d7b5e73fc91a source/common/param.cpp
--- a/source/common/param.cpp	Tue Dec 02 12:36:41 2014 -0600
+++ b/source/common/param.cpp	Wed Dec 03 19:50:54 2014 -0600
@@ -1079,7 +1079,7 @@ int x265_check_params(x265_param *param)
     CHECK(param->rc.qCompress < 0.5 || param->rc.qCompress > 1.0,
           "qCompress must be between 0.5 and 1.0");
     if (param->noiseReduction)
-        CHECK(100 > param->noiseReduction || param->noiseReduction > 2000, "Valid noise reduction range 100 - 1000");
+        CHECK(0 > param->noiseReduction || param->noiseReduction > 2000, "Valid noise reduction range 0 - 2000");
     CHECK(param->rc.rateControlMode == X265_RC_CRF && param->rc.bStatRead,
           "Constant rate-factor is incompatible with 2pass");
     CHECK(param->rc.rateControlMode == X265_RC_CQP && param->rc.bStatRead,
diff -r de54cffaecf2 -r d7b5e73fc91a source/common/primitives.cpp
--- a/source/common/primitives.cpp	Tue Dec 02 12:36:41 2014 -0600
+++ b/source/common/primitives.cpp	Wed Dec 03 19:50:54 2014 -0600
@@ -123,9 +123,9 @@ void x265_setup_primitives(x265_param *p
     if (!primitives.sad[0])
     {
         Setup_C_Primitives(primitives);


More information about the x265-commits mailing list