Overview

Request 5395 (accepted)

- Update to version 3.5
New features:
* Real-time VBV for ABR (Average BitRate) encodes in –pass 2
using --vbv-live-multi-pass. Improves VBV compliance with no
significant impact on coding efficiency.
Enhancements to existing features:
* Improved hist-based scene cut algorithm: Reduces false
positives by leveraging motion and scene transition info.
* Support for RADL pictures at IDR scene cuts: Improves coding
efficiency with no significant impact on performance.
* Bidirectional scene cut aware Frame Quantizer Selection:
Saves bits than forward masking with no noticeable perceptual
quality difference.
API changes:
* Additions to x265_param structure to support the newly added
features and encoder enhancements.
* New x265_param options --min-vbv-fullness and
--max-vbv-fullness to control min and max VBV fullness.
Bug fixes:
* Incorrect VBV lookahead in --analysis-load + --scale-factor.
* Encoder hang when VBV is used with slices.
* QP spikes in the row-level VBV rate-control when WPP enabled.
* Encoder crash in --abr-ladder.
- Use new homepage and download URLs.
- Add subpackage for HDR10+ library
- Add update.sh

Submit package Staging / x265 to package Essentials / x265

x265.changes Changed
x
 
1
@@ -1,4 +1,34 @@
2
 -------------------------------------------------------------------
3
+Fri Mar 26 12:02:14 UTC 2021 - Luigi Baldoni <aloisio@gmx.com>
4
+
5
+- Update to version 3.5
6
+  New features:
7
+  * Real-time VBV for ABR (Average BitRate) encodes in –pass 2
8
+    using --vbv-live-multi-pass. Improves VBV compliance with no
9
+    significant impact on coding efficiency.
10
+  Enhancements to existing features:
11
+  * Improved hist-based scene cut algorithm: Reduces false
12
+    positives by leveraging motion and scene transition info.
13
+  * Support for RADL pictures at IDR scene cuts: Improves coding
14
+    efficiency with no significant impact on performance.
15
+  * Bidirectional scene cut aware Frame Quantizer Selection:
16
+    Saves bits than forward masking with no noticeable perceptual
17
+    quality difference.
18
+  API changes:
19
+  * Additions to x265_param structure to support the newly added
20
+    features and encoder enhancements.
21
+  * New x265_param options --min-vbv-fullness and
22
+    --max-vbv-fullness to control min and max VBV fullness.
23
+  Bug fixes:
24
+  * Incorrect VBV lookahead in --analysis-load + --scale-factor.
25
+  * Encoder hang when VBV is used with slices.
26
+  * QP spikes in the row-level VBV rate-control when WPP enabled.
27
+  * Encoder crash in --abr-ladder.
28
+- Use new homepage and download URLs.
29
+- Add subpackage for HDR10+ library
30
+- Add update.sh
31
+
32
+-------------------------------------------------------------------
33
 Mon Jun  1 17:51:22 UTC 2020 - Luigi Baldoni <aloisio@gmx.com>
34
 
35
 - Update to version 3.4
36
x265.spec Changed
130
 
1
@@ -1,7 +1,7 @@
2
 #
3
 # spec file for package x265
4
 #
5
-# Copyright (c) 2020 Packman Team <packman@links2linux.de>
6
+# Copyright (c) 2021 Packman Team <packman@links2linux.de>
7
 # Copyright (c) 2014 Torsten Gruner <t.gruner@katodev.de>
8
 #
9
 # All modifications and additions to the file contributed by third parties
10
@@ -17,17 +17,18 @@
11
 #
12
 
13
 
14
-%define sover  192
15
+%define sover   199
16
 %define libname lib%{name}
17
 %define libsoname %{libname}-%{sover}
18
+%define uver    3_5
19
 Name:           x265
20
-Version:        3.4
21
+Version:        3.5
22
 Release:        0
23
 Summary:        A free h265/HEVC encoder - encoder binary
24
 License:        GPL-2.0-or-later
25
 Group:          Productivity/Multimedia/Video/Editors and Convertors
26
-URL:            https://bitbucket.org/multicoreware/x265/wiki/Home
27
-Source0:        https://bitbucket.org/multicoreware/x265/downloads/%{name}_%{version}.tar.gz
28
+URL:            https://bitbucket.org/multicoreware/x265_git
29
+Source0:        https://bitbucket.org/multicoreware/x265_git/downloads/%{name}_%{version}.tar.gz
30
 Patch0:         arm.patch
31
 Patch1:         x265.pkgconfig.patch
32
 Patch2:         x265-fix_enable512.patch
33
@@ -51,10 +52,18 @@
34
 x265 is a free library for encoding next-generation H265/HEVC video
35
 streams.
36
 
37
+%package -n libhdr10plus-%{uver}
38
+Summary:        A free HDR10+ library
39
+Group:          Productivity/Multimedia/Video/Editors and Convertors
40
+
41
+%description -n libhdr10plus-%{uver}
42
+A free library supporting HDR10+.
43
+
44
 %package -n %{libname}-devel
45
 Summary:        Libraries and include file for the %{libname} encoder
46
 Group:          Development/Libraries/C and C++
47
 Requires:       %{libsoname} = %{version}-%{release}
48
+Requires:       libhdr10plus-%{uver} = %{version}-%{release}
49
 Provides:       %{name}-devel = %{version}
50
 Obsoletes:      %{name}-devel < %{version}
51
 
52
@@ -67,12 +76,15 @@
53
 %patch0 -p1
54
 %patch1 -p1
55
 %patch2 -p1
56
-sed -i -e "s/0.0/%{sover}.0/g" source/cmake/version.cmake
57
-
58
+# set the version by hand
59
+sed -i "/^include(Version)/d" source/CMakeLists.txt
60
+# force version number in the soname
61
+sed -i 's/hdr10plus-shared PROPERTIES OUTPUT_NAME hdr10plus/hdr10plus-shared PROPERTIES OUTPUT_NAME hdr10plus-%{version}/' \
62
+       source/CMakeLists.txt
63
 
64
 %build
65
 SOURCE_DIR="$PWD"/source
66
-COMMON_FLAGS="-DENABLE_TESTS=OFF -DENABLE_PIC=ON"
67
+COMMON_FLAGS="-DENABLE_TESTS=OFF -DENABLE_PIC=ON -Wno-dev"
68
 HIGH_BIT_DEPTH_FLAGS="-DENABLE_CLI=OFF -DENABLE_SHARED=OFF -DEXPORT_C_API=OFF -DHIGH_BIT_DEPTH=ON"
69
 
70
 %if 0%{?suse_version} >= 1500
71
@@ -104,16 +116,24 @@
72
 # Build general version of the library linking in the 10/12bit depth versions
73
 %define __builddir ./source/build
74
 %cmake -DENABLE_TESTS=OFF \
75
+       -DENABLE_SHARED=ON \
76
+       -DX265_LATEST_TAG="%{sover}.0" \
77
+       -DX265_VERSION="%{version}" \
78
+       -DENABLE_HDR10_PLUS=ON \
79
        -DENABLE_PIC=ON \
80
        -DENABLE_CLI=ON \
81
        -DLINKED_10BIT=ON \
82
        -DLINKED_12BIT=ON \
83
        -DEXTRA_LINK_FLAGS="-L$SOURCE_DIR/build-10bit -L$SOURCE_DIR/build-12bit" \
84
-       -DEXTRA_LIB="x265_main10.a;x265_main12.a"
85
-
86
+       -DEXTRA_LIB="x265_main10.a;x265_main12.a" \
87
+       -Wno-dev
88
 %else
89
 cd source
90
-%cmake $COMMON_FLAGS
91
+%cmake $COMMON_FLAGS \
92
+       -DENABLE_SHARED=ON \
93
+       -DX265_LATEST_TAG="%{sover}.0" \
94
+       -DX265_VERSION="%{version}" \
95
+       -DENABLE_HDR10_PLUS=ON
96
 %endif
97
 make %{?_smp_mflags}
98
 cd ../../
99
@@ -123,15 +143,20 @@
100
 cd source
101
 %endif
102
 %cmake_install
103
-rm -f %{buildroot}%{_libdir}/%{libname}.a
104
-echo "%{libname}-%{sover}" > %{_sourcedir}/baselibs.conf
105
+find %{buildroot} -type f -name "*.a" -delete -print0
106
 
107
 %post -n %{libsoname} -p /sbin/ldconfig
108
 %postun -n %{libsoname} -p /sbin/ldconfig
109
 
110
+%post -n libhdr10plus-%{uver} -p /sbin/ldconfig
111
+%postun -n libhdr10plus-%{uver} -p /sbin/ldconfig
112
+
113
 %files -n %{libsoname}
114
 %{_libdir}/%{libname}.so.%{sover}*
115
 
116
+%files -n libhdr10plus-%{uver}
117
+%{_libdir}/libhdr10plus-%{version}.so
118
+
119
 %files
120
 %{_bindir}/%{name}
121
 
122
@@ -140,6 +165,7 @@
123
 %doc readme.rst
124
 %{_includedir}/%{name}.h
125
 %{_includedir}/%{name}_config.h
126
+%{_includedir}/hdr10plus.h
127
 %{_libdir}/pkgconfig/%{name}.pc
128
 %{_libdir}/%{libname}.so
129
 
130
baselibs.conf Changed
4
 
1
@@ -1,1 +1,1 @@
2
-libx265-192
3
+libx265-199
4
update.sh Added
12
 
1
@@ -0,0 +1,10 @@
2
+#!/bin/sh
3
+
4
+rm -f x265_*.tar.gz
5
+osc service disabledrun download_files
6
+version=$(grep ^Version x265.spec|awk '{print $2}')
7
+echo "The new version is:" $version
8
+api=$(tar xzfO x265_${version}.tar.gz x265_${version}/source/CMakeLists.txt|grep "set(X265_BUILD"|sed 's/^.* \([1-9][0-9]*\).*$/\1/')
9
+echo "The new api version is:" $api
10
+echo "libx265-${api}" > baselibs.conf
11
+sed -i "/^%define sover/c%define sover   ${api}" x265.spec
12
x265_3.4.tar.gz/.hg_archival.txt Deleted
6
 
1
@@ -1,4 +0,0 @@
2
-repo: 09fe40627f03a0f9c3e6ac78b22ac93da23f9fdf
3
-node: 2a65b720985096bcb1664f7cb05c3d04aeb576f5
4
-branch: Release_3.4
5
-tag: 3.4
6
x265_3.4.tar.gz/source/cmake/version.cmake Deleted
107
 
1
@@ -1,105 +0,0 @@
2
-if(CMAKE_VERSION VERSION_LESS "2.8.10")
3
-    find_program(HG_EXECUTABLE hg)
4
-else()
5
-    find_package(Hg QUIET)
6
-endif()
7
-find_package(Git QUIET) # present in 2.8.8
8
-
9
-# defaults, in case everything below fails
10
-set(X265_VERSION "unknown")
11
-set(X265_LATEST_TAG "0.0")
12
-set(X265_TAG_DISTANCE "0")
13
-
14
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt)
15
-    # read the lines of the archive summary file to extract the version
16
-    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt archive)
17
-    STRING(REGEX REPLACE "\n" ";" archive "${archive}")
18
-    foreach(f ${archive})
19
-        string(FIND "${f}" ": " pos)
20
-        string(SUBSTRING "${f}" 0 ${pos} key)
21
-        string(SUBSTRING "${f}" ${pos} -1 value)
22
-        string(SUBSTRING "${value}" 2 -1 value)
23
-        set(hg_${key} ${value})
24
-    endforeach()
25
-    if(DEFINED hg_tag)
26
-        set(X265_LATEST_TAG ${hg_tag})
27
-    elseif(DEFINED hg_node)
28
-        set(X265_LATEST_TAG ${hg_latesttag})
29
-        set(X265_TAG_DISTANCE ${hg_latesttagdistance})
30
-        string(SUBSTRING "${hg_node}" 0 12 X265_REVISION_ID)
31
-    endif()
32
-elseif(HG_EXECUTABLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg)
33
-    if(EXISTS "${HG_EXECUTABLE}.bat")
34
-        # mercurial source installs on Windows require .bat extension
35
-        set(HG_EXECUTABLE "${HG_EXECUTABLE}.bat")
36
-    endif()
37
-    message(STATUS "hg found at ${HG_EXECUTABLE}")
38
-
39
-    execute_process(COMMAND
40
-        ${HG_EXECUTABLE} log -r. --template "{latesttag}"
41
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
42
-        OUTPUT_VARIABLE X265_LATEST_TAG
43
-        ERROR_QUIET
44
-        OUTPUT_STRIP_TRAILING_WHITESPACE
45
-        )
46
-    execute_process(COMMAND
47
-        ${HG_EXECUTABLE} log -r. --template "{latesttagdistance}"
48
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
49
-        OUTPUT_VARIABLE X265_TAG_DISTANCE
50
-        ERROR_QUIET
51
-        OUTPUT_STRIP_TRAILING_WHITESPACE
52
-        )
53
-    execute_process(
54
-        COMMAND
55
-        ${HG_EXECUTABLE} log -r. --template "{node}"
56
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
57
-        OUTPUT_VARIABLE X265_REVISION_ID
58
-        ERROR_QUIET
59
-        OUTPUT_STRIP_TRAILING_WHITESPACE
60
-        )
61
-    string(SUBSTRING "${X265_REVISION_ID}" 0 12 X265_REVISION_ID)
62
-
63
-    if(X265_LATEST_TAG MATCHES "^r")
64
-        string(SUBSTRING ${X265_LATEST_TAG} 1 -1 X265_LATEST_TAG)
65
-    endif()
66
-elseif(GIT_EXECUTABLE AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git)
67
-    execute_process(
68
-        COMMAND
69
-        ${GIT_EXECUTABLE} rev-list --tags --max-count=1
70
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
71
-        OUTPUT_VARIABLE X265_LATEST_TAG_COMMIT
72
-        ERROR_QUIET
73
-        OUTPUT_STRIP_TRAILING_WHITESPACE
74
-        )
75
-    execute_process(
76
-        COMMAND
77
-        ${GIT_EXECUTABLE} describe --tags ${X265_LATEST_TAG_COMMIT}
78
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
79
-        OUTPUT_VARIABLE X265_LATEST_TAG
80
-        ERROR_QUIET
81
-        OUTPUT_STRIP_TRAILING_WHITESPACE
82
-        )
83
-    execute_process(
84
-        COMMAND
85
-        ${GIT_EXECUTABLE} rev-list ${X265_LATEST_TAG}.. --count --first-parent
86
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
87
-        OUTPUT_VARIABLE X265_TAG_DISTANCE
88
-        ERROR_QUIET
89
-        OUTPUT_STRIP_TRAILING_WHITESPACE
90
-        )
91
-    execute_process(
92
-        COMMAND
93
-        ${GIT_EXECUTABLE} log -1 --format=g%h
94
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
95
-        OUTPUT_VARIABLE X265_REVISION_ID
96
-        ERROR_QUIET
97
-        OUTPUT_STRIP_TRAILING_WHITESPACE
98
-        )
99
-endif()
100
-if(X265_TAG_DISTANCE STREQUAL "0")
101
-    set(X265_VERSION "${X265_LATEST_TAG}")
102
-else()
103
-    set(X265_VERSION "${X265_LATEST_TAG}+${X265_TAG_DISTANCE}-${X265_REVISION_ID}")
104
-endif()
105
-
106
-message(STATUS "x265 version ${X265_VERSION}")
107
x265_3.5.tar.gz/. Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/aarch64-linux Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/arm-linux Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/linux Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/msys Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/msys-cl Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc10-x86 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc10-x86_64 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc11-x86 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc11-x86_64 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc12-x86 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc12-x86_64 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc15-x86 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc15-x86_64 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc9-x86 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/vc9-x86_64 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/build/xcode Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/doc Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/doc/intra Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/doc/reST Added
2
 
1
+(directory)
2
x265_3.4.tar.gz/doc/reST/cli.rst -> x265_3.5.tar.gz/doc/reST/cli.rst Changed
665
 
1
@@ -36,13 +36,26 @@
2
 
3
 .. option:: --help, -h
4
 
5
-   Display help text
6
+   Displays help text
7
 
8
    **CLI ONLY**
9
 
10
 .. option:: --version, -V
11
 
12
-   Display version details
13
+   Displays version details in the following manner *[Version Name]+/-[Number of commits from the release changeset]-/+[repository's head changeset  SHA-1 paraphrase identifier]*
14
+   along with the compilation platform, build information and supported cpu capabilities.
15
+
16
+   In case of release tar balls version information is partly derived from configuration file *x265Version.txt*
17
+   .. seeAlso::  For more information on how to configure the version file please refer to `<https://bitbucket.org/multicoreware/x265_git/wiki/Home>`_  and Contribute pages for updates specific
18
+   release and version control management.
19
+
20
+   **Example:**
21
+
22
+   *x265 [info]: HEVC encoder version 3.4+27-'d9217cf00'*
23
+
24
+   *x265 [info]: build info [Windows][MSVC 1916][64 bit] 10bit*
25
+
26
+   *x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2*
27
 
28
    **CLI ONLY**
29
 
30
@@ -141,7 +154,7 @@
31
    **Residual Energy** Average residual energy. SSE is calculated on fenc 
32
    and pred(before quantization).
33
    
34
-   **Luma/Chroma Values** minumum, maximum and average(averaged by area)
35
+   **Luma/Chroma Values** minimum, maximum and average(averaged by area)
36
    luma and chroma values of source for each frame.
37
    
38
    **PU Statistics** percentage of PU modes at each depth.
39
@@ -246,7 +259,7 @@
40
 
41
 .. option:: --pools <string>, --numa-pools <string>
42
 
43
-   Comma seperated list of threads per NUMA node. If "none", then no worker
44
+   Comma separated list of threads per NUMA node. If "none", then no worker
45
    pools are created and only frame parallelism is possible. If NULL or ""
46
    (default) x265 will use all available threads on each NUMA node::
47
 
48
@@ -284,7 +297,7 @@
49
    the last thread pool is spawned only if it has more than 32 threads for
50
    64-bit machines, or 16 for 32-bit machines. If the total number of threads
51
    in the system doesn't obey this constraint, we may spawn fewer threads
52
-   than cores which has been emperically shown to be better for performance. 
53
+   than cores which has been empirically shown to be better for performance. 
54
 
55
    If the four pool features: :option:`--wpp`, :option:`--pmode`,
56
    :option:`--pme` and :option:`--lookahead-slices` are all disabled,
57
@@ -409,7 +422,7 @@
58
 
59
    Allow encoder to copy input x265 pictures to internal frame buffers. When disabled,
60
    x265 will not make an internal copy of the input picture and will work with the
61
-   application's buffers. While this allows for deeper integration, it is the responsbility
62
+   application's buffers. While this allows for deeper integration, it is the responsibility
63
    of the application to (a) ensure that the allocated picture has extra space for padding
64
    that will be done by the library, and (b) the buffers aren't recycled until the library
65
    has completed encoding this frame (which can be figured out by tracking NALs output by x265)
66
@@ -554,7 +567,7 @@
67
 
68
 .. option:: --chunk-start <integer>
69
 
70
-   First frame of the chunk. Frames preceeding this in display order will
71
+   First frame of the chunk. Frames preceding this in display order will
72
    be encoded, however, they will be discarded in the bitstream. This
73
    feature can be enabled only in closed GOP structures.
74
    Default 0 (disabled).
75
@@ -562,7 +575,7 @@
76
 .. option:: --chunk-end <integer>
77
 
78
    Last frame of the chunk. Frames following this in display order will be
79
-   used in taking lookahead decisions, but, they will not be encoded.
80
+   used in taking lookahead decisions, but they will not be encoded.
81
    This feature can be enabled only in closed GOP structures.
82
    Default 0 (disabled).
83
 
84
@@ -638,7 +651,7 @@
85
    If :option:`--level-idc` has been specified, --high-tier allows the
86
    support of high tier at that level. The encoder will first attempt to encode 
87
    at the specified level, main tier first, turning on high tier only if 
88
-   necessary and available at that level.If your requested level does not 
89
+   necessary and available at that level. If your requested level does not 
90
    support a High tier, high tier will not be supported. If --no-high-tier 
91
    has been specified, then the encoder will attempt to encode only at the main tier.
92
 
93
@@ -647,8 +660,8 @@
94
 .. option:: --ref <1..16>
95
 
96
    Max number of L0 references to be allowed. This number has a linear
97
-   multiplier effect on the amount of work performed in motion search,
98
-   but will generally have a beneficial affect on compression and
99
+   multiplier effect on the amount of work performed in motion search
100
+   but will generally have a beneficial effect on compression and
101
    distortion.
102
    
103
    Note that x265 allows up to 16 L0 references but the HEVC
104
@@ -668,7 +681,7 @@
105
 .. option:: --allow-non-conformance, --no-allow-non-conformance
106
 
107
    Allow libx265 to generate a bitstream with profile and level NONE.
108
-   By default it will abort any encode which does not meet strict level
109
+   By default, it will abort any encode which does not meet strict level
110
    compliance. The two most likely causes for non-conformance are
111
    :option:`--ctu` being too small, :option:`--ref` being too high,
112
    or the bitrate or resolution being out of specification.
113
@@ -727,7 +740,7 @@
114
    used. The lower the value the faster the encode, the higher the
115
    value the smaller the bitstream (in general). Default 3
116
 
117
-   Note that this table aims for accuracy, but is not necessarily our
118
+   Note that this table aims for accuracy but is not necessarily our
119
    final target behavior for each mode.
120
 
121
    +-------+---------------------------------------------------------------+
122
@@ -758,7 +771,7 @@
123
 
124
    Maximum CU size (width and height). The larger the maximum CU size,
125
    the more efficiently x265 can encode flat areas of the picture,
126
-   giving large reductions in bitrate. However this comes at a loss of
127
+   giving large reductions in bitrate. However, this comes at a loss of
128
    parallelism with fewer rows of CUs that can be encoded in parallel,
129
    and less frame parallelism as well. Because of this the faster
130
    presets use a CU size of 32. Default: 64
131
@@ -799,7 +812,7 @@
132
 
133
    For all non-zero values of limit-refs, the current depth will evaluate
134
    intra mode (in inter slices), only if intra mode was chosen as the best
135
-   mode for atleast one of the 4 sub-blocks.
136
+   mode for at least one of the 4 sub-blocks.
137
 
138
    You can often increase the number of references you are using
139
    (within your decoder level limits) if you enable one or
140
@@ -863,13 +876,12 @@
141
 
142
    Provides minimal quality degradation at good performance gains for non-zero modes.
143
    :option:`--rskip mode 0` means disabled. Default: 1, disabled when :option:`--tune grain` is used.
144
-   This is a integer value representing the edge-density percentage within the CU. Internally normalized to a number between 0.0 to 1.0 in x265. 
145
-   Recommended low thresholds for slow encodes and high for fast encodes.
146
 
147
 .. option:: --rskip-edge-threshold <0..100>
148
 
149
    Denotes the minimum expected edge-density percentage within the CU, below which the recursion is skipped.
150
-   Default: 5, requires :option:`--rskip mode 2` to be enabled.
151
+   Internally normalized to decimal value in x265 library. Recommended low thresholds for slow encodes and high
152
+   for fast encodes. Default: 5, requires :option:`--rskip mode 2` to be enabled.
153
 
154
 .. option:: --splitrd-skip, --no-splitrd-skip
155
 
156
@@ -928,7 +940,7 @@
157
    
158
 .. option:: --analysis-load <filename>
159
 
160
-   Encoder reuses analysis information from the file specified. By reading the analysis data writen by
161
+   Encoder reuses analysis information from the file specified. By reading the analysis data written by
162
    an earlier encode of the same sequence, substantial redundant work may be avoided. Requires cutree, pmode
163
    to be off. Default disabled.
164
 
165
@@ -1082,7 +1094,7 @@
166
    
167
    Note that when the CU intra prediction is NxN (only possible with
168
    8x8 CUs), a TU split is implied, and thus the residual quad-tree
169
-   begins at 4x4 and cannot split any futhrer.
170
+   begins at 4x4 and cannot split any further.
171
 
172
 .. option:: --tu-inter-depth <1..4>
173
 
174
@@ -1101,7 +1113,7 @@
175
    Enables early exit from TU depth recursion, for inter coded blocks.
176
    
177
    Level 1 - decides to recurse to next higher depth based on cost 
178
-   comparison of full size TU and split TU.
179
+   comparison of full-size TU and split TU.
180
    
181
    Level 2 - based on first split subTU's depth, limits recursion of
182
    other split subTUs.
183
@@ -1109,13 +1121,13 @@
184
    Level 3 - based on the average depth of the co-located and the neighbor
185
    CUs' TU depth, limits recursion of the current CU.
186
    
187
-   Level 4 - uses the depth of the neighbouring/ co-located CUs TU depth 
188
+   Level 4 - uses the depth of the neighboring/ co-located CUs TU depth 
189
    to limit the 1st subTU depth. The 1st subTU depth is taken as the 
190
    limiting depth for the other subTUs.
191
    
192
    Enabling levels 3 or 4 may cause a mismatch in the output bitstreams 
193
    between :option:`--analysis-save` and :option:`--analysis-load`
194
-   as all neighbouring CUs TU depth may not be available in the 
195
+   as all neighboring CUs TU depth may not be available in the 
196
    :option:`--analysis-load` run as only the best mode's information is 
197
    available to it.
198
    
199
@@ -1216,14 +1228,14 @@
200
    Motion search method. Generally, the higher the number the harder
201
    the ME method will try to find an optimal match. Diamond search is
202
    the simplest. Hexagon search is a little better. Uneven
203
-   Multi-Hexegon is an adaption of the search method used by x264 for
204
-   slower presets. Star is a three step search adapted from the HM
205
+   Multi-Hexagon is an adaption of the search method used by x264 for
206
+   slower presets. Star is a three-step search adapted from the HM
207
    encoder: a star-pattern search followed by an optional radix scan
208
    followed by an optional star-search refinement. Full is an
209
    exhaustive search; an order of magnitude slower than all other
210
    searches but not much better than umh or star. SEA is similar to
211
    x264's ESA implementation and a speed optimization of full search.
212
-    It is a three step motion search where the DC calculation is
213
+    It is a three-step motion search where the DC calculation is
214
     followed by ADS calculation followed by SAD of the passed motion
215
     vector candidates.
216
 
217
@@ -1262,7 +1274,7 @@
218
    At --subme values larger than 2, chroma residual cost is included
219
    in all subpel refinement steps and chroma residual is included in
220
    all motion estimation decisions (selecting the best reference
221
-   picture in each list, and chosing between merge, uni-directional
222
+   picture in each list, and choosing between merge, uni-directional
223
    motion and bi-directional motion). The 'slow' preset is the first
224
    preset to enable the use of chroma residual.
225
 
226
@@ -1356,7 +1368,7 @@
227
 do not match the visual energy of the source block. The higher the
228
 strength of :option:`--psy-rd` the more strongly it will favor similar
229
 energy over blur and the more aggressively it will ignore rate
230
-distortion. If it is too high, it will introduce visal artifacts and
231
+distortion. If it is too high, it will introduce visual artifacts and
232
 increase bitrate enough for rate control to increase quantization
233
 globally, reducing overall quality. psy-rd will tend to reduce the use
234
 of blurred prediction modes, like DC and planar intra and bi-directional
235
@@ -1366,11 +1378,11 @@
236
 rate-distortion optimized quantization (RDO quant), enabled by
237
 :option:`--rdoq-level` 1 or 2, favoring the preservation of energy in the
238
 reconstructed image.  :option:`--psy-rdoq` prevents RDOQ from blurring
239
-all of the encoding options which psy-rd has to chose from.  At low
240
+all of the encoding options which psy-rd has to choose from.  At low
241
 strength levels, psy-rdoq will influence the quantization level
242
 decisions, favoring higher AC energy in the reconstructed image. As
243
 psy-rdoq strength is increased, more non-zero coefficient levels are
244
-added and fewer coefficients are zeroed by RDOQ's rate distortion
245
+added, and fewer coefficients are zeroed by RDOQ's rate distortion
246
 analysis. High levels of psy-rdoq can double the bitrate which can have
247
 a drastic effect on rate control, forcing higher overall QP, and can
248
 cause ringing artifacts. psy-rdoq is less accurate than psy-rd, it is
249
@@ -1394,16 +1406,16 @@
250
 is forced to code skip blocks (no residual) in areas of difficult motion
251
 because it is the best option psycho-visually (they have great amounts
252
 of energy and no residual cost). One can lower psy-rd settings when
253
-judder is happening, and allow the encoder to use some blur in these
254
+judder is happening and allow the encoder to use some blur in these
255
 areas of high motion.
256
 
257
 In 444, chroma gets twice as much resolution, so halve the quality when psy-rd is enabled.
258
-So when psy-rd is enabled for 444 videos, cbQpOffset and crQpOffset are set to value 6,
259
+So, when psy-rd is enabled for 444 videos, cbQpOffset and crQpOffset are set to value 6,
260
 if they are not explicitly set.
261
 
262
 .. option:: --psy-rd <float>
263
 
264
-   Influence rate distortion optimizated mode decision to preserve the
265
+   Influence rate distortion optimized mode decision to preserve the
266
    energy of the source image in the encoded image at the expense of
267
    compression efficiency. It only has effect on presets which use
268
    RDO-based mode decisions (:option:`--rd` 3 and above). 1.0 is a
269
@@ -1462,19 +1474,23 @@
270
 .. option:: --hist-scenecut, --no-hist-scenecut
271
 
272
    Indicates that scenecuts need to be detected using luma edge and chroma histograms.
273
-   :option: `--hist-scenecut` enables scenecut detection using the histograms and disables the default scene cut algorithm.
274
-   :option: `--no-hist-scenecut` disables histogram based scenecut algorithm.
275
+   :option:`--hist-scenecut` enables scenecut detection using the histograms and disables the default scene cut algorithm.
276
+   :option:`--no-hist-scenecut` disables histogram based scenecut algorithm.
277
    
278
-.. option:: --hist-threshold <0.0..2.0>
279
+.. option:: --hist-threshold <0.0..1.0>
280
 
281
    This value represents the threshold for normalized SAD of edge histograms used in scenecut detection.
282
-   This requires :option: `--hist-scenecut` to be enabled. For example, a value of 0.2 indicates that a frame with normalized SAD value 
283
+   This requires :option:`--hist-scenecut` to be enabled. For example, a value of 0.2 indicates that a frame with normalized SAD value 
284
    greater than 0.2 against the previous frame as scenecut. 
285
-   Default 0.01.
286
+   Increasing the threshold reduces the number of scenecuts detected.
287
+   Default 0.03.
288
    
289
 .. option:: --radl <integer>
290
    
291
-   Number of RADL pictures allowed infront of IDR. Requires fixed keyframe interval.
292
+   Number of RADL pictures allowed infront of IDR. Requires closed gop interval.
293
+   If enabled for fixed keyframe interval, inserts RADL at every IDR.
294
+   If enabled for closed gop interval, in case of :option:`--hist-scenecut` inserts RADL at every hard scenecut
295
+   whereas for the :option:`--scenecut`, inserts RADL at every scenecut.
296
    Recommended value is 2-3. Default 0 (disabled).
297
    
298
    **Range of values: Between 0 and `--bframes`
299
@@ -1501,7 +1517,7 @@
300
    Number of frames for slice-type decision lookahead (a key
301
    determining factor for encoder latency). The longer the lookahead
302
    buffer the more accurate scenecut decisions will be, and the more
303
-   effective cuTree will be at improving adaptive quant. Having a
304
+   effective cutree will be at improving adaptive quant. Having a
305
    lookahead larger than the max keyframe interval is not helpful.
306
    Default 20
307
 
308
@@ -1510,7 +1526,7 @@
309
 .. option:: --gop-lookahead <integer>
310
 
311
    Number of frames for GOP boundary decision lookahead. If a scenecut frame is found
312
-   within this from the gop boundary set by `--keyint`, the GOP will be extented until such a point,
313
+   within this from the gop boundary set by `--keyint`, the GOP will be extended until such a point,
314
    otherwise the GOP will be terminated as set by `--keyint`. Default 0.
315
 
316
    **Range of values:** Between 0 and (`--rc-lookahead` - mini-GOP length)
317
@@ -1629,7 +1645,7 @@
318
 
319
 .. option:: --crf-min <0..51.0>
320
 
321
-   Specify an lower limit to the rate factor which may be assigned to
322
+   Specify a lower limit to the rate factor which may be assigned to
323
    any given frame (ensuring a min compression factor).
324
 
325
 .. option:: --vbv-bufsize <integer>
326
@@ -1656,7 +1672,7 @@
327
    Initial buffer occupancy. The portion of the decode buffer which
328
    must be full before the decoder will begin decoding.  Determines
329
    absolute maximum frame size. May be specified as a fractional value
330
-   between 0 and 1, or in kbits. In other words these two option pairs
331
+   between 0 and 1, or in kbits. In other words, these two option pairs
332
    are equivalent::
333
 
334
    --vbv-bufsize 1000 --vbv-init 900
335
@@ -1668,8 +1684,8 @@
336
 
337
 .. option:: --vbv-end <float>
338
 
339
-   Final buffer emptiness. The portion of the decode buffer that must be 
340
-   available after all the specified frames have been inserted into the 
341
+   Final buffer fullness. The portion of the decode buffer that must be 
342
+   full after all the specified frames have been inserted into the 
343
    decode buffer. Specified as a fractional value between 0 and 1, or in 
344
    kbits. Default 0 (disabled)
345
    
346
@@ -1681,8 +1697,26 @@
347
 .. option:: --vbv-end-fr-adj <float>
348
 
349
    Frame from which qp has to be adjusted to achieve final decode buffer
350
-   emptiness. Specified as a fraction of the total frames. Fractions > 0 are 
351
+   fullness. Specified as a fraction of the total frames. Fractions > 0 are 
352
    supported only when the total number of frames is known. Default 0.
353
+   
354
+.. option:: --min-vbv-fullness <double>
355
+
356
+    Minimum VBV fullness percentage to be maintained. Specified as a fractional
357
+    value ranging between 0 and 100. Default 50 i.e, Tries to keep the buffer at least
358
+    50% full at any point in time.
359
+   
360
+   Decreasing the minimum required fullness shall improve the compression efficiency,
361
+   but is expected to affect VBV conformance. Experimental option.
362
+
363
+.. option:: --max-vbv-fullness <double>
364
+
365
+    Maximum VBV fullness percentage to be maintained. Specified as a fractional
366
+    value ranging between 0 and 100. Default 80 i.e Tries to keep the buffer at max 80%
367
+    full at any point in time.
368
+   
369
+    Increasing the minimum required fullness shall improve the compression efficiency,
370
+   but is expected to affect VBV conformance. Experimental option.
371
 
372
 .. option:: --qp, -q <integer>
373
 
374
@@ -1710,7 +1744,7 @@
375
 
376
    Adaptive Quantization operating mode. Raise or lower per-block
377
    quantization based on complexity analysis of the source image. The
378
-   more complex the block, the more quantization is used. This offsets
379
+   more complex the block, the more quantization is used. These offsets
380
    the tendency of the encoder to spend too many bits on complex areas
381
    and not enough in flat areas.
382
 
383
@@ -1737,8 +1771,8 @@
384
    Enable adaptive quantization
385
    It scales the quantization step size according to the spatial activity of one
386
    coding unit relative to frame average spatial activity. This AQ method utilizes
387
-   the minimum variance of sub-unit in each coding unit to represent the coding
388
-   unit’s spatial complexity.
389
+   the minimum variance of sub-unit in each coding unit to represent the spatial 
390
+   complexity of the coding unit.
391
 
392
 .. option:: --qp-adaptation-range
393
 
394
@@ -1938,31 +1972,91 @@
395
 
396
    The frame number indicates the beginning of a zone. The options 
397
    following this is applied until another zone begins. The reconfigurable 
398
-   options can be spcified as --<feature name> <feature value>
399
+   options can be specified as --<feature name> <feature value>
400
    
401
    **CLI ONLY**
402
 
403
-.. option:: --scenecut-aware-qp, --no-scenecut-aware-qp
404
-   
405
-   Enables a ratecontrol algorithm for reducing the bits spent on the inter-frames
406
-   within the :option:`--scenecut-window` after a scenecut by increasing their QP
407
-   without any deterioration in visual quality. It also increases the quality of
408
-   scenecut I-Frames by reducing their QP. Default disabled.
409
-   
410
-.. option:: --scenecut-window <integer>
411
+.. option:: --scenecut-aware-qp <integer>
412
 
413
-   The duration(in milliseconds) for which there is a reduction in the bits spent
414
-   on the inter-frames after a scenecut by increasing their QP, when
415
-   :option:`--scenecut-aware-qp` is enabled. Default 500ms.
416
-   
417
-   **Range of values:** 0 to 1000
418
-   
419
-.. option:: --max-qp-delta <integer>
420
+   It reduces the bits spent on the inter-frames within the scenecut window
421
+   before and after a scenecut by increasing their QP in ratecontrol pass2 algorithm
422
+   without any deterioration in visual quality. If a scenecut falls within the window,
423
+   the QP of the inter-frames after this scenecut will not be modified.
424
+   :option:`--scenecut-aware-qp` works only with --pass 2. Default 0.
425
 
426
-   The offset by which QP is incremented for inter-frames
427
-   when :option:`--scenecut-aware-qp` is enabled. Default 5.
428
-   
429
-   **Range of values:**  0 to 10
430
+   +-------+---------------------------------------------------------------+
431
+   | Mode  | Description                                                   |
432
+   +=======+===============================================================+
433
+   | 0     | Disabled.                                                     |
434
+   +-------+---------------------------------------------------------------+
435
+   | 1     | Forward masking.                                              |
436
+   |       | Applies QP modification for frames after the scenecut.        |
437
+   +-------+---------------------------------------------------------------+
438
+   | 2     | Backward masking.                                             |
439
+   |       | Applies QP modification for frames before the scenecut.       |
440
+   +-------+---------------------------------------------------------------+
441
+   | 3     | Bi-directional masking.                                       |
442
+   |       | Applies QP modification for frames before and after           |
443
+   |       | the scenecut.                                                 |
444
+   +-------+---------------------------------------------------------------+
445
+
446
+.. option:: --masking-strength <string>
447
+
448
+   Comma separated list of values which specifies the duration and offset
449
+   for the QP increment for inter-frames when :option:`--scenecut-aware-qp`
450
+   is enabled.
451
+
452
+   When :option:`--scenecut-aware-qp` is::
453
+   * 1 (Forward masking):
454
+   --masking-strength <fwdWindow,fwdRefQPDelta,fwdNonRefQPDelta>
455
+   * 2 (Backward masking):
456
+   --masking-strength <bwdWindow,bwdRefQPDelta,bwdNonRefQPDelta>
457
+   * 3 (Bi-directional masking):
458
+   --masking-strength <fwdWindow,fwdRefQPDelta,fwdNonRefQPDelta,bwdWindow,bwdRefQPDelta,bwdNonRefQPDelta>
459
+
460
+   +-----------------+---------------------------------------------------------------+
461
+   | Parameter       | Description                                                   |
462
+   +=================+===============================================================+
463
+   | fwdWindow       | The duration(in milliseconds) for which there is a reduction  |
464
+   |                 | in the bits spent on the inter-frames after a scenecut by     |
465
+   |                 | increasing their QP. Default 500ms.                           |
466
+   |                 | **Range of values:** 0 to 1000                                |
467
+   +-----------------+---------------------------------------------------------------+
468
+   | fwdRefQPDelta   | The offset by which QP is incremented for inter-frames        |
469
+   |                 | after a scenecut. Default 5.                                  |
470
+   |                 | **Range of values:** 0 to 10                                  |
471
+   +-----------------+---------------------------------------------------------------+
472
+   | fwdNonRefQPDelta| The offset by which QP is incremented for non-referenced      |
473
+   |                 | inter-frames after a scenecut. The offset is computed from    |
474
+   |                 | fwdRefQPDelta when it is not explicitly specified.            |
475
+   |                 | **Range of values:** 0 to 10                                  |
476
+   +-----------------+---------------------------------------------------------------+
477
+   | bwdWindow       | The duration(in milliseconds) for which there is a reduction  |
478
+   |                 | in the bits spent on the inter-frames before a scenecut by    |
479
+   |                 | increasing their QP. Default 100ms.                           |
480
+   |                 | **Range of values:** 0 to 1000                                |
481
+   +-----------------+---------------------------------------------------------------+
482
+   | bwdRefQPDelta   | The offset by which QP is incremented for inter-frames        |
483
+   |                 | before a scenecut. The offset is computed from                |
484
+   |                 | fwdRefQPDelta when it is not explicitly specified.            |
485
+   |                 | **Range of values:** 0 to 10                                  |
486
+   +-----------------+---------------------------------------------------------------+
487
+   | bwdNonRefQPDelta| The offset by which QP is incremented for non-referenced      |
488
+   |                 | inter-frames before a scenecut. The offset is computed from   |
489
+   |                 | bwdRefQPDelta when it is not explicitly specified.            |
490
+   |                 | **Range of values:** 0 to 10                                  |
491
+   +-----------------+---------------------------------------------------------------+
492
+
493
+   **CLI ONLY**
494
+
495
+.. option:: --vbv-live-multi-pass, --no-vbv-live-multi-pass
496
+
497
+   It enables the Qp tuning at frame level based on real time VBV Buffer fullness
498
+   in the ratecontrol 2nd pass of multi pass mode to reduce the VBV violations.
499
+   It could only be enabled with rate control stat-read encodes with VBV and ABR
500
+   rate control mode.
501
+
502
+   Default disabled. **Experimental feature**
503
 
504
 Quantization Options
505
 ====================
506
@@ -2010,7 +2104,7 @@
507
    All other strings indicate a filename containing custom scaling
508
    lists in the HM format. The encode will abort if the file is not
509
    parsed correctly. Custom lists must be signaled in the SPS. A sample
510
-   scaling list file is available in `the downloads page <https://bitbucket.org/multicoreware/x265/downloads/reference_scalinglist.txt>`_
511
+   scaling list file is available in `the downloads page <https://bitbucket.org/multicoreware/x265_git/downloads/reference_scalinglist.txt>`_
512
 
513
 .. option:: --lambda-file <filename>
514
 
515
@@ -2064,7 +2158,7 @@
516
 
517
 .. option:: --sao-non-deblock, --no-sao-non-deblock
518
 
519
-   Specify how to handle depencency between SAO and deblocking filter.
520
+   Specify how to handle dependency between SAO and deblocking filter.
521
    When enabled, non-deblocked pixels are used for SAO analysis. When
522
    disabled, SAO analysis skips the right/bottom boundary areas.
523
    Default disabled
524
@@ -2154,7 +2248,7 @@
525
    2. ntsc
526
    3. secam
527
    4. mac
528
-   5. undefined
529
+   5. unknown
530
 
531
 .. option:: --range <full|limited>
532
 
533
@@ -2207,15 +2301,15 @@
534
    Specify color matrix setting i.e set the matrix coefficients used in
535
    deriving the luma and chroma. Default undefined (not signaled)
536
 
537
-   0. GBR
538
+   0. gbr
539
    1. bt709
540
-   2. undef 
541
+   2. unknown 
542
    3. **reserved**
543
    4. fcc
544
    5. bt470bg
545
    6. smpte170m
546
    7. smpte240m
547
-   8. YCgCo
548
+   8. ycgco
549
    9. bt2020nc
550
    10. bt2020c
551
    11. smpte2085
552
@@ -2297,7 +2391,7 @@
553
    to be encoded as Dynamic Tone Mapping into the bitstream. 
554
    
555
    Click `here <https://www.sra.samsung.com/assets/User-data-registered-itu-t-t35-SEI-message-for-ST-2094-40-v1.1.pdf>`_
556
-   for the syntax of the metadata file. A sample JSON file is available in `the downloads page <https://bitbucket.org/multicoreware/x265/downloads/DCIP3_4K_to_400_dynamic.json>`_
557
+   for the syntax of the metadata file. A sample JSON file is available in `the downloads page <https://bitbucket.org/multicoreware/x265_git/downloads/DCIP3_4K_to_400_dynamic.json>`_
558
    
559
 .. option:: --dhdr10-opt, --no-dhdr10-opt
560
 
561
@@ -2325,13 +2419,13 @@
562
 
563
    Emit the alternative transfer characteristics SEI message where the integer
564
    is the preferred transfer characteristics. Required for HLG (Hybrid Log Gamma)
565
-   signalling. Not signalled by default.
566
+   signaling. Not signaled by default.
567
 
568
 .. option:: --pic-struct <integer>
569
 
570
    Set the picture structure and emits it in the picture timing SEI message.
571
    Values in the range 0..12. See D.3.3 of the HEVC spec. for a detailed explanation.
572
-   Required for HLG (Hybrid Log Gamma) signalling. Not signalled by default.
573
+   Required for HLG (Hybrid Log Gamma) signaling. Not signaled by default.
574
 
575
 Bitstream options
576
 =================
577
@@ -2362,7 +2456,7 @@
578
 
579
 .. option:: --hrd, --no-hrd
580
 
581
-   Enable the signalling of HRD parameters to the decoder. The HRD
582
+   Enable the signaling of HRD parameters to the decoder. The HRD
583
    parameters are carried by the Buffering Period SEI messages and
584
    Picture Timing SEI messages providing timing information to the
585
    decoder. Default disabled
586
@@ -2370,7 +2464,7 @@
587
        
588
 .. option:: --hrd-concat, --no-hrd-concat
589
 
590
-    Set concantenation flag for the first keyframe in the HRD buffering period SEI. This
591
+    Set concatenation flag for the first keyframe in the HRD buffering period SEI. This
592
     is to signal the decoder if splicing is performed during bitstream generation. 
593
     Recommended to enable this option during chunked encoding, except for the first chunk.
594
     Default disabled.
595
@@ -2419,7 +2513,7 @@
596
 
597
    Enable a temporal sub layer. All referenced I/P/B frames are in the
598
    base layer and all unreferenced B frames are placed in a temporal
599
-   enhancement layer. A decoder may chose to drop the enhancement layer 
600
+   enhancement layer. A decoder may choose to drop the enhancement layer 
601
    and only decode and display the base layer slices.
602
    
603
    If used with a fixed GOP (:option:`--b-adapt` 0) and :option:`--bframes`
604
@@ -2457,7 +2551,7 @@
605
 .. option:: --opt-cu-delta-qp, --no-opt-cu-delta-qp
606
 
607
    Optimize CU level QPs by pulling up lower QPs to value close to meanQP thereby
608
-   minimizing fluctuations in deltaQP signalling. Default disabled.
609
+   minimizing fluctuations in deltaQP signaling. Default disabled.
610
 
611
    Only effective at RD levels 5 and 6
612
 
613
@@ -2476,10 +2570,10 @@
614
 .. option:: --lowpass-dct
615
 
616
    If enabled, x265 will use low-pass subband dct approximation instead of the
617
-   standard dct for 16x16 and 32x32 blocks. This approximation is less computational 
618
+   standard dct for 16x16 and 32x32 blocks. This approximation is less computationally 
619
    intensive but it generates truncated coefficient matrixes for the transformed block. 
620
    Empirical analysis shows marginal loss in compression and performance gains up to 10%,
621
-   paticularly at moderate bit-rates.
622
+   particularly at moderate bit-rates.
623
 
624
    This approximation should be considered for platforms with performance and time 
625
    constrains.
626
@@ -2536,10 +2630,15 @@
627
    if analysis reuse isn't preferred ), and reuse-level indicates the level ( :option:`--analysis-load-reuse-level`)
628
    at which analysis info has to be reused.
629
    
630
-   A sample config file is available in `the downloads page <https://bitbucket.org/multicoreware/x265/downloads/Sample_ABR_ladder_config>`_
631
-   
632
-   Default: Disabled ( Conventional single encode generation ). Experimental feature.
633
+   Sample config file::
634
+
635
+   [540p:0:nil] --input 540pSource.y4m --ctu 16 --bitrate 1600 --vbv-maxrate 2400 --vbv-bufsize 4800 -o 540p.hevc --preset veryslow
636
+   [1080p:10:540p] --input 1080pSource.y4m --ctu 32 --bitrate 5800 --vbv-maxrate 8700 --vbv-bufsize 17400 -o 1080p.hevc --preset veryslow --scale-factor 2
637
+   [2160p:10:1080p] --input 2160pSource.y4m --bitrate 16800 --vbv-maxrate 25200  --vbv-bufsize 50400 -o 2160p.hevc --preset veryslow  --scale-factor 2
638
 
639
+   The above sample config file is available in `the downloads page <https://bitbucket.org/multicoreware/x265_git/downloads/Sample_ABR_ladder_config.txt>`_
640
+
641
+   Default: Disabled ( Conventional single encode generation ). Experimental feature.
642
    **CLI ONLY**
643
 
644
 
645
@@ -2576,8 +2675,8 @@
646
 .. option:: --svt-compressed-ten-bit-format, --no-svt-compressed-ten-bit-format
647
 
648
     In order to reduce the size of input YUV and to increase channel density,
649
-    SVT-HEVC accetps inputs in compressed-ten-bit-format. The conversion between
650
-    yuv420p10le and compressed ten bit format is a lossless operation. For more
651
+    SVT-HEVC accepts inputs in compressed-ten-bit-format. The conversion between
652
+    yuv420p10le and compressed ten-bit format is a lossless operation. For more
653
     details about the conversion refer
654
     `here<https://github.com/intel/SVT-HEVC/blob/master/Docs/SVT-HEVC_Encoder_User_Guide.pdf>'_.
655
 
656
@@ -2629,7 +2728,7 @@
657
     supports Low delay(P/B) and random access prediction structure. In a low delay
658
     structure, pictures within a mini-gop can only refer to the previous pictures
659
     in display order. In other words, picture with display order N can only refer
660
-    to pictures of display order lower than N. In random acccess method, pictures
661
+    to pictures of display order lower than N. In random access method, pictures
662
     can be referenced from both the directions. It accepts values in the range
663
     [0-2]
664
 
665
x265_3.4.tar.gz/doc/reST/introduction.rst -> x265_3.5.tar.gz/doc/reST/introduction.rst Changed
10
 
1
@@ -43,7 +43,7 @@
2
 features and optimizations from the x264 AVC encoder project.
3
 
4
 The x265 software is available for free under the GNU GPL 2 license,
5
-from https://bitbucket.org/multicoreware/x265.  For commercial companies
6
+from https://bitbucket.org/multicoreware/x265_git.  For commercial companies
7
 that wish to distribute x265 without being subject to the open source
8
 requirements of the GPL 2 license, commercial licenses are available
9
 with competitive terms.  Contact license @ x265.com to inquire about
10
x265_3.4.tar.gz/doc/reST/releasenotes.rst -> x265_3.5.tar.gz/doc/reST/releasenotes.rst Changed
35
 
1
@@ -2,6 +2,33 @@
2
 Release Notes
3
 *************
4
 
5
+Version 3.5
6
+===========
7
+
8
+Release date - 16th March, 2021.
9
+
10
+New feature
11
+-----------
12
+1. Real-time VBV for ABR (Average BitRate) encodes in –pass 2 using :option:`--vbv-live-multi-pass`: Improves VBV compliance with no significant impact on coding efficiency.
13
+
14
+Enhancements to existing features
15
+---------------------------------
16
+1. Improved hist-based scene cut algorithm: Reduces false positives by leveraging motion and scene transition info.
17
+2. Support for RADL pictures at IDR scene cuts: Improves coding efficiency with no significant impact on performance.
18
+3. Bidirectional scene cut aware Frame Quantizer Selection: Saves bits than forward masking with no noticeable perceptual quality difference.
19
+
20
+API changes
21
+-----------
22
+1. Additions to x265_param structure to support the newly added features and encoder enhancements.
23
+2. New x265_param options :option:`--min-vbv-fullness` and :option:`--max-vbv-fullness` to control min and max VBV fullness.
24
+
25
+Bug fixes
26
+---------
27
+1. Incorrect VBV lookahead in :option:`--analysis-load` + :option:`--scale-factor`.
28
+2. Encoder hang when VBV is used with slices.
29
+3. QP spikes in the row-level VBV rate-control when WPP enabled.
30
+4. Encoder crash in :option:`--abr-ladder`.
31
+
32
 Version 3.4
33
 ===========
34
 
35
x265_3.5.tar.gz/doc/uncrustify Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source Added
2
 
1
+(directory)
2
x265_3.4.tar.gz/source/CMakeLists.txt -> x265_3.5.tar.gz/source/CMakeLists.txt Changed
19
 
1
@@ -29,7 +29,7 @@
2
 option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)
3
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)
4
 # X265_BUILD must be incremented each time the public API is changed
5
-set(X265_BUILD 192)
6
+set(X265_BUILD 199)
7
 configure_file("${PROJECT_SOURCE_DIR}/x265.def.in"
8
                "${PROJECT_BINARY_DIR}/x265.def")
9
 configure_file("${PROJECT_SOURCE_DIR}/x265_config.h.in"
10
@@ -485,7 +485,7 @@
11
     endif()
12
 endif()
13
 
14
-include(version) # determine X265_VERSION and X265_LATEST_TAG
15
+include(Version) # determine X265_VERSION and X265_LATEST_TAG
16
 include_directories(. common encoder "${PROJECT_BINARY_DIR}")
17
 
18
 option(ENABLE_PPA "Enable PPA profiling instrumentation" OFF)
19
x265_3.4.tar.gz/source/abrEncApp.cpp -> x265_3.5.tar.gz/source/abrEncApp.cpp Changed
35
 
1
@@ -98,13 +98,15 @@
2
                 x265_picture_init(m_passEnc[pass]->m_param, m_inputPicBuffer[pass][idx]);
3
             }
4
 
5
-            m_analysisBuffer[pass] = X265_MALLOC(x265_analysis_data, m_queueSize);
6
+            CHECKED_MALLOC_ZERO(m_analysisBuffer[pass], x265_analysis_data, m_queueSize);
7
             m_picIdxReadCnt[pass] = new ThreadSafeInteger[m_queueSize];
8
             m_analysisWrite[pass] = new ThreadSafeInteger[m_queueSize];
9
             m_analysisRead[pass] = new ThreadSafeInteger[m_queueSize];
10
             m_readFlag[pass] = X265_MALLOC(int, m_queueSize);
11
         }
12
         return true;
13
+    fail:
14
+        return false;
15
     }
16
 
17
     void AbrEncoder::destroy()
18
@@ -315,6 +317,7 @@
19
 
20
         x265_analysis_data *m_analysisInfo = &m_parent->m_analysisBuffer[m_id][index];
21
 
22
+        x265_free_analysis_data(m_param, m_analysisInfo);
23
         memcpy(m_analysisInfo, src, sizeof(x265_analysis_data));
24
         x265_alloc_analysis_data(m_param, m_analysisInfo);
25
 
26
@@ -814,7 +817,7 @@
27
             api->encoder_get_stats(m_encoder, &stats, sizeof(stats));
28
             if (m_param->csvfn && !b_ctrl_c)
29
 #if ENABLE_LIBVMAF
30
-                api->vmaf_encoder_log(m_encoder, m_cliopt.argCount, m_cliopt.argString, m_cliopt.param, vmafdata);
31
+                api->vmaf_encoder_log(m_encoder, m_cliopt.argCnt, m_cliopt.argString, m_cliopt.param, vmafdata);
32
 #else
33
                 api->encoder_log(m_encoder, m_cliopt.argCnt, m_cliopt.argString);
34
 #endif
35
x265_3.5.tar.gz/source/cmake Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/cmake/Version.cmake Added
181
 
1
@@ -0,0 +1,179 @@
2
+ #################################################################################################################
3
+ #
4
+ #    Copyright (C) 2013-2020 MulticoreWare, Inc
5
+ #
6
+ # This program is free software; you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation; either version 2 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program; if not, write to the Free Software
18
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
19
+ #
20
+ # This program is also available under a commercial proprietary license.
21
+ # For more information, contact us at license @ x265.com
22
+ #
23
+ # Authors: Janani T.E <janani.te@multicorewareinc.com>, Srikanth Kurapati <srikanthkurapati@multicorewareinc.com>
24
+ #
25
+ #################################################################################################################
26
+ # PURPOSE: Identity version control software version display, also read version files to present x265 version.
27
+ #################################################################################################################
28
+ #Default Settings, for user to be vigilant about x265 version being reported during product build.
29
+set(X265_VERSION "unknown")
30
+set(X265_LATEST_TAG "0.0")
31
+set(X265_TAG_DISTANCE "0")
32
+
33
+#Find version control software to be used for live and extracted repositories from compressed tarballs
34
+if(CMAKE_VERSION VERSION_LESS "2.8.10")
35
+    find_program(HG_EXECUTABLE hg)
36
+    if(EXISTS "${HG_EXECUTABLE}.bat")
37
+        set(HG_EXECUTABLE "${HG_EXECUTABLE}.bat")
38
+    endif()
39
+    message(STATUS "hg found at ${HG_EXECUTABLE}")
40
+else()
41
+    find_package(Hg QUIET)
42
+endif()
43
+if(HG_EXECUTABLE)
44
+    #Set Version Control binary for source code kind
45
+    if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt)
46
+        set(HG_ARCHETYPE "1")
47
+    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.hg)
48
+        set(HG_ARCHETYPE "0")
49
+    endif()
50
+endif(HG_EXECUTABLE)
51
+find_package(Git QUIET) #No restrictions on Git versions used, any versions from 1.8.x to 2.2.x or later should do.
52
+if(GIT_FOUND)
53
+    find_program(GIT_EXECUTABLE git)
54
+    message(STATUS "GIT_EXECUTABLE ${GIT_EXECUTABLE}")
55
+    if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../.git)
56
+        set(GIT_ARCHETYPE "0")
57
+    elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../x265Version.txt)
58
+        set(GIT_ARCHETYPE "1")
59
+    endif()
60
+endif(GIT_FOUND)
61
+if(HG_ARCHETYPE)
62
+    #Read the lines of the archive summary file to extract the version
63
+    message(STATUS "SOURCE CODE IS FROM x265 HG ARCHIVED ZIP OR TAR BALL")
64
+    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../.hg_archival.txt archive)
65
+    STRING(REGEX REPLACE "\n" ";" archive "${archive}")
66
+    foreach(f ${archive})
67
+        string(FIND "${f}" ": " pos)
68
+        string(SUBSTRING "${f}" 0 ${pos} key)
69
+        string(SUBSTRING "${f}" ${pos} -1 value)
70
+        string(SUBSTRING "${value}" 2 -1 value)
71
+        set(hg_${key} ${value})
72
+    endforeach()
73
+    if(DEFINED hg_tag)
74
+        set(X265_LATEST_TAG ${hg_tag})
75
+    elseif(DEFINED hg_node)
76
+        set(X265_LATEST_TAG ${hg_latesttag})
77
+        set(X265_TAG_DISTANCE ${hg_latesttagdistance})
78
+        string(SUBSTRING "${hg_node}" 0 12 X265_REVISION_ID)
79
+    endif()
80
+    message(STATUS "HG ARCHIVAL INFORMATION PROCESSED")
81
+elseif(NOT DEFINED GIT_ARCHETYPE)
82
+# means that's its neither hg archive nor git clone/archive hence it has to be hg live repo as these are only four cases that need to processed in mutual exclusion.
83
+    execute_process(COMMAND
84
+        ${HG_EXECUTABLE} log -r. --template "{latesttag}"
85
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
86
+        OUTPUT_VARIABLE X265_LATEST_TAG
87
+        ERROR_QUIET
88
+        OUTPUT_STRIP_TRAILING_WHITESPACE
89
+        )
90
+    execute_process(COMMAND
91
+        ${HG_EXECUTABLE} log -r. --template "{latesttagdistance}"
92
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
93
+        OUTPUT_VARIABLE X265_TAG_DISTANCE
94
+        ERROR_QUIET
95
+        OUTPUT_STRIP_TRAILING_WHITESPACE
96
+        )
97
+    execute_process(
98
+        COMMAND
99
+        ${HG_EXECUTABLE} log -r. --template "{node}"
100
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
101
+        OUTPUT_VARIABLE X265_REVISION_ID
102
+        ERROR_QUIET
103
+        OUTPUT_STRIP_TRAILING_WHITESPACE
104
+        )
105
+    string(SUBSTRING "${X265_REVISION_ID}" 0 12 X265_REVISION_ID)
106
+    if(X265_LATEST_TAG MATCHES "^r")
107
+        string(SUBSTRING ${X265_LATEST_TAG} 1 -1 X265_LATEST_TAG)
108
+    endif()
109
+    message(STATUS "HG LIVE REPO STATUS CHECK DONE")
110
+elseif(GIT_ARCHETYPE)
111
+    message(STATUS "SOURCE CODE IS FROM x265 GIT ARCHIVED ZIP OR TAR BALL")
112
+    #Read the lines of the archive summary file to extract the version
113
+    file(READ ${CMAKE_CURRENT_SOURCE_DIR}/../x265Version.txt filebuf)
114
+    STRING(REGEX REPLACE "\n" ";" filebuf "${filebuf}")
115
+    foreach(line ${filebuf})
116
+        string(FIND "${line}" ": " pos)
117
+        string(SUBSTRING "${line}" 0 ${pos} key)
118
+        string(SUBSTRING "${line}" ${pos} -1 value)
119
+        string(SUBSTRING "${value}" 2 -1 value)
120
+        set(git_${key} ${value})
121
+    endforeach()
122
+    if(DEFINED git_releasetag)
123
+        set(X265_LATEST_TAG ${git_releasetag})
124
+        if(DEFINED git_releasetagdistance)
125
+            set(X265_TAG_DISTANCE ${git_releasetagdistance})
126
+            if(X265_TAG_DISTANCE STRGREATER "0" OR X265_TAG_DISTANCE STREQUAL "0")
127
+                #for x265 the repository changeset has to be a tag id or commit id after the tag
128
+                #hence mandating it's presence in version file always for valid tag distances.
129
+                if(DEFINED git_repositorychangeset)
130
+                    string(SUBSTRING "${git_repositorychangeset}" 0 9 X265_REVISION_ID)
131
+                else()
132
+                    message(WARNING "X265 LATEST COMMIT TIP INFORMATION NOT AVAILABLE")
133
+                endif()
134
+            else()
135
+                message(WARNING "X265 TAG DISTANCE INVALID")
136
+            endif()
137
+        else()
138
+            message(WARNING "COMMIT INFORMATION AFTER LATEST REVISION UNAVAILABLE")
139
+        endif()
140
+    else()
141
+        message(WARNING "X265 RELEASE VERSION LABEL MISSING: ${X265_LATEST_TAG}")
142
+    endif()
143
+    message(STATUS "GIT ARCHIVAL INFORMATION PROCESSED")
144
+else()
145
+    execute_process(
146
+        COMMAND
147
+        ${GIT_EXECUTABLE} describe --abbrev=0 --tags
148
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
149
+        OUTPUT_VARIABLE X265_LATEST_TAG
150
+        ERROR_QUIET
151
+        OUTPUT_STRIP_TRAILING_WHITESPACE
152
+        )
153
+    execute_process(
154
+        COMMAND
155
+        ${GIT_EXECUTABLE} rev-list ${X265_LATEST_TAG}.. --count --first-parent
156
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
157
+        OUTPUT_VARIABLE X265_TAG_DISTANCE
158
+        ERROR_QUIET
159
+        OUTPUT_STRIP_TRAILING_WHITESPACE
160
+        )
161
+    execute_process(
162
+        COMMAND
163
+        ${GIT_EXECUTABLE} log --pretty=format:%h -n 1
164
+        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
165
+        OUTPUT_VARIABLE X265_REVISION_ID
166
+        ERROR_QUIET
167
+        OUTPUT_STRIP_TRAILING_WHITESPACE
168
+        )
169
+    message(STATUS "GIT LIVE REPO VERSION RETRIEVED")
170
+endif()
171
+
172
+# formatting based on distance from tag
173
+if(X265_TAG_DISTANCE STREQUAL "0")
174
+    set(X265_VERSION "${X265_LATEST_TAG}")
175
+elseif(X265_TAG_DISTANCE STRGREATER "0")
176
+    set(X265_VERSION "${X265_LATEST_TAG}+${X265_TAG_DISTANCE}-${X265_REVISION_ID}")
177
+endif()
178
+
179
+#will always be printed in its entirety based on version file configuration to avail revision monitoring by repo owners
180
+message(STATUS "X265 RELEASE VERSION ${X265_VERSION}")
181
x265_3.5.tar.gz/source/common Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/common/aarch64 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/common/arm Added
2
 
1
+(directory)
2
x265_3.4.tar.gz/source/common/frame.cpp -> x265_3.5.tar.gz/source/common/frame.cpp Changed
9
 
1
@@ -63,6 +63,7 @@
2
     m_thetaPic = NULL;
3
     m_edgeBitPlane = NULL;
4
     m_edgeBitPic = NULL;
5
+    m_isInsideWindow = 0;
6
 }
7
 
8
 bool Frame::create(x265_param *param, float* quantOffsets)
9
x265_3.4.tar.gz/source/common/frame.h -> x265_3.5.tar.gz/source/common/frame.h Changed
10
 
1
@@ -141,6 +141,8 @@
2
     pixel*                 m_edgeBitPlane;
3
     pixel*                 m_edgeBitPic;
4
 
5
+    int                    m_isInsideWindow;
6
+
7
     Frame();
8
 
9
     bool create(x265_param *param, float* quantOffsets);
10
x265_3.4.tar.gz/source/common/lowres.cpp -> x265_3.5.tar.gz/source/common/lowres.cpp Changed
12
 
1
@@ -266,6 +266,10 @@
2
     indB = 0;
3
     memset(costEst, -1, sizeof(costEst));
4
     memset(weightedCostDelta, 0, sizeof(weightedCostDelta));
5
+    interPCostPercDiff = 0.0;
6
+    intraCostPercDiff = 0.0;
7
+    m_bIsMaxThres = false;
8
+    m_bIsHardScenecut = false;
9
 
10
     if (qpAqOffset && invQscaleFactor)
11
         memset(costEstAq, -1, sizeof(costEstAq));
12
x265_3.4.tar.gz/source/common/lowres.h -> x265_3.5.tar.gz/source/common/lowres.h Changed
14
 
1
@@ -234,6 +234,12 @@
2
     uint16_t* propagateCost;
3
     double    weightedCostDelta[X265_BFRAME_MAX + 2];
4
     ReferencePlanes weightedRef[X265_BFRAME_MAX + 2];
5
+    /* For hist-based scenecut */
6
+    bool   m_bIsMaxThres;
7
+    double interPCostPercDiff;
8
+    double intraCostPercDiff;
9
+    bool   m_bIsHardScenecut;
10
+
11
     bool create(x265_param* param, PicYuv *origPic, uint32_t qgSize);
12
     void destroy();
13
     void init(PicYuv *origPic, int poc);
14
x265_3.4.tar.gz/source/common/param.cpp -> x265_3.5.tar.gz/source/common/param.cpp Changed
317
 
1
@@ -168,7 +168,7 @@
2
     param->bFrameAdaptive = X265_B_ADAPT_TRELLIS;
3
     param->bBPyramid = 1;
4
     param->scenecutThreshold = 40; /* Magic number pulled in from x264 */
5
-    param->edgeTransitionThreshold = 0.01;
6
+    param->edgeTransitionThreshold = 0.03;
7
     param->bHistBasedSceneCut = 0;
8
     param->lookaheadSlices = 8;
9
     param->lookaheadThreads = 0;
10
@@ -179,8 +179,12 @@
11
     param->bEnableHRDConcatFlag = 0;
12
     param->bEnableFades = 0;
13
     param->bEnableSceneCutAwareQp = 0;
14
-    param->scenecutWindow = 500;
15
-    param->maxQpDelta = 5;
16
+    param->fwdScenecutWindow = 500;
17
+    param->fwdRefQpDelta = 5;
18
+    param->fwdNonRefQpDelta = param->fwdRefQpDelta + (SLICE_TYPE_DELTA * param->fwdRefQpDelta);
19
+    param->bwdScenecutWindow = 100;
20
+    param->bwdRefQpDelta = -1;
21
+    param->bwdNonRefQpDelta = -1;
22
 
23
     /* Intra Coding Tools */
24
     param->bEnableConstrainedIntra = 0;
25
@@ -254,6 +258,8 @@
26
     param->rc.vbvBufferInit = 0.9;
27
     param->vbvBufferEnd = 0;
28
     param->vbvEndFrameAdjust = 0;
29
+    param->minVbvFullness = 50;
30
+    param->maxVbvFullness = 80;
31
     param->rc.rfConstant = 28;
32
     param->rc.bitrate = 0;
33
     param->rc.qCompress = 0.6;
34
@@ -287,6 +293,7 @@
35
     param->bResetZoneConfig = 1;
36
     param->reconfigWindowSize = 0;
37
     param->decoderVbvMaxRate = 0;
38
+    param->bliveVBV2pass = 0;
39
 
40
     /* Video Usability Information (VUI) */
41
     param->vui.aspectRatioIdc = 0;
42
@@ -1122,7 +1129,7 @@
43
             p->vui.bEnableOverscanInfoPresentFlag = 1;
44
             p->vui.bEnableOverscanAppropriateFlag = 1;
45
         }
46
-        else if (!strcmp(value, "undef"))
47
+        else if (!strcmp(value, "unknown"))
48
             p->vui.bEnableOverscanInfoPresentFlag = 0;
49
         else
50
             bError = true;
51
@@ -1340,9 +1347,72 @@
52
             p->selectiveSAO = atoi(value);
53
         }
54
         OPT("fades") p->bEnableFades = atobool(value);
55
-        OPT("scenecut-aware-qp") p->bEnableSceneCutAwareQp = atobool(value);
56
-        OPT("scenecut-window") p->scenecutWindow = atoi(value);
57
-        OPT("max-qp-delta") p->maxQpDelta = atoi(value);
58
+        OPT("scenecut-aware-qp") p->bEnableSceneCutAwareQp = atoi(value);
59
+        OPT("masking-strength")
60
+        {
61
+            int window1;
62
+            double refQpDelta1, nonRefQpDelta1;
63
+
64
+            if (p->bEnableSceneCutAwareQp == FORWARD)
65
+            {
66
+                if (3 == sscanf(value, "%d,%lf,%lf", &window1, &refQpDelta1, &nonRefQpDelta1))
67
+                {
68
+                    if (window1 > 0)
69
+                        p->fwdScenecutWindow = window1;
70
+                    if (refQpDelta1 > 0)
71
+                        p->fwdRefQpDelta = refQpDelta1;
72
+                    if (nonRefQpDelta1 > 0)
73
+                        p->fwdNonRefQpDelta = nonRefQpDelta1;
74
+                }
75
+                else
76
+                {
77
+                    x265_log(NULL, X265_LOG_ERROR, "Specify all the necessary offsets for masking-strength \n");
78
+                    bError = true;
79
+                }
80
+            }
81
+            else if (p->bEnableSceneCutAwareQp == BACKWARD)
82
+            {
83
+                if (3 == sscanf(value, "%d,%lf,%lf", &window1, &refQpDelta1, &nonRefQpDelta1))
84
+                {
85
+                    if (window1 > 0)
86
+                        p->bwdScenecutWindow = window1;
87
+                    if (refQpDelta1 > 0)
88
+                        p->bwdRefQpDelta = refQpDelta1;
89
+                    if (nonRefQpDelta1 > 0)
90
+                        p->bwdNonRefQpDelta = nonRefQpDelta1;
91
+                }
92
+                else
93
+                {
94
+                    x265_log(NULL, X265_LOG_ERROR, "Specify all the necessary offsets for masking-strength \n");
95
+                    bError = true;
96
+                }
97
+            }
98
+            else if (p->bEnableSceneCutAwareQp == BI_DIRECTIONAL)
99
+            {
100
+                int window2;
101
+                double refQpDelta2, nonRefQpDelta2;
102
+                if (6 == sscanf(value, "%d,%lf,%lf,%d,%lf,%lf", &window1, &refQpDelta1, &nonRefQpDelta1, &window2, &refQpDelta2, &nonRefQpDelta2))
103
+                {
104
+                    if (window1 > 0)
105
+                        p->fwdScenecutWindow = window1;
106
+                    if (refQpDelta1 > 0)
107
+                        p->fwdRefQpDelta = refQpDelta1;
108
+                    if (nonRefQpDelta1 > 0)
109
+                        p->fwdNonRefQpDelta = nonRefQpDelta1;
110
+                    if (window2 > 0)
111
+                        p->bwdScenecutWindow = window2;
112
+                    if (refQpDelta2 > 0)
113
+                        p->bwdRefQpDelta = refQpDelta2;
114
+                    if (nonRefQpDelta2 > 0)
115
+                        p->bwdNonRefQpDelta = nonRefQpDelta2;
116
+                }
117
+                else
118
+                {
119
+                    x265_log(NULL, X265_LOG_ERROR, "Specify all the necessary offsets for masking-strength \n");
120
+                    bError = true;
121
+                }
122
+            }
123
+        }
124
         OPT("field") p->bField = atobool( value );
125
         OPT("cll") p->bEmitCLL = atobool(value);
126
         OPT("frame-dup") p->bEnableFrameDuplication = atobool(value);
127
@@ -1373,6 +1443,9 @@
128
             sscanf(value, "%d,%d,%d", &p->hmeRange[0], &p->hmeRange[1], &p->hmeRange[2]);
129
             p->bEnableHME = true;
130
         }
131
+        OPT("vbv-live-multi-pass") p->bliveVBV2pass = atobool(value);
132
+        OPT("min-vbv-fullness") p->minVbvFullness = atof(value);
133
+        OPT("max-vbv-fullness") p->maxVbvFullness = atof(value);
134
         else
135
             return X265_PARAM_BAD_NAME;
136
     }
137
@@ -1643,23 +1716,23 @@
138
           "Sample Aspect Ratio height must be greater than 0");
139
     CHECK(param->vui.videoFormat < 0 || param->vui.videoFormat > 5,
140
           "Video Format must be component,"
141
-          " pal, ntsc, secam, mac or undef");
142
+          " pal, ntsc, secam, mac or unknown");
143
     CHECK(param->vui.colorPrimaries < 0
144
           || param->vui.colorPrimaries > 12
145
           || param->vui.colorPrimaries == 3,
146
-          "Color Primaries must be undef, bt709, bt470m,"
147
+          "Color Primaries must be unknown, bt709, bt470m,"
148
           " bt470bg, smpte170m, smpte240m, film, bt2020, smpte-st-428, smpte-rp-431 or smpte-eg-432");
149
     CHECK(param->vui.transferCharacteristics < 0
150
           || param->vui.transferCharacteristics > 18
151
           || param->vui.transferCharacteristics == 3,
152
-          "Transfer Characteristics must be undef, bt709, bt470m, bt470bg,"
153
+          "Transfer Characteristics must be unknown, bt709, bt470m, bt470bg,"
154
           " smpte170m, smpte240m, linear, log100, log316, iec61966-2-4, bt1361e,"
155
           " iec61966-2-1, bt2020-10, bt2020-12, smpte-st-2084, smpte-st-428 or arib-std-b67");
156
     CHECK(param->vui.matrixCoeffs < 0
157
           || param->vui.matrixCoeffs > 14
158
           || param->vui.matrixCoeffs == 3,
159
-          "Matrix Coefficients must be undef, bt709, fcc, bt470bg, smpte170m,"
160
-          " smpte240m, GBR, YCgCo, bt2020nc, bt2020c, smpte-st-2085, chroma-nc, chroma-c or ictcp");
161
+          "Matrix Coefficients must be unknown, bt709, fcc, bt470bg, smpte170m,"
162
+          " smpte240m, gbr, ycgco, bt2020nc, bt2020c, smpte-st-2085, chroma-nc, chroma-c or ictcp");
163
     CHECK(param->vui.chromaSampleLocTypeTopField < 0
164
           || param->vui.chromaSampleLocTypeTopField > 5,
165
           "Chroma Sample Location Type Top Field must be 0-5");
166
@@ -1688,8 +1761,8 @@
167
           "scenecutThreshold must be greater than 0");
168
     CHECK(param->scenecutBias < 0 || 100 < param->scenecutBias,
169
             "scenecut-bias must be between 0 and 100");
170
-    CHECK(param->edgeTransitionThreshold < 0.0 || 2.0 < param->edgeTransitionThreshold,
171
-            "hist-threshold must be between 0.0 and 2.0");
172
+    CHECK(param->edgeTransitionThreshold < 0.0 || 1.0 < param->edgeTransitionThreshold,
173
+            "hist-threshold must be between 0.0 and 1.0");
174
     CHECK(param->radl < 0 || param->radl > param->bframes,
175
           "radl must be between 0 and bframes");
176
     CHECK(param->rdPenalty < 0 || param->rdPenalty > 2,
177
@@ -1712,6 +1785,10 @@
178
         "Valid vbv-end-fr-adj must be a fraction 0 - 1");
179
     CHECK(!param->totalFrames && param->vbvEndFrameAdjust,
180
         "vbv-end-fr-adj cannot be enabled when total number of frames is unknown");
181
+    CHECK(param->minVbvFullness < 0 && param->minVbvFullness > 100,
182
+        "min-vbv-fullness must be a fraction 0 - 100");
183
+    CHECK(param->maxVbvFullness < 0 && param->maxVbvFullness > 100,
184
+        "max-vbv-fullness must be a fraction 0 - 100");
185
     CHECK(param->rc.bitrate < 0,
186
           "Target bitrate can not be less than zero");
187
     CHECK(param->rc.qCompress < 0.5 || param->rc.qCompress > 1.0,
188
@@ -1756,11 +1833,9 @@
189
         CHECK((param->rc.vbvMaxBitrate <= 0 || param->rc.vbvBufferSize <= 0), "Dolby Vision requires VBV settings to enable HRD.\n");
190
         CHECK((param->internalBitDepth != 10), "Dolby Vision profile - 5, profile - 8.1 and profile - 8.2 is Main10 only\n");
191
         CHECK((param->internalCsp != X265_CSP_I420), "Dolby Vision profile - 5, profile - 8.1 and profile - 8.2 requires YCbCr 4:2:0 color space\n");
192
-
193
         if (param->dolbyProfile == 81)
194
             CHECK(!(param->masteringDisplayColorVolume), "Dolby Vision profile - 8.1 requires Mastering display color volume information\n");
195
     }
196
-
197
     if (param->bField && param->interlaceMode)
198
     {
199
         CHECK( (param->bFrameAdaptive==0), "Adaptive B-frame decision method should be closed for field feature.\n" );
200
@@ -1768,13 +1843,38 @@
201
     }
202
     CHECK(param->selectiveSAO < 0 || param->selectiveSAO > 4,
203
         "Invalid SAO tune level. Value must be between 0 and 4 (inclusive)");
204
-    CHECK(param->scenecutWindow < 0 || param->scenecutWindow > 1000,
205
-        "Invalid scenecut Window duration. Value must be between 0 and 1000(inclusive)");
206
-    CHECK(param->maxQpDelta < 0 || param->maxQpDelta > 10,
207
-        "Invalid maxQpDelta value. Value must be between 0 and 10 (inclusive)");
208
-    for(int level = 0; level < 3; level++)
209
-        CHECK(param->hmeRange[level] < 0 || param->hmeRange[level] >= 32768,
210
-            "Search Range for HME levels must be between 0 and 32768");
211
+    if (param->bEnableSceneCutAwareQp)
212
+    {
213
+        if (!param->rc.bStatRead)
214
+        {
215
+            param->bEnableSceneCutAwareQp = 0;
216
+            x265_log(param, X265_LOG_WARNING, "Disabling Scenecut Aware Frame Quantizer Selection since it works only in pass 2\n");
217
+        }
218
+        else
219
+        {
220
+            CHECK(param->bEnableSceneCutAwareQp < 0 || param->bEnableSceneCutAwareQp > 3,
221
+            "Invalid masking direction. Value must be between 0 and 3(inclusive)");
222
+            CHECK(param->fwdScenecutWindow < 0 || param->fwdScenecutWindow > 1000,
223
+            "Invalid forward scenecut Window duration. Value must be between 0 and 1000(inclusive)");
224
+            CHECK(param->fwdRefQpDelta < 0 || param->fwdRefQpDelta > 10,
225
+            "Invalid fwdRefQpDelta value. Value must be between 0 and 10 (inclusive)");
226
+            CHECK(param->fwdNonRefQpDelta < 0 || param->fwdNonRefQpDelta > 10,
227
+            "Invalid fwdNonRefQpDelta value. Value must be between 0 and 10 (inclusive)");
228
+
229
+            CHECK(param->bwdScenecutWindow < 0 || param->bwdScenecutWindow > 1000,
230
+                "Invalid backward scenecut Window duration. Value must be between 0 and 1000(inclusive)");
231
+            CHECK(param->bwdRefQpDelta < -1 || param->bwdRefQpDelta > 10,
232
+                "Invalid bwdRefQpDelta value. Value must be between 0 and 10 (inclusive)");
233
+            CHECK(param->bwdNonRefQpDelta < -1 || param->bwdNonRefQpDelta > 10,
234
+                "Invalid bwdNonRefQpDelta value. Value must be between 0 and 10 (inclusive)");
235
+        }
236
+    }
237
+    if (param->bEnableHME)
238
+    {
239
+        for (int level = 0; level < 3; level++)
240
+            CHECK(param->hmeRange[level] < 0 || param->hmeRange[level] >= 32768,
241
+                "Search Range for HME levels must be between 0 and 32768");
242
+    }
243
 #if !X86_64
244
     CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 || param->sourceHeight > 480),
245
         "SEA motion search does not support resolutions greater than 480p in 32 bit build");
246
@@ -1801,6 +1901,15 @@
247
     CHECK(param->confWinRightOffset < 0, "Conformance Window Right Offset must be 0 or greater");
248
     CHECK(param->confWinBottomOffset < 0, "Conformance Window Bottom Offset must be 0 or greater");
249
     CHECK(param->decoderVbvMaxRate < 0, "Invalid Decoder Vbv Maxrate. Value can not be less than zero");
250
+    if (param->bliveVBV2pass)
251
+    {
252
+        CHECK((param->rc.bStatRead == 0), "Live VBV in multi pass option requires rate control 2 pass to be enabled");
253
+        if ((param->rc.vbvMaxBitrate <= 0 || param->rc.vbvBufferSize <= 0))
254
+        {
255
+            param->bliveVBV2pass = 0;
256
+            x265_log(param, X265_LOG_WARNING, "Live VBV enabled without VBV settings.Disabling live VBV in 2 pass\n");
257
+        }
258
+    }
259
     return check_failed;
260
 }
261
 
262
@@ -2115,8 +2224,8 @@
263
             BOOL(p->rc.bEnableSlowFirstPass, "slow-firstpass");
264
         if (p->rc.vbvBufferSize)
265
         {
266
-            s += sprintf(s, " vbv-maxrate=%d vbv-bufsize=%d vbv-init=%.1f",
267
-                 p->rc.vbvMaxBitrate, p->rc.vbvBufferSize, p->rc.vbvBufferInit);
268
+            s += sprintf(s, " vbv-maxrate=%d vbv-bufsize=%d vbv-init=%.1f min-vbv-fullness=%.1f max-vbv-fullness=%.1f",
269
+                p->rc.vbvMaxBitrate, p->rc.vbvBufferSize, p->rc.vbvBufferInit, p->minVbvFullness, p->maxVbvFullness);
270
             if (p->vbvBufferEnd)
271
                 s += sprintf(s, " vbv-end=%.1f vbv-end-fr-adj=%.1f", p->vbvBufferEnd, p->vbvEndFrameAdjust);
272
             if (p->rc.rateControlMode == X265_RC_CRF)
273
@@ -2217,11 +2326,12 @@
274
     BOOL(p->bEnableSvtHevc, "svt");
275
     BOOL(p->bField, "field");
276
     s += sprintf(s, " qp-adaptation-range=%.2f", p->rc.qpAdaptationRange);
277
-    BOOL(p->bEnableSceneCutAwareQp, "scenecut-aware-qp");
278
+    s += sprintf(s, " scenecut-aware-qp=%d", p->bEnableSceneCutAwareQp);
279
     if (p->bEnableSceneCutAwareQp)
280
-        s += sprintf(s, " scenecut-window=%d max-qp-delta=%d", p->scenecutWindow, p->maxQpDelta);
281
+        s += sprintf(s, " fwd-scenecut-window=%d fwd-ref-qp-delta=%f fwd-nonref-qp-delta=%f bwd-scenecut-window=%d bwd-ref-qp-delta=%f bwd-nonref-qp-delta=%f", p->fwdScenecutWindow, p->fwdRefQpDelta, p->fwdNonRefQpDelta, p->bwdScenecutWindow, p->bwdRefQpDelta, p->bwdNonRefQpDelta);
282
     s += sprintf(s, "conformance-window-offsets right=%d bottom=%d", p->confWinRightOffset, p->confWinBottomOffset);
283
     s += sprintf(s, " decoder-max-rate=%d", p->decoderVbvMaxRate);
284
+    BOOL(p->bliveVBV2pass, "vbv-live-multi-pass");
285
 #undef BOOL
286
     return buf;
287
 }
288
@@ -2424,6 +2534,8 @@
289
     dst->rc.vbvMaxBitrate = src->rc.vbvMaxBitrate;
290
 
291
     dst->rc.vbvBufferInit = src->rc.vbvBufferInit;
292
+    dst->minVbvFullness = src->minVbvFullness;
293
+    dst->maxVbvFullness = src->maxVbvFullness;
294
     dst->rc.cuTree = src->rc.cuTree;
295
     dst->rc.rfConstantMax = src->rc.rfConstantMax;
296
     dst->rc.rfConstantMin = src->rc.rfConstantMin;
297
@@ -2570,12 +2682,17 @@
298
     dst->bEnableSvtHevc = src->bEnableSvtHevc;
299
     dst->bEnableFades = src->bEnableFades;
300
     dst->bEnableSceneCutAwareQp = src->bEnableSceneCutAwareQp;
301
-    dst->scenecutWindow = src->scenecutWindow;
302
-    dst->maxQpDelta = src->maxQpDelta;
303
+    dst->fwdScenecutWindow = src->fwdScenecutWindow;
304
+    dst->fwdRefQpDelta = src->fwdRefQpDelta;
305
+    dst->fwdNonRefQpDelta = src->fwdNonRefQpDelta;
306
+    dst->bwdScenecutWindow = src->bwdScenecutWindow;
307
+    dst->bwdRefQpDelta = src->bwdRefQpDelta;
308
+    dst->bwdNonRefQpDelta = src->bwdNonRefQpDelta;
309
     dst->bField = src->bField;
310
 
311
     dst->confWinRightOffset = src->confWinRightOffset;
312
     dst->confWinBottomOffset = src->confWinBottomOffset;
313
+    dst->bliveVBV2pass = src->bliveVBV2pass;
314
 #ifdef SVT_HEVC
315
     memcpy(dst->svtHevcParam, src->svtHevcParam, sizeof(EB_H265_ENC_CONFIGURATION));
316
 #endif
317
x265_3.5.tar.gz/source/common/ppc Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/common/vec Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/common/x86 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/compat Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/compat/getopt Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/compat/msvc Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/dynamicHDR10 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/dynamicHDR10/json11 Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/encoder Added
2
 
1
+(directory)
2
x265_3.4.tar.gz/source/encoder/api.cpp -> x265_3.5.tar.gz/source/encoder/api.cpp Changed
10
 
1
@@ -33,7 +33,7 @@
2
 #include "svt.h"
3
 
4
 #if ENABLE_LIBVMAF
5
-#include "libvmaf.h"
6
+#include "libvmaf/libvmaf.h"
7
 #endif
8
 
9
 /* multilib namespace reflectors */
10
x265_3.4.tar.gz/source/encoder/encoder.cpp -> x265_3.5.tar.gz/source/encoder/encoder.cpp Changed
395
 
1
@@ -222,12 +222,9 @@
2
         uint32_t pixelbytes = m_param->internalBitDepth > 8 ? 2 : 1;
3
         m_edgePic = X265_MALLOC(pixel, m_planeSizes[0] * pixelbytes);
4
         m_edgeHistThreshold = m_param->edgeTransitionThreshold;
5
-        m_chromaHistThreshold = m_edgeHistThreshold * 10.0;
6
-        m_chromaHistThreshold = x265_min(m_chromaHistThreshold, MAX_SCENECUT_THRESHOLD);
7
-        m_scaledEdgeThreshold = m_edgeHistThreshold * SCENECUT_STRENGTH_FACTOR;
8
-        m_scaledEdgeThreshold = x265_min(m_scaledEdgeThreshold, MAX_SCENECUT_THRESHOLD);
9
-        m_scaledChromaThreshold = m_chromaHistThreshold * SCENECUT_STRENGTH_FACTOR;
10
-        m_scaledChromaThreshold = x265_min(m_scaledChromaThreshold, MAX_SCENECUT_THRESHOLD);
11
+        m_chromaHistThreshold = x265_min(m_edgeHistThreshold * 10.0, MAX_SCENECUT_THRESHOLD);
12
+        m_scaledEdgeThreshold = x265_min(m_edgeHistThreshold * SCENECUT_STRENGTH_FACTOR, MAX_SCENECUT_THRESHOLD);
13
+        m_scaledChromaThreshold = x265_min(m_chromaHistThreshold * SCENECUT_STRENGTH_FACTOR, MAX_SCENECUT_THRESHOLD);
14
         if (m_param->sourceBitDepth != m_param->internalBitDepth)
15
         {
16
             int size = m_param->sourceWidth * m_param->sourceHeight;
17
@@ -1437,7 +1434,6 @@
18
     }
19
 
20
     size_t bufSize = sizeof(pixel) * m_planeSizes[0];
21
-    int32_t planeCount = x265_cli_csps[m_param->internalCsp].planes;
22
     memset(m_edgePic, 0, bufSize);
23
 
24
     if (!computeEdge(m_edgePic, src, NULL, pic->width, pic->height, pic->width, false, 1))
25
@@ -1448,88 +1444,96 @@
26
 
27
     pixel pixelVal;
28
     int32_t *edgeHist = m_curEdgeHist;
29
-    memset(edgeHist, 0, 2 * sizeof(int32_t));
30
-    for (int64_t i = 0; i < m_planeSizes[0]; i++)
31
+    memset(edgeHist, 0, EDGE_BINS * sizeof(int32_t));
32
+    for (uint32_t i = 0; i < m_planeSizes[0]; i++)
33
     {
34
-        if (!m_edgePic[i])
35
-           edgeHist[0]++;
36
+        if (m_edgePic[i])
37
+            edgeHist[1]++;
38
         else
39
-           edgeHist[1]++;
40
+            edgeHist[0]++;
41
+    }
42
+
43
+    /* Y Histogram Calculation */
44
+    int32_t *yHist = m_curYUVHist[0];
45
+    memset(yHist, 0, HISTOGRAM_BINS * sizeof(int32_t));
46
+    for (uint32_t i = 0; i < m_planeSizes[0]; i++)
47
+    {
48
+        pixelVal = src[i];
49
+        yHist[pixelVal]++;
50
     }
51
 
52
     if (pic->colorSpace != X265_CSP_I400)
53
     {
54
         /* U Histogram Calculation */
55
-        int32_t *uHist = m_curUVHist[0];
56
-        memset(uHist, 0, HISTOGRAM_BINS * sizeof(int32_t));
57
-
58
-        for (int64_t i = 0; i < m_planeSizes[1]; i++)
59
+        int32_t *uHist = m_curYUVHist[1];
60
+        memset(uHist, 0, sizeof(m_curYUVHist[1]));
61
+        for (uint32_t i = 0; i < m_planeSizes[1]; i++)
62
         {
63
             pixelVal = planeU[i];
64
             uHist[pixelVal]++;
65
         }
66
 
67
         /* V Histogram Calculation */
68
-        if (planeCount == 3)
69
+        pixelVal = 0;
70
+        int32_t *vHist = m_curYUVHist[2];
71
+        memset(vHist, 0, sizeof(m_curYUVHist[2]));
72
+        for (uint32_t i = 0; i < m_planeSizes[2]; i++)
73
         {
74
-            pixelVal = 0;
75
-            int32_t *vHist = m_curUVHist[1];
76
-            memset(vHist, 0, HISTOGRAM_BINS * sizeof(int32_t));
77
-
78
-            for (int64_t i = 0; i < m_planeSizes[2]; i++)
79
-            {
80
-                pixelVal = planeV[i];
81
-                vHist[pixelVal]++;
82
-            }
83
-            for (int i = 0; i < HISTOGRAM_BINS; i++)
84
-            {
85
-                m_curMaxUVHist[i] = x265_max(uHist[i], vHist[i]);
86
-            }
87
-        }
88
-        else
89
-        {   /* in case of bi planar color space */
90
-            memcpy(m_curMaxUVHist, m_curUVHist[0], HISTOGRAM_BINS * sizeof(int32_t));
91
+            pixelVal = planeV[i];
92
+            vHist[pixelVal]++;
93
         }
94
     }
95
     return true;
96
 }
97
 
98
-void Encoder::computeHistogramSAD(double *maxUVNormalizedSad, double *edgeNormalizedSad, int curPoc)
99
+void Encoder::computeHistogramSAD(double *normalizedMaxUVSad, double *normalizedEdgeSad, int curPoc)
100
 {
101
 
102
     if (curPoc == 0)
103
     {   /* first frame is scenecut by default no sad computation for the same. */
104
-        *maxUVNormalizedSad = 0.0;
105
-        *edgeNormalizedSad  = 0.0;
106
+        *normalizedMaxUVSad = 0.0;
107
+        *normalizedEdgeSad = 0.0;
108
     }
109
     else
110
     {
111
-        /* compute sum of absolute difference of normalized histogram bins for maxUV and edge histograms. */
112
-        int32_t edgefreqDiff = 0;
113
-        int32_t maxUVfreqDiff = 0;
114
-        double  edgeProbabilityDiff = 0;
115
+        /* compute sum of absolute differences of histogram bins of chroma and luma edge response between the current and prev pictures. */
116
+        int32_t edgeHistSad = 0;
117
+        int32_t uHistSad = 0;
118
+        int32_t vHistSad = 0;
119
+        double normalizedUSad = 0.0;
120
+        double normalizedVSad = 0.0;
121
 
122
         for (int j = 0; j < HISTOGRAM_BINS; j++)
123
         {
124
             if (j < 2)
125
             {
126
-                edgefreqDiff = abs(m_curEdgeHist[j] - m_prevEdgeHist[j]);
127
-                edgeProbabilityDiff = (double) edgefreqDiff / m_planeSizes[0];
128
-                *edgeNormalizedSad += edgeProbabilityDiff;
129
+                edgeHistSad += abs(m_curEdgeHist[j] - m_prevEdgeHist[j]);
130
             }
131
-            maxUVfreqDiff = abs(m_curMaxUVHist[j] - m_prevMaxUVHist[j]);
132
-            *maxUVNormalizedSad += (double)maxUVfreqDiff / m_planeSizes[2];
133
+            uHistSad += abs(m_curYUVHist[1][j] - m_prevYUVHist[1][j]);
134
+            vHistSad += abs(m_curYUVHist[2][j] - m_prevYUVHist[2][j]);
135
         }
136
+        *normalizedEdgeSad = normalizeRange(edgeHistSad, 0, 2 * m_planeSizes[0], 0.0, 1.0);
137
+        normalizedUSad = normalizeRange(uHistSad, 0, 2 * m_planeSizes[1], 0.0, 1.0);
138
+        normalizedVSad = normalizeRange(vHistSad, 0, 2 * m_planeSizes[2], 0.0, 1.0);
139
+        *normalizedMaxUVSad = x265_max(normalizedUSad, normalizedVSad);
140
     }
141
 
142
     /* store histograms of previous frame for reference */
143
-    size_t bufsize = HISTOGRAM_BINS * sizeof(int32_t);
144
-    memcpy(m_prevMaxUVHist, m_curMaxUVHist, bufsize);
145
-    memcpy(m_prevEdgeHist, m_curEdgeHist, 2 * sizeof(int32_t));
146
+    memcpy(m_prevEdgeHist, m_curEdgeHist, sizeof(m_curEdgeHist));
147
+    memcpy(m_prevYUVHist, m_curYUVHist, sizeof(m_curYUVHist));
148
+}
149
+
150
+double Encoder::normalizeRange(int32_t value, int32_t minValue, int32_t maxValue, double rangeStart, double rangeEnd)
151
+{
152
+    return (double)(value - minValue) * (rangeEnd - rangeStart) / (maxValue - minValue) + rangeStart;
153
 }
154
 
155
-void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double maxUVSad, double edgeSad)
156
+void Encoder::findSceneCuts(x265_picture *pic, bool& bDup, double maxUVSad, double edgeSad, bool& isMaxThres, bool& isHardSC)
157
 {
158
+    double minEdgeT = m_edgeHistThreshold * MIN_EDGE_FACTOR;
159
+    double minChromaT = minEdgeT * SCENECUT_CHROMA_FACTOR;
160
+    double maxEdgeT = m_edgeHistThreshold * MAX_EDGE_FACTOR;
161
+    double maxChromaT = maxEdgeT * SCENECUT_CHROMA_FACTOR;
162
     pic->frameData.bScenecut = false;
163
 
164
     if (pic->poc == 0)
165
@@ -1544,20 +1548,25 @@
166
         {
167
             bDup = true;
168
         }
169
-        else if (edgeSad > m_edgeHistThreshold && maxUVSad >= m_chromaHistThreshold)
170
+        else if (edgeSad < minEdgeT && maxUVSad < minChromaT)
171
+        {
172
+            pic->frameData.bScenecut = false;
173
+        }
174
+        else if (edgeSad > maxEdgeT && maxUVSad > maxChromaT)
175
         {
176
             pic->frameData.bScenecut = true;
177
-            bDup = false;
178
+            isMaxThres = true;
179
+            isHardSC = true;
180
         }
181
-        else if (edgeSad > m_scaledEdgeThreshold || maxUVSad >= m_scaledChromaThreshold)
182
+        else if (edgeSad > m_scaledEdgeThreshold || maxUVSad >= m_scaledChromaThreshold
183
+                 || (edgeSad > m_edgeHistThreshold && maxUVSad >= m_chromaHistThreshold))
184
         {
185
             pic->frameData.bScenecut = true;
186
             bDup = false;
187
+            if (edgeSad > m_scaledEdgeThreshold || maxUVSad >= m_scaledChromaThreshold)
188
+                isHardSC = true;
189
         }
190
     }
191
-
192
-    if (pic->frameData.bScenecut)
193
-       x265_log(m_param, X265_LOG_DEBUG, "scene cut at %d \n", pic->poc);
194
 }
195
 
196
 /**
197
@@ -1588,6 +1597,8 @@
198
     bool dontRead = false;
199
     bool bdropFrame = false;
200
     bool dropflag = false;
201
+    bool isMaxThres = false;
202
+    bool isHardSC = false;
203
 
204
     if (m_exportedPic)
205
     {
206
@@ -1614,7 +1625,7 @@
207
             {
208
                 double maxUVSad = 0.0, edgeSad = 0.0;
209
                 computeHistogramSAD(&maxUVSad, &edgeSad, pic_in->poc);
210
-                findSceneCuts(pic, bdropFrame, maxUVSad, edgeSad);
211
+                findSceneCuts(pic, bdropFrame, maxUVSad, edgeSad, isMaxThres, isHardSC);
212
             }
213
         }
214
 
215
@@ -1782,6 +1793,7 @@
216
             inFrame->m_lowres.bScenecut = false;
217
             inFrame->m_lowres.satdCost = (int64_t)-1;
218
             inFrame->m_lowresInit = false;
219
+            inFrame->m_isInsideWindow = 0;
220
         }
221
 
222
         /* Copy input picture into a Frame and PicYuv, send to lookahead */
223
@@ -1793,6 +1805,36 @@
224
         if (m_param->bHistBasedSceneCut)
225
         {
226
             inFrame->m_lowres.bScenecut = (inputPic->frameData.bScenecut == 1) ? true : false;
227
+            inFrame->m_lowres.m_bIsMaxThres = isMaxThres;
228
+            if (m_param->radl && m_param->keyframeMax != m_param->keyframeMin)
229
+                inFrame->m_lowres.m_bIsHardScenecut = isHardSC;
230
+        }
231
+
232
+        if ((m_param->bEnableSceneCutAwareQp & BACKWARD) && m_param->rc.bStatRead)
233
+        {
234
+            RateControlEntry * rcEntry = NULL;
235
+            rcEntry = &(m_rateControl->m_rce2Pass[inFrame->m_poc]);
236
+            if(rcEntry->scenecut)
237
+            {
238
+                int backwardWindow = X265_MIN(int((m_param->bwdScenecutWindow / 1000.0) * (m_param->fpsNum / m_param->fpsDenom)), p->lookaheadDepth);
239
+                for (int i = 1; i <= backwardWindow; i++)
240
+                {
241
+                    int frameNum = inFrame->m_poc - i;
242
+                    Frame * frame = m_lookahead->m_inputQueue.getPOC(frameNum);
243
+                    if (frame)
244
+                        frame->m_isInsideWindow = BACKWARD_WINDOW;
245
+                }
246
+            }
247
+        }
248
+        if (m_param->bHistBasedSceneCut && m_param->analysisSave)
249
+        {
250
+            memcpy(inFrame->m_analysisData.edgeHist, m_curEdgeHist, EDGE_BINS * sizeof(int32_t));
251
+            memcpy(inFrame->m_analysisData.yuvHist[0], m_curYUVHist[0], HISTOGRAM_BINS *sizeof(int32_t));
252
+            if (inputPic->colorSpace != X265_CSP_I400)
253
+            {
254
+                memcpy(inFrame->m_analysisData.yuvHist[1], m_curYUVHist[1], HISTOGRAM_BINS * sizeof(int32_t));
255
+                memcpy(inFrame->m_analysisData.yuvHist[2], m_curYUVHist[2], HISTOGRAM_BINS * sizeof(int32_t));
256
+            }
257
         }
258
         inFrame->m_forceqp   = inputPic->forceqp;
259
         inFrame->m_param     = (m_reconfigure || m_reconfigureRc) ? m_latestParam : m_param;
260
@@ -1999,6 +2041,16 @@
261
                     pic_out->analysisData.poc = pic_out->poc;
262
                     pic_out->analysisData.sliceType = pic_out->sliceType;
263
                     pic_out->analysisData.bScenecut = outFrame->m_lowres.bScenecut;
264
+                    if (m_param->bHistBasedSceneCut)
265
+                    {
266
+                        memcpy(pic_out->analysisData.edgeHist, outFrame->m_analysisData.edgeHist, EDGE_BINS * sizeof(int32_t));
267
+                        memcpy(pic_out->analysisData.yuvHist[0], outFrame->m_analysisData.yuvHist[0], HISTOGRAM_BINS * sizeof(int32_t));
268
+                        if (pic_out->colorSpace != X265_CSP_I400)
269
+                        {
270
+                            memcpy(pic_out->analysisData.yuvHist[1], outFrame->m_analysisData.yuvHist[1], HISTOGRAM_BINS * sizeof(int32_t));
271
+                            memcpy(pic_out->analysisData.yuvHist[2], outFrame->m_analysisData.yuvHist[2], HISTOGRAM_BINS * sizeof(int32_t));
272
+                        }
273
+                    }
274
                     pic_out->analysisData.satdCost  = outFrame->m_lowres.satdCost;
275
                     pic_out->analysisData.numCUsInFrame = outFrame->m_analysisData.numCUsInFrame;
276
                     pic_out->analysisData.numPartitions = outFrame->m_analysisData.numPartitions;
277
@@ -2190,8 +2242,23 @@
278
             frameEnc = m_lookahead->getDecidedPicture();
279
         if (frameEnc && !pass && (!m_param->chunkEnd || (m_encodedFrameNum < m_param->chunkEnd)))
280
         {
281
-            if (m_param->bEnableSceneCutAwareQp && frameEnc->m_lowres.bScenecut)
282
-                m_rateControl->m_lastScenecut = frameEnc->m_poc;
283
+            if ((m_param->bEnableSceneCutAwareQp & FORWARD) && m_param->rc.bStatRead)
284
+            {
285
+                RateControlEntry * rcEntry;
286
+                rcEntry = &(m_rateControl->m_rce2Pass[frameEnc->m_poc]);
287
+
288
+                if (rcEntry->scenecut)
289
+                {
290
+                    if (m_rateControl->m_lastScenecut == -1)
291
+                        m_rateControl->m_lastScenecut = frameEnc->m_poc;
292
+                    else
293
+                    {
294
+                        int maxWindowSize = int((m_param->fwdScenecutWindow / 1000.0) * (m_param->fpsNum / m_param->fpsDenom) + 0.5);
295
+                        if (frameEnc->m_poc > (m_rateControl->m_lastScenecut + maxWindowSize))
296
+                            m_rateControl->m_lastScenecut = frameEnc->m_poc;
297
+                    }
298
+                }
299
+            }
300
 
301
             if (m_param->analysisMultiPassRefine || m_param->analysisMultiPassDistortion)
302
             {
303
@@ -4190,10 +4257,10 @@
304
     p->unitSizeDepth = p->maxLog2CUSize - LOG2_UNIT_SIZE;
305
     p->num4x4Partitions = (1U << (p->unitSizeDepth << 1));
306
 
307
-    if (p->radl && (p->keyframeMax != p->keyframeMin))
308
+    if (p->radl && p->bOpenGOP)
309
     {
310
         p->radl = 0;
311
-        x265_log(p, X265_LOG_WARNING, "Radl requires fixed gop-length (keyint == min-keyint). Disabling radl.\n");
312
+        x265_log(p, X265_LOG_WARNING, "Radl requires closed gop structure. Disabling radl.\n");
313
     }
314
 
315
     if ((p->chunkStart || p->chunkEnd) && p->bOpenGOP && m_param->bResetZoneConfig)
316
@@ -4248,7 +4315,7 @@
317
 
318
    if (p->bHistBasedSceneCut && !p->edgeTransitionThreshold)
319
    {
320
-       p->edgeTransitionThreshold = 0.01;
321
+       p->edgeTransitionThreshold = 0.03;
322
        x265_log(p, X265_LOG_WARNING, "using  default threshold %.2lf for scene cut detection\n", p->edgeTransitionThreshold);
323
    }
324
 
325
@@ -4312,6 +4379,16 @@
326
     analysis->frameRecordSize = frameRecordSize;
327
     X265_FREAD(&analysis->sliceType, sizeof(int), 1, m_analysisFileIn, &(picData->sliceType));
328
     X265_FREAD(&analysis->bScenecut, sizeof(int), 1, m_analysisFileIn, &(picData->bScenecut));
329
+    if (m_param->bHistBasedSceneCut)
330
+    {
331
+        X265_FREAD(&analysis->edgeHist, sizeof(int32_t), EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);
332
+        X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);
333
+        if (m_param->internalCsp != X265_CSP_I400)
334
+        {
335
+            X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);
336
+            X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);
337
+        }
338
+    }
339
     X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileIn, &(picData->satdCost));
340
     X265_FREAD(&numCUsLoad, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));
341
     X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));
342
@@ -4634,6 +4711,16 @@
343
     analysis->frameRecordSize = frameRecordSize;
344
     X265_FREAD(&analysis->sliceType, sizeof(int), 1, m_analysisFileIn, &(picData->sliceType));
345
     X265_FREAD(&analysis->bScenecut, sizeof(int), 1, m_analysisFileIn, &(picData->bScenecut));
346
+    if (m_param->bHistBasedSceneCut)
347
+    {
348
+        X265_FREAD(&analysis->edgeHist, sizeof(int32_t), EDGE_BINS, m_analysisFileIn, &m_curEdgeHist);
349
+        X265_FREAD(&analysis->yuvHist[0], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[0]);
350
+        if (m_param->internalCsp != X265_CSP_I400)
351
+        {
352
+            X265_FREAD(&analysis->yuvHist[1], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[1]);
353
+            X265_FREAD(&analysis->yuvHist[2], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileIn, &m_curYUVHist[2]);
354
+        }
355
+    }
356
     X265_FREAD(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileIn, &(picData->satdCost));
357
     X265_FREAD(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFileIn, &(picData->numCUsInFrame));
358
     X265_FREAD(&analysis->numPartitions, sizeof(int), 1, m_analysisFileIn, &(picData->numPartitions));
359
@@ -5399,6 +5486,17 @@
360
     /* calculate frameRecordSize */
361
     analysis->frameRecordSize = sizeof(analysis->frameRecordSize) + sizeof(depthBytes) + sizeof(analysis->poc) + sizeof(analysis->sliceType) +
362
                       sizeof(analysis->numCUsInFrame) + sizeof(analysis->numPartitions) + sizeof(analysis->bScenecut) + sizeof(analysis->satdCost);
363
+    if (m_param->bHistBasedSceneCut)
364
+    {
365
+        analysis->frameRecordSize += sizeof(analysis->edgeHist);
366
+        analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;
367
+        if (m_param->internalCsp != X265_CSP_I400)
368
+        {
369
+            analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;
370
+            analysis->frameRecordSize += sizeof(int32_t) * HISTOGRAM_BINS;
371
+        }
372
+    }
373
+
374
     if (analysis->sliceType > X265_TYPE_I)
375
     {
376
         numDir = (analysis->sliceType == X265_TYPE_P) ? 1 : 2;
377
@@ -5543,6 +5641,17 @@
378
     X265_FWRITE(&analysis->poc, sizeof(int), 1, m_analysisFileOut);
379
     X265_FWRITE(&analysis->sliceType, sizeof(int), 1, m_analysisFileOut);
380
     X265_FWRITE(&analysis->bScenecut, sizeof(int), 1, m_analysisFileOut);
381
+    if (m_param->bHistBasedSceneCut)
382
+    {
383
+        X265_FWRITE(&analysis->edgeHist, sizeof(int32_t), EDGE_BINS, m_analysisFileOut);
384
+        X265_FWRITE(&analysis->yuvHist[0], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileOut);
385
+        if (m_param->internalCsp != X265_CSP_I400)
386
+        {
387
+            X265_FWRITE(&analysis->yuvHist[1], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileOut);
388
+            X265_FWRITE(&analysis->yuvHist[2], sizeof(int32_t), HISTOGRAM_BINS, m_analysisFileOut);
389
+        }
390
+    }
391
+
392
     X265_FWRITE(&analysis->satdCost, sizeof(int64_t), 1, m_analysisFileOut);
393
     X265_FWRITE(&analysis->numCUsInFrame, sizeof(int), 1, m_analysisFileOut);
394
     X265_FWRITE(&analysis->numPartitions, sizeof(int), 1, m_analysisFileOut);
395
x265_3.4.tar.gz/source/encoder/encoder.h -> x265_3.5.tar.gz/source/encoder/encoder.h Changed
36
 
1
@@ -163,8 +163,11 @@
2
 class ThreadPool;
3
 class FrameData;
4
 
5
-#define MAX_SCENECUT_THRESHOLD 2.0
6
+#define MAX_SCENECUT_THRESHOLD 1.0
7
 #define SCENECUT_STRENGTH_FACTOR 2.0
8
+#define MIN_EDGE_FACTOR 0.5
9
+#define MAX_EDGE_FACTOR 1.5
10
+#define SCENECUT_CHROMA_FACTOR 10.0
11
 
12
 class Encoder : public x265_encoder
13
 {
14
@@ -256,9 +259,8 @@
15
     /* For histogram based scene-cut detection */
16
     pixel*             m_edgePic;
17
     pixel*             m_inputPic[3];
18
-    int32_t            m_curUVHist[2][HISTOGRAM_BINS];
19
-    int32_t            m_curMaxUVHist[HISTOGRAM_BINS];
20
-    int32_t            m_prevMaxUVHist[HISTOGRAM_BINS];
21
+    int32_t            m_curYUVHist[3][HISTOGRAM_BINS];
22
+    int32_t            m_prevYUVHist[3][HISTOGRAM_BINS];
23
     int32_t            m_curEdgeHist[2];
24
     int32_t            m_prevEdgeHist[2];
25
     uint32_t           m_planeSizes[3];
26
@@ -373,7 +375,8 @@
27
 
28
     bool computeHistograms(x265_picture *pic);
29
     void computeHistogramSAD(double *maxUVNormalizedSAD, double *edgeNormalizedSAD, int curPoc);
30
-    void findSceneCuts(x265_picture *pic, bool& bDup, double m_maxUVSADVal, double m_edgeSADVal);
31
+    double normalizeRange(int32_t value, int32_t minValue, int32_t maxValue, double rangeStart, double rangeEnd);
32
+    void findSceneCuts(x265_picture *pic, bool& bDup, double m_maxUVSADVal, double m_edgeSADVal, bool& isMaxThres, bool& isHardSC);
33
 
34
     void initRefIdx();
35
     void analyseRefIdx(int *numRefIdx);
36
x265_3.4.tar.gz/source/encoder/frameencoder.cpp -> x265_3.5.tar.gz/source/encoder/frameencoder.cpp Changed
113
 
1
@@ -47,8 +47,6 @@
2
     m_slicetypeWaitTime = 0;
3
     m_activeWorkerCount = 0;
4
     m_completionCount = 0;
5
-    m_bAllRowsStop = false;
6
-    m_vbvResetTriggerRow = -1;
7
     m_outStreams = NULL;
8
     m_backupStreams = NULL;
9
     m_substreamSizes = NULL;
10
@@ -88,6 +86,8 @@
11
     delete[] m_outStreams;
12
     delete[] m_backupStreams;
13
     X265_FREE(m_sliceBaseRow);
14
+    X265_FREE((void*)m_bAllRowsStop);
15
+    X265_FREE((void*)m_vbvResetTriggerRow);
16
     X265_FREE(m_sliceMaxBlockRow);
17
     X265_FREE(m_cuGeoms);
18
     X265_FREE(m_ctuGeomMap);
19
@@ -118,6 +118,8 @@
20
     bool ok = !!m_numRows;
21
 
22
     m_sliceBaseRow = X265_MALLOC(uint32_t, m_param->maxSlices + 1);
23
+    m_bAllRowsStop = X265_MALLOC(bool, m_param->maxSlices);
24
+    m_vbvResetTriggerRow = X265_MALLOC(int, m_param->maxSlices);
25
     ok &= !!m_sliceBaseRow;
26
     m_sliceGroupSize = (uint16_t)(m_numRows + m_param->maxSlices - 1) / m_param->maxSlices;
27
     uint32_t sliceGroupSizeAccu = (m_numRows << 8) / m_param->maxSlices;    
28
@@ -438,8 +440,8 @@
29
     m_stallStartTime = 0;
30
 
31
     m_completionCount = 0;
32
-    m_bAllRowsStop = false;
33
-    m_vbvResetTriggerRow = -1;
34
+    memset((void*)m_bAllRowsStop, 0, sizeof(bool) * m_param->maxSlices);
35
+    memset((void*)m_vbvResetTriggerRow, -1, sizeof(int) * m_param->maxSlices);
36
     m_rowSliceTotalBits[0] = 0;
37
     m_rowSliceTotalBits[1] = 0;
38
 
39
@@ -1469,16 +1471,16 @@
40
                 curRow.bufferedEntropy.copyState(rowCoder);
41
                 curRow.bufferedEntropy.loadContexts(rowCoder);
42
             }
43
-            if (bFirstRowInSlice && m_vbvResetTriggerRow != intRow)            
44
+            if (bFirstRowInSlice && m_vbvResetTriggerRow[curRow.sliceId] != intRow)
45
             {
46
                 curEncData.m_rowStat[row].rowQp = curEncData.m_avgQpRc;
47
                 curEncData.m_rowStat[row].rowQpScale = x265_qp2qScale(curEncData.m_avgQpRc);
48
             }
49
 
50
             FrameData::RCStatCU& cuStat = curEncData.m_cuStat[cuAddr];
51
-            if (m_param->bEnableWavefront && rowInSlice >= col && !bFirstRowInSlice && m_vbvResetTriggerRow != intRow)
52
+            if (m_param->bEnableWavefront && rowInSlice >= col && !bFirstRowInSlice && m_vbvResetTriggerRow[curRow.sliceId] != intRow)
53
                 cuStat.baseQp = curEncData.m_cuStat[cuAddr - numCols + 1].baseQp;
54
-            else if (!m_param->bEnableWavefront && !bFirstRowInSlice && m_vbvResetTriggerRow != intRow)
55
+            else if (!m_param->bEnableWavefront && !bFirstRowInSlice && m_vbvResetTriggerRow[curRow.sliceId] != intRow)
56
                 cuStat.baseQp = curEncData.m_rowStat[row - 1].rowQp;
57
             else
58
                 cuStat.baseQp = curEncData.m_rowStat[row].rowQp;
59
@@ -1655,7 +1657,7 @@
60
                     x265_log(m_param, X265_LOG_DEBUG, "POC %d row %d - encode restart required for VBV, to %.2f from %.2f\n",
61
                         m_frame->m_poc, row, qpBase, curEncData.m_cuStat[cuAddr].baseQp);
62
 
63
-                    m_vbvResetTriggerRow = row;
64
+                    m_vbvResetTriggerRow[curRow.sliceId] = row;
65
                     m_outStreams[0].copyBits(&m_backupStreams[0]);
66
 
67
                     rowCoder.copyState(curRow.bufferedEntropy);
68
@@ -1707,8 +1709,8 @@
69
                              m_frame->m_poc, row, qpBase, curEncData.m_cuStat[cuAddr].baseQp);
70
 
71
                     // prevent the WaveFront::findJob() method from providing new jobs
72
-                    m_vbvResetTriggerRow = row;
73
-                    m_bAllRowsStop = true;
74
+                    m_vbvResetTriggerRow[curRow.sliceId] = row;
75
+                    m_bAllRowsStop[curRow.sliceId] = true;
76
 
77
                     for (uint32_t r = m_sliceBaseRow[sliceId + 1] - 1; r >= row; r--)
78
                     {
79
@@ -1720,7 +1722,7 @@
80
                             stopRow.lock.acquire();
81
                             while (stopRow.active)
82
                             {
83
-                                if (dequeueRow(r * 2))
84
+                                if (dequeueRow(m_row_to_idx[r] * 2))
85
                                     stopRow.active = false;
86
                                 else
87
                                 {
88
@@ -1758,13 +1760,13 @@
89
                         curEncData.m_rowStat[r].sumQpAq = 0;
90
                     }
91
 
92
-                    m_bAllRowsStop = false;
93
+                    m_bAllRowsStop[curRow.sliceId] = false;
94
                 }
95
             }
96
         }
97
 
98
         if (m_param->bEnableWavefront && curRow.completed >= 2 && !bLastRowInSlice &&
99
-            (!m_bAllRowsStop || intRow + 1 < m_vbvResetTriggerRow))
100
+            (!m_bAllRowsStop[curRow.sliceId] || intRow + 1 < m_vbvResetTriggerRow[curRow.sliceId]))
101
         {
102
             /* activate next row */
103
             ScopedLock below(m_rows[row + 1].lock);
104
@@ -1779,7 +1781,7 @@
105
         }
106
 
107
         ScopedLock self(curRow.lock);
108
-        if ((m_bAllRowsStop && intRow > m_vbvResetTriggerRow) ||
109
+        if ((m_bAllRowsStop[curRow.sliceId] && intRow > m_vbvResetTriggerRow[curRow.sliceId]) ||
110
             (!bFirstRowInSlice && ((curRow.completed < numCols - 1) || (m_rows[row - 1].completed < numCols)) && m_rows[row - 1].completed < curRow.completed + 2))
111
         {
112
             curRow.active = false;
113
x265_3.4.tar.gz/source/encoder/frameencoder.h -> x265_3.5.tar.gz/source/encoder/frameencoder.h Changed
13
 
1
@@ -140,9 +140,9 @@
2
     int                      m_localTldIdx;
3
     bool                     m_reconfigure; /* reconfigure in progress */
4
     volatile bool            m_threadActive;
5
-    volatile bool            m_bAllRowsStop;
6
+    volatile bool            *m_bAllRowsStop;
7
     volatile int             m_completionCount;
8
-    volatile int             m_vbvResetTriggerRow;
9
+    volatile int             *m_vbvResetTriggerRow;
10
     volatile int             m_sliceCnt;
11
 
12
     uint32_t                 m_numRows;
13
x265_3.4.tar.gz/source/encoder/ratecontrol.cpp -> x265_3.5.tar.gz/source/encoder/ratecontrol.cpp Changed
450
 
1
@@ -356,6 +356,8 @@
2
         m_bufferFillFinal = m_bufferSize * m_param->rc.vbvBufferInit;
3
         m_bufferFillActual = m_bufferFillFinal;
4
         m_bufferExcess = 0;
5
+        m_minBufferFill = m_param->minVbvFullness / 100;
6
+        m_maxBufferFill = 1 - (m_param->maxVbvFullness / 100);
7
         m_initVbv = true;
8
     }
9
 
10
@@ -580,7 +582,7 @@
11
             double totalQpAq = 0;
12
             for (int i = 0; i < m_numEntries; i++)
13
             {
14
-                RateControlEntry *rce;
15
+                RateControlEntry *rce, *rcePocOrder;
16
                 int frameNumber;
17
                 int encodeOrder;
18
                 char picType;
19
@@ -597,13 +599,16 @@
20
                     return false;
21
                 }
22
                 rce = &m_rce2Pass[encodeOrder];
23
+                rcePocOrder = &m_rce2Pass[frameNumber];
24
                 m_encOrder[frameNumber] = encodeOrder;
25
                 if (!m_param->bMultiPassOptRPS)
26
                 {
27
-                    e += sscanf(p, " in:%*d out:%*d type:%c q:%lf q-aq:%lf q-noVbv:%lf q-Rceq:%lf tex:%d mv:%d misc:%d icu:%lf pcu:%lf scu:%lf",
28
+                    int scenecut = 0;
29
+                    e += sscanf(p, " in:%*d out:%*d type:%c q:%lf q-aq:%lf q-noVbv:%lf q-Rceq:%lf tex:%d mv:%d misc:%d icu:%lf pcu:%lf scu:%lf sc:%d",
30
                         &picType, &qpRc, &qpAq, &qNoVbv, &qRceq, &rce->coeffBits,
31
                         &rce->mvBits, &rce->miscBits, &rce->iCuCount, &rce->pCuCount,
32
-                        &rce->skipCuCount);
33
+                        &rce->skipCuCount, &scenecut);
34
+                    rcePocOrder->scenecut = scenecut != 0;
35
                 }
36
                 else
37
                 {
38
@@ -1311,7 +1316,8 @@
39
         copyRceData(rce, &m_rce2Pass[index]);
40
     }
41
     rce->isActive = true;
42
-    rce->scenecut = false;
43
+    if (!m_param->rc.bStatRead)
44
+        rce->scenecut = false;
45
     rce->isFadeEnd = curFrame->m_lowres.bIsFadeEnd;
46
     bool isRefFrameScenecut = m_sliceType!= I_SLICE && m_curSlice->m_refFrameList[0][0]->m_lowres.bScenecut;
47
     m_isFirstMiniGop = m_sliceType == I_SLICE ? true : m_isFirstMiniGop;
48
@@ -1751,34 +1757,32 @@
49
                      g_sliceTypeToChar[m_sliceType], g_sliceTypeToChar[rce->sliceType]);
50
         }
51
     }
52
-    else
53
+
54
+    if ((m_param->bliveVBV2pass && m_param->rc.rateControlMode == X265_RC_ABR) || m_isAbr)
55
     {
56
-        if (m_isAbr)
57
+        int pos = m_sliderPos % s_slidingWindowFrames;
58
+        int addPos = (pos + s_slidingWindowFrames - 1) % s_slidingWindowFrames;
59
+        if (m_sliderPos > s_slidingWindowFrames)
60
         {
61
-            int pos = m_sliderPos % s_slidingWindowFrames;
62
-            int addPos = (pos + s_slidingWindowFrames - 1) % s_slidingWindowFrames;
63
-            if (m_sliderPos > s_slidingWindowFrames)
64
-            {
65
-                const static double base = pow(0.5, s_slidingWindowFrames - 1);
66
-                m_movingAvgSum -= m_lastRemovedSatdCost * base;
67
-                m_movingAvgSum *= 0.5;
68
-                m_movingAvgSum += m_satdCostWindow[addPos];
69
-            }
70
-            else if (m_sliderPos == s_slidingWindowFrames)
71
-            {
72
-                m_movingAvgSum += m_satdCostWindow[addPos];
73
-            }
74
-            else if (m_sliderPos > 0)
75
-            {
76
-                m_movingAvgSum += m_satdCostWindow[addPos];
77
-                m_movingAvgSum *= 0.5;
78
-            }
79
-
80
-            rce->movingAvgSum = m_movingAvgSum;
81
-            m_lastRemovedSatdCost = m_satdCostWindow[pos];
82
-            m_satdCostWindow[pos] = rce->lastSatd;
83
-            m_sliderPos++;
84
+            const static double base = pow(0.5, s_slidingWindowFrames - 1);
85
+            m_movingAvgSum -= m_lastRemovedSatdCost * base;
86
+            m_movingAvgSum *= 0.5;
87
+            m_movingAvgSum += m_satdCostWindow[addPos];
88
+        }
89
+        else if (m_sliderPos == s_slidingWindowFrames)
90
+        {
91
+            m_movingAvgSum += m_satdCostWindow[addPos];
92
+        }
93
+        else if (m_sliderPos > 0)
94
+        {
95
+            m_movingAvgSum += m_satdCostWindow[addPos];
96
+            m_movingAvgSum *= 0.5;
97
         }
98
+
99
+        rce->movingAvgSum = m_movingAvgSum;
100
+        m_lastRemovedSatdCost = m_satdCostWindow[pos];
101
+        m_satdCostWindow[pos] = rce->lastSatd;
102
+        m_sliderPos++;
103
     }
104
 
105
     if (m_sliceType == B_SLICE)
106
@@ -1856,11 +1860,15 @@
107
         {
108
             double lqmin = m_lmin[m_sliceType];
109
             double lqmax = m_lmax[m_sliceType];
110
-            qScale = scenecutAwareQp(curFrame, qScale);
111
+            if (m_param->bEnableSceneCutAwareQp & FORWARD)
112
+                qScale = forwardMasking(curFrame, qScale);
113
+            if (m_param->bEnableSceneCutAwareQp & BACKWARD)
114
+                qScale = backwardMasking(curFrame, qScale);
115
             qScale = x265_clip3(lqmin, lqmax, qScale);
116
             q = x265_qScale2qp(qScale);
117
             rce->qpNoVbv = q;
118
         }
119
+
120
         if (m_isVbv)
121
         {
122
             lmin = m_lastQScaleFor[P_SLICE] / m_lstep;
123
@@ -1882,7 +1890,7 @@
124
                 qScale = x265_clip3(lqmin, lqmax, qScale);
125
             }
126
 
127
-            if (!m_2pass)
128
+            if (!m_2pass || m_param->bliveVBV2pass)
129
             {
130
                 /* clip qp to permissible range after vbv-lookahead estimation to avoid possible 
131
                  * mispredictions by initial frame size predictors */
132
@@ -1950,7 +1958,9 @@
133
                 else
134
                     q /= zone->bitrateFactor;
135
             }
136
-            q /= x265_clip3(0.5, 2.0, (double)(abrBuffer - diff) / abrBuffer);
137
+            /*Existing ABR conformance check may not be valid with real time VBV*/
138
+            if(!m_param->bliveVBV2pass)
139
+                q /= x265_clip3(0.5, 2.0, (double)(abrBuffer - diff) / abrBuffer);
140
             if (m_expectedBitsSum > 0)
141
             {
142
                 /* Adjust quant based on the difference between
143
@@ -1971,26 +1981,51 @@
144
                 m_avgPFrameQp = (m_avgPFrameQp + rce->qpNoVbv) / 2;
145
             }
146
 
147
+            /* Scenecut Aware QP offsets*/
148
+            if (m_param->bEnableSceneCutAwareQp)
149
+            {
150
+                double qmin = m_lmin[m_sliceType];
151
+                double qmax = m_lmax[m_sliceType];
152
+
153
+                if (m_param->bEnableSceneCutAwareQp & FORWARD)
154
+                    q = forwardMasking(curFrame, q);
155
+                if (m_param->bEnableSceneCutAwareQp & BACKWARD)
156
+                    q = backwardMasking(curFrame, q);
157
+
158
+                q = x265_clip3(qmin, qmax, q);
159
+                rce->qpNoVbv = x265_qScale2qp(q);
160
+            }
161
+
162
             if (m_isVbv)
163
             {
164
-                /* Do not overflow vbv */
165
-                double expectedSize = qScale2bits(rce, q);
166
-                double expectedVbv = m_bufferFill + m_bufferRate - expectedSize;
167
-                double expectedFullness = rce->expectedVbv / m_bufferSize;
168
-                double qmax = q * (2 - expectedFullness);
169
-                double sizeConstraint = 1 + expectedFullness;
170
-                qmax = X265_MAX(qmax, rce->newQScale);
171
-                if (expectedFullness < .05)
172
-                    qmax = lmax;
173
-                qmax = X265_MIN(qmax, lmax);
174
-                while (((expectedVbv < rce->expectedVbv/sizeConstraint) && (q < qmax)) ||
175
+                if (!m_param->bliveVBV2pass)
176
+                {
177
+                    /* Do not overflow vbv */
178
+                    double expectedSize = qScale2bits(rce, q);
179
+                    double expectedVbv = m_bufferFill + m_bufferRate - expectedSize;
180
+                    double expectedFullness = rce->expectedVbv / m_bufferSize;
181
+                    double qmax = q * (2 - expectedFullness);
182
+                    double sizeConstraint = 1 + expectedFullness;
183
+                    qmax = X265_MAX(qmax, rce->newQScale);
184
+                    if (expectedFullness < .05)
185
+                        qmax = lmax;
186
+                    qmax = X265_MIN(qmax, lmax);
187
+                    while (((expectedVbv < rce->expectedVbv / sizeConstraint) && (q < qmax)) ||
188
                         ((expectedVbv < 0) && (q < lmax)))
189
+                    {
190
+                        q *= 1.05;
191
+                        expectedSize = qScale2bits(rce, q);
192
+                        expectedVbv = m_bufferFill + m_bufferRate - expectedSize;
193
+                    }
194
+                }
195
+                else
196
                 {
197
-                    q *= 1.05;
198
-                    expectedSize = qScale2bits(rce, q);
199
-                    expectedVbv = m_bufferFill + m_bufferRate - expectedSize;
200
+                        /*  clip qp to permissible range after vbv-lookahead estimation to avoid possible
201
+                        * mispredictions by Rate Control pass 1 statistics analysis */
202
+                        q = clipQscale(curFrame, rce, q);
203
                 }
204
             }
205
+
206
             q = x265_clip3(lmin, lmax, q);
207
         }
208
         else
209
@@ -2120,13 +2155,17 @@
210
             {
211
                 double qmin = m_lmin[m_sliceType];
212
                 double qmax = m_lmax[m_sliceType];
213
-                q = scenecutAwareQp(curFrame, q);
214
+
215
+                if (m_param->bEnableSceneCutAwareQp & FORWARD)
216
+                    q = forwardMasking(curFrame, q);
217
+                if (m_param->bEnableSceneCutAwareQp & BACKWARD)
218
+                    q = backwardMasking(curFrame, q);
219
+
220
                 q = x265_clip3(qmin, qmax, q);
221
                 rce->qpNoVbv = x265_qScale2qp(q);
222
             }
223
             q = clipQscale(curFrame, rce, q);
224
 
225
-
226
             if (m_2pass)
227
                 rce->frameSizePlanned = qScale2bits(rce, q);
228
             else
229
@@ -2356,7 +2395,7 @@
230
                     {
231
                         finalDur = x265_clip3(0.4, 1.0, totalDuration);
232
                     }
233
-                    targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5, m_bufferSize * (1 - 0.5 * finalDur));
234
+                    targetFill = X265_MIN(m_bufferFill + totalDuration * m_vbvMaxRate * 0.5, m_bufferSize * (1 - m_minBufferFill * finalDur));
235
                     if (bufferFillCur < targetFill)
236
                     {
237
                         q *= 1.01;
238
@@ -2364,8 +2403,9 @@
239
                         continue;
240
                     }
241
                     /* Try to get the buffer not more than 80% filled, but don't set an impossible goal. */
242
-                    targetFill = x265_clip3(m_bufferSize * (1 - 0.2 * finalDur), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);
243
-                    if (m_isCbr && bufferFillCur > targetFill && !m_isSceneTransition)
244
+
245
+                    targetFill = x265_clip3(m_bufferSize * (1 - m_maxBufferFill * finalDur), m_bufferSize, m_bufferFill - totalDuration * m_vbvMaxRate * 0.5);
246
+                    if ((m_isCbr || m_2pass) && bufferFillCur > targetFill && !m_isSceneTransition)
247
                     {
248
                         q /= 1.01;
249
                         loopTerminate |= 2;
250
@@ -2381,7 +2421,7 @@
251
             /* Fallback to old purely-reactive algorithm: no lookahead. */
252
             if ((m_sliceType == P_SLICE || m_sliceType == B_SLICE ||
253
                     (m_sliceType == I_SLICE && m_lastNonBPictType == I_SLICE)) &&
254
-                m_bufferFill / m_bufferSize < 0.5)
255
+                m_bufferFill / m_bufferSize < m_minBufferFill)
256
             {
257
                 q /= x265_clip3(0.5, 1.0, 2.0 * m_bufferFill / m_bufferSize);
258
             }
259
@@ -2418,7 +2458,7 @@
260
          * lookahead vbv reduces its qscale by half its value. Be on safer side and avoid drastic 
261
          * qscale reductions for frames high in complexity */
262
         bool mispredCheck = rce->movingAvgSum && m_currentSatd >= rce->movingAvgSum && q <= q0 / 2;
263
-        if (!m_isCbr || (m_isAbr && mispredCheck))
264
+        if (!m_isCbr || ((m_isAbr || m_2pass) && mispredCheck))
265
             q = X265_MAX(q0, q);
266
 
267
         if (m_rateFactorMaxIncrement)
268
@@ -2428,7 +2468,7 @@
269
             return x265_clip3(lmin, qmax, q);
270
         }
271
     }
272
-    if (m_2pass)
273
+    if (!curFrame && m_2pass)
274
     {
275
         double min = log(lmin);
276
         double max = log(lmax);
277
@@ -2529,13 +2569,7 @@
278
     double qScaleVbv = x265_qp2qScale(qpVbv);
279
     uint64_t rowSatdCost = curEncData.m_rowStat[row].rowSatd;
280
     double encodedBits = curEncData.m_rowStat[row].encodedBits;
281
-    uint32_t rowInSlice = row - m_sliceBaseRow[sliceId];
282
 
283
-    if (m_param->bEnableWavefront && rowInSlice == 1)
284
-    {
285
-        rowSatdCost += curEncData.m_rowStat[row - 1].rowSatd;
286
-        encodedBits += curEncData.m_rowStat[row - 1].encodedBits;
287
-    }
288
     rowSatdCost >>= X265_DEPTH - 8;
289
     updatePredictor(rce->rowPred[0], qScaleVbv, (double)rowSatdCost, encodedBits);
290
     if (curEncData.m_slice->m_sliceType != I_SLICE && !m_param->rc.bEnableConstVbv)
291
@@ -2544,8 +2578,6 @@
292
         if (qpVbv < refFrame->m_encData->m_rowStat[row].rowQp)
293
         {
294
             uint64_t intraRowSatdCost = curEncData.m_rowStat[row].rowIntraSatd;
295
-            if (m_param->bEnableWavefront && rowInSlice == 1)
296
-                intraRowSatdCost += curEncData.m_rowStat[row - 1].rowIntraSatd;
297
             intraRowSatdCost >>= X265_DEPTH - 8;
298
             updatePredictor(rce->rowPred[1], qScaleVbv, (double)intraRowSatdCost, encodedBits);
299
         }
300
@@ -2964,7 +2996,7 @@
301
     if (!curEncData.m_param->bMultiPassOptRPS)
302
     {
303
         if (fprintf(m_statFileOut,
304
-            "in:%d out:%d type:%c q:%.2f q-aq:%.2f q-noVbv:%.2f q-Rceq:%.2f tex:%d mv:%d misc:%d icu:%.2f pcu:%.2f scu:%.2f ;\n",
305
+            "in:%d out:%d type:%c q:%.2f q-aq:%.2f q-noVbv:%.2f q-Rceq:%.2f tex:%d mv:%d misc:%d icu:%.2f pcu:%.2f scu:%.2f sc:%d ;\n",
306
             rce->poc, rce->encodeOrder,
307
             cType, curEncData.m_avgQpRc, curEncData.m_avgQpAq,
308
             rce->qpNoVbv, rce->qRceq,
309
@@ -2973,7 +3005,8 @@
310
             curFrame->m_encData->m_frameStats.miscBits,
311
             curFrame->m_encData->m_frameStats.percent8x8Intra * m_ncu,
312
             curFrame->m_encData->m_frameStats.percent8x8Inter * m_ncu,
313
-            curFrame->m_encData->m_frameStats.percent8x8Skip  * m_ncu) < 0)
314
+            curFrame->m_encData->m_frameStats.percent8x8Skip  * m_ncu,
315
+            curFrame->m_lowres.bScenecut) < 0)
316
             goto writeFailure;
317
     }
318
     else
319
@@ -3150,51 +3183,94 @@
320
     }
321
 }
322
 
323
-double RateControl::scenecutAwareQp(Frame* curFrame, double q)
324
+double RateControl::forwardMasking(Frame* curFrame, double q)
325
 {
326
-    uint32_t maxWindowSize = uint32_t((m_param->scenecutWindow / 1000.0) * (m_param->fpsNum / m_param->fpsDenom) + 0.5);
327
+    double qp = x265_qScale2qp(q);
328
+    uint32_t maxWindowSize = uint32_t((m_param->fwdScenecutWindow / 1000.0) * (m_param->fpsNum / m_param->fpsDenom) + 0.5);
329
     uint32_t windowSize = maxWindowSize / 3;
330
     int lastScenecut = m_top->m_rateControl->m_lastScenecut;
331
     int lastIFrame = m_top->m_rateControl->m_lastScenecutAwareIFrame;
332
-    double maxQpDelta = x265_qp2qScale(double(m_param->maxQpDelta));
333
-    double iSliceDelta = x265_qp2qScale(double(I_SLICE_DELTA));
334
-    double sliceTypeDelta = SLICE_TYPE_DELTA * maxQpDelta;
335
-    double window2Delta = WINDOW2_DELTA * maxQpDelta;
336
-    double window3Delta = WINDOW3_DELTA * maxQpDelta;
337
+    double fwdRefQpDelta = double(m_param->fwdRefQpDelta);
338
+    double fwdNonRefQpDelta = double(m_param->fwdNonRefQpDelta);
339
+    double sliceTypeDelta = SLICE_TYPE_DELTA * fwdRefQpDelta;
340
 
341
-    bool isFrameInsideWindow = curFrame->m_poc > lastScenecut && curFrame->m_poc <= (lastScenecut + int(maxWindowSize));
342
-
343
-    if (isFrameInsideWindow && IS_X265_TYPE_I(curFrame->m_lowres.sliceType))
344
-    {
345
-        m_top->m_rateControl->m_lastScenecutAwareIFrame = curFrame->m_poc;
346
-    }
347
-    else if (isFrameInsideWindow && (curFrame->m_lowres.sliceType == X265_TYPE_P))
348
+    //Check whether the current frame is within the forward window
349
+    if (curFrame->m_poc > lastScenecut && curFrame->m_poc <= (lastScenecut + int(maxWindowSize)))
350
+        curFrame->m_isInsideWindow = FORWARD_WINDOW;
351
+    if (curFrame->m_isInsideWindow == FORWARD_WINDOW)
352
     {
353
-        if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut + int(maxWindowSize))
354
-            && curFrame->m_poc > lastIFrame))
355
+        if (IS_X265_TYPE_I(curFrame->m_lowres.sliceType) || curFrame->m_lowres.bScenecut)
356
         {
357
-            q += maxQpDelta - sliceTypeDelta;
358
-            if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
359
-                q -= window2Delta;
360
-            else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))
361
-                q -= window3Delta;
362
+            m_top->m_rateControl->m_lastScenecutAwareIFrame = curFrame->m_poc;
363
         }
364
-    }
365
-    else if (isFrameInsideWindow && IS_X265_TYPE_B(curFrame->m_lowres.sliceType))
366
-    {
367
-        if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut + int(maxWindowSize))
368
-            && curFrame->m_poc > lastIFrame))
369
+        else if (curFrame->m_lowres.sliceType == X265_TYPE_P)
370
+        {
371
+            if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut + int(maxWindowSize))
372
+                && curFrame->m_poc >= lastIFrame))
373
+            {
374
+                //Add offsets corresponding to the window in which the P-frame occurs
375
+                if (curFrame->m_poc <= (lastScenecut + int(windowSize)))
376
+                    qp += WINDOW1_DELTA * (fwdRefQpDelta - sliceTypeDelta);
377
+                else if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
378
+                    qp += WINDOW2_DELTA * (fwdRefQpDelta - sliceTypeDelta);
379
+                else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))
380
+                    qp += WINDOW3_DELTA * (fwdRefQpDelta - sliceTypeDelta);
381
+            }
382
+        }
383
+        else if (curFrame->m_lowres.sliceType == X265_TYPE_BREF)
384
+        {
385
+            if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut + int(maxWindowSize))
386
+                && curFrame->m_poc >= lastIFrame))
387
+            {
388
+                //Add offsets corresponding to the window in which the B-frame occurs
389
+                if (curFrame->m_poc <= (lastScenecut + int(windowSize)))
390
+                    qp += WINDOW1_DELTA * fwdRefQpDelta;
391
+                else if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
392
+                    qp += WINDOW2_DELTA * fwdRefQpDelta;
393
+                else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))
394
+                    qp += WINDOW3_DELTA * fwdRefQpDelta;
395
+            }
396
+        }
397
+        else if (curFrame->m_lowres.sliceType == X265_TYPE_B)
398
         {
399
-            q += maxQpDelta;
400
-            if (curFrame->m_lowres.sliceType == X265_TYPE_B)
401
-                q += sliceTypeDelta;
402
-            if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
403
-                q -= window2Delta;
404
-            else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))
405
-                q -= window3Delta;
406
+            if (!(lastIFrame > lastScenecut && lastIFrame <= (lastScenecut + int(maxWindowSize))
407
+                && curFrame->m_poc >= lastIFrame))
408
+            {
409
+                //Add offsets corresponding to the window in which the b-frame occurs
410
+                if (curFrame->m_poc <= (lastScenecut + int(windowSize)))
411
+                    qp += WINDOW1_DELTA * fwdNonRefQpDelta;
412
+                else if (((curFrame->m_poc) > (lastScenecut + int(windowSize))) && ((curFrame->m_poc) <= (lastScenecut + 2 * int(windowSize))))
413
+                    qp += WINDOW2_DELTA * fwdNonRefQpDelta;
414
+                else if (curFrame->m_poc > lastScenecut + 2 * int(windowSize))
415
+                    qp += WINDOW3_DELTA * fwdNonRefQpDelta;
416
+            }
417
         }
418
     }
419
-    if (IS_X265_TYPE_I(curFrame->m_lowres.sliceType) && curFrame->m_lowres.bScenecut)
420
-        q = q - iSliceDelta;
421
-    return q;
422
+
423
+    return x265_qp2qScale(qp);
424
+}
425
+double RateControl::backwardMasking(Frame* curFrame, double q)
426
+{
427
+    double qp = x265_qScale2qp(q);
428
+    double fwdRefQpDelta = double(m_param->fwdRefQpDelta);
429
+    double bwdRefQpDelta = double(m_param->bwdRefQpDelta);
430
+    double bwdNonRefQpDelta = double(m_param->bwdNonRefQpDelta);
431
+
432
+    if (curFrame->m_isInsideWindow == BACKWARD_WINDOW)
433
+    {
434
+        if (bwdRefQpDelta < 0)
435
+            bwdRefQpDelta = WINDOW3_DELTA * fwdRefQpDelta;
436
+        double sliceTypeDelta = SLICE_TYPE_DELTA * bwdRefQpDelta;
437
+        if (bwdNonRefQpDelta < 0)
438
+            bwdNonRefQpDelta = bwdRefQpDelta + sliceTypeDelta;
439
+
440
+        if (curFrame->m_lowres.sliceType == X265_TYPE_P)
441
+            qp += bwdRefQpDelta - sliceTypeDelta;
442
+        else if (curFrame->m_lowres.sliceType == X265_TYPE_BREF)
443
+            qp += bwdRefQpDelta;
444
+        else if (curFrame->m_lowres.sliceType == X265_TYPE_B)
445
+            qp += bwdNonRefQpDelta;
446
+    }
447
+
448
+    return x265_qp2qScale(qp);
449
 }
450
x265_3.4.tar.gz/source/encoder/ratecontrol.h -> x265_3.5.tar.gz/source/encoder/ratecontrol.h Changed
35
 
1
@@ -47,11 +47,9 @@
2
 #define CLIP_DURATION(f) x265_clip3(MIN_FRAME_DURATION, MAX_FRAME_DURATION, f)
3
 
4
 /*Scenecut Aware QP*/
5
-#define I_SLICE_DELTA           2   /* Subtracted from base QP for the scenecut I frames*/
6
-#define SLICE_TYPE_DELTA        0.3 /* The offset decremented or incremented for P-frames or b-frames respectively*/
7
-#define WINDOW1_DELTA           0   /* The offset for the frames coming in the window-1*/
8
-#define WINDOW2_DELTA           0.3 /* The offset for the frames coming in the window-2*/
9
-#define WINDOW3_DELTA           0.6 /* The offset for the frames coming in the window-3*/
10
+#define WINDOW1_DELTA           1.0 /* The offset for the frames coming in the window-1*/
11
+#define WINDOW2_DELTA           0.7 /* The offset for the frames coming in the window-2*/
12
+#define WINDOW3_DELTA           0.4 /* The offset for the frames coming in the window-3*/
13
 
14
 struct Predictor
15
 {
16
@@ -166,6 +164,8 @@
17
     double m_avgPFrameQp;
18
     double m_bufferFillActual;
19
     double m_bufferExcess;
20
+    double m_minBufferFill;
21
+    double m_maxBufferFill;
22
     bool   m_isFirstMiniGop;
23
     Predictor m_pred[4];       /* Slice predictors to preidct bits for each Slice type - I,P,Bref and B */
24
     int64_t m_leadingNoBSatd;
25
@@ -271,7 +271,8 @@
26
     int writeRateControlFrameStats(Frame* curFrame, RateControlEntry* rce);
27
     bool   initPass2();
28
 
29
-    double scenecutAwareQp(Frame* curFrame, double q);
30
+    double forwardMasking(Frame* curFrame, double q);
31
+    double backwardMasking(Frame* curFrame, double q);
32
 
33
 protected:
34
 
35
x265_3.4.tar.gz/source/encoder/slicetype.cpp -> x265_3.5.tar.gz/source/encoder/slicetype.cpp Changed
244
 
1
@@ -1497,14 +1497,15 @@
2
         }
3
     }
4
 
5
-    if (m_lastNonB && !m_param->rc.bStatRead &&
6
+    if (m_lastNonB &&
7
         ((m_param->bFrameAdaptive && m_param->bframes) ||
8
          m_param->rc.cuTree || m_param->scenecutThreshold || m_param->bHistBasedSceneCut ||
9
          (m_param->lookaheadDepth && m_param->rc.vbvBufferSize)))
10
     {
11
-        slicetypeAnalyse(frames, false);
12
+        if(!m_param->rc.bStatRead)
13
+            slicetypeAnalyse(frames, false);
14
         bool bIsVbv = m_param->rc.vbvBufferSize > 0 && m_param->rc.vbvMaxBitrate > 0;
15
-        if (m_param->analysisLoad && m_param->scaleFactor && bIsVbv)
16
+        if ((m_param->analysisLoad && m_param->scaleFactor && bIsVbv) || m_param->bliveVBV2pass)
17
         {
18
             int numFrames;
19
             for (numFrames = 0; numFrames < maxSearch; numFrames++)
20
@@ -1513,13 +1514,14 @@
21
                 if (!fenc)
22
                     break;
23
             }
24
-            vbvLookahead(frames, numFrames, true);
25
+            vbvLookahead(frames, numFrames, false);
26
         }
27
     }
28
 
29
     int bframes, brefs;
30
     if (!m_param->analysisLoad || m_param->bAnalysisType == HEVC_INFO)
31
     {
32
+        bool isClosedGopRadl = m_param->radl && (m_param->keyframeMax != m_param->keyframeMin);
33
         for (bframes = 0, brefs = 0;; bframes++)
34
         {
35
             Lowres& frm = list[bframes]->m_lowres;
36
@@ -1579,6 +1581,15 @@
37
                 else
38
                     frm.sliceType = X265_TYPE_IDR;
39
             }
40
+            if (frm.sliceType == X265_TYPE_IDR && frm.bScenecut && isClosedGopRadl)
41
+            {
42
+                if (!m_param->bHistBasedSceneCut || (m_param->bHistBasedSceneCut && frm.m_bIsHardScenecut))
43
+                {
44
+                    for (int i = bframes; i < bframes + m_param->radl; i++)
45
+                        list[i]->m_lowres.sliceType = X265_TYPE_B;
46
+                    list[(bframes + m_param->radl)]->m_lowres.sliceType = X265_TYPE_IDR;
47
+                }
48
+            }
49
             if (frm.sliceType == X265_TYPE_IDR)
50
             {
51
                 /* Closed GOP */
52
@@ -1739,7 +1750,7 @@
53
         }
54
     }
55
 
56
-    bool isKeyFrameAnalyse = (m_param->rc.cuTree || (m_param->rc.vbvBufferSize && m_param->lookaheadDepth)) && !m_param->rc.bStatRead;
57
+    bool isKeyFrameAnalyse = (m_param->rc.cuTree || (m_param->rc.vbvBufferSize && m_param->lookaheadDepth));
58
     if (isKeyFrameAnalyse && IS_X265_TYPE_I(m_lastNonB->sliceType))
59
     {
60
         m_inputLock.acquire();
61
@@ -1754,9 +1765,10 @@
62
         m_inputLock.release();
63
 
64
         frames[j + 1] = NULL;
65
-        slicetypeAnalyse(frames, true);
66
+        if (!m_param->rc.bStatRead)
67
+            slicetypeAnalyse(frames, true);
68
         bool bIsVbv = m_param->rc.vbvBufferSize > 0 && m_param->rc.vbvMaxBitrate > 0;
69
-        if (m_param->analysisLoad && m_param->scaleFactor && bIsVbv)
70
+        if ((m_param->analysisLoad && m_param->scaleFactor && bIsVbv) || m_param->bliveVBV2pass)
71
         {
72
             int numFrames;
73
             for (numFrames = 0; numFrames < maxSearch; numFrames++)
74
@@ -1774,7 +1786,7 @@
75
 void Lookahead::vbvLookahead(Lowres **frames, int numFrames, int keyframe)
76
 {
77
     int prevNonB = 0, curNonB = 1, idx = 0;
78
-    while (curNonB < numFrames && frames[curNonB]->sliceType == X265_TYPE_B)
79
+    while (curNonB < numFrames && IS_X265_TYPE_B(frames[curNonB]->sliceType))
80
         curNonB++;
81
     int nextNonB = keyframe ? prevNonB : curNonB;
82
     int nextB = prevNonB + 1;
83
@@ -1841,7 +1853,7 @@
84
         }
85
         prevNonB = curNonB;
86
         curNonB++;
87
-        while (curNonB <= numFrames && frames[curNonB]->sliceType == X265_TYPE_B)
88
+        while (curNonB <= numFrames && IS_X265_TYPE_B(frames[curNonB]->sliceType))
89
             curNonB++;
90
     }
91
 
92
@@ -2001,10 +2013,41 @@
93
     int numAnalyzed = numFrames;
94
     bool isScenecut = false;
95
 
96
-    /* When scenecut threshold is set, use scenecut detection for I frame placements */
97
+    /* Temporal computations for scenecut detection */
98
     if (m_param->bHistBasedSceneCut)
99
-        isScenecut = frames[1]->bScenecut;
100
-    else
101
+    {
102
+        for (int i = numFrames - 1; i > 0; i--)
103
+        {
104
+            if (frames[i]->interPCostPercDiff > 0.0)
105
+                continue;
106
+            int64_t interCost = frames[i]->costEst[1][0];
107
+            int64_t intraCost = frames[i]->costEst[0][0];
108
+            if (interCost < 0 || intraCost < 0)
109
+                continue;
110
+            int times = 0;
111
+            double averagePcost = 0.0, averageIcost = 0.0;
112
+            for (int j = i - 1; j >= 0 && times < 5; j--, times++)
113
+            {
114
+                if (frames[j]->costEst[0][0] > 0 && frames[j]->costEst[1][0] > 0)
115
+                {
116
+                    averageIcost += frames[j]->costEst[0][0];
117
+                    averagePcost += frames[j]->costEst[1][0];
118
+                }
119
+                else
120
+                    times--;
121
+            }
122
+            if (times)
123
+            {
124
+                averageIcost = averageIcost / times;
125
+                averagePcost = averagePcost / times;
126
+                frames[i]->interPCostPercDiff = abs(interCost - averagePcost) / X265_MIN(interCost, averagePcost) * 100;
127
+                frames[i]->intraCostPercDiff = abs(intraCost - averageIcost) / X265_MIN(intraCost, averageIcost) * 100;
128
+            }
129
+        }
130
+    }
131
+
132
+    /* When scenecut threshold is set, use scenecut detection for I frame placements */
133
+    if (!m_param->bHistBasedSceneCut || (m_param->bHistBasedSceneCut && frames[1]->bScenecut))
134
         isScenecut = scenecut(frames, 0, 1, true, origNumFrames);
135
 
136
     if (isScenecut && (m_param->bHistBasedSceneCut || m_param->scenecutThreshold))
137
@@ -2018,17 +2061,16 @@
138
         m_extendGopBoundary = false;
139
         for (int i = m_param->bframes + 1; i < origNumFrames; i += m_param->bframes + 1)
140
         {
141
-            if (!m_param->bHistBasedSceneCut)
142
+            if (!m_param->bHistBasedSceneCut || (m_param->bHistBasedSceneCut && frames[i + 1]->bScenecut))
143
                 scenecut(frames, i, i + 1, true, origNumFrames);
144
 
145
             for (int j = i + 1; j <= X265_MIN(i + m_param->bframes + 1, origNumFrames); j++)
146
             {
147
-                if ((!m_param->bHistBasedSceneCut && frames[j]->bScenecut && scenecutInternal(frames, j - 1, j, true)) || 
148
-                    (m_param->bHistBasedSceneCut && frames[j]->bScenecut))
149
-                    {
150
-                        m_extendGopBoundary = true;
151
-                        break;
152
-                    }
153
+                if (frames[j]->bScenecut && scenecutInternal(frames, j - 1, j, true))
154
+                {
155
+                    m_extendGopBoundary = true;
156
+                    break;
157
+                }
158
             }
159
             if (m_extendGopBoundary)
160
                 break;
161
@@ -2117,7 +2159,7 @@
162
         }
163
 
164
         int zoneRadl = m_param->rc.zonefileCount && m_param->bResetZoneConfig ? m_param->rc.zones->zoneParam->radl : 0;
165
-        bool bForceRADL = (m_param->radl || zoneRadl) && !m_param->bOpenGOP;
166
+        bool bForceRADL = zoneRadl || (m_param->radl && (m_param->keyframeMax == m_param->keyframeMin));
167
         bool bLastMiniGop = (framecnt >= m_param->bframes + 1) ? false : true;
168
         int radl = m_param->radl ? m_param->radl : zoneRadl;
169
         int preRADL = m_lastKeyframe + m_param->keyframeMax - radl - 1; /*Frame preceeding RADL in POC order*/
170
@@ -2133,14 +2175,15 @@
171
         {
172
             for (int j = 1; j < numBFrames + 1; j++)
173
             {
174
-                if ((!m_param->bHistBasedSceneCut && scenecut(frames, j, j + 1, false, origNumFrames)) ||
175
-                    (m_param->bHistBasedSceneCut && frames[j + 1]->bScenecut) ||
176
-                    (bForceRADL && (frames[j]->frameNum == preRADL)))
177
-                    {
178
-                        frames[j]->sliceType = X265_TYPE_P;
179
-                        numAnalyzed = j;
180
-                        break;
181
-                    }
182
+                bool isNextScenecut = false;
183
+                if (!m_param->bHistBasedSceneCut || (m_param->bHistBasedSceneCut && frames[j + 1]->bScenecut))
184
+                    isNextScenecut = scenecut(frames, j, j + 1, false, origNumFrames);
185
+                if (isNextScenecut || (bForceRADL && frames[j]->frameNum == preRADL))
186
+                {
187
+                    frames[j]->sliceType = X265_TYPE_P;
188
+                    numAnalyzed = j;
189
+                    break;
190
+                }
191
             }
192
         }
193
         resetStart = bKeyframe ? 1 : X265_MIN(numBFrames + 2, numAnalyzed + 1);
194
@@ -2203,7 +2246,7 @@
195
          * and not considered a scenecut. */
196
         for (int cp1 = p1; cp1 <= maxp1; cp1++)
197
         {
198
-            if (!scenecutInternal(frames, p0, cp1, false))
199
+            if (!scenecutInternal(frames, p0, cp1, false) && !m_param->bHistBasedSceneCut)
200
             {
201
                 /* Any frame in between p0 and cur_p1 cannot be a real scenecut. */
202
                 for (int i = cp1; i > p0; i--)
203
@@ -2212,7 +2255,7 @@
204
                     noScenecuts = false;
205
                 }
206
             }
207
-            else if (scenecutInternal(frames, cp1 - 1, cp1, false))
208
+            else if ((m_param->bHistBasedSceneCut && frames[cp1]->m_bIsMaxThres) || scenecutInternal(frames, cp1 - 1, cp1, false))
209
             {
210
                 /* If current frame is a Scenecut from p0 frame as well as Scenecut from
211
                  * preceeding frame, mark it as a Scenecut */
212
@@ -2273,6 +2316,10 @@
213
 
214
     if (!frames[p1]->bScenecut)
215
         return false;
216
+    /* Check only scene transitions if max threshold */
217
+    if (m_param->bHistBasedSceneCut && frames[p1]->m_bIsMaxThres)
218
+        return frames[p1]->bScenecut;
219
+
220
     return scenecutInternal(frames, p0, p1, bRealScenecut);
221
 }
222
 
223
@@ -2289,7 +2336,19 @@
224
     /* magic numbers pulled out of thin air */
225
     float threshMin = (float)(threshMax * 0.25);
226
     double bias = m_param->scenecutBias;
227
-    if (bRealScenecut)
228
+    if (m_param->bHistBasedSceneCut)
229
+    {
230
+        double minT = TEMPORAL_SCENECUT_THRESHOLD * (1 + m_param->edgeTransitionThreshold);
231
+        if (frame->interPCostPercDiff > minT || frame->intraCostPercDiff > minT)
232
+        {
233
+            if (bRealScenecut && frame->bScenecut)
234
+                x265_log(m_param, X265_LOG_DEBUG, "scene cut at %d \n", frame->frameNum);
235
+            return frame->bScenecut;
236
+        }
237
+        else
238
+            return false;
239
+    }
240
+    else if (bRealScenecut)
241
     {
242
         if (m_param->keyframeMin == m_param->keyframeMax)
243
             threshMin = threshMax;
244
x265_3.4.tar.gz/source/encoder/slicetype.h -> x265_3.5.tar.gz/source/encoder/slicetype.h Changed
9
 
1
@@ -42,6 +42,7 @@
2
 #define LOWRES_COST_SHIFT 14
3
 #define AQ_EDGE_BIAS 0.5
4
 #define EDGE_INCLINATION 45
5
+#define TEMPORAL_SCENECUT_THRESHOLD 50
6
 
7
 #if HIGH_BIT_DEPTH
8
 #define EDGE_THRESHOLD 1023.0
9
x265_3.5.tar.gz/source/input Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/output Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/profile Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/profile/PPA Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/profile/vtune Added
2
 
1
+(directory)
2
x265_3.5.tar.gz/source/test Added
2
 
1
+(directory)
2
x265_3.4.tar.gz/source/test/rate-control-tests.txt -> x265_3.5.tar.gz/source/test/rate-control-tests.txt Changed
11
 
1
@@ -44,6 +44,9 @@
2
 RaceHorses_416x240_30_10bit.yuv,--preset medium --crf 26 --vbv-maxrate 1000 --vbv-bufsize 1000 --pass 1::--preset fast --bitrate 1000  --vbv-maxrate 1000 --vbv-bufsize 700 --pass 3 -F4::--preset slow --bitrate 500 --vbv-maxrate 500  --vbv-bufsize 700 --pass 2 -F4
3
 sita_1920x1080_30.yuv, --preset ultrafast --crf 20 --no-cutree --keyint 50 --min-keyint 50 --no-open-gop --pass 1 --vbv-bufsize 7000 --vbv-maxrate 5000:: --preset ultrafast --crf 20 --no-cutree --keyint 50 --min-keyint 50 --no-open-gop --pass 2 --vbv-bufsize 7000 --vbv-maxrate 5000 --repeat-headers
4
 sita_1920x1080_30.yuv, --preset medium --crf 20 --no-cutree --keyint 50 --min-keyint 50 --no-open-gop --pass 1 --vbv-bufsize 7000 --vbv-maxrate 5000 --repeat-headers --multi-pass-opt-rps:: --preset medium --crf 20 --no-cutree --keyint 50 --min-keyint 50 --no-open-gop --pass 2 --vbv-bufsize 7000 --vbv-maxrate 5000 --repeat-headers --multi-pass-opt-rps
5
+sintel_trailer_2k_1920x1080_24.yuv,--preset medium --bitrate 6000 --no-cutree --aq-mode 0 --pass 1::--preset medium --bitrate 6000 --no-cutree --aq-mode 0 --pass 2 --scenecut-aware-qp 1
6
+sintel_trailer_2k_1920x1080_24.yuv,--preset medium --bitrate 6000 --no-cutree --aq-mode 0 --hist-scenecut --pass 1::--preset medium --bitrate 6000 --no-cutree --aq-mode 0 --hist-scenecut --pass 2 --scenecut-aware-qp 3 --masking-strength 300,-1,7,100,2,3
7
+sintel_trailer_2k_1920x1080_24.yuv,--preset medium --bitrate 6000 --no-cutree --aq-mode 0 --pass 1::--preset medium --bitrate 6000 --no-cutree --aq-mode 0 --pass 2 --scenecut-aware-qp 2 --masking-strength 100,-1,-1
8
 
9
 # multi-pass rate control and analysis
10
 ducks_take_off_1080p50.y4m,--bitrate 6000 --pass 1  --multi-pass-opt-analysis  --hash 1 --ssim --psnr:: --bitrate 6000 --pass 2  --multi-pass-opt-analysis  --hash 1 --ssim --psnr
11
x265_3.4.tar.gz/source/test/regression-tests.txt -> x265_3.5.tar.gz/source/test/regression-tests.txt Changed
9
 
1
@@ -158,7 +158,6 @@
2
 ducks_take_off_420_1_720p50.y4m,--preset medium --selective-sao 4 --sao --crf 20
3
 Traffic_4096x2048_30p.y4m, --preset medium --frame-dup --dup-threshold 60 --hrd --bitrate 10000 --vbv-bufsize 15000 --vbv-maxrate 12000
4
 Kimono1_1920x1080_24_400.yuv,--preset superfast --qp 28 --zones 0,139,q=32
5
-Island_960x540_24.yuv,--no-cutree --aq-mode 0 --bitrate 6000 --scenecut-aware-qp
6
 sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut --hist-threshold 0.02 --frame-dup --dup-threshold 60 --hrd --bitrate 10000 --vbv-bufsize 15000 --vbv-maxrate 12000
7
 sintel_trailer_2k_1920x1080_24.yuv, --preset medium --hist-scenecut --hist-threshold 0.02
8
 sintel_trailer_2k_1920x1080_24.yuv, --preset ultrafast --hist-scenecut --hist-threshold 0.02
9
x265_3.4.tar.gz/source/x265.cpp -> x265_3.5.tar.gz/source/x265.cpp Changed
13
 
1
@@ -46,9 +46,11 @@
2
 using namespace X265_NS;
3
 
4
 #define X265_HEAD_ENTRIES 3
5
+#define CONSOLE_TITLE_SIZE 200
6
 
7
 #ifdef _WIN32
8
 #define strdup _strdup
9
+static char orgConsoleTitle[CONSOLE_TITLE_SIZE] = "";
10
 #endif
11
 
12
 #ifdef _WIN32
13
x265_3.4.tar.gz/source/x265.h -> x265_3.5.tar.gz/source/x265.h Changed
102
 
1
@@ -204,6 +204,9 @@
2
 }x265_analysis_distortion_data;
3
 
4
 #define MAX_NUM_REF 16
5
+#define EDGE_BINS 2
6
+#define MAX_HIST_BINS 1024
7
+
8
 /* Stores all analysis data for a single frame */
9
 typedef struct x265_analysis_data
10
 {
11
@@ -214,6 +217,8 @@
12
     uint32_t                          numCUsInFrame;
13
     uint32_t                          numPartitions;
14
     uint32_t                          depthBytes;
15
+    int32_t                           edgeHist[EDGE_BINS];
16
+    int32_t                           yuvHist[3][MAX_HIST_BINS];
17
     int                               bScenecut;
18
     x265_weight_param*                wt;
19
     x265_analysis_inter_data*         interData;
20
@@ -602,6 +607,13 @@
21
 #define X265_ANALYSIS_SAVE 1
22
 #define X265_ANALYSIS_LOAD 2
23
 
24
+#define FORWARD                 1
25
+#define BACKWARD                2
26
+#define BI_DIRECTIONAL          3
27
+#define SLICE_TYPE_DELTA        0.3 /* The offset decremented or incremented for P-frames or b-frames respectively*/
28
+#define BACKWARD_WINDOW         1 /* Scenecut window before a scenecut */
29
+#define FORWARD_WINDOW          2 /* Scenecut window after a scenecut */
30
+
31
 typedef struct x265_cli_csp
32
 {
33
     int planes;
34
@@ -1838,24 +1850,29 @@
35
       Default 1 (Enabled). API only. */
36
     int       bResetZoneConfig;
37
 
38
-    /* Enables a ratecontrol algorithm for reducing the bits spent on the inter-frames
39
-     * within the scenecutWindow after a scenecut by increasing their QP without
40
-     * any deterioration in visual quality. It also increases the quality of scenecut I-Frames by reducing their QP.
41
-     * Default is disabled. */
42
+    /* It reduces the bits spent on the inter-frames within the scenecutWindow before and / or after a scenecut
43
+     * by increasing their QP in ratecontrol pass2 algorithm without any deterioration in visual quality.
44
+     * 0 - Disabled (default).
45
+     * 1 - Forward masking.
46
+     * 2 - Backward masking.
47
+     * 3 - Bi-directional masking. */
48
     int       bEnableSceneCutAwareQp;
49
 
50
     /* The duration(in milliseconds) for which there is a reduction in the bits spent on the inter-frames after a scenecut
51
-     * by increasing their QP, when bEnableSceneCutAwareQp is set. Default is 500ms.*/
52
-    int       scenecutWindow;
53
+     * by increasing their QP, when bEnableSceneCutAwareQp is 1 or 3. Default is 500ms.*/
54
+    int       fwdScenecutWindow;
55
 
56
-    /* The offset by which QP is incremented for inter-frames when bEnableSceneCutAwareQp is set.
57
+    /* The offset by which QP is incremented for inter-frames after a scenecut when bEnableSceneCutAwareQp is 1 or 3.
58
      * Default is +5. */
59
-    int       maxQpDelta;
60
+    double    fwdRefQpDelta;
61
+
62
+    /* The offset by which QP is incremented for non-referenced inter-frames after a scenecut when bEnableSceneCutAwareQp is 1 or 3. */
63
+    double    fwdNonRefQpDelta;
64
 
65
     /* A genuine threshold used for histogram based scene cut detection.
66
      * This threshold determines whether a frame is a scenecut or not
67
      * when compared against the edge and chroma histogram sad values.
68
-     * Default 0.01. Range: Real number in the interval (0,2). */
69
+     * Default 0.03. Range: Real number in the interval (0,1). */
70
     double    edgeTransitionThreshold;
71
 
72
     /* Enables histogram based scenecut detection algorithm to detect scenecuts. Default disabled */
73
@@ -1909,6 +1926,28 @@
74
 
75
     /* Maxrate that could be signaled to the decoder. Default 0. API only. */
76
     int      decoderVbvMaxRate;
77
+
78
+    /*Enables Qp tuning with respect to real time VBV buffer fullness in rate
79
+    control 2 pass. Experimental.Default is disabled*/
80
+    int      bliveVBV2pass;
81
+
82
+    /* Minimum VBV fullness to be maintained. Default 50. Keep the buffer
83
+     * at least 50% full */
84
+    double   minVbvFullness;
85
+
86
+    /* Maximum VBV fullness to be maintained. Default 80. Keep the buffer
87
+    * at max 80% full */
88
+    double   maxVbvFullness;
89
+
90
+    /* The duration(in milliseconds) for which there is a reduction in the bits spent on the inter-frames before a scenecut
91
+     * by increasing their QP, when bEnableSceneCutAwareQp is 2 or 3. Default is 100ms.*/
92
+    int       bwdScenecutWindow;
93
+
94
+    /* The offset by which QP is incremented for inter-frames before a scenecut when bEnableSceneCutAwareQp is 2 or 3. */
95
+    double    bwdRefQpDelta;
96
+
97
+    /* The offset by which QP is incremented for non-referenced inter-frames before a scenecut when bEnableSceneCutAwareQp is 2 or 3. */
98
+    double    bwdNonRefQpDelta;
99
 } x265_param;
100
 
101
 /* x265_param_alloc:
102
x265_3.4.tar.gz/source/x265cli.cpp -> x265_3.5.tar.gz/source/x265cli.cpp Changed
72
 
1
@@ -127,9 +127,8 @@
2
         H0("   --[no-]ssim-rd                Enable ssim rate distortion optimization, 0 to disable. Default %s\n", OPT(param->bSsimRd));
3
         H0("   --[no-]rd-refine              Enable QP based RD refinement for rd levels 5 and 6. Default %s\n", OPT(param->bEnableRdRefine));
4
         H0("   --[no-]early-skip             Enable early SKIP detection. Default %s\n", OPT(param->bEnableEarlySkip));
5
-        H0("   --rskip <mode>                Set mode for early exit from recursion. Mode 1: exit using rdcost & CU homogenity. Mode 2: exit using CU edge density.\n"
6
-            "                                 Mode 0: disabled. Default %d\n", param->recursionSkipMode);
7
-        H1("   --rskip-edge-threshold        Threshold in terms of percentage (integer of range [0,100]) for minimum edge density in CUs used to prun the recursion depth. Applicable only for rskip mode 2. Value is preset dependent. Default: %.f\n", param->edgeVarThreshold*100.0f);
8
+        H0("   --rskip <Integer>             Enable recursion skip for early exit from CTU analysis during inter prediction. 1: exit using RD cost & CU homogeneity. 2: exit using CU edge density. 0: disabled. Default %d\n", param->recursionSkipMode);
9
+        H1("   --rskip-edge-threshold        Threshold in terms of percentage (an integer of range [0,100]) for minimum edge density in CU's used to prune the recursion depth. Applicable only to rskip mode 2. Value is preset dependent. Default: %.f\n", param->edgeVarThreshold*100.0f);
10
         H1("   --[no-]tskip-fast             Enable fast intra transform skipping. Default %s\n", OPT(param->bEnableTSkipFast));
11
         H1("   --[no-]splitrd-skip           Enable skipping split RD analysis when sum of split CU rdCost larger than one split CU rdCost for Intra CU. Default %s\n", OPT(param->bEnableSplitRdSkip));
12
         H1("   --nr-intra <integer>          An integer value in range of 0 to 2000, which denotes strength of noise reduction in intra CUs. Default 0\n");
13
@@ -175,11 +174,14 @@
14
         H1("   --scenecut-bias <0..100.0>    Bias for scenecut detection. Default %.2f\n", param->scenecutBias);
15
         H0("   --hist-scenecut               Enables histogram based scene-cut detection using histogram based algorithm.\n");
16
         H0("   --no-hist-scenecut            Disables histogram based scene-cut detection using histogram based algorithm.\n");
17
-        H1("   --hist-threshold <0.0..2.0>   Luma Edge histogram's Normalized SAD threshold for histogram based scenecut detection Default %.2f\n", param->edgeTransitionThreshold);
18
+        H1("   --hist-threshold <0.0..1.0>   Luma Edge histogram's Normalized SAD threshold for histogram based scenecut detection Default %.2f\n", param->edgeTransitionThreshold);
19
         H0("   --[no-]fades                  Enable detection and handling of fade-in regions. Default %s\n", OPT(param->bEnableFades));
20
-        H1("   --[no-]scenecut-aware-qp      Enable increasing QP for frames inside the scenecut window after scenecut. Default %s\n", OPT(param->bEnableSceneCutAwareQp));
21
-        H1("   --scenecut-window <0..1000>   QP incremental duration(in milliseconds) when scenecut-aware-qp is enabled. Default %d\n", param->scenecutWindow);
22
-        H1("   --max-qp-delta <0..10>        QP offset to increment with base QP for inter-frames. Default %d\n", param->maxQpDelta);
23
+        H1("   --scenecut-aware-qp <0..3>    Enable increasing QP for frames inside the scenecut window around scenecut. Default %s\n", OPT(param->bEnableSceneCutAwareQp));
24
+        H1("                                 0 - Disabled\n");
25
+        H1("                                 1 - Forward masking\n");
26
+        H1("                                 2 - Backward masking\n");
27
+        H1("                                 3 - Bidirectional masking\n");
28
+        H1("   --masking-strength <string>   Comma separated values which specify the duration and offset for the QP increment for inter-frames when scenecut-aware-qp is enabled.\n");
29
         H0("   --radl <integer>              Number of RADL pictures allowed in front of IDR. Default %d\n", param->radl);
30
         H0("   --intra-refresh               Use Periodic Intra Refresh instead of IDR frames\n");
31
         H0("   --rc-lookahead <integer>      Number of frames for frame-type lookahead (determines encoder latency) Default %d\n", param->lookaheadDepth);
32
@@ -211,6 +213,8 @@
33
         H0("   --vbv-bufsize <integer>       Set size of the VBV buffer (kbit). Default %d\n", param->rc.vbvBufferSize);
34
         H0("   --vbv-init <float>            Initial VBV buffer occupancy (fraction of bufsize or in kbits). Default %.2f\n", param->rc.vbvBufferInit);
35
         H0("   --vbv-end <float>             Final VBV buffer emptiness (fraction of bufsize or in kbits). Default 0 (disabled)\n");
36
+        H0("   --min-vbv-fullness <double>   Minimum VBV fullness percentage to be maintained. Default %.2f\n", param->minVbvFullness);
37
+        H0("   --max-vbv-fullness <double>   Maximum VBV fullness percentage to be maintained. Default %.2f\n", param->maxVbvFullness);
38
         H0("   --vbv-end-fr-adj <float>      Frame from which qp has to be adjusted to achieve final decode buffer emptiness. Default 0\n");
39
         H0("   --chunk-start <integer>       First frame of the chunk. Default 0 (disabled)\n");
40
         H0("   --chunk-end <integer>         Last frame of the chunk. Default 0 (disabled)\n");
41
@@ -220,6 +224,7 @@
42
             "                                   - 3 : Nth pass, overwrites stats file\n");
43
         H0("   --[no-]multi-pass-opt-analysis   Refine analysis in 2 pass based on analysis information from pass 1\n");
44
         H0("   --[no-]multi-pass-opt-distortion Use distortion of CTU from pass 1 to refine qp in 2 pass\n");
45
+        H0("   --[no-]vbv-live-multi-pass    Enable realtime VBV in rate control 2 pass.Default %s\n", OPT(param->bliveVBV2pass));
46
         H0("   --stats                       Filename for stats file in multipass pass rate control. Default x265_2pass.log\n");
47
         H0("   --[no-]analyze-src-pics       Motion estimation uses source frame planes. Default disable\n");
48
         H0("   --[no-]slow-firstpass         Enable a slow first pass in a multipass rate control mode. Default %s\n", OPT(param->rc.bEnableSlowFirstPass));
49
@@ -295,16 +300,16 @@
50
         H0("                                 5=40:33, 6=24:11, 7=20:11, 8=32:11, 9=80:33, 10=18:11, 11=15:11,\n");
51
         H0("                                 12=64:33, 13=160:99, 14=4:3, 15=3:2, 16=2:1 or custom ratio of <int:int>. Default %d\n", param->vui.aspectRatioIdc);
52
         H1("   --display-window <string>     Describe overscan cropping region as 'left,top,right,bottom' in pixels\n");
53
-        H1("   --overscan <string>           Specify whether it is appropriate for decoder to show cropped region: undef, show or crop. Default undef\n");
54
-        H0("   --videoformat <string>        Specify video format from undef, component, pal, ntsc, secam, mac. Default undef\n");
55
+        H1("   --overscan <string>           Specify whether it is appropriate for decoder to show cropped region: unknown, show or crop. Default unknown\n");
56
+        H0("   --videoformat <string>        Specify video format from unknown, component, pal, ntsc, secam, mac. Default unknown\n");
57
         H0("   --range <string>              Specify black level and range of luma and chroma signals as full or limited Default limited\n");
58
         H0("   --colorprim <string>          Specify color primaries from  bt709, unknown, reserved, bt470m, bt470bg, smpte170m,\n");
59
-        H0("                                 smpte240m, film, bt2020, smpte428, smpte431, smpte432. Default undef\n");
60
+        H0("                                 smpte240m, film, bt2020, smpte428, smpte431, smpte432. Default unknown\n");
61
         H0("   --transfer <string>           Specify transfer characteristics from bt709, unknown, reserved, bt470m, bt470bg, smpte170m,\n");
62
         H0("                                 smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1,\n");
63
-        H0("                                 bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67. Default undef\n");
64
-        H1("   --colormatrix <string>        Specify color matrix setting from undef, bt709, fcc, bt470bg, smpte170m,\n");
65
-        H1("                                 smpte240m, GBR, YCgCo, bt2020nc, bt2020c, smpte2085, chroma-derived-nc, chroma-derived-c, ictcp. Default undef\n");
66
+        H0("                                 bt2020-10, bt2020-12, smpte2084, smpte428, arib-std-b67. Default unknown\n");
67
+        H1("   --colormatrix <string>        Specify color matrix setting from unknown, bt709, fcc, bt470bg, smpte170m,\n");
68
+        H1("                                 smpte240m, gbr, ycgco, bt2020nc, bt2020c, smpte2085, chroma-derived-nc, chroma-derived-c, ictcp. Default unknown\n");
69
         H1("   --chromaloc <integer>         Specify chroma sample location (0 to 5). Default of %d\n", param->vui.chromaSampleLocTypeTopField);
70
         H0("   --master-display <string>     SMPTE ST 2086 master display color volume info SEI (HDR)\n");
71
         H0("                                    format: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");
72
x265_3.4.tar.gz/source/x265cli.h -> x265_3.5.tar.gz/source/x265cli.h Changed
44
 
1
@@ -33,11 +33,9 @@
2
 
3
 #include <getopt.h>
4
 
5
-#define CONSOLE_TITLE_SIZE 200
6
 #ifdef _WIN32
7
 #include <windows.h>
8
 #define SetThreadExecutionState(es)
9
-static char orgConsoleTitle[CONSOLE_TITLE_SIZE] = "";
10
 #else
11
 #define GetConsoleTitle(t, n)
12
 #define SetConsoleTitle(t)
13
@@ -148,10 +146,8 @@
14
     { "hist-threshold", required_argument, NULL, 0},
15
     { "fades",                no_argument, NULL, 0 },
16
     { "no-fades",             no_argument, NULL, 0 },
17
-    { "scenecut-aware-qp",    no_argument, NULL, 0 },
18
-    { "no-scenecut-aware-qp", no_argument, NULL, 0 },
19
-    { "scenecut-window",required_argument, NULL, 0 },
20
-    { "max-qp-delta",   required_argument, NULL, 0 },
21
+    { "scenecut-aware-qp", required_argument, NULL, 0 },
22
+    { "masking-strength",  required_argument, NULL, 0 },
23
     { "radl",           required_argument, NULL, 0 },
24
     { "ctu-info",       required_argument, NULL, 0 },
25
     { "intra-refresh",        no_argument, NULL, 0 },
26
@@ -283,6 +279,8 @@
27
     { "no-multi-pass-opt-analysis",    no_argument, NULL, 0 },
28
     { "multi-pass-opt-distortion",     no_argument, NULL, 0 },
29
     { "no-multi-pass-opt-distortion",  no_argument, NULL, 0 },
30
+    { "vbv-live-multi-pass",           no_argument, NULL, 0 },
31
+    { "no-vbv-live-multi-pass",        no_argument, NULL, 0 },
32
     { "slow-firstpass",       no_argument, NULL, 0 },
33
     { "no-slow-firstpass",    no_argument, NULL, 0 },
34
     { "multi-pass-opt-rps",   no_argument, NULL, 0 },
35
@@ -373,6 +371,8 @@
36
     { "no-cll", no_argument, NULL, 0 },
37
     { "hme-range", required_argument, NULL, 0 },
38
     { "abr-ladder", required_argument, NULL, 0 },
39
+    { "min-vbv-fullness", required_argument, NULL, 0 },
40
+    { "max-vbv-fullness", required_argument, NULL, 0 },
41
     { 0, 0, 0, 0 },
42
     { 0, 0, 0, 0 },
43
     { 0, 0, 0, 0 },
44
x265_3.5.tar.gz/x265Version.txt Added
6
 
1
@@ -0,0 +1,4 @@
2
+#Attribute:         Values
3
+repositorychangeset: f0c1022b6
4
+releasetagdistance: 1
5
+releasetag: 3.5
6
Refresh
Refresh


Request History
Olaf Hering's avatar

olh created request almost 4 years ago

- Update to version 3.5
New features:
* Real-time VBV for ABR (Average BitRate) encodes in –pass 2
using --vbv-live-multi-pass. Improves VBV compliance with no
significant impact on coding efficiency.
Enhancements to existing features:
* Improved hist-based scene cut algorithm: Reduces false
positives by leveraging motion and scene transition info.
* Support for RADL pictures at IDR scene cuts: Improves coding
efficiency with no significant impact on performance.
* Bidirectional scene cut aware Frame Quantizer Selection:
Saves bits than forward masking with no noticeable perceptual
quality difference.
API changes:
* Additions to x265_param structure to support the newly added
features and encoder enhancements.
* New x265_param options --min-vbv-fullness and
--max-vbv-fullness to control min and max VBV fullness.
Bug fixes:
* Incorrect VBV lookahead in --analysis-load + --scale-factor.
* Encoder hang when VBV is used with slices.
* QP spikes in the row-level VBV rate-control when WPP enabled.
* Encoder crash in --abr-ladder.
- Use new homepage and download URLs.
- Add subpackage for HDR10+ library
- Add update.sh


Olaf Hering's avatar

olh accepted request almost 4 years ago