Avisynth ColorMatrix (AVSR)

From wiki.selur.net
Revision as of 18:45, 21 November 2026 by Selur (talk | contribs) (Avisynth filter documentation (via update-page on MediaWiki MCP Server))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

ColorMatrix (AVSR) converts the YUV matrix of a clip — and optionally its transfer function and primaries — with the zimg library through the avsresize plugin (z_ConvertFormat). Unlike the classic ColorMatrix it accepts any color space and bit depth.

Filtering → Avisynth → Color → Conversion

ColorMatrix (AVSR) controls in Hybrid
ColorMatrix (AVSR) controls in Hybrid

What it does

The clip is converted from one combination of matrix, transfer and primaries to another, keeping its format and bit depth. The most common use is the same as ColorMatrix: Rec.709 ↔ Rec.601 when the resolution class changes. With Transfer and Primaries it can also convert the transfer function (e.g. to HLG or PQ) and the color primaries.

Settings

Control Parameter Values Hybrid default Meaning
From colorspace_op (input matrix) Rec.709, FCC, Rec.601, SMPTE 240M, Rec.2020 Rec.709 Matrix of the input.
To colorspace_op (output matrix) Rec.709, FCC, Rec.601, SMPTE 240M, Rec.2020 Rec.601 Matrix of the output; locked while Adjust by resolution is on.
Adjust by resolution – on/off on Picks To from the resolution of the clip at the filter's position: Rec.601 up to 720×576, Rec.709 up to 1920×1088, Rec.2020 above.
Transfer colorspace_op (output transfer) keep, bt709, bt601, st2084, hlg, linear keep Output transfer function; keep = unchanged.
Primaries colorspace_op (output primaries) keep, bt709, bt601, bt2020, dci-p3 keep Output primaries; keep = unchanged.
Clipping colorspace_op (range) no clipping, pre clipping, post clipping, pre and post clipping pre and post clipping Which side is treated as limited range: pre = input, post = output, both, or none (full range).
Dither dither_type error_diffusion, ordered, random, none error_diffusion Dithering when rounding.
Chroma resampler resample_filter_uv spline64, spline36, spline16, bicubic, bilinear, lanczos, point spline64 Filter for the chroma planes.

Example

Defaults (Rec.709 to Rec.601, limited range on both sides) on a 10-bit YUV 4:2:0 source; no format change is needed:

# color matrix conversion using avsresize
z_ConvertFormat(colorspace_op="709:709:709:limited=>470bg:601:170m:limited",resample_filter_uv="spline64",dither_type="error_diffusion")

How Hybrid calls it

  • Hybrid loads avsresize.dll and writes one z_ConvertFormat() call. Each side of colorspace_op is matrix:transfer:primaries:range; Rec.601 becomes 470bg, its transfer 601 and its primaries 170m.
  • The input transfer and primaries are the ones Hybrid knows for the clip at this point; if unknown, they are derived from the matrix.
  • No pixel type is given, so format and bit depth stay unchanged. interlaced=true is added for interlaced sources.
  • The filter is left out when From and To are the same, the transfer stays and Clipping is no clipping.
  • Later steps of the script use the new matrix, transfer, primaries and range.
  • ColorMatrix (AVSR) and ColorMatrix exclude each other: enabling one disables the other.
  • ColorMatrix (AVSR) also offers the common options and can be added to the filter queue several times.

Background

avsresize ("z.lib resizers for AviSynth+") by StvG brings the zimg library to AviSynth+, the same library VapourSynth uses in its resize functions. In colorspace_op, auto reads the values from the frame properties and same keeps the input value. By default the plugin treats YUV as limited and RGB as full range and does not dither; Hybrid passes error diffusion.

See also: Vapoursynth ColorMatrix

Sources

  • avsresize repository (README)
  • Hybrid's tooltips
  • The AviSynth+ documentation does not cover avsresize.