Overview
x265.changes
Changed
x
1
2
-------------------------------------------------------------------
3
+Thu Jul 18 13:17:22 UTC 2019 - enzokiel@kabelmail.de
4
+
5
+- Update to version 3.1.1
6
+ - No changelog available.
7
+
8
+- Version 3.1
9
+ New features
10
+ * x265 can invoke SVT-HEVC library for encoding through --svt.
11
+ * x265 can now accept interlaced inputs directly (no need to
12
+ separate fields), and sends it to the encoder with proper fps
13
+ and frame-size through --field.
14
+ * --fades can detect and handle fade-in regions. This option will
15
+ force I-slice and initialize RC history for the brightest frame
16
+ after fade-in.
17
+ API changes
18
+ * A new flag to signal MasterDisplayParams and maxCll/Fall
19
+ separately
20
+ Encoder enhancements
21
+ * Improved the performance of inter-refine level 1 by skipping
22
+ the evaluation of smaller CUs when the current block is decided
23
+ as “skip” by the save mode.
24
+ * New AVX2 primitives to improve the performance of encodes that
25
+ enable --ssim-rd.
26
+ * Improved performance in medium preset with negligible loss in
27
+ quality.
28
+ Bug fixes
29
+ * Bug fixes for zones.
30
+ * Fixed wrap-around from MV structure overflow occurred around 8K
31
+ pixels or over.
32
+ * Fixed issues in configuring cbQpOffset and crQpOffset for 444
33
+ input
34
+ * Fixed cutree offset computation in 2nd pass encodes.
35
+ Known issues
36
+ * AVX512 main12 asm disabling.
37
+ * Inconsistent output with 2-pass due to cutree offset sharing.
38
+
39
+-------------------------------------------------------------------
40
Fri Feb 1 00:32:50 UTC 2019 - antonio.larrosa@gmail.com
41
42
- Support 10 and 12 bit color depths
43
x265.spec
Changed
14
1
2
# based on the spec file from https://build.opensuse.org/package/view_file/home:Simmphonie/libx265/
3
4
Name: x265
5
-%define soname 169
6
+%define soname 176
7
%define libname lib%{name}
8
%define libsoname %{libname}-%{soname}
9
-Version: 3.0
10
+Version: 3.1.1
11
Release: 0
12
License: GPL-2.0+
13
Summary: A free h265/HEVC encoder - encoder binary
14
baselibs.conf
Changed
4
1
2
-libx265-169
3
+libx265-176
4
x265_3.0.tar.gz/.hg_archival.txt -> x265_3.1.1.tar.gz/.hg_archival.txt
Changed
10
1
2
repo: 09fe40627f03a0f9c3e6ac78b22ac93da23f9fdf
3
-node: 72188bd2f03447e71e789a5fd2f10364bb232c2c
4
-branch: stable
5
-tag: 3.0
6
+node: 04b37fdfd2dcde24da4d47ced91dddc10ffe0cbf
7
+branch: Release_3.1
8
+latesttag: 3.1.1
9
+latesttagdistance: 1
10
x265_3.0.tar.gz/.hgtags -> x265_3.1.1.tar.gz/.hgtags
Changed
10
1
2
bad4e598cac7cdd3df4623c68c91299c620471bd 3.0-rc
3
0000000000000000000000000000000000000000 3.0-rc
4
1307fd7b2b9984f45179db01432305a416713049 3.0_RC
5
+72188bd2f03447e71e789a5fd2f10364bb232c2c 3.0
6
+113518629fa54ffb491dd479e15c1f00dd39d376 3.1_RC1
7
+b4e38ce16d7c4b37a6482dc7ae61fd31071b6ff1 3.1_RC2
8
+acce27790559b68f93319cd21b588f90aa93c0b1 3.1
9
+6f7c2ae0d5bd46506b7a772abebd7eff3fa3bbcb 3.1.1
10
x265_3.0.tar.gz/doc/reST/cli.rst -> x265_3.1.1.tar.gz/doc/reST/cli.rst
Changed
156
1
2
This feature can be enabled only in closed GOP structures.
3
Default 0 (disabled).
4
5
+.. option:: --field, --no-field
6
+
7
+ Enable or disable field coding. Default disabled.
8
+
9
Profile, Level, Tier
10
====================
11
12
13
judder is happening, and allow the encoder to use some blur in these
14
areas of high motion.
15
16
+In 444, chroma gets twice as much resolution, so halve the quality when psy-rd is enabled.
17
+So when psy-rd is enabled for 444 videos, cbQpOffset and crQpOffset are set to value 6,
18
+if they are not explicitly set.
19
+
20
.. option:: --psy-rd <float>
21
22
Influence rate distortion optimizated mode decision to preserve the
23
24
slicetype decision may change with this option.
25
2 - flush the slicetype decided frames only.
26
27
+.. option:: --fades, --no-fades
28
+
29
+ Detect and handle fade-in regions. Default disabled.
30
+
31
Quality, rate control and rate distortion options
32
=================================================
33
34
35
Note that this string value will need to be escaped or quoted to
36
protect against shell expansion on many platforms. No default.
37
38
+.. option:: --cll, --no-cll
39
+
40
+ Emit content light level SEI. Enabled automatically when :option:`--dolby-vision-profile` 8.1
41
+ is specified. When enabled, signals max-cll and max-fall as 0 if :option:`max-cll` is unspecified.
42
+ Default enabled.
43
+
44
.. option:: --hdr, --no-hdr
45
46
Force signalling of HDR parameters in SEI packets. Enabled
47
48
49
**CLI ONLY**
50
51
+SVT-HEVC Encoder Options
52
+========================
53
+This section lists options which are SVT-HEVC encoder specific.
54
+See section :ref:`svthevc <SvtHevc>` for more details.
55
+
56
+.. option:: --svt, --no-svt
57
+
58
+ Enable SVT-HEVC encoder if x265 is built with SVT-HEVC library. Default
59
+ disabled.
60
+
61
+.. option:: --svt-hme, --no-svt-hme
62
+
63
+ Enable Hierarchical Motion Estimation(HME) in SVT-HEVC. Default enabled.
64
+
65
+ **CLI_ONLY**
66
+
67
+.. option:: --svt-search-width <integer>
68
+
69
+ Search Area Width used during motion estimation. It depends on input resolution.
70
+ Values: [1-256]
71
+
72
+ **CLI_ONLY**
73
+
74
+.. option:: --svt-search-height <integer>
75
+
76
+ Search Area Height used during motion estimation. It depends on input resolution.
77
+ Values: [1-256]
78
+
79
+ **CLI_ONLY**
80
+
81
+.. option:: --svt-compressed-ten-bit-format, --no-svt-compressed-ten-bit-format
82
+
83
+ In order to reduce the size of input YUV and to increase channel density,
84
+ SVT-HEVC accetps inputs in compressed-ten-bit-format. The conversion between
85
+ yuv420p10le and compressed ten bit format is a lossless operation. For more
86
+ details about the conversion refer
87
+ `here<https://github.com/intel/SVT-HEVC/blob/master/Docs/SVT-HEVC_Encoder_User_Guide.pdf>'_.
88
+
89
+ **CLI_ONLY**
90
+
91
+.. option:: --svt-speed-control, --no-svt-speed-control
92
+
93
+ Enable speed control functionality to achieve real time encoding speed defined
94
+ by :option:`--fps`. Default disabled.
95
+
96
+ **CLI_ONLY**
97
+
98
+.. option:: --svt-preset-tuner <integer>
99
+
100
+ SVT-HEVC exposes 13 presets. Presets [3-12] of SVT-HEVC is mapped to x265's
101
+ presets [placebo-ultrafast]. Ultrafast is mapped to preset(12) of SVT-HEVC,
102
+ superfast to preset(11), placebo to preset(3) and so on. svt-preset-tuner works
103
+ only on top of placebo preset and maps to presets (0-2) of SVT-HEVC.
104
+
105
+ Values: [0-2]
106
+
107
+ **CLI_ONLY**
108
+
109
+.. option:: --svt-hierarchical-level <integer>
110
+
111
+ Enables multiple hierarchical levels in SVT-HEVC. Accepts values in the range [0-3].
112
+ 0 - Flat
113
+ 1 - 2-Level Hierarchy
114
+ 2 - 3-Level Hierarchy
115
+ 3 - 4-Level Hierarchy
116
+
117
+ Default: 3
118
+
119
+ **CLI_ONLY**
120
+
121
+.. option:: --svt-base-layer-switch-mode <integer>
122
+
123
+ Choose type of slices to be in base layer. Accepts values 0,1.
124
+ 0 - Use B-frames in the base layer
125
+ 1 - Use P-frames in the base layer
126
+
127
+ Default: 0
128
+
129
+ **CLI_ONLY**
130
+
131
+.. option:: --svt-pred-struct <integer>
132
+
133
+ Prediction structure forms the basis in deciding the GOP structure. SVT-HEVC
134
+ supports Low delay(P/B) and random access prediction structure. In a low delay
135
+ structure, pictures within a mini-gop can only refer to the previous pictures
136
+ in display order. In other words, picture with display order N can only refer
137
+ to pictures of display order lower than N. In random acccess method, pictures
138
+ can be referenced from both the directions. It accepts values in the range
139
+ [0-2]
140
+
141
+ 0 - Low Delay P
142
+ 1 - Low Delay B
143
+ 2 - Random Access
144
+
145
+ Default: 2
146
+
147
+ **CLI_ONLY**
148
+
149
+.. option:: --svt-fps-in-vps, --no-svt-fps-in-vps
150
+
151
+ Enable sending timing info in VPS. Default disabled.
152
+
153
+ **CLI_ONLY**
154
+
155
.. vim: noet
156
x265_3.0.tar.gz/doc/reST/index.rst -> x265_3.1.1.tar.gz/doc/reST/index.rst
Changed
7
1
2
threading
3
presets
4
lossless
5
+ svthevc
6
releasenotes
7
x265_3.0.tar.gz/doc/reST/releasenotes.rst -> x265_3.1.1.tar.gz/doc/reST/releasenotes.rst
Changed
42
1
2
*************
3
Release Notes
4
*************
5
+
6
+Version 3.1
7
+===========
8
+
9
+Release date - 18th June, 2019.
10
+
11
+New features
12
+----------------
13
+1. x265 can invoke SVT-HEVC library for encoding through :option:`--svt`.
14
+2. x265 can now accept interlaced inputs directly (no need to separate fields), and sends it to the encoder with proper fps and frame-size through :option:`--field`.
15
+3. :option:`--fades` can detect and handle fade-in regions. This option will force I-slice and initialize RC history for the brightest frame after fade-in.
16
+
17
+API changes
18
+-----------
19
+1. A new flag to signal MasterDisplayParams and maxCll/Fall separately
20
+
21
+Encoder enhancements
22
+--------------------
23
+1. Improved the performance of inter-refine level 1 by skipping the evaluation of smaller CUs when the current block is decided as "skip" by the save mode.
24
+2. New AVX2 primitives to improve the performance of encodes that enable :option:`--ssim-rd`.
25
+3. Improved performance in medium preset with negligible loss in quality.
26
+
27
+Bug fixes
28
+---------
29
+1. Bug fixes for zones.
30
+2. Fixed wrap-around from MV structure overflow occurred around 8K pixels or over.
31
+3. Fixed issues in configuring cbQpOffset and crQpOffset for 444 input
32
+4. Fixed cutree offset computation in 2nd pass encodes.
33
+
34
+Known issues
35
+------------
36
+1. AVX512 main12 asm disabling.
37
+2. Inconsistent output with 2-pass due to cutree offset sharing.
38
+
39
Version 3.0
40
===========
41
42
x265_3.1.1.tar.gz/doc/reST/svthevc.rst
Added
204
1
2
+SVT-HEVC
3
+--------
4
+
5
+.. _SvtHevc:
6
+
7
+x265 has support for open source HEVC encoder `SVT-HEVC <https://01.org/svt>`_
8
+and can generate SVT-HEVC compliant bitstreams. SVT-HEVC encoder can be enabled at run time
9
+using :option:`--svt`. Since SVT-HEVC params/CLI are not exposed outside, it has to be
10
+configured only via x265 CLI options. The API's of SVT-HEVC are accessed through x265's API
11
+so even library users of x265 can avail this feature, under the condition that x265_param_parse()
12
+API should be used for all param assignment. Params assigned outside of x265_param_parse() API
13
+wont't be mapped to SVT-HEVC. This document describes the steps needed to compile x265
14
+with SVT-HEVC and CLI options mapping between x265 and SVT-HEVC.
15
+
16
+Build Steps
17
+===========
18
+This section describes the build steps to be followed to link SVT-HEVC with x265.
19
+
20
+**SVT-HEVC**
21
+
22
+1. Clone `SVT-HEVC <https://github.com/intel/SVT-HEVC>`_ (say at path "/home/app/") and build it (follow the build steps in its README file)
23
+2. Once build is successful, binaries can be found inside the *Bin* folder at its root directory ("/home/app/SVT-HEVC/Bin/Release/")
24
+
25
+**x265**
26
+
27
+1. Set environmental variables SVT_HEVC_INCLUDE_DIR and SVT_HEVC_LIBRARY_DIR to help x265 locate SVT-HEVC. For example:
28
+ * export SVT_HEVC_INCLUDE_DIR = /home/app/SVT-HEVC/Source/API/
29
+ * export SVT_HEVC_LIBRARY_DIR = /home/app/SVT-HEVC/Bin/Release/
30
+2. Enable the cmake option ENABLE_SVT_HEVC and continue the normal build process
31
+
32
+CLI options Mapping
33
+===================
34
+Once x265 is compiled with SVT-HEVC, SVT-HEVC encoder can be invoked at run time using
35
+:option:`--svt`. :option:`--svt` can be added anywhere in the command line, x265 application will automatically
36
+parse it first and maps all other x265 CLI's present in the command line to SVT-HEVC encoder options
37
+internally and configures the same. Below table shows the actual mapping of x265 CLI options to
38
+SVT-HEVC encoder options (Name as shown in SVT-HEVC's sample configuration file)
39
+
40
++-------------------------------------------+------------------------------+------------------------------+
41
+| x265 CLI option | SVT-HEVC Encoder Option | Range |
42
++===========================================+==============================+==============================+
43
+| :option:`--input` | InputFile | Any String |
44
++-------------------------------------------+------------------------------+------------------------------+
45
+| :option:`--output` | StreamFile | Any String |
46
++-------------------------------------------+------------------------------+------------------------------+
47
+| :option:`--input-depth` | EncoderBitDepth | [8, 10] |
48
++-------------------------------------------+------------------------------+------------------------------+
49
+| | SourceWidth | [64 - 8192] |
50
+| :option:`--input-res` +------------------------------+------------------------------+
51
+| | SourceHeight | [64 - 8192] |
52
++-------------------------------------------+------------------------------+------------------------------+
53
+| :option:`--frames` | FrameToBeEncoded | Any Positive Integer |
54
++-------------------------------------------+------------------------------+------------------------------+
55
+| | FrameRateNumerator | Any Positive Integer |
56
+| :option:`--fps` +------------------------------+------------------------------+
57
+| | FrameRateDenominator | Any Positive Integer |
58
++-------------------------------------------+------------------------------+------------------------------+
59
+| :option:`--profile` | Profile | [main, main10] |
60
++-------------------------------------------+------------------------------+------------------------------+
61
+| :option:`--level-idc` | Level | [1, 2, 2.1, 3, 3.1, 4, 4.1, |
62
+| | | 5, 5.1, 5.2, 6, 6.1, 6.2] |
63
++-------------------------------------------+------------------------------+------------------------------+
64
+| :option:`--high-tier` | Tier | |
65
++-------------------------------------------+------------------------------+------------------------------+
66
+| :option:`--qpmin` | MinQpAllowed | [0 - 50] |
67
++-------------------------------------------+------------------------------+------------------------------+
68
+| :option:`--qpmax` | MaxQpAllowed | [0 - 51] |
69
++-------------------------------------------+------------------------------+------------------------------+
70
+| :option:`--rc-lookahead` | LookAheadDistance | [0 - 250] |
71
++-------------------------------------------+------------------------------+------------------------------+
72
+| :option:`--scenecut` | SceneChangeDetection | Any Positive Integer |
73
++-------------------------------------------+------------------------------+------------------------------+
74
+| :option:`--open-gop` | IntraRefreshType | |
75
++-------------------------------------------+------------------------------+------------------------------+
76
+| :option:`--deblock` | LoopFilterDisable | Any Integer |
77
++-------------------------------------------+------------------------------+------------------------------+
78
+| :option:`--sao` | SAO | |
79
++-------------------------------------------+------------------------------+------------------------------+
80
+| :option:`--keyint` | IntraPeriod | [(-2) - 255] |
81
++-------------------------------------------+------------------------------+------------------------------+
82
+| :option:`--constrained-intra` | ConstrainedIntra | |
83
++-------------------------------------------+------------------------------+------------------------------+
84
+| :option:`--vui-timing-info` | VideoUsabilityInfo | |
85
++-------------------------------------------+------------------------------+------------------------------+
86
+| :option:`--hdr` | HighDynamicRangeInput | |
87
++-------------------------------------------+------------------------------+------------------------------+
88
+| :option:`--aud` | AccessUnitDelimeter | |
89
++-------------------------------------------+------------------------------+------------------------------+
90
+| | RateControlMode | RateControlMode = 0 |
91
+| :option:`--qp` +------------------------------+------------------------------+
92
+| | QP | [0 - 51] |
93
++-------------------------------------------+------------------------------+------------------------------+
94
+| | RateControlMode | RateControlMode = 1 |
95
+| :option:`--bitrate` +------------------------------+------------------------------+
96
+| | TargetBitrate | Any Positive Integer |
97
++-------------------------------------------+------------------------------+------------------------------+
98
+| :option:`--interlace` | InterlacedVideo | [0 - 2] |
99
++-------------------------------------------+------------------------------+------------------------------+
100
+| :option:`--pools` | TargetSocket, | Maximum NUMA Nodes = 2 |
101
+| | LogicalProcessors | |
102
++-------------------------------------------+------------------------------+------------------------------+
103
+| :option:`--master-display` | MasteringDisplayColorVolume | Any String |
104
++-------------------------------------------+------------------------------+------------------------------+
105
+| :option:`--max-cll` | maxCLL, maxFALL | Any Positve Integer |
106
++-------------------------------------------+------------------------------+------------------------------+
107
+| :option:`--dolby-vision-profile` | DolbyVisionProfile | [8.1] |
108
++-------------------------------------------+------------------------------+------------------------------+
109
+| :option:`--dolby-vision-rpu` | DolbyVisionRpuFile | Any String |
110
++-------------------------------------------+------------------------------+------------------------------+
111
+| :option:`--nalu-file` | NaluFile | Any String |
112
++-------------------------------------------+------------------------------+------------------------------+
113
+| :option:`--tune` zerolatency | LatencyMode | |
114
++-------------------------------------------+------------------------------+------------------------------+
115
+| :option:`--svt-search-width` | SearchAreaWidth | [1 - 256] |
116
++-------------------------------------------+------------------------------+------------------------------+
117
+| :option:`--svt-search-height` | SearchAreaHeight | [1 - 256] |
118
++-------------------------------------------+------------------------------+------------------------------+
119
+| :option:`--svt-hierarchical-level` | HierarchicalLevels | [0 - 3] |
120
++-------------------------------------------+------------------------------+------------------------------+
121
+| :option:`--svt-base-layer-switch-mode` | BaseLayerSwitchMode | [0, 1] |
122
+| | | |
123
++-------------------------------------------+------------------------------+------------------------------+
124
+| :option:`--svt-pred-struct` | PredStructure | [0 - 2] |
125
++-------------------------------------------+------------------------------+------------------------------+
126
+| :option:`--svt-hme` | HME, UseDefaultMeHme | |
127
++-------------------------------------------+------------------------------+------------------------------+
128
+| :option:`--svt-compressed-ten-bit-format` | CompressedTenBitFormat | |
129
+| | | |
130
++-------------------------------------------+------------------------------+------------------------------+
131
+| :option:`--svt-speed-control` | SpeedControlFlag | |
132
++-------------------------------------------+------------------------------+------------------------------+
133
+| :option:`--svt-fps-in-vps` | FpsInVps | |
134
++-------------------------------------------+------------------------------+------------------------------+
135
+
136
+x265 CLI options which are not present in the above table will have no effect if SVT-HEVC is enabled
137
+and would be ignored silently with a warning. If SVT-HEVC is enabled, accepted input range of x265 CLI
138
+options will change, because it follows SVT-HEVC encoder's specs, which are mentioned in the Range
139
+section in the above table. Options starting with prefix "--svt-" are newly added to
140
+fecilitate access to the features of SVT-HEVC which couldn't be mapped to the existing x265 CLI's.
141
+So these options will have effect only if SVT-HEVC is enabled and would be ignored with default x265 encode.
142
+
143
+Preset & Tune Options Mapping
144
+=============================
145
+x265 has 10 presets from ultrafast to placebo whereas SVT-HEVC has 13 presets. Use :option:`--svt-preset-tuner`
146
+with Placebo preset to access the additional 3 presets of SVT-HEVC. Note that :option:`--svt-preset-tuner` should be
147
+used only if SVT-HEVC is enabled and only with Placebo preset, would be ignored otherwise.
148
+Below table shows the actual mapping of presets,
149
+
150
++----------------------------------------+------------------------------+
151
+| x265 Preset | SVT-HEVC Preset |
152
++========================================+==============================+
153
+| Ultrafast | 12 |
154
++----------------------------------------+------------------------------+
155
+| Superfast | 11 |
156
++----------------------------------------+------------------------------+
157
+| Veryfast | 10 |
158
++----------------------------------------+------------------------------+
159
+| Faster | 9 |
160
++----------------------------------------+------------------------------+
161
+| Fast | 8 |
162
++----------------------------------------+------------------------------+
163
+| Medium | 7 |
164
++----------------------------------------+------------------------------+
165
+| Slow | 6 |
166
++----------------------------------------+------------------------------+
167
+| Slower | 5 |
168
++----------------------------------------+------------------------------+
169
+| Veryslow | 4 |
170
++----------------------------------------+------------------------------+
171
+| Placebo | 3 |
172
++----------------------------------------+------------------------------+
173
+| Placebo :option:`--svt-preset-tuner` 0 | 0 |
174
++----------------------------------------+------------------------------+
175
+| Placebo :option:`--svt-preset-tuner` 1 | 1 |
176
++----------------------------------------+------------------------------+
177
+| Placebo :option:`--svt-preset-tuner` 2 | 2 |
178
++----------------------------------------+------------------------------+
179
+
180
+x265 has 5 tune modes (psnr, ssim, grain, zero-latency, animation) whereas SVT-HEVC
181
+has only 3 tune modes (0 - visual quality, 1 - PSNR / SSIM and 2 - VMAF). Below
182
+table shows the mapping of tune modes,
183
+
184
++-----------------------+---------------------------+
185
+| x265 Tune Modes | SVT-HEVC Tune Modes |
186
++=======================+===========================+
187
+| vmaf | 2 |
188
++-----------------------+---------------------------+
189
+| psnr | 1 |
190
++-----------------------+---------------------------+
191
+| ssim | 1 |
192
++-----------------------+---------------------------+
193
+| grain | 0 |
194
++-----------------------+---------------------------+
195
+| fastdecode | 0 |
196
++-----------------------+---------------------------+
197
+| zerolatency | 0 |
198
++-----------------------+---------------------------+
199
+| animation | 0 |
200
++-----------------------+---------------------------+
201
+
202
+Note that : 1.option:`--tune` animation is also mapped to "LatencyMode" of SVT-HEVC.
203
+ 2.option: '--tune' vmaf is not supported in x265, its under development.
204
x265_3.0.tar.gz/source/CMakeLists.txt -> x265_3.1.1.tar.gz/source/CMakeLists.txt
Changed
64
1
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 169)
6
+set(X265_BUILD 176)
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
11
add_subdirectory(dynamicHDR10)
12
add_definitions(-DENABLE_HDR10_PLUS)
13
endif(ENABLE_HDR10_PLUS)
14
+
15
+option(ENABLE_SVT_HEVC "Enable SVT HEVC Encoder" OFF)
16
+if(ENABLE_SVT_HEVC)
17
+ find_package(svthevc)
18
+ if(SVTHEVC_FOUND)
19
+ add_definitions(-DSVT_HEVC)
20
+ include_directories(${SVT_HEVC_INCLUDE_DIR})
21
+ endif(SVTHEVC_FOUND)
22
+endif(ENABLE_SVT_HEVC)
23
+
24
# this option can only be used when linking multiple libx265 libraries
25
# together, and some alternate API access method is implemented.
26
option(EXPORT_C_API "Implement public C programming interface" ON)
27
28
if(ENABLE_LIBVMAF)
29
target_link_libraries(x265-static ${VMAF})
30
endif()
31
+if(SVTHEVC_FOUND)
32
+ target_link_libraries(x265-static ${SVT_HEVC_LIBRARY})
33
+endif()
34
install(TARGETS x265-static
35
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
36
ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
37
38
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
39
ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
40
endif()
41
+
42
+if(SVTHEVC_FOUND)
43
+ install(FILES "${SVT_HEVC_INCLUDE_DIR}/EbApi.h" DESTINATION include)
44
+ install(FILES "${SVT_HEVC_INCLUDE_DIR}/EbErrorCodes.h" DESTINATION include)
45
+ install(FILES "${SVT_HEVC_INCLUDE_DIR}/EbTime.h" DESTINATION include)
46
+ install(FILES "${SVT_HEVC_LIBRARY}" DESTINATION ${BIN_INSTALL_DIR})
47
+endif()
48
+
49
install(FILES x265.h "${PROJECT_BINARY_DIR}/x265_config.h" DESTINATION include)
50
if((WIN32 AND ENABLE_CLI) OR (WIN32 AND ENABLE_SHARED))
51
if(MSVC_IDE)
52
53
if(EXTRA_LIB)
54
target_link_libraries(x265-shared ${EXTRA_LIB})
55
endif()
56
- target_link_libraries(x265-shared ${PLATFORM_LIBS})
57
+ target_link_libraries(x265-shared ${PLATFORM_LIBS})
58
+ if(SVTHEVC_FOUND)
59
+ target_link_libraries(x265-shared ${SVT_HEVC_LIBRARY})
60
+ endif(SVTHEVC_FOUND)
61
if(MSVC)
62
set_target_properties(x265-shared PROPERTIES OUTPUT_NAME libx265)
63
else()
64
x265_3.1.1.tar.gz/source/cmake/Findsvthevc.cmake
Added
62
1
2
+# Module for locating SVT-HEVC Library
3
+#
4
+# SVT_HEVC_INCLUDE_DIR
5
+# Points to the SVT-HEVC include directory.
6
+#
7
+# SVT_HEVC_LIBRARY
8
+# Points to the SVT-HEVC library
9
+# Copyright (c) 2013-2018 MulticoreWare, Inc
10
+
11
+include(FindPackageHandleStandardArgs)
12
+
13
+if(UNIX)
14
+SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so")
15
+else()
16
+SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
17
+endif()
18
+
19
+set(SVT_VERSION_MAJOR_REQUIRED 1)
20
+set(SVT_VERSION_MINOR_REQUIRED 3)
21
+set(SVT_VERSION_PATCHLEVEL_REQUIRED 0)
22
+
23
+find_path(SVT_HEVC_INCLUDE_DIR
24
+ NAMES EbApi.h EbErrorCodes.h EbTime.h
25
+ HINTS $ENV{SVT_HEVC_INCLUDE_DIR}
26
+ PATHS ENV
27
+ DOC "SVT-HEVC include directory")
28
+
29
+if(SVT_HEVC_INCLUDE_DIR)
30
+file(READ "${SVT_HEVC_INCLUDE_DIR}/EbApi.h" version)
31
+
32
+string(REGEX MATCH "SVT_VERSION_MAJOR ([0-9]*)" _ ${version})
33
+set(SVT_VERSION_MAJOR ${CMAKE_MATCH_1})
34
+
35
+string(REGEX MATCH "SVT_VERSION_MINOR ([0-9]*)" _ ${version})
36
+set(SVT_VERSION_MINOR ${CMAKE_MATCH_1})
37
+
38
+string(REGEX MATCH "SVT_VERSION_PATCHLEVEL ([0-9]*)" _ ${version})
39
+set(SVT_VERSION_PATCHLEVEL ${CMAKE_MATCH_1})
40
+
41
+if(NOT ${SVT_VERSION_MAJOR} EQUAL "1" OR NOT ${SVT_VERSION_MINOR} EQUAL "3" OR NOT ${SVT_VERSION_PATCHLEVEL} EQUAL "0")
42
+ message (SEND_ERROR "-- Found SVT-HEVC Lib Version: ${SVT_VERSION_MAJOR}.${SVT_VERSION_MINOR}.${SVT_VERSION_PATCHLEVEL} which doesn't match the required version: ${SVT_VERSION_MAJOR_REQUIRED}.${SVT_VERSION_MINOR_REQUIRED}.${SVT_VERSION_PATCHLEVEL_REQUIRED}; Aborting configure ")
43
+else()
44
+ message(STATUS "-- Found SVT-HEVC Lib Version: ${SVT_VERSION_MAJOR}.${SVT_VERSION_MINOR}.${SVT_VERSION_PATCHLEVEL}")
45
+endif()
46
+
47
+endif()
48
+
49
+find_library(SVT_HEVC_LIBRARY
50
+if(UNIX)
51
+ NAMES SvtHevcEnc
52
+else()
53
+ NAMES SvtHevcEnc
54
+endif()
55
+ HINTS $ENV{SVT_HEVC_LIBRARY_DIR}
56
+ PATHS ENV
57
+ DOC "SVT-HEVC library")
58
+
59
+
60
+mark_as_advanced(SVT_HEVC_LIBRARY SVT_HEVC_INCLUDE_DIR SVT_HEVC_LIBRARY_DIR)
61
+find_package_handle_standard_args(SVTHEVC REQUIRED_VARS SVT_HEVC_LIBRARY SVT_HEVC_INCLUDE_DIR)
62
x265_3.0.tar.gz/source/common/cudata.cpp -> x265_3.1.1.tar.gz/source/common/cudata.cpp
Changed
26
1
2
int mvx = x265_clip3(-32768, 32767, (scale * mv.x + 127 + (scale * mv.x < 0)) >> 8);
3
int mvy = x265_clip3(-32768, 32767, (scale * mv.y + 127 + (scale * mv.y < 0)) >> 8);
4
5
- return MV((int16_t)mvx, (int16_t)mvy);
6
+ return MV((int32_t)mvx, (int32_t)mvy);
7
}
8
9
}
10
11
const uint32_t mvshift = 2;
12
uint32_t offset = 8;
13
14
- int16_t xmax = (int16_t)((m_slice->m_sps->picWidthInLumaSamples + offset - m_cuPelX - 1) << mvshift);
15
- int16_t xmin = -(int16_t)((m_encData->m_param->maxCUSize + offset + m_cuPelX - 1) << mvshift);
16
+ int32_t xmax = (int32_t)((m_slice->m_sps->picWidthInLumaSamples + offset - m_cuPelX - 1) << mvshift);
17
+ int32_t xmin = -(int32_t)((m_encData->m_param->maxCUSize + offset + m_cuPelX - 1) << mvshift);
18
19
- int16_t ymax = (int16_t)((m_slice->m_sps->picHeightInLumaSamples + offset - m_cuPelY - 1) << mvshift);
20
- int16_t ymin = -(int16_t)((m_encData->m_param->maxCUSize + offset + m_cuPelY - 1) << mvshift);
21
+ int32_t ymax = (int32_t)((m_slice->m_sps->picHeightInLumaSamples + offset - m_cuPelY - 1) << mvshift);
22
+ int32_t ymin = -(int32_t)((m_encData->m_param->maxCUSize + offset + m_cuPelY - 1) << mvshift);
23
24
outMV.x = X265_MIN(xmax, X265_MAX(xmin, outMV.x));
25
outMV.y = X265_MIN(ymax, X265_MAX(ymin, outMV.y));
26
x265_3.0.tar.gz/source/common/frame.cpp -> x265_3.1.1.tar.gz/source/common/frame.cpp
Changed
9
1
2
m_addOnCtuInfo = NULL;
3
m_addOnPrevChange = NULL;
4
m_classifyFrame = false;
5
+ m_fieldNum = 0;
6
}
7
8
bool Frame::create(x265_param *param, float* quantOffsets)
9
x265_3.0.tar.gz/source/common/frame.h -> x265_3.1.1.tar.gz/source/common/frame.h
Changed
9
1
2
uint32_t* m_classifyCount;
3
4
bool m_classifyFrame;
5
+ int m_fieldNum;
6
7
Frame();
8
9
x265_3.0.tar.gz/source/common/lowres.cpp -> x265_3.1.1.tar.gz/source/common/lowres.cpp
Changed
27
1
2
3
size_t planesize = lumaStride * (lines + 2 * origPic->m_lumaMarginY);
4
size_t padoffset = lumaStride * origPic->m_lumaMarginY + origPic->m_lumaMarginX;
5
- if (!!param->rc.aqMode || !!param->rc.hevcAq)
6
+ if (!!param->rc.aqMode || !!param->rc.hevcAq || !!param->bAQMotion)
7
{
8
CHECKED_MALLOC_ZERO(qpAqOffset, double, cuCountFullRes);
9
CHECKED_MALLOC_ZERO(invQscaleFactor, int, cuCountFullRes);
10
11
12
if (origPic->m_param->bAQMotion)
13
CHECKED_MALLOC_ZERO(qpAqMotionOffset, double, cuCountFullRes);
14
- if (origPic->m_param->bDynamicRefine)
15
+ if (origPic->m_param->bDynamicRefine || origPic->m_param->bEnableFades)
16
CHECKED_MALLOC_ZERO(blockVariance, uint32_t, cuCountFullRes);
17
18
if (!!param->rc.hevcAq)
19
20
{
21
bLastMiniGopBFrame = false;
22
bKeyframe = false; // Not a keyframe unless identified by lookahead
23
+ bIsFadeEnd = false;
24
frameNum = poc;
25
leadingBframes = 0;
26
indB = 0;
27
x265_3.0.tar.gz/source/common/lowres.h -> x265_3.1.1.tar.gz/source/common/lowres.h
Changed
17
1
2
bool bScenecut; // Set to false if the frame cannot possibly be part of a real scenecut.
3
bool bKeyframe;
4
bool bLastMiniGopBFrame;
5
+ bool bIsFadeEnd;
6
7
double ipCostRatio;
8
9
10
uint32_t* blockVariance;
11
uint64_t wp_ssd[3]; // This is different than SSDY, this is sum(pixel^2) - sum(pixel)^2 for entire frame
12
uint64_t wp_sum[3];
13
+ double frameVariance;
14
15
/* cutree intermediate data */
16
PicQPAdaptationLayer* pAQLayer;
17
x265_3.0.tar.gz/source/common/mv.h -> x265_3.1.1.tar.gz/source/common/mv.h
Changed
41
1
2
public:
3
4
union {
5
- struct { int16_t x, y; };
6
+ struct { int32_t x, y; };
7
8
- int32_t word;
9
+ int64_t word;
10
};
11
12
MV() {}
13
- MV(int32_t w) : word(w) {}
14
- MV(int16_t _x, int16_t _y) : x(_x), y(_y) {}
15
+ MV(int64_t w) : word(w) {}
16
+ MV(int32_t _x, int32_t _y) : x(_x), y(_y) {}
17
18
- MV& operator =(uint32_t w) { word = w; return *this; }
19
+ MV& operator =(uint64_t w) { word = w; return *this; }
20
21
MV& operator +=(const MV& other) { x += other.x; y += other.y; return *this; }
22
23
24
25
MV operator >>(int i) const { return MV(x >> i, y >> i); }
26
27
- MV operator *(int16_t i) const { return MV(x * i, y * i); }
28
+ MV operator *(int32_t i) const { return MV(x * i, y * i); }
29
30
MV operator -(const MV& other) const { return MV(x - other.x, y - other.y); }
31
32
33
34
bool inline notZero() const { return this->word != 0; }
35
36
- bool inline isSubpel() const { return (this->word & 0x00030003) != 0; }
37
+ bool inline isSubpel() const { return (this->word & 0x0000000300000003ll) != 0; }
38
39
MV mvmin(const MV& m) const { return MV(x > m.x ? m.x : x, y > m.y ? m.y : y); }
40
41
x265_3.0.tar.gz/source/common/param.cpp -> x265_3.1.1.tar.gz/source/common/param.cpp
Changed
936
1
2
#include "param.h"
3
#include "cpu.h"
4
#include "x265.h"
5
+#include "svt.h"
6
7
#if _MSC_VER
8
#pragma warning(disable: 4996) // POSIX functions are just fine, thanks
9
10
11
x265_param *x265_param_alloc()
12
{
13
- return (x265_param*)x265_malloc(sizeof(x265_param));
14
+ x265_param* param = (x265_param*)x265_malloc(sizeof(x265_param));
15
+#ifdef SVT_HEVC
16
+ param->svtHevcParam = (EB_H265_ENC_CONFIGURATION*)x265_malloc(sizeof(EB_H265_ENC_CONFIGURATION));
17
+#endif
18
+ return param;
19
}
20
21
void x265_param_free(x265_param* p)
22
{
23
+ x265_zone_free(p);
24
+#ifdef SVT_HEVC
25
+ x265_free(p->svtHevcParam);
26
+#endif
27
x265_free(p);
28
}
29
30
void x265_param_default(x265_param* param)
31
{
32
+#ifdef SVT_HEVC
33
+ EB_H265_ENC_CONFIGURATION* svtParam = (EB_H265_ENC_CONFIGURATION*)param->svtHevcParam;
34
+#endif
35
+
36
memset(param, 0, sizeof(x265_param));
37
38
/* Applying default values to all elements in the param structure */
39
40
param->uhdBluray = 0;
41
param->bHighTier = 1; //Allow high tier by default
42
param->interlaceMode = 0;
43
+ param->bField = 0;
44
param->bAnnexB = 1;
45
param->bRepeatHeaders = 0;
46
param->bEnableAccessUnitDelimiters = 0;
47
48
param->chunkStart = 0;
49
param->chunkEnd = 0;
50
param->bEnableHRDConcatFlag = 0;
51
+ param->bEnableFades = 0;
52
53
/* Intra Coding Tools */
54
param->bEnableConstrainedIntra = 0;
55
56
param->searchMethod = X265_HEX_SEARCH;
57
param->subpelRefine = 2;
58
param->searchRange = 57;
59
- param->maxNumMergeCand = 2;
60
- param->limitReferences = 3;
61
+ param->maxNumMergeCand = 3;
62
+ param->limitReferences = 1;
63
param->limitModes = 0;
64
param->bEnableWeightedPred = 1;
65
param->bEnableWeightedBiPred = 0;
66
- param->bEnableEarlySkip = 0;
67
+ param->bEnableEarlySkip = 1;
68
param->bEnableRecursionSkip = 1;
69
param->bEnableAMP = 0;
70
param->bEnableRectInter = 0;
71
72
param->analysisReuseFileName = NULL;
73
param->analysisSave = NULL;
74
param->analysisLoad = NULL;
75
- param->bIntraInBFrames = 0;
76
+ param->bIntraInBFrames = 1;
77
param->bLossless = 0;
78
param->bCULossless = 0;
79
param->bEnableTemporalSubLayers = 0;
80
81
/* SEI messages */
82
param->preferredTransferCharacteristics = -1;
83
param->pictureStructure = -1;
84
+ param->bEmitCLL = 1;
85
+
86
+ /* SVT Hevc Encoder specific params */
87
+ param->bEnableSvtHevc = 0;
88
+ param->svtHevcParam = NULL;
89
+
90
+#ifdef SVT_HEVC
91
+ param->svtHevcParam = svtParam;
92
+ svt_param_default(param);
93
+#endif
94
}
95
96
int x265_param_default_preset(x265_param* param, const char* preset, const char* tune)
97
98
99
if (!strcmp(preset, "ultrafast"))
100
{
101
+ param->maxNumMergeCand = 2;
102
+ param->bIntraInBFrames = 0;
103
param->lookaheadDepth = 5;
104
param->scenecutThreshold = 0; // disable lookahead
105
param->maxCUSize = 32;
106
107
param->bFrameAdaptive = 0;
108
param->subpelRefine = 0;
109
param->searchMethod = X265_DIA_SEARCH;
110
- param->bEnableEarlySkip = 1;
111
param->bEnableSAO = 0;
112
param->bEnableSignHiding = 0;
113
param->bEnableWeightedPred = 0;
114
115
}
116
else if (!strcmp(preset, "superfast"))
117
{
118
+ param->maxNumMergeCand = 2;
119
+ param->bIntraInBFrames = 0;
120
param->lookaheadDepth = 10;
121
param->maxCUSize = 32;
122
param->bframes = 3;
123
param->bFrameAdaptive = 0;
124
param->subpelRefine = 1;
125
- param->bEnableEarlySkip = 1;
126
param->bEnableWeightedPred = 0;
127
param->rdLevel = 2;
128
param->maxNumReferences = 1;
129
130
}
131
else if (!strcmp(preset, "veryfast"))
132
{
133
+ param->maxNumMergeCand = 2;
134
+ param->limitReferences = 3;
135
+ param->bIntraInBFrames = 0;
136
param->lookaheadDepth = 15;
137
param->bFrameAdaptive = 0;
138
param->subpelRefine = 1;
139
- param->bEnableEarlySkip = 1;
140
param->rdLevel = 2;
141
param->maxNumReferences = 2;
142
param->rc.qgSize = 32;
143
144
}
145
else if (!strcmp(preset, "faster"))
146
{
147
+ param->maxNumMergeCand = 2;
148
+ param->limitReferences = 3;
149
+ param->bIntraInBFrames = 0;
150
param->lookaheadDepth = 15;
151
param->bFrameAdaptive = 0;
152
- param->bEnableEarlySkip = 1;
153
param->rdLevel = 2;
154
param->maxNumReferences = 2;
155
param->bEnableFastIntra = 1;
156
}
157
else if (!strcmp(preset, "fast"))
158
{
159
+ param->maxNumMergeCand = 2;
160
+ param->limitReferences = 3;
161
+ param->bEnableEarlySkip = 0;
162
+ param->bIntraInBFrames = 0;
163
param->lookaheadDepth = 15;
164
param->bFrameAdaptive = 0;
165
param->rdLevel = 2;
166
167
}
168
else if (!strcmp(preset, "slow"))
169
{
170
+ param->limitReferences = 3;
171
+ param->bEnableEarlySkip = 0;
172
+ param->bIntraInBFrames = 0;
173
param->bEnableRectInter = 1;
174
param->lookaheadDepth = 25;
175
param->rdLevel = 4;
176
param->rdoqLevel = 2;
177
param->psyRdoq = 1.0;
178
param->subpelRefine = 3;
179
- param->maxNumMergeCand = 3;
180
param->searchMethod = X265_STAR_SEARCH;
181
param->maxNumReferences = 4;
182
param->limitModes = 1;
183
184
}
185
else if (!strcmp(preset, "slower"))
186
{
187
+ param->bEnableEarlySkip = 0;
188
param->bEnableWeightedBiPred = 1;
189
param->bEnableAMP = 1;
190
param->bEnableRectInter = 1;
191
192
param->maxNumMergeCand = 4;
193
param->searchMethod = X265_STAR_SEARCH;
194
param->maxNumReferences = 5;
195
- param->limitReferences = 1;
196
param->limitModes = 1;
197
- param->bIntraInBFrames = 1;
198
param->lookaheadSlices = 0; // disabled for best quality
199
param->limitTU = 4;
200
}
201
else if (!strcmp(preset, "veryslow"))
202
{
203
+ param->bEnableEarlySkip = 0;
204
param->bEnableWeightedBiPred = 1;
205
param->bEnableAMP = 1;
206
param->bEnableRectInter = 1;
207
208
param->maxNumReferences = 5;
209
param->limitReferences = 0;
210
param->limitModes = 0;
211
- param->bIntraInBFrames = 1;
212
param->lookaheadSlices = 0; // disabled for best quality
213
param->limitTU = 0;
214
}
215
else if (!strcmp(preset, "placebo"))
216
{
217
+ param->bEnableEarlySkip = 0;
218
param->bEnableWeightedBiPred = 1;
219
param->bEnableAMP = 1;
220
param->bEnableRectInter = 1;
221
222
param->bEnableRecursionSkip = 0;
223
param->maxNumReferences = 5;
224
param->limitReferences = 0;
225
- param->bIntraInBFrames = 1;
226
param->lookaheadSlices = 0; // disabled for best quality
227
// TODO: optimized esa
228
}
229
230
param->deblockingFilterBetaOffset = 1;
231
param->deblockingFilterTCOffset = 1;
232
}
233
+ else if (!strcmp(tune, "vmaf")) /*Adding vmaf for x265 + SVT-HEVC integration support*/
234
+ {
235
+ /*vmaf is under development, currently x265 won't support vmaf*/
236
+ }
237
else
238
return -1;
239
}
240
241
+#ifdef SVT_HEVC
242
+ if (svt_set_preset_tune(param, preset, tune))
243
+ return -1;
244
+#endif
245
+
246
return 0;
247
}
248
249
250
bool bValueWasNull = !value;
251
bool bExtraParams = false;
252
char nameBuf[64];
253
+ static int count;
254
255
if (!name)
256
return X265_PARAM_BAD_NAME;
257
258
+ count++;
259
// skip -- prefix if provided
260
if (name[0] == '-' && name[1] == '-')
261
name += 2;
262
263
#endif
264
#define OPT(STR) else if (!strcmp(name, STR))
265
#define OPT2(STR1, STR2) else if (!strcmp(name, STR1) || !strcmp(name, STR2))
266
+
267
+#ifdef SVT_HEVC
268
+ if (p->bEnableSvtHevc)
269
+ {
270
+ if(svt_param_parse(p, name, value))
271
+ {
272
+ x265_log(p, X265_LOG_ERROR, "Error while parsing params \n");
273
+ bError = true;
274
+ }
275
+ return bError ? X265_PARAM_BAD_VALUE : 0;
276
+ }
277
+#endif
278
+
279
if (0) ;
280
OPT("asm")
281
{
282
283
OPT("refine-ctu-distortion") p->ctuDistortionRefine = atoi(value);
284
OPT("hevc-aq") p->rc.hevcAq = atobool(value);
285
OPT("qp-adaptation-range") p->rc.qpAdaptationRange = atof(value);
286
+#ifdef SVT_HEVC
287
+ OPT("svt")
288
+ {
289
+ p->bEnableSvtHevc = atobool(value);
290
+ if (count > 1 && p->bEnableSvtHevc)
291
+ {
292
+ x265_log(NULL, X265_LOG_ERROR, "Enable SVT should be the first call to x265_parse_parse \n");
293
+ bError = true;
294
+ }
295
+ }
296
+ OPT("svt-hme") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
297
+ OPT("svt-search-width") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
298
+ OPT("svt-search-height") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
299
+ OPT("svt-compressed-ten-bit-format") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
300
+ OPT("svt-speed-control") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
301
+ OPT("input-depth") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
302
+ OPT("svt-preset-tuner") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
303
+ OPT("svt-hierarchical-level") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
304
+ OPT("svt-base-layer-switch-mode") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
305
+ OPT("svt-pred-struct") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
306
+ OPT("svt-fps-in-vps") x265_log(p, X265_LOG_WARNING, "Option %s is SVT-HEVC Encoder specific; Disabling it here \n", name);
307
+#endif
308
+ OPT("fades") p->bEnableFades = atobool(value);
309
+ OPT("field") p->bField = atobool( value );
310
+ OPT("cll") p->bEmitCLL = atobool(value);
311
else
312
return X265_PARAM_BAD_NAME;
313
}
314
315
if (param->dolbyProfile == 81)
316
CHECK(!(param->masteringDisplayColorVolume), "Dolby Vision profile - 8.1 requires Mastering display color volume information\n");
317
}
318
+
319
+ if (param->bField && param->interlaceMode)
320
+ {
321
+ CHECK( (param->bFrameAdaptive==0), "Adaptive B-frame decision method should be closed for field feature.\n" );
322
+ // to do
323
+ }
324
#if !X86_64
325
CHECK(param->searchMethod == X265_SEA && (param->sourceWidth > 840 || param->sourceHeight > 480),
326
"SEA motion search does not support resolutions greater than 480p in 32 bit build");
327
328
p->vui.defDispWinRightOffset, p->vui.defDispWinBottomOffset);
329
if (p->masteringDisplayColorVolume)
330
s += sprintf(s, " master-display=%s", p->masteringDisplayColorVolume);
331
- s += sprintf(s, " max-cll=%hu,%hu", p->maxCLL, p->maxFALL);
332
+ if (p->bEmitCLL)
333
+ s += sprintf(s, "cll=%hu,%hu", p->maxCLL, p->maxFALL);
334
s += sprintf(s, " min-luma=%hu", p->minLuma);
335
s += sprintf(s, " max-luma=%hu", p->maxLuma);
336
s += sprintf(s, " log2-max-poc-lsb=%d", p->log2MaxPocLsb);
337
338
BOOL(p->bDynamicRefine, "dynamic-refine");
339
BOOL(p->bSingleSeiNal, "single-sei");
340
BOOL(p->rc.hevcAq, "hevc-aq");
341
+ BOOL(p->bEnableSvtHevc, "svt");
342
+ BOOL(p->bField, "field");
343
s += sprintf(s, " qp-adaptation-range=%.2f", p->rc.qpAdaptationRange);
344
#undef BOOL
345
return buf;
346
347
return false;
348
}
349
350
+void x265_copy_params(x265_param* dst, x265_param* src)
351
+{
352
+ dst->cpuid = src->cpuid;
353
+ dst->frameNumThreads = src->frameNumThreads;
354
+ if (src->numaPools) dst->numaPools = strdup(src->numaPools);
355
+ else dst->numaPools = NULL;
356
+
357
+ dst->bEnableWavefront = src->bEnableWavefront;
358
+ dst->bDistributeModeAnalysis = src->bDistributeModeAnalysis;
359
+ dst->bDistributeMotionEstimation = src->bDistributeMotionEstimation;
360
+ dst->bLogCuStats = src->bLogCuStats;
361
+ dst->bEnablePsnr = src->bEnablePsnr;
362
+ dst->bEnableSsim = src->bEnableSsim;
363
+ dst->logLevel = src->logLevel;
364
+ dst->csvLogLevel = src->csvLogLevel;
365
+ if (src->csvfn) dst->csvfn = strdup(src->csvfn);
366
+ else dst->csvfn = NULL;
367
+ dst->internalBitDepth = src->internalBitDepth;
368
+ dst->internalCsp = src->internalCsp;
369
+ dst->fpsNum = src->fpsNum;
370
+ dst->fpsDenom = src->fpsDenom;
371
+ dst->sourceHeight = src->sourceHeight;
372
+ dst->sourceWidth = src->sourceWidth;
373
+ dst->interlaceMode = src->interlaceMode;
374
+ dst->totalFrames = src->totalFrames;
375
+ dst->levelIdc = src->levelIdc;
376
+ dst->bHighTier = src->bHighTier;
377
+ dst->uhdBluray = src->uhdBluray;
378
+ dst->maxNumReferences = src->maxNumReferences;
379
+ dst->bAllowNonConformance = src->bAllowNonConformance;
380
+ dst->bRepeatHeaders = src->bRepeatHeaders;
381
+ dst->bAnnexB = src->bAnnexB;
382
+ dst->bEnableAccessUnitDelimiters = src->bEnableAccessUnitDelimiters;
383
+ dst->bEmitInfoSEI = src->bEmitInfoSEI;
384
+ dst->decodedPictureHashSEI = src->decodedPictureHashSEI;
385
+ dst->bEnableTemporalSubLayers = src->bEnableTemporalSubLayers;
386
+ dst->bOpenGOP = src->bOpenGOP;
387
+ dst->keyframeMax = src->keyframeMax;
388
+ dst->keyframeMin = src->keyframeMin;
389
+ dst->bframes = src->bframes;
390
+ dst->bFrameAdaptive = src->bFrameAdaptive;
391
+ dst->bFrameBias = src->bFrameBias;
392
+ dst->bBPyramid = src->bBPyramid;
393
+ dst->lookaheadDepth = src->lookaheadDepth;
394
+ dst->lookaheadSlices = src->lookaheadSlices;
395
+ dst->lookaheadThreads = src->lookaheadThreads;
396
+ dst->scenecutThreshold = src->scenecutThreshold;
397
+ dst->bIntraRefresh = src->bIntraRefresh;
398
+ dst->maxCUSize = src->maxCUSize;
399
+ dst->minCUSize = src->minCUSize;
400
+ dst->bEnableRectInter = src->bEnableRectInter;
401
+ dst->bEnableAMP = src->bEnableAMP;
402
+ dst->maxTUSize = src->maxTUSize;
403
+ dst->tuQTMaxInterDepth = src->tuQTMaxInterDepth;
404
+ dst->tuQTMaxIntraDepth = src->tuQTMaxIntraDepth;
405
+ dst->limitTU = src->limitTU;
406
+ dst->rdoqLevel = src->rdoqLevel;
407
+ dst->bEnableSignHiding = src->bEnableSignHiding;
408
+ dst->bEnableTransformSkip = src->bEnableTransformSkip;
409
+ dst->noiseReductionInter = src->noiseReductionInter;
410
+ dst->noiseReductionIntra = src->noiseReductionIntra;
411
+ if (src->scalingLists) dst->scalingLists = strdup(src->scalingLists);
412
+ else dst->scalingLists = NULL;
413
+ dst->bEnableStrongIntraSmoothing = src->bEnableStrongIntraSmoothing;
414
+ dst->bEnableConstrainedIntra = src->bEnableConstrainedIntra;
415
+ dst->maxNumMergeCand = src->maxNumMergeCand;
416
+ dst->limitReferences = src->limitReferences;
417
+ dst->limitModes = src->limitModes;
418
+ dst->searchMethod = src->searchMethod;
419
+ dst->subpelRefine = src->subpelRefine;
420
+ dst->searchRange = src->searchRange;
421
+ dst->bEnableTemporalMvp = src->bEnableTemporalMvp;
422
+ dst->bEnableWeightedBiPred = src->bEnableWeightedBiPred;
423
+ dst->bEnableWeightedPred = src->bEnableWeightedPred;
424
+ dst->bSourceReferenceEstimation = src->bSourceReferenceEstimation;
425
+ dst->bEnableLoopFilter = src->bEnableLoopFilter;
426
+ dst->deblockingFilterBetaOffset = src->deblockingFilterBetaOffset;
427
+ dst->deblockingFilterTCOffset = src->deblockingFilterTCOffset;
428
+ dst->bEnableSAO = src->bEnableSAO;
429
+ dst->bSaoNonDeblocked = src->bSaoNonDeblocked;
430
+ dst->rdLevel = src->rdLevel;
431
+ dst->bEnableEarlySkip = src->bEnableEarlySkip;
432
+ dst->bEnableRecursionSkip = src->bEnableRecursionSkip;
433
+ dst->bEnableFastIntra = src->bEnableFastIntra;
434
+ dst->bEnableTSkipFast = src->bEnableTSkipFast;
435
+ dst->bCULossless = src->bCULossless;
436
+ dst->bIntraInBFrames = src->bIntraInBFrames;
437
+ dst->rdPenalty = src->rdPenalty;
438
+ dst->psyRd = src->psyRd;
439
+ dst->psyRdoq = src->psyRdoq;
440
+ dst->bEnableRdRefine = src->bEnableRdRefine;
441
+ dst->analysisReuseMode = src->analysisReuseMode;
442
+ if (src->analysisReuseFileName) dst->analysisReuseFileName=strdup(src->analysisReuseFileName);
443
+ else dst->analysisReuseFileName = NULL;
444
+ dst->bLossless = src->bLossless;
445
+ dst->cbQpOffset = src->cbQpOffset;
446
+ dst->crQpOffset = src->crQpOffset;
447
+ dst->preferredTransferCharacteristics = src->preferredTransferCharacteristics;
448
+ dst->pictureStructure = src->pictureStructure;
449
+
450
+ dst->rc.rateControlMode = src->rc.rateControlMode;
451
+ dst->rc.qp = src->rc.qp;
452
+ dst->rc.bitrate = src->rc.bitrate;
453
+ dst->rc.qCompress = src->rc.qCompress;
454
+ dst->rc.ipFactor = src->rc.ipFactor;
455
+ dst->rc.pbFactor = src->rc.pbFactor;
456
+ dst->rc.rfConstant = src->rc.rfConstant;
457
+ dst->rc.qpStep = src->rc.qpStep;
458
+ dst->rc.aqMode = src->rc.aqMode;
459
+ dst->rc.aqStrength = src->rc.aqStrength;
460
+ dst->rc.vbvBufferSize = src->rc.vbvBufferSize;
461
+ dst->rc.vbvMaxBitrate = src->rc.vbvMaxBitrate;
462
+
463
+ dst->rc.vbvBufferInit = src->rc.vbvBufferInit;
464
+ dst->rc.cuTree = src->rc.cuTree;
465
+ dst->rc.rfConstantMax = src->rc.rfConstantMax;
466
+ dst->rc.rfConstantMin = src->rc.rfConstantMin;
467
+ dst->rc.bStatWrite = src->rc.bStatWrite;
468
+ dst->rc.bStatRead = src->rc.bStatRead;
469
+ if (src->rc.statFileName) dst->rc.statFileName=strdup(src->rc.statFileName);
470
+ else dst->rc.statFileName = NULL;
471
+ dst->rc.qblur = src->rc.qblur;
472
+ dst->rc.complexityBlur = src->rc.complexityBlur;
473
+ dst->rc.bEnableSlowFirstPass = src->rc.bEnableSlowFirstPass;
474
+ dst->rc.zoneCount = src->rc.zoneCount;
475
+ dst->rc.zonefileCount = src->rc.zonefileCount;
476
+
477
+ if (src->rc.zonefileCount && src->rc.zones)
478
+ {
479
+ for (int i = 0; i < src->rc.zonefileCount; i++)
480
+ {
481
+ dst->rc.zones[i].startFrame = src->rc.zones[i].startFrame;
482
+ memcpy(dst->rc.zones[i].zoneParam, src->rc.zones[i].zoneParam, sizeof(x265_param));
483
+ }
484
+ }
485
+ else if (src->rc.zoneCount && src->rc.zones)
486
+ {
487
+ for (int i = 0; i < src->rc.zoneCount; i++)
488
+ {
489
+ dst->rc.zones[i].startFrame = src->rc.zones[i].startFrame;
490
+ dst->rc.zones[i].endFrame = src->rc.zones[i].endFrame;
491
+ dst->rc.zones[i].bForceQp = src->rc.zones[i].bForceQp;
492
+ dst->rc.zones[i].qp = src->rc.zones[i].qp;
493
+ dst->rc.zones[i].bitrateFactor = src->rc.zones[i].bitrateFactor;
494
+ }
495
+ }
496
+ else
497
+ dst->rc.zones = NULL;
498
+
499
+ if (src->rc.lambdaFileName) dst->rc.lambdaFileName = strdup(src->rc.lambdaFileName);
500
+ else dst->rc.lambdaFileName = NULL;
501
+ dst->rc.bStrictCbr = src->rc.bStrictCbr;
502
+ dst->rc.qgSize = src->rc.qgSize;
503
+ dst->rc.bEnableGrain = src->rc.bEnableGrain;
504
+ dst->rc.qpMax = src->rc.qpMax;
505
+ dst->rc.qpMin = src->rc.qpMin;
506
+ dst->rc.bEnableConstVbv = src->rc.bEnableConstVbv;
507
+ dst->rc.hevcAq = src->rc.hevcAq;
508
+ dst->rc.qpAdaptationRange = src->rc.qpAdaptationRange;
509
+
510
+ dst->vui.aspectRatioIdc = src->vui.aspectRatioIdc;
511
+ dst->vui.sarWidth = src->vui.sarWidth;
512
+ dst->vui.sarHeight = src->vui.sarHeight;
513
+ dst->vui.bEnableOverscanAppropriateFlag = src->vui.bEnableOverscanAppropriateFlag;
514
+ dst->vui.bEnableOverscanInfoPresentFlag = src->vui.bEnableOverscanInfoPresentFlag;
515
+ dst->vui.bEnableVideoSignalTypePresentFlag = src->vui.bEnableVideoSignalTypePresentFlag;
516
+ dst->vui.videoFormat = src->vui.videoFormat;
517
+ dst->vui.bEnableVideoFullRangeFlag = src->vui.bEnableVideoFullRangeFlag;
518
+ dst->vui.bEnableColorDescriptionPresentFlag = src->vui.bEnableColorDescriptionPresentFlag;
519
+ dst->vui.colorPrimaries = src->vui.colorPrimaries;
520
+ dst->vui.transferCharacteristics = src->vui.transferCharacteristics;
521
+ dst->vui.matrixCoeffs = src->vui.matrixCoeffs;
522
+ dst->vui.bEnableChromaLocInfoPresentFlag = src->vui.bEnableChromaLocInfoPresentFlag;
523
+ dst->vui.chromaSampleLocTypeTopField = src->vui.chromaSampleLocTypeTopField;
524
+ dst->vui.chromaSampleLocTypeBottomField = src->vui.chromaSampleLocTypeBottomField;
525
+ dst->vui.bEnableDefaultDisplayWindowFlag = src->vui.bEnableDefaultDisplayWindowFlag;
526
+ dst->vui.defDispWinBottomOffset = src->vui.defDispWinBottomOffset;
527
+ dst->vui.defDispWinLeftOffset = src->vui.defDispWinLeftOffset;
528
+ dst->vui.defDispWinRightOffset = src->vui.defDispWinRightOffset;
529
+ dst->vui.defDispWinTopOffset = src->vui.defDispWinTopOffset;
530
+
531
+ if (src->masteringDisplayColorVolume) dst->masteringDisplayColorVolume=strdup( src->masteringDisplayColorVolume);
532
+ else dst->masteringDisplayColorVolume = NULL;
533
+ dst->maxLuma = src->maxLuma;
534
+ dst->minLuma = src->minLuma;
535
+ dst->bEmitCLL = src->bEmitCLL;
536
+ dst->maxCLL = src->maxCLL;
537
+ dst->maxFALL = src->maxFALL;
538
+ dst->log2MaxPocLsb = src->log2MaxPocLsb;
539
+ dst->bEmitVUIHRDInfo = src->bEmitVUIHRDInfo;
540
+ dst->bEmitVUITimingInfo = src->bEmitVUITimingInfo;
541
+ dst->maxSlices = src->maxSlices;
542
+ dst->bOptQpPPS = src->bOptQpPPS;
543
+ dst->bOptRefListLengthPPS = src->bOptRefListLengthPPS;
544
+ dst->bMultiPassOptRPS = src->bMultiPassOptRPS;
545
+ dst->scenecutBias = src->scenecutBias;
546
+ dst->gopLookahead = src->lookaheadDepth;
547
+ dst->bOptCUDeltaQP = src->bOptCUDeltaQP;
548
+ dst->analysisMultiPassDistortion = src->analysisMultiPassDistortion;
549
+ dst->analysisMultiPassRefine = src->analysisMultiPassRefine;
550
+ dst->bAQMotion = src->bAQMotion;
551
+ dst->bSsimRd = src->bSsimRd;
552
+ dst->dynamicRd = src->dynamicRd;
553
+ dst->bEmitHDRSEI = src->bEmitHDRSEI;
554
+ dst->bEmitHRDSEI = src->bEmitHRDSEI;
555
+ dst->bHDROpt = src->bHDROpt;
556
+ dst->analysisReuseLevel = src->analysisReuseLevel;
557
+ dst->bLimitSAO = src->bLimitSAO;
558
+ if (src->toneMapFile) dst->toneMapFile = strdup(src->toneMapFile);
559
+ else dst->toneMapFile = NULL;
560
+ dst->bDhdr10opt = src->bDhdr10opt;
561
+ dst->bCTUInfo = src->bCTUInfo;
562
+ dst->bUseRcStats = src->bUseRcStats;
563
+ dst->interRefine = src->interRefine;
564
+ dst->intraRefine = src->intraRefine;
565
+ dst->mvRefine = src->mvRefine;
566
+ dst->maxLog2CUSize = src->maxLog2CUSize;
567
+ dst->maxCUDepth = src->maxCUDepth;
568
+ dst->unitSizeDepth = src->unitSizeDepth;
569
+ dst->num4x4Partitions = src->num4x4Partitions;
570
+
571
+ dst->csvfpt = src->csvfpt;
572
+ dst->bEnableSplitRdSkip = src->bEnableSplitRdSkip;
573
+ dst->bUseAnalysisFile = src->bUseAnalysisFile;
574
+ dst->forceFlush = src->forceFlush;
575
+ dst->bDisableLookahead = src->bDisableLookahead;
576
+ dst->bLowPassDct = src->bLowPassDct;
577
+ dst->vbvBufferEnd = src->vbvBufferEnd;
578
+ dst->vbvEndFrameAdjust = src->vbvEndFrameAdjust;
579
+
580
+ dst->bCopyPicToFrame = src->bCopyPicToFrame;
581
+ if (src->analysisSave) dst->analysisSave=strdup(src->analysisSave);
582
+ else dst->analysisSave = NULL;
583
+ if (src->analysisLoad) dst->analysisLoad=strdup(src->analysisLoad);
584
+ else dst->analysisLoad = NULL;
585
+ dst->gopLookahead = src->gopLookahead;
586
+ dst->radl = src->radl;
587
+ dst->maxAUSizeFactor = src->maxAUSizeFactor;
588
+ dst->bEmitIDRRecoverySEI = src->bEmitIDRRecoverySEI;
589
+ dst->bDynamicRefine = src->bDynamicRefine;
590
+ dst->bSingleSeiNal = src->bSingleSeiNal;
591
+ dst->chunkStart = src->chunkStart;
592
+ dst->chunkEnd = src->chunkEnd;
593
+ if (src->naluFile) dst->naluFile=strdup(src->naluFile);
594
+ else dst->naluFile = NULL;
595
+ dst->scaleFactor = src->scaleFactor;
596
+ dst->ctuDistortionRefine = src->ctuDistortionRefine;
597
+ dst->bEnableHRDConcatFlag = src->bEnableHRDConcatFlag;
598
+ dst->dolbyProfile = src->dolbyProfile;
599
+ dst->bEnableSvtHevc = src->bEnableSvtHevc;
600
+ dst->bEnableFades = src->bEnableFades;
601
+ dst->bField = src->bField;
602
+
603
+#ifdef SVT_HEVC
604
+ memcpy(dst->svtHevcParam, src->svtHevcParam, sizeof(EB_H265_ENC_CONFIGURATION));
605
+#endif
606
+}
607
+
608
+#ifdef SVT_HEVC
609
+
610
+void svt_param_default(x265_param* param)
611
+{
612
+ EB_H265_ENC_CONFIGURATION* svtHevcParam = (EB_H265_ENC_CONFIGURATION*)param->svtHevcParam;
613
+
614
+ // Channel info
615
+ svtHevcParam->channelId = 0;
616
+ svtHevcParam->activeChannelCount = 0;
617
+
618
+ // GOP Structure
619
+ svtHevcParam->intraPeriodLength = -2;
620
+ svtHevcParam->intraRefreshType = 1;
621
+ svtHevcParam->predStructure = 2;
622
+ svtHevcParam->baseLayerSwitchMode = 0;
623
+ svtHevcParam->hierarchicalLevels = 3;
624
+ svtHevcParam->sourceWidth = 0;
625
+ svtHevcParam->sourceHeight = 0;
626
+ svtHevcParam->latencyMode = 0;
627
+
628
+ //Preset & Tune
629
+ svtHevcParam->encMode = 9;
630
+ svtHevcParam->tune = 0;
631
+
632
+ // Interlaced Video
633
+ svtHevcParam->interlacedVideo = 0;
634
+
635
+ // Quantization
636
+ svtHevcParam->qp = 32;
637
+ svtHevcParam->useQpFile = 0;
638
+
639
+ // Deblock Filter
640
+ svtHevcParam->disableDlfFlag = 0;
641
+
642
+ // SAO
643
+ svtHevcParam->enableSaoFlag = 1;
644
+
645
+ // ME Tools
646
+ svtHevcParam->useDefaultMeHme = 1;
647
+ svtHevcParam->enableHmeFlag = 1;
648
+
649
+ // ME Parameters
650
+ svtHevcParam->searchAreaWidth = 16;
651
+ svtHevcParam->searchAreaHeight = 7;
652
+
653
+ // MD Parameters
654
+ svtHevcParam->constrainedIntra = 0;
655
+
656
+ // Rate Control
657
+ svtHevcParam->frameRate = 60;
658
+ svtHevcParam->frameRateNumerator = 0;
659
+ svtHevcParam->frameRateDenominator = 0;
660
+ svtHevcParam->encoderBitDepth = 8;
661
+ svtHevcParam->encoderColorFormat = EB_YUV420;
662
+ svtHevcParam->compressedTenBitFormat = 0;
663
+ svtHevcParam->rateControlMode = 0;
664
+ svtHevcParam->sceneChangeDetection = 1;
665
+ svtHevcParam->lookAheadDistance = (uint32_t)~0;
666
+ svtHevcParam->framesToBeEncoded = 0;
667
+ svtHevcParam->targetBitRate = 7000000;
668
+ svtHevcParam->maxQpAllowed = 48;
669
+ svtHevcParam->minQpAllowed = 10;
670
+ svtHevcParam->bitRateReduction = 1;
671
+
672
+ // Thresholds
673
+ svtHevcParam->improveSharpness = 1;
674
+ svtHevcParam->videoUsabilityInfo = 0;
675
+ svtHevcParam->highDynamicRangeInput = 0;
676
+ svtHevcParam->accessUnitDelimiter = 0;
677
+ svtHevcParam->bufferingPeriodSEI = 0;
678
+ svtHevcParam->pictureTimingSEI = 0;
679
+ svtHevcParam->registeredUserDataSeiFlag = 0;
680
+ svtHevcParam->unregisteredUserDataSeiFlag = 0;
681
+ svtHevcParam->recoveryPointSeiFlag = 0;
682
+ svtHevcParam->enableTemporalId = 1;
683
+ svtHevcParam->profile = 2;
684
+ svtHevcParam->tier = 0;
685
+ svtHevcParam->level = 0;
686
+
687
+ svtHevcParam->injectorFrameRate = 60 << 16;
688
+ svtHevcParam->speedControlFlag = 0;
689
+
690
+ // ASM Type
691
+ svtHevcParam->asmType = 1;
692
+
693
+ svtHevcParam->codeVpsSpsPps = 1;
694
+ svtHevcParam->codeEosNal = 0;
695
+ svtHevcParam->reconEnabled = 0;
696
+ svtHevcParam->maxCLL = 0;
697
+ svtHevcParam->maxFALL = 0;
698
+ svtHevcParam->useMasteringDisplayColorVolume = 0;
699
+ svtHevcParam->useNaluFile = 0;
700
+ svtHevcParam->whitePointX = 0;
701
+ svtHevcParam->whitePointY = 0;
702
+ svtHevcParam->maxDisplayMasteringLuminance = 0;
703
+ svtHevcParam->minDisplayMasteringLuminance = 0;
704
+ svtHevcParam->dolbyVisionProfile = 0;
705
+ svtHevcParam->targetSocket = -1;
706
+ svtHevcParam->logicalProcessors = 0;
707
+ svtHevcParam->switchThreadsToRtPriority = 1;
708
+ svtHevcParam->fpsInVps = 0;
709
+
710
+ svtHevcParam->tileColumnCount = 1;
711
+ svtHevcParam->tileRowCount = 1;
712
+ svtHevcParam->tileSliceMode = 0;
713
+ svtHevcParam->unrestrictedMotionVector = 1;
714
+}
715
+
716
+int svt_set_preset_tune(x265_param* param, const char* preset, const char* tune)
717
+{
718
+ EB_H265_ENC_CONFIGURATION* svtHevcParam = (EB_H265_ENC_CONFIGURATION*)param->svtHevcParam;
719
+
720
+ if (preset)
721
+ {
722
+ if (!strcmp(preset, "ultrafast")) svtHevcParam->encMode = 12;
723
+ else if (!strcmp(preset, "superfast")) svtHevcParam->encMode = 11;
724
+ else if (!strcmp(preset, "veryfast")) svtHevcParam->encMode = 10;
725
+ else if (!strcmp(preset, "faster")) svtHevcParam->encMode = 9;
726
+ else if (!strcmp(preset, "fast")) svtHevcParam->encMode = 8;
727
+ else if (!strcmp(preset, "medium")) svtHevcParam->encMode = 7;
728
+ else if (!strcmp(preset, "slow")) svtHevcParam->encMode = 6;
729
+ else if (!strcmp(preset, "slower")) svtHevcParam->encMode = 5;
730
+ else if (!strcmp(preset, "veryslow")) svtHevcParam->encMode = 4;
731
+ else if (!strcmp(preset, "placebo")) svtHevcParam->encMode = 3;
732
+ else return -1;
733
+ }
734
+ if (tune)
735
+ {
736
+ if (!strcmp(tune, "psnr")) svtHevcParam->tune = 1;
737
+ else if (!strcmp(tune, "ssim")) svtHevcParam->tune = 1;
738
+ else if (!strcmp(tune, "grain")) svtHevcParam->tune = 0;
739
+ else if (!strcmp(tune, "animation")) svtHevcParam->tune = 0;
740
+ else if (!strcmp(tune, "vmaf")) svtHevcParam->tune = 2;
741
+ else if (!strcmp(tune, "zero-latency") || !strcmp(tune, "zerolatency")) svtHevcParam->latencyMode = 1;
742
+ else return -1;
743
+ }
744
+ return 0;
745
+}
746
+
747
+int svt_param_parse(x265_param* param, const char* name, const char* value)
748
+{
749
+ bool bError = false;
750
+#define OPT(STR) else if (!strcmp(name, STR))
751
+
752
+ EB_H265_ENC_CONFIGURATION* svtHevcParam = (EB_H265_ENC_CONFIGURATION*)param->svtHevcParam;
753
+ if (0);
754
+ OPT("input-res") bError |= sscanf(value, "%dx%d", &svtHevcParam->sourceWidth, &svtHevcParam->sourceHeight) != 2;
755
+ OPT("input-depth") svtHevcParam->encoderBitDepth = atoi(value);
756
+ OPT("total-frames") svtHevcParam->framesToBeEncoded = atoi(value);
757
+ OPT("frames") svtHevcParam->framesToBeEncoded = atoi(value);
758
+ OPT("fps")
759
+ {
760
+ if (sscanf(value, "%u/%u", &svtHevcParam->frameRateNumerator, &svtHevcParam->frameRateDenominator) == 2)
761
+ ;
762
+ else
763
+ {
764
+ int fps = atoi(value);
765
+ svtHevcParam->frameRateDenominator = 1;
766
+
767
+ if (fps < 1000)
768
+ svtHevcParam->frameRate = fps << 16;
769
+ else
770
+ svtHevcParam->frameRate = fps;
771
+ }
772
+ }
773
+ OPT2("level-idc", "level")
774
+ {
775
+ /* allow "5.1" or "51", both converted to integer 51 */
776
+ /* if level-idc specifies an obviously wrong value in either float or int,
777
+ throw error consistently. Stronger level checking will be done in encoder_open() */
778
+ if (atof(value) < 10)
779
+ svtHevcParam->level = (int)(10 * atof(value) + .5);
780
+ else if (atoi(value) < 100)
781
+ svtHevcParam->level = atoi(value);
782
+ else
783
+ bError = true;
784
+ }
785
+ OPT2("pools", "numa-pools")
786
+ {
787
+ char *pools = strdup(value);
788
+ char *temp1, *temp2;
789
+ int count = 0;
790
+
791
+ for (temp1 = strstr(pools, ","); temp1 != NULL; temp1 = strstr(temp2, ","))
792
+ {
793
+ temp2 = ++temp1;
794
+ count++;
795
+ }
796
+
797
+ if (count > 1)
798
+ x265_log(param, X265_LOG_WARNING, "SVT-HEVC Encoder supports pools option only upto 2 sockets \n");
799
+ else if (count == 1)
800
+ {
801
+ temp1 = strtok(pools, ",");
802
+ temp2 = strtok(NULL, ",");
803
+
804
+ if (!strcmp(temp1, "+"))
805
+ {
806
+ if (!strcmp(temp2, "+")) svtHevcParam->targetSocket = -1;
807
+ else if (!strcmp(temp2, "-")) svtHevcParam->targetSocket = 0;
808
+ else svtHevcParam->targetSocket = -1;
809
+ }
810
+ else if (!strcmp(temp1, "-"))
811
+ {
812
+ if (!strcmp(temp2, "+")) svtHevcParam->targetSocket = 1;
813
+ else if (!strcmp(temp2, "-")) x265_log(param, X265_LOG_ERROR, "Shouldn't exclude both sockets for pools option %s \n", pools);
814
+ else if (!strcmp(temp2, "*")) svtHevcParam->targetSocket = 1;
815
+ else
816
+ {
817
+ svtHevcParam->targetSocket = 1;
818
+ svtHevcParam->logicalProcessors = atoi(temp2);
819
+ }
820
+ }
821
+ else svtHevcParam->targetSocket = -1;
822
+ }
823
+ else
824
+ {
825
+ if (!strcmp(temp1, "*")) svtHevcParam->targetSocket = -1;
826
+ else
827
+ {
828
+ svtHevcParam->targetSocket = 0;
829
+ svtHevcParam->logicalProcessors = atoi(temp1);
830
+ }
831
+ }
832
+ }
833
+ OPT("high-tier") svtHevcParam->tier = x265_atobool(value, bError);
834
+ OPT("qpmin") svtHevcParam->minQpAllowed = atoi(value);
835
+ OPT("qpmax") svtHevcParam->maxQpAllowed = atoi(value);
836
+ OPT("rc-lookahead") svtHevcParam->lookAheadDistance = atoi(value);
837
+ OPT("scenecut")
838
+ {
839
+ svtHevcParam->sceneChangeDetection = x265_atobool(value, bError);
840
+ if (bError || svtHevcParam->sceneChangeDetection)
841
+ {
842
+ bError = false;
843
+ svtHevcParam->sceneChangeDetection = 1;
844
+ }
845
+ }
846
+ OPT("open-gop")
847
+ {
848
+ if (x265_atobool(value, bError))
849
+ svtHevcParam->intraRefreshType = 1;
850
+ else
851
+ svtHevcParam->intraRefreshType = 2;
852
+ }
853
+ OPT("deblock")
854
+ {
855
+ if (strtol(value, NULL, 0))
856
+ svtHevcParam->disableDlfFlag = 0;
857
+ else if (x265_atobool(value, bError) == 0 && !bError)
858
+ svtHevcParam->disableDlfFlag = 1;
859
+ }
860
+ OPT("sao") svtHevcParam->enableSaoFlag = (uint8_t)x265_atobool(value, bError);
861
+ OPT("keyint") svtHevcParam->intraPeriodLength = atoi(value);
862
+ OPT2("constrained-intra", "cip") svtHevcParam->constrainedIntra = (uint8_t)x265_atobool(value, bError);
863
+ OPT("vui-timing-info") svtHevcParam->videoUsabilityInfo = x265_atobool(value, bError);
864
+ OPT("hdr") svtHevcParam->highDynamicRangeInput = x265_atobool(value, bError);
865
+ OPT("aud") svtHevcParam->accessUnitDelimiter = x265_atobool(value, bError);
866
+ OPT("qp")
867
+ {
868
+ svtHevcParam->rateControlMode = 0;
869
+ svtHevcParam->qp = atoi(value);
870
+ }
871
+ OPT("bitrate")
872
+ {
873
+ svtHevcParam->rateControlMode = 1;
874
+ svtHevcParam->targetBitRate = atoi(value);
875
+ }
876
+ OPT("interlace")
877
+ {
878
+ svtHevcParam->interlacedVideo = (uint8_t)x265_atobool(value, bError);
879
+ if (bError || svtHevcParam->interlacedVideo)
880
+ {
881
+ bError = false;
882
+ svtHevcParam->interlacedVideo = 1;
883
+ }
884
+ }
885
+ OPT("svt-hme")
886
+ {
887
+ svtHevcParam->enableHmeFlag = (uint8_t)x265_atobool(value, bError);
888
+ if (svtHevcParam->enableHmeFlag) svtHevcParam->useDefaultMeHme = 1;
889
+ }
890
+ OPT("svt-search-width") svtHevcParam->searchAreaWidth = atoi(value);
891
+ OPT("svt-search-height") svtHevcParam->searchAreaHeight = atoi(value);
892
+ OPT("svt-compressed-ten-bit-format") svtHevcParam->compressedTenBitFormat = x265_atobool(value, bError);
893
+ OPT("svt-speed-control") svtHevcParam->speedControlFlag = x265_atobool(value, bError);
894
+ OPT("svt-preset-tuner")
895
+ {
896
+ if (svtHevcParam->encMode == 3)
897
+ {
898
+ if (!strcmp(value, "0")) svtHevcParam->encMode = 0;
899
+ else if (!strcmp(value, "1")) svtHevcParam->encMode = 1;
900
+ else if (!strcmp(value, "2")) svtHevcParam->encMode = 2;
901
+ else
902
+ {
903
+ x265_log(param, X265_LOG_ERROR, " Unsupported value=%s for svt-preset-tuner \n", value);
904
+ bError = true;
905
+ }
906
+ }
907
+ else
908
+ x265_log(param, X265_LOG_WARNING, " svt-preset-tuner should be used only with ultrafast preset; Ignoring it \n");
909
+ }
910
+ OPT("svt-hierarchical-level") svtHevcParam->hierarchicalLevels = atoi(value);
911
+ OPT("svt-base-layer-switch-mode") svtHevcParam->baseLayerSwitchMode = atoi(value);
912
+ OPT("svt-pred-struct") svtHevcParam->predStructure = (uint8_t)atoi(value);
913
+ OPT("svt-fps-in-vps") svtHevcParam->fpsInVps = (uint8_t)x265_atobool(value, bError);
914
+ OPT("master-display") svtHevcParam->useMasteringDisplayColorVolume = (uint8_t)atoi(value);
915
+ OPT("max-cll") bError |= sscanf(value, "%hu,%hu", &svtHevcParam->maxCLL, &svtHevcParam->maxFALL) != 2;
916
+ OPT("nalu-file") svtHevcParam->useNaluFile = (uint8_t)atoi(value);
917
+ OPT("dolby-vision-profile")
918
+ {
919
+ if (atof(value) < 10)
920
+ svtHevcParam->dolbyVisionProfile = (int)(10 * atof(value) + .5);
921
+ else if (atoi(value) < 100)
922
+ svtHevcParam->dolbyVisionProfile = atoi(value);
923
+ else
924
+ bError = true;
925
+ }
926
+ else
927
+ x265_log(param, X265_LOG_INFO, "SVT doesn't support %s param; Disabling it \n", name);
928
+
929
+
930
+ return bError ? X265_PARAM_BAD_VALUE : 0;
931
+}
932
+
933
+#endif //ifdef SVT_HEVC
934
+
935
}
936
x265_3.0.tar.gz/source/common/param.h -> x265_3.1.1.tar.gz/source/common/param.h
Changed
9
1
2
void setParamAspectRatio(x265_param *p, int width, int height);
3
void getParamAspectRatio(x265_param *p, int& width, int& height);
4
bool parseLambdaFile(x265_param *param);
5
+void x265_copy_params(x265_param* dst, x265_param* src);
6
7
/* this table is kept internal to avoid confusion, since log level indices start at -1 */
8
static const char * const logLevelNames[] = { "none", "error", "warning", "info", "debug", "full", 0 };
9
x265_3.0.tar.gz/source/common/pixel.cpp -> x265_3.1.1.tar.gz/source/common/pixel.cpp
Changed
63
1
2
}
3
}
4
5
+template<int log2TrSize>
6
+static void ssimDist_c(const pixel* fenc, uint32_t fStride, const pixel* recon, intptr_t rstride, uint64_t *ssBlock, int shift, uint64_t *ac_k)
7
+{
8
+ *ssBlock = 0;
9
+ int trSize = 1 << log2TrSize;
10
+ for (int y = 0; y < trSize; y++)
11
+ {
12
+ for (int x = 0; x < trSize; x++)
13
+ {
14
+ int temp = fenc[y * fStride + x] - recon[y * rstride + x]; // copy of residual coeff
15
+ *ssBlock += temp * temp;
16
+ }
17
+ }
18
+
19
+ *ac_k = 0;
20
+ for (int block_yy = 0; block_yy < trSize; block_yy += 1)
21
+ {
22
+ for (int block_xx = 0; block_xx < trSize; block_xx += 1)
23
+ {
24
+ uint32_t temp = fenc[block_yy * fStride + block_xx] >> shift;
25
+ *ac_k += temp * temp;
26
+ }
27
+ }
28
+}
29
+
30
+static void normFact_c(const pixel* src, uint32_t blockSize, int shift, uint64_t *z_k)
31
+{
32
+ *z_k = 0;
33
+ for (uint32_t block_yy = 0; block_yy < blockSize; block_yy += 1)
34
+ {
35
+ for (uint32_t block_xx = 0; block_xx < blockSize; block_xx += 1)
36
+ {
37
+ uint32_t temp = src[block_yy * blockSize + block_xx] >> shift;
38
+ *z_k += temp * temp;
39
+ }
40
+ }
41
+}
42
+
43
#if HIGH_BIT_DEPTH
44
static pixel planeClipAndMax_c(pixel *src, intptr_t stride, int width, int height, uint64_t *outsum,
45
const pixel minPix, const pixel maxPix)
46
47
p.propagateCost = estimateCUPropagateCost;
48
p.fix8Unpack = cuTreeFix8Unpack;
49
p.fix8Pack = cuTreeFix8Pack;
50
+
51
+ p.cu[BLOCK_4x4].ssimDist = ssimDist_c<2>;
52
+ p.cu[BLOCK_8x8].ssimDist = ssimDist_c<3>;
53
+ p.cu[BLOCK_16x16].ssimDist = ssimDist_c<4>;
54
+ p.cu[BLOCK_32x32].ssimDist = ssimDist_c<5>;
55
+ p.cu[BLOCK_64x64].ssimDist = ssimDist_c<6>;
56
+
57
+ p.cu[BLOCK_8x8].normFact = normFact_c;
58
+ p.cu[BLOCK_16x16].normFact = normFact_c;
59
+ p.cu[BLOCK_32x32].normFact = normFact_c;
60
+ p.cu[BLOCK_64x64].normFact = normFact_c;
61
}
62
}
63
x265_3.0.tar.gz/source/common/primitives.h -> x265_3.1.1.tar.gz/source/common/primitives.h
Changed
19
1
2
typedef void(*psyRdoQuant_t)(int16_t *m_resiDctCoeff, int16_t *m_fencDctCoeff, int64_t *costUncoded, int64_t *totalUncodedCost, int64_t *totalRdCost, int64_t *psyScale, uint32_t blkPos);
3
typedef void(*psyRdoQuant_t1)(int16_t *m_resiDctCoeff, int64_t *costUncoded, int64_t *totalUncodedCost, int64_t *totalRdCost,uint32_t blkPos);
4
typedef void(*psyRdoQuant_t2)(int16_t *m_resiDctCoeff, int16_t *m_fencDctCoeff, int64_t *costUncoded, int64_t *totalUncodedCost, int64_t *totalRdCost, int64_t *psyScale, uint32_t blkPos);
5
+typedef void(*ssimDistortion_t)(const pixel *fenc, uint32_t fStride, const pixel *recon, intptr_t rstride, uint64_t *ssBlock, int shift, uint64_t *ac_k);
6
+typedef void(*normFactor_t)(const pixel *src, uint32_t blockSize, int shift, uint64_t *z_k);
7
/* Function pointers to optimized encoder primitives. Each pointer can reference
8
* either an assembly routine, a SIMD intrinsic primitive, or a C function */
9
struct EncoderPrimitives
10
11
psyRdoQuant_t psyRdoQuant;
12
psyRdoQuant_t1 psyRdoQuant_1p;
13
psyRdoQuant_t2 psyRdoQuant_2p;
14
+ ssimDistortion_t ssimDist;
15
+ normFactor_t normFact;
16
}
17
cu[NUM_CU_SIZES];
18
/* These remaining primitives work on either fixed block sizes or take
19
x265_3.0.tar.gz/source/common/quant.cpp -> x265_3.1.1.tar.gz/source/common/quant.cpp
Changed
35
1
2
3
// Calculation of (X(k) - Y(k)) * (X(k) - Y(k)), AC
4
ssBlock = 0;
5
- for (int y = 0; y < trSize; y++)
6
- {
7
- for (int x = 0; x < trSize; x++)
8
- {
9
- int temp = fenc[y * fStride + x] - recon[y * rstride + x]; // copy of residual coeff
10
- ssBlock += temp * temp;
11
- }
12
- }
13
-
14
+ uint64_t ac_k = 0;
15
+ primitives.cu[log2TrSize - 2].ssimDist(fenc, fStride, recon, rstride, &ssBlock, shift, &ac_k);
16
ssAc = ssBlock - ssDc;
17
18
// 1. Calculation of fdc'
19
20
uint64_t fAc_num = 0;
21
22
// 2. Calculate ac component
23
- uint64_t ac_k = 0;
24
- for (int block_yy = 0; block_yy < trSize; block_yy += 1)
25
- {
26
- for (int block_xx = 0; block_xx < trSize; block_xx += 1)
27
- {
28
- uint32_t temp = fenc[block_yy * fStride + block_xx] >> shift;
29
- ac_k += temp * temp;
30
- }
31
- }
32
ac_k -= dc_k;
33
34
double s = 1 + 0.005 * cu.m_qp[absPartIdx];
35
x265_3.0.tar.gz/source/common/slice.h -> x265_3.1.1.tar.gz/source/common/slice.h
Changed
17
1
2
int numRefIdxDefault[2];
3
int m_iNumRPSInSPS;
4
const x265_param *m_param;
5
+ int m_fieldNum;
6
7
Slice()
8
{
9
10
numRefIdxDefault[1] = 1;
11
m_rpsIdx = -1;
12
m_chromaQpOffset[0] = m_chromaQpOffset[1] = 0;
13
+ m_fieldNum = 0;
14
}
15
16
void disableWeights();
17
x265_3.0.tar.gz/source/common/x86/asm-primitives.cpp -> x265_3.1.1.tar.gz/source/common/x86/asm-primitives.cpp
Changed
46
1
2
p.cu[BLOCK_16x16].psyRdoQuant_1p = PFX(psyRdoQuant_1p16_avx2);
3
p.cu[BLOCK_32x32].psyRdoQuant_1p = PFX(psyRdoQuant_1p32_avx2);
4
5
+ p.cu[BLOCK_4x4].ssimDist = PFX(ssimDist4_avx2);
6
+ p.cu[BLOCK_8x8].ssimDist = PFX(ssimDist8_avx2);
7
+ p.cu[BLOCK_16x16].ssimDist = PFX(ssimDist16_avx2);
8
+ p.cu[BLOCK_32x32].ssimDist = PFX(ssimDist32_avx2);
9
+ p.cu[BLOCK_64x64].ssimDist = PFX(ssimDist64_avx2);
10
+
11
+ p.cu[BLOCK_8x8].normFact = PFX(normFact8_avx2);
12
+ p.cu[BLOCK_16x16].normFact = PFX(normFact16_avx2);
13
+ p.cu[BLOCK_32x32].normFact = PFX(normFact32_avx2);
14
+ p.cu[BLOCK_64x64].normFact = PFX(normFact64_avx2);
15
+
16
/* TODO: This kernel needs to be modified to work with HIGH_BIT_DEPTH only
17
p.planeClipAndMax = PFX(planeClipAndMax_avx2); */
18
19
20
p.pu[LUMA_32x24].pixelavg_pp[ALIGNED] = PFX(pixel_avg_aligned_32x24_avx512);
21
p.pu[LUMA_32x32].pixelavg_pp[ALIGNED] = PFX(pixel_avg_aligned_32x32_avx512);
22
p.pu[LUMA_32x64].pixelavg_pp[ALIGNED] = PFX(pixel_avg_aligned_32x64_avx512);
23
- p.pu[LUMA_48x64].pixelavg_pp[ALIGNED] = PFX(pixel_avg_aligned_48x64_avx512);
24
+ //p.pu[LUMA_48x64].pixelavg_pp[ALIGNED] = PFX(pixel_avg_aligned_48x64_avx512);
25
p.pu[LUMA_64x16].pixelavg_pp[ALIGNED] = PFX(pixel_avg_aligned_64x16_avx512);
26
p.pu[LUMA_64x32].pixelavg_pp[ALIGNED] = PFX(pixel_avg_aligned_64x32_avx512);
27
p.pu[LUMA_64x48].pixelavg_pp[ALIGNED] = PFX(pixel_avg_aligned_64x48_avx512);
28
29
p.cu[BLOCK_16x16].psyRdoQuant_1p = PFX(psyRdoQuant_1p16_avx2);
30
p.cu[BLOCK_32x32].psyRdoQuant_1p = PFX(psyRdoQuant_1p32_avx2);
31
32
+ p.cu[BLOCK_4x4].ssimDist = PFX(ssimDist4_avx2);
33
+ p.cu[BLOCK_8x8].ssimDist = PFX(ssimDist8_avx2);
34
+ p.cu[BLOCK_16x16].ssimDist = PFX(ssimDist16_avx2);
35
+ p.cu[BLOCK_32x32].ssimDist = PFX(ssimDist32_avx2);
36
+ p.cu[BLOCK_64x64].ssimDist = PFX(ssimDist64_avx2);
37
+
38
+ p.cu[BLOCK_8x8].normFact = PFX(normFact8_avx2);
39
+ p.cu[BLOCK_16x16].normFact = PFX(normFact16_avx2);
40
+ p.cu[BLOCK_32x32].normFact = PFX(normFact32_avx2);
41
+ p.cu[BLOCK_64x64].normFact = PFX(normFact64_avx2);
42
+
43
}
44
if (cpuMask & X265_CPU_AVX512)
45
{
46
x265_3.0.tar.gz/source/common/x86/pixel-a.asm -> x265_3.1.1.tar.gz/source/common/x86/pixel-a.asm
Changed
717
1
2
cextern pb_movemask_32
3
cextern pw_pixel_max
4
5
+%if BIT_DEPTH == 12
6
+ %define SSIMRD_SHIFT 4
7
+%elif BIT_DEPTH == 10
8
+ %define SSIMRD_SHIFT 2
9
+%elif BIT_DEPTH == 8
10
+ %define SSIMRD_SHIFT 0
11
+%else
12
+ %error Unsupported BIT_DEPTH!
13
+%endif
14
+
15
;=============================================================================
16
; SATD
17
;=============================================================================
18
19
RET
20
%endmacro
21
22
+%macro SSIM_DIST_HIGH 2
23
+ vpsrld m6, m0, SSIMRD_SHIFT
24
+ vpsubd m0, m1
25
+
26
+ vpmuldq m2, m0, m0
27
+ vpsrldq m0, m0, 4
28
+ vpmuldq m0, m0, m0
29
+ vpaddq m0, m2
30
+
31
+ vpmuldq m2, m6, m6
32
+ vpsrldq m6, m6, 4
33
+ vpmuldq m6, m6, m6
34
+ vpaddq m6, m2
35
+
36
+ vpaddq m4, m0
37
+ vpaddq m7, m6
38
+%endmacro
39
+
40
+%macro NORM_FACT_HIGH 1
41
+ vpsrld m1, m0, SSIMRD_SHIFT
42
+ vpmuldq m2, m1, m1
43
+ vpsrldq m1, m1, 4
44
+ vpmuldq m1, m1, m1
45
+
46
+ vpaddq m1, m2
47
+ vpaddq m3, m1
48
+%endmacro
49
+
50
+%macro SSIM_DIST_LOW 2
51
+ vpsrlw m6, m0, SSIMRD_SHIFT
52
+ vpsubw m0, m1
53
+
54
+ vpmaddwd m0, m0, m0
55
+ vpmaddwd m6, m6, m6
56
+
57
+ vpaddd m4, m0
58
+ vpaddd m7, m6
59
+%endmacro
60
+
61
+%macro NORM_FACT_LOW 1
62
+ vpsrlw m1, m0, SSIMRD_SHIFT
63
+ vpmaddwd m1, m1, m1
64
+ vpaddd m3, m1
65
+%endmacro
66
+
67
; FIXME avoid the spilling of regs to hold 3*stride.
68
; for small blocks on x86_32, modify pixel pointer instead.
69
70
71
RET
72
%endif
73
%endif ; HIGH_BIT_DEPTH == 1 && BIT_DEPTH == 10
74
+
75
+;template<int log2TrSize>
76
+;static void ssimDist_c(const pixel* fenc, uint32_t fStride, const pixel* recon, intptr_t rstride, uint64_t *ssBlock, int shift, uint64_t *ac_k)
77
+;{
78
+; *ssBlock = 0;
79
+; const uint32_t trSize = 1 << log2TrSize;
80
+; for (int y = 0; y < trSize; y++)
81
+; {
82
+; for (int x = 0; x < trSize; x++)
83
+; {
84
+; int temp = fenc[y * fStride + x] - recon[y * rstride + x]; // copy of residual coeff
85
+; *ssBlock += temp * temp;
86
+; }
87
+; }
88
+;
89
+; *ac_k = 0;
90
+; for (int block_yy = 0; block_yy < trSize; block_yy += 1)
91
+; {
92
+; for (int block_xx = 0; block_xx < trSize; block_xx += 1)
93
+; {
94
+; uint32_t temp = fenc[block_yy * fStride + block_xx] >> shift;
95
+; *ac_k += temp * temp;
96
+; }
97
+; }
98
+;}
99
+;-----------------------------------------------------------------------------------------------------------------
100
+; void ssimDist_c(const pixel* fenc, uint32_t fStride, const pixel* recon, intptr_t rstride, uint64_t *ssBlock, int shift, uint64_t *ac_k)
101
+;-----------------------------------------------------------------------------------------------------------------
102
+
103
+INIT_YMM avx2
104
+cglobal ssimDist4, 7, 8, 8
105
+ mov r5d, 4
106
+ vpxor m4, m4 ;ssBlock
107
+ vpxor m3, m3
108
+ vpxor m7, m7 ;ac_k
109
+.row:
110
+%if HIGH_BIT_DEPTH
111
+ vpmovzxwq m0, [r0] ;fenc
112
+ vpmovzxwq m1, [r2] ;recon
113
+%elif BIT_DEPTH == 8
114
+ vpmovzxbq m0, [r0]
115
+ vpmovzxbq m1, [r2]
116
+%else
117
+ %error Unsupported BIT_DEPTH!
118
+%endif
119
+ vpsrlq m6, m0, SSIMRD_SHIFT
120
+ vpsubq m0, m1
121
+ vpmuldq m0, m0, m0
122
+ vpmuldq m6, m6, m6
123
+ vpaddq m4, m0
124
+ vpaddq m7, m6
125
+
126
+%if HIGH_BIT_DEPTH
127
+ lea r0, [r0 + 2 * r1]
128
+ lea r2, [r2 + 2 * r3]
129
+%else
130
+ lea r0, [r0 + r1]
131
+ lea r2, [r2 + r3]
132
+%endif
133
+ dec r5d
134
+ jnz .row
135
+ vextracti128 xm5, m4, 1
136
+ vpaddq xm4, xm5
137
+ punpckhqdq xm2, xm4, xm3
138
+ paddq xm4, xm2
139
+
140
+ vextracti128 xm5, m7, 1
141
+ vpaddq xm7, xm5
142
+ punpckhqdq xm2, xm7, xm3
143
+ paddq xm7, xm2
144
+
145
+ movq [r4], xm4
146
+ movq [r6], xm7
147
+ RET
148
+
149
+
150
+INIT_YMM avx2
151
+cglobal ssimDist8, 7, 8, 8
152
+ mov r5d, 8
153
+ vpxor m4, m4 ;ssBlock
154
+ vpxor m3, m3
155
+ vpxor m7, m7 ;ac_k
156
+.row:
157
+%if HIGH_BIT_DEPTH
158
+ vpmovzxwd m0, [r0] ;fenc
159
+ vpmovzxwd m1, [r2] ;recon
160
+%elif BIT_DEPTH == 8
161
+ vpmovzxbd m0, [r0]
162
+ vpmovzxbd m1, [r2]
163
+%else
164
+ %error Unsupported BIT_DEPTH!
165
+%endif
166
+
167
+ SSIM_DIST_HIGH m0, m1
168
+
169
+%if HIGH_BIT_DEPTH
170
+ lea r0, [r0 + 2 * r1]
171
+ lea r2, [r2 + 2 * r3]
172
+%else
173
+ lea r0, [r0 + r1]
174
+ lea r2, [r2 + r3]
175
+%endif
176
+ dec r5d
177
+ jnz .row
178
+ vextracti128 xm5, m4, 1
179
+ vpaddq xm4, xm5
180
+ punpckhqdq xm2, xm4, xm3
181
+ paddq xm4, xm2
182
+
183
+ vextracti128 xm5, m7, 1
184
+ vpaddq xm7, xm5
185
+ punpckhqdq xm2, xm7, xm3
186
+ paddq xm7, xm2
187
+
188
+ movq [r4], xm4
189
+ movq [r6], xm7
190
+ RET
191
+
192
+
193
+INIT_YMM avx2
194
+cglobal ssimDist16, 7, 8, 8
195
+ mov r5d, 16
196
+ vpxor m4, m4 ;ssBlock
197
+ vpxor m3, m3
198
+ vpxor m7, m7 ;ac_k
199
+.row:
200
+%if HIGH_BIT_DEPTH
201
+;Col 1-8
202
+ vpmovzxwd m0, [r0] ;fenc
203
+ vpmovzxwd m1, [r2] ;recon
204
+
205
+ SSIM_DIST_HIGH m0, m1
206
+
207
+;Col 9-16
208
+ vpmovzxwd m0, [r0 + 16]
209
+ vpmovzxwd m1, [r2 + 16]
210
+
211
+ SSIM_DIST_HIGH m0, m1
212
+
213
+ lea r0, [r0 + 2 * r1]
214
+ lea r2, [r2 + 2 * r3]
215
+%elif BIT_DEPTH == 8
216
+;col 1- 16
217
+ vpmovzxbw m0, [r0] ;fenc
218
+ vpmovzxbw m1, [r2] ;recon
219
+
220
+ SSIM_DIST_LOW m0, m1
221
+
222
+ lea r0, [r0 + r1]
223
+ lea r2, [r2 + r3]
224
+%else
225
+ %error Unsupported BIT_DEPTH!
226
+%endif
227
+ dec r5d
228
+ jnz .row
229
+
230
+%if HIGH_BIT_DEPTH
231
+ vextracti128 xm5, m4, 1
232
+ vpaddq xm4, xm5
233
+ punpckhqdq xm2, xm4, xm3
234
+ paddq xm4, xm2
235
+
236
+ vextracti128 xm5, m7, 1
237
+ vpaddq xm7, xm5
238
+ punpckhqdq xm2, xm7, xm3
239
+ paddq xm7, xm2
240
+%else
241
+ vextracti128 xm5, m4, 1
242
+ vpaddd xm4, xm5
243
+ punpckhqdq xm2, xm4, xm3
244
+ paddd xm4, xm2
245
+ punpckldq xm4, xm4, xm3
246
+ punpckhqdq xm2, xm4, xm3
247
+ paddd xm4, xm2
248
+
249
+ vextracti128 xm5, m7, 1
250
+ vpaddd xm7, xm5
251
+ punpckhqdq xm2, xm7, xm3
252
+ paddd xm7, xm2
253
+ punpckldq xm7, xm7, xm3
254
+ punpckhqdq xm2, xm7, xm3
255
+ paddd xm7, xm2
256
+%endif
257
+ movq [r4], xm4
258
+ movq [r6], xm7
259
+ RET
260
+
261
+
262
+INIT_YMM avx2
263
+cglobal ssimDist32, 7, 8, 8
264
+ mov r5d, 32
265
+ vpxor m4, m4 ;ssBlock
266
+ vpxor m3, m3
267
+ vpxor m7, m7 ;ac_k
268
+.row:
269
+%if HIGH_BIT_DEPTH
270
+;Col 1-8
271
+ vpmovzxwd m0, [r0] ;fenc
272
+ vpmovzxwd m1, [r2] ;recon
273
+
274
+ SSIM_DIST_HIGH m0, m1
275
+
276
+;Col 9-16
277
+ vpmovzxwd m0, [r0 + 16]
278
+ vpmovzxwd m1, [r2 + 16]
279
+
280
+ SSIM_DIST_HIGH m0, m1
281
+
282
+;Col 17-24
283
+ vpmovzxwd m0, [r0 + 32]
284
+ vpmovzxwd m1, [r2 + 32]
285
+
286
+ SSIM_DIST_HIGH m0, m1
287
+
288
+;Col 25-32
289
+ vpmovzxwd m0, [r0 + 48]
290
+ vpmovzxwd m1, [r2 + 48]
291
+
292
+ SSIM_DIST_HIGH m0, m1
293
+
294
+ lea r0, [r0 + 2 * r1]
295
+ lea r2, [r2 + 2 * r3]
296
+%elif BIT_DEPTH == 8
297
+;col 1-16
298
+ vpmovzxbw m0, [r0] ;fenc
299
+ vpmovzxbw m1, [r2] ;recon
300
+
301
+ SSIM_DIST_LOW m0, m1
302
+
303
+;col 17-32
304
+ vpmovzxbw m0, [r0 + 16]
305
+ vpmovzxbw m1, [r2 + 16]
306
+
307
+ SSIM_DIST_LOW m0, m1
308
+
309
+ lea r0, [r0 + r1]
310
+ lea r2, [r2 + r3]
311
+%else
312
+ %error Unsupported BIT_DEPTH!
313
+%endif
314
+ dec r5d
315
+ jnz .row
316
+
317
+%if HIGH_BIT_DEPTH
318
+ vextracti128 xm5, m4, 1
319
+ vpaddq xm4, xm5
320
+ punpckhqdq xm2, xm4, xm3
321
+ paddq xm4, xm2
322
+
323
+ vextracti128 xm5, m7, 1
324
+ vpaddq xm7, xm5
325
+ punpckhqdq xm2, xm7, xm3
326
+ paddq xm7, xm2
327
+%else
328
+ vextracti128 xm5, m4, 1
329
+ vpaddd xm4, xm5
330
+ punpckhqdq xm2, xm4, xm3
331
+ paddd xm4, xm2
332
+ punpckldq xm4, xm4, xm3
333
+ punpckhqdq xm2, xm4, xm3
334
+ paddd xm4, xm2
335
+
336
+ vextracti128 xm5, m7, 1
337
+ vpaddd xm7, xm5
338
+ punpckhqdq xm2, xm7, xm3
339
+ paddd xm7, xm2
340
+ punpckldq xm7, xm7, xm3
341
+ punpckhqdq xm2, xm7, xm3
342
+ paddd xm7, xm2
343
+%endif
344
+ movq [r4], xm4
345
+ movq [r6], xm7
346
+ RET
347
+
348
+
349
+INIT_YMM avx2
350
+cglobal ssimDist64, 7, 8, 8
351
+ mov r5d, 64
352
+ vpxor m4, m4 ;ssBlock
353
+ vpxor m3, m3
354
+ vpxor m7, m7 ;ac_k
355
+.row:
356
+%if HIGH_BIT_DEPTH
357
+;Col 1-8
358
+ vpmovzxwd m0, [r0] ;fenc
359
+ vpmovzxwd m1, [r2] ;recon
360
+
361
+ SSIM_DIST_HIGH m0, m1
362
+
363
+;Col 9-16
364
+ vpmovzxwd m0, [r0 + 16]
365
+ vpmovzxwd m1, [r2 + 16]
366
+
367
+ SSIM_DIST_HIGH m0, m1
368
+
369
+;Col 17-24
370
+ vpmovzxwd m0, [r0 + 32]
371
+ vpmovzxwd m1, [r2 + 32]
372
+
373
+ SSIM_DIST_HIGH m0, m1
374
+
375
+;Col 25-32
376
+ vpmovzxwd m0, [r0 + 48]
377
+ vpmovzxwd m1, [r2 + 48]
378
+
379
+ SSIM_DIST_HIGH m0, m1
380
+
381
+;Col 33-40
382
+ vpmovzxwd m0, [r0 + 64]
383
+ vpmovzxwd m1, [r2 + 64]
384
+
385
+ SSIM_DIST_HIGH m0, m1
386
+
387
+;Col 41-48
388
+ vpmovzxwd m0, [r0 + 80]
389
+ vpmovzxwd m1, [r2 + 80]
390
+
391
+ SSIM_DIST_HIGH m0, m1
392
+
393
+;Col 49-56
394
+ vpmovzxwd m0, [r0 + 96]
395
+ vpmovzxwd m1, [r2 + 96]
396
+
397
+ SSIM_DIST_HIGH m0, m1
398
+
399
+;Col 57-64
400
+ vpmovzxwd m0, [r0 + 112]
401
+ vpmovzxwd m1, [r2 + 112]
402
+
403
+ SSIM_DIST_HIGH m0, m1
404
+
405
+ lea r0, [r0 + 2 * r1]
406
+ lea r2, [r2 + 2 * r3]
407
+%elif BIT_DEPTH == 8
408
+;col 1-16
409
+ vpmovzxbw m0, [r0] ;fenc
410
+ vpmovzxbw m1, [r2] ;recon
411
+
412
+ SSIM_DIST_LOW m0, m1
413
+
414
+;col 17-32
415
+ vpmovzxbw m0, [r0 + 16]
416
+ vpmovzxbw m1, [r2 + 16]
417
+
418
+ SSIM_DIST_LOW m0, m1
419
+
420
+;col 33-48
421
+ vpmovzxbw m0, [r0 + 32]
422
+ vpmovzxbw m1, [r2 + 32]
423
+
424
+ SSIM_DIST_LOW m0, m1
425
+
426
+;col 49-64
427
+ vpmovzxbw m0, [r0 + 48]
428
+ vpmovzxbw m1, [r2 + 48]
429
+
430
+ SSIM_DIST_LOW m0, m1
431
+
432
+ lea r0, [r0 + r1]
433
+ lea r2, [r2 + r3]
434
+%endif
435
+ dec r5d
436
+ jnz .row
437
+
438
+%if HIGH_BIT_DEPTH
439
+ vextracti128 xm5, m4, 1
440
+ vpaddq xm4, xm5
441
+ punpckhqdq xm2, xm4, xm3
442
+ paddq xm4, xm2
443
+
444
+ vextracti128 xm5, m7, 1
445
+ vpaddq xm7, xm5
446
+ punpckhqdq xm2, xm7, xm3
447
+ paddq xm7, xm2
448
+%else
449
+ vextracti128 xm5, m4, 1
450
+ vpaddd xm4, xm5
451
+ punpckhqdq xm2, xm4, xm3
452
+ paddd xm4, xm2
453
+ punpckldq xm4, xm4, xm3
454
+ punpckhqdq xm2, xm4, xm3
455
+ paddd xm4, xm2
456
+
457
+ vextracti128 xm5, m7, 1
458
+ vpaddd xm7, xm5
459
+ punpckhqdq xm2, xm7, xm3
460
+ paddd xm7, xm2
461
+ punpckldq xm7, xm7, xm3
462
+ punpckhqdq xm2, xm7, xm3
463
+ paddd xm7, xm2
464
+%endif
465
+ movq [r4], xm4
466
+ movq [r6], xm7
467
+ RET
468
+
469
+
470
+;static void normFact_c(const pixel* src, uint32_t blockSize, int shift, uint64_t *z_k)
471
+;{
472
+; *z_k = 0;
473
+; for (uint32_t block_yy = 0; block_yy < blockSize; block_yy += 1)
474
+; {
475
+; for (uint32_t block_xx = 0; block_xx < blockSize; block_xx += 1)
476
+; {
477
+; uint32_t temp = src[block_yy * blockSize + block_xx] >> shift;
478
+; *z_k += temp * temp;
479
+; }
480
+; }
481
+;}
482
+;--------------------------------------------------------------------------------------
483
+; void normFact_c(const pixel* src, uint32_t blockSize, int shift, uint64_t *z_k)
484
+;--------------------------------------------------------------------------------------
485
+INIT_YMM avx2
486
+cglobal normFact8, 4, 5, 6
487
+ mov r4d, 8
488
+ vpxor m3, m3 ;z_k
489
+ vpxor m5, m5
490
+.row:
491
+%if HIGH_BIT_DEPTH
492
+ vpmovzxwd m0, [r0] ;src
493
+%elif BIT_DEPTH == 8
494
+ vpmovzxbd m0, [r0]
495
+%else
496
+ %error Unsupported BIT_DEPTH!
497
+%endif
498
+
499
+ NORM_FACT_HIGH m0
500
+
501
+%if HIGH_BIT_DEPTH
502
+ lea r0, [r0 + 2 * r1]
503
+%else
504
+ lea r0, [r0 + r1]
505
+%endif
506
+ dec r4d
507
+ jnz .row
508
+ vextracti128 xm4, m3, 1
509
+ vpaddq xm3, xm4
510
+ punpckhqdq xm2, xm3, xm5
511
+ paddq xm3, xm2
512
+ movq [r3], xm3
513
+ RET
514
+
515
+
516
+INIT_YMM avx2
517
+cglobal normFact16, 4, 5, 6
518
+ mov r4d, 16
519
+ vpxor m3, m3 ;z_k
520
+ vpxor m5, m5
521
+.row:
522
+%if HIGH_BIT_DEPTH
523
+;Col 1-8
524
+ vpmovzxwd m0, [r0] ;src
525
+
526
+ NORM_FACT_HIGH m0
527
+
528
+;Col 9-16
529
+ vpmovzxwd m0, [r0 + 16]
530
+
531
+ NORM_FACT_HIGH m0
532
+
533
+ lea r0, [r0 + 2 * r1]
534
+%elif BIT_DEPTH == 8
535
+;col 1-16
536
+ vpmovzxbw m0, [r0] ;src
537
+
538
+ NORM_FACT_LOW m0
539
+
540
+ lea r0, [r0 + r1]
541
+%else
542
+ %error Unsupported BIT_DEPTH!
543
+%endif
544
+ dec r4d
545
+ jnz .row
546
+
547
+%if HIGH_BIT_DEPTH
548
+ vextracti128 xm4, m3, 1
549
+ vpaddq xm3, xm4
550
+ punpckhqdq xm2, xm3, xm5
551
+ paddq xm3, xm2
552
+%else
553
+ vextracti128 xm4, m3, 1
554
+ vpaddd xm3, xm4
555
+ punpckhqdq xm2, xm3, xm5
556
+ paddd xm3, xm2
557
+ punpckldq xm3, xm3, xm5
558
+ punpckhqdq xm2, xm3, xm5
559
+ paddd xm3, xm2
560
+%endif
561
+ movq [r3], xm3
562
+ RET
563
+
564
+
565
+INIT_YMM avx2
566
+cglobal normFact32, 4, 5, 6
567
+ mov r4d, 32
568
+ vpxor m3, m3 ;z_k
569
+ vpxor m5, m5
570
+.row:
571
+%if HIGH_BIT_DEPTH
572
+;Col 1-8
573
+ vpmovzxwd m0, [r0] ;src
574
+
575
+ NORM_FACT_HIGH m0
576
+
577
+;Col 9-16
578
+ vpmovzxwd m0, [r0 + 16]
579
+
580
+ NORM_FACT_HIGH m0
581
+
582
+;Col 17-24
583
+ vpmovzxwd m0, [r0 + 32]
584
+
585
+ NORM_FACT_HIGH m0
586
+
587
+;Col 25-32
588
+ vpmovzxwd m0, [r0 + 48]
589
+
590
+ NORM_FACT_HIGH m0
591
+
592
+ lea r0, [r0 + 2 * r1]
593
+%elif BIT_DEPTH == 8
594
+;col 1-16
595
+ vpmovzxbw m0, [r0] ;src
596
+
597
+ NORM_FACT_LOW m0
598
+;col 17-32
599
+ vpmovzxbw m0, [r0 + 16]
600
+
601
+ NORM_FACT_LOW m0
602
+
603
+ lea r0, [r0 + r1]
604
+%else
605
+ %error Unsupported BIT_DEPTH!
606
+%endif
607
+ dec r4d
608
+ jnz .row
609
+
610
+%if HIGH_BIT_DEPTH
611
+ vextracti128 xm4, m3, 1
612
+ vpaddq xm3, xm4
613
+ punpckhqdq xm2, xm3, xm5
614
+ paddq xm3, xm2
615
+%else
616
+ vextracti128 xm4, m3, 1
617
+ vpaddd xm3, xm4
618
+ punpckhqdq xm2, xm3, xm5
619
+ paddd xm3, xm2
620
+ punpckldq xm3, xm3, xm5
621
+ punpckhqdq xm2, xm3, xm5
622
+ paddd xm3, xm2
623
+%endif
624
+ movq [r3], xm3
625
+ RET
626
+
627
+
628
+INIT_YMM avx2
629
+cglobal normFact64, 4, 5, 6
630
+ mov r4d, 64
631
+ vpxor m3, m3 ;z_k
632
+ vpxor m5, m5
633
+.row:
634
+%if HIGH_BIT_DEPTH
635
+;Col 1-8
636
+ vpmovzxwd m0, [r0] ;src
637
+
638
+ NORM_FACT_HIGH m0
639
+
640
+;Col 9-16
641
+ vpmovzxwd m0, [r0 + 16]
642
+
643
+ NORM_FACT_HIGH m0
644
+
645
+;Col 17-24
646
+ vpmovzxwd m0, [r0 + 32]
647
+
648
+ NORM_FACT_HIGH m0
649
+
650
+;Col 25-32
651
+ vpmovzxwd m0, [r0 + 48]
652
+
653
+ NORM_FACT_HIGH m0
654
+
655
+;Col 33-40
656
+ vpmovzxwd m0, [r0 + 64]
657
+
658
+ NORM_FACT_HIGH m0
659
+
660
+;Col 41-48
661
+ vpmovzxwd m0, [r0 + 80]
662
+
663
+ NORM_FACT_HIGH m0
664
+
665
+;Col 49-56
666
+ vpmovzxwd m0, [r0 + 96]
667
+
668
+ NORM_FACT_HIGH m0
669
+
670
+;Col 57-64
671
+ vpmovzxwd m0, [r0 + 112]
672
+
673
+ NORM_FACT_HIGH m0
674
+
675
+ lea r0, [r0 + 2 * r1]
676
+%elif BIT_DEPTH == 8
677
+;col 1-16
678
+ vpmovzxbw m0, [r0] ;src
679
+
680
+ NORM_FACT_LOW m0
681
+;col 17-32
682
+ vpmovzxbw m0, [r0 + 16]
683
+
684
+ NORM_FACT_LOW m0
685
+;col 33-48
686
+ vpmovzxbw m0, [r0 + 32]
687
+
688
+ NORM_FACT_LOW m0
689
+;col 49-56
690
+ vpmovzxbw m0, [r0 + 48]
691
+
692
+ NORM_FACT_LOW m0
693
+
694
+ lea r0, [r0 + r1]
695
+%else
696
+ %error Unsupported BIT_DEPTH!
697
+%endif
698
+ dec r4d
699
+ jnz .row
700
+
701
+%if HIGH_BIT_DEPTH
702
+ vextracti128 xm4, m3, 1
703
+ vpaddq xm3, xm4
704
+ punpckhqdq xm2, xm3, xm5
705
+ paddq xm3, xm2
706
+%else
707
+ vextracti128 xm4, m3, 1
708
+ vpaddd xm3, xm4
709
+ punpckhqdq xm2, xm3, xm5
710
+ paddd xm3, xm2
711
+ punpckldq xm3, xm3, xm5
712
+ punpckhqdq xm2, xm3, xm5
713
+ paddd xm3, xm2
714
+%endif
715
+ movq [r3], xm3
716
+ RET
717
x265_3.0.tar.gz/source/common/x86/pixel.h -> x265_3.1.1.tar.gz/source/common/x86/pixel.h
Changed
12
1
2
FUNCDEF_TU_S(sse_t, pixel_ssd_s_aligned, cpu, const int16_t*, intptr_t); \
3
FUNCDEF_TU(uint64_t, pixel_var, cpu, const pixel*, intptr_t); \
4
FUNCDEF_TU(int, psyCost_pp, cpu, const pixel* source, intptr_t sstride, const pixel* recon, intptr_t rstride); \
5
- FUNCDEF_TU(int, psyCost_ss, cpu, const int16_t* source, intptr_t sstride, const int16_t* recon, intptr_t rstride)
6
+ FUNCDEF_TU(int, psyCost_ss, cpu, const int16_t* source, intptr_t sstride, const int16_t* recon, intptr_t rstride); \
7
+ FUNCDEF_TU_S2(void, ssimDist, cpu, const pixel *fenc, uint32_t fStride, const pixel *recon, intptr_t rstride, uint64_t *ssBlock, int shift, uint64_t *ac_k); \
8
+ FUNCDEF_TU_S2(void, normFact, cpu, const pixel *src, uint32_t blockSize, int shift, uint64_t *z_k)
9
10
DECL_PIXELS(mmx);
11
DECL_PIXELS(mmx2);
12
x265_3.0.tar.gz/source/dynamicHDR10/metadataFromJson.cpp -> x265_3.1.1.tar.gz/source/dynamicHDR10/metadataFromJson.cpp
Changed
15
1
2
const uint16_t terminalProviderCode = 0x003C;
3
const uint16_t terminalProviderOrientedCode = 0x0001;
4
const uint8_t applicationIdentifier = 4;
5
- const uint8_t applicationVersion = 1;
6
+ uint8_t applicationVersion = 0;
7
+
8
+ if (jsonType & LLC)
9
+ {
10
+ applicationVersion = 1;
11
+ }
12
13
mPimpl->appendBits(metadata, countryCode, 8);
14
mPimpl->appendBits(metadata, terminalProviderCode, 16);
15
x265_3.0.tar.gz/source/encoder/CMakeLists.txt -> x265_3.1.1.tar.gz/source/encoder/CMakeLists.txt
Changed
7
1
2
reference.cpp reference.h
3
encoder.cpp encoder.h
4
api.cpp
5
- weightPrediction.cpp)
6
+ weightPrediction.cpp svt.h)
7
x265_3.0.tar.gz/source/encoder/analysis.cpp -> x265_3.1.1.tar.gz/source/encoder/analysis.cpp
Changed
42
1
2
bool mightSplit = !(cuGeom.flags & CUGeom::LEAF);
3
bool mightNotSplit = !(cuGeom.flags & CUGeom::SPLIT_MANDATORY);
4
bool bDecidedDepth = parentCTU.m_cuDepth[cuGeom.absPartIdx] == depth;
5
+ int split = 0;
6
7
TrainingData td;
8
td.init(parentCTU, cuGeom);
9
10
m_refineLevel = m_param->interRefine;
11
else
12
m_refineLevel = m_frame->m_classifyFrame ? 1 : 3;
13
- int split = (m_param->scaleFactor && bDecidedDepth && (!mightNotSplit ||
14
- (m_refineLevel && cuGeom.log2CUSize == (uint32_t)(g_log2Size[m_param->minCUSize] + 1))));
15
+
16
+ if (m_param->interRefine == 1)
17
+ split = (m_param->scaleFactor && bDecidedDepth && parentCTU.m_predMode[cuGeom.absPartIdx] == MODE_SKIP && (!mightNotSplit ||
18
+ (m_refineLevel && cuGeom.log2CUSize == (uint32_t)(g_log2Size[m_param->minCUSize] + 1))));
19
+ else
20
+ split = (m_param->scaleFactor && bDecidedDepth && (!mightNotSplit ||
21
+ (m_refineLevel && cuGeom.log2CUSize == (uint32_t)(g_log2Size[m_param->minCUSize] + 1))));
22
td.split = split;
23
24
if ((bDecidedDepth && mightNotSplit) || (m_param->bAnalysisType == HEVC_INFO && parentCTU.m_cuDepth[cuGeom.absPartIdx] == 4))
25
26
27
// 2. Calculate ac component
28
uint64_t z_k = 0;
29
- for (uint32_t block_yy = 0; block_yy < blockSize; block_yy += 1)
30
- {
31
- for (uint32_t block_xx = 0; block_xx < blockSize; block_xx += 1)
32
- {
33
- uint32_t temp = src[block_yy * blockSize + block_xx] >> shift;
34
- z_k += temp * temp;
35
- }
36
- }
37
+ int block = (int)(((log(blockSize) / log(2)) - 2) + 0.5);
38
+ primitives.cu[block].normFact(src, blockSize, shift, &z_k);
39
40
// Remove the DC part
41
z_k -= z_o;
42
x265_3.0.tar.gz/source/encoder/api.cpp -> x265_3.1.1.tar.gz/source/encoder/api.cpp
Changed
486
1
2
#include "level.h"
3
#include "nal.h"
4
#include "bitcost.h"
5
+#include "svt.h"
6
7
#if ENABLE_LIBVMAF
8
#include "libvmaf.h"
9
10
x265_param* zoneParam = PARAM_NS::x265_param_alloc();
11
if (!param || !latestParam)
12
goto fail;
13
+ if (p->rc.zoneCount || p->rc.zonefileCount)
14
+ {
15
+ int zoneCount = p->rc.zonefileCount ? p->rc.zonefileCount : p->rc.zoneCount;
16
+ param->rc.zones = x265_zone_alloc(zoneCount, !!p->rc.zonefileCount);
17
+ latestParam->rc.zones = x265_zone_alloc(zoneCount, !!p->rc.zonefileCount);
18
+ }
19
20
- memcpy(param, p, sizeof(x265_param));
21
+ x265_copy_params(param, p);
22
x265_log(param, X265_LOG_INFO, "HEVC encoder version %s\n", PFX(version_str));
23
x265_log(param, X265_LOG_INFO, "build info %s\n", PFX(build_info_str));
24
25
+ encoder = new Encoder;
26
+
27
+#ifdef SVT_HEVC
28
+
29
+ if (param->bEnableSvtHevc)
30
+ {
31
+ EB_ERRORTYPE return_error = EB_ErrorNone;
32
+ int ret = 0;
33
+
34
+ svt_initialise_app_context(encoder);
35
+ ret = svt_initialise_input_buffer(encoder);
36
+ if (!ret)
37
+ {
38
+ x265_log(param, X265_LOG_ERROR, "SVT-HEVC Encoder: Unable to allocate input buffer \n");
39
+ goto fail;
40
+ }
41
+
42
+ // Create Encoder Handle
43
+ return_error = EbInitHandle(&encoder->m_svtAppData->svtEncoderHandle, encoder->m_svtAppData, encoder->m_svtAppData->svtHevcParams);
44
+ if (return_error != EB_ErrorNone)
45
+ {
46
+ x265_log(param, X265_LOG_ERROR, "SVT-HEVC Encoder: Unable to initialise encoder handle \n");
47
+ goto fail;
48
+ }
49
+
50
+ memcpy(encoder->m_svtAppData->svtHevcParams, param->svtHevcParam, sizeof(EB_H265_ENC_CONFIGURATION));
51
+
52
+ // Send over all configuration parameters
53
+ return_error = EbH265EncSetParameter(encoder->m_svtAppData->svtEncoderHandle, encoder->m_svtAppData->svtHevcParams);
54
+ if (return_error != EB_ErrorNone)
55
+ {
56
+ x265_log(param, X265_LOG_ERROR, "SVT-HEVC Encoder: Error while configuring encoder parameters \n");
57
+ goto fail;
58
+ }
59
+
60
+ // Init Encoder
61
+ return_error = EbInitEncoder(encoder->m_svtAppData->svtEncoderHandle);
62
+ if (return_error != EB_ErrorNone)
63
+ {
64
+ x265_log(param, X265_LOG_ERROR, "SVT-HEVC Encoder: Encoder init failed \n");
65
+ goto fail;
66
+ }
67
+
68
+ memcpy(param->svtHevcParam, encoder->m_svtAppData->svtHevcParams, sizeof(EB_H265_ENC_CONFIGURATION));
69
+ encoder->m_param = param;
70
+ return encoder;
71
+ }
72
+#endif
73
+
74
x265_setup_primitives(param);
75
76
if (x265_check_params(param))
77
goto fail;
78
79
- encoder = new Encoder;
80
if (!param->rc.bEnableSlowFirstPass)
81
PARAM_NS::x265_param_apply_fastfirstpass(param);
82
83
84
}
85
86
encoder->m_latestParam = latestParam;
87
- memcpy(latestParam, param, sizeof(x265_param));
88
+ x265_copy_params(latestParam, param);
89
if (encoder->m_aborted)
90
goto fail;
91
92
93
if (pp_nal && enc)
94
{
95
Encoder *encoder = static_cast<Encoder*>(enc);
96
+#ifdef SVT_HEVC
97
+ if (encoder->m_param->bEnableSvtHevc)
98
+ {
99
+ EB_ERRORTYPE return_error;
100
+ EB_BUFFERHEADERTYPE* outputPtr;
101
+ return_error = EbH265EncStreamHeader(encoder->m_svtAppData->svtEncoderHandle, &outputPtr);
102
+ if (return_error != EB_ErrorNone)
103
+ {
104
+ x265_log(encoder->m_param, X265_LOG_ERROR, "SVT HEVC encoder: Error while generating stream headers \n");
105
+ encoder->m_aborted = true;
106
+ return -1;
107
+ }
108
+
109
+ //Copy data from output packet to NAL
110
+ encoder->m_nalList.m_nal[0].payload = outputPtr->pBuffer;
111
+ encoder->m_nalList.m_nal[0].sizeBytes = outputPtr->nFilledLen;
112
+ *pp_nal = &encoder->m_nalList.m_nal[0];
113
+ *pi_nal = 1;
114
+ encoder->m_svtAppData->byteCount += outputPtr->nFilledLen;
115
+
116
+ // Release the output buffer
117
+ EbH265ReleaseOutBuffer(&outputPtr);
118
+
119
+ return pp_nal[0]->sizeBytes;
120
+ }
121
+#endif
122
+
123
Entropy sbacCoder;
124
Bitstream bs;
125
if (encoder->m_param->rc.bStatRead && encoder->m_param->bMultiPassOptRPS)
126
127
if (enc && out)
128
{
129
Encoder *encoder = static_cast<Encoder*>(enc);
130
- memcpy(out, encoder->m_param, sizeof(x265_param));
131
+ x265_copy_params(out, encoder->m_param);
132
}
133
}
134
135
136
bool isReconfigureRc = encoder->isReconfigureRc(encoder->m_latestParam, param_in);
137
if ((encoder->m_reconfigure && !isReconfigureRc) || (encoder->m_reconfigureRc && isReconfigureRc)) /* Reconfigure in progress */
138
return 1;
139
- memcpy(&save, encoder->m_latestParam, sizeof(x265_param));
140
+ if (encoder->m_latestParam->rc.zoneCount || encoder->m_latestParam->rc.zonefileCount)
141
+ {
142
+ int zoneCount = encoder->m_latestParam->rc.zonefileCount ? encoder->m_latestParam->rc.zonefileCount : encoder->m_latestParam->rc.zoneCount;
143
+ save.rc.zones = x265_zone_alloc(zoneCount, !!encoder->m_latestParam->rc.zonefileCount);
144
+ }
145
+ x265_copy_params(&save, encoder->m_latestParam);
146
int ret = encoder->reconfigureParam(encoder->m_latestParam, param_in);
147
if (ret)
148
{
149
/* reconfigure failed, recover saved param set */
150
- memcpy(encoder->m_latestParam, &save, sizeof(x265_param));
151
+ x265_copy_params(encoder->m_latestParam, &save);
152
ret = -1;
153
}
154
else
155
156
{
157
if (encoder->m_scalingList.parseScalingList(encoder->m_latestParam->scalingLists))
158
{
159
- memcpy(encoder->m_latestParam, &save, sizeof(x265_param));
160
+ x265_copy_params(encoder->m_latestParam, &save);
161
return -1;
162
}
163
encoder->m_scalingList.setupQuantMatrices(encoder->m_param->internalCsp);
164
165
else
166
{
167
x265_log(encoder->m_param, X265_LOG_ERROR, "Repeat headers is turned OFF, cannot reconfigure scalinglists\n");
168
- memcpy(encoder->m_latestParam, &save, sizeof(x265_param));
169
+ x265_copy_params(encoder->m_latestParam, &save);
170
return -1;
171
}
172
}
173
174
x265_log(encoder->m_param, X265_LOG_WARNING, "Profile/Level/Tier has changed from %d/%d/%s to %d/%d/%s.Cannot reconfigure rate-control.\n",
175
saveVPS.ptl.profileIdc, saveVPS.ptl.levelIdc, saveVPS.ptl.tierFlag ? "High" : "Main", encoder->m_vps.ptl.profileIdc,
176
encoder->m_vps.ptl.levelIdc, encoder->m_vps.ptl.tierFlag ? "High" : "Main");
177
- memcpy(encoder->m_latestParam, &save, sizeof(x265_param));
178
+ x265_copy_params(encoder->m_latestParam, &save);
179
memcpy(&encoder->m_vps.ptl, &saveVPS.ptl, sizeof(saveVPS.ptl));
180
encoder->m_reconfigureRc = false;
181
}
182
183
Encoder *encoder = static_cast<Encoder*>(enc);
184
int numEncoded;
185
186
+#ifdef SVT_HEVC
187
+ EB_ERRORTYPE return_error;
188
+ static unsigned char picSendDone = 0;
189
+ numEncoded = 0;
190
+ static int codedNal = 0, eofReached = 0;
191
+ EB_H265_ENC_CONFIGURATION* svtParam = (EB_H265_ENC_CONFIGURATION*)encoder->m_svtAppData->svtHevcParams;
192
+ if (encoder->m_param->bEnableSvtHevc)
193
+ {
194
+ if (pic_in)
195
+ {
196
+ if (pic_in->colorSpace == X265_CSP_I420) // SVT-HEVC supports only yuv420p color space
197
+ {
198
+ EB_BUFFERHEADERTYPE *inputPtr = encoder->m_svtAppData->inputPictureBuffer;
199
+
200
+ if (pic_in->framesize) inputPtr->nFilledLen = (uint32_t)pic_in->framesize;
201
+ inputPtr->nFlags = 0;
202
+ inputPtr->pts = pic_in->pts;
203
+ inputPtr->dts = pic_in->dts;
204
+ inputPtr->sliceType = EB_INVALID_PICTURE;
205
+
206
+ EB_H265_ENC_INPUT *inputData = (EB_H265_ENC_INPUT*) inputPtr->pBuffer;
207
+ inputData->luma = (unsigned char*) pic_in->planes[0];
208
+ inputData->cb = (unsigned char*) pic_in->planes[1];
209
+ inputData->cr = (unsigned char*) pic_in->planes[2];
210
+
211
+ inputData->yStride = encoder->m_param->sourceWidth;
212
+ inputData->cbStride = encoder->m_param->sourceWidth >> 1;
213
+ inputData->crStride = encoder->m_param->sourceWidth >> 1;
214
+
215
+ inputData->lumaExt = NULL;
216
+ inputData->cbExt = NULL;
217
+ inputData->crExt = NULL;
218
+
219
+ if (pic_in->rpu.payloadSize)
220
+ {
221
+ inputData->dolbyVisionRpu.payload = X265_MALLOC(uint8_t, 1024);
222
+ memcpy(inputData->dolbyVisionRpu.payload, pic_in->rpu.payload, pic_in->rpu.payloadSize);
223
+ inputData->dolbyVisionRpu.payloadSize = pic_in->rpu.payloadSize;
224
+ inputData->dolbyVisionRpu.payloadType = NAL_UNIT_UNSPECIFIED;
225
+ }
226
+ else
227
+ {
228
+ inputData->dolbyVisionRpu.payload = NULL;
229
+ inputData->dolbyVisionRpu.payloadSize = 0;
230
+ }
231
+
232
+ // Send the picture to the encoder
233
+ return_error = EbH265EncSendPicture(encoder->m_svtAppData->svtEncoderHandle, inputPtr);
234
+
235
+ if (return_error != EB_ErrorNone)
236
+ {
237
+ x265_log(encoder->m_param, X265_LOG_ERROR, "SVT HEVC encoder: Error while encoding \n");
238
+ numEncoded = -1;
239
+ goto fail;
240
+ }
241
+ }
242
+ else
243
+ {
244
+ x265_log(encoder->m_param, X265_LOG_ERROR, "SVT HEVC Encoder accepts only yuv420p input \n");
245
+ numEncoded = -1;
246
+ goto fail;
247
+ }
248
+ }
249
+ else if (!picSendDone) //Encoder flush
250
+ {
251
+ picSendDone = 1;
252
+ EB_BUFFERHEADERTYPE inputPtrLast;
253
+ inputPtrLast.nAllocLen = 0;
254
+ inputPtrLast.nFilledLen = 0;
255
+ inputPtrLast.nTickCount = 0;
256
+ inputPtrLast.pAppPrivate = NULL;
257
+ inputPtrLast.nFlags = EB_BUFFERFLAG_EOS;
258
+ inputPtrLast.pBuffer = NULL;
259
+
260
+ return_error = EbH265EncSendPicture(encoder->m_svtAppData->svtEncoderHandle, &inputPtrLast);
261
+ if (return_error != EB_ErrorNone)
262
+ {
263
+ x265_log(encoder->m_param, X265_LOG_ERROR, "SVT HEVC encoder: Error while encoding \n");
264
+ numEncoded = -1;
265
+ goto fail;
266
+ }
267
+ }
268
+
269
+ if (eofReached && svtParam->codeEosNal == 0 && !codedNal)
270
+ {
271
+ EB_BUFFERHEADERTYPE *outputStreamPtr = 0;
272
+ return_error = EbH265EncEosNal(encoder->m_svtAppData->svtEncoderHandle, &outputStreamPtr);
273
+ if (return_error == EB_ErrorMax)
274
+ {
275
+ x265_log(encoder->m_param, X265_LOG_ERROR, "SVT HEVC encoder: Error while encoding \n");
276
+ numEncoded = -1;
277
+ goto fail;
278
+ }
279
+ if (return_error != EB_NoErrorEmptyQueue)
280
+ {
281
+ if (outputStreamPtr->pBuffer)
282
+ {
283
+ //Copy data from output packet to NAL
284
+ encoder->m_nalList.m_nal[0].payload = outputStreamPtr->pBuffer;
285
+ encoder->m_nalList.m_nal[0].sizeBytes = outputStreamPtr->nFilledLen;
286
+ encoder->m_svtAppData->byteCount += outputStreamPtr->nFilledLen;
287
+ *pp_nal = &encoder->m_nalList.m_nal[0];
288
+ *pi_nal = 1;
289
+ numEncoded = 0;
290
+ codedNal = 1;
291
+ return numEncoded;
292
+ }
293
+
294
+ // Release the output buffer
295
+ EbH265ReleaseOutBuffer(&outputStreamPtr);
296
+ }
297
+ }
298
+ else if (eofReached)
299
+ {
300
+ *pi_nal = 0;
301
+ return numEncoded;
302
+ }
303
+
304
+ //Receive Packet
305
+ EB_BUFFERHEADERTYPE *outputPtr;
306
+ return_error = EbH265GetPacket(encoder->m_svtAppData->svtEncoderHandle, &outputPtr, picSendDone);
307
+ if (return_error == EB_ErrorMax)
308
+ {
309
+ x265_log(encoder->m_param, X265_LOG_ERROR, "SVT HEVC encoder: Error while encoding \n");
310
+ numEncoded = -1;
311
+ goto fail;
312
+ }
313
+
314
+ if (return_error != EB_NoErrorEmptyQueue)
315
+ {
316
+ if (outputPtr->pBuffer)
317
+ {
318
+ //Copy data from output packet to NAL
319
+ encoder->m_nalList.m_nal[0].payload = outputPtr->pBuffer;
320
+ encoder->m_nalList.m_nal[0].sizeBytes = outputPtr->nFilledLen;
321
+ encoder->m_svtAppData->byteCount += outputPtr->nFilledLen;
322
+ encoder->m_svtAppData->outFrameCount++;
323
+ *pp_nal = &encoder->m_nalList.m_nal[0];
324
+ *pi_nal = 1;
325
+ numEncoded = 1;
326
+ }
327
+
328
+ eofReached = outputPtr->nFlags & EB_BUFFERFLAG_EOS;
329
+
330
+ // Release the output buffer
331
+ EbH265ReleaseOutBuffer(&outputPtr);
332
+ }
333
+ else if (pi_nal)
334
+ *pi_nal = 0;
335
+
336
+ pic_out = NULL;
337
+
338
+fail:
339
+ if (numEncoded < 0)
340
+ encoder->m_aborted = true;
341
+
342
+ return numEncoded;
343
+ }
344
+#endif
345
+
346
// While flushing, we cannot return 0 until the entire stream is flushed
347
do
348
{
349
350
}
351
}
352
353
+#ifdef SVT_HEVC
354
+static void svt_print_summary(x265_encoder *enc)
355
+{
356
+ Encoder *encoder = static_cast<Encoder*>(enc);
357
+ double frameRate = 0, bitrate = 0;
358
+ EB_H265_ENC_CONFIGURATION *svtParam = (EB_H265_ENC_CONFIGURATION*)encoder->m_svtAppData->svtHevcParams;
359
+ if (svtParam->frameRateNumerator && svtParam->frameRateDenominator && (svtParam->frameRateNumerator != 0 && svtParam->frameRateDenominator != 0))
360
+ {
361
+ frameRate = ((double)svtParam->frameRateNumerator) / ((double)svtParam->frameRateDenominator);
362
+ if(encoder->m_svtAppData->outFrameCount)
363
+ bitrate = ((double)(encoder->m_svtAppData->byteCount << 3) * frameRate / (encoder->m_svtAppData->outFrameCount * 1000));
364
+
365
+ printf("Total Frames\t\tFrame Rate\t\tByte Count\t\tBitrate\n");
366
+ printf("%12d\t\t%4.2f fps\t\t%10.0f\t\t%5.2f kbps\n", (int32_t)encoder->m_svtAppData->outFrameCount, (double)frameRate, (double)encoder->m_svtAppData->byteCount, bitrate);
367
+ }
368
+}
369
+#endif
370
+
371
void x265_encoder_close(x265_encoder *enc)
372
{
373
if (enc)
374
{
375
Encoder *encoder = static_cast<Encoder*>(enc);
376
377
+#ifdef SVT_HEVC
378
+ if (encoder->m_param->bEnableSvtHevc)
379
+ {
380
+ EB_ERRORTYPE return_value;
381
+ return_value = EbDeinitEncoder(encoder->m_svtAppData->svtEncoderHandle);
382
+ if (return_value != EB_ErrorNone)
383
+ {
384
+ x265_log(encoder->m_param, X265_LOG_ERROR, "SVT HEVC encoder: Error while closing the encoder \n");
385
+ }
386
+ return_value = EbDeinitHandle(encoder->m_svtAppData->svtEncoderHandle);
387
+ if (return_value != EB_ErrorNone)
388
+ {
389
+ x265_log(encoder->m_param, X265_LOG_ERROR, "SVT HEVC encoder: Error while closing the Handle \n");
390
+ }
391
+
392
+ svt_print_summary(enc);
393
+ EB_H265_ENC_INPUT *inputData = (EB_H265_ENC_INPUT*)encoder->m_svtAppData->inputPictureBuffer->pBuffer;
394
+ if (inputData->dolbyVisionRpu.payload) X265_FREE(inputData->dolbyVisionRpu.payload);
395
+
396
+ X265_FREE(inputData);
397
+ X265_FREE(encoder->m_svtAppData->inputPictureBuffer);
398
+ X265_FREE(encoder->m_svtAppData->svtHevcParams);
399
+ encoder->stopJobs();
400
+ encoder->destroy();
401
+ delete encoder;
402
+ return;
403
+ }
404
+#endif
405
+
406
encoder->stopJobs();
407
encoder->printSummary();
408
encoder->destroy();
409
410
411
void x265_picture_free(x265_picture *p)
412
{
413
- if (p->rpu.payload)
414
- X265_FREE(p->rpu.payload);
415
return x265_free(p);
416
}
417
418
+x265_zone *x265_zone_alloc(int zoneCount, int isZoneFile)
419
+{
420
+ x265_zone* zone = (x265_zone*)x265_malloc(sizeof(x265_zone) * zoneCount);
421
+ if (isZoneFile) {
422
+ for (int i = 0; i < zoneCount; i++)
423
+ zone[i].zoneParam = (x265_param*)x265_malloc(sizeof(x265_param));
424
+ }
425
+ return zone;
426
+}
427
+
428
+void x265_zone_free(x265_param *param)
429
+{
430
+ if (param->rc.zonefileCount) {
431
+ for (int i = 0; i < param->rc.zonefileCount; i++)
432
+ x265_free(param->rc.zones[i].zoneParam);
433
+ }
434
+ if (param->rc.zoneCount || param->rc.zonefileCount)
435
+ x265_free(param->rc.zones);
436
+}
437
+
438
static const x265_api libapi =
439
{
440
X265_MAJOR_VERSION,
441
442
return score;
443
}
444
#endif
445
+
446
} /* end namespace or extern "C" */
447
+
448
+namespace X265_NS {
449
+#ifdef SVT_HEVC
450
+
451
+void svt_initialise_app_context(x265_encoder *enc)
452
+{
453
+ Encoder *encoder = static_cast<Encoder*>(enc);
454
+
455
+ //Initialise Application Context
456
+ encoder->m_svtAppData = (SvtAppContext*)x265_malloc(sizeof(SvtAppContext));
457
+ encoder->m_svtAppData->svtHevcParams = (EB_H265_ENC_CONFIGURATION*)x265_malloc(sizeof(EB_H265_ENC_CONFIGURATION));
458
+ encoder->m_svtAppData->byteCount = 0;
459
+ encoder->m_svtAppData->outFrameCount = 0;
460
+}
461
+
462
+int svt_initialise_input_buffer(x265_encoder *enc)
463
+{
464
+ Encoder *encoder = static_cast<Encoder*>(enc);
465
+
466
+ //Initialise Input Buffer
467
+ encoder->m_svtAppData->inputPictureBuffer = (EB_BUFFERHEADERTYPE*)x265_malloc(sizeof(EB_BUFFERHEADERTYPE));
468
+ EB_BUFFERHEADERTYPE *inputPtr = encoder->m_svtAppData->inputPictureBuffer;
469
+ inputPtr->pBuffer = (unsigned char*)x265_malloc(sizeof(EB_H265_ENC_INPUT));
470
+
471
+ EB_H265_ENC_INPUT *inputData = (EB_H265_ENC_INPUT*)inputPtr->pBuffer;
472
+ inputData->dolbyVisionRpu.payload = NULL;
473
+ inputData->dolbyVisionRpu.payloadSize = 0;
474
+
475
+
476
+ if (!inputPtr->pBuffer)
477
+ return 0;
478
+
479
+ inputPtr->nSize = sizeof(EB_BUFFERHEADERTYPE);
480
+ inputPtr->pAppPrivate = NULL;
481
+ return 1;
482
+}
483
+#endif // ifdef SVT_HEVC
484
+
485
+} // end namespace X265_NS
486
x265_3.0.tar.gz/source/encoder/dpb.cpp -> x265_3.1.1.tar.gz/source/encoder/dpb.cpp
Changed
9
1
2
{
3
Slice* slice = newFrame->m_encData->m_slice;
4
slice->m_poc = newFrame->m_poc;
5
+ slice->m_fieldNum = newFrame->m_fieldNum;
6
7
int pocCurr = slice->m_poc;
8
int type = newFrame->m_lowres.sliceType;
9
x265_3.0.tar.gz/source/encoder/encoder.cpp -> x265_3.1.1.tar.gz/source/encoder/encoder.cpp
Changed
160
1
2
* TODO: come up an algorithm for adoptive threshold */
3
#define MVTHRESHOLD (10*10)
4
#define PU_2Nx2N 1
5
+#define MAX_CHROMA_QP_OFFSET 12
6
static const char* defaultAnalysisFileName = "x265_analysis.dat";
7
8
using namespace X265_NS;
9
10
m_cim = NULL;
11
#endif
12
13
+#if SVT_HEVC
14
+ m_svtAppData = NULL;
15
+#endif
16
+
17
m_prevTonemapPayload.payload = NULL;
18
m_startPoint = 0;
19
m_saveCTUSize = 0;
20
21
22
m_nalList.m_annexB = !!m_param->bAnnexB;
23
24
- m_emitCLLSEI = p->maxCLL || p->maxFALL || (p->dolbyProfile == 81);
25
-
26
if (m_param->naluFile)
27
{
28
m_naluFile = x265_fopen(m_param->naluFile, "r");
29
30
}
31
if (m_naluFile)
32
fclose(m_naluFile);
33
+
34
+#ifdef SVT_HEVC
35
+ X265_FREE(m_svtAppData);
36
+#endif
37
if (m_param)
38
{
39
if (m_param->csvfpt)
40
41
inFrame->m_pts = pic_in->pts;
42
inFrame->m_forceqp = pic_in->forceqp;
43
inFrame->m_param = (m_reconfigure || m_reconfigureRc) ? m_latestParam : m_param;
44
+ if (m_param->bField && m_param->interlaceMode)
45
+ inFrame->m_fieldNum = pic_in->fieldNum;
46
47
copyUserSEIMessages(inFrame, pic_in);
48
49
50
51
if (frameEnc->m_reconfigureRc && m_reconfigureRc)
52
{
53
- memcpy(m_param, m_latestParam, sizeof(x265_param));
54
+ x265_copy_params(m_param, m_latestParam);
55
m_rateControl->reconfigureRC();
56
m_reconfigureRc = false;
57
}
58
59
/* Safe to copy m_latestParam to Encoder::m_param, encoder reconfigure complete */
60
for (int frameEncId = 0; frameEncId < m_param->frameNumThreads; frameEncId++)
61
m_frameEncoder[frameEncId]->m_reconfigure = false;
62
- memcpy (m_param, m_latestParam, sizeof(x265_param));
63
+ x265_copy_params(m_param, m_latestParam);
64
m_reconfigure = false;
65
}
66
67
68
69
int Encoder::reconfigureParam(x265_param* encParam, x265_param* param)
70
{
71
- if (isReconfigureRc(encParam, param))
72
+ if (isReconfigureRc(encParam, param) && !param->rc.zonefileCount)
73
{
74
/* VBV can't be turned ON if it wasn't ON to begin with and can't be turned OFF if it was ON to begin with*/
75
if (param->rc.vbvMaxBitrate > 0 && param->rc.vbvBufferSize > 0 &&
76
77
78
if (m_param->bEmitHDRSEI)
79
{
80
- if (m_emitCLLSEI)
81
+ if (m_param->bEmitCLL)
82
{
83
SEIContentLightLevel cllsei;
84
cllsei.max_content_light_level = m_param->maxCLL;
85
86
p->bEnableRectInter = zone->bEnableRectInter;
87
p->maxNumMergeCand = zone->maxNumMergeCand;
88
p->bIntraInBFrames = zone->bIntraInBFrames;
89
- p->scalingLists = strdup(zone->scalingLists);
90
+ if(zone->scalingLists)
91
+ p->scalingLists = strdup(zone->scalingLists);
92
93
p->rc.aqMode = zone->rc.aqMode;
94
p->rc.aqStrength = zone->rc.aqStrength;
95
96
p->vui.matrixCoeffs = dovi[doviProfile].matrixCoeffs;
97
98
if (dovi[doviProfile].doviProfileId == 81)
99
- p->bEmitHDRSEI = 1;
100
+ p->bEmitHDRSEI = p->bEmitCLL = 1;
101
102
- if (dovi[doviProfile].doviProfileId == 50 && p->noiseReductionIntra && p->noiseReductionInter)
103
- p->crQpOffset = 4;
104
+ if (dovi[doviProfile].doviProfileId == 50)
105
+ p->crQpOffset = 3;
106
}
107
108
void Encoder::configure(x265_param *p)
109
110
/* In 444, chroma gets twice as much resolution, so halve quality when psy-rd is enabled */
111
if (p->internalCsp == X265_CSP_I444 && p->psyRd)
112
{
113
- p->cbQpOffset += 6;
114
- p->crQpOffset += 6;
115
+ if (!p->cbQpOffset && !p->crQpOffset)
116
+ {
117
+ p->cbQpOffset = MAX_CHROMA_QP_OFFSET / 2;
118
+ p->crQpOffset = MAX_CHROMA_QP_OFFSET / 2;
119
+ x265_log(p, X265_LOG_WARNING, "halving the quality when psy-rd is enabled for 444 input."
120
+ " Setting cbQpOffset = %d and crQpOffset = %d\n", p->cbQpOffset, p->crQpOffset);
121
+ }
122
}
123
124
if (p->bLossless)
125
126
if (p->dolbyProfile) // Default disabled.
127
configureDolbyVisionParams(p);
128
129
+ if (p->rc.zonefileCount && p->rc.zoneCount)
130
+ {
131
+ p->rc.zoneCount = 0;
132
+ x265_log(p, X265_LOG_WARNING, "Only zone or zonefile can be used. Enabling only zonefile\n");
133
+ }
134
+
135
if (m_param->rc.zonefileCount && p->bOpenGOP)
136
{
137
p->bOpenGOP = 0;
138
139
(analysis->interData)->refIdx[i][count + pu] = refIdx[i][d];
140
if (m_param->scaleFactor)
141
{
142
- mv[i][d].x *= (int16_t)m_param->scaleFactor;
143
- mv[i][d].y *= (int16_t)m_param->scaleFactor;
144
+ mv[i][d].x *= (int32_t)m_param->scaleFactor;
145
+ mv[i][d].y *= (int32_t)m_param->scaleFactor;
146
}
147
memcpy(&(analysis->interData)->mv[i][count + pu], &mv[i][d], sizeof(MV));
148
}
149
150
{
151
(analysis->interData)->mvpIdx[i][count + pu] = mvpIdx[i][d];
152
(analysis->interData)->refIdx[i][count + pu] = refIdx[i][d];
153
- mvCopy[i].x = mv[i][d].x * (int16_t)m_param->scaleFactor;
154
- mvCopy[i].y = mv[i][d].y * (int16_t)m_param->scaleFactor;
155
+ mvCopy[i].x = mv[i][d].x * (int32_t)m_param->scaleFactor;
156
+ mvCopy[i].y = mv[i][d].y * (int32_t)m_param->scaleFactor;
157
memcpy(&(analysis->interData)->mv[i][count + pu], &mvCopy[i], sizeof(MV));
158
}
159
}
160
x265_3.0.tar.gz/source/encoder/encoder.h -> x265_3.1.1.tar.gz/source/encoder/encoder.h
Changed
49
1
2
#include "x265.h"
3
#include "nal.h"
4
#include "framedata.h"
5
+#include "svt.h"
6
#ifdef ENABLE_HDR10_PLUS
7
#include "dynamicHDR10/hdr10plus.h"
8
#endif
9
10
11
class Entropy;
12
13
+#ifdef SVT_HEVC
14
+typedef struct SvtAppContext
15
+{
16
+ EB_COMPONENTTYPE* svtEncoderHandle;
17
+ EB_H265_ENC_CONFIGURATION* svtHevcParams;
18
+
19
+ // Buffer Pools
20
+ EB_BUFFERHEADERTYPE* inputPictureBuffer;
21
+ uint64_t byteCount;
22
+ uint64_t outFrameCount;
23
+
24
+}SvtAppContext;
25
+#endif
26
+
27
struct EncStats
28
{
29
double m_psnrSumY;
30
31
ScalingList m_scalingList; // quantization matrix information
32
Window m_conformanceWindow;
33
34
- bool m_emitCLLSEI;
35
bool m_bZeroLatency; // x265_encoder_encode() returns NALs for the input picture, zero lag
36
bool m_aborted; // fatal error detected
37
bool m_reconfigure; // Encoder reconfigure in progress
38
39
int m_numCimInfo;
40
#endif
41
42
+#ifdef SVT_HEVC
43
+ SvtAppContext* m_svtAppData;
44
+#endif
45
+
46
x265_sei_payload m_prevTonemapPayload;
47
48
/* Collect frame level feature data */
49
x265_3.0.tar.gz/source/encoder/frameencoder.cpp -> x265_3.1.1.tar.gz/source/encoder/frameencoder.cpp
Changed
42
1
2
3
if (vui->frameFieldInfoPresentFlag)
4
{
5
- if (m_param->interlaceMode == 2)
6
- sei->m_picStruct = (poc & 1) ? 1 /* top */ : 2 /* bottom */;
7
- else if (m_param->interlaceMode == 1)
8
- sei->m_picStruct = (poc & 1) ? 2 /* bottom */ : 1 /* top */;
9
+ if (m_param->interlaceMode > 0)
10
+ {
11
+ if( m_param->interlaceMode == 2 )
12
+ {
13
+ // m_picStruct should be set to 3 or 4 when field feature is enabled
14
+ if (m_param->bField)
15
+ // 3: Top field, bottom field, in that order; 4: Bottom field, top field, in that order
16
+ sei->m_picStruct = (slice->m_fieldNum == 1) ? 4 : 3;
17
+ else
18
+ sei->m_picStruct = (poc & 1) ? 1 /* top */ : 2 /* bottom */;
19
+ }
20
+ else if (m_param->interlaceMode == 1)
21
+ {
22
+ if (m_param->bField)
23
+ sei->m_picStruct = (slice->m_fieldNum == 1) ? 3: 4;
24
+ else
25
+ sei->m_picStruct = (poc & 1) ? 2 /* bottom */ : 1 /* top */;
26
+ }
27
+ }
28
else
29
sei->m_picStruct = m_param->pictureStructure;
30
31
32
}
33
34
// Initialize restrict on MV range in slices
35
- tld.analysis.m_sliceMinY = -(int16_t)(rowInSlice * m_param->maxCUSize * 4) + 3 * 4;
36
- tld.analysis.m_sliceMaxY = (int16_t)((endRowInSlicePlus1 - 1 - row) * (m_param->maxCUSize * 4) - 4 * 4);
37
+ tld.analysis.m_sliceMinY = -(int32_t)(rowInSlice * m_param->maxCUSize * 4) + 3 * 4;
38
+ tld.analysis.m_sliceMaxY = (int32_t)((endRowInSlicePlus1 - 1 - row) * (m_param->maxCUSize * 4) - 4 * 4);
39
40
// Handle single row slice
41
if (tld.analysis.m_sliceMaxY < tld.analysis.m_sliceMinY)
42
x265_3.0.tar.gz/source/encoder/level.cpp -> x265_3.1.1.tar.gz/source/encoder/level.cpp
Changed
31
1
2
#include "common.h"
3
#include "slice.h"
4
#include "level.h"
5
+#include "svt.h"
6
7
namespace X265_NS {
8
typedef struct
9
10
if (!param || !profile)
11
return 0;
12
13
+#ifdef SVT_HEVC
14
+ if (param->bEnableSvtHevc)
15
+ {
16
+ EB_H265_ENC_CONFIGURATION* svtParam = (EB_H265_ENC_CONFIGURATION*)param->svtHevcParam;
17
+ if (!strcmp(profile, "main")) svtParam->profile = 1;
18
+ else if (!strcmp(profile, "main10")) svtParam->profile = 2;
19
+ else
20
+ {
21
+ x265_log(param, X265_LOG_ERROR, "SVT-HEVC encoder: Unsupported profile %s \n", profile);
22
+ return -1;
23
+ }
24
+ return 0;
25
+ }
26
+#endif
27
+
28
/* Check if profile bit-depth requirement is exceeded by internal bit depth */
29
bool bInvalidDepth = false;
30
#if X265_DEPTH > 8
31
x265_3.0.tar.gz/source/encoder/motion.cpp -> x265_3.1.1.tar.gz/source/encoder/motion.cpp
Changed
99
1
2
4 * 5
3
7
4
*/
5
- const int16_t top = omv.y - dist;
6
- const int16_t bottom = omv.y + dist;
7
- const int16_t left = omv.x - dist;
8
- const int16_t right = omv.x + dist;
9
+ const int32_t top = omv.y - dist;
10
+ const int32_t bottom = omv.y + dist;
11
+ const int32_t left = omv.x - dist;
12
+ const int32_t right = omv.x + dist;
13
14
if (top >= mvmin.y && left >= mvmin.x && right <= mvmax.x && bottom <= mvmax.y)
15
{
16
17
Points 2, 4, 5, 7 are dist
18
Points 1, 3, 6, 8 are dist>>1
19
*/
20
- const int16_t top = omv.y - dist;
21
- const int16_t bottom = omv.y + dist;
22
- const int16_t left = omv.x - dist;
23
- const int16_t right = omv.x + dist;
24
- const int16_t top2 = omv.y - (dist >> 1);
25
- const int16_t bottom2 = omv.y + (dist >> 1);
26
- const int16_t left2 = omv.x - (dist >> 1);
27
- const int16_t right2 = omv.x + (dist >> 1);
28
+ const int32_t top = omv.y - dist;
29
+ const int32_t bottom = omv.y + dist;
30
+ const int32_t left = omv.x - dist;
31
+ const int32_t right = omv.x + dist;
32
+ const int32_t top2 = omv.y - (dist >> 1);
33
+ const int32_t bottom2 = omv.y + (dist >> 1);
34
+ const int32_t left2 = omv.x - (dist >> 1);
35
+ const int32_t right2 = omv.x + (dist >> 1);
36
saved = bcost;
37
38
if (top >= mvmin.y && left >= mvmin.x &&
39
40
41
for (int16_t dist = 16; dist <= (int16_t)merange; dist <<= 1)
42
{
43
- const int16_t top = omv.y - dist;
44
- const int16_t bottom = omv.y + dist;
45
- const int16_t left = omv.x - dist;
46
- const int16_t right = omv.x + dist;
47
+ const int32_t top = omv.y - dist;
48
+ const int32_t bottom = omv.y + dist;
49
+ const int32_t left = omv.x - dist;
50
+ const int32_t right = omv.x + dist;
51
52
saved = bcost;
53
if (top >= mvmin.y && left >= mvmin.x &&
54
55
56
for (int16_t index = 1; index < 4; index++)
57
{
58
- int16_t posYT = top + ((dist >> 2) * index);
59
- int16_t posYB = bottom - ((dist >> 2) * index);
60
- int16_t posXL = omv.x - ((dist >> 2) * index);
61
- int16_t posXR = omv.x + ((dist >> 2) * index);
62
+ int32_t posYT = top + ((dist >> 2) * index);
63
+ int32_t posYB = bottom - ((dist >> 2) * index);
64
+ int32_t posXL = omv.x - ((dist >> 2) * index);
65
+ int32_t posXR = omv.x + ((dist >> 2) * index);
66
67
COST_MV_PT_DIST_X4(posXL, posYT, 0, dist,
68
posXR, posYT, 0, dist,
69
70
}
71
for (int16_t index = 1; index < 4; index++)
72
{
73
- int16_t posYT = top + ((dist >> 2) * index);
74
- int16_t posYB = bottom - ((dist >> 2) * index);
75
- int16_t posXL = omv.x - ((dist >> 2) * index);
76
- int16_t posXR = omv.x + ((dist >> 2) * index);
77
+ int32_t posYT = top + ((dist >> 2) * index);
78
+ int32_t posYB = bottom - ((dist >> 2) * index);
79
+ int32_t posXL = omv.x - ((dist >> 2) * index);
80
+ int32_t posXR = omv.x + ((dist >> 2) * index);
81
82
if (posYT >= mvmin.y) // check top
83
{
84
85
case X265_SEA:
86
{
87
// Successive Elimination Algorithm
88
- const int16_t minX = X265_MAX(omv.x - (int16_t)merange, mvmin.x);
89
- const int16_t minY = X265_MAX(omv.y - (int16_t)merange, mvmin.y);
90
- const int16_t maxX = X265_MIN(omv.x + (int16_t)merange, mvmax.x);
91
- const int16_t maxY = X265_MIN(omv.y + (int16_t)merange, mvmax.y);
92
+ const int32_t minX = X265_MAX(omv.x - (int32_t)merange, mvmin.x);
93
+ const int32_t minY = X265_MAX(omv.y - (int32_t)merange, mvmin.y);
94
+ const int32_t maxX = X265_MIN(omv.x + (int32_t)merange, mvmax.x);
95
+ const int32_t maxY = X265_MIN(omv.y + (int32_t)merange, mvmax.y);
96
const uint16_t *p_cost_mvx = m_cost_mvx - qmvp.x;
97
const uint16_t *p_cost_mvy = m_cost_mvy - qmvp.y;
98
int16_t* meScratchBuffer = NULL;
99
x265_3.0.tar.gz/source/encoder/ratecontrol.cpp -> x265_3.1.1.tar.gz/source/encoder/ratecontrol.cpp
Changed
46
1
2
}
3
rce->isActive = true;
4
rce->scenecut = false;
5
+ rce->isFadeEnd = curFrame->m_lowres.bIsFadeEnd;
6
bool isRefFrameScenecut = m_sliceType!= I_SLICE && m_curSlice->m_refFrameList[0][0]->m_lowres.bScenecut;
7
m_isFirstMiniGop = m_sliceType == I_SLICE ? true : m_isFirstMiniGop;
8
if (curFrame->m_lowres.bScenecut)
9
10
m_numBframesInPattern++;
11
}
12
}
13
+ if (rce->isFadeEnd)
14
+ m_isPatternPresent = true;
15
}
16
/* For a scenecut that occurs within the mini-gop, enable scene transition
17
* switch until the next mini-gop to ensure a min qp for all the frames within
18
19
double abrBuffer = 2 * m_rateTolerance * m_bitrate;
20
21
// Check if current Slice is a scene cut that follows low detailed/blank frames
22
- if (rce->lastSatd > 4 * rce->movingAvgSum || rce->scenecut)
23
+ if (rce->lastSatd > 4 * rce->movingAvgSum || rce->scenecut || rce->isFadeEnd)
24
{
25
if (!m_isAbrReset && rce->movingAvgSum > 0
26
&& (m_isPatternPresent || !m_param->bframes))
27
28
shrtTermTotalBitsSum += m_encodedBitsWindow[i];
29
double underflow = (shrtTermTotalBitsSum - shrtTermWantedBits) / abrBuffer;
30
const double epsilon = 0.0001f;
31
- if (underflow < epsilon && !isFrameDone)
32
+ if ((underflow < epsilon || rce->isFadeEnd) && !isFrameDone)
33
{
34
init(*m_curSlice->m_sps);
35
m_shortTermCplxSum = rce->lastSatd / (CLIP_DURATION(m_frameDuration) / BASE_FRAME_DURATION);
36
37
X265_FREE(m_encOrder);
38
for (int i = 0; i < 2; i++)
39
X265_FREE(m_cuTreeStats.qpBuffer[i]);
40
-
41
- X265_FREE(m_param->rc.zones);
42
+
43
}
44
45
void RateControl::splitdeltaPOC(char deltapoc[], RateControlEntry *rce)
46
x265_3.0.tar.gz/source/encoder/ratecontrol.h -> x265_3.1.1.tar.gz/source/encoder/ratecontrol.h
Changed
9
1
2
HRDTiming *hrdTiming;
3
int rpsIdx;
4
RPS rpsData;
5
+ bool isFadeEnd;
6
};
7
8
class RateControl
9
x265_3.0.tar.gz/source/encoder/search.cpp -> x265_3.1.1.tar.gz/source/encoder/search.cpp
Changed
21
1
2
3
void Search::setSearchRange(const CUData& cu, const MV& mvp, int merange, MV& mvmin, MV& mvmax) const
4
{
5
- MV dist((int16_t)merange << 2, (int16_t)merange << 2);
6
+ MV dist((int32_t)merange << 2, (int32_t)merange << 2);
7
mvmin = mvp - dist;
8
mvmax = mvp + dist;
9
10
11
mvmax >>= 2;
12
13
/* conditional clipping for frame parallelism */
14
- mvmin.y = X265_MIN(mvmin.y, (int16_t)m_refLagPixels);
15
- mvmax.y = X265_MIN(mvmax.y, (int16_t)m_refLagPixels);
16
+ mvmin.y = X265_MIN(mvmin.y, (int32_t)m_refLagPixels);
17
+ mvmax.y = X265_MIN(mvmax.y, (int32_t)m_refLagPixels);
18
19
/* conditional clipping for negative mv range */
20
mvmax.y = X265_MAX(mvmax.y, mvmin.y);
21
x265_3.0.tar.gz/source/encoder/search.h -> x265_3.1.1.tar.gz/source/encoder/search.h
Changed
12
1
2
int32_t m_maxTUDepth;
3
uint16_t m_limitTU;
4
5
- int16_t m_sliceMaxY;
6
- int16_t m_sliceMinY;
7
+ int32_t m_sliceMaxY;
8
+ int32_t m_sliceMinY;
9
10
#if DETAILED_CU_STATS
11
/* Accumulate CU statistics separately for each frame encoder */
12
x265_3.0.tar.gz/source/encoder/slicetype.cpp -> x265_3.1.1.tar.gz/source/encoder/slicetype.cpp
Changed
134
1
2
}
3
}
4
5
- if (param->bDynamicRefine)
6
+ if (param->bDynamicRefine || param->bEnableFades)
7
{
8
- int blockXY = 0;
9
+ uint64_t blockXY = 0, rowVariance = 0;
10
+ curFrame->m_lowres.frameVariance = 0;
11
for (int blockY = 0; blockY < maxRow; blockY += loopIncr)
12
{
13
for (int blockX = 0; blockX < maxCol; blockX += loopIncr)
14
{
15
curFrame->m_lowres.blockVariance[blockXY] = acEnergyCu(curFrame, blockX, blockY, param->internalCsp, param->rc.qgSize);
16
+ rowVariance += curFrame->m_lowres.blockVariance[blockXY];
17
blockXY++;
18
}
19
+ curFrame->m_lowres.frameVariance += (rowVariance / maxCol);
20
}
21
+ curFrame->m_lowres.frameVariance /= maxRow;
22
}
23
}
24
25
26
m_8x8Width = ((m_param->sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
27
m_cuCount = m_8x8Width * m_8x8Height;
28
m_8x8Blocks = m_8x8Width > 2 && m_8x8Height > 2 ? (m_cuCount + 4 - 2 * (m_8x8Width + m_8x8Height)) : m_cuCount;
29
+ m_isFadeIn = false;
30
+ m_fadeCount = 0;
31
+ m_fadeStart = -1;
32
33
/* Allow the strength to be adjusted via qcompress, since the two concepts
34
* are very similar. */
35
36
ProfileScopeEvent(prelookahead);
37
m_lock.release();
38
preFrame->m_lowres.init(preFrame->m_fencPic, preFrame->m_poc);
39
- if (m_lookahead.m_bAdaptiveQuant)
40
+ if (m_lookahead.m_param->rc.bStatRead && m_lookahead.m_param->rc.cuTree && IS_REFERENCED(preFrame))
41
+ /* cu-tree offsets were read from stats file */;
42
+ else if (m_lookahead.m_bAdaptiveQuant)
43
tld.calcAdaptiveQuantFrame(preFrame, m_lookahead.m_param);
44
tld.lowresIntraEstimate(preFrame->m_lowres, m_lookahead.m_param->rc.qgSize);
45
preFrame->m_lowresInit = true;
46
47
void Lookahead::slicetypeDecide()
48
{
49
PreLookaheadGroup pre(*this);
50
-
51
Lowres* frames[X265_LOOKAHEAD_MAX + X265_BFRAME_MAX + 4];
52
Frame* list[X265_BFRAME_MAX + 4];
53
memset(frames, 0, sizeof(frames));
54
55
pre.waitForExit();
56
}
57
58
+ if(m_param->bEnableFades)
59
+ {
60
+ int j, endIndex = 0, length = X265_BFRAME_MAX + 4;
61
+ for (j = 0; j < length; j++)
62
+ m_frameVariance[j] = -1;
63
+ for (j = 0; list[j] != NULL; j++)
64
+ m_frameVariance[list[j]->m_poc % length] = list[j]->m_lowres.frameVariance;
65
+ for (int k = list[0]->m_poc % length; k <= list[j - 1]->m_poc % length; k++)
66
+ {
67
+ if (m_frameVariance[k] == -1)
68
+ break;
69
+ if((k > 0 && m_frameVariance[k] >= m_frameVariance[k - 1]) ||
70
+ (k == 0 && m_frameVariance[k] >= m_frameVariance[length - 1]))
71
+ {
72
+ m_isFadeIn = true;
73
+ if (m_fadeCount == 0 && m_fadeStart == -1)
74
+ {
75
+ for(int temp = list[0]->m_poc; temp <= list[j - 1]->m_poc; temp++)
76
+ if (k == temp % length) {
77
+ m_fadeStart = temp ? temp - 1 : 0;
78
+ break;
79
+ }
80
+ }
81
+ m_fadeCount = list[endIndex]->m_poc > m_fadeStart ? list[endIndex]->m_poc - m_fadeStart : 0;
82
+ endIndex++;
83
+ }
84
+ else
85
+ {
86
+ if (m_isFadeIn && m_fadeCount >= m_param->fpsNum / m_param->fpsDenom)
87
+ {
88
+ for (int temp = 0; list[temp] != NULL; temp++)
89
+ {
90
+ if (list[temp]->m_poc == m_fadeStart + (int)m_fadeCount)
91
+ {
92
+ list[temp]->m_lowres.bIsFadeEnd = true;
93
+ break;
94
+ }
95
+ }
96
+ }
97
+ m_isFadeIn = false;
98
+ m_fadeCount = 0;
99
+ m_fadeStart = -1;
100
+ }
101
+ if (k == length - 1)
102
+ k = -1;
103
+ }
104
+ }
105
+
106
if (m_lastNonB && !m_param->rc.bStatRead &&
107
((m_param->bFrameAdaptive && m_param->bframes) ||
108
m_param->rc.cuTree || m_param->scenecutThreshold ||
109
110
frm.sliceType = m_param->bOpenGOP && m_lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;
111
}
112
}
113
+ if (frm.bIsFadeEnd){
114
+ frm.sliceType = m_param->bOpenGOP && m_lastKeyframe >= 0 ? X265_TYPE_I : X265_TYPE_IDR;
115
+ }
116
for (int i = 0; i < m_param->rc.zonefileCount; i++)
117
{
118
int curZoneStart = m_param->rc.zones[i].startFrame;
119
120
121
// TODO: restrict to slices boundaries
122
// establish search bounds that don't cross extended frame boundaries
123
- mvmin.x = (int16_t)(-cuX * cuSize - 8);
124
- mvmin.y = (int16_t)(-cuY * cuSize - 8);
125
- mvmax.x = (int16_t)((widthInCU - cuX - 1) * cuSize + 8);
126
- mvmax.y = (int16_t)((heightInCU - cuY - 1) * cuSize + 8);
127
+ mvmin.x = (int32_t)(-cuX * cuSize - 8);
128
+ mvmin.y = (int32_t)(-cuY * cuSize - 8);
129
+ mvmax.x = (int32_t)((widthInCU - cuX - 1) * cuSize + 8);
130
+ mvmax.y = (int32_t)((heightInCU - cuY - 1) * cuSize + 8);
131
132
for (int i = 0; i < 1 + bBidir; i++)
133
{
134
x265_3.0.tar.gz/source/encoder/slicetype.h -> x265_3.1.1.tar.gz/source/encoder/slicetype.h
Changed
12
1
2
bool m_isSceneTransition;
3
int m_numPools;
4
bool m_extendGopBoundary;
5
+ double m_frameVariance[X265_BFRAME_MAX + 4];
6
+ bool m_isFadeIn;
7
+ uint64_t m_fadeCount;
8
+ int m_fadeStart;
9
Lookahead(x265_param *param, ThreadPool *pool);
10
#if DETAILED_CU_STATS
11
int64_t m_slicetypeDecideElapsedTime;
12
x265_3.1.1.tar.gz/source/encoder/svt.h
Added
55
1
2
+/*****************************************************************************
3
+* Copyright (C) 2013-2018 MulticoreWare, Inc
4
+*
5
+* Authors: Radhakrishnan <radhakrishnan@multicorewareinc.com>
6
+*
7
+* This program is free software; you can redistribute it and/or modify
8
+* it under the terms of the GNU General Public License as published by
9
+* the Free Software Foundation; either version 2 of the License, or
10
+* (at your option) any later version.
11
+*
12
+* This program is distributed in the hope that it will be useful,
13
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+* GNU General Public License for more details.
16
+*
17
+* You should have received a copy of the GNU General Public License
18
+* along with this program; if not, write to the Free Software
19
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
20
+*
21
+* This program is also available under a commercial proprietary license.
22
+* For more information, contact us at license @ x265.com.
23
+*****************************************************************************/
24
+
25
+
26
+#ifndef SVT_H
27
+#define SVT_H
28
+
29
+#ifdef SVT_HEVC
30
+
31
+#include "EbApi.h"
32
+#include "EbErrorCodes.h"
33
+#include "EbTime.h"
34
+
35
+namespace X265_NS {
36
+
37
+#define INPUT_SIZE_576p_TH 0x90000 // 0.58 Million
38
+#define INPUT_SIZE_1080i_TH 0xB71B0 // 0.75 Million
39
+#define INPUT_SIZE_1080p_TH 0x1AB3F0 // 1.75 Million
40
+#define INPUT_SIZE_4K_TH 0x29F630 // 2.75 Million
41
+
42
+#define EB_OUTPUTSTREAMBUFFERSIZE_MACRO(ResolutionSize) ((ResolutionSize) < (INPUT_SIZE_1080i_TH) ? 0x1E8480 : (ResolutionSize) < (INPUT_SIZE_1080p_TH) ? 0x2DC6C0 : (ResolutionSize) < (INPUT_SIZE_4K_TH) ? 0x2DC6C0 : 0x2DC6C0)
43
+
44
+void svt_param_default(x265_param* param);
45
+int svt_set_preset_tune(x265_param* param, const char* preset, const char* tune);
46
+int svt_param_parse(x265_param* param, const char* name, const char* value);
47
+void svt_initialise_app_context(x265_encoder *enc);
48
+int svt_initialise_input_buffer(x265_encoder *enc);
49
+}
50
+
51
+#endif // ifdef SVT_HEVC
52
+
53
+#endif // ifndef SVT_H
54
\ No newline at end of file
55
x265_3.0.tar.gz/source/encoder/weightPrediction.cpp -> x265_3.1.1.tar.gz/source/encoder/weightPrediction.cpp
Changed
43
1
2
for (int y = 0; y < ref.lines; y += cuSize)
3
{
4
intptr_t pixoff = y * stride;
5
- mvmin.y = (int16_t)((-y - 8) * mvshift);
6
- mvmax.y = (int16_t)((ref.lines - y - 1 + 8) * mvshift);
7
+ mvmin.y = (int32_t)((-y - 8) * mvshift);
8
+ mvmax.y = (int32_t)((ref.lines - y - 1 + 8) * mvshift);
9
10
for (int x = 0; x < ref.width; x += cuSize, pixoff += cuSize, cu++)
11
{
12
ALIGN_VAR_16(pixel, buf8x8[8 * 8]);
13
intptr_t bstride = 8;
14
- mvmin.x = (int16_t)((-x - 8) * mvshift);
15
- mvmax.x = (int16_t)((ref.width - x - 1 + 8) * mvshift);
16
+ mvmin.x = (int32_t)((-x - 8) * mvshift);
17
+ mvmax.x = (int32_t)((ref.width - x - 1 + 8) * mvshift);
18
19
/* clip MV to available pixels */
20
MV mv = mvs[cu];
21
22
* into the lowres structures */
23
int cu = y * cache.lowresWidthInCU;
24
intptr_t pixoff = y * stride;
25
- mvmin.y = (int16_t)((-y - 8) * mvshift);
26
- mvmax.y = (int16_t)((height - y - 1 + 8) * mvshift);
27
+ mvmin.y = (int32_t)((-y - 8) * mvshift);
28
+ mvmax.y = (int32_t)((height - y - 1 + 8) * mvshift);
29
30
for (int x = 0; x < width; x += bw, cu++, pixoff += bw)
31
{
32
33
mv.y >>= cache.vshift;
34
35
/* clip MV to available pixels */
36
- mvmin.x = (int16_t)((-x - 8) * mvshift);
37
- mvmax.x = (int16_t)((width - x - 1 + 8) * mvshift);
38
+ mvmin.x = (int32_t)((-x - 8) * mvshift);
39
+ mvmax.x = (int32_t)((width - x - 1 + 8) * mvshift);
40
mv = mv.clipped(mvmin, mvmax);
41
42
intptr_t fpeloffset = (mv.y >> 2) * stride + (mv.x >> 2);
43
x265_3.0.tar.gz/source/test/pixelharness.cpp -> x265_3.1.1.tar.gz/source/test/pixelharness.cpp
Changed
126
1
2
return true;
3
}
4
5
+bool PixelHarness::check_ssimDist(ssimDistortion_t ref, ssimDistortion_t opt)
6
+{
7
+ uint32_t srcStride[5] = { 4, 8, 16, 32, 64 };
8
+ intptr_t dstStride[5] = { 4, 8, 16, 32, 64 };
9
+ int shift = X265_DEPTH - 8;
10
+ uint64_t opt_dest1 = 0, ref_dest1 = 0, opt_dest2 = 0, ref_dest2 = 0;
11
+ int j = 0;
12
+
13
+ for (int i = 0; i < ITERS; i++)
14
+ {
15
+ int index = i % TEST_CASES;
16
+ int k1 = rand() % 5, k2 = rand() % 5;
17
+ ref(pixel_test_buff[index] + j, srcStride[k1], pixel_test_buff[index + 10] + j, dstStride[k2], &ref_dest1, shift, &ref_dest2);
18
+ opt(pixel_test_buff[index] + j, srcStride[k1], pixel_test_buff[index + 10] + j, dstStride[k2], &opt_dest1, shift, &opt_dest2);
19
+
20
+ if (opt_dest1 != ref_dest1 && opt_dest2 != ref_dest2)
21
+ {
22
+ return false;
23
+ }
24
+
25
+ reportfail()
26
+ j += INCR;
27
+ }
28
+ return true;
29
+}
30
+
31
+bool PixelHarness::check_normFact(normFactor_t ref, normFactor_t opt, int block)
32
+{
33
+ int shift = X265_DEPTH - 8;
34
+ uint64_t opt_dest = 0, ref_dest = 0;
35
+ int j = 0;
36
+ int blockSize = 4 << block;
37
+
38
+ for (int i = 0; i < ITERS; i++)
39
+ {
40
+ int index = i % TEST_CASES;
41
+ ref(pixel_test_buff[index] + j, blockSize, shift, &ref_dest);
42
+ opt(pixel_test_buff[index] + j, blockSize, shift, &opt_dest);
43
+
44
+ if (opt_dest != ref_dest)
45
+ {
46
+ return false;
47
+ }
48
+
49
+ reportfail()
50
+ j += INCR;
51
+ }
52
+ return true;
53
+}
54
+
55
bool PixelHarness::testPU(int part, const EncoderPrimitives& ref, const EncoderPrimitives& opt)
56
{
57
if (opt.pu[part].satd)
58
59
}
60
}
61
62
+ if (opt.cu[i].ssimDist)
63
+ {
64
+ if (!check_ssimDist(ref.cu[i].ssimDist, opt.cu[i].ssimDist))
65
+ {
66
+ printf("\nssimDist[%dx%d] failed!\n", 4 << i, 4 << i);
67
+ return false;
68
+ }
69
+ }
70
+
71
if (i < BLOCK_64x64)
72
{
73
/* TU only primitives */
74
75
return false;
76
}
77
}
78
+
79
+ for (int i = BLOCK_8x8; i < NUM_CU_SIZES; i++)
80
+ {
81
+ if (opt.cu[i].normFact)
82
+ {
83
+ if (!check_normFact(ref.cu[i].normFact, opt.cu[i].normFact, i))
84
+ {
85
+ printf("\nnormFact[%dx%d] failed!\n", 4 << i, 4 << i);
86
+ return false;
87
+ }
88
+ }
89
+ }
90
+
91
return true;
92
}
93
94
95
HEADER("psy_cost_pp[%dx%d]", 4 << i, 4 << i);
96
REPORT_SPEEDUP(opt.cu[i].psy_cost_pp, ref.cu[i].psy_cost_pp, pbuf1, STRIDE, pbuf2, STRIDE);
97
}
98
+
99
+ if (opt.cu[i].ssimDist)
100
+ {
101
+ uint64_t dst1 = 0, dst2 = 0;
102
+ int shift = X265_DEPTH - 8;
103
+ printf("ssimDist[%dx%d]", 4 << i, 4 << i);
104
+ REPORT_SPEEDUP(opt.cu[i].ssimDist, ref.cu[i].ssimDist, pixel_test_buff[0], 32, pixel_test_buff[5], 64, &dst1, shift, &dst2);
105
+ }
106
}
107
108
if (opt.weight_pp)
109
110
REPORT_SPEEDUP(opt.integral_inith[k], ref.integral_inith[k], dst_buf, pbuf1, STRIDE);
111
}
112
}
113
+
114
+ for (int i = BLOCK_8x8; i < NUM_CU_SIZES; i++)
115
+ {
116
+ if (opt.cu[i].normFact)
117
+ {
118
+ uint64_t dst = 0;
119
+ int blockSize = 4 << i;
120
+ int shift = X265_DEPTH - 8;
121
+ printf("normFact[%dx%d]", blockSize, blockSize);
122
+ REPORT_SPEEDUP(opt.cu[i].normFact, ref.cu[i].normFact, pixel_test_buff[0], blockSize, shift, &dst);
123
+ }
124
+ }
125
}
126
x265_3.0.tar.gz/source/test/pixelharness.h -> x265_3.1.1.tar.gz/source/test/pixelharness.h
Changed
10
1
2
bool check_pelFilterChroma_H(pelFilterChroma_t ref, pelFilterChroma_t opt);
3
bool check_integral_initv(integralv_t ref, integralv_t opt);
4
bool check_integral_inith(integralh_t ref, integralh_t opt);
5
+ bool check_ssimDist(ssimDistortion_t ref, ssimDistortion_t opt);
6
+ bool check_normFact(normFactor_t ref, normFactor_t opt, int block);
7
8
public:
9
10
x265_3.0.tar.gz/source/test/regression-tests.txt -> x265_3.1.1.tar.gz/source/test/regression-tests.txt
Changed
17
1
2
ParkScene_1920x1080_24.y4m,--preset medium --qp 40 --rdpenalty 2 --tu-intra-depth 3
3
ParkScene_1920x1080_24.y4m,--preset medium --pme --tskip-fast --tskip --min-keyint 48 --weightb --limit-refs 3
4
ParkScene_1920x1080_24.y4m,--preset slower --no-weightp
5
+ParkScene_1920x1080_24.y4m,--tune grain --aq-motion
6
RaceHorses_416x240_30.y4m,--preset superfast --no-cutree
7
RaceHorses_416x240_30.y4m,--preset medium --tskip-fast --tskip
8
RaceHorses_416x240_30.y4m,--preset slower --keyint -1 --rdoq-level 0 --limit-tu 2
9
10
Kimono1_1920x1080_24_400.yuv,--preset placebo --ctu 32 --max-tu-size 8 --limit-tu 2
11
big_buck_bunny_360p24.y4m, --keyint 60 --min-keyint 40 --gop-lookahead 14
12
BasketballDrive_1920x1080_50.y4m, --preset medium --no-open-gop --keyint 50 --min-keyint 50 --radl 2 --vbv-maxrate 5000 --vbv-bufsize 5000
13
+big_buck_bunny_360p24.y4m, --bitrate 500 --fades
14
15
# Main12 intraCost overflow bug test
16
720p50_parkrun_ter.y4m,--preset medium
17
x265_3.0.tar.gz/source/x265.cpp -> x265_3.1.1.tar.gz/source/x265.cpp
Changed
316
1
2
#include "input/input.h"
3
#include "output/output.h"
4
#include "output/reconplay.h"
5
+#include "svt.h"
6
7
#if HAVE_VLD
8
/* Visual Leak Detector */
9
10
const char *preset = NULL;
11
const char *tune = NULL;
12
const char *profile = NULL;
13
+ int svtEnabled = 0;
14
15
if (argc <= 1)
16
{
17
18
/* Presets are applied before all other options. */
19
for (optind = 0;; )
20
{
21
- int c = getopt_long(argc, argv, short_options, long_options, NULL);
22
+ int optionsIndex = -1;
23
+ int c = getopt_long(argc, argv, short_options, long_options, &optionsIndex);
24
if (c == -1)
25
break;
26
else if (c == 'p')
27
28
profile = optarg;
29
else if (c == '?')
30
bShowHelp = true;
31
+ else if (!c && !strcmp(long_options[optionsIndex].name, "svt"))
32
+ svtEnabled = 1;
33
}
34
35
if (!outputBitDepth && profile)
36
37
showHelp(param);
38
}
39
40
+ //Set enable SVT-HEVC encoder first if found in the command line
41
+ if (svtEnabled) api->param_parse(param, "svt", NULL);
42
+
43
for (optind = 0;; )
44
{
45
int long_options_index = -1;
46
47
OPT("tune") /* handled above */;
48
OPT("output-depth") /* handled above */;
49
OPT("recon-y4m-exec") reconPlayCmd = optarg;
50
+ OPT("svt") /* handled above */;
51
OPT("qpfile")
52
{
53
this->qpfile = x265_fopen(optarg, "rb");
54
55
return true;
56
}
57
58
+#ifdef SVT_HEVC
59
+ if (svtEnabled)
60
+ {
61
+ EB_H265_ENC_CONFIGURATION* svtParam = (EB_H265_ENC_CONFIGURATION*)param->svtHevcParam;
62
+ param->sourceWidth = svtParam->sourceWidth;
63
+ param->sourceHeight = svtParam->sourceHeight;
64
+ param->fpsNum = svtParam->frameRateNumerator;
65
+ param->fpsDenom = svtParam->frameRateDenominator;
66
+ svtParam->encoderBitDepth = inputBitDepth;
67
+ }
68
+#endif
69
+
70
InputFileInfo info;
71
info.filename = inputfn;
72
info.depth = inputBitDepth;
73
74
if (this->framesToBeEncoded == 0 && info.frameCount > (int)seek)
75
this->framesToBeEncoded = info.frameCount - seek;
76
param->totalFrames = this->framesToBeEncoded;
77
+
78
+#ifdef SVT_HEVC
79
+ if (svtEnabled)
80
+ {
81
+ EB_H265_ENC_CONFIGURATION* svtParam = (EB_H265_ENC_CONFIGURATION*)param->svtHevcParam;
82
+ svtParam->sourceWidth = param->sourceWidth;
83
+ svtParam->sourceHeight = param->sourceHeight;
84
+ svtParam->frameRateNumerator = param->fpsNum;
85
+ svtParam->frameRateDenominator = param->fpsDenom;
86
+ svtParam->framesToBeEncoded = param->totalFrames;
87
+ svtParam->encoderColorFormat = (EB_COLOR_FORMAT)param->internalCsp;
88
+ }
89
+#endif
90
91
/* Force CFR until we have support for VFR */
92
info.timebaseNum = param->fpsDenom;
93
info.timebaseDenom = param->fpsNum;
94
95
+ if (param->bField && param->interlaceMode)
96
+ { // Field FPS
97
+ param->fpsNum *= 2;
98
+ // Field height
99
+ param->sourceHeight = param->sourceHeight >> 1;
100
+ // Number of fields to encode
101
+ param->totalFrames *= 2;
102
+ }
103
+
104
if (api->param_apply_profile(param, profile))
105
return true;
106
107
108
uint32_t nal;
109
int16_t *errorBuf = NULL;
110
bool bDolbyVisionRPU = false;
111
+ uint8_t *rpuPayload = NULL;
112
int ret = 0;
113
+ int inputPicNum = 1;
114
+ x265_picture picField1, picField2;
115
116
-
117
- if (!param->bRepeatHeaders)
118
+ if (!param->bRepeatHeaders && !param->bEnableSvtHevc)
119
{
120
if (api->encoder_headers(encoder, &p_nal, &nal) < 0)
121
{
122
123
cliopt.totalbytes += cliopt.output->writeHeaders(p_nal, nal);
124
}
125
126
- api->picture_init(param, pic_in);
127
+ if (param->bField && param->interlaceMode)
128
+ {
129
+ api->picture_init(param, &picField1);
130
+ api->picture_init(param, &picField2);
131
+ // return back the original height of input
132
+ param->sourceHeight *= 2;
133
+ api->picture_init(param, pic_in);
134
+ }
135
+ else
136
+ api->picture_init(param, pic_in);
137
138
if (param->dolbyProfile && cliopt.dolbyVisionRpu)
139
{
140
- pic_in->rpu.payload = X265_MALLOC(uint8_t, 1024);
141
+ rpuPayload = X265_MALLOC(uint8_t, 1024);
142
+ pic_in->rpu.payload = rpuPayload;
143
if (pic_in->rpu.payload)
144
bDolbyVisionRPU = true;
145
}
146
147
// main encoder loop
148
while (pic_in && !b_ctrl_c)
149
{
150
- pic_orig.poc = inFrameCount;
151
+ pic_orig.poc = (param->bField && param->interlaceMode) ? inFrameCount * 2 : inFrameCount;
152
if (cliopt.qpfile)
153
{
154
if (!cliopt.parseQPFile(pic_orig))
155
156
/* Overwrite PTS */
157
pic_in->pts = pic_in->poc;
158
159
+ // convert to field
160
+ if (param->bField && param->interlaceMode)
161
+ {
162
+ int height = pic_in->height >> 1;
163
+
164
+ int static bCreated = 0;
165
+ if (bCreated == 0)
166
+ {
167
+ bCreated = 1;
168
+ inputPicNum = 2;
169
+ picField1.fieldNum = 1;
170
+ picField2.fieldNum = 2;
171
+
172
+ picField1.bitDepth = picField2.bitDepth = pic_in->bitDepth;
173
+ picField1.colorSpace = picField2.colorSpace = pic_in->colorSpace;
174
+ picField1.height = picField2.height = pic_in->height >> 1;
175
+ picField1.framesize = picField2.framesize = pic_in->framesize >> 1;
176
+
177
+ size_t fieldFrameSize = (size_t)pic_in->framesize >> 1;
178
+ char* field1Buf = X265_MALLOC(char, fieldFrameSize);
179
+ char* field2Buf = X265_MALLOC(char, fieldFrameSize);
180
+
181
+ int stride = picField1.stride[0] = picField2.stride[0] = pic_in->stride[0];
182
+ uint64_t framesize = stride * (height >> x265_cli_csps[pic_in->colorSpace].height[0]);
183
+ picField1.planes[0] = field1Buf;
184
+ picField2.planes[0] = field2Buf;
185
+ for (int i = 1; i < x265_cli_csps[pic_in->colorSpace].planes; i++)
186
+ {
187
+ picField1.planes[i] = field1Buf + framesize;
188
+ picField2.planes[i] = field2Buf + framesize;
189
+
190
+ stride = picField1.stride[i] = picField2.stride[i] = pic_in->stride[i];
191
+ framesize += (stride * (height >> x265_cli_csps[pic_in->colorSpace].height[i]));
192
+ }
193
+ assert(framesize == picField1.framesize);
194
+ }
195
+
196
+ picField1.pts = picField1.poc = pic_in->poc;
197
+ picField2.pts = picField2.poc = pic_in->poc + 1;
198
+
199
+ picField1.userSEI = picField2.userSEI = pic_in->userSEI;
200
+
201
+ //if (pic_in->userData)
202
+ //{
203
+ // // Have to handle userData here
204
+ //}
205
+
206
+ if (pic_in->framesize)
207
+ {
208
+ for (int i = 0; i < x265_cli_csps[pic_in->colorSpace].planes; i++)
209
+ {
210
+ char* srcP1 = (char*)pic_in->planes[i];
211
+ char* srcP2 = (char*)pic_in->planes[i] + pic_in->stride[i];
212
+ char* p1 = (char*)picField1.planes[i];
213
+ char* p2 = (char*)picField2.planes[i];
214
+
215
+ int stride = picField1.stride[i];
216
+
217
+ for (int y = 0; y < (height >> x265_cli_csps[pic_in->colorSpace].height[i]); y++)
218
+ {
219
+ memcpy(p1, srcP1, stride);
220
+ memcpy(p2, srcP2, stride);
221
+ srcP1 += 2*stride;
222
+ srcP2 += 2*stride;
223
+ p1 += stride;
224
+ p2 += stride;
225
+ }
226
+ }
227
+ }
228
+ }
229
+
230
if (bDolbyVisionRPU)
231
{
232
- if (rpuParser(pic_in, cliopt.dolbyVisionRpu) > 0)
233
- goto fail;
234
+ if (param->bField && param->interlaceMode)
235
+ {
236
+ if (rpuParser(&picField1, cliopt.dolbyVisionRpu) > 0)
237
+ goto fail;
238
+ if (rpuParser(&picField2, cliopt.dolbyVisionRpu) > 0)
239
+ goto fail;
240
+ }
241
+ else
242
+ {
243
+ if (rpuParser(pic_in, cliopt.dolbyVisionRpu) > 0)
244
+ goto fail;
245
+ }
246
}
247
}
248
- int numEncoded = api->encoder_encode(encoder, &p_nal, &nal, pic_in, pic_recon);
249
- if (numEncoded < 0)
250
- {
251
- b_ctrl_c = 1;
252
- ret = 4;
253
- break;
254
- }
255
+
256
+ for (int inputNum = 0; inputNum < inputPicNum; inputNum++)
257
+ {
258
+ x265_picture *picInput = NULL;
259
+ if (inputPicNum == 2)
260
+ picInput = pic_in ? (inputNum ? &picField2 : &picField1) : NULL;
261
+ else
262
+ picInput = pic_in;
263
264
- if (reconPlay && numEncoded)
265
- reconPlay->writePicture(*pic_recon);
266
+ int numEncoded = api->encoder_encode( encoder, &p_nal, &nal, picInput, pic_recon );
267
+ if( numEncoded < 0 )
268
+ {
269
+ b_ctrl_c = 1;
270
+ ret = 4;
271
+ break;
272
+ }
273
274
- outFrameCount += numEncoded;
275
+ if (reconPlay && numEncoded)
276
+ reconPlay->writePicture(*pic_recon);
277
278
- if (numEncoded && pic_recon && cliopt.recon)
279
- cliopt.recon->writePicture(pic_out);
280
- if (nal)
281
- {
282
- cliopt.totalbytes += cliopt.output->writeFrame(p_nal, nal, pic_out);
283
- if (pts_queue)
284
+ outFrameCount += numEncoded;
285
+
286
+ if (numEncoded && pic_recon && cliopt.recon)
287
+ cliopt.recon->writePicture(pic_out);
288
+ if (nal)
289
{
290
- pts_queue->push(-pic_out.pts);
291
- if (pts_queue->size() > 2)
292
- pts_queue->pop();
293
+ cliopt.totalbytes += cliopt.output->writeFrame(p_nal, nal, pic_out);
294
+ if (pts_queue)
295
+ {
296
+ pts_queue->push(-pic_out.pts);
297
+ if (pts_queue->size() > 2)
298
+ pts_queue->pop();
299
+ }
300
}
301
+ cliopt.printStatus( outFrameCount );
302
}
303
-
304
- cliopt.printStatus(outFrameCount);
305
}
306
307
/* Flush the encoder */
308
309
api->param_free(param);
310
311
X265_FREE(errorBuf);
312
+ X265_FREE(rpuPayload);
313
314
SetConsoleTitle(orgConsoleTitle);
315
SetThreadExecutionState(ES_CONTINUOUS);
316
x265_3.0.tar.gz/source/x265.h -> x265_3.1.1.tar.gz/source/x265.h
Changed
65
1
2
typedef struct x265_analysis_MV
3
{
4
union{
5
- struct { int16_t x, y; };
6
+ struct { int32_t x, y; };
7
8
- int32_t word;
9
+ int64_t word;
10
};
11
}x265_analysis_MV;
12
13
14
15
//Dolby Vision RPU metadata
16
x265_dolby_vision_rpu rpu;
17
+
18
+ int fieldNum;
19
} x265_picture;
20
21
typedef enum
22
23
* 0 - Disabled. 1 - Save/Load ctu distortion to/from the file specified
24
* analysis-save/load. Default 0. */
25
int ctuDistortionRefine;
26
+
27
+ /* Enable SVT HEVC Encoder */
28
+ int bEnableSvtHevc;
29
+
30
+ /* SVT-HEVC param structure. For internal use when SVT HEVC encoder is enabled */
31
+ void* svtHevcParam;
32
+
33
+ /* Detect fade-in regions. Enforces I-slice for the brightest point.
34
+ Re-init RC history at that point in ABR mode. Default is disabled. */
35
+ int bEnableFades;
36
+
37
+ /* Enable field coding */
38
+ int bField;
39
+
40
+ /*Emit content light level info SEI*/
41
+ int bEmitCLL;
42
} x265_param;
43
/* x265_param_alloc:
44
* Allocates an x265_param instance. The returned param structure is not
45
46
#define X265_PARAM_BAD_VALUE (-2)
47
int x265_param_parse(x265_param *p, const char *name, const char *value);
48
49
+x265_zone *x265_zone_alloc(int zoneCount, int isZoneFile);
50
+
51
+void x265_zone_free(x265_param *param);
52
+
53
int x265_zone_param_parse(x265_param* p, const char* name, const char* value);
54
55
static const char * const x265_profile_names[] = {
56
57
* 100 times faster than placebo!
58
*
59
* Currently available tunings are: */
60
-static const char * const x265_tune_names[] = { "psnr", "ssim", "grain", "zerolatency", "fastdecode", 0 };
61
+static const char * const x265_tune_names[] = { "psnr", "ssim", "grain", "zerolatency", "fastdecode", "animation", 0 };
62
63
/* returns 0 on success, negative on failure (e.g. invalid preset/tune name). */
64
int x265_param_default_preset(x265_param *, const char *preset, const char *tune);
65
x265_3.0.tar.gz/source/x265cli.h -> x265_3.1.1.tar.gz/source/x265cli.h
Changed
92
1
2
{ "input-csp", required_argument, NULL, 0 },
3
{ "interlace", required_argument, NULL, 0 },
4
{ "no-interlace", no_argument, NULL, 0 },
5
+ { "field", no_argument, NULL, 0 },
6
+ { "no-field", no_argument, NULL, 0 },
7
{ "fps", required_argument, NULL, 0 },
8
{ "seek", required_argument, NULL, 0 },
9
{ "frame-skip", required_argument, NULL, 0 },
10
11
{ "scenecut", required_argument, NULL, 0 },
12
{ "no-scenecut", no_argument, NULL, 0 },
13
{ "scenecut-bias", required_argument, NULL, 0 },
14
+ { "fades", no_argument, NULL, 0 },
15
+ { "no-fades", no_argument, NULL, 0 },
16
{ "radl", required_argument, NULL, 0 },
17
{ "ctu-info", required_argument, NULL, 0 },
18
{ "intra-refresh", no_argument, NULL, 0 },
19
20
{ "hevc-aq", no_argument, NULL, 0 },
21
{ "no-hevc-aq", no_argument, NULL, 0 },
22
{ "qp-adaptation-range", required_argument, NULL, 0 },
23
+#ifdef SVT_HEVC
24
+ { "svt", no_argument, NULL, 0 },
25
+ { "no-svt", no_argument, NULL, 0 },
26
+ { "svt-hme", no_argument, NULL, 0 },
27
+ { "no-svt-hme", no_argument, NULL, 0 },
28
+ { "svt-search-width", required_argument, NULL, 0 },
29
+ { "svt-search-height", required_argument, NULL, 0 },
30
+ { "svt-compressed-ten-bit-format", no_argument, NULL, 0 },
31
+ { "no-svt-compressed-ten-bit-format", no_argument, NULL, 0 },
32
+ { "svt-speed-control", no_argument , NULL, 0 },
33
+ { "no-svt-speed-control", no_argument , NULL, 0 },
34
+ { "svt-preset-tuner", required_argument , NULL, 0 },
35
+ { "svt-hierarchical-level", required_argument , NULL, 0 },
36
+ { "svt-base-layer-switch-mode", required_argument , NULL, 0 },
37
+ { "svt-pred-struct", required_argument , NULL, 0 },
38
+ { "svt-fps-in-vps", no_argument , NULL, 0 },
39
+ { "no-svt-fps-in-vps", no_argument , NULL, 0 },
40
+#endif
41
+ { "cll", no_argument, NULL, 0 },
42
+ { "no-cll", no_argument, NULL, 0 },
43
{ 0, 0, 0, 0 },
44
{ 0, 0, 0, 0 },
45
{ 0, 0, 0, 0 },
46
47
H0("-f/--frames <integer> Maximum number of frames to encode. Default all\n");
48
H0(" --seek <integer> First frame to encode\n");
49
H1(" --[no-]interlace <bff|tff> Indicate input pictures are interlace fields in temporal order. Default progressive\n");
50
+ H0(" --[no-]field Enable or disable field coding. Default %s\n", OPT( param->bField));
51
H1(" --dither Enable dither if downscaling to 8 bit pixels. Default disabled\n");
52
H0(" --[no-]copy-pic Copy buffers of input picture in frame. Default %s\n", OPT(param->bCopyPicToFrame));
53
H0("\nQuality reporting metrics:\n");
54
55
H0(" --no-scenecut Disable adaptive I-frame decision\n");
56
H0(" --scenecut <integer> How aggressively to insert extra I-frames. Default %d\n", param->scenecutThreshold);
57
H1(" --scenecut-bias <0..100.0> Bias for scenecut detection. Default %.2f\n", param->scenecutBias);
58
+ H0(" --[no-]fades Enable detection and handling of fade-in regions. Default %s\n", OPT(param->bEnableFades));
59
H0(" --radl <integer> Number of RADL pictures allowed in front of IDR. Default %d\n", param->radl);
60
H0(" --intra-refresh Use Periodic Intra Refresh instead of IDR frames\n");
61
H0(" --rc-lookahead <integer> Number of frames for frame-type lookahead (determines encoder latency) Default %d\n", param->lookaheadDepth);
62
63
H1(" --chromaloc <integer> Specify chroma sample location (0 to 5). Default of %d\n", param->vui.chromaSampleLocTypeTopField);
64
H0(" --master-display <string> SMPTE ST 2086 master display color volume info SEI (HDR)\n");
65
H0(" format: G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)\n");
66
- H0(" --max-cll <string> Emit content light level info SEI as \"cll,fall\" (HDR)\n");
67
+ H0(" --max-cll <string> Specify content light level info SEI as \"cll,fall\" (HDR).\n");
68
+ H0(" --[no-]cll Emit content light level info SEI. Default %s\n", OPT(param->bEmitCLL));
69
H0(" --[no-]hdr Control dumping of HDR SEI packet. If max-cll or master-display has non-zero values, this is enabled. Default %s\n", OPT(param->bEmitHDRSEI));
70
H0(" --[no-]hdr-opt Add luma and chroma offsets for HDR/WCG content. Default %s\n", OPT(param->bHDROpt));
71
H0(" --min-luma <integer> Minimum luma plane value of input source picture\n");
72
73
H1(" --recon-depth <integer> Bit-depth of reconstructed raw image file. Defaults to input bit depth, or 8 if Y4M\n");
74
H1(" --recon-y4m-exec <string> pipe reconstructed frames to Y4M viewer, ex:\"ffplay -i pipe:0 -autoexit\"\n");
75
H0(" --lowpass-dct Use low-pass subband dct approximation. Default %s\n", OPT(param->bLowPassDct));
76
+#ifdef SVT_HEVC
77
+ H0(" --[no]svt Enable SVT HEVC encoder %s\n", OPT(param->bEnableSvtHevc));
78
+ H0(" --[no-]svt-hme Enable Hierarchial motion estimation(HME) in SVT HEVC encoder \n");
79
+ H0(" --svt-search-width Motion estimation search area width for SVT HEVC encoder \n");
80
+ H0(" --svt-search-height Motion estimation search area height for SVT HEVC encoder \n");
81
+ H0(" --[no-]svt-compressed-ten-bit-format Enable 8+2 encoding mode for 10bit input in SVT HEVC encoder \n");
82
+ H0(" --[no-]svt-speed-control Enable speed control functionality to achieve real time encoding speed for SVT HEVC encoder \n");
83
+ H0(" --svt-preset-tuner Enable additional faster presets of SVT; This only has to be used on top of x265's ultrafast preset. Accepts values in the range of 0-2 \n");
84
+ H0(" --svt-hierarchical-level Hierarchical layer for SVT-HEVC encoder; Accepts inputs in the range 0-3 \n");
85
+ H0(" --svt-base-layer-switch-mode Select whether B/P slice should be used in base layer for SVT-HEVC encoder. 0-Use B-frames; 1-Use P frames in the base layer \n");
86
+ H0(" --svt-pred-struct Select pred structure for SVT HEVC encoder; Accepts inputs in the range 0-2 \n");
87
+ H0(" --[no-]svt-fps-in-vps Enable VPS timing info for SVT HEVC encoder \n");
88
+#endif
89
H1("\nExecutable return codes:\n");
90
H1(" 0 - encode successful\n");
91
H1(" 1 - unable to parse command line\n");
92
Refresh
x265
x86_64
aarch64
x86_64
aarch64
armv7l
Refresh
Login required, please
login
or
signup
in order to comment