x265 16-bit

From wiki.selur.net
Jump to navigation Jump to search

x265 16-bit is a separate, old build of the HEVC/H.265 encoder x265 (version 1.6) that is compiled for 16-bit sample precision (it reports itself as 16bpp) and is fed with 16-bit video. It is kept next to the current x265 for the rare case that this old high bit depth build is wanted. It is an optional encoder that has to be switched on first, and it only knows the options x265 had in 2015. For normal HEVC encoding use x265.

Base → Video: 16bit-x265, then the 16bit-x265 tab

What it does

Like every HEVC encoder it splits the picture into coding tree units of up to 64×64 pixels, divides these further into coding, prediction and transform units, predicts each block from other frames (motion estimation) or from its neighbours, and quantizes what is left. The rate control chooses the quantization from the encoding mode:

  • constant rate factor (CRF): constant perceived quality, the size results from the content.
  • 2-pass: a first pass analyses the video, the second distributes a given bit rate or file size over it.
  • average bitrate: one pass towards a bit rate.
  • constant quantizer: the same quantizer for all frames of a type; also the mode that offers lossless encoding.

The video is handed to the encoder with 16 bit per sample, so no precision is lost on the way into the encoder. No profile and no level are requested; the encoder reports the result as Main 10 profile with an internal bit depth of 10.

Requirements

  • The encoder only shows up in Hybrid when supportX26516bit=true is set in misc.ini (in Hybrid's settings folder); restart Hybrid afterwards.
  • The binary 16bit-x265 has to be present next to Hybrid's other tools.

Settings

The option column shows the x265 option a control ends up as. Level, Profile and In-Output bit-depth are shown but fixed for this build.

Main

16bit-x265 Main tab
16bit-x265 Main tab

General Settings

The controls below Encoding mode change with the mode.

Control x265 option Range / values Hybrid default Meaning
Encoding mode --crf, --qp, --bitrate, --pass average bitrate (1-pass), constant quantizer (1-pass), constant rate factor (1-pass), specific filesize/bitrate (2-pass), 2pass - 1st pass, 2pass - 2nd pass constant rate factor (1-pass) Rate control mode, see above. The two single-pass entries of 2-pass run only that pass, e.g. to repeat a second pass with an existing statistics file.
Constant rate factor --crf 0 – 51, step 0.01 28 Quality target of the CRF mode; lower is better and bigger. 28 is the encoder's own default.
Quantization strength --qp 0 – 51 32 Quantizer of the constant quantizer mode (for P-frames; I- and B-frames follow through the quant factors). Locked with Lossless on.
Lossless --lossless on/off off Lossless encoding (constant quantizer mode only): transform, quantization and loop filters are bypassed. Gives very large files. Locks the quantizer, the loop filter and the noise reduction.
Bitrate (kbit/s) --bitrate 16 – 800000 selected, 1500 Target bit rate of the average bitrate and 2-pass modes.
Target size (MiB), Target mode --bitrate 0.2 MiB and up; custom, 1/4 CD … 1 BD 50 not selected; 700, custom Aim at a file size instead (2-pass modes only); Hybrid computes the video bit rate from the size, the length and the size of audio and other streams. Target mode offers common media sizes.
Min/Max rate factor --crf-min, --crf-max 0 – 51 each, step 0.01 0 / 0 Lower and upper limit for the rate factor the rate control may use; 0 means no limit. Only available in the average bitrate mode.
CBR --strict-cbr on/off off Stricter bit rate control: the encoder keeps much closer to the target bit rate, also in short clips, at the cost of quality. Only available in the average bitrate mode.
Fast 1st pass --no-slow-firstpass / --slow-firstpass on/off on Lets the encoder run the first pass with reduced analysis, which is much faster and costs hardly any quality. Only for the 2-pass mode and the 1st-pass-only mode.

Loop Filter

Control x265 option Range / values Hybrid default Meaning
Loop Filter, strength / threshold --deblock=<tC>:<beta> / --no-deblock on/off; -6 – 6 each on, 0 / 0 The deblocking filter of HEVC and its two offsets. Negative values keep more detail, positive values smooth more. Switched off and locked with Lossless.
Sample Adaptive Offset --sao / --no-sao on/off on Second in-loop filter that corrects sample values after deblocking; reduces ringing and banding. Independent of the loop filter.
non-deblock --sao-non-deblock / --no-sao-non-deblock on/off off Lets the SAO analysis use pixels that are not deblocked yet instead of skipping the right and bottom edge of each block. Only with Sample Adaptive Offset on.

Restrictions

Control x265 option Range / values Hybrid default Meaning
Level --level-idc 1.0 – 6.2, unrestricted unrestricted HEVC level. Locked at unrestricted: no level is requested.
Profile --profile Main 10, Main 4:2:2 - 10bit, Main 4:4:4 - 10bit, None None HEVC profile. Locked at None: no profile is passed to the encoder.
Tier --high-tier / --no-high-tier Main, High Main Tier of the level. Written in every mode except constant quantizer; without a level it has no effect.
Preset --preset none, ultrafast … placebo none x265's speed presets. The arrow button first resets the controls to the encoder's defaults and then applies the preset; nothing changes before that. medium equals the encoder's defaults.
Tune --tune none, grain, psnr, ssim, fastdecode, zerolatency none Adjustment for a kind of content or a goal; also applied to the controls with its arrow button.

Frames

16bit-x265 Frames tab
16bit-x265 Frames tab

General Slice Decision

Control x265 option Range / values Hybrid default Meaning
Maximum number of reference frames --ref 1 – 16 3 How many earlier frames a frame may refer to. More helps mostly with animation and costs speed and decoder memory.
Weighted P-frame prediction --weightp / --no-weightp on/off on Weighted prediction for P-frames, which helps most in fades.
Scene change --scenecut / --no-scenecut on/off; 0 – 100 on, 40 How readily an I-frame is placed at a scene change. Higher reacts more eagerly.
Open GOP --open-gop / --no-open-gop on/off off Allows I-frames that are not IDR frames, so B-frames may refer across them. Saves a little, but some players and splitters seek badly in such streams. The encoder's own default is on.
Min/Max GOP size --min-keyint, --keyint 0 – 10000 each 0 / 250 Shortest and longest distance between IDR frames. Minimum 0 lets the encoder choose; maximum 0 is written as --keyint infinite. The maximum cannot be set below the minimum; a maximum of 1 locks the B-frame controls.

B-Frame Settings

Control x265 option Range / values Hybrid default Meaning
Maximum number of consecutive b-frames --bframes 0 – 16 4 Upper limit of B-frames in a row. With 0 the other B-frame controls are locked and not written.
Boost b-frame frequency --bframe-bias 0 – 1000 0 Makes the adaptive decision prefer B-frames.
Adaptive b-frame decision --b-adapt none, fast, trellis trellis How the encoder decides between P- and B-frames (0, 1, 2). none always uses the maximum, fast is a simple lookahead, trellis searches the best sequence and is slowest.
B-Pyramid --b-pyramid / --no-b-pyramid on/off on Lets B-frames be references for other B-frames. Only available with more than three B-frames, or with at least one and trellis.
Weighted b-frames --weightb / --no-weightb on/off off Weighted prediction for B-frames.

Spatial / Intra

Control x265 option Range / values Hybrid default Meaning
Tree unit non-I slice penalty --rdpenalty disabled, RD-penalty, maximum disabled Penalty for 32×32 intra transform units outside I-frames (0, 1, 2); makes the encoder prefer smaller ones there.
Transform skip, fast --tskip / --no-tskip, --tskip-fast / --no-tskip-fast on/off each off / off Allows 4×4 intra blocks to be coded without a transform, which helps with sharp synthetic content such as text. fast uses a quicker decision and is only available with transform skip on.
Constrained intra --constrained-intra / --no-constrained-intra on/off off Intra blocks use only intra coded neighbours for prediction; for error resilience.
Intra smoothing --strong-intra-smoothing / --no-strong-intra-smoothing on/off on Strong smoothing of the reference samples of 32×32 intra blocks; avoids visible steps in flat areas.
Interlace, field order --interlace tff/bff / --no-interlace on/off; same, tff, bff off, same Tells the encoder that the input consists of fields. same takes the field order of the video that reaches the encoder. The field order is only available with Interlace on.
Noise reduction (Intra/Inter) --nr-intra, --nr-inter 0 – 2000 each 0 / 0 Built-in noise reduction in the transform domain for intra and inter blocks. A denoising filter gives better results. Locked with Lossless.
Frame lookahead --rc-lookahead 0 – 256 20 Frames the frame type decision and the rate control look ahead. Hybrid keeps it between the number of B-frames + 1 (0 without B-frames) and the maximum GOP size.
Statistic file --stats file empty Statistics file of the 2-pass modes; empty uses a temporary file. Only available in the two single-pass entries of 2-pass.

Motion

16bit-x265 Motion tab
16bit-x265 Motion tab

Motion Estimation

Control x265 option Range / values Hybrid default Meaning
Motion estimation --me dia, hex, umh, star, full hex Motion search method (written as 0 – 4), from fastest to slowest. star is what the slow presets use; full is an exhaustive search.
Sub-Pixel precision --subme 0 – 7 2 Amount of sub-pixel refinement; higher levels run more half and quarter pixel iterations and compare with SATD.
Max pixel search range --merange 1 – 32768 57 Search range of the motion search in pixels.

Motion Partitioning

Control x265 option Range / values Hybrid default Meaning
rectangular --rect / --no-rect on/off off Also tests rectangular prediction blocks (2N×N and N×2N). Slower, slightly better compression.
asymmetric --amp / --no-amp on/off off Also tests asymmetric splits (a quarter and three quarters). Only available with rectangular on.
Max merge candidates --max-merge 1 – 5 2 How many neighbouring motion vectors are tested for merge mode. More costs time and saves a few bits.

Quantization

16bit-x265 Quantization tab
16bit-x265 Quantization tab

General Quantization

Control x265 option Range / values Hybrid default Meaning
Adaptive quantization --aq-mode none, normal, auto normal Shifts bits between flat and detailed areas inside a frame. normal is 1, auto is 2 (auto variance). Locked in constant quantizer mode.
Adaptive quantization strength --aq-strength 0 – 3, step 0.01 1 Strength of the adaptive quantization; 0 switches it off. Locked with Adaptive quantization none.
Coding unit tree for adaptive quantization --cutree / --no-cutree on/off on Gives blocks that many later frames refer to more bits (the counterpart of x264's macroblock tree). Locked with Adaptive quantization none.
Quantfactor I->P/P->B --ipratio, --pbratio 1 – 10 each 1.4 / 1.3 Quantizer ratio between I- and P-frames and between P- and B-frames.
Chroma offset (Cb/Cr) --cbqpoffs, --crqpoffs -12 – 12 each 0 / 0 Quantizer offset of the two chroma planes. Negative values give chroma more bits.
Quantizer step --qpstep 1 – 50 4 Largest quantizer change the rate control may make from one frame to the next.
Custom qp file --qpfile file empty File that forces frame types and quantizers for single frames. It replaces the qp file Hybrid creates for chapters.

QuadTree

Control x265 option Range / values Hybrid default Meaning
Wavefront Parallel Processing --wpp / --no-wpp on/off on Encodes the rows of a frame in parallel, each row a little behind the one above. Large speed gain for about 1 % compression.
cu lossless --cu-lossless / --no-cu-lossless on/off on Also tests for every coding unit whether coding it lossless is cheaper. Slow; the encoder's own default is off.
Coding Unit size (min/max) --min-cu-size, --ctu 8x8, 16x16, 32x32, 64x64; 16x16, 32x32, 64x64 8x8 / 64x64 Smallest and largest coding unit. A large maximum helps with high resolutions and flat areas but lowers parallelism; a larger minimum saves time and costs compression. The maximum cannot be below the minimum or above the frame size.
Quantization group size --qg-size on/off; 16, 32, 64 off Smallest block that may get its own quantizer. Only values between the minimum and maximum coding unit size are offered; without the option the encoder uses its default.
Max tree unit size --max-tu-size 4, 8, 16, 32 32 Largest transform block. Larger transforms compress smooth areas better and cost time.
Max intra/inter tree unit depth --tu-intra-depth, --tu-inter-depth 1 – 4 each 1 / 1 How many times the transform tree may be split further than the coding unit, for intra and inter blocks. More is slower and compresses a little better. The upper limit follows the maximum coding unit size (3 at 16x16, 4 at 32x32 and 64x64).
Early skip --early-skip / --no-early-skip on/off off Checks the skip candidates first and stops the analysis of a block when one of them leaves no residual. Faster, slightly worse.

Rate Control

16bit-x265 Rate Control tab
16bit-x265 Rate Control tab

Rate Distortion Optimization

Control x265 option Range / values Hybrid default Meaning
Rate Distortion Optimization --rd 0 – 6 3 How much of the mode decision is done by real rate-distortion measurement instead of estimates. Higher is slower and compresses better; 5 and 6 are the same.
Hide sign bit --signhide / --no-signhide on/off on Saves the sign of one coefficient per transform unit by implying it from the others.
RDO Quantization Level --rdoq-level / --no-rdoq-level 0 – 2 0 Rate-distortion optimized quantization: 0 off, 1 optimizes the coefficient levels, 2 also decides about whole coefficient groups.
Psy-RDO quantization --psy-rdoq / --no-psy-rdoq 0 – 50, step 0.01 15 Makes the optimized quantization keep more energy (detail, grain) instead of zeroing coefficients. High values raise the bit rate considerably. Only available with an RDO quantization level above 0.
B-frame intra --b-intra / --no-b-intra on/off on Allows intra blocks in B-frames. Only available and only written with RDO level 5 or 6.
Fast intra --fast-intra / --no-fast-intra on/off off Tests only a subset of the 33 intra directions and refines around the best one. Only available with RDO level 3 or lower.
Psycho-visual RDO --psy-rd 0 – 2, step 0.01 1 Psychovisual optimization of the mode decision that keeps detail and grain instead of maximizing PSNR; 0 switches it off. The encoder's own default is 0.3.
Curve compression --qcomp 0 – 1 0.6 0 gives a constant bit rate, 1 a constant quantizer.

In constant quantizer mode Hybrid leaves out adaptive quantization, the coding unit tree and curve compression; the RDO options, quant factors, chroma offsets, noise reduction and qp file options are written.

Video Buffer Verifier (VBV)

Control x265 option Range / values Hybrid default Meaning
Medium limit – on/off; unrestricted, UHD-BD, BD 25/50 - x2, BD 25/50 - x1, DVD/BD (5/9), CD off Sets the VBV values to what the read speed of the medium allows and locks the two fields below.
Buffer size (kbit) --vbv-bufsize 0 – 800000 0 Size of the decoder buffer; 0 means no VBV.
Max fillrate (kbit/s) --vbv-maxrate 0 – 800000 0 Highest rate at which the buffer is filled, i.e. the peak bit rate.
Initial load --vbv-init 0.1 – 100 0.9 Buffer fill at the start of playback.

The VBV options are not written in constant quantizer mode, and the group is locked there.

Zones,VUI

16bit-x265 Zones,VUI tab
16bit-x265 Zones,VUI tab

Zone Editor

A zone gives a range of frames its own treatment, e.g. fewer bits for the credits. Enter start and end frame, the value and the type, then add the zone to the list with the plus button; the arrow loads the selected zone back into the fields, minus removes it. Zones must not overlap. Hybrid passes the list as --zones.

Type x265 zone option Meaning of Mod/Quant
fixed quantizer q= Quantizer for the zone (0 – 51).
bitrate modificator b= Factor on the bit rate of the zone; 1.0 changes nothing.

Video Usability Information

The Video Usability Information describes how the decoded video is to be shown. It does not change the picture, only the flags in the stream. Each line has a check box that decides whether the flag is written at all.

Control x265 option Range / values Hybrid default Meaning
Overscan --overscan undef, show, crop off Whether the edge of the picture may be cut off by overscan.
Crop (left/top/right/bottom) --crop-rect 0 – 8192 each 0 Cropping rectangle that is written into the stream, so the decoder hides these pixels. Only with Overscan set to show or crop, and only written when one of the values is above 0.
Video format --videoformat undef, component, pal, ntsc, secam, mac off Original video system.
Color range --range limited, full on, limited Value range (tv/pc).
Color primaries --colorprim undef, bt709, bt470m, bt470bg, smpte170m, smpte240m, film, bt2020 off Color primaries.
Transfer characteristics --transfer undef, bt709, bt470m, bt470bg, linear, log100, log316, smpte170m, smpte240m, iec61966-2-4, bt1361e, iec61966-2-1, bt2020-10, bt2020-12 off Transfer function (gamma). This build knows neither PQ nor HLG.
Color matrix --colormatrix undef, bt709, fcc, bt470bg, smpte170m, smpte240m, GBR, YCgCo, bt2020nc, bt2020c on Matrix for the YUV ↔ RGB conversion.
Chroma sample location --chromaloc 0 – 5 off, 0 Position of the chroma samples.
Adjust color: matrix, transfer, primes – on/off each on Hybrid takes the value from the video that reaches the encoder instead of the one selected above; the matching list is then locked.

Misc

16bit-x265 Misc tab
16bit-x265 Misc tab

Internals

Control x265 option Range / values Hybrid default Meaning
In-Output bit-depth --input-depth 16-bit 16-bit Bit depth of the video handed to the encoder. Fixed; Hybrid converts the video to 16 bit before the encoder.
Color space --input-csp i420, i422, i444 i420 Chroma format of the output. Hybrid converts the video to it before the encoder.
Minimize command line --preset, --tune on/off on Shortens the call: Hybrid looks for the preset and tune whose values are all present and writes them instead of the single options, and drops options that equal the encoder's defaults.

Threading

Control x265 option Range / values Hybrid default Meaning
Pools/Threads --pools 0 – 64 each 1 / 0 Number of thread pools and threads per pool. With 0 threads the encoder decides and no --pools is written; 0 pools is written as --pools none and locks the three parallel options. The pool count is only available with wavefront processing or one of the distributed options on.
Frame threads --frame-threads 0 – 1000 0 Number of frames encoded at the same time; 0 lets the encoder choose from the core count.
Distributed analysis --pmode / --no-pmode on/off off Spreads the mode analysis of each coding unit over several threads. Only useful when the CPU is not already fully used; helps most at high RDO levels.
Distributed motion estimation --pme / --no-pme on/off off Spreads the motion search over several threads. The overhead often eats the gain.

Metrics

Control x265 option Range / values Hybrid default Meaning
PSNR, SSIM --psnr / --no-psnr, --ssim / --no-ssim on/off each off Lets the encoder report the metrics in its log.

Random Stuff

Control x265 option Range / values Hybrid default Meaning
Repeat headers --repeat-headers / --no-repeat-headers on/off off Writes the parameter sets at every key frame; for streams without a container.
SEI Info --info / --no-info on/off on Writes the encoder version and settings into the stream, where MediaInfo shows them.
HRD signaling --hrd / --no-hrd on/off off Signals the buffer model (buffering period and picture timing SEI) in the stream.
AUD signaling --aud / --no-aud on/off off Writes access unit delimiters; some transport streams and players need them.
Create qp file for chapters --qpfile on/off on Writes a qp file that puts an IDR frame at every chapter start. Not used when a custom qp file is set.
Temporal layers --temporal-layers / --no-temporal-layers on/off off Puts the B-frames nothing refers to into their own layer, which a decoder may drop to play at a lower frame rate.

Other

Control x265 option Range / values Hybrid default Meaning
No too small warning – on/off off No warning when the computed file size is below 1 MB.
Custom command line addition text text empty Text that is added to the call unchanged, for options Hybrid does not offer. It is not shortened and not checked.

The Configuration row below the tabs saves, loads and deletes named sets of all settings of this encoder.

Example

Default settings (CRF 28) on a 10-bit YUV 4:2:0 source (640x352, 25 fps), with Minimize command line on:

vspipe "encodingTempSynthSkript.vpy" - --outputindex 0 -c y4m --progress | 16bit-x265 --input - --input-depth 16 --y4m --no-open-gop --psy-rd 1.00 --no-rdoq-level --cu-lossless --colormatrix smpte170m --output "video.265"

Nearly everything else equals the encoder's defaults and was dropped from the call.

How Hybrid calls it

  • The filter script (Vapoursynth or AviSynth) is piped into the encoder as y4m; without a script ffmpeg decodes the source and pipes it.
  • The video is converted to 16 bit and to the chosen Color space before the encoder; in the example the 10-bit 4:2:0 source becomes 16-bit 4:2:0.
  • The encoder writes a raw HEVC stream (.265); Hybrid muxes it into the chosen container in a separate job.
  • Preset and tune are not passed on as they are selected. Their buttons set the single controls, and Hybrid always builds the call from the controls; --preset and --tune only appear when Minimize command line finds that the values match one.
  • Options that equal the encoder's default are left out with Minimize command line on.
  • In the 2-pass mode Hybrid creates one call per pass. The first pass writes to NUL; with Fast 1st pass on Hybrid also leaves the reference, motion search, sub-pixel, RDO, partition and early skip options out of it, so that the encoder's own fast first pass settings apply.
  • No profile, no level and no pixel aspect ratio are passed.
  • The color matrix, transfer and primaries follow the video that reaches the encoder as long as the Adjust color boxes are set.

Background

Why a separate build

An x265 binary is compiled for one sample precision. The old releases had two variants, an 8-bit one and a high bit depth one that reports itself as 16bpp; this is the latter. Hybrid's normal x265 follows the current encoder; this build stays at version 1.6 and therefore lacks everything that came later (HDR signalling such as PQ and HLG, newer adaptive quantization modes, many analysis options).

When to use it

Only when exactly this old build is the goal, e.g. for tests and comparisons. For high quality intermediates a lossless codec such as FFV1 is the better choice, and for delivery 10-bit HEVC from the normal x265 is what players support.

Sources