Vapoursynth ChromaShiftSP

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

ChromaShiftSP moves the color planes horizontally and/or vertically with sub-pixel accuracy, to fix sources where the colors sit next to the outlines.

Filtering → Vapoursynth → Color → Chroma

ChromaShiftSP controls in Hybrid
ChromaShiftSP controls in Hybrid

What it does

The clip is resized with a shifted source window (Spline16), and the shifted U and/or V planes are combined with the original luma. The shift is given in luma pixels and can be fractional.

Settings

Control Parameter Range Hybrid default Meaning
X X -512 – 512 0.00 Horizontal shift in luma pixels; positive values move the chroma to the left, negative to the right.
Y Y -512 – 512 0.00 Vertical shift in luma pixels; positive values move the chroma up, negative down.
Shift U shiftU on/off on Shift the U (blue-difference) plane.
Shift V shiftV on/off on Shift the V (red-difference) plane.
JEH jeh on/off on Fix by JEH: the source window keeps its size, so the chroma is only shifted. When off, the original formula also stretches the chroma slightly.

Switch off Shift U or Shift V when only one of the two color planes is misplaced.

Example

Chroma moved 2 pixels to the left on a 10-bit YUV 4:2:0 source:

# Chroma adjustment using ChromaShiftSP
clip = chromashift.ChromaShiftSP(clip, X=2.00)

How Hybrid calls it

  • ChromaShiftSP works on 8–16-bit integer YUV.
  • Only values that differ from the defaults are written.
  • Nothing is written when X and Y are both 0, or when neither Shift U nor Shift V is ticked.
  • Interlaced clips are processed as they are as long as Y is 0; with a vertical shift Hybrid deinterlaces or separates the fields first, so the chroma of the two fields is not mixed.
  • ChromaShiftSP also offers the common options (Masked, ApplyOnlyTo, Merge, OnRegion, Gimmick).

Background

The script

A port of the AviSynth function ChromaShift_SP (basic function by IanB, standalone version by McCauley, with an optional fix by JEH). It uses resize.Spline16 with src_left/src_top and recombines the planes with std.ShufflePlanes.

VapourSynth

The shift itself is done with the core resizers (see the VapourSynth documentation of resize).

AviSynth

The original ChromaShift_SP is an AviSynth script function; it uses the core filter MergeChroma to take the chroma from the shifted copy.

Sources