Enum Class SyntheticPattern

java.lang.Object
java.lang.Enum<SyntheticPattern>
limn.video.decode.SyntheticPattern
All Implemented Interfaces:
Serializable, Comparable<SyntheticPattern>, Constable

public enum SyntheticPattern extends Enum<SyntheticPattern>
What a synthetic stream draws. Every pattern is a pure function of a pixel's coordinates, the picture size and the picture's index in the stream, so any sample of any picture can be worked out in advance and a rendered frame can be compared against arithmetic instead of against a reference image.

All three accessors take a luma coordinate, including the two chroma ones. A chroma sample of a subsampled layout is the value at the luma pixel it covers the top-left of (the pixel a nearest-neighbour upsampler reads back), so the same three functions describe I420, NV12 and I444 without a layout ever entering the arithmetic. The visible consequence at 4:2:0 is a one-pixel colour fringe wherever a pattern's colour changes on an odd column, which is what real subsampled video does and is deliberately not smoothed away.

The values are codes, not colours, and every accessor takes the bit depth they are to be expressed in. The bars carry the studio-range BT.709 code table shifted up to that depth (235 at eight bits is 940 at ten, which is what studio white actually is there), so they read as the familiar bar sequence under a limited-range interpretation and as something visibly wrong under a full-range one, at either depth. That is the point of being able to ask for any VideoColor: a matrix or range regression shows up as the wrong bars rather than as nothing at all.

GRADIENT is the one pattern whose shape depends on the depth, deliberately: it wraps at the end of the code space, so the same picture size shows several ramps at eight bits and fewer at ten. That is the only way to make four times as many codes visible on a screen that has eight bits of its own.

  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Eight vertical colour bars (white, yellow, cyan, green, magenta, red, blue, black) that do not move.
    The bars with the picture's index over them, in black, as seven-segment digits.
    A gradient that moves one code per picture, in every channel and in a different direction in each: luma along both axes, Cb across, Cr down and backwards.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    cb(int x, int y, int width, int height, int frameIndex, int bitDepth)
    The Cb code the pattern assigns at luma pixel (x, y): the value a chroma sample takes when it covers that pixel, whatever the layout's subsampling.
    int
    cr(int x, int y, int width, int height, int frameIndex, int bitDepth)
    The Cr code the pattern assigns at luma pixel (x, y), as cb(int, int, int, int, int, int).
    int
    luma(int x, int y, int width, int height, int frameIndex, int bitDepth)
    The luma code at pixel (x, y) of picture frameIndex.
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • BARS

      public static final SyntheticPattern BARS
      Eight vertical colour bars (white, yellow, cyan, green, magenta, red, blue, black) that do not move. Bar b covers the columns where x * 8 / width is b, so at a width that is not a multiple of eight the bars differ in width by a pixel rather than the last one being short.
    • GRADIENT

      public static final SyntheticPattern GRADIENT
      A gradient that moves one code per picture, in every channel and in a different direction in each: luma along both axes, Cb across, Cr down and backwards. It wraps at the end of the code space rather than clamping, so every code including the studio footroom and headroom is exercised, and a picture differs from its neighbour everywhere; a stream that shows the same picture twice or steps by the wrong number is visible in a single still.

      Because it wraps at the code space and steps one code per column, the number of ramps across a picture is the picture's width divided by the code count: 640 columns give two and a half sawtooths at eight bits and a single unfinished ramp at ten. That is what makes a depth change something a reader can see and name on an ordinary eight-bit display, where the extra precision itself is by definition invisible.

    • COUNTER

      public static final SyntheticPattern COUNTER
      The bars with the picture's index over them, in black, as seven-segment digits. The only pattern a human can read a frame number off, which is what makes it the one to put in front of someone checking that a stream is stepping at all.
  • Method Details

    • values

      public static SyntheticPattern[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static SyntheticPattern valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • luma

      public int luma(int x, int y, int width, int height, int frameIndex, int bitDepth)
      The luma code at pixel (x, y) of picture frameIndex.
      Parameters:
      x - column, in [0..width)
      y - row, in [0..height)
      frameIndex - the picture's index in the stream, from 0
      bitDepth - bits per component the code is wanted in, in [8..16]
      Returns:
      a code in [0..(1 << bitDepth) - 1]
      Throws:
      IllegalArgumentException - if bitDepth is outside [8..16]
    • cb

      public int cb(int x, int y, int width, int height, int frameIndex, int bitDepth)
      The Cb code the pattern assigns at luma pixel (x, y): the value a chroma sample takes when it covers that pixel, whatever the layout's subsampling.
      Parameters:
      bitDepth - bits per component the code is wanted in, in [8..16]
      Returns:
      a code in [0..(1 << bitDepth) - 1]
      Throws:
      IllegalArgumentException - if bitDepth is outside [8..16]
    • cr

      public int cr(int x, int y, int width, int height, int frameIndex, int bitDepth)
      The Cr code the pattern assigns at luma pixel (x, y), as cb(int, int, int, int, int, int).
      Parameters:
      bitDepth - bits per component the code is wanted in, in [8..16]
      Returns:
      a code in [0..(1 << bitDepth) - 1]
      Throws:
      IllegalArgumentException - if bitDepth is outside [8..16]