e5474b75035f274387a21d78394a060837a38838
[deb_x265.git] / source / x265.h
1 /*****************************************************************************
2 * Copyright (C) 2013 x265 project
3 *
4 * Authors: Steve Borho <steve@borho.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
19 *
20 * This program is also available under a commercial proprietary license.
21 * For more information, contact us at license @ x265.com.
22 *****************************************************************************/
23
24 #ifndef X265_H
25 #define X265_H
26
27 #include <stdint.h>
28 #include "x265_config.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /* x265_encoder:
35 * opaque handler for encoder */
36 typedef struct x265_encoder x265_encoder;
37
38 /* Application developers planning to link against a shared library version of
39 * libx265 from a Microsoft Visual Studio or similar development environment
40 * will need to define X265_API_IMPORTS before including this header.
41 * This clause does not apply to MinGW, similar development environments, or non
42 * Windows platforms. */
43 #ifdef X265_API_IMPORTS
44 #define X265_API __declspec(dllimport)
45 #else
46 #define X265_API
47 #endif
48
49 typedef enum
50 {
51 NAL_UNIT_CODED_SLICE_TRAIL_N = 0,
52 NAL_UNIT_CODED_SLICE_TRAIL_R,
53 NAL_UNIT_CODED_SLICE_TSA_N,
54 NAL_UNIT_CODED_SLICE_TLA_R,
55 NAL_UNIT_CODED_SLICE_STSA_N,
56 NAL_UNIT_CODED_SLICE_STSA_R,
57 NAL_UNIT_CODED_SLICE_RADL_N,
58 NAL_UNIT_CODED_SLICE_RADL_R,
59 NAL_UNIT_CODED_SLICE_RASL_N,
60 NAL_UNIT_CODED_SLICE_RASL_R,
61 NAL_UNIT_CODED_SLICE_BLA_W_LP = 16,
62 NAL_UNIT_CODED_SLICE_BLA_W_RADL,
63 NAL_UNIT_CODED_SLICE_BLA_N_LP,
64 NAL_UNIT_CODED_SLICE_IDR_W_RADL,
65 NAL_UNIT_CODED_SLICE_IDR_N_LP,
66 NAL_UNIT_CODED_SLICE_CRA,
67 NAL_UNIT_VPS = 32,
68 NAL_UNIT_SPS,
69 NAL_UNIT_PPS,
70 NAL_UNIT_ACCESS_UNIT_DELIMITER,
71 NAL_UNIT_EOS,
72 NAL_UNIT_EOB,
73 NAL_UNIT_FILLER_DATA,
74 NAL_UNIT_PREFIX_SEI,
75 NAL_UNIT_SUFFIX_SEI,
76 NAL_UNIT_INVALID = 64,
77 } NalUnitType;
78
79 /* The data within the payload is already NAL-encapsulated; the type is merely
80 * in the struct for easy access by the calling application. All data returned
81 * in an x265_nal, including the data in payload, is no longer valid after the
82 * next call to x265_encoder_encode. Thus it must be used or copied before
83 * calling x265_encoder_encode again. */
84 typedef struct x265_nal
85 {
86 uint32_t type; /* NalUnitType */
87 uint32_t sizeBytes; /* size in bytes */
88 uint8_t* payload;
89 } x265_nal;
90
91 /* Stores inter (motion estimation) analysis data for a single frame */
92 typedef struct x265_inter_data
93 {
94 uint32_t zOrder;
95 int ref[2];
96 int costZero[2];
97 int16_t mvx[2];
98 int16_t mvy[2];
99 uint32_t depth;
100 int poc;
101 uint32_t cuAddr;
102 } x265_inter_data;
103
104 /* Stores intra (motion estimation) analysis data for a single frame */
105 typedef struct x265_intra_data
106 {
107 uint8_t* depth;
108 uint8_t* modes;
109 char* partSizes;
110 int* poc;
111 uint32_t* cuAddr;
112 } x265_intra_data;
113
114 /* Stores all analysis data for a single frame */
115 typedef struct x265_analysis_data
116 {
117 x265_inter_data* interData;
118 x265_intra_data* intraData;
119 uint32_t numCUsInFrame;
120 uint32_t numPartitions;
121 } x265_analysis_data;
122
123 /* Used to pass pictures into the encoder, and to get picture data back out of
124 * the encoder. The input and output semantics are different */
125 typedef struct x265_picture
126 {
127 /* Must be specified on input pictures, the number of planes is determined
128 * by the colorSpace value */
129 void* planes[3];
130
131 /* Stride is the number of bytes between row starts */
132 int stride[3];
133
134 /* Must be specified on input pictures. x265_picture_init() will set it to
135 * the encoder's internal bit depth, but this field must describe the depth
136 * of the input pictures. Must be between 8 and 16. Values larger than 8
137 * imply 16bits per input sample. If input bit depth is larger than the
138 * internal bit depth, the encoder will down-shift pixels. Input samples
139 * larger than 8bits will be masked to internal bit depth. On output the
140 * bitDepth will be the internal encoder bit depth */
141 int bitDepth;
142
143 /* Must be specified on input pictures: X265_TYPE_AUTO or other.
144 * x265_picture_init() sets this to auto, returned on output */
145 int sliceType;
146
147 /* Ignored on input, set to picture count, returned on output */
148 int poc;
149
150 /* Must be specified on input pictures: X265_CSP_I420 or other. It must
151 * match the internal color space of the encoder. x265_picture_init() will
152 * initialize this value to the internal color space */
153 int colorSpace;
154
155 /* presentation time stamp: user-specified, returned on output */
156 int64_t pts;
157
158 /* display time stamp: ignored on input, copied from reordered pts. Returned
159 * on output */
160 int64_t dts;
161
162 /* The value provided on input is returned with the same picture (POC) on
163 * output */
164 void* userData;
165
166 /* force quantizer for != X265_QP_AUTO */
167 int forceqp;
168
169 /* If param.analysisMode is X265_ANALYSIS_OFF this field is ignored on input
170 * and output. Else the user must call x265_alloc_analysis_data() to
171 * allocate analysis buffers for every picture passed to the encoder.
172 *
173 * On input when param.analysisMode is X265_ANALYSIS_LOAD and analysisData
174 * member pointers are valid, the encoder will use the data stored here to
175 * reduce encoder work.
176 *
177 * On output when param.analysisMode is X265_ANALYSIS_SAVE and analysisData
178 * member pointers are valid, the encoder will write output analysis into
179 * this data structure */
180 x265_analysis_data analysisData;
181
182 /* new data members to this structure must be added to the end so that
183 * users of x265_picture_alloc/free() can be assured of future safety */
184 } x265_picture;
185
186 typedef enum
187 {
188 X265_DIA_SEARCH,
189 X265_HEX_SEARCH,
190 X265_UMH_SEARCH,
191 X265_STAR_SEARCH,
192 X265_FULL_SEARCH
193 } X265_ME_METHODS;
194
195 /* CPU flags */
196
197 /* x86 */
198 #define X265_CPU_CMOV 0x0000001
199 #define X265_CPU_MMX 0x0000002
200 #define X265_CPU_MMX2 0x0000004 /* MMX2 aka MMXEXT aka ISSE */
201 #define X265_CPU_MMXEXT X265_CPU_MMX2
202 #define X265_CPU_SSE 0x0000008
203 #define X265_CPU_SSE2 0x0000010
204 #define X265_CPU_SSE3 0x0000020
205 #define X265_CPU_SSSE3 0x0000040
206 #define X265_CPU_SSE4 0x0000080 /* SSE4.1 */
207 #define X265_CPU_SSE42 0x0000100 /* SSE4.2 */
208 #define X265_CPU_LZCNT 0x0000200 /* Phenom support for "leading zero count" instruction. */
209 #define X265_CPU_AVX 0x0000400 /* AVX support: requires OS support even if YMM registers aren't used. */
210 #define X265_CPU_XOP 0x0000800 /* AMD XOP */
211 #define X265_CPU_FMA4 0x0001000 /* AMD FMA4 */
212 #define X265_CPU_AVX2 0x0002000 /* AVX2 */
213 #define X265_CPU_FMA3 0x0004000 /* Intel FMA3 */
214 #define X265_CPU_BMI1 0x0008000 /* BMI1 */
215 #define X265_CPU_BMI2 0x0010000 /* BMI2 */
216 /* x86 modifiers */
217 #define X265_CPU_CACHELINE_32 0x0020000 /* avoid memory loads that span the border between two cachelines */
218 #define X265_CPU_CACHELINE_64 0x0040000 /* 32/64 is the size of a cacheline in bytes */
219 #define X265_CPU_SSE2_IS_SLOW 0x0080000 /* avoid most SSE2 functions on Athlon64 */
220 #define X265_CPU_SSE2_IS_FAST 0x0100000 /* a few functions are only faster on Core2 and Phenom */
221 #define X265_CPU_SLOW_SHUFFLE 0x0200000 /* The Conroe has a slow shuffle unit (relative to overall SSE performance) */
222 #define X265_CPU_STACK_MOD4 0x0400000 /* if stack is only mod4 and not mod16 */
223 #define X265_CPU_SLOW_CTZ 0x0800000 /* BSR/BSF x86 instructions are really slow on some CPUs */
224 #define X265_CPU_SLOW_ATOM 0x1000000 /* The Atom is terrible: slow SSE unaligned loads, slow
225 * SIMD multiplies, slow SIMD variable shifts, slow pshufb,
226 * cacheline split penalties -- gather everything here that
227 * isn't shared by other CPUs to avoid making half a dozen
228 * new SLOW flags. */
229 #define X265_CPU_SLOW_PSHUFB 0x2000000 /* such as on the Intel Atom */
230 #define X265_CPU_SLOW_PALIGNR 0x4000000 /* such as on the AMD Bobcat */
231
232 /* ARM */
233 #define X265_CPU_ARMV6 0x0000001
234 #define X265_CPU_NEON 0x0000002 /* ARM NEON */
235 #define X265_CPU_FAST_NEON_MRC 0x0000004 /* Transfer from NEON to ARM register is fast (Cortex-A9) */
236
237 #define X265_MAX_SUBPEL_LEVEL 7
238
239 /* Log level */
240 #define X265_LOG_NONE (-1)
241 #define X265_LOG_ERROR 0
242 #define X265_LOG_WARNING 1
243 #define X265_LOG_INFO 2
244 #define X265_LOG_DEBUG 3
245 #define X265_LOG_FULL 4
246
247 #define X265_B_ADAPT_NONE 0
248 #define X265_B_ADAPT_FAST 1
249 #define X265_B_ADAPT_TRELLIS 2
250
251 #define X265_BFRAME_MAX 16
252
253 #define X265_TYPE_AUTO 0x0000 /* Let x265 choose the right type */
254 #define X265_TYPE_IDR 0x0001
255 #define X265_TYPE_I 0x0002
256 #define X265_TYPE_P 0x0003
257 #define X265_TYPE_BREF 0x0004 /* Non-disposable B-frame */
258 #define X265_TYPE_B 0x0005
259 #define X265_QP_AUTO 0
260
261 #define X265_AQ_NONE 0
262 #define X265_AQ_VARIANCE 1
263 #define X265_AQ_AUTO_VARIANCE 2
264 #define IS_X265_TYPE_I(x) ((x) == X265_TYPE_I || (x) == X265_TYPE_IDR)
265 #define IS_X265_TYPE_B(x) ((x) == X265_TYPE_B || (x) == X265_TYPE_BREF)
266
267 /* NOTE! For this release only X265_CSP_I420 and X265_CSP_I444 are supported */
268
269 /* Supported internal color space types (according to semantics of chroma_format_idc) */
270 #define X265_CSP_I400 0 /* yuv 4:0:0 planar */
271 #define X265_CSP_I420 1 /* yuv 4:2:0 planar */
272 #define X265_CSP_I422 2 /* yuv 4:2:2 planar */
273 #define X265_CSP_I444 3 /* yuv 4:4:4 planar */
274 #define X265_CSP_COUNT 4 /* Number of supported internal color spaces */
275
276 /* These color spaces will eventually be supported as input pictures. The pictures will
277 * be converted to the appropriate planar color spaces at ingest */
278 #define X265_CSP_NV12 4 /* yuv 4:2:0, with one y plane and one packed u+v */
279 #define X265_CSP_NV16 5 /* yuv 4:2:2, with one y plane and one packed u+v */
280
281 /* Interleaved color-spaces may eventually be supported as input pictures */
282 #define X265_CSP_BGR 6 /* packed bgr 24bits */
283 #define X265_CSP_BGRA 7 /* packed bgr 32bits */
284 #define X265_CSP_RGB 8 /* packed rgb 24bits */
285 #define X265_CSP_MAX 9 /* end of list */
286
287 #define X265_EXTENDED_SAR 255 /* aspect ratio explicitly specified as width:height */
288
289 /* Analysis options */
290 #define X265_ANALYSIS_OFF 0
291 #define X265_ANALYSIS_SAVE 1
292 #define X265_ANALYSIS_LOAD 2
293
294 typedef struct
295 {
296 int planes;
297 int width[3];
298 int height[3];
299 } x265_cli_csp;
300
301 static const x265_cli_csp x265_cli_csps[] =
302 {
303 { 1, { 0, 0, 0 }, { 0, 0, 0 } }, /* i400 */
304 { 3, { 0, 1, 1 }, { 0, 1, 1 } }, /* i420 */
305 { 3, { 0, 1, 1 }, { 0, 0, 0 } }, /* i422 */
306 { 3, { 0, 0, 0 }, { 0, 0, 0 } }, /* i444 */
307 { 2, { 0, 0 }, { 0, 1 } }, /* nv12 */
308 { 2, { 0, 0 }, { 0, 0 } }, /* nv16 */
309 };
310
311 /* rate tolerance method */
312 typedef enum
313 {
314 X265_RC_ABR,
315 X265_RC_CQP,
316 X265_RC_CRF
317 } X265_RC_METHODS;
318
319 /* Output statistics from encoder */
320 typedef struct x265_stats
321 {
322 double globalPsnrY;
323 double globalPsnrU;
324 double globalPsnrV;
325 double globalPsnr;
326 double globalSsim;
327 double elapsedEncodeTime; /* wall time since encoder was opened */
328 double elapsedVideoTime; /* encoded picture count / frame rate */
329 double bitrate; /* accBits / elapsed video time */
330 uint32_t encodedPictureCount; /* number of output pictures thus far */
331 uint32_t totalWPFrames; /* number of uni-directional weighted frames used */
332 uint64_t accBits; /* total bits output thus far */
333
334 /* new statistic member variables must be added below this line */
335 } x265_stats;
336
337 /* String values accepted by x265_param_parse() (and CLI) for various parameters */
338 static const char * const x265_motion_est_names[] = { "dia", "hex", "umh", "star", "full", 0 };
339 static const char * const x265_source_csp_names[] = { "i400", "i420", "i422", "i444", "nv12", "nv16", 0 };
340 static const char * const x265_video_format_names[] = { "component", "pal", "ntsc", "secam", "mac", "undef", 0 };
341 static const char * const x265_fullrange_names[] = { "limited", "full", 0 };
342 static const char * const x265_colorprim_names[] = { "", "bt709", "undef", "", "bt470m", "bt470bg", "smpte170m", "smpte240m", "film", "bt2020", 0 };
343 static const char * const x265_transfer_names[] = { "", "bt709", "undef", "", "bt470m", "bt470bg", "smpte170m", "smpte240m", "linear", "log100",
344 "log316", "iec61966-2-4", "bt1361e", "iec61966-2-1", "bt2020-10", "bt2020-12", 0 };
345 static const char * const x265_colmatrix_names[] = { "GBR", "bt709", "undef", "", "fcc", "bt470bg", "smpte170m", "smpte240m",
346 "YCgCo", "bt2020nc", "bt2020c", 0 };
347 static const char * const x265_sar_names[] = { "undef", "1:1", "12:11", "10:11", "16:11", "40:33", "24:11", "20:11",
348 "32:11", "80:33", "18:11", "15:11", "64:33", "160:99", "4:3", "3:2", "2:1", 0 };
349 static const char * const x265_interlace_names[] = { "prog", "tff", "bff", 0 };
350 static const char * const x265_analysis_names[] = { "off", "save", "load", 0 };
351
352 /* x265 input parameters
353 *
354 * For version safety you may use x265_param_alloc/free() to manage the
355 * allocation of x265_param instances, and x265_param_parse() to assign values
356 * by name. By never dereferencing param fields in your own code you can treat
357 * x265_param as an opaque data structure */
358 typedef struct x265_param
359 {
360 /*== Encoder Environment ==*/
361
362 /* x265_param_default() will auto-detect this cpu capability bitmap. it is
363 * recommended to not change this value unless you know the cpu detection is
364 * somehow flawed on your target hardware. The asm function tables are
365 * process global, the first encoder configures them for all encoders */
366 int cpuid;
367
368 /* Enable wavefront parallel processing, greatly increases parallelism for
369 * less than 1% compression efficiency loss */
370 int bEnableWavefront;
371
372 /* Number of threads to allocate for the process global thread pool, if no
373 * thread pool has yet been created. 0 implies auto-detection. By default
374 * x265 will try to allocate one worker thread per CPU core */
375 int poolNumThreads;
376
377 /* Number of concurrently encoded frames, 0 implies auto-detection. By
378 * default x265 will use a number of frame threads emperically determined to
379 * be optimal for your CPU core count, between 2 and 6. Using more than one
380 * frame thread causes motion search in the down direction to be clamped but
381 * otherwise encode behavior is unaffected. With CQP rate control the output
382 * bitstream is deterministic for all values of frameNumThreads greater than
383 * 1. All other forms of rate-control can be negatively impacted by
384 * increases to the number of frame threads because the extra concurrency
385 * adds uncertainty to the bitrate estimations. There is no limit to the
386 * number of frame threads you use for each encoder, but frame parallelism
387 * is generally limited by the the number of CU rows */
388 int frameNumThreads;
389
390 /* Use multiple threads to measure CU mode costs. Recommended for many core
391 * CPUs. On RD levels less than 5, it may not offload enough work to warrant
392 * the overhead. It is useful with the slow preset since it has the
393 * rectangular predictions enabled. At RD level 5 and 6 (preset slower and
394 * below), this feature should be an unambiguous win if you have CPU
395 * cores available for work. Default disabled */
396 int bDistributeModeAnalysis;
397
398 /* Use multiple threads to perform motion estimation to (ME to one reference
399 * per thread). Recommended for many core CPUs. The more references the more
400 * motion searches there will be to distribute. This option is often not a
401 * win, particularly in video sequences with low motion. Default disabled */
402 int bDistributeMotionEstimation;
403
404 /* The level of logging detail emitted by the encoder. X265_LOG_NONE to
405 * X265_LOG_FULL, default is X265_LOG_INFO */
406 int logLevel;
407
408 /* Enable analysis and logging distribution of Cus encoded across various
409 * modes during mode decision. Default disabled */
410 int bLogCuStats;
411
412 /* Enable the measurement and reporting of PSNR. Default is enabled */
413 int bEnablePsnr;
414
415 /* Enable the measurement and reporting of SSIM. Default is disabled */
416 int bEnableSsim;
417
418 /* filename of CSV log. If logLevel is X265_LOG_DEBUG, the encoder will emit
419 * per-slice statistics to this log file in encode order. Otherwise the
420 * encoder will emit per-stream statistics into the log file when
421 * x265_encoder_log is called (presumably at the end of the encode) */
422 const char *csvfn;
423
424 /* Enable the generation of SEI messages for each encoded frame containing
425 * the hashes of the three reconstructed picture planes. Most decoders will
426 * validate those hashes against the reconstructed images it generates and
427 * report any mismatches. This is essentially a debugging feature. Hash
428 * types are MD5(1), CRC(2), Checksum(3). Default is 0, none */
429 int decodedPictureHashSEI;
430
431 /*== Internal Picture Specification ==*/
432
433 /* Internal encoder bit depth. If x265 was compiled to use 8bit pixels
434 * (HIGH_BIT_DEPTH=0), this field must be 8, else this field must be 10.
435 * Future builds may support 12bit pixels. */
436 int internalBitDepth;
437
438 /* Color space of internal pictures. Only X265_CSP_I420 and X265_CSP_I444
439 * are supported. Eventually, i422 will also be supported as an internal
440 * color space and other packed formats will be supported in
441 * x265_picture.colorSpace */
442 int internalCsp;
443
444 /* Numerator and denominator of frame rate */
445 uint32_t fpsNum;
446 uint32_t fpsDenom;
447
448 /* Width (in pixels) of the source pictures. If this width is not an even
449 * multiple of 4, the encoder will pad the pictures internally to meet this
450 * minimum requirement. All valid HEVC widths are supported */
451 int sourceWidth;
452
453 /* Height (in pixels) of the source pictures. If this height is not an even
454 * multiple of 4, the encoder will pad the pictures internally to meet this
455 * minimum requirement. All valid HEVC heights are supported */
456 int sourceHeight;
457
458 /* Minimum decoder requirement level. Defaults to 0, which implies auto-
459 * detection by the encoder. If specified, the encoder will attempt to bring
460 * the encode specifications within that specified level. If the encoder is
461 * unable to reach the level it issues a warning and emits the actual
462 * decoder requirement. If the requested requirement level is higher than
463 * the actual level, the actual requirement level is signaled. The value is
464 * an specified as an integer with the level times 10, for example level
465 * "5.1" is specified as 51, and level "5.0" is specified as 50. */
466 int levelIdc;
467
468 /* if levelIdc is specified (non-zero) this flag will differentiate between
469 * Main (0) and High (1) tier. Default is Main tier (0) */
470 int bHighTier;
471
472 /* Interlace type of source pictures. 0 - progressive pictures (default).
473 * 1 - top field first, 2 - bottom field first. HEVC encodes interlaced
474 * content as fields, they must be provided to the encoder in the correct
475 * temporal order. EXPERIMENTAL */
476 int interlaceMode;
477
478 /* Flag indicating whether VPS, SPS and PPS headers should be output with
479 * each keyframe. Default false */
480 int bRepeatHeaders;
481
482 /* Flag indicating whether the encoder should emit an Access Unit Delimiter
483 * NAL at the start of every access unit. Default false */
484 int bEnableAccessUnitDelimiters;
485
486 /* Enables the buffering period SEI and picture timing SEI to signal the HRD
487 * parameteres. Default is disabled */
488 int bEmitHRDSEI;
489
490 /* Enables the emission of a user data SEI with the stream headers which
491 * describes the encoder version, build info, and parameters. This is
492 * very helpful for debugging, but may interfere with regression tests.
493 * Default enabled */
494 int bEmitInfoSEI;
495
496 /*== Coding Unit (CU) definitions ==*/
497
498 /* Maxiumum CU width and height in pixels. The size must be 64, 32, or 16.
499 * The higher the size, the more efficiently x265 can encode areas of low
500 * complexity, greatly improving compression efficiency at large
501 * resolutions. The smaller the size, the more effective wavefront and
502 * frame parallelism will become because of the increase in rows. default 64 */
503 uint32_t maxCUSize;
504
505 /* The additional depth the residual quadtree is allowed to recurse beyond
506 * the coding quadtree, for inter coded blocks. This must be between 1 and
507 * 3. The higher the value the more efficiently the residual can be
508 * compressed by the DCT transforms, at the expense of much more compute */
509 uint32_t tuQTMaxInterDepth;
510
511 /* The additional depth the residual quadtree is allowed to recurse beyond
512 * the coding quadtree, for intra coded blocks. This must be between 1 and
513 * 3. The higher the value the more efficiently the residual can be
514 * compressed by the DCT transforms, at the expense of much more compute */
515 uint32_t tuQTMaxIntraDepth;
516
517 /*== GOP Structure and Lokoahead ==*/
518
519 /* Enable open GOP - meaning I slices are not necessariy IDR and thus frames
520 * encoded after an I slice may reference frames encoded prior to the I
521 * frame which have remained in the decoded picture buffer. Open GOP
522 * generally has better compression efficiency and negligable encoder
523 * performance impact, but the use case may preclude it. Default true */
524 int bOpenGOP;
525
526 /* Scenecuts closer together than this are coded as I, not IDR. */
527 int keyframeMin;
528
529 /* Maximum keyframe distance or intra period in number of frames. If 0 or 1,
530 * all frames are I frames. A negative value is casted to MAX_INT internally
531 * which effectively makes frame 0 the only I frame. Default is 250 */
532 int keyframeMax;
533
534 /* The maximum number of L0 references a P or B slice may use. This
535 * influences the size of the decoded picture buffer. The higher this
536 * number, the more reference frames there will be available for motion
537 * search, improving compression efficiency of most video at a cost of
538 * performance. Value must be between 1 and 16, default is 3 */
539 int maxNumReferences;
540
541 /* Sets the operating mode of the lookahead. With b-adapt 0, the GOP
542 * structure is fixed based on the values of keyframeMax and bframes.
543 * With b-adapt 1 a light lookahead is used to chose B frame placement.
544 * With b-adapt 2 (trellis) a viterbi B path selection is performed */
545 int bFrameAdaptive;
546
547 /* Maximum consecutive B frames that can be emitted by the lookehead. When
548 * b-adapt is 0 and keyframMax is greater than bframes, the lookahead emits
549 * a fixed pattern of `bframes` B frames between each P. With b-adapt 1 the
550 * lookahead ignores the value of bframes for the most part. With b-adapt 2
551 * the value of bframes determines the search (POC) distance performeed in
552 * both directions, quadradically increasing the compute load of the
553 * lookahead. The higher the value, the more B frames the lookahead may
554 * possibly use consecutively, usually improving compression. Default is 3,
555 * maximum is 16 */
556 int bframes;
557
558 /* Total Number of frames to be encoded, caclulated from the user input
559 * (--frames) and (--seek). In case, the input is read from a pipe, this can
560 * remain as 0. It is later used in 2 pass RateControl, hence storing the
561 * value in param */
562 int totalFrames;
563
564 /* When enabled, the encoder will use the B frame in the middle of each
565 * mini-GOP larger than 2 B frames as a motion reference for the surrounding
566 * B frames. This improves compression efficiency for a small performance
567 * penalty. Referenced B frames are treated somewhere between a B and a P
568 * frame by rate control. Default is enabled. */
569 int bBPyramid;
570
571 /* The number of frames that must be queued in the lookahead before it may
572 * make slice decisions. Increasing this value directly increases the encode
573 * latency. The longer the queue the more optimally the lookahead may make
574 * slice decisions, particularly with b-adapt 2. When mb-tree is enabled,
575 * the length of the queue linearly increases the effectiveness of the
576 * mb-tree analysis. Default is 40 frames, maximum is 250 */
577 int lookaheadDepth;
578
579 /* A value which is added to the cost estimate of B frames in the lookahead.
580 * It may be a positive value (making B frames appear more expensive, which
581 * causes the lookahead to chose more P frames) or negative, which makes the
582 * lookahead chose more B frames. Default is 0, there are no limits */
583 int bFrameBias;
584
585 /* An arbitrary threshold which determines how agressively the lookahead
586 * should detect scene cuts. The default (40) is recommended. */
587 int scenecutThreshold;
588
589 /*== Intra Coding Tools ==*/
590
591 /* Enable constrained intra prediction. This causes intra prediction to
592 * input samples that were inter predicted. For some use cases this is
593 * believed to me more robust to stream errors, but it has a compression
594 * penalty on P and (particularly) B slices. Defaults to diabled */
595 int bEnableConstrainedIntra;
596
597 /* Enable strong intra smoothing for 32x32 blocks where the reference
598 * samples are flat. It may or may not improve compression efficiency,
599 * depending on your source material. Defaults to disabled */
600 int bEnableStrongIntraSmoothing;
601
602 /* Use a faster search method to find the best intra mode. Default is 0 */
603 int bEnableFastIntra;
604
605 /*== Inter Coding Tools ==*/
606
607 /* ME search method (DIA, HEX, UMH, STAR, FULL). The search patterns
608 * (methods) are sorted in increasing complexity, with diamond being the
609 * simplest and fastest and full being the slowest. DIA, HEX, and UMH were
610 * adapted from x264 directly. STAR is an adaption of the HEVC reference
611 * encoder's three step search, while full is a naive exhaustive search. The
612 * default is the star search, it has a good balance of performance and
613 * compression efficiecy */
614 int searchMethod;
615
616 /* A value between 0 and X265_MAX_SUBPEL_LEVEL which adjusts the amount of
617 * effort performed during subpel refine. Default is 5 */
618 int subpelRefine;
619
620 /* The maximum distance from the motion prediction that the full pel motion
621 * search is allowed to progress before terminating. This value can have an
622 * effect on frame parallelism, as referenced frames must be at least this
623 * many rows of reconstructed pixels ahead of the referencee at all times.
624 * (When considering reference lag, the motion prediction must be ignored
625 * because it cannot be known ahead of time). Default is 60, which is the
626 * default max CU size (64) minus the luma HPEL half-filter length (4). If a
627 * smaller CU size is used, the search range should be similarly reduced */
628 int searchRange;
629
630 /* The maximum number of merge candidates that are considered during inter
631 * analysis. This number (between 1 and 5) is signaled in the stream
632 * headers and determines the number of bits required to signal a merge so
633 * it can have significant trade-offs. The smaller this number the higher
634 * the performance but the less compression efficiency. Default is 3 */
635 uint32_t maxNumMergeCand;
636
637 /* Disable availability of temporal motion vector for AMVP */
638 int bEnableTemporalMvp;
639
640 /* Enable weighted prediction in P slices. This enables weighting analysis
641 * in the lookahead, which influences slice decisions, and enables weighting
642 * analysis in the main encoder which allows P reference samples to have a
643 * weight function applied to them prior to using them for motion
644 * compensation. In video which has lighting changes, it can give a large
645 * improvement in compression efficiency. Default is enabled */
646 int bEnableWeightedPred;
647
648 /* Enable weighted prediction in B slices. Default is disabled */
649 int bEnableWeightedBiPred;
650
651 /*== Analysis tools ==*/
652
653 /* Enable asymmetrical motion predictions. At CU depths 64, 32, and 16, it
654 * is possible to use 25%/75% split partitions in the up, down, right, left
655 * directions. For some material this can improve compression efficiency at
656 * the cost of extra analysis. bEnableRectInter must be enabled for this
657 * feature to be used. Default enabled */
658 int bEnableAMP;
659
660 /* Enable rectangular motion prediction partitions (vertical and
661 * horizontal), available at all CU depths from 64x64 to 8x8. Default is
662 * enabled */
663 int bEnableRectInter;
664
665 /* Enable the use of `coded block flags` (flags set to true when a residual
666 * has been coded for a given block) to avoid intra analysis in likely skip
667 * blocks. Default is disabled */
668 int bEnableCbfFastMode;
669
670 /* Enable early skip decisions to avoid intra and inter analysis in likely
671 * skip blocks. Default is disabled */
672 int bEnableEarlySkip;
673
674 /* Apply an optional penalty to the estimated cost of 32x32 intra blocks in
675 * non-intra slices. 0 is disabled, 1 enables a small penalty, and 2 enables
676 * a full penalty. This favors inter-coding and its low bitrate over
677 * potential increases in distortion, but usually improves performance.
678 * Default is 0 */
679 int rdPenalty;
680
681 /* A value betwen X265_NO_RDO_NO_RDOQ and X265_RDO_LEVEL which determines
682 * the level of rate distortion optimizations to perform during mode
683 * decisions and quantization. The more RDO the better the compression
684 * efficiency at a major cost of performance. Default is no RDO (0) */
685 int rdLevel;
686
687 /* Psycho-visual rate-distortion strength. Only has an effect in presets
688 * which use RDO. It makes mode decision favor options which preserve the
689 * energy of the source, at the cost of lost compression. The value must
690 * be between 0 and 2.0, 1.0 is typical. Default 0.0 */
691 double psyRd;
692
693 /* Quantization scaling lists. HEVC supports 6 quantization scaling lists to
694 * be defined; one each for Y, Cb, Cr for intra prediction and one each for
695 * inter prediction.
696 *
697 * - NULL and "off" will disable quant scaling (default)
698 * - "default" will enable the HEVC default scaling lists, which
699 * do not need to be signaled since they are specified
700 * - all other strings indicate a filename containing custom scaling lists
701 * in the HM format. The encode will fail if the file is not parsed
702 * correctly. Custom lists must be signaled in the SPS. */
703 const char *scalingLists;
704
705 /* Strength of psycho-visual optimizations in quantization. Only has an
706 * effect in presets which use RDOQ (rd-levels 4 and 5). The value must be
707 * between 0 and 50, 1.0 is typical. Default 0.0 */
708 double psyRdoq;
709
710 /* If X265_ANALYSIS_SAVE, write per-frame analysis information into analysis
711 * buffers. if X265_ANALYSIS_LOAD, read analysis information into analysis
712 * buffer and use this analysis information to reduce the amount of work
713 * the encoder must perform. Default X265_ANALYSIS_OFF */
714 int analysisMode;
715
716 /*== Coding tools ==*/
717
718 /* Enable the implicit signaling of the sign bit of the last coefficient of
719 * each transform unit. This saves one bit per TU at the expense of figuring
720 * out which coefficient can be toggled with the least distortion.
721 * Default is enabled */
722 int bEnableSignHiding;
723
724 /* Allow intra coded blocks to be encoded directly as residual without the
725 * DCT transform, when this improves efficiency. Checking whether the block
726 * will benefit from this option incurs a performance penalty. Default is
727 * enabled */
728 int bEnableTransformSkip;
729
730 /* Enable a faster determination of whether skippig the DCT transform will
731 * be beneficial. Slight performance gain for some compression loss. Default
732 * is enabled */
733 int bEnableTSkipFast;
734
735 /* Enable the deblocking loop filter, which improves visual quality by
736 * reducing blocking effects at block edges, particularly at lower bitrates
737 * or higher QP. When enabled it adds another CU row of reference lag,
738 * reducing frame parallelism effectiveness. Default is enabled */
739 int bEnableLoopFilter;
740
741 /* Enable the Sample Adaptive Offset loop filter, which reduces distortion
742 * effects by adjusting reconstructed sample values based on histogram
743 * analysis to better approximate the original samples. When enabled it adds
744 * a CU row of reference lag, reducing frame parallelism effectiveness.
745 * Default is enabled */
746 int bEnableSAO;
747
748 /* Note: when deblocking and SAO are both enabled, the loop filter CU lag is
749 * only one row, as they operate in series on the same row. */
750
751 /* Select the method in which SAO deals with deblocking boundary pixels. If
752 * disabled the right and bottom boundary areas are skipped. If enabled,
753 * non-deblocked pixels are used entirely. Default is disabled */
754 int bSaoNonDeblocked;
755
756 /* Generally a small signed integer which offsets the QP used to quantize
757 * the Cb chroma residual (delta from luma QP specified by rate-control).
758 * Default is 0, which is recommended */
759 int cbQpOffset;
760
761 /* Generally a small signed integer which offsets the QP used to quantize
762 * the Cr chroma residual (delta from luma QP specified by rate-control).
763 * Default is 0, which is recommended */
764 int crQpOffset;
765
766 /* Specify whether to attempt to encode intra modes in B frames. By default
767 * enabled, but only applicable for the presets which use rdLevel 5 or 6
768 * (veryslow and placebo). All other presets will not try intra in B frames
769 * regardless of this setting. */
770 int bIntraInBFrames;
771
772 /* An integer value in range of 100 to 1000, which denotes strength of noise
773 * reduction */
774 int noiseReduction;
775
776 /* The lossless flag enables true lossless coding, by bypassing scaling,
777 * transform, quantization and in-loop filter processes. This is used for
778 * ultra-high bitrates with zero loss of quality. */
779 int bLossless;
780
781 /* The CU Lossless flag, when enabled, compares the rate-distortion costs
782 * for normal and lossless encoding, and chooses the best mode for each CU.
783 * If lossless mode is chosen, the cu-transquant-bypass flag is set for that
784 * CU. */
785 int bCULossless;
786
787 /*== Rate Control ==*/
788
789 struct
790 {
791 /* Explicit mode of rate-control, necessary for API users. It must
792 * be one of the X265_RC_METHODS enum values. */
793 int rateControlMode;
794
795 /* Base QP to use for Constant QP rate control. Adaptive QP may alter
796 * the QP used for each block. If a QP is specified on the command line
797 * CQP rate control is implied. Default: 32 */
798 int qp;
799
800 /* target bitrate for Average BitRate (ABR) rate control. If a non- zero
801 * bitrate is specified on the command line, ABR is implied. Default 0 */
802 int bitrate;
803
804 /* The degree of rate fluctuation that x265 tolerates. Rate tolerance is used
805 * alongwith overflow (difference between actual and target bitrate), to adjust
806 * qp. Default is 1.0 */
807 double rateTolerance;
808
809 /* qComp sets the quantizer curve compression factor. It weights the frame
810 * quantizer based on the complexity of residual (measured by lookahead).
811 * Default value is 0.6. Increasing it to 1 will effectively generate CQP */
812 double qCompress;
813
814 /* QP offset between I/P and P/B frames. Default ipfactor: 1.4
815 * Default pbFactor: 1.3 */
816 double ipFactor;
817 double pbFactor;
818
819 /* Max QP difference between frames. Default: 4 */
820 int qpStep;
821
822 /* Ratefactor constant: targets a certain constant "quality".
823 * Acceptable values between 0 and 51. Default value: 28 */
824 double rfConstant;
825
826 /* Enable adaptive quantization. This mode distributes available bits between all
827 * macroblocks of a frame, assigning more bits to low complexity areas. Turning
828 * this ON will usually affect PSNR negatively, however SSIM and visual quality
829 * generally improves. Default: X265_AQ_AUTO_VARIANCE */
830 int aqMode;
831
832 /* Sets the strength of AQ bias towards low detail macroblocks. Valid only if
833 * AQ is enabled. Default value: 1.0. Acceptable values between 0.0 and 3.0 */
834 double aqStrength;
835
836 /* Sets the maximum rate the VBV buffer should be assumed to refill at
837 * Default is zero */
838 int vbvMaxBitrate;
839
840 /* Sets the size of the VBV buffer in kilobits. Default is zero */
841 int vbvBufferSize;
842
843 /* Sets how full the VBV buffer must be before playback starts. If it is less than
844 * 1, then the initial fill is vbv-init * vbvBufferSize. Otherwise, it is
845 * interpreted as the initial fill in kbits. Default is 0.9 */
846 double vbvBufferInit;
847
848 /* Enable CUTree ratecontrol. This keeps track of the CUs that propagate temporally
849 * across frames and assigns more bits to these CUs. Improves encode efficiency.
850 * Default: enabled */
851 int cuTree;
852
853 /* In CRF mode, maximum CRF as caused by VBV. 0 implies no limit */
854 double rfConstantMax;
855
856 /* In CRF mode, minimum CRF as caused by VBV */
857 double rfConstantMin;
858
859 /* Two pass (INCOMPLETE) */
860 /* Enable writing the stats in a multipass encode to the stat output file */
861 int bStatWrite;
862
863 /* Enable loading data from the stat input file in a multi pass encode */
864 int bStatRead;
865
866 /* Filename of the 2pass output/input stats file */
867 char* statFileName;
868
869 /* temporally blur quants */
870 double qblur;
871
872 /* temporally blur complexity */
873 double complexityBlur;
874
875 /* Enable slow and a more detailed first pass encode in multi pass rate control */
876 int bEnableSlowFirstPass;
877
878 /* specify a text file which contains MAX_MAX_QP + 1 floating point
879 * values to be copied into x265_lambda_tab and a second set of
880 * MAX_MAX_QP + 1 floating point values for x265_lambda2_tab. All values
881 * are separated by comma, space or newline. Text after a hash (#) is
882 * ignored. The lambda tables are process-global, so these new lambda
883 * values will affect all encoders in the same process */
884 const char* lambdaFileName;
885 } rc;
886
887 /*== Video Usability Information ==*/
888 struct
889 {
890 /* Aspect ratio idc to be added to the VUI. The default is 0 indicating
891 * the apsect ratio is unspecified. If set to X265_EXTENDED_SAR then
892 * sarWidth and sarHeight must also be set */
893 int aspectRatioIdc;
894
895 /* Sample Aspect Ratio width in arbitrary units to be added to the VUI
896 * only if aspectRatioIdc is set to X265_EXTENDED_SAR. This is the width
897 * of an individual pixel. If this is set then sarHeight must also be set */
898 int sarWidth;
899
900 /* Sample Aspect Ratio height in arbitrary units to be added to the VUI.
901 * only if aspectRatioIdc is set to X265_EXTENDED_SAR. This is the width
902 * of an individual pixel. If this is set then sarWidth must also be set */
903 int sarHeight;
904
905 /* Enable overscan info present flag in the VUI. If this is set then
906 * bEnabledOverscanAppropriateFlag will be added to the VUI. The default
907 * is false */
908 int bEnableOverscanInfoPresentFlag;
909
910 /* Enable overscan appropriate flag. The status of this flag is added
911 * to the VUI only if bEnableOverscanInfoPresentFlag is set. If this
912 * flag is set then cropped decoded pictures may be output for display.
913 * The default is false */
914 int bEnableOverscanAppropriateFlag;
915
916 /* Video signal type present flag of the VUI. If this is set then
917 * videoFormat, bEnableVideoFullRangeFlag and
918 * bEnableColorDescriptionPresentFlag will be added to the VUI. The
919 * default is false */
920 int bEnableVideoSignalTypePresentFlag;
921
922 /* Video format of the source video. 0 = component, 1 = PAL, 2 = NTSC,
923 * 3 = SECAM, 4 = MAC, 5 = unspecified video format is the default */
924 int videoFormat;
925
926 /* Video full range flag indicates the black level and range of the luma
927 * and chroma signals as derived from E′Y, E′PB, and E′PR or E′R, E′G,
928 * and E′B real-valued component signals. The default is false */
929 int bEnableVideoFullRangeFlag;
930
931 /* Color description present flag in the VUI. If this is set then
932 * color_primaries, transfer_characteristics and matrix_coeffs are to be
933 * added to the VUI. The default is false */
934 int bEnableColorDescriptionPresentFlag;
935
936 /* Color primaries holds the chromacity coordinates of the source
937 * primaries. The default is 2 */
938 int colorPrimaries;
939
940 /* Transfer characteristics indicates the opto-electronic transfer
941 * characteristic of the source picture. The default is 2 */
942 int transferCharacteristics;
943
944 /* Matrix coefficients used to derive the luma and chroma signals from
945 * the red, blue and green primaries. The default is 2 */
946 int matrixCoeffs;
947
948 /* Chroma location info present flag adds chroma_sample_loc_type_top_field and
949 * chroma_sample_loc_type_bottom_field to the VUI. The default is false */
950 int bEnableChromaLocInfoPresentFlag;
951
952 /* Chroma sample location type top field holds the chroma location in
953 * the top field. The default is 0 */
954 int chromaSampleLocTypeTopField;
955
956 /* Chroma sample location type bottom field holds the chroma location in
957 * the bottom field. The default is 0 */
958 int chromaSampleLocTypeBottomField;
959
960 /* Default display window flag adds def_disp_win_left_offset,
961 * def_disp_win_right_offset, def_disp_win_top_offset and
962 * def_disp_win_bottom_offset to the VUI. The default is false */
963 int bEnableDefaultDisplayWindowFlag;
964
965 /* Default display window left offset holds the left offset with the
966 * conformance cropping window to further crop the displayed window */
967 int defDispWinLeftOffset;
968
969 /* Default display window right offset holds the right offset with the
970 * conformance cropping window to further crop the displayed window */
971 int defDispWinRightOffset;
972
973 /* Default display window top offset holds the top offset with the
974 * conformance cropping window to further crop the displayed window */
975 int defDispWinTopOffset;
976
977 /* Default display window bottom offset holds the bottom offset with the
978 * conformance cropping window to further crop the displayed window */
979 int defDispWinBottomOffset;
980 } vui;
981 } x265_param;
982
983 /***
984 * If not called, first encoder allocated will auto-detect the CPU and
985 * initialize performance primitives, which are process global.
986 * DEPRECATED: use x265_param.cpuid to specify CPU */
987 void x265_setup_primitives(x265_param *param, int cpu);
988
989 /* x265_param_alloc:
990 * Allocates an x265_param instance. The returned param structure is not
991 * special in any way, but using this method together with x265_param_free()
992 * and x265_param_parse() to set values by name allows the application to treat
993 * x265_param as an opaque data struct for version safety */
994 x265_param *x265_param_alloc();
995
996 /* x265_param_free:
997 * Use x265_param_free() to release storage for an x265_param instance
998 * allocated by x265_param_alloc() */
999 void x265_param_free(x265_param *);
1000
1001 /***
1002 * Initialize an x265_param structure to default values
1003 */
1004 void x265_param_default(x265_param *param);
1005
1006 /* x265_param_parse:
1007 * set one parameter by name.
1008 * returns 0 on success, or returns one of the following errors.
1009 * note: BAD_VALUE occurs only if it can't even parse the value,
1010 * numerical range is not checked until x265_encoder_open().
1011 * value=NULL means "true" for boolean options, but is a BAD_VALUE for non-booleans. */
1012 #define X265_PARAM_BAD_NAME (-1)
1013 #define X265_PARAM_BAD_VALUE (-2)
1014 int x265_param_parse(x265_param *p, const char *name, const char *value);
1015
1016 /* x265_param_apply_profile:
1017 * Applies the restrictions of the given profile. (one of below) */
1018 static const char * const x265_profile_names[] = { "main", "main10", "mainstillpicture", 0 };
1019
1020 /* (can be NULL, in which case the function will do nothing)
1021 * returns 0 on success, negative on failure (e.g. invalid profile name). */
1022 int x265_param_apply_profile(x265_param *, const char *profile);
1023
1024 /* x265_param_default_preset:
1025 * The same as x265_param_default, but also use the passed preset and tune
1026 * to modify the default settings.
1027 * (either can be NULL, which implies no preset or no tune, respectively)
1028 *
1029 * Currently available presets are, ordered from fastest to slowest: */
1030 static const char * const x265_preset_names[] = { "ultrafast", "superfast", "veryfast", "faster", "fast", "medium", "slow", "slower", "veryslow", "placebo", 0 };
1031
1032 /* The presets can also be indexed numerically, as in:
1033 * x265_param_default_preset( &param, "3", ... )
1034 * with ultrafast mapping to "0" and placebo mapping to "9". This mapping may
1035 * of course change if new presets are added in between, but will always be
1036 * ordered from fastest to slowest.
1037 *
1038 * Warning: the speed of these presets scales dramatically. Ultrafast is a full
1039 * 100 times faster than placebo!
1040 *
1041 * Currently available tunings are: */
1042 static const char * const x265_tune_names[] = { "psnr", "ssim", "zerolatency", "fastdecode", 0 };
1043
1044 /* returns 0 on success, negative on failure (e.g. invalid preset/tune name). */
1045 int x265_param_default_preset(x265_param *, const char *preset, const char *tune);
1046
1047 /* x265_picture_alloc:
1048 * Allocates an x265_picture instance. The returned picture structure is not
1049 * special in any way, but using this method together with x265_picture_free()
1050 * and x265_picture_init() allows some version safety. New picture fields will
1051 * always be added to the end of x265_picture */
1052 x265_picture *x265_picture_alloc();
1053
1054 /* x265_picture_free:
1055 * Use x265_picture_free() to release storage for an x265_picture instance
1056 * allocated by x265_picture_alloc() */
1057 void x265_picture_free(x265_picture *);
1058
1059 /* x265_alloc_analysis_data:
1060 * Allocate memory to hold analysis data, returns 0 on success else negative */
1061 int x265_alloc_analysis_data(x265_picture*);
1062
1063 /* x265_free_analysis_data:
1064 * Use x265_free_analysis_data to release storage of members allocated by
1065 * x265_alloc_analysis_data */
1066 void x265_free_analysis_data(x265_picture*);
1067
1068 /***
1069 * Initialize an x265_picture structure to default values. It sets the pixel
1070 * depth and color space to the encoder's internal values and sets the slice
1071 * type to auto - so the lookahead will determine slice type.
1072 */
1073 void x265_picture_init(x265_param *param, x265_picture *pic);
1074
1075 /* x265_max_bit_depth:
1076 * Specifies the maximum number of bits per pixel that x265 can input. This
1077 * is also the max bit depth that x265 encodes in. When x265_max_bit_depth
1078 * is 8, the internal and input bit depths must be 8. When
1079 * x265_max_bit_depth is 12, the internal and input bit depths can be
1080 * either 8, 10, or 12. Note that the internal bit depth must be the same
1081 * for all encoders allocated in the same process. */
1082 X265_API extern const int x265_max_bit_depth;
1083
1084 /* x265_version_str:
1085 * A static string containing the version of this compiled x265 library */
1086 X265_API extern const char *x265_version_str;
1087
1088 /* x265_build_info:
1089 * A static string describing the compiler and target architecture */
1090 X265_API extern const char *x265_build_info_str;
1091
1092 /* Force a link error in the case of linking against an incompatible API version.
1093 * Glue #defines exist to force correct macro expansion; the final output of the macro
1094 * is x265_encoder_open_##X265_BUILD (for purposes of dlopen). */
1095 #define x265_encoder_glue1(x, y) x ## y
1096 #define x265_encoder_glue2(x, y) x265_encoder_glue1(x, y)
1097 #define x265_encoder_open x265_encoder_glue2(x265_encoder_open_, X265_BUILD)
1098
1099 /* x265_encoder_open:
1100 * create a new encoder handler, all parameters from x265_param are copied */
1101 x265_encoder* x265_encoder_open(x265_param *);
1102
1103 /* x265_encoder_parameters:
1104 * copies the current internal set of parameters to the pointer provided
1105 * by the caller. useful when the calling application needs to know
1106 * how x265_encoder_open has changed the parameters.
1107 * note that the data accessible through pointers in the returned param struct
1108 * (e.g. filenames) should not be modified by the calling application. */
1109 void x265_encoder_parameters(x265_encoder *, x265_param *);
1110
1111 /* x265_encoder_headers:
1112 * return the SPS and PPS that will be used for the whole stream.
1113 * *pi_nal is the number of NAL units outputted in pp_nal.
1114 * returns negative on error, total byte size of payload data on success
1115 * the payloads of all output NALs are guaranteed to be sequential in memory. */
1116 int x265_encoder_headers(x265_encoder *, x265_nal **pp_nal, uint32_t *pi_nal);
1117
1118 /* x265_encoder_encode:
1119 * encode one picture.
1120 * *pi_nal is the number of NAL units outputted in pp_nal.
1121 * returns negative on error, 1 if a picture and access unit were output,
1122 * or zero if the encoder pipeline is still filling or is empty after flushing.
1123 * the payloads of all output NALs are guaranteed to be sequential in memory.
1124 * To flush the encoder and retrieve delayed output pictures, pass pic_in as NULL.
1125 * Once flushing has begun, all subsequent calls must pass pic_in as NULL. */
1126 int x265_encoder_encode(x265_encoder *encoder, x265_nal **pp_nal, uint32_t *pi_nal, x265_picture *pic_in, x265_picture *pic_out);
1127
1128 /* x265_encoder_get_stats:
1129 * returns encoder statistics */
1130 void x265_encoder_get_stats(x265_encoder *encoder, x265_stats *, uint32_t statsSizeBytes);
1131
1132 /* x265_encoder_log:
1133 * write a line to the configured CSV file. If a CSV filename was not
1134 * configured, or file open failed, or the log level indicated frame level
1135 * logging, this function will perform no write. */
1136 void x265_encoder_log(x265_encoder *encoder, int argc, char **argv);
1137
1138 /* x265_encoder_close:
1139 * close an encoder handler */
1140 void x265_encoder_close(x265_encoder *);
1141
1142 /***
1143 * Release library static allocations
1144 */
1145 void x265_cleanup(void);
1146
1147 #ifdef __cplusplus
1148 }
1149 #endif
1150
1151 #endif // X265_H