@pproenca/ffmpeg-dev 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/include/aom/aom.h +127 -0
  2. package/include/aom/aom_codec.h +594 -0
  3. package/include/aom/aom_decoder.h +257 -0
  4. package/include/aom/aom_encoder.h +1154 -0
  5. package/include/aom/aom_external_partition.h +452 -0
  6. package/include/aom/aom_frame_buffer.h +84 -0
  7. package/include/aom/aom_image.h +462 -0
  8. package/include/aom/aom_integer.h +60 -0
  9. package/include/aom/aomcx.h +2288 -0
  10. package/include/aom/aomdx.h +607 -0
  11. package/include/dav1d/common.h +94 -0
  12. package/include/dav1d/data.h +117 -0
  13. package/include/dav1d/dav1d.h +329 -0
  14. package/include/dav1d/headers.h +444 -0
  15. package/include/dav1d/picture.h +157 -0
  16. package/include/dav1d/version.h +50 -0
  17. package/include/index.js +1 -0
  18. package/include/lame/lame.h +1342 -0
  19. package/include/libavcodec/ac3_parser.h +36 -0
  20. package/include/libavcodec/adts_parser.h +37 -0
  21. package/include/libavcodec/avcodec.h +3128 -0
  22. package/include/libavcodec/avdct.h +88 -0
  23. package/include/libavcodec/avfft.h +149 -0
  24. package/include/libavcodec/bsf.h +332 -0
  25. package/include/libavcodec/codec.h +382 -0
  26. package/include/libavcodec/codec_desc.h +134 -0
  27. package/include/libavcodec/codec_id.h +669 -0
  28. package/include/libavcodec/codec_par.h +248 -0
  29. package/include/libavcodec/d3d11va.h +109 -0
  30. package/include/libavcodec/defs.h +337 -0
  31. package/include/libavcodec/dirac.h +135 -0
  32. package/include/libavcodec/dv_profile.h +82 -0
  33. package/include/libavcodec/dxva2.h +90 -0
  34. package/include/libavcodec/jni.h +67 -0
  35. package/include/libavcodec/mediacodec.h +103 -0
  36. package/include/libavcodec/packet.h +887 -0
  37. package/include/libavcodec/qsv.h +109 -0
  38. package/include/libavcodec/vdpau.h +171 -0
  39. package/include/libavcodec/version.h +45 -0
  40. package/include/libavcodec/version_major.h +52 -0
  41. package/include/libavcodec/videotoolbox.h +85 -0
  42. package/include/libavcodec/vorbis_parser.h +74 -0
  43. package/include/libavdevice/avdevice.h +397 -0
  44. package/include/libavdevice/version.h +45 -0
  45. package/include/libavdevice/version_major.h +43 -0
  46. package/include/libavfilter/avfilter.h +1379 -0
  47. package/include/libavfilter/buffersink.h +173 -0
  48. package/include/libavfilter/buffersrc.h +215 -0
  49. package/include/libavfilter/version.h +48 -0
  50. package/include/libavfilter/version_major.h +40 -0
  51. package/include/libavformat/avformat.h +3107 -0
  52. package/include/libavformat/avio.h +831 -0
  53. package/include/libavformat/version.h +47 -0
  54. package/include/libavformat/version_major.h +54 -0
  55. package/include/libavutil/adler32.h +63 -0
  56. package/include/libavutil/aes.h +69 -0
  57. package/include/libavutil/aes_ctr.h +99 -0
  58. package/include/libavutil/ambient_viewing_environment.h +72 -0
  59. package/include/libavutil/attributes.h +173 -0
  60. package/include/libavutil/audio_fifo.h +187 -0
  61. package/include/libavutil/avassert.h +78 -0
  62. package/include/libavutil/avconfig.h +6 -0
  63. package/include/libavutil/avstring.h +428 -0
  64. package/include/libavutil/avutil.h +362 -0
  65. package/include/libavutil/base64.h +72 -0
  66. package/include/libavutil/blowfish.h +82 -0
  67. package/include/libavutil/bprint.h +254 -0
  68. package/include/libavutil/bswap.h +105 -0
  69. package/include/libavutil/buffer.h +322 -0
  70. package/include/libavutil/camellia.h +70 -0
  71. package/include/libavutil/cast5.h +80 -0
  72. package/include/libavutil/channel_layout.h +751 -0
  73. package/include/libavutil/common.h +589 -0
  74. package/include/libavutil/cpu.h +145 -0
  75. package/include/libavutil/crc.h +102 -0
  76. package/include/libavutil/csp.h +150 -0
  77. package/include/libavutil/des.h +81 -0
  78. package/include/libavutil/detection_bbox.h +108 -0
  79. package/include/libavutil/dict.h +241 -0
  80. package/include/libavutil/display.h +109 -0
  81. package/include/libavutil/dovi_meta.h +396 -0
  82. package/include/libavutil/downmix_info.h +115 -0
  83. package/include/libavutil/encryption_info.h +205 -0
  84. package/include/libavutil/error.h +129 -0
  85. package/include/libavutil/eval.h +140 -0
  86. package/include/libavutil/executor.h +67 -0
  87. package/include/libavutil/ffversion.h +5 -0
  88. package/include/libavutil/fifo.h +242 -0
  89. package/include/libavutil/file.h +62 -0
  90. package/include/libavutil/film_grain_params.h +322 -0
  91. package/include/libavutil/frame.h +1175 -0
  92. package/include/libavutil/hash.h +264 -0
  93. package/include/libavutil/hdr_dynamic_metadata.h +376 -0
  94. package/include/libavutil/hdr_dynamic_vivid_metadata.h +346 -0
  95. package/include/libavutil/hmac.h +99 -0
  96. package/include/libavutil/hwcontext.h +598 -0
  97. package/include/libavutil/hwcontext_cuda.h +74 -0
  98. package/include/libavutil/hwcontext_d3d11va.h +178 -0
  99. package/include/libavutil/hwcontext_d3d12va.h +142 -0
  100. package/include/libavutil/hwcontext_drm.h +169 -0
  101. package/include/libavutil/hwcontext_dxva2.h +75 -0
  102. package/include/libavutil/hwcontext_mediacodec.h +61 -0
  103. package/include/libavutil/hwcontext_opencl.h +100 -0
  104. package/include/libavutil/hwcontext_qsv.h +87 -0
  105. package/include/libavutil/hwcontext_vaapi.h +117 -0
  106. package/include/libavutil/hwcontext_vdpau.h +44 -0
  107. package/include/libavutil/hwcontext_videotoolbox.h +106 -0
  108. package/include/libavutil/hwcontext_vulkan.h +382 -0
  109. package/include/libavutil/iamf.h +690 -0
  110. package/include/libavutil/imgutils.h +377 -0
  111. package/include/libavutil/intfloat.h +77 -0
  112. package/include/libavutil/intreadwrite.h +677 -0
  113. package/include/libavutil/lfg.h +81 -0
  114. package/include/libavutil/log.h +387 -0
  115. package/include/libavutil/lzo.h +66 -0
  116. package/include/libavutil/macros.h +80 -0
  117. package/include/libavutil/mastering_display_metadata.h +137 -0
  118. package/include/libavutil/mathematics.h +300 -0
  119. package/include/libavutil/md5.h +89 -0
  120. package/include/libavutil/mem.h +607 -0
  121. package/include/libavutil/motion_vector.h +57 -0
  122. package/include/libavutil/murmur3.h +115 -0
  123. package/include/libavutil/opt.h +1187 -0
  124. package/include/libavutil/parseutils.h +197 -0
  125. package/include/libavutil/pixdesc.h +440 -0
  126. package/include/libavutil/pixelutils.h +51 -0
  127. package/include/libavutil/pixfmt.h +716 -0
  128. package/include/libavutil/random_seed.h +57 -0
  129. package/include/libavutil/rational.h +225 -0
  130. package/include/libavutil/rc4.h +69 -0
  131. package/include/libavutil/replaygain.h +50 -0
  132. package/include/libavutil/ripemd.h +83 -0
  133. package/include/libavutil/samplefmt.h +269 -0
  134. package/include/libavutil/sha.h +90 -0
  135. package/include/libavutil/sha512.h +92 -0
  136. package/include/libavutil/spherical.h +243 -0
  137. package/include/libavutil/stereo3d.h +325 -0
  138. package/include/libavutil/tea.h +71 -0
  139. package/include/libavutil/threadmessage.h +115 -0
  140. package/include/libavutil/time.h +56 -0
  141. package/include/libavutil/timecode.h +199 -0
  142. package/include/libavutil/timestamp.h +85 -0
  143. package/include/libavutil/tree.h +137 -0
  144. package/include/libavutil/twofish.h +70 -0
  145. package/include/libavutil/tx.h +210 -0
  146. package/include/libavutil/uuid.h +146 -0
  147. package/include/libavutil/version.h +124 -0
  148. package/include/libavutil/video_enc_params.h +171 -0
  149. package/include/libavutil/video_hint.h +107 -0
  150. package/include/libavutil/xtea.h +94 -0
  151. package/include/libpostproc/postprocess.h +107 -0
  152. package/include/libpostproc/version.h +46 -0
  153. package/include/libpostproc/version_major.h +31 -0
  154. package/include/libswresample/swresample.h +587 -0
  155. package/include/libswresample/version.h +46 -0
  156. package/include/libswresample/version_major.h +31 -0
  157. package/include/libswscale/swscale.h +460 -0
  158. package/include/libswscale/version.h +44 -0
  159. package/include/libswscale/version_major.h +35 -0
  160. package/include/ogg/config_types.h +26 -0
  161. package/include/ogg/ogg.h +209 -0
  162. package/include/ogg/os_types.h +158 -0
  163. package/include/opus/opus.h +1099 -0
  164. package/include/opus/opus_defines.h +830 -0
  165. package/include/opus/opus_multistream.h +660 -0
  166. package/include/opus/opus_projection.h +568 -0
  167. package/include/opus/opus_types.h +166 -0
  168. package/include/svt-av1/EbDebugMacros.h +88 -0
  169. package/include/svt-av1/EbSvtAv1.h +462 -0
  170. package/include/svt-av1/EbSvtAv1Enc.h +1112 -0
  171. package/include/svt-av1/EbSvtAv1ErrorCodes.h +67 -0
  172. package/include/svt-av1/EbSvtAv1ExtFrameBuf.h +64 -0
  173. package/include/svt-av1/EbSvtAv1Formats.h +126 -0
  174. package/include/svt-av1/EbSvtAv1Metadata.h +156 -0
  175. package/include/vorbis/codec.h +242 -0
  176. package/include/vorbis/vorbisenc.h +435 -0
  177. package/include/vorbis/vorbisfile.h +205 -0
  178. package/include/vpx/vp8.h +136 -0
  179. package/include/vpx/vp8cx.h +1118 -0
  180. package/include/vpx/vp8dx.h +228 -0
  181. package/include/vpx/vpx_codec.h +475 -0
  182. package/include/vpx/vpx_decoder.h +367 -0
  183. package/include/vpx/vpx_encoder.h +1150 -0
  184. package/include/vpx/vpx_ext_ratectrl.h +590 -0
  185. package/include/vpx/vpx_frame_buffer.h +83 -0
  186. package/include/vpx/vpx_image.h +221 -0
  187. package/include/vpx/vpx_integer.h +40 -0
  188. package/include/vpx/vpx_tpl.h +68 -0
  189. package/include/x264.h +1027 -0
  190. package/include/x264_config.h +6 -0
  191. package/include/x265.h +2737 -0
  192. package/include/x265_config.h +34 -0
  193. package/package.json +24 -0
package/include/x265.h ADDED
@@ -0,0 +1,2737 @@
1
+ /*****************************************************************************
2
+ * Copyright (C) 2013-2020 MulticoreWare, Inc
3
+ *
4
+ * Authors: Steve Borho <steve@borho.org>
5
+ * Min Chen <chenm003@163.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
+ #ifndef X265_H
26
+ #define X265_H
27
+ #include <stdint.h>
28
+ #include <stdio.h>
29
+ #include <sys/stat.h>
30
+ #include "x265_config.h"
31
+ #ifdef __cplusplus
32
+ extern "C" {
33
+ #endif
34
+
35
+ #if _MSC_VER
36
+ #pragma warning(disable: 4201) // non-standard extension used (nameless struct/union)
37
+ #endif
38
+
39
+ /* x265_encoder:
40
+ * opaque handler for encoder */
41
+ typedef struct x265_encoder x265_encoder;
42
+
43
+ /* x265_picyuv:
44
+ * opaque handler for PicYuv */
45
+ typedef struct x265_picyuv x265_picyuv;
46
+
47
+ /* Application developers planning to link against a shared library version of
48
+ * libx265 from a Microsoft Visual Studio or similar development environment
49
+ * will need to define X265_API_IMPORTS before including this header.
50
+ * This clause does not apply to MinGW, similar development environments, or non
51
+ * Windows platforms. */
52
+ #ifdef X265_API_IMPORTS
53
+ #define X265_API __declspec(dllimport)
54
+ #else
55
+ #define X265_API
56
+ #endif
57
+
58
+ typedef enum
59
+ {
60
+ NAL_UNIT_CODED_SLICE_TRAIL_N = 0,
61
+ NAL_UNIT_CODED_SLICE_TRAIL_R,
62
+ NAL_UNIT_CODED_SLICE_TSA_N,
63
+ NAL_UNIT_CODED_SLICE_TSA_R,
64
+ NAL_UNIT_CODED_SLICE_STSA_N,
65
+ NAL_UNIT_CODED_SLICE_STSA_R,
66
+ NAL_UNIT_CODED_SLICE_RADL_N,
67
+ NAL_UNIT_CODED_SLICE_RADL_R,
68
+ NAL_UNIT_CODED_SLICE_RASL_N,
69
+ NAL_UNIT_CODED_SLICE_RASL_R,
70
+ NAL_UNIT_CODED_SLICE_BLA_W_LP = 16,
71
+ NAL_UNIT_CODED_SLICE_BLA_W_RADL,
72
+ NAL_UNIT_CODED_SLICE_BLA_N_LP,
73
+ NAL_UNIT_CODED_SLICE_IDR_W_RADL,
74
+ NAL_UNIT_CODED_SLICE_IDR_N_LP,
75
+ NAL_UNIT_CODED_SLICE_CRA,
76
+ NAL_UNIT_VPS = 32,
77
+ NAL_UNIT_SPS,
78
+ NAL_UNIT_PPS,
79
+ NAL_UNIT_ACCESS_UNIT_DELIMITER,
80
+ NAL_UNIT_EOS,
81
+ NAL_UNIT_EOB,
82
+ NAL_UNIT_FILLER_DATA,
83
+ NAL_UNIT_PREFIX_SEI,
84
+ NAL_UNIT_SUFFIX_SEI,
85
+ NAL_UNIT_UNSPECIFIED = 62,
86
+ NAL_UNIT_INVALID = 64,
87
+ } NalUnitType;
88
+
89
+ /* The data within the payload is already NAL-encapsulated; the type is merely
90
+ * in the struct for easy access by the calling application. All data returned
91
+ * in an x265_nal, including the data in payload, is no longer valid after the
92
+ * next call to x265_encoder_encode. Thus it must be used or copied before
93
+ * calling x265_encoder_encode again. */
94
+ typedef struct x265_nal
95
+ {
96
+ uint32_t type; /* NalUnitType */
97
+ uint32_t sizeBytes; /* size in bytes */
98
+ uint8_t* payload;
99
+ } x265_nal;
100
+
101
+ #define X265_LOOKAHEAD_MAX 250
102
+
103
+ typedef struct x265_lookahead_data
104
+ {
105
+ int64_t plannedSatd[X265_LOOKAHEAD_MAX + 1];
106
+ uint32_t *vbvCost;
107
+ uint32_t *intraVbvCost;
108
+ uint32_t *satdForVbv;
109
+ uint32_t *intraSatdForVbv;
110
+ int keyframe;
111
+ int lastMiniGopBFrame;
112
+ int plannedType[X265_LOOKAHEAD_MAX + 1];
113
+ int64_t dts;
114
+ int64_t reorderedPts;
115
+ } x265_lookahead_data;
116
+
117
+ typedef struct x265_analysis_validate
118
+ {
119
+ int maxNumReferences;
120
+ int analysisReuseLevel;
121
+ int sourceWidth;
122
+ int sourceHeight;
123
+ int keyframeMax;
124
+ int keyframeMin;
125
+ int openGOP;
126
+ int bframes;
127
+ int bPyramid;
128
+ int maxCUSize;
129
+ int minCUSize;
130
+ int intraRefresh;
131
+ int lookaheadDepth;
132
+ int chunkStart;
133
+ int chunkEnd;
134
+ int cuTree;
135
+ int ctuDistortionRefine;
136
+ int rightOffset;
137
+ int bottomOffset;
138
+ int frameDuplication;
139
+ }x265_analysis_validate;
140
+
141
+ /* Stores intra analysis data for a single frame. This struct needs better packing */
142
+ typedef struct x265_analysis_intra_data
143
+ {
144
+ uint8_t* depth;
145
+ uint8_t* modes;
146
+ char* partSizes;
147
+ uint8_t* chromaModes;
148
+ int8_t* cuQPOff;
149
+ }x265_analysis_intra_data;
150
+
151
+ typedef struct x265_analysis_MV
152
+ {
153
+ union{
154
+ struct { int32_t x, y; };
155
+
156
+ int64_t word;
157
+ };
158
+ }x265_analysis_MV;
159
+
160
+ /* Stores inter analysis data for a single frame */
161
+ typedef struct x265_analysis_inter_data
162
+ {
163
+ int32_t* ref;
164
+ uint8_t* depth;
165
+ uint8_t* modes;
166
+ uint8_t* partSize;
167
+ uint8_t* mergeFlag;
168
+ uint8_t* interDir;
169
+ uint8_t* mvpIdx[2];
170
+ int8_t* refIdx[2];
171
+ x265_analysis_MV* mv[2];
172
+ int64_t* sadCost;
173
+ int8_t* cuQPOff;
174
+ }x265_analysis_inter_data;
175
+
176
+ typedef struct x265_weight_param
177
+ {
178
+ uint32_t log2WeightDenom;
179
+ int inputWeight;
180
+ int inputOffset;
181
+ int wtPresent;
182
+ }x265_weight_param;
183
+
184
+ #if X265_DEPTH < 10
185
+ typedef uint32_t sse_t;
186
+ #else
187
+ typedef uint64_t sse_t;
188
+ #endif
189
+
190
+ #define CTU_DISTORTION_OFF 0
191
+ #define CTU_DISTORTION_INTERNAL 1
192
+ #define CTU_DISTORTION_EXTERNAL 2
193
+
194
+ typedef struct x265_analysis_distortion_data
195
+ {
196
+ sse_t* ctuDistortion;
197
+ double* scaledDistortion;
198
+ double averageDistortion;
199
+ double sdDistortion;
200
+ uint32_t highDistortionCtuCount;
201
+ uint32_t lowDistortionCtuCount;
202
+ double* offset;
203
+ double* threshold;
204
+
205
+ }x265_analysis_distortion_data;
206
+
207
+ #define MAX_NUM_REF 16
208
+ #define EDGE_BINS 2
209
+ #define MAX_HIST_BINS 1024
210
+
211
+ /* Stores all analysis data for a single frame */
212
+ typedef struct x265_analysis_data
213
+ {
214
+ int64_t satdCost;
215
+ uint32_t frameRecordSize;
216
+ uint32_t poc;
217
+ uint32_t sliceType;
218
+ uint32_t numCUsInFrame;
219
+ uint32_t numPartitions;
220
+ uint32_t depthBytes;
221
+ int32_t edgeHist[EDGE_BINS];
222
+ int32_t yuvHist[3][MAX_HIST_BINS];
223
+ int bScenecut;
224
+ x265_weight_param* wt;
225
+ x265_analysis_inter_data* interData;
226
+ x265_analysis_intra_data* intraData;
227
+ uint32_t numCuInHeight;
228
+ x265_lookahead_data lookahead;
229
+ uint8_t* modeFlag[2];
230
+ x265_analysis_validate saveParam;
231
+ x265_analysis_distortion_data* distortionData;
232
+ uint64_t frameBits;
233
+ int list0POC[MAX_NUM_REF];
234
+ int list1POC[MAX_NUM_REF];
235
+ double totalIntraPercent;
236
+ } x265_analysis_data;
237
+
238
+ /* cu statistics */
239
+ typedef struct x265_cu_stats
240
+ {
241
+ double percentSkipCu[4]; // Percentage of skip cu in all depths
242
+ double percentMergeCu[4]; // Percentage of merge cu in all depths
243
+ double percentIntraDistribution[4][3]; // Percentage of DC, Planar, Angular intra modes in all depths
244
+ double percentInterDistribution[4][3]; // Percentage of 2Nx2N inter, rect and amp in all depths
245
+ double percentIntraNxN; // Percentage of 4x4 cu
246
+
247
+ /* All the above values will add up to 100%. */
248
+ } x265_cu_stats;
249
+
250
+
251
+ /* pu statistics */
252
+ typedef struct x265_pu_stats
253
+ {
254
+ double percentSkipPu[4]; // Percentage of skip cu in all depths
255
+ double percentIntraPu[4]; // Percentage of intra modes in all depths
256
+ double percentAmpPu[4]; // Percentage of amp modes in all depths
257
+ double percentInterPu[4][3]; // Percentage of inter 2nx2n, 2nxn and nx2n in all depths
258
+ double percentMergePu[4][3]; // Percentage of merge 2nx2n, 2nxn and nx2n in all depth
259
+ double percentNxN;
260
+
261
+ /* All the above values will add up to 100%. */
262
+ } x265_pu_stats;
263
+
264
+ /* Frame level statistics */
265
+ typedef struct x265_frame_stats
266
+ {
267
+ double qp;
268
+ double rateFactor;
269
+ double psnrY;
270
+ double psnrU;
271
+ double psnrV;
272
+ double psnr;
273
+ double ssim;
274
+ double decideWaitTime;
275
+ double row0WaitTime;
276
+ double wallTime;
277
+ double refWaitWallTime;
278
+ double totalCTUTime;
279
+ double stallTime;
280
+ double avgWPP;
281
+ double avgLumaDistortion;
282
+ double avgChromaDistortion;
283
+ double avgPsyEnergy;
284
+ double avgResEnergy;
285
+ double avgLumaLevel;
286
+ double bufferFill;
287
+ uint64_t bits;
288
+ int encoderOrder;
289
+ int poc;
290
+ int countRowBlocks;
291
+ int list0POC[MAX_NUM_REF];
292
+ int list1POC[MAX_NUM_REF];
293
+ uint16_t maxLumaLevel;
294
+ uint16_t minLumaLevel;
295
+
296
+ uint16_t maxChromaULevel;
297
+ uint16_t minChromaULevel;
298
+ double avgChromaULevel;
299
+
300
+
301
+ uint16_t maxChromaVLevel;
302
+ uint16_t minChromaVLevel;
303
+ double avgChromaVLevel;
304
+
305
+ char sliceType;
306
+ int bScenecut;
307
+ double ipCostRatio;
308
+ int frameLatency;
309
+ x265_cu_stats cuStats;
310
+ x265_pu_stats puStats;
311
+ double totalFrameTime;
312
+ double vmafFrameScore;
313
+ double bufferFillFinal;
314
+ double unclippedBufferFillFinal;
315
+ uint8_t tLayer;
316
+ } x265_frame_stats;
317
+
318
+ typedef struct x265_ctu_info_t
319
+ {
320
+ int32_t ctuAddress;
321
+ int32_t ctuPartitions[64];
322
+ void* ctuInfo;
323
+ } x265_ctu_info_t;
324
+
325
+ typedef enum
326
+ {
327
+ NO_CTU_INFO = 0,
328
+ HAS_CTU_INFO = 1,
329
+ CTU_INFO_CHANGE = 2,
330
+ }CTUInfo;
331
+
332
+ typedef enum
333
+ {
334
+ DEFAULT = 0,
335
+ AVC_INFO = 1,
336
+ HEVC_INFO = 2,
337
+ }AnalysisRefineType;
338
+
339
+ /* Arbitrary User SEI
340
+ * Payload size is in bytes and the payload pointer must be non-NULL.
341
+ * Payload types and syntax can be found in Annex D of the H.265 Specification.
342
+ * SEI Payload Alignment bits as described in Annex D must be included at the
343
+ * end of the payload if needed. The payload should not be NAL-encapsulated.
344
+ * Payloads are written in the order of input */
345
+
346
+ typedef enum
347
+ {
348
+ BUFFERING_PERIOD = 0,
349
+ PICTURE_TIMING = 1,
350
+ PAN_SCAN_RECT = 2,
351
+ FILLER_PAYLOAD = 3,
352
+ USER_DATA_REGISTERED_ITU_T_T35 = 4,
353
+ USER_DATA_UNREGISTERED = 5,
354
+ RECOVERY_POINT = 6,
355
+ SCENE_INFO = 9,
356
+ FULL_FRAME_SNAPSHOT = 15,
357
+ PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
358
+ PROGRESSIVE_REFINEMENT_SEGMENT_END = 17,
359
+ FILM_GRAIN_CHARACTERISTICS = 19,
360
+ POST_FILTER_HINT = 22,
361
+ TONE_MAPPING_INFO = 23,
362
+ FRAME_PACKING = 45,
363
+ DISPLAY_ORIENTATION = 47,
364
+ SOP_DESCRIPTION = 128,
365
+ ACTIVE_PARAMETER_SETS = 129,
366
+ DECODING_UNIT_INFO = 130,
367
+ TEMPORAL_LEVEL0_INDEX = 131,
368
+ DECODED_PICTURE_HASH = 132,
369
+ SCALABLE_NESTING = 133,
370
+ REGION_REFRESH_INFO = 134,
371
+ MASTERING_DISPLAY_INFO = 137,
372
+ CONTENT_LIGHT_LEVEL_INFO = 144,
373
+ ALTERNATIVE_TRANSFER_CHARACTERISTICS = 147,
374
+ ALPHA_CHANNEL_INFO = 165,
375
+ THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO = 176,
376
+ MULTIVIEW_SCENE_INFO = 178,
377
+ MULTIVIEW_ACQUISITION_INFO = 179,
378
+ MULTIVIEW_VIEW_POSITION = 180
379
+ } SEIPayloadType;
380
+
381
+ typedef struct x265_sei_payload
382
+ {
383
+ int payloadSize;
384
+ SEIPayloadType payloadType;
385
+ uint8_t* payload;
386
+ } x265_sei_payload;
387
+
388
+ typedef struct x265_sei
389
+ {
390
+ int numPayloads;
391
+ x265_sei_payload *payloads;
392
+ } x265_sei;
393
+
394
+ typedef struct x265_dolby_vision_rpu
395
+ {
396
+ int payloadSize;
397
+ uint8_t* payload;
398
+ }x265_dolby_vision_rpu;
399
+
400
+ /* Used to pass pictures into the encoder, and to get picture data back out of
401
+ * the encoder. The input and output semantics are different */
402
+ typedef struct x265_picture
403
+ {
404
+ /* presentation time stamp: user-specified, returned on output */
405
+ int64_t pts;
406
+
407
+ /* display time stamp: ignored on input, copied from reordered pts. Returned
408
+ * on output */
409
+ int64_t dts;
410
+
411
+ /* force quantizer for != X265_QP_AUTO */
412
+ /* The value provided on input is returned with the same picture (POC) on
413
+ * output */
414
+ void* userData;
415
+
416
+ /* Must be specified on input pictures, the number of planes is determined
417
+ * by the colorSpace value */
418
+ void* planes[4];
419
+
420
+ /* Stride is the number of bytes between row starts */
421
+ int stride[4];
422
+
423
+ /* Must be specified on input pictures. x265_picture_init() will set it to
424
+ * the encoder's internal bit depth, but this field must describe the depth
425
+ * of the input pictures. Must be between 8 and 16. Values larger than 8
426
+ * imply 16bits per input sample. If input bit depth is larger than the
427
+ * internal bit depth, the encoder will down-shift pixels. Input samples
428
+ * larger than 8bits will be masked to internal bit depth. On output the
429
+ * bitDepth will be the internal encoder bit depth */
430
+ int bitDepth;
431
+
432
+ /* Must be specified on input pictures: X265_TYPE_AUTO or other.
433
+ * x265_picture_init() sets this to auto, returned on output */
434
+ int sliceType;
435
+
436
+ /* Ignored on input, set to picture count, returned on output */
437
+ int poc;
438
+
439
+ /* Must be specified on input pictures: X265_CSP_I420 or other. It must
440
+ * match the internal color space of the encoder. x265_picture_init() will
441
+ * initialize this value to the internal color space */
442
+ int colorSpace;
443
+
444
+ /* Force the slice base QP for this picture within the encoder. Set to 0
445
+ * to allow the encoder to determine base QP */
446
+ int forceqp;
447
+
448
+ /* If param.analysisLoad and param.analysisSave are disabled, this field is
449
+ * ignored on input and output. Else the user must call x265_alloc_analysis_data()
450
+ * to allocate analysis buffers for every picture passed to the encoder.
451
+ *
452
+ * On input when param.analysisLoad is enabled and analysisData
453
+ * member pointers are valid, the encoder will use the data stored here to
454
+ * reduce encoder work.
455
+ *
456
+ * On output when param.analysisSave is enabled and analysisData
457
+ * member pointers are valid, the encoder will write output analysis into
458
+ * this data structure */
459
+ x265_analysis_data analysisData;
460
+
461
+ /* An array of quantizer offsets to be applied to this image during encoding.
462
+ * These are added on top of the decisions made by rateControl.
463
+ * Adaptive quantization must be enabled to use this feature. These quantizer
464
+ * offsets should be given for each 16x16 block (8x8 block, when qg-size is 8).
465
+ * Behavior if quant offsets differ between encoding passes is undefined. */
466
+ float *quantOffsets;
467
+
468
+ /* Frame level statistics */
469
+ x265_frame_stats frameData;
470
+
471
+ /* User defined SEI */
472
+ x265_sei userSEI;
473
+
474
+ /* Ratecontrol statistics for collecting the ratecontrol information.
475
+ * It is not used for collecting the last pass ratecontrol data in
476
+ * multi pass ratecontrol mode. */
477
+ void* rcData;
478
+
479
+ size_t framesize;
480
+
481
+ int height;
482
+
483
+ // pts is reordered in the order of encoding.
484
+ int64_t reorderedPts;
485
+
486
+ //Dolby Vision RPU metadata
487
+ x265_dolby_vision_rpu rpu;
488
+
489
+ int fieldNum;
490
+
491
+ //SEI picture structure message
492
+ uint32_t picStruct;
493
+
494
+ int width;
495
+
496
+ int layerID;
497
+ int format;
498
+ } x265_picture;
499
+
500
+ typedef enum
501
+ {
502
+ X265_DIA_SEARCH,
503
+ X265_HEX_SEARCH,
504
+ X265_UMH_SEARCH,
505
+ X265_STAR_SEARCH,
506
+ X265_SEA,
507
+ X265_FULL_SEARCH
508
+ } X265_ME_METHODS;
509
+
510
+ /* CPU flags */
511
+
512
+ /* x86 */
513
+ #define X265_CPU_MMX (1 << 0)
514
+ #define X265_CPU_MMX2 (1 << 1) /* MMX2 aka MMXEXT aka ISSE */
515
+ #define X265_CPU_MMXEXT X265_CPU_MMX2
516
+ #define X265_CPU_SSE (1 << 2)
517
+ #define X265_CPU_SSE2 (1 << 3)
518
+ #define X265_CPU_LZCNT (1 << 4)
519
+ #define X265_CPU_SSE3 (1 << 5)
520
+ #define X265_CPU_SSSE3 (1 << 6)
521
+ #define X265_CPU_SSE4 (1 << 7) /* SSE4.1 */
522
+ #define X265_CPU_SSE42 (1 << 8) /* SSE4.2 */
523
+ #define X265_CPU_AVX (1 << 9) /* Requires OS support even if YMM registers aren't used. */
524
+ #define X265_CPU_XOP (1 << 10) /* AMD XOP */
525
+ #define X265_CPU_FMA4 (1 << 11) /* AMD FMA4 */
526
+ #define X265_CPU_FMA3 (1 << 12) /* Intel FMA3 */
527
+ #define X265_CPU_BMI1 (1 << 13) /* BMI1 */
528
+ #define X265_CPU_BMI2 (1 << 14) /* BMI2 */
529
+ #define X265_CPU_AVX2 (1 << 15) /* AVX2 */
530
+ #define X265_CPU_AVX512 (1 << 16) /* AVX-512 {F, CD, BW, DQ, VL}, requires OS support */
531
+ /* x86 modifiers */
532
+ #define X265_CPU_CACHELINE_32 (1 << 17) /* avoid memory loads that span the border between two cachelines */
533
+ #define X265_CPU_CACHELINE_64 (1 << 18) /* 32/64 is the size of a cacheline in bytes */
534
+ #define X265_CPU_SSE2_IS_SLOW (1 << 19) /* avoid most SSE2 functions on Athlon64 */
535
+ #define X265_CPU_SSE2_IS_FAST (1 << 20) /* a few functions are only faster on Core2 and Phenom */
536
+ #define X265_CPU_SLOW_SHUFFLE (1 << 21) /* The Conroe has a slow shuffle unit (relative to overall SSE performance) */
537
+ #define X265_CPU_STACK_MOD4 (1 << 22) /* if stack is only mod4 and not mod16 */
538
+ #define X265_CPU_SLOW_ATOM (1 << 23) /* The Atom is terrible: slow SSE unaligned loads, slow
539
+ * SIMD multiplies, slow SIMD variable shifts, slow pshufb,
540
+ * cacheline split penalties -- gather everything here that
541
+ * isn't shared by other CPUs to avoid making half a dozen
542
+ * new SLOW flags. */
543
+ #define X265_CPU_SLOW_PSHUFB (1 << 24) /* such as on the Intel Atom */
544
+ #define X265_CPU_SLOW_PALIGNR (1 << 25) /* such as on the AMD Bobcat */
545
+
546
+ /* ARM */
547
+ #define X265_CPU_ARMV6 (1 << 0)
548
+ #define X265_CPU_NEON (1 << 1) /* ARM NEON */
549
+ #define X265_CPU_FAST_NEON_MRC (1 << 2) /* Transfer from NEON to ARM register is fast (Cortex-A9) */
550
+ #define X265_CPU_SVE2 (1 << 3) /* AArch64 SVE2 */
551
+ #define X265_CPU_SVE (1 << 4) /* AArch64 SVE2 */
552
+ #define X265_CPU_NEON_DOTPROD (1 << 5) /* AArch64 Neon DotProd */
553
+ #define X265_CPU_NEON_I8MM (1 << 6) /* AArch64 Neon I8MM */
554
+
555
+ /* IBM Power8 */
556
+ #define X265_CPU_ALTIVEC 0x0000001
557
+
558
+ #define X265_MAX_SUBPEL_LEVEL 7
559
+
560
+ /* Log level */
561
+ #define X265_LOG_NONE (-1)
562
+ #define X265_LOG_ERROR 0
563
+ #define X265_LOG_WARNING 1
564
+ #define X265_LOG_INFO 2
565
+ #define X265_LOG_DEBUG 3
566
+ #define X265_LOG_FULL 4
567
+
568
+ #define X265_B_ADAPT_NONE 0
569
+ #define X265_B_ADAPT_FAST 1
570
+ #define X265_B_ADAPT_TRELLIS 2
571
+
572
+ #define X265_REF_LIMIT_DEPTH 1
573
+ #define X265_REF_LIMIT_CU 2
574
+
575
+ #define X265_TU_LIMIT_BFS 1
576
+ #define X265_TU_LIMIT_DFS 2
577
+ #define X265_TU_LIMIT_NEIGH 4
578
+
579
+ #define X265_BFRAME_MAX 16
580
+ #define X265_MAX_FRAME_THREADS 16
581
+
582
+ #define X265_TYPE_AUTO 0x0000 /* Let x265 choose the right type */
583
+ #define X265_TYPE_IDR 0x0001
584
+ #define X265_TYPE_I 0x0002
585
+ #define X265_TYPE_P 0x0003
586
+ #define X265_TYPE_BREF 0x0004 /* Non-disposable B-frame */
587
+ #define X265_TYPE_B 0x0005
588
+ #define IS_X265_TYPE_I(x) ((x) == X265_TYPE_I || (x) == X265_TYPE_IDR)
589
+ #define IS_X265_TYPE_B(x) ((x) == X265_TYPE_B || (x) == X265_TYPE_BREF)
590
+
591
+ #define X265_QP_AUTO 0
592
+
593
+ #define X265_AQ_NONE 0
594
+ #define X265_AQ_VARIANCE 1
595
+ #define X265_AQ_AUTO_VARIANCE 2
596
+ #define X265_AQ_AUTO_VARIANCE_BIASED 3
597
+ #define X265_AQ_EDGE 4
598
+ #define x265_ADAPT_RD_STRENGTH 4
599
+ #define X265_REFINE_INTER_LEVELS 3
600
+ /* NOTE! For this release only X265_CSP_I420 and X265_CSP_I444 are supported */
601
+ /* Supported internal color space types (according to semantics of chroma_format_idc) */
602
+ #define X265_CSP_I400 0 /* yuv 4:0:0 planar */
603
+ #define X265_CSP_I420 1 /* yuv 4:2:0 planar */
604
+ #define X265_CSP_I422 2 /* yuv 4:2:2 planar */
605
+ #define X265_CSP_I444 3 /* yuv 4:4:4 planar */
606
+ #define X265_CSP_COUNT 4 /* Number of supported internal color spaces */
607
+
608
+ /* These color spaces will eventually be supported as input pictures. The pictures will
609
+ * be converted to the appropriate planar color spaces at ingest */
610
+ #define X265_CSP_NV12 4 /* yuv 4:2:0, with one y plane and one packed u+v */
611
+ #define X265_CSP_NV16 5 /* yuv 4:2:2, with one y plane and one packed u+v */
612
+
613
+ /* Interleaved color-spaces may eventually be supported as input pictures */
614
+ #define X265_CSP_BGR 6 /* packed bgr 24bits */
615
+ #define X265_CSP_BGRA 7 /* packed bgr 32bits */
616
+ #define X265_CSP_RGB 8 /* packed rgb 24bits */
617
+ #define X265_CSP_MAX 9 /* end of list */
618
+ #define X265_EXTENDED_SAR 255 /* aspect ratio explicitly specified as width:height */
619
+ /* Analysis options */
620
+ #define X265_ANALYSIS_OFF 0
621
+ #define X265_ANALYSIS_SAVE 1
622
+ #define X265_ANALYSIS_LOAD 2
623
+
624
+ #define FORWARD 1
625
+ #define BACKWARD 2
626
+ #define BI_DIRECTIONAL 3
627
+ #define SLICE_TYPE_DELTA 0.3 /* The offset decremented or incremented for P-frames or b-frames respectively*/
628
+ #define BACKWARD_WINDOW 1 /* Scenecut window before a scenecut */
629
+ #define FORWARD_WINDOW 2 /* Scenecut window after a scenecut */
630
+ #define BWD_WINDOW_DELTA 0.4
631
+
632
+ #define X265_MAX_GOP_CONFIG 3
633
+ #define X265_MAX_GOP_LENGTH 16
634
+ #define MAX_T_LAYERS 7
635
+
636
+ #if ENABLE_MULTIVIEW
637
+ #define MAX_VIEWS 2
638
+ #define MAX_VPS_NUM_SCALABILITY_TYPES 16
639
+ #define MAX_VPS_LAYER_ID_PLUS1 MAX_VIEWS
640
+ #define MULTIVIEW_SCALABILITY_IDX 1
641
+ #else
642
+ #define MAX_VIEWS 1
643
+ #endif
644
+
645
+ #if ENABLE_ALPHA
646
+ #define MAX_SCALABLE_LAYERS 2
647
+ #define MAX_VPS_NUM_SCALABILITY_TYPES 16
648
+ #define MAX_VPS_LAYER_ID_PLUS1 MAX_SCALABLE_LAYERS
649
+ #else
650
+ #define MAX_SCALABLE_LAYERS 1
651
+ #endif
652
+
653
+ #if ENABLE_ALPHA || ENABLE_MULTIVIEW
654
+ #define MAX_LAYERS 2
655
+ #else
656
+ #define MAX_LAYERS 1
657
+ #endif
658
+
659
+ #if ENABLE_SCC_EXT
660
+ /* SCC Extension Options */
661
+ #define SCC_EXT_IDX 3
662
+ #define NUM_EXTENSION_FLAGS 8
663
+ #define SCM_S0067_NUM_CANDIDATES 64
664
+ #define CHROMA_REFINEMENT_CANDIDATES 8
665
+ #define SCM_S0067_IBC_FULL_1D_SEARCH_FOR_PU 2 ///< Do full horizontal/vertical search for Nx2N
666
+ #define SCM_S0067_MAX_CAND_SIZE 32 ///< 32 or 64, 16 by default
667
+ #define NUM_RECON_VERSION 2
668
+ #else
669
+ #define NUM_RECON_VERSION 1
670
+ #endif
671
+
672
+ #define X265_IPRATIO_STRENGTH 1.43
673
+
674
+ typedef struct x265_cli_csp
675
+ {
676
+ int planes;
677
+ int width[4];
678
+ int height[4];
679
+ } x265_cli_csp;
680
+
681
+ static const x265_cli_csp x265_cli_csps[] =
682
+ {
683
+ { 1, { 0, 0, 0 }, { 0, 0, 0 } }, /* i400 */
684
+ { 3, { 0, 1, 1 }, { 0, 1, 1 } }, /* i420 */
685
+ { 3, { 0, 1, 1 }, { 0, 0, 0 } }, /* i422 */
686
+ { 3, { 0, 0, 0 }, { 0, 0, 0 } }, /* i444 */
687
+ { 2, { 0, 0 }, { 0, 1 } }, /* nv12 */
688
+ { 2, { 0, 0 }, { 0, 0 } }, /* nv16 */
689
+ };
690
+
691
+ /* rate tolerance method */
692
+ typedef enum
693
+ {
694
+ X265_RC_ABR,
695
+ X265_RC_CQP,
696
+ X265_RC_CRF
697
+ } X265_RC_METHODS;
698
+
699
+ /* slice type statistics */
700
+ typedef struct x265_sliceType_stats
701
+ {
702
+ double avgQp;
703
+ double bitrate;
704
+ double psnrY;
705
+ double psnrU;
706
+ double psnrV;
707
+ double ssim;
708
+ uint32_t numPics;
709
+ } x265_sliceType_stats;
710
+
711
+ /* Output statistics from encoder */
712
+ typedef struct x265_stats
713
+ {
714
+ double globalPsnrY;
715
+ double globalPsnrU;
716
+ double globalPsnrV;
717
+ double globalPsnr;
718
+ double globalSsim;
719
+ double elapsedEncodeTime; /* wall time since encoder was opened */
720
+ double elapsedVideoTime; /* encoded picture count / frame rate */
721
+ double bitrate; /* accBits / elapsed video time */
722
+ double aggregateVmafScore; /* aggregate VMAF score for input video*/
723
+ uint64_t accBits; /* total bits output thus far */
724
+ uint32_t encodedPictureCount; /* number of output pictures thus far */
725
+ uint32_t totalWPFrames; /* number of uni-directional weighted frames used */
726
+ x265_sliceType_stats statsI; /* statistics of I slice */
727
+ x265_sliceType_stats statsP; /* statistics of P slice */
728
+ x265_sliceType_stats statsB; /* statistics of B slice */
729
+ uint16_t maxCLL; /* maximum content light level */
730
+ uint16_t maxFALL; /* maximum frame average light level */
731
+ } x265_stats;
732
+
733
+ /* String values accepted by x265_param_parse() (and CLI) for various parameters */
734
+ static const char * const x265_motion_est_names[] = { "dia", "hex", "umh", "star", "sea", "full", 0 };
735
+ static const char * const x265_source_csp_names[] = { "i400", "i420", "i422", "i444", "nv12", "nv16", 0 };
736
+ static const char * const x265_video_format_names[] = { "component", "pal", "ntsc", "secam", "mac", "unknown", 0 };
737
+ static const char * const x265_fullrange_names[] = { "limited", "full", 0 };
738
+ static const char * const x265_colorprim_names[] = { "reserved", "bt709", "unknown", "reserved", "bt470m", "bt470bg", "smpte170m", "smpte240m", "film", "bt2020", "smpte428", "smpte431", "smpte432", 0 };
739
+ static const char * const x265_transfer_names[] = { "reserved", "bt709", "unknown", "reserved", "bt470m", "bt470bg", "smpte170m", "smpte240m", "linear", "log100",
740
+ "log316", "iec61966-2-4", "bt1361e", "iec61966-2-1", "bt2020-10", "bt2020-12",
741
+ "smpte2084", "smpte428", "arib-std-b67", 0 };
742
+ static const char * const x265_colmatrix_names[] = { "gbr", "bt709", "unknown", "", "fcc", "bt470bg", "smpte170m", "smpte240m",
743
+ "ycgco", "bt2020nc", "bt2020c", "smpte2085", "chroma-derived-nc", "chroma-derived-c", "ictcp", 0 };
744
+ static const char * const x265_sar_names[] = { "unknown", "1:1", "12:11", "10:11", "16:11", "40:33", "24:11", "20:11",
745
+ "32:11", "80:33", "18:11", "15:11", "64:33", "160:99", "4:3", "3:2", "2:1", 0 };
746
+ static const char * const x265_interlace_names[] = { "prog", "tff", "bff", 0 };
747
+ static const char * const x265_analysis_names[] = { "off", "save", "load", 0 };
748
+
749
+ struct x265_zone;
750
+ struct x265_param;
751
+ /* Zones: override ratecontrol for specific sections of the video.
752
+ * If zones overlap, whichever comes later in the list takes precedence. */
753
+ typedef struct x265_zone
754
+ {
755
+ int startFrame, endFrame; /* range of frame numbers */
756
+ int keyframeMax; /* it store the default/user defined keyframeMax value*/
757
+ int bForceQp; /* whether to use qp vs bitrate factor */
758
+ int qp;
759
+ float bitrateFactor;
760
+ struct x265_param* zoneParam;
761
+ double* relativeComplexity;
762
+ } x265_zone;
763
+
764
+ /* data to calculate aggregate VMAF score */
765
+ typedef struct x265_vmaf_data
766
+ {
767
+ int width;
768
+ int height;
769
+ size_t offset;
770
+ int internalBitDepth;
771
+ FILE *reference_file; /* FILE pointer for input file */
772
+ FILE *distorted_file; /* FILE pointer for recon file generated*/
773
+ }x265_vmaf_data;
774
+
775
+ /* data to calculate frame level VMAF score */
776
+ typedef struct x265_vmaf_framedata
777
+ {
778
+ int width;
779
+ int height;
780
+ int frame_set;
781
+ int internalBitDepth;
782
+ void *reference_frame; /* points to fenc of particular frame */
783
+ void *distorted_frame; /* points to recon of particular frame */
784
+ }x265_vmaf_framedata;
785
+
786
+ /* common data needed to calculate both frame level and video level VMAF scores */
787
+ typedef struct x265_vmaf_commondata
788
+ {
789
+ char *format;
790
+ char *model_path;
791
+ char *log_path;
792
+ char *log_fmt;
793
+ int disable_clip;
794
+ int disable_avx;
795
+ int enable_transform;
796
+ int phone_model;
797
+ int psnr;
798
+ int ssim;
799
+ int ms_ssim;
800
+ char *pool;
801
+ int thread;
802
+ int subsample;
803
+ }x265_vmaf_commondata;
804
+
805
+ static x265_vmaf_commondata vcd[] = { { NULL, (char *)"/usr/local/share/model/vmaf_v0.6.1.json", NULL, NULL, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 1} };
806
+
807
+ typedef struct x265_temporal_layer {
808
+ int poc_offset; /* POC offset */
809
+ int8_t layer; /* Current layer */
810
+ int8_t qp_offset; /* QP offset */
811
+ } x265_temporal_layer;
812
+
813
+ static const int8_t x265_temporal_layer_bframes[MAX_T_LAYERS] = {-1, -1, 3, 7, 15, -1, -1};
814
+
815
+ static const int8_t x265_gop_ra_length[X265_MAX_GOP_CONFIG] = { 4, 8, 16};
816
+ static const x265_temporal_layer x265_gop_ra[X265_MAX_GOP_CONFIG][X265_MAX_GOP_LENGTH] = {
817
+ {
818
+ {
819
+ 4,
820
+ 0,
821
+ 1,
822
+ },
823
+ {
824
+ 2,
825
+ 1,
826
+ 5,
827
+ },
828
+ {
829
+ 1,
830
+ 2,
831
+ 3,
832
+ },
833
+ {
834
+ 3,
835
+ 2,
836
+ 5,
837
+ },
838
+ {
839
+ -1,
840
+ -1,
841
+ -1,
842
+ },
843
+ {
844
+ -1,
845
+ -1,
846
+ -1,
847
+ },
848
+ {
849
+ -1,
850
+ -1,
851
+ -1,
852
+ },
853
+ {
854
+ -1,
855
+ -1,
856
+ -1,
857
+ },
858
+ {
859
+ -1,
860
+ -1,
861
+ -1,
862
+ },
863
+ {
864
+ -1,
865
+ -1,
866
+ -1,
867
+ },
868
+ {
869
+ -1,
870
+ -1,
871
+ -1,
872
+ },
873
+ {
874
+ -1,
875
+ -1,
876
+ -1,
877
+ },
878
+ {
879
+ -1,
880
+ -1,
881
+ -1,
882
+ },
883
+ {
884
+ -1,
885
+ -1,
886
+ -1,
887
+ },
888
+ {
889
+ -1,
890
+ -1,
891
+ -1,
892
+ },
893
+ {
894
+ -1,
895
+ -1,
896
+ -1,
897
+ }
898
+ },
899
+
900
+ {
901
+ {
902
+ 8,
903
+ 0,
904
+ 1,
905
+ },
906
+ {
907
+ 4,
908
+ 1,
909
+ 5,
910
+ },
911
+ {
912
+ 2,
913
+ 2,
914
+ 4,
915
+ },
916
+ {
917
+ 1,
918
+ 3,
919
+ 5,
920
+ },
921
+ {
922
+ 3,
923
+ 3,
924
+ 2,
925
+ },
926
+ {
927
+ 6,
928
+ 2,
929
+ 5,
930
+ },
931
+ {
932
+ 5,
933
+ 3,
934
+ 4,
935
+ },
936
+ {
937
+ 7,
938
+ 3,
939
+ 5,
940
+ },
941
+ {
942
+ -1,
943
+ -1,
944
+ -1,
945
+ },
946
+ {
947
+ -1,
948
+ -1,
949
+ -1,
950
+ },
951
+ {
952
+ -1,
953
+ -1,
954
+ -1,
955
+ },
956
+ {
957
+ -1,
958
+ -1,
959
+ -1,
960
+ },
961
+ {
962
+ -1,
963
+ -1,
964
+ -1,
965
+ },
966
+ {
967
+ -1,
968
+ -1,
969
+ -1,
970
+ },
971
+ {
972
+ -1,
973
+ -1,
974
+ -1,
975
+ },
976
+ {
977
+ -1,
978
+ -1,
979
+ -1,
980
+ },
981
+ },
982
+ {
983
+ {
984
+ 16,
985
+ 0,
986
+ 1,
987
+ },
988
+ {
989
+ 8,
990
+ 1,
991
+ 6,
992
+ },
993
+ {
994
+ 4,
995
+ 2,
996
+ 5,
997
+ },
998
+ {
999
+ 2,
1000
+ 3,
1001
+ 6,
1002
+ },
1003
+ {
1004
+ 1,
1005
+ 4,
1006
+ 4,
1007
+ },
1008
+ {
1009
+ 3,
1010
+ 4,
1011
+ 6,
1012
+ },
1013
+ {
1014
+ 6,
1015
+ 3,
1016
+ 5,
1017
+ },
1018
+ {
1019
+ 5,
1020
+ 4,
1021
+ 6,
1022
+ },
1023
+ {
1024
+ 7,
1025
+ 4,
1026
+ 1,
1027
+ },
1028
+ {
1029
+ 12,
1030
+ 2,
1031
+ 6,
1032
+ },
1033
+ {
1034
+ 10,
1035
+ 3,
1036
+ 5,
1037
+ },
1038
+ {
1039
+ 9,
1040
+ 4,
1041
+ 6,
1042
+ },
1043
+ {
1044
+ 11,
1045
+ 4,
1046
+ 4,
1047
+ },
1048
+ {
1049
+ 14,
1050
+ 3,
1051
+ 6,
1052
+ },
1053
+ {
1054
+ 13,
1055
+ 4,
1056
+ 5,
1057
+ },
1058
+ {
1059
+ 15,
1060
+ 4,
1061
+ 6,
1062
+ }
1063
+ }
1064
+ };
1065
+
1066
+ typedef enum
1067
+ {
1068
+ X265_SHARE_MODE_FILE = 0,
1069
+ X265_SHARE_MODE_SHAREDMEM
1070
+ }X265_DATA_SHARE_MODES;
1071
+
1072
+ /* x265 input parameters
1073
+ *
1074
+ * For version safety you may use x265_param_alloc/free() to manage the
1075
+ * allocation of x265_param instances, and x265_param_parse() to assign values
1076
+ * by name. By never dereferencing param fields in your own code you can treat
1077
+ * x265_param as an opaque data structure */
1078
+ typedef struct x265_param
1079
+ {
1080
+ /* x265_param_default() will auto-detect this cpu capability bitmap. it is
1081
+ * recommended to not change this value unless you know the cpu detection is
1082
+ * somehow flawed on your target hardware. The asm function tables are
1083
+ * process global, the first encoder configures them for all encoders */
1084
+ int cpuid;
1085
+ /*== Parallelism Features ==*/
1086
+
1087
+ /* Number of concurrently encoded frames between 1 and X265_MAX_FRAME_THREADS
1088
+ * or 0 for auto-detection. By default x265 will use a number of frame
1089
+ * threads empirically determined to be optimal for your CPU core count,
1090
+ * between 2 and 6. Using more than one frame thread causes motion search
1091
+ * in the down direction to be clamped but otherwise encode behavior is
1092
+ * unaffected. With CQP rate control the output bitstream is deterministic
1093
+ * for all values of frameNumThreads greater than 1. All other forms of
1094
+ * rate-control can be negatively impacted by increases to the number of
1095
+ * frame threads because the extra concurrency adds uncertainty to the
1096
+ * bitrate estimations. Frame parallelism is generally limited by the the
1097
+ * is generally limited by the the number of CU rows
1098
+ *
1099
+ * When thread pools are used, each frame thread is assigned to a single
1100
+ * pool and the frame thread itself is given the node affinity of its pool.
1101
+ * But when no thread pools are used no node affinity is assigned. */
1102
+ int frameNumThreads;
1103
+
1104
+ /* Comma seperated list of threads per NUMA node. If "none", then no worker
1105
+ * pools are created and only frame parallelism is possible. If NULL or ""
1106
+ * (default) x265 will use all available threads on each NUMA node.
1107
+ *
1108
+ * '+' is a special value indicating all cores detected on the node
1109
+ * '*' is a special value indicating all cores detected on the node and all
1110
+ * remaining nodes.
1111
+ * '-' is a special value indicating no cores on the node, same as '0'
1112
+ *
1113
+ * example strings for a 4-node system:
1114
+ * "" - default, unspecified, all numa nodes are used for thread pools
1115
+ * "*" - same as default
1116
+ * "none" - no thread pools are created, only frame parallelism possible
1117
+ * "-" - same as "none"
1118
+ * "10" - allocate one pool, using up to 10 cores on node 0
1119
+ * "-,+" - allocate one pool, using all cores on node 1
1120
+ * "+,-,+" - allocate two pools, using all cores on nodes 0 and 2
1121
+ * "+,-,+,-" - allocate two pools, using all cores on nodes 0 and 2
1122
+ * "-,*" - allocate three pools, using all cores on nodes 1, 2 and 3
1123
+ * "8,8,8,8" - allocate four pools with up to 8 threads in each pool
1124
+ *
1125
+ * The total number of threads will be determined by the number of threads
1126
+ * assigned to all nodes. The worker threads will each be given affinity for
1127
+ * their node, they will not be allowed to migrate between nodes, but they
1128
+ * will be allowed to move between CPU cores within their node.
1129
+ *
1130
+ * If the three pool features: bEnableWavefront, bDistributeModeAnalysis and
1131
+ * bDistributeMotionEstimation are all disabled, then numaPools is ignored
1132
+ * and no thread pools are created.
1133
+ *
1134
+ * If "none" is specified, then all three of the thread pool features are
1135
+ * implicitly disabled.
1136
+ *
1137
+ * Multiple thread pools will be allocated for any NUMA node with more than
1138
+ * 64 logical CPU cores. But any given thread pool will always use at most
1139
+ * one NUMA node.
1140
+ *
1141
+ * Frame encoders are distributed between the available thread pools, and
1142
+ * the encoder will never generate more thread pools than frameNumThreads */
1143
+ const char* numaPools;
1144
+
1145
+ /* Enable wavefront parallel processing, greatly increases parallelism for
1146
+ * less than 1% compression efficiency loss. Requires a thread pool, enabled
1147
+ * by default */
1148
+ int bEnableWavefront;
1149
+
1150
+ /* Use multiple threads to measure CU mode costs. Recommended for many core
1151
+ * CPUs. On RD levels less than 5, it may not offload enough work to warrant
1152
+ * the overhead. It is useful with the slow preset since it has the
1153
+ * rectangular predictions enabled. At RD level 5 and 6 (preset slower and
1154
+ * below), this feature should be an unambiguous win if you have CPU
1155
+ * cores available for work. Default disabled */
1156
+ int bDistributeModeAnalysis;
1157
+
1158
+ /* Use multiple threads to perform motion estimation to (ME to one reference
1159
+ * per thread). Recommended for many core CPUs. The more references the more
1160
+ * motion searches there will be to distribute. This option is often not a
1161
+ * win, particularly in video sequences with low motion. Default disabled */
1162
+ int bDistributeMotionEstimation;
1163
+
1164
+ /*== Logging Features ==*/
1165
+
1166
+ /* Enable analysis and logging distribution of CUs. Now deprecated */
1167
+ int bLogCuStats;
1168
+
1169
+ /* Enable the measurement and reporting of PSNR. Default is enabled */
1170
+ int bEnablePsnr;
1171
+
1172
+ /* Enable the measurement and reporting of SSIM. Default is disabled */
1173
+ int bEnableSsim;
1174
+
1175
+ /* The level of logging detail emitted by the encoder. X265_LOG_NONE to
1176
+ * X265_LOG_FULL, default is X265_LOG_INFO */
1177
+ int logLevel;
1178
+
1179
+ /* Level of csv logging. 0 is summary, 1 is frame level logging,
1180
+ * 2 is frame level logging with performance statistics */
1181
+ int csvLogLevel;
1182
+
1183
+ /* filename of CSV log. If csvLogLevel is non-zero, the encoder will emit
1184
+ * per-slice statistics to this log file in encode order. Otherwise the
1185
+ * encoder will emit per-stream statistics into the log file when
1186
+ * x265_encoder_log is called (presumably at the end of the encode) */
1187
+ const char* csvfn;
1188
+
1189
+ /*== Internal Picture Specification ==*/
1190
+
1191
+ /* Internal encoder bit depth. If x265 was compiled to use 8bit pixels
1192
+ * (HIGH_BIT_DEPTH=0), this field must be 8, else this field must be 10.
1193
+ * Future builds may support 12bit pixels. */
1194
+ int internalBitDepth;
1195
+
1196
+ /* Color space of internal pictures, must match color space of input
1197
+ * pictures */
1198
+ int internalCsp;
1199
+
1200
+ /* Numerator and denominator of frame rate */
1201
+ uint32_t fpsNum;
1202
+ uint32_t fpsDenom;
1203
+
1204
+ /* Width (in pixels) of the source pictures. If this width is not an even
1205
+ * multiple of 4, the encoder will pad the pictures internally to meet this
1206
+ * minimum requirement. All valid HEVC widths are supported */
1207
+ int sourceWidth;
1208
+
1209
+ /* Height (in pixels) of the source pictures. If this height is not an even
1210
+ * multiple of 4, the encoder will pad the pictures internally to meet this
1211
+ * minimum requirement. All valid HEVC heights are supported */
1212
+ int sourceHeight;
1213
+
1214
+ /* Interlace type of source pictures. 0 - progressive pictures (default).
1215
+ * 1 - top field first, 2 - bottom field first. HEVC encodes interlaced
1216
+ * content as fields, they must be provided to the encoder in the correct
1217
+ * temporal order */
1218
+ int interlaceMode;
1219
+
1220
+ /* Total Number of frames to be encoded, calculated from the user input
1221
+ * (--frames) and (--seek). In case, the input is read from a pipe, this can
1222
+ * remain as 0. It is later used in 2 pass RateControl, hence storing the
1223
+ * value in param */
1224
+ int totalFrames;
1225
+
1226
+ /*== Profile / Tier / Level ==*/
1227
+
1228
+ /* Note: the profile is specified by x265_param_apply_profile() */
1229
+
1230
+ /* Minimum decoder requirement level. Defaults to 0, which implies auto-
1231
+ * detection by the encoder. If specified, the encoder will attempt to bring
1232
+ * the encode specifications within that specified level. If the encoder is
1233
+ * unable to reach the level it issues a warning and emits the actual
1234
+ * decoder requirement. If the requested requirement level is higher than
1235
+ * the actual level, the actual requirement level is signaled. The value is
1236
+ * an specified as an integer with the level times 10, for example level
1237
+ * "5.1" is specified as 51, and level "5.0" is specified as 50. */
1238
+ int levelIdc;
1239
+
1240
+ /* if levelIdc is specified (non-zero) this flag will differentiate between
1241
+ * Main (0) and High (1) tier. Default is Main tier (0) */
1242
+ int bHighTier;
1243
+
1244
+ /* Enable UHD Blu-ray compatibility support. If specified, the encoder will
1245
+ * attempt to modify/set the encode specifications. If the encoder is unable
1246
+ * to do so, this option will be turned OFF. */
1247
+ int uhdBluray;
1248
+
1249
+ /* The maximum number of L0 references a P or B slice may use. This
1250
+ * influences the size of the decoded picture buffer. The higher this
1251
+ * number, the more reference frames there will be available for motion
1252
+ * search, improving compression efficiency of most video at a cost of
1253
+ * performance. Value must be between 1 and 16, default is 3 */
1254
+ int maxNumReferences;
1255
+
1256
+ /* Allow libx265 to emit HEVC bitstreams which do not meet strict level
1257
+ * requirements. Defaults to false */
1258
+ int bAllowNonConformance;
1259
+
1260
+ /*== Bitstream Options ==*/
1261
+
1262
+ /* Flag indicating whether VPS, SPS and PPS headers should be output with
1263
+ * each keyframe. Default false */
1264
+ int bRepeatHeaders;
1265
+
1266
+ /* Flag indicating whether the encoder should generate start codes (Annex B
1267
+ * format) or length (file format) before NAL units. Default true, Annex B.
1268
+ * Muxers should set this to the correct value */
1269
+ int bAnnexB;
1270
+
1271
+ /* Flag indicating whether the encoder should emit an Access Unit Delimiter
1272
+ * NAL at the start of every access unit. Default false */
1273
+ int bEnableAccessUnitDelimiters;
1274
+
1275
+ /* Enables the buffering period SEI and picture timing SEI to signal the HRD
1276
+ * parameters. Default is disabled */
1277
+ int bEmitHRDSEI;
1278
+
1279
+ /* Enables the emission of a user data SEI with the stream headers which
1280
+ * describes the encoder version, build info, and parameters. This is
1281
+ * very helpful for debugging, but may interfere with regression tests.
1282
+ * Default enabled */
1283
+ int bEmitInfoSEI;
1284
+
1285
+ /* Enable the generation of SEI messages for each encoded frame containing
1286
+ * the hashes of the three reconstructed picture planes. Most decoders will
1287
+ * validate those hashes against the reconstructed images it generates and
1288
+ * report any mismatches. This is essentially a debugging feature. Hash
1289
+ * types are MD5(1), CRC(2), Checksum(3). Default is 0, none */
1290
+ int decodedPictureHashSEI;
1291
+
1292
+ /* Enable Temporal Sub Layers while encoding, signals NAL units of coded
1293
+ * slices with their temporalId. Output bitstreams can be extracted either
1294
+ * at the base temporal layer (layer 0) with roughly half the frame rate or
1295
+ * at a higher temporal layer (layer 1) that decodes all the frames in the
1296
+ * sequence. */
1297
+ int bEnableTemporalSubLayers;
1298
+
1299
+ /*== GOP structure and slice type decisions (lookahead) ==*/
1300
+
1301
+ /* Enable open GOP - meaning I slices are not necessarily IDR and thus frames
1302
+ * encoded after an I slice may reference frames encoded prior to the I
1303
+ * frame which have remained in the decoded picture buffer. Open GOP
1304
+ * generally has better compression efficiency and negligible encoder
1305
+ * performance impact, but the use case may preclude it. Default true */
1306
+ int bOpenGOP;
1307
+
1308
+ /*Force nal type to CRA to all frames expect first frame. Default disabled*/
1309
+ int craNal;
1310
+
1311
+ /* Scene cuts closer together than this are coded as I, not IDR. */
1312
+ int keyframeMin;
1313
+
1314
+ /* Maximum keyframe distance or intra period in number of frames. If 0 or 1,
1315
+ * all frames are I frames. A negative value is casted to MAX_INT internally
1316
+ * which effectively makes frame 0 the only I frame. Default is 250 */
1317
+ int keyframeMax;
1318
+
1319
+ /* Maximum consecutive B frames that can be emitted by the lookahead. When
1320
+ * b-adapt is 0 and keyframMax is greater than bframes, the lookahead emits
1321
+ * a fixed pattern of `bframes` B frames between each P. With b-adapt 1 the
1322
+ * lookahead ignores the value of bframes for the most part. With b-adapt 2
1323
+ * the value of bframes determines the search (POC) distance performed in
1324
+ * both directions, quadratically increasing the compute load of the
1325
+ * lookahead. The higher the value, the more B frames the lookahead may
1326
+ * possibly use consecutively, usually improving compression. Default is 3,
1327
+ * maximum is 16 */
1328
+ int bframes;
1329
+
1330
+ /* Sets the operating mode of the lookahead. With b-adapt 0, the GOP
1331
+ * structure is fixed based on the values of keyframeMax and bframes.
1332
+ * With b-adapt 1 a light lookahead is used to chose B frame placement.
1333
+ * With b-adapt 2 (trellis) a viterbi B path selection is performed */
1334
+ int bFrameAdaptive;
1335
+
1336
+ /* When enabled, the encoder will use the B frame in the middle of each
1337
+ * mini-GOP larger than 2 B frames as a motion reference for the surrounding
1338
+ * B frames. This improves compression efficiency for a small performance
1339
+ * penalty. Referenced B frames are treated somewhere between a B and a P
1340
+ * frame by rate control. Default is enabled. */
1341
+ int bBPyramid;
1342
+
1343
+ /* A value which is added to the cost estimate of B frames in the lookahead.
1344
+ * It may be a positive value (making B frames appear less expensive, which
1345
+ * biases the lookahead to choose more B frames) or negative, which makes the
1346
+ * lookahead choose more P frames. Default is 0, there are no limits */
1347
+ int bFrameBias;
1348
+
1349
+ /* The number of frames that must be queued in the lookahead before it may
1350
+ * make slice decisions. Increasing this value directly increases the encode
1351
+ * latency. The longer the queue the more optimally the lookahead may make
1352
+ * slice decisions, particularly with b-adapt 2. When cu-tree is enabled,
1353
+ * the length of the queue linearly increases the effectiveness of the
1354
+ * cu-tree analysis. Default is 40 frames, maximum is 250 */
1355
+ int lookaheadDepth;
1356
+
1357
+ /* Use multiple worker threads to measure the estimated cost of each frame
1358
+ * within the lookahead. When bFrameAdaptive is 2, most frame cost estimates
1359
+ * will be performed in batch mode, many cost estimates at the same time,
1360
+ * and lookaheadSlices is ignored for batched estimates. The effect on
1361
+ * performance can be quite small. The higher this parameter, the less
1362
+ * accurate the frame costs will be (since context is lost across slice
1363
+ * boundaries) which will result in less accurate B-frame and scene-cut
1364
+ * decisions. Default is 0 - disabled. 1 is the same as 0. Max 16 */
1365
+ int lookaheadSlices;
1366
+
1367
+ /* An arbitrary threshold which determines how aggressively the lookahead
1368
+ * should detect scene cuts for cost based scenecut detection.
1369
+ * The default (40) is recommended. */
1370
+ int scenecutThreshold;
1371
+
1372
+ /* Replace keyframes by using a column of intra blocks that move across the video
1373
+ * from one side to the other, thereby "refreshing" the image. In effect, instead of a
1374
+ * big keyframe, the keyframe is "spread" over many frames. */
1375
+ int bIntraRefresh;
1376
+
1377
+ /*== Coding Unit (CU) definitions ==*/
1378
+
1379
+ /* Maximum CU width and height in pixels. The size must be 64, 32, or 16.
1380
+ * The higher the size, the more efficiently x265 can encode areas of low
1381
+ * complexity, greatly improving compression efficiency at large
1382
+ * resolutions. The smaller the size, the more effective wavefront and
1383
+ * frame parallelism will become because of the increase in rows. default 64
1384
+ * All encoders within the same process must use the same maxCUSize, until
1385
+ * all encoders are closed and x265_cleanup() is called to reset the value. */
1386
+ uint32_t maxCUSize;
1387
+
1388
+ /* Minimum CU width and height in pixels. The size must be 64, 32, 16, or
1389
+ * 8. Default 8. All encoders within the same process must use the same
1390
+ * minCUSize. */
1391
+ uint32_t minCUSize;
1392
+
1393
+ /* Enable rectangular motion prediction partitions (vertical and
1394
+ * horizontal), available at all CU depths from 64x64 to 8x8. Default is
1395
+ * disabled */
1396
+ int bEnableRectInter;
1397
+
1398
+ /* Enable asymmetrical motion predictions. At CU depths 64, 32, and 16, it
1399
+ * is possible to use 25%/75% split partitions in the up, down, right, left
1400
+ * directions. For some material this can improve compression efficiency at
1401
+ * the cost of extra analysis. bEnableRectInter must be enabled for this
1402
+ * feature to be used. Default disabled */
1403
+ int bEnableAMP;
1404
+
1405
+ /*== Residual Quadtree Transform Unit (TU) definitions ==*/
1406
+
1407
+ /* Maximum TU width and height in pixels. The size must be 32, 16, 8 or 4.
1408
+ * The larger the size the more efficiently the residual can be compressed
1409
+ * by the DCT transforms, at the expense of more computation */
1410
+ uint32_t maxTUSize;
1411
+
1412
+ /* The additional depth the residual quad-tree is allowed to recurse beyond
1413
+ * the coding quad-tree, for inter coded blocks. This must be between 1 and
1414
+ * 4. The higher the value the more efficiently the residual can be
1415
+ * compressed by the DCT transforms, at the expense of much more compute */
1416
+ uint32_t tuQTMaxInterDepth;
1417
+
1418
+ /* The additional depth the residual quad-tree is allowed to recurse beyond
1419
+ * the coding quad-tree, for intra coded blocks. This must be between 1 and
1420
+ * 4. The higher the value the more efficiently the residual can be
1421
+ * compressed by the DCT transforms, at the expense of much more compute */
1422
+ uint32_t tuQTMaxIntraDepth;
1423
+
1424
+ /* Enable early exit decisions for inter coded blocks to avoid recursing to
1425
+ * higher TU depths. Default: 0 */
1426
+ uint32_t limitTU;
1427
+
1428
+ /* Set the amount of rate-distortion analysis to use within quant. 0 implies
1429
+ * no rate-distortion optimization. At level 1 rate-distortion cost is used to
1430
+ * find optimal rounding values for each level (and allows psy-rdoq to be
1431
+ * enabled). At level 2 rate-distortion cost is used to make decimate decisions
1432
+ * on each 4x4 coding group (including the cost of signaling the group within
1433
+ * the group bitmap). Psy-rdoq is less effective at preserving energy when
1434
+ * RDOQ is at level 2. Default: 0 */
1435
+ int rdoqLevel;
1436
+
1437
+ /* Enable the implicit signaling of the sign bit of the last coefficient of
1438
+ * each transform unit. This saves one bit per TU at the expense of figuring
1439
+ * out which coefficient can be toggled with the least distortion.
1440
+ * Default is enabled */
1441
+ int bEnableSignHiding;
1442
+
1443
+ /* Allow intra coded blocks to be encoded directly as residual without the
1444
+ * DCT transform, when this improves efficiency. Checking whether the block
1445
+ * will benefit from this option incurs a performance penalty. Default is
1446
+ * disabled */
1447
+ int bEnableTransformSkip;
1448
+
1449
+ /* An integer value in range of 0 to 2000, which denotes strength of noise
1450
+ * reduction in intra CUs. 0 means disabled */
1451
+ int noiseReductionIntra;
1452
+
1453
+ /* An integer value in range of 0 to 2000, which denotes strength of noise
1454
+ * reduction in inter CUs. 0 means disabled */
1455
+ int noiseReductionInter;
1456
+
1457
+ /* Quantization scaling lists. HEVC supports 6 quantization scaling lists to
1458
+ * be defined; one each for Y, Cb, Cr for intra prediction and one each for
1459
+ * inter prediction.
1460
+ *
1461
+ * - NULL and "off" will disable quant scaling (default)
1462
+ * - "default" will enable the HEVC default scaling lists, which
1463
+ * do not need to be signaled since they are specified
1464
+ * - all other strings indicate a filename containing custom scaling lists
1465
+ * in the HM format. The encode will fail if the file is not parsed
1466
+ * correctly. Custom lists must be signaled in the SPS. */
1467
+ const char *scalingLists;
1468
+
1469
+ /*== Intra Coding Tools ==*/
1470
+
1471
+ /* Enable constrained intra prediction. This causes intra prediction to
1472
+ * input samples that were inter predicted. For some use cases this is
1473
+ * believed to me more robust to stream errors, but it has a compression
1474
+ * penalty on P and (particularly) B slices. Defaults to disabled */
1475
+ int bEnableConstrainedIntra;
1476
+
1477
+ /* Enable strong intra smoothing for 32x32 blocks where the reference
1478
+ * samples are flat. It may or may not improve compression efficiency,
1479
+ * depending on your source material. Defaults to disabled */
1480
+ int bEnableStrongIntraSmoothing;
1481
+
1482
+ /*== Inter Coding Tools ==*/
1483
+
1484
+ /* The maximum number of merge candidates that are considered during inter
1485
+ * analysis. This number (between 1 and 5) is signaled in the stream
1486
+ * headers and determines the number of bits required to signal a merge so
1487
+ * it can have significant trade-offs. The smaller this number the higher
1488
+ * the performance but the less compression efficiency. Default is 3 */
1489
+ uint32_t maxNumMergeCand;
1490
+
1491
+ /* Limit the motion references used for each search based on the results of
1492
+ * previous motion searches already performed for the same CU: If 0 all
1493
+ * references are always searched. If X265_REF_LIMIT_CU all motion searches
1494
+ * will restrict themselves to the references selected by the 2Nx2N search
1495
+ * at the same depth. If X265_REF_LIMIT_DEPTH the 2Nx2N motion search will
1496
+ * only use references that were selected by the best motion searches of the
1497
+ * 4 split CUs at the next lower CU depth. The two flags may be combined */
1498
+ uint32_t limitReferences;
1499
+
1500
+ /* Limit modes analyzed for each CU using cost metrics from the 4 sub-CUs */
1501
+ uint32_t limitModes;
1502
+
1503
+ /* ME search method (DIA, HEX, UMH, STAR, SEA, FULL). The search patterns
1504
+ * (methods) are sorted in increasing complexity, with diamond being the
1505
+ * simplest and fastest and full being the slowest. DIA, HEX, UMH and SEA were
1506
+ * adapted from x264 directly. STAR is an adaption of the HEVC reference
1507
+ * encoder's three step search, while full is a naive exhaustive search. The
1508
+ * default is the star search, it has a good balance of performance and
1509
+ * compression efficiency */
1510
+ int searchMethod;
1511
+
1512
+ /* A value between 0 and X265_MAX_SUBPEL_LEVEL which adjusts the amount of
1513
+ * effort performed during sub-pel refine. Default is 5 */
1514
+ int subpelRefine;
1515
+
1516
+ /* The maximum distance from the motion prediction that the full pel motion
1517
+ * search is allowed to progress before terminating. This value can have an
1518
+ * effect on frame parallelism, as referenced frames must be at least this
1519
+ * many rows of reconstructed pixels ahead of the referencee at all times.
1520
+ * (When considering reference lag, the motion prediction must be ignored
1521
+ * because it cannot be known ahead of time). Default is 60, which is the
1522
+ * default max CU size (64) minus the luma HPEL half-filter length (4). If a
1523
+ * smaller CU size is used, the search range should be similarly reduced */
1524
+ int searchRange;
1525
+
1526
+ /* Enable availability of temporal motion vector for AMVP, default is enabled */
1527
+ int bEnableTemporalMvp;
1528
+
1529
+ /* Enable 3-level Hierarchical motion estimation at One-Sixteenth, Quarter and Full resolution.
1530
+ * Default is disabled */
1531
+ int bEnableHME;
1532
+
1533
+ /* Enable HME search method (DIA, HEX, UMH, STAR, SEA, FULL) for level 0, 1 and 2.
1534
+ * Default is hex, umh, umh for L0, L1 and L2 respectively. */
1535
+ int hmeSearchMethod[3];
1536
+
1537
+ /* Enable weighted prediction in P slices. This enables weighting analysis
1538
+ * in the lookahead, which influences slice decisions, and enables weighting
1539
+ * analysis in the main encoder which allows P reference samples to have a
1540
+ * weight function applied to them prior to using them for motion
1541
+ * compensation. In video which has lighting changes, it can give a large
1542
+ * improvement in compression efficiency. Default is enabled */
1543
+ int bEnableWeightedPred;
1544
+
1545
+ /* Enable weighted prediction in B slices. Default is disabled */
1546
+ int bEnableWeightedBiPred;
1547
+ /* Enable source pixels in motion estimation. Default is disabled */
1548
+ int bSourceReferenceEstimation;
1549
+ /*== Loop Filters ==*/
1550
+ /* Enable the deblocking loop filter, which improves visual quality by
1551
+ * reducing blocking effects at block edges, particularly at lower bitrates
1552
+ * or higher QP. When enabled it adds another CU row of reference lag,
1553
+ * reducing frame parallelism effectiveness. Default is enabled */
1554
+ int bEnableLoopFilter;
1555
+
1556
+ /* deblocking filter tC offset [-6, 6] -6 light filter, 6 strong.
1557
+ * This is the coded div2 value, actual offset is doubled at use */
1558
+ int deblockingFilterTCOffset;
1559
+
1560
+ /* deblocking filter Beta offset [-6, 6] -6 light filter, 6 strong
1561
+ * This is the coded div2 value, actual offset is doubled at use */
1562
+ int deblockingFilterBetaOffset;
1563
+
1564
+ /* Enable the Sample Adaptive Offset loop filter, which reduces distortion
1565
+ * effects by adjusting reconstructed sample values based on histogram
1566
+ * analysis to better approximate the original samples. When enabled it adds
1567
+ * a CU row of reference lag, reducing frame parallelism effectiveness.
1568
+ * Default is enabled */
1569
+ int bEnableSAO;
1570
+
1571
+ /* Note: when deblocking and SAO are both enabled, the loop filter CU lag is
1572
+ * only one row, as they operate in series on the same row. */
1573
+
1574
+ /* Select the method in which SAO deals with deblocking boundary pixels. If
1575
+ * disabled the right and bottom boundary areas are skipped. If enabled,
1576
+ * non-deblocked pixels are used entirely. Default is disabled */
1577
+ int bSaoNonDeblocked;
1578
+
1579
+ /* Select tune rate in which SAO has to be applied.
1580
+ 1 - Filtering applied only on I-frames(I) [Light tune]
1581
+ 2 - No Filtering on B frames (I, P) [Medium tune]
1582
+ 3 - No Filtering on non-ref b frames (I, P, B) [Strong tune] */
1583
+ int selectiveSAO;
1584
+
1585
+ /*== Analysis tools ==*/
1586
+
1587
+ /* A value between 1 and 6 (both inclusive) which determines the level of
1588
+ * rate distortion optimizations to perform during mode and depth decisions.
1589
+ * The more RDO the better the compression efficiency at a major cost of
1590
+ * performance. Default is 3 */
1591
+ int rdLevel;
1592
+
1593
+ /* Enable early skip decisions to avoid analysing additional modes in likely
1594
+ * skip blocks. Default is disabled */
1595
+ int bEnableEarlySkip;
1596
+
1597
+ /* Enable early CU size decisions to avoid recursing to higher depths.
1598
+ * Default is enabled */
1599
+ int recursionSkipMode;
1600
+
1601
+ /* Use a faster search method to find the best intra mode. Default is 0 */
1602
+ int bEnableFastIntra;
1603
+
1604
+ /* Enable a faster determination of whether skipping the DCT transform will
1605
+ * be beneficial. Slight performance gain for some compression loss. Default
1606
+ * is enabled */
1607
+ int bEnableTSkipFast;
1608
+
1609
+ /* The CU Lossless flag, when enabled, compares the rate-distortion costs
1610
+ * for normal and lossless encoding, and chooses the best mode for each CU.
1611
+ * If lossless mode is chosen, the cu-transquant-bypass flag is set for that
1612
+ * CU */
1613
+ int bCULossless;
1614
+
1615
+ /* Specify whether to attempt to encode intra modes in B frames. By default
1616
+ * enabled, but only applicable for the presets which use rdLevel 5 or 6
1617
+ * (veryslow and placebo). All other presets will not try intra in B frames
1618
+ * regardless of this setting */
1619
+ int bIntraInBFrames;
1620
+
1621
+ /* Apply an optional penalty to the estimated cost of 32x32 intra blocks in
1622
+ * non-intra slices. 0 is disabled, 1 enables a small penalty, and 2 enables
1623
+ * a full penalty. This favors inter-coding and its low bitrate over
1624
+ * potential increases in distortion, but usually improves performance.
1625
+ * Default is 0 */
1626
+ int rdPenalty;
1627
+
1628
+ /* Psycho-visual rate-distortion strength. Only has an effect in presets
1629
+ * which use RDO. It makes mode decision favor options which preserve the
1630
+ * energy of the source, at the cost of lost compression. The value must
1631
+ * be between 0 and 5.0, 1.0 is typical. Default 2.0 */
1632
+ double psyRd;
1633
+
1634
+ /* Strength of psycho-visual optimizations in quantization. Only has an
1635
+ * effect when RDOQ is enabled (presets slow, slower and veryslow). The
1636
+ * value must be between 0 and 50, 1.0 is typical. Default 0 */
1637
+ double psyRdoq;
1638
+
1639
+ /* Perform quantisation parameter based RD refinement. RD cost is calculated
1640
+ * on the best CU partitions, chosen after the CU analysis, for a range of QPs
1641
+ * to find the optimal rounding effect. Only effective at rd-levels 5 and 6.
1642
+ * Default disabled */
1643
+ int bEnableRdRefine;
1644
+
1645
+ /* If save, write per-frame analysis information into analysis buffers.
1646
+ * If load, read analysis information into analysis buffer and use this
1647
+ * analysis information to reduce the amount of work the encoder must perform.
1648
+ * Default disabled. Now deprecated*/
1649
+ int analysisReuseMode;
1650
+
1651
+ /* Filename for multi-pass-opt-analysis/distortion. Default name is "x265_analysis.dat" */
1652
+ const char* analysisReuseFileName;
1653
+
1654
+ /*== Rate Control ==*/
1655
+
1656
+ /* The lossless flag enables true lossless coding, bypassing scaling,
1657
+ * transform, quantization and in-loop filter processes. This is used for
1658
+ * ultra-high bitrates with zero loss of quality. It implies no rate control */
1659
+ int bLossless;
1660
+
1661
+ /* Generally a small signed integer which offsets the QP used to quantize
1662
+ * the Cb chroma residual (delta from luma QP specified by rate-control).
1663
+ * Default is 0, which is recommended */
1664
+ int cbQpOffset;
1665
+
1666
+ /* Generally a small signed integer which offsets the QP used to quantize
1667
+ * the Cr chroma residual (delta from luma QP specified by rate-control).
1668
+ * Default is 0, which is recommended */
1669
+ int crQpOffset;
1670
+
1671
+ /* Specifies the preferred transfer characteristics syntax element in the
1672
+ * alternative transfer characteristics SEI message (see. D.2.38 and D.3.38 of
1673
+ * JCTVC-W1005 http://phenix.it-sudparis.eu/jct/doc_end_user/documents/23_San%20Diego/wg11/JCTVC-W1005-v4.zip
1674
+ * */
1675
+ int preferredTransferCharacteristics;
1676
+
1677
+ /*
1678
+ * Specifies the value for the pic_struc syntax element of the picture timing SEI message (See D2.3 and D3.3)
1679
+ * of the HEVC spec. for a detailed explanation
1680
+ * */
1681
+ int pictureStructure;
1682
+
1683
+ struct
1684
+ {
1685
+ /* Explicit mode of rate-control, necessary for API users. It must
1686
+ * be one of the X265_RC_METHODS enum values. */
1687
+ int rateControlMode;
1688
+
1689
+ /* Base QP to use for Constant QP rate control. Adaptive QP may alter
1690
+ * the QP used for each block. If a QP is specified on the command line
1691
+ * CQP rate control is implied. Default: 32 */
1692
+ int qp;
1693
+
1694
+ /* target bitrate for Average BitRate (ABR) rate control. If a non- zero
1695
+ * bitrate is specified on the command line, ABR is implied. Default 0 */
1696
+ int bitrate;
1697
+
1698
+ /* qComp sets the quantizer curve compression factor. It weights the frame
1699
+ * quantizer based on the complexity of residual (measured by lookahead).
1700
+ * Default value is 0.6. Increasing it to 1 will effectively generate CQP */
1701
+ double qCompress;
1702
+
1703
+ /* QP offset between I/P and P/B frames. Default ipfactor: 1.4
1704
+ * Default pbFactor: 1.3 */
1705
+ double ipFactor;
1706
+ double pbFactor;
1707
+
1708
+ /* Ratefactor constant: targets a certain constant "quality".
1709
+ * Acceptable values between 0 and 51. Default value: 28 */
1710
+ double rfConstant;
1711
+
1712
+ /* Max QP difference between frames. Default: 4 */
1713
+ int qpStep;
1714
+
1715
+ /* Enable adaptive quantization. This mode distributes available bits between all
1716
+ * CTUs of a frame, assigning more bits to low complexity areas. Turning
1717
+ * this ON will usually affect PSNR negatively, however SSIM and visual quality
1718
+ * generally improves. Default: X265_AQ_AUTO_VARIANCE */
1719
+ int aqMode;
1720
+
1721
+ /*
1722
+ * Enable adaptive quantization.
1723
+ * It scales the quantization step size according to the spatial activity of one
1724
+ * coding unit relative to frame average spatial activity. This AQ method utilizes
1725
+ * the minimum variance of sub-unit in each coding unit to represent the coding
1726
+ * unit’s spatial complexity. */
1727
+ int hevcAq;
1728
+
1729
+ /* Sets the strength of AQ bias towards low detail CTUs. Valid only if
1730
+ * AQ is enabled. Default value: 1.0. Acceptable values between 0.0 and 3.0 */
1731
+ double aqStrength;
1732
+
1733
+ /* Delta QP range by QP adaptation based on a psycho-visual model.
1734
+ * Acceptable values between 1.0 to 6.0 */
1735
+ double qpAdaptationRange;
1736
+
1737
+ /* Sets the maximum rate the VBV buffer should be assumed to refill at
1738
+ * Default is zero */
1739
+ int vbvMaxBitrate;
1740
+
1741
+ /* Sets the size of the VBV buffer in kilobits. Default is zero */
1742
+ int vbvBufferSize;
1743
+
1744
+ /* Sets how full the VBV buffer must be before playback starts. If it is less than
1745
+ * 1, then the initial fill is vbv-init * vbvBufferSize. Otherwise, it is
1746
+ * interpreted as the initial fill in kbits. Default is 0.9 */
1747
+ double vbvBufferInit;
1748
+
1749
+ /* Enable CUTree rate-control. This keeps track of the CUs that propagate temporally
1750
+ * across frames and assigns more bits to these CUs. Improves encode efficiency.
1751
+ * Default: enabled */
1752
+ int cuTree;
1753
+
1754
+ /* In CRF mode, maximum CRF as caused by VBV. 0 implies no limit */
1755
+ double rfConstantMax;
1756
+
1757
+ /* In CRF mode, minimum CRF as caused by VBV */
1758
+ double rfConstantMin;
1759
+
1760
+ /* Multi-pass encoding */
1761
+ /* Enable writing the stats in a multi-pass encode to the stat output file/memory */
1762
+ int bStatWrite;
1763
+
1764
+ /* Enable loading data from the stat input file/memory in a multi pass encode */
1765
+ int bStatRead;
1766
+
1767
+ /* Filename of the 2pass output/input stats file, if unspecified the
1768
+ * encoder will default to using x265_2pass.log */
1769
+ const char* statFileName;
1770
+
1771
+ /* temporally blur quants */
1772
+ double qblur;
1773
+
1774
+ /* temporally blur complexity */
1775
+ double complexityBlur;
1776
+
1777
+ /* Enable slow and a more detailed first pass encode in multi pass rate control */
1778
+ int bEnableSlowFirstPass;
1779
+
1780
+ /* rate-control overrides */
1781
+ int zoneCount;
1782
+ x265_zone* zones;
1783
+
1784
+ /* number of zones in zone-file*/
1785
+ int zonefileCount;
1786
+
1787
+ /* specify a text file which contains MAX_MAX_QP + 1 floating point
1788
+ * values to be copied into x265_lambda_tab and a second set of
1789
+ * MAX_MAX_QP + 1 floating point values for x265_lambda2_tab. All values
1790
+ * are separated by comma, space or newline. Text after a hash (#) is
1791
+ * ignored. The lambda tables are process-global, so these new lambda
1792
+ * values will affect all encoders in the same process */
1793
+ const char* lambdaFileName;
1794
+
1795
+ /* Enable stricter conditions to check bitrate deviations in CBR mode. May compromise
1796
+ * quality to maintain bitrate adherence */
1797
+ int bStrictCbr;
1798
+
1799
+ /* Enable adaptive quantization at CU granularity. This parameter specifies
1800
+ * the minimum CU size at which QP can be adjusted, i.e. Quantization Group
1801
+ * (QG) size. Allowed values are 64, 32, 16, 8 provided it falls within the
1802
+ * inclusuve range [maxCUSize, minCUSize]. Experimental, default: maxCUSize */
1803
+ uint32_t qgSize;
1804
+
1805
+ /* internally enable if tune grain is set */
1806
+ int bEnableGrain;
1807
+
1808
+ /* sets a hard upper limit on QP */
1809
+ int qpMax;
1810
+
1811
+ /* sets a hard lower limit on QP */
1812
+ int qpMin;
1813
+
1814
+ /* internally enable if tune grain is set */
1815
+ int bEnableConstVbv;
1816
+
1817
+ /* if only the focused frames would be re-encode or not */
1818
+ int bEncFocusedFramesOnly;
1819
+
1820
+ /* Share the data with stats file or shared memory.
1821
+ It must be one of the X265_DATA_SHARE_MODES enum values
1822
+ Available if the bStatWrite or bStatRead is true.
1823
+ Use stats file by default.
1824
+ The stats file mode would be used among the encoders running in sequence.
1825
+ The shared memory mode could only be used among the encoders running in parallel.
1826
+ Now only the cutree data could be shared among shared memory. More data would be support in the future.*/
1827
+ int dataShareMode;
1828
+
1829
+ /* Unique shared memory name. Required if the shared memory mode enabled. NULL by default */
1830
+ const char* sharedMemName;
1831
+
1832
+ } rc;
1833
+
1834
+ /*== Video Usability Information ==*/
1835
+ struct
1836
+ {
1837
+ /* Aspect ratio idc to be added to the VUI. The default is 0 indicating
1838
+ * the apsect ratio is unspecified. If set to X265_EXTENDED_SAR then
1839
+ * sarWidth and sarHeight must also be set */
1840
+ int aspectRatioIdc;
1841
+
1842
+ /* Sample Aspect Ratio width in arbitrary units to be added to the VUI
1843
+ * only if aspectRatioIdc is set to X265_EXTENDED_SAR. This is the width
1844
+ * of an individual pixel. If this is set then sarHeight must also be set */
1845
+ int sarWidth;
1846
+
1847
+ /* Sample Aspect Ratio height in arbitrary units to be added to the VUI.
1848
+ * only if aspectRatioIdc is set to X265_EXTENDED_SAR. This is the width
1849
+ * of an individual pixel. If this is set then sarWidth must also be set */
1850
+ int sarHeight;
1851
+
1852
+ /* Enable overscan info present flag in the VUI. If this is set then
1853
+ * bEnabledOverscanAppropriateFlag will be added to the VUI. The default
1854
+ * is false */
1855
+ int bEnableOverscanInfoPresentFlag;
1856
+
1857
+ /* Enable overscan appropriate flag. The status of this flag is added
1858
+ * to the VUI only if bEnableOverscanInfoPresentFlag is set. If this
1859
+ * flag is set then cropped decoded pictures may be output for display.
1860
+ * The default is false */
1861
+ int bEnableOverscanAppropriateFlag;
1862
+
1863
+ /* Video signal type present flag of the VUI. If this is set then
1864
+ * videoFormat, bEnableVideoFullRangeFlag and
1865
+ * bEnableColorDescriptionPresentFlag will be added to the VUI. The
1866
+ * default is false */
1867
+ int bEnableVideoSignalTypePresentFlag;
1868
+
1869
+ /* Video format of the source video. 0 = component, 1 = PAL, 2 = NTSC,
1870
+ * 3 = SECAM, 4 = MAC, 5 = unspecified video format is the default */
1871
+ int videoFormat;
1872
+
1873
+ /* Video full range flag indicates the black level and range of the luma
1874
+ * and chroma signals as derived from E′Y, E′PB, and E′PR or E′R, E′G,
1875
+ * and E′B real-valued component signals. The default is false */
1876
+ int bEnableVideoFullRangeFlag;
1877
+
1878
+ /* Color description present flag in the VUI. If this is set then
1879
+ * color_primaries, transfer_characteristics and matrix_coeffs are to be
1880
+ * added to the VUI. The default is false */
1881
+ int bEnableColorDescriptionPresentFlag;
1882
+
1883
+ /* Color primaries holds the chromacity coordinates of the source
1884
+ * primaries. The default is 2 */
1885
+ int colorPrimaries;
1886
+
1887
+ /* Transfer characteristics indicates the opto-electronic transfer
1888
+ * characteristic of the source picture. The default is 2 */
1889
+ int transferCharacteristics;
1890
+
1891
+ /* Matrix coefficients used to derive the luma and chroma signals from
1892
+ * the red, blue and green primaries. The default is 2 */
1893
+ int matrixCoeffs;
1894
+
1895
+ /* Chroma location info present flag adds chroma_sample_loc_type_top_field and
1896
+ * chroma_sample_loc_type_bottom_field to the VUI. The default is false */
1897
+ int bEnableChromaLocInfoPresentFlag;
1898
+
1899
+ /* Chroma sample location type top field holds the chroma location in
1900
+ * the top field. The default is 0 */
1901
+ int chromaSampleLocTypeTopField;
1902
+
1903
+ /* Chroma sample location type bottom field holds the chroma location in
1904
+ * the bottom field. The default is 0 */
1905
+ int chromaSampleLocTypeBottomField;
1906
+
1907
+ /* Default display window flag adds def_disp_win_left_offset,
1908
+ * def_disp_win_right_offset, def_disp_win_top_offset and
1909
+ * def_disp_win_bottom_offset to the VUI. The default is false */
1910
+ int bEnableDefaultDisplayWindowFlag;
1911
+
1912
+ /* Default display window left offset holds the left offset with the
1913
+ * conformance cropping window to further crop the displayed window */
1914
+ int defDispWinLeftOffset;
1915
+
1916
+ /* Default display window right offset holds the right offset with the
1917
+ * conformance cropping window to further crop the displayed window */
1918
+ int defDispWinRightOffset;
1919
+
1920
+ /* Default display window top offset holds the top offset with the
1921
+ * conformance cropping window to further crop the displayed window */
1922
+ int defDispWinTopOffset;
1923
+
1924
+ /* Default display window bottom offset holds the bottom offset with the
1925
+ * conformance cropping window to further crop the displayed window */
1926
+ int defDispWinBottomOffset;
1927
+ } vui;
1928
+
1929
+ /* SMPTE ST 2086 mastering display color volume SEI info, specified as a
1930
+ * string which is parsed when the stream header SEI are emitted. The string
1931
+ * format is "G(%hu,%hu)B(%hu,%hu)R(%hu,%hu)WP(%hu,%hu)L(%u,%u)" where %hu
1932
+ * are unsigned 16bit integers and %u are unsigned 32bit integers. The SEI
1933
+ * includes X,Y display primaries for RGB channels, white point X,Y and
1934
+ * max,min luminance values. */
1935
+ const char* masteringDisplayColorVolume;
1936
+
1937
+ /* Maximum Content light level(MaxCLL), specified as integer that indicates the
1938
+ * maximum pixel intensity level in units of 1 candela per square metre of the
1939
+ * bitstream. x265 will also calculate MaxCLL programmatically from the input
1940
+ * pixel values and set in the Content light level info SEI */
1941
+ uint16_t maxCLL;
1942
+
1943
+ /* Maximum Frame Average Light Level(MaxFALL), specified as integer that indicates
1944
+ * the maximum frame average intensity level in units of 1 candela per square
1945
+ * metre of the bitstream. x265 will also calculate MaxFALL programmatically
1946
+ * from the input pixel values and set in the Content light level info SEI */
1947
+ uint16_t maxFALL;
1948
+
1949
+ /* Minimum luma level of input source picture, specified as a integer which
1950
+ * would automatically increase any luma values below the specified --min-luma
1951
+ * value to that value. */
1952
+ uint16_t minLuma;
1953
+
1954
+ /* Maximum luma level of input source picture, specified as a integer which
1955
+ * would automatically decrease any luma values above the specified --max-luma
1956
+ * value to that value. */
1957
+ uint16_t maxLuma;
1958
+
1959
+ /* Maximum of the picture order count */
1960
+ int log2MaxPocLsb;
1961
+
1962
+ /* Emit VUI Timing info, an optional VUI field */
1963
+ int bEmitVUITimingInfo;
1964
+
1965
+ /* Emit HRD Timing info */
1966
+ int bEmitVUIHRDInfo;
1967
+
1968
+ /* Maximum count of Slices of picture, the value range is [1, maximum rows] */
1969
+ unsigned int maxSlices;
1970
+
1971
+ /* Optimize QP in PPS based on statistics from prevvious GOP*/
1972
+ int bOptQpPPS;
1973
+
1974
+ /* Opitmize ref list length in PPS based on stats from previous GOP*/
1975
+ int bOptRefListLengthPPS;
1976
+
1977
+ /* Enable storing commonly RPS in SPS in multi pass mode */
1978
+ int bMultiPassOptRPS;
1979
+ /* This value represents the percentage difference between the inter cost and
1980
+ * intra cost of a frame used in scenecut detection. Default 5. */
1981
+ double scenecutBias;
1982
+ /* Use multiple worker threads dedicated to doing only lookahead instead of sharing
1983
+ * the worker threads with Frame Encoders. A dedicated lookahead threadpool is created with the
1984
+ * specified number of worker threads. This can range from 0 upto half the
1985
+ * hardware threads available for encoding. Using too many threads for lookahead can starve
1986
+ * resources for frame Encoder and can harm performance. Default is 0 - disabled. */
1987
+ int lookaheadThreads;
1988
+ /* Optimize CU level QPs to signal consistent deltaQPs in frame for rd level > 4 */
1989
+ int bOptCUDeltaQP;
1990
+ /* Refine analysis in multipass ratecontrol based on analysis information stored */
1991
+ int analysisMultiPassRefine;
1992
+ /* Refine analysis in multipass ratecontrol based on distortion data stored */
1993
+ int analysisMultiPassDistortion;
1994
+ /* Adaptive Quantization based on relative motion */
1995
+ int bAQMotion;
1996
+ /* SSIM based RDO, based on residual divisive normalization scheme. Used for mode
1997
+ * selection during analysis of CTUs, can achieve significant gain in terms of
1998
+ * objective quality metrics SSIM and PSNR */
1999
+ int bSsimRd;
2000
+
2001
+ /* Increase RD at points where bitrate drops due to vbv. Default 0 */
2002
+ double dynamicRd;
2003
+
2004
+ /* Enables the emitting of HDR SEI packets which contains HDR-specific params.
2005
+ * Auto-enabled when max-cll, max-fall, or mastering display info is specified.
2006
+ * Default is disabled. Now deprecated.*/
2007
+ int bEmitHDRSEI;
2008
+
2009
+ /* Enable luma and chroma offsets for HDR/WCG content.
2010
+ * Default is disabled. Now deprecated.*/
2011
+ int bHDROpt;
2012
+
2013
+ /* A value between 1 and 10 (both inclusive) determines the level of
2014
+ * information stored/reused in analysis save/load. Higher the refine
2015
+ * level higher the information stored/reused. Default is 5. Now deprecated. */
2016
+ int analysisReuseLevel;
2017
+
2018
+ /* Limit Sample Adaptive Offset filter computation by early terminating SAO
2019
+ * process based on inter prediction mode, CTU spatial-domain correlations,
2020
+ * and relations between luma and chroma */
2021
+ int bLimitSAO;
2022
+
2023
+ /* File containing the tone mapping information */
2024
+ const char* toneMapFile;
2025
+
2026
+ /* Insert tone mapping information only for IDR frames and when the
2027
+ * tone mapping information changes. */
2028
+ int bDhdr10opt;
2029
+
2030
+ /* Determine how x265 react to the content information recieved through the API */
2031
+ int bCTUInfo;
2032
+
2033
+ /* Use ratecontrol statistics from pic_in, if available*/
2034
+ int bUseRcStats;
2035
+
2036
+ /* Factor by which input video is scaled down for analysis save mode. Default is 0 */
2037
+ int scaleFactor;
2038
+
2039
+ /* Enable intra refinement in load mode*/
2040
+ int intraRefine;
2041
+
2042
+ /* Enable inter refinement in load mode*/
2043
+ int interRefine;
2044
+
2045
+ /* Enable motion vector refinement in load mode*/
2046
+ int mvRefine;
2047
+
2048
+ /* Log of maximum CTU size */
2049
+ uint32_t maxLog2CUSize;
2050
+
2051
+ /* Actual CU depth with respect to config depth */
2052
+ uint32_t maxCUDepth;
2053
+
2054
+ /* CU depth with respect to maximum transform size */
2055
+ uint32_t unitSizeDepth;
2056
+
2057
+ /* Number of 4x4 units in maximum CU size */
2058
+ uint32_t num4x4Partitions;
2059
+
2060
+ /* Specify if analysis mode uses file for data reuse */
2061
+ int bUseAnalysisFile;
2062
+
2063
+ /* File pointer for csv log */
2064
+ FILE* csvfpt;
2065
+
2066
+ /* Force flushing the frames from encoder */
2067
+ int forceFlush;
2068
+
2069
+ /* Enable skipping split RD analysis when sum of split CU rdCost larger than none split CU rdCost for Intra CU */
2070
+ int bEnableSplitRdSkip;
2071
+
2072
+ /* Disable lookahead */
2073
+ int bDisableLookahead;
2074
+
2075
+ /* Use low-pass subband dct approximation
2076
+ * This DCT approximation is less computational intensive and gives results close to standard DCT */
2077
+ int bLowPassDct;
2078
+
2079
+ /* Sets the portion of the decode buffer that must be available after all the
2080
+ * specified frames have been inserted into the decode buffer. If it is less
2081
+ * than 1, then the final buffer available is vbv-end * vbvBufferSize. Otherwise,
2082
+ * it is interpreted as the final buffer available in kbits. Default 0 (disabled) */
2083
+ double vbvBufferEnd;
2084
+
2085
+ /* Frame from which qp has to be adjusted to hit final decode buffer emptiness.
2086
+ * Specified as a fraction of the total frames. Default 0 */
2087
+ double vbvEndFrameAdjust;
2088
+
2089
+ /* Reuse MV information obtained through API */
2090
+ int bAnalysisType;
2091
+ /* Allow the encoder to have a copy of the planes of x265_picture in Frame */
2092
+ int bCopyPicToFrame;
2093
+
2094
+ /*Number of frames for GOP boundary decision lookahead.If a scenecut frame is found
2095
+ * within this from the gop boundary set by keyint, the GOP will be extented until such a point,
2096
+ * otherwise the GOP will be terminated as set by keyint*/
2097
+ int gopLookahead;
2098
+
2099
+ /*Write per-frame analysis information into analysis buffers. Default disabled. */
2100
+ const char* analysisSave;
2101
+
2102
+ /* Read analysis information into analysis buffer and use this analysis information
2103
+ * to reduce the amount of work the encoder must perform. Default disabled. */
2104
+ const char* analysisLoad;
2105
+
2106
+ /*Number of RADL pictures allowed in front of IDR*/
2107
+ int radl;
2108
+
2109
+ /* This value controls the maximum AU size defined in specification
2110
+ * It represents the percentage of maximum AU size used.
2111
+ * Default is 1 (which is 100%). Range is 0.5 to 1. */
2112
+ double maxAUSizeFactor;
2113
+
2114
+ /* Enables the emission of a Recovery Point SEI with the stream headers
2115
+ * at each IDR frame describing poc of the recovery point, exact matching flag
2116
+ * and broken link flag. Default is disabled. */
2117
+ int bEmitIDRRecoverySEI;
2118
+
2119
+ /* Dynamically change refine-inter at block level*/
2120
+ int bDynamicRefine;
2121
+
2122
+ /* Enable writing all SEI messgaes in one single NAL instead of mul*/
2123
+ int bSingleSeiNal;
2124
+
2125
+
2126
+ /* First frame of the chunk. Frames preceeding this in display order will
2127
+ * be encoded, however, they will be discarded in the bitstream.
2128
+ * Default 0 (disabled). */
2129
+ int chunkStart;
2130
+
2131
+ /* Last frame of the chunk. Frames following this in display order will be
2132
+ * used in taking lookahead decisions, but, they will not be encoded.
2133
+ * Default 0 (disabled). */
2134
+ int chunkEnd;
2135
+ /* File containing base64 encoded SEI messages in POC order */
2136
+ const char* naluFile;
2137
+
2138
+ /* Generate bitstreams confirming to the specified dolby vision profile,
2139
+ * note that 0x7C01 makes RPU appear to be an unspecified NAL type in
2140
+ * HEVC stream. if BL is backward compatible, Dolby Vision single
2141
+ * layer VES will be equivalent to a backward compatible BL VES on legacy
2142
+ * device as RPU will be ignored. Default 0 (disabled) */
2143
+ int dolbyProfile;
2144
+
2145
+ /* Set concantenation flag for the first keyframe in the HRD buffering period SEI. */
2146
+ int bEnableHRDConcatFlag;
2147
+
2148
+
2149
+ /* Store/normalize ctu distortion in analysis-save/load. Ranges from 0 - 1.
2150
+ * 0 - Disabled. 1 - Save/Load ctu distortion to/from the file specified
2151
+ * analysis-save/load. Default 0. */
2152
+ int ctuDistortionRefine;
2153
+
2154
+ /* Enable SVT HEVC Encoder */
2155
+ int bEnableSvtHevc;
2156
+
2157
+ /* SVT-HEVC param structure. For internal use when SVT HEVC encoder is enabled */
2158
+ void* svtHevcParam;
2159
+
2160
+ /* Detect fade-in regions. Enforces I-slice for the brightest point.
2161
+ Re-init RC history at that point in ABR mode. Default is disabled. */
2162
+ int bEnableFades;
2163
+
2164
+ /* Enable field coding */
2165
+ int bField;
2166
+
2167
+ /*Emit content light level info SEI*/
2168
+ int bEmitCLL;
2169
+
2170
+ /*
2171
+ * Signals picture structure SEI timing message for every frame
2172
+ * picture structure 7 is signalled for frame doubling
2173
+ * picture structure 8 is signalled for frame tripling
2174
+ * */
2175
+ int bEnableFrameDuplication;
2176
+
2177
+ /*
2178
+ * For adaptive frame duplication, a threshold is set above which the frames are similar.
2179
+ * User can set a variable threshold. Default 70.
2180
+ * */
2181
+ int dupThreshold;
2182
+
2183
+ /*Input sequence bit depth. It can be either 8bit, 10bit or 12bit.*/
2184
+ int sourceBitDepth;
2185
+
2186
+ /*Size of the zone to be reconfigured in frames. Default 0. API only. */
2187
+ uint32_t reconfigWindowSize;
2188
+
2189
+ /*Flag to indicate if rate-control history has to be reset during zone reconfiguration.
2190
+ Default 1 (Enabled). API only. */
2191
+ int bResetZoneConfig;
2192
+
2193
+ /*Flag to indicate rate-control history has not to be reset during zone reconfiguration.
2194
+ Default 0 (Disabled) */
2195
+ int bNoResetZoneConfig;
2196
+
2197
+ /* It reduces the bits spent on the inter-frames within the scenecutWindow before and / or after a scenecut
2198
+ * by increasing their QP in ratecontrol pass2 algorithm without any deterioration in visual quality.
2199
+ * 0 - Disabled (default).
2200
+ * 1 - Forward masking.
2201
+ * 2 - Backward masking.
2202
+ * 3 - Bi-directional masking. */
2203
+ int bEnableSceneCutAwareQp;
2204
+
2205
+ /* The duration(in milliseconds) for which there is a reduction in the bits spent on the inter-frames after a scenecut
2206
+ * by increasing their QP, when bEnableSceneCutAwareQp is 1 or 3. Default is 500ms.*/
2207
+ int fwdMaxScenecutWindow;
2208
+ int fwdScenecutWindow[6];
2209
+
2210
+ /* The offset by which QP is incremented for inter-frames after a scenecut when bEnableSceneCutAwareQp is 1 or 3.
2211
+ * Default is +5. */
2212
+ double fwdRefQpDelta[6];
2213
+
2214
+ /* The offset by which QP is incremented for non-referenced inter-frames after a scenecut when bEnableSceneCutAwareQp is 1 or 3. */
2215
+ double fwdNonRefQpDelta[6];
2216
+
2217
+ /* Enables histogram based scenecut detection algorithm to detect scenecuts. Default disabled */
2218
+ int bHistBasedSceneCut;
2219
+
2220
+ /* Enable HME search ranges for L0, L1 and L2 respectively. */
2221
+ int hmeRange[3];
2222
+
2223
+ /* Block-level QP optimization for HDR10 content. Default is disabled.*/
2224
+ int bHDR10Opt;
2225
+
2226
+ /* Enables the emitting of HDR10 SEI packets which contains HDR10-specific params.
2227
+ * Auto-enabled when max-cll, max-fall, or mastering display info is specified.
2228
+ * Default is disabled */
2229
+ int bEmitHDR10SEI;
2230
+
2231
+ /* A value between 1 and 10 (both inclusive) determines the level of
2232
+ * analysis information stored in analysis-save. Higher the refine level higher
2233
+ * the information stored. Default is 5 */
2234
+ int analysisSaveReuseLevel;
2235
+
2236
+ /* A value between 1 and 10 (both inclusive) determines the level of
2237
+ * analysis information reused in analysis-load. Higher the refine level higher
2238
+ * the information reused. Default is 5 */
2239
+ int analysisLoadReuseLevel;
2240
+
2241
+ /* Conformance window right offset specifies the padding offset to the
2242
+ * right side of the internal copy of the input pictures in the library.
2243
+ * The decoded picture will be cropped based on conformance window right offset
2244
+ * signaled in the SPS before output. Default is 0.
2245
+ * Recommended to set this during non-file based analysis-load.
2246
+ * This is to inform the encoder about the conformace window right offset
2247
+ * to be added to match the number of CUs across the width for which analysis
2248
+ * info is available from the corresponding analysis-save. */
2249
+
2250
+ int confWinRightOffset;
2251
+
2252
+ /* Conformance window bottom offset specifies the padding offset to the
2253
+ * bottom side of the internal copy of the input pictures in the library.
2254
+ * The decoded picture will be cropped based on conformance window bottom offset
2255
+ * signaled in the SPS before output. Default is 0.
2256
+ * Recommended to set this during non-file based analysis-load.
2257
+ * This is to inform the encoder about the conformace window bottom offset
2258
+ * to be added to match the number of CUs across the height for which analysis
2259
+ * info is available from the corresponding analysis-save. */
2260
+
2261
+ int confWinBottomOffset;
2262
+
2263
+ /* Edge variance threshold for quad tree establishment. */
2264
+ float edgeVarThreshold;
2265
+
2266
+ /* Maxrate that could be signaled to the decoder. Default 0. API only. */
2267
+ int decoderVbvMaxRate;
2268
+
2269
+ /*Enables Qp tuning with respect to real time VBV buffer fullness in rate
2270
+ control 2 pass. Experimental.Default is disabled*/
2271
+ int bliveVBV2pass;
2272
+
2273
+ /* Minimum VBV fullness to be maintained. Default 50. Keep the buffer
2274
+ * at least 50% full */
2275
+ double minVbvFullness;
2276
+
2277
+ /* Maximum VBV fullness to be maintained. Default 80. Keep the buffer
2278
+ * at max 80% full */
2279
+ double maxVbvFullness;
2280
+
2281
+ /* The duration(in milliseconds) for which there is a reduction in the bits spent on the inter-frames before a scenecut
2282
+ * by increasing their QP, when bEnableSceneCutAwareQp is 2 or 3. Default is 100ms.*/
2283
+ int bwdMaxScenecutWindow;
2284
+ int bwdScenecutWindow[6];
2285
+
2286
+ /* The offset by which QP is incremented for inter-frames before a scenecut when bEnableSceneCutAwareQp is 2 or 3. */
2287
+ double bwdRefQpDelta[6];
2288
+
2289
+ /* The offset by which QP is incremented for non-referenced inter-frames before a scenecut when bEnableSceneCutAwareQp is 2 or 3. */
2290
+ double bwdNonRefQpDelta[6];
2291
+
2292
+ /* Specify combinations of color primaries, transfer characteristics, color matrix,
2293
+ * range of luma and chroma signals, and chroma sample location. This has higher
2294
+ * precedence than individual VUI parameters. If any individual VUI option is specified
2295
+ * together with this, which changes the values set corresponding to the system-id
2296
+ * or color-volume, it will be discarded. */
2297
+ const char* videoSignalTypePreset;
2298
+
2299
+ /* Flag indicating whether the encoder should emit an End of Bitstream
2300
+ * NAL at the end of bitstream. Default false */
2301
+ int bEnableEndOfBitstream;
2302
+
2303
+ /* Flag indicating whether the encoder should emit an End of Sequence
2304
+ * NAL at the end of every Coded Video Sequence. Default false */
2305
+ int bEnableEndOfSequence;
2306
+
2307
+ /* Film Grain Characteristic file */
2308
+ char* filmGrain;
2309
+
2310
+ /*Motion compensated temporal filter*/
2311
+ int bEnableTemporalFilter;
2312
+ double temporalFilterStrength;
2313
+
2314
+ /*SBRC*/
2315
+ int bEnableSBRC;
2316
+ int mcstfFrameRange;
2317
+
2318
+ /*Alpha channel encoding*/
2319
+ int bEnableAlpha;
2320
+ int numScalableLayers;
2321
+
2322
+ /*Multi View Encoding*/
2323
+ int numViews;
2324
+ int format;
2325
+
2326
+ int numLayers;
2327
+
2328
+ /*Screen Content Coding*/
2329
+ int bEnableSCC;
2330
+ } x265_param;
2331
+
2332
+ /* x265_param_alloc:
2333
+ * Allocates an x265_param instance. The returned param structure is not
2334
+ * special in any way, but using this method together with x265_param_free()
2335
+ * and x265_param_parse() to set values by name allows the application to treat
2336
+ * x265_param as an opaque data struct for version safety */
2337
+ x265_param *x265_param_alloc(void);
2338
+
2339
+ /* x265_param_free:
2340
+ * Use x265_param_free() to release storage for an x265_param instance
2341
+ * allocated by x265_param_alloc() */
2342
+ void x265_param_free(x265_param *);
2343
+
2344
+ /* x265_param_default:
2345
+ * Initialize an x265_param structure to default values */
2346
+ void x265_param_default(x265_param *param);
2347
+
2348
+ /* x265_param_parse:
2349
+ * set one parameter by name.
2350
+ * returns 0 on success, or returns one of the following errors.
2351
+ * note: BAD_VALUE occurs only if it can't even parse the value,
2352
+ * numerical range is not checked until x265_encoder_open().
2353
+ * value=NULL means "true" for boolean options, but is a BAD_VALUE for non-booleans. */
2354
+ #define X265_PARAM_BAD_NAME (-1)
2355
+ #define X265_PARAM_BAD_VALUE (-2)
2356
+ int x265_param_parse(x265_param *p, const char *name, const char *value);
2357
+
2358
+ x265_zone *x265_zone_alloc(int zoneCount, int isZoneFile);
2359
+
2360
+ void x265_zone_free(x265_param *param);
2361
+
2362
+ int x265_zone_param_parse(x265_param* p, const char* name, const char* value);
2363
+
2364
+ int x265_scenecut_aware_qp_param_parse(x265_param* p, const char* name, const char* value);
2365
+
2366
+ static const char * const x265_profile_names[] = {
2367
+ /* HEVC v1 */
2368
+ "main", "main10", "mainstillpicture", /* alias */ "msp",
2369
+
2370
+ /* HEVC v2 (Range Extensions) */
2371
+ "main-intra", "main10-intra",
2372
+ "main444-8", "main444-intra", "main444-stillpicture",
2373
+
2374
+ "main422-10", "main422-10-intra",
2375
+ "main444-10", "main444-10-intra",
2376
+
2377
+ "main12", "main12-intra",
2378
+ "main422-12", "main422-12-intra",
2379
+ "main444-12", "main444-12-intra",
2380
+
2381
+ "main444-16-intra", "main444-16-stillpicture", /* Not Supported! */
2382
+
2383
+ #if ENABLE_SCC_EXT
2384
+ "main-scc", "main10-scc", "main444-scc", "main444-10-scc", /* Screen content coding */
2385
+ #endif
2386
+ 0
2387
+ };
2388
+
2389
+ /* x265_param_apply_profile:
2390
+ * Applies the restrictions of the given profile. (one of x265_profile_names)
2391
+ * (can be NULL, in which case the function will do nothing)
2392
+ * Note: the detected profile can be lower than the one specified to this
2393
+ * function. This function will force the encoder parameters to fit within
2394
+ * the specified profile, or fail if that is impossible.
2395
+ * returns 0 on success, negative on failure (e.g. invalid profile name). */
2396
+ int x265_param_apply_profile(x265_param *, const char *profile);
2397
+
2398
+ /* x265_param_default_preset:
2399
+ * The same as x265_param_default, but also use the passed preset and tune
2400
+ * to modify the default settings.
2401
+ * (either can be NULL, which implies no preset or no tune, respectively)
2402
+ *
2403
+ * Currently available presets are, ordered from fastest to slowest: */
2404
+ static const char * const x265_preset_names[] = { "ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo", 0 };
2405
+
2406
+ /* The presets can also be indexed numerically, as in:
2407
+ * x265_param_default_preset( &param, "3", ... )
2408
+ * with ultrafast mapping to "0" and placebo mapping to "9". This mapping may
2409
+ * of course change if new presets are added in between, but will always be
2410
+ * ordered from fastest to slowest.
2411
+ *
2412
+ * Warning: the speed of these presets scales dramatically. Ultrafast is a full
2413
+ * 100 times faster than placebo!
2414
+ *
2415
+ * Currently available tunings are: */
2416
+ static const char * const x265_tune_names[] = { "psnr", "ssim", "grain", "zerolatency", "fastdecode", "animation", 0 };
2417
+
2418
+ /* returns 0 on success, negative on failure (e.g. invalid preset/tune name). */
2419
+ int x265_param_default_preset(x265_param *, const char *preset, const char *tune);
2420
+
2421
+ /* x265_picture_alloc:
2422
+ * Allocates an x265_picture instance. The returned picture structure is not
2423
+ * special in any way, but using this method together with x265_picture_free()
2424
+ * and x265_picture_init() allows some version safety. New picture fields will
2425
+ * always be added to the end of x265_picture */
2426
+ x265_picture *x265_picture_alloc(void);
2427
+
2428
+ /* x265_picture_free:
2429
+ * Use x265_picture_free() to release storage for an x265_picture instance
2430
+ * allocated by x265_picture_alloc() */
2431
+ void x265_picture_free(x265_picture *);
2432
+
2433
+ /* x265_picture_init:
2434
+ * Initialize an x265_picture structure to default values. It sets the pixel
2435
+ * depth and color space to the encoder's internal values and sets the slice
2436
+ * type to auto - so the lookahead will determine slice type. */
2437
+ void x265_picture_init(x265_param *param, x265_picture *pic);
2438
+
2439
+ /* x265_max_bit_depth:
2440
+ * Specifies the numer of bits per pixel that x265 uses internally to
2441
+ * represent a pixel, and the bit depth of the output bitstream.
2442
+ * param->internalBitDepth must be set to this value. x265_max_bit_depth
2443
+ * will be 8 for default builds, 10 for HIGH_BIT_DEPTH builds. */
2444
+ X265_API extern const int x265_max_bit_depth;
2445
+
2446
+ /* x265_version_str:
2447
+ * A static string containing the version of this compiled x265 library */
2448
+ X265_API extern const char *x265_version_str;
2449
+
2450
+ /* x265_build_info:
2451
+ * A static string describing the compiler and target architecture */
2452
+ X265_API extern const char *x265_build_info_str;
2453
+
2454
+ /* x265_alloc_analysis_data:
2455
+ * Allocate memory for the x265_analysis_data object's internal structures. */
2456
+ void x265_alloc_analysis_data(x265_param *param, x265_analysis_data* analysis);
2457
+
2458
+ /*
2459
+ * Free the allocated memory for x265_analysis_data object's internal structures. */
2460
+ void x265_free_analysis_data(x265_param *param, x265_analysis_data* analysis);
2461
+
2462
+ /* Force a link error in the case of linking against an incompatible API version.
2463
+ * Glue #defines exist to force correct macro expansion; the final output of the macro
2464
+ * is x265_encoder_open_##X265_BUILD (for purposes of dlopen). */
2465
+ #define x265_encoder_glue1(x, y) x ## y
2466
+ #define x265_encoder_glue2(x, y) x265_encoder_glue1(x, y)
2467
+ #define x265_encoder_open x265_encoder_glue2(x265_encoder_open_, X265_BUILD)
2468
+
2469
+ /* x265_encoder_open:
2470
+ * create a new encoder handler, all parameters from x265_param are copied */
2471
+ x265_encoder* x265_encoder_open(x265_param *);
2472
+
2473
+ /* x265_encoder_parameters:
2474
+ * copies the current internal set of parameters to the pointer provided
2475
+ * by the caller. useful when the calling application needs to know
2476
+ * how x265_encoder_open has changed the parameters.
2477
+ * note that the data accessible through pointers in the returned param struct
2478
+ * (e.g. filenames) should not be modified by the calling application. */
2479
+ void x265_encoder_parameters(x265_encoder *, x265_param *);
2480
+
2481
+ /* x265_encoder_headers:
2482
+ * return the SPS and PPS that will be used for the whole stream.
2483
+ * *pi_nal is the number of NAL units outputted in pp_nal.
2484
+ * returns negative on error, total byte size of payload data on success
2485
+ * the payloads of all output NALs are guaranteed to be sequential in memory. */
2486
+ int x265_encoder_headers(x265_encoder *, x265_nal **pp_nal, uint32_t *pi_nal);
2487
+
2488
+ /* x265_encoder_encode:
2489
+ * encode one picture.
2490
+ * *pi_nal is the number of NAL units outputted in pp_nal.
2491
+ * returns negative on error, 1 if a picture and access unit were output,
2492
+ * or zero if the encoder pipeline is still filling or is empty after flushing.
2493
+ * the payloads of all output NALs are guaranteed to be sequential in memory.
2494
+ * To flush the encoder and retrieve delayed output pictures, pass pic_in as NULL.
2495
+ * Once flushing has begun, all subsequent calls must pass pic_in as NULL. */
2496
+ int x265_encoder_encode(x265_encoder *encoder, x265_nal **pp_nal, uint32_t *pi_nal, x265_picture *pic_in, x265_picture **pic_out);
2497
+
2498
+ /* x265_encoder_reconfig:
2499
+ * various parameters from x265_param are copied.
2500
+ * this takes effect immediately, on whichever frame is encoded next;
2501
+ * returns 0 on success, negative on parameter validation error.
2502
+ *
2503
+ * not all parameters can be changed; see the actual function for a
2504
+ * detailed breakdown. since not all parameters can be changed, moving
2505
+ * from preset to preset may not always fully copy all relevant parameters,
2506
+ * but should still work usably in practice. however, more so than for
2507
+ * other presets, many of the speed shortcuts used in ultrafast cannot be
2508
+ * switched out of; using reconfig to switch between ultrafast and other
2509
+ * presets is not recommended without a more fine-grained breakdown of
2510
+ * parameters to take this into account. */
2511
+ int x265_encoder_reconfig(x265_encoder *, x265_param *);
2512
+
2513
+ /* x265_encoder_reconfig_zone:
2514
+ * zone settings are copied to the encoder's param.
2515
+ * Properties of the zone will be used only to re-configure rate-control settings
2516
+ * of the zone mid-encode. Returns 0 on success on successful copy, negative on failure.*/
2517
+ int x265_encoder_reconfig_zone(x265_encoder *, x265_zone *);
2518
+
2519
+ /* x265_encoder_get_stats:
2520
+ * returns encoder statistics */
2521
+ void x265_encoder_get_stats(x265_encoder *encoder, x265_stats *, uint32_t statsSizeBytes);
2522
+
2523
+ /* x265_encoder_log:
2524
+ * write a line to the configured CSV file. If a CSV filename was not
2525
+ * configured, or file open failed, this function will perform no write. */
2526
+ void x265_encoder_log(x265_encoder *encoder, int argc, char **argv);
2527
+
2528
+ /* x265_encoder_close:
2529
+ * close an encoder handler */
2530
+ void x265_encoder_close(x265_encoder *);
2531
+
2532
+ /* x265_encoder_intra_refresh:
2533
+ * If an intra refresh is not in progress, begin one with the next P-frame.
2534
+ * If an intra refresh is in progress, begin one as soon as the current one finishes.
2535
+ * Requires bIntraRefresh to be set.
2536
+ *
2537
+ * Useful for interactive streaming where the client can tell the server that packet loss has
2538
+ * occurred. In this case, keyint can be set to an extremely high value so that intra refreshes
2539
+ * occur only when calling x265_encoder_intra_refresh.
2540
+ *
2541
+ * In multi-pass encoding, if x265_encoder_intra_refresh is called differently in each pass,
2542
+ * behavior is undefined.
2543
+ *
2544
+ * Should not be called during an x265_encoder_encode. */
2545
+
2546
+ int x265_encoder_intra_refresh(x265_encoder *);
2547
+
2548
+ /* x265_encoder_ctu_info:
2549
+ * Copy CTU information such as ctu address and ctu partition structure of all
2550
+ * CTUs in each frame. The function is invoked only if "--ctu-info" is enabled and
2551
+ * the encoder will wait for this copy to complete if enabled.
2552
+ */
2553
+ int x265_encoder_ctu_info(x265_encoder *, int poc, x265_ctu_info_t** ctu);
2554
+
2555
+ /* x265_get_slicetype_poc_and_scenecut:
2556
+ * get the slice type, poc and scene cut information for the current frame,
2557
+ * returns negative on error, 0 when access unit were output.
2558
+ * This API must be called after(poc >= lookaheadDepth + bframes + 2) condition check */
2559
+ int x265_get_slicetype_poc_and_scenecut(x265_encoder *encoder, int *slicetype, int *poc, int* sceneCut);
2560
+
2561
+ /* x265_get_ref_frame_list:
2562
+ * returns negative on error, 0 when access unit were output.
2563
+ * This API must be called after(poc >= lookaheadDepth + bframes + 2) condition check */
2564
+ int x265_get_ref_frame_list(x265_encoder *encoder, x265_picyuv**, x265_picyuv**, int, int, int*, int*);
2565
+
2566
+ /* x265_set_analysis_data:
2567
+ * set the analysis data. The incoming analysis_data structure is assumed to be AVC-sized blocks.
2568
+ * returns negative on error, 0 access unit were output. */
2569
+ int x265_set_analysis_data(x265_encoder *encoder, x265_analysis_data *analysis_data, int poc, uint32_t cuBytes);
2570
+
2571
+ /* x265_cleanup:
2572
+ * release library static allocations, reset configured CTU size */
2573
+ void x265_cleanup(void);
2574
+
2575
+ /* Open a CSV log file. On success it returns a file handle which must be passed
2576
+ * to x265_csvlog_frame() and/or x265_csvlog_encode(). The file handle must be
2577
+ * closed by the caller using fclose(). If csv-loglevel is 0, then no frame logging
2578
+ * header is written to the file. This function will return NULL if it is unable
2579
+ * to open the file for write or if it detects a structure size skew */
2580
+ FILE* x265_csvlog_open(const x265_param *);
2581
+
2582
+ /* Log frame statistics to the CSV file handle. csv-loglevel should have been non-zero
2583
+ * in the call to x265_csvlog_open() if this function is called. */
2584
+ void x265_csvlog_frame(const x265_param *, const x265_picture *);
2585
+
2586
+ /* Log final encode statistics to the CSV file handle. 'argc' and 'argv' are
2587
+ * intended to be command line arguments passed to the encoder. padx and pady are
2588
+ * padding offsets for conformance and can be given from sps settings. Encode
2589
+ * statistics should be queried from the encoder just prior to closing it. */
2590
+ void x265_csvlog_encode(const x265_param*, const x265_stats *, int padx, int pady, int argc, char** argv);
2591
+
2592
+ /* In-place downshift from a bit-depth greater than 8 to a bit-depth of 8, using
2593
+ * the residual bits to dither each row. */
2594
+ void x265_dither_image(x265_picture *, int picWidth, int picHeight, int16_t *errorBuf, int bitDepth);
2595
+ #if ENABLE_LIBVMAF
2596
+ /* x265_calculate_vmafScore:
2597
+ * returns VMAF score for the input video.
2598
+ * This api must be called only after encoding was done. */
2599
+ double x265_calculate_vmafscore(x265_param*, x265_vmaf_data*);
2600
+
2601
+ /* x265_calculate_vmaf_framelevelscore:
2602
+ * returns VMAF score for each frame in a given input video. */
2603
+ double x265_calculate_vmaf_framelevelscore(x265_param*, x265_vmaf_framedata*);
2604
+ /* x265_vmaf_encoder_log:
2605
+ * write a line to the configured CSV file. If a CSV filename was not
2606
+ * configured, or file open failed, this function will perform no write.
2607
+ * This api will be called only when ENABLE_LIBVMAF cmake option is set */
2608
+ void x265_vmaf_encoder_log(x265_encoder *encoder, int argc, char **argv, x265_param*, x265_vmaf_data*);
2609
+
2610
+ #endif
2611
+
2612
+ #define X265_MAJOR_VERSION 1
2613
+
2614
+ /* === Multi-lib API ===
2615
+ * By using this method to gain access to the libx265 interfaces, you allow run-
2616
+ * time selection between various available libx265 libraries based on the
2617
+ * encoder parameters. The most likely use case is to choose between Main and
2618
+ * Main10 builds of libx265. */
2619
+
2620
+ typedef struct x265_api
2621
+ {
2622
+ int api_major_version; /* X265_MAJOR_VERSION */
2623
+ int api_build_number; /* X265_BUILD (soname) */
2624
+ int sizeof_param; /* sizeof(x265_param) */
2625
+ int sizeof_picture; /* sizeof(x265_picture) */
2626
+ int sizeof_analysis_data; /* sizeof(x265_analysis_data) */
2627
+ int sizeof_zone; /* sizeof(x265_zone) */
2628
+ int sizeof_stats; /* sizeof(x265_stats) */
2629
+
2630
+ int bit_depth;
2631
+ const char* version_str;
2632
+ const char* build_info_str;
2633
+
2634
+ /* libx265 public API functions, documented above with x265_ prefixes */
2635
+ x265_param* (*param_alloc)(void);
2636
+ void (*param_free)(x265_param*);
2637
+ void (*param_default)(x265_param*);
2638
+ int (*param_parse)(x265_param*, const char*, const char*);
2639
+ int (*scenecut_aware_qp_param_parse)(x265_param*, const char*, const char*);
2640
+ int (*param_apply_profile)(x265_param*, const char*);
2641
+ int (*param_default_preset)(x265_param*, const char*, const char *);
2642
+ x265_picture* (*picture_alloc)(void);
2643
+ void (*picture_free)(x265_picture*);
2644
+ void (*picture_init)(x265_param*, x265_picture*);
2645
+ x265_encoder* (*encoder_open)(x265_param*);
2646
+ void (*encoder_parameters)(x265_encoder*, x265_param*);
2647
+ int (*encoder_reconfig)(x265_encoder*, x265_param*);
2648
+ int (*encoder_reconfig_zone)(x265_encoder*, x265_zone*);
2649
+ int (*encoder_headers)(x265_encoder*, x265_nal**, uint32_t*);
2650
+ int (*encoder_encode)(x265_encoder*, x265_nal**, uint32_t*, x265_picture*, x265_picture**);
2651
+ void (*encoder_get_stats)(x265_encoder*, x265_stats*, uint32_t);
2652
+ void (*encoder_log)(x265_encoder*, int, char**);
2653
+ void (*encoder_close)(x265_encoder*);
2654
+ void (*cleanup)(void);
2655
+
2656
+ int sizeof_frame_stats; /* sizeof(x265_frame_stats) */
2657
+ int (*encoder_intra_refresh)(x265_encoder*);
2658
+ int (*encoder_ctu_info)(x265_encoder*, int, x265_ctu_info_t**);
2659
+ int (*get_slicetype_poc_and_scenecut)(x265_encoder*, int*, int*, int*);
2660
+ int (*get_ref_frame_list)(x265_encoder*, x265_picyuv**, x265_picyuv**, int, int, int*, int*);
2661
+ FILE* (*csvlog_open)(const x265_param*);
2662
+ void (*csvlog_frame)(const x265_param*, const x265_picture*);
2663
+ void (*csvlog_encode)(const x265_param*, const x265_stats *, int, int, int, char**);
2664
+ void (*dither_image)(x265_picture*, int, int, int16_t*, int);
2665
+ int (*set_analysis_data)(x265_encoder *encoder, x265_analysis_data *analysis_data, int poc, uint32_t cuBytes);
2666
+ #if ENABLE_LIBVMAF
2667
+ double (*calculate_vmafscore)(x265_param *, x265_vmaf_data *);
2668
+ double (*calculate_vmaf_framelevelscore)(x265_param *, x265_vmaf_framedata *);
2669
+ void (*vmaf_encoder_log)(x265_encoder*, int, char**, x265_param *, x265_vmaf_data *);
2670
+ #endif
2671
+ int (*zone_param_parse)(x265_param*, const char*, const char*);
2672
+ /* add new pointers to the end, or increment X265_MAJOR_VERSION */
2673
+ } x265_api;
2674
+
2675
+ /* Force a link error in the case of linking against an incompatible API version.
2676
+ * Glue #defines exist to force correct macro expansion; the final output of the macro
2677
+ * is x265_api_get_##X265_BUILD (for purposes of dlopen). */
2678
+ #define x265_api_glue1(x, y) x ## y
2679
+ #define x265_api_glue2(x, y) x265_api_glue1(x, y)
2680
+ #define x265_api_get x265_api_glue2(x265_api_get_, X265_BUILD)
2681
+
2682
+ /* x265_api_get:
2683
+ * Retrieve the programming interface for a linked x265 library.
2684
+ * May return NULL if no library is available that supports the
2685
+ * requested bit depth. If bitDepth is 0 the function is guarunteed
2686
+ * to return a non-NULL x265_api pointer, from the linked libx265.
2687
+ *
2688
+ * If the requested bitDepth is not supported by the linked libx265,
2689
+ * it will attempt to dynamically bind x265_api_get() from a shared
2690
+ * library with an appropriate name:
2691
+ * 8bit: libx265_main.so
2692
+ * 10bit: libx265_main10.so
2693
+ * Obviously the shared library file extension is platform specific */
2694
+ const x265_api* x265_api_get(int bitDepth);
2695
+
2696
+ /* x265_api_query:
2697
+ * Retrieve the programming interface for a linked x265 library, like
2698
+ * x265_api_get(), except this function accepts X265_BUILD as the second
2699
+ * argument rather than using the build number as part of the function name.
2700
+ * Applications which dynamically link to libx265 can use this interface to
2701
+ * query the library API and achieve a relative amount of version skew
2702
+ * flexibility. The function may return NULL if the library determines that
2703
+ * the apiVersion that your application was compiled against is not compatible
2704
+ * with the library you have linked with.
2705
+ *
2706
+ * api_major_version will be incremented any time non-backward compatible
2707
+ * changes are made to any public structures or functions. If
2708
+ * api_major_version does not match X265_MAJOR_VERSION from the x265.h your
2709
+ * application compiled against, your application must not use the returned
2710
+ * x265_api pointer.
2711
+ *
2712
+ * Users of this API *must* also validate the sizes of any structures which
2713
+ * are not treated as opaque in application code. For instance, if your
2714
+ * application dereferences a x265_param pointer, then it must check that
2715
+ * api->sizeof_param matches the sizeof(x265_param) that your application
2716
+ * compiled with. */
2717
+ const x265_api* x265_api_query(int bitDepth, int apiVersion, int* err);
2718
+
2719
+ #define X265_API_QUERY_ERR_NONE 0 /* returned API pointer is non-NULL */
2720
+ #define X265_API_QUERY_ERR_VER_REFUSED 1 /* incompatible version skew */
2721
+ #define X265_API_QUERY_ERR_LIB_NOT_FOUND 2 /* libx265_main10 not found, for ex */
2722
+ #define X265_API_QUERY_ERR_FUNC_NOT_FOUND 3 /* unable to bind x265_api_query */
2723
+ #define X265_API_QUERY_ERR_WRONG_BITDEPTH 4 /* libx265_main10 not 10bit, for ex */
2724
+
2725
+ static const char * const x265_api_query_errnames[] = {
2726
+ "api queried from libx265",
2727
+ "libx265 version is not compatible with this application",
2728
+ "unable to bind a libx265 with requested bit depth",
2729
+ "unable to bind x265_api_query from libx265",
2730
+ "libx265 has an invalid bitdepth"
2731
+ };
2732
+
2733
+ #ifdef __cplusplus
2734
+ }
2735
+ #endif
2736
+
2737
+ #endif // X265_H