@UnstableApi
public final class ColorInfo implements Bundleable


Stores color info.

When a nullColorInfo instance is used, this often represents a generic SDR_BT709_LIMITED instance.

Summary

Nested types

public final class ColorInfo.Builder

Builds ColorInfo instances.

Constants

static final Bundleable.Creator<ColorInfo>

This field is deprecated.

Use fromBundle instead.

static final ColorInfo

Color info representing SDR BT.709 limited range, which is a common SDR video color format.

static final ColorInfo

Color info representing SDR sRGB in accordance with DATASPACE_SRGB, which is a common SDR image color format.

Public fields

final int

The bit depth of the chroma samples of the video, or NO_VALUE if not set.

final @C.ColorRange int

The C.ColorRange, or NO_VALUE if not set.

final int

The C.ColorSpace, or NO_VALUE if not set.

final int

The C.ColorTransfer, or NO_VALUE if not set.

final @Nullable byte[]

HdrStaticInfo as defined in CTA-861.3, or null if none specified.

final int

The bit depth of the luma samples of the video, or NO_VALUE if not set.

Public methods

ColorInfo.Builder

Returns a Builder initialized with the values of this instance.

boolean
static ColorInfo

Restores a ColorInfo from a Bundle.

int
boolean

Returns whether this instance has valid bitdepths.

boolean

Returns whether this instance has valid DataSpace members.

static boolean
@EnsuresNonNullIf(result = false, expression = "#1")
isEquivalentToAssumedSdrDefault(@Nullable ColorInfo colorInfo)

Returns whether the given color info is equivalent to values for a standard dynamic range video that could generally be assumed if no further information is given.

static boolean

Returns whether the ColorInfo uses an HDR C.ColorTransfer.

boolean

Returns whether this instance is valid.

static int

Returns the C.ColorSpace corresponding to the given ISO color primary code, as per table A.7.21.1 in Rec.

static int
@Pure
@C.ColorTransfer
isoTransferCharacteristicsToColorTransfer(
    int isoTransferCharacteristics
)

Returns the C.ColorTransfer corresponding to the given ISO transfer characteristics code, as per table A.7.21.2 in Rec.

Bundle

Returns a Bundle representing the information stored in this object.

String

Returns a prettier String than toString, intended for logging.

String

Constants

CREATOR

public static final Bundleable.Creator<ColorInfoCREATOR

SDR_BT709_LIMITED

public static final ColorInfo SDR_BT709_LIMITED

Color info representing SDR BT.709 limited range, which is a common SDR video color format.

SRGB_BT709_FULL

public static final ColorInfo SRGB_BT709_FULL

Color info representing SDR sRGB in accordance with DATASPACE_SRGB, which is a common SDR image color format.

Public fields

chromaBitdepth

public final int chromaBitdepth

The bit depth of the chroma samples of the video, or NO_VALUE if not set. It may differ from the luma bit depth.

colorRange

public final @C.ColorRange int colorRange

The C.ColorRange, or NO_VALUE if not set.

colorSpace

@C.ColorSpace
public final int colorSpace

The C.ColorSpace, or NO_VALUE if not set.

colorTransfer

@C.ColorTransfer
public final int colorTransfer

The C.ColorTransfer, or NO_VALUE if not set.

hdrStaticInfo

public final @Nullable byte[] hdrStaticInfo

HdrStaticInfo as defined in CTA-861.3, or null if none specified.

lumaBitdepth

public final int lumaBitdepth

The bit depth of the luma samples of the video, or NO_VALUE if not set.

Public methods

buildUpon

public ColorInfo.Builder buildUpon()

Returns a Builder initialized with the values of this instance.

equals

public boolean equals(@Nullable Object obj)

fromBundle

public static ColorInfo fromBundle(Bundle bundle)

Restores a ColorInfo from a Bundle.

hashCode

public int hashCode()

isBitdepthValid

public boolean isBitdepthValid()

Returns whether this instance has valid bitdepths.

This instance has valid bitdepths if none of them is NO_VALUE.

isDataSpaceValid

public boolean isDataSpaceValid()

Returns whether this instance has valid DataSpace members.

This instance is valid if no DataSpace members are NO_VALUE.

isEquivalentToAssumedSdrDefault

@EnsuresNonNullIf(result = false, expression = "#1")
public static boolean isEquivalentToAssumedSdrDefault(@Nullable ColorInfo colorInfo)

Returns whether the given color info is equivalent to values for a standard dynamic range video that could generally be assumed if no further information is given.

The color info is deemed to be equivalent to SDR video if it either has unset values or values matching a 8-bit (chroma+luma), BT.709 or BT.601 color space, SDR transfer and Limited range color info.

Parameters
@Nullable ColorInfo colorInfo

The color info to evaluate.

Returns
boolean

Whether the given color info is equivalent to the assumed default SDR color info.

isTransferHdr

public static boolean isTransferHdr(@Nullable ColorInfo colorInfo)

Returns whether the ColorInfo uses an HDR C.ColorTransfer.

COLOR_TRANSFER_LINEAR is not considered to be an HDR C.ColorTransfer, because it may represent either SDR or HDR contents.

isValid

public boolean isValid()

Returns whether this instance is valid.

This instance is valid if at least one between bitdepths and DataSpace info are valid.

isoColorPrimariesToColorSpace

@Pure
@C.ColorSpace
public static int isoColorPrimariesToColorSpace(int isoColorPrimaries)

Returns the C.ColorSpace corresponding to the given ISO color primary code, as per table A.7.21.1 in Rec. ITU-T T.832 (03/2009), or NO_VALUE if no mapping can be made.

isoTransferCharacteristicsToColorTransfer

@Pure
@C.ColorTransfer
public static int isoTransferCharacteristicsToColorTransfer(
    int isoTransferCharacteristics
)

Returns the C.ColorTransfer corresponding to the given ISO transfer characteristics code, as per table A.7.21.2 in Rec. ITU-T T.832 (03/2009), or NO_VALUE if no mapping can be made.

toBundle

public Bundle toBundle()

Returns a Bundle representing the information stored in this object.

toLogString

public String toLogString()

Returns a prettier String than toString, intended for logging.

See also
toLogString

toString

public String toString()