Skia
2D Graphics Library
SkYUVAInfo Class Reference

Specifies the structure of planes for a YUV image with optional alpha. More...

#include <SkYUVAInfo.h>

Public Types

enum  YUVAChannels {
  kY , kU , kV , kA ,
  kLast = kA
}
 
enum class  PlaneConfig {
  kUnknown , kY_U_V , kY_V_U , kY_UV ,
  kY_VU , kYUV , kUYV , kY_U_V_A ,
  kY_V_U_A , kY_UV_A , kY_VU_A , kYUVA ,
  kUYVA , kLast = kUYVA
}
 Specifies how YUV (and optionally A) are divided among planes. More...
 
enum class  Subsampling {
  kUnknown , k444 , k422 , k420 ,
  k440 , k411 , k410 , kLast = k410
}
 UV subsampling is also specified in the enum value names using J:a:b notation (e.g. More...
 
enum class  Siting { kCentered }
 Describes how subsampled chroma values are sited relative to luma values. More...
 
using YUVALocations = std::array< YUVALocation, kYUVAChannelCount >
 

Public Member Functions

 SkYUVAInfo ()=default
 
 SkYUVAInfo (const SkYUVAInfo &)=default
 
 SkYUVAInfo (SkISize dimensions, PlaneConfig, Subsampling, SkYUVColorSpace, SkEncodedOrigin origin=kTopLeft_SkEncodedOrigin, Siting sitingX=Siting::kCentered, Siting sitingY=Siting::kCentered)
 'dimensions' should specify the size of the full resolution image (after planes have been oriented to how the image is displayed as indicated by 'origin'). More...
 
SkYUVAInfooperator= (const SkYUVAInfo &that)=default
 
PlaneConfig planeConfig () const
 
Subsampling subsampling () const
 
std::tuple< int, int > planeSubsamplingFactors (int planeIdx) const
 
SkISize dimensions () const
 Dimensions of the full resolution image (after planes have been oriented to how the image is displayed as indicated by fOrigin). More...
 
int width () const
 
int height () const
 
SkYUVColorSpace yuvColorSpace () const
 
Siting sitingX () const
 
Siting sitingY () const
 
SkEncodedOrigin origin () const
 
SkMatrix originMatrix () const
 
bool hasAlpha () const
 
int planeDimensions (SkISize planeDimensions[kMaxPlanes]) const
 Returns the number of planes and initializes planeDimensions[0]..planeDimensions[<ret>] to the expected dimensions for each plane. More...
 
size_t computeTotalBytes (const size_t rowBytes[kMaxPlanes], size_t planeSizes[kMaxPlanes]=nullptr) const
 Given a per-plane row bytes, determine size to allocate for all planes. More...
 
int numPlanes () const
 
int numChannelsInPlane (int i) const
 
YUVALocations toYUVALocations (const uint32_t *channelFlags) const
 Given a set of channel flags for each plane, converts this->planeConfig() to YUVALocations representation. More...
 
SkYUVAInfo makeSubsampling (SkYUVAInfo::Subsampling) const
 Makes a SkYUVAInfo that is identical to this one but with the passed Subsampling. More...
 
SkYUVAInfo makeDimensions (SkISize) const
 Makes a SkYUVAInfo that is identical to this one but with the passed dimensions. More...
 
bool operator== (const SkYUVAInfo &that) const
 
bool operator!= (const SkYUVAInfo &that) const
 
bool isValid () const
 

Static Public Member Functions

static std::tuple< int, int > SubsamplingFactors (Subsampling)
 ratio of Y/A values to U/V values in x and y. More...
 
static std::tuple< int, int > PlaneSubsamplingFactors (PlaneConfig, Subsampling, int planeIdx)
 SubsamplingFactors(Subsampling) if planedIdx refers to a U/V plane and otherwise {1, 1} if inputs are valid. More...
 
static int PlaneDimensions (SkISize imageDimensions, PlaneConfig, Subsampling, SkEncodedOrigin, SkISize planeDimensions[kMaxPlanes])
 Given image dimensions, a planer configuration, subsampling, and origin, determine the expected size of each plane. More...
 
static constexpr int NumPlanes (PlaneConfig)
 Number of planes for a given PlaneConfig. More...
 
static constexpr int NumChannelsInPlane (PlaneConfig, int i)
 Number of Y, U, V, A channels in the ith plane for a given PlaneConfig (or 0 if i is invalid). More...
 
static YUVALocations GetYUVALocations (PlaneConfig, const uint32_t *planeChannelFlags)
 Given a PlaneConfig and a set of channel flags for each plane, convert to YUVALocations representation. More...
 
static bool HasAlpha (PlaneConfig)
 Does the PlaneConfig have alpha values? More...
 

Static Public Attributes

static constexpr int kYUVAChannelCount = static_cast<int>(YUVAChannels::kLast + 1)
 
static constexpr int kMaxPlanes = 4
 

Detailed Description

Specifies the structure of planes for a YUV image with optional alpha.

The actual planar data is not part of this structure and depending on usage is in external textures or pixmaps.

Member Typedef Documentation

◆ YUVALocations

using SkYUVAInfo::YUVALocations = std::array<YUVALocation, kYUVAChannelCount>

Member Enumeration Documentation

◆ PlaneConfig

Specifies how YUV (and optionally A) are divided among planes.

Planes are separated by underscores in the enum value names. Within each plane the pixmap/texture channels are mapped to the YUVA channels in the order specified, e.g. for kY_UV Y is in channel 0 of plane 0, U is in channel 0 of plane 1, and V is in channel 1 of plane 1. Channel ordering within a pixmap/texture given the channels it contains: A: 0:A Luminance/Gray: 0:Gray Luminance/Gray + Alpha: 0:Gray, 1:A RG 0:R, 1:G RGB 0:R, 1:G, 2:B RGBA 0:R, 1:G, 2:B, 3:A

Enumerator
kUnknown 
kY_U_V 

Plane 0: Y, Plane 1: U, Plane 2: V.

kY_V_U 

Plane 0: Y, Plane 1: V, Plane 2: U.

kY_UV 

Plane 0: Y, Plane 1: UV.

kY_VU 

Plane 0: Y, Plane 1: VU.

kYUV 

Plane 0: YUV.

kUYV 

Plane 0: UYV.

kY_U_V_A 

Plane 0: Y, Plane 1: U, Plane 2: V, Plane 3: A.

kY_V_U_A 

Plane 0: Y, Plane 1: V, Plane 2: U, Plane 3: A.

kY_UV_A 

Plane 0: Y, Plane 1: UV, Plane 2: A.

kY_VU_A 

Plane 0: Y, Plane 1: VU, Plane 2: A.

kYUVA 

Plane 0: YUVA.

kUYVA 

Plane 0: UYVA.

kLast 

◆ Siting

enum SkYUVAInfo::Siting
strong

Describes how subsampled chroma values are sited relative to luma values.

Currently only centered siting is supported but will expand to support additional sitings.

Enumerator
kCentered 

Subsampled chroma value is sited at the center of the block of corresponding luma values.

◆ Subsampling

UV subsampling is also specified in the enum value names using J:a:b notation (e.g.

4:2:0 is 1/2 horizontal and 1/2 vertical resolution for U and V). If alpha is present it is not sub- sampled. Note that Subsampling values other than k444 are only valid with PlaneConfig values that have U and V in different planes than Y (and A, if present).

Enumerator
kUnknown 
k444 

No subsampling. UV values for each Y.

k422 

1 set of UV values for each 2x1 block of Y values.

k420 

1 set of UV values for each 2x2 block of Y values.

k440 

1 set of UV values for each 1x2 block of Y values.

k411 

1 set of UV values for each 4x1 block of Y values.

k410 

1 set of UV values for each 4x2 block of Y values.

kLast 

◆ YUVAChannels

Enumerator
kY 
kU 
kV 
kA 
kLast 

Constructor & Destructor Documentation

◆ SkYUVAInfo() [1/3]

SkYUVAInfo::SkYUVAInfo ( )
default

◆ SkYUVAInfo() [2/3]

SkYUVAInfo::SkYUVAInfo ( const SkYUVAInfo )
default

◆ SkYUVAInfo() [3/3]

SkYUVAInfo::SkYUVAInfo ( SkISize  dimensions,
PlaneConfig  ,
Subsampling  ,
SkYUVColorSpace  ,
SkEncodedOrigin  origin = kTopLeft_SkEncodedOrigin,
Siting  sitingX = Siting::kCentered,
Siting  sitingY = Siting::kCentered 
)

'dimensions' should specify the size of the full resolution image (after planes have been oriented to how the image is displayed as indicated by 'origin').

Member Function Documentation

◆ computeTotalBytes()

size_t SkYUVAInfo::computeTotalBytes ( const size_t  rowBytes[kMaxPlanes],
size_t  planeSizes[kMaxPlanes] = nullptr 
) const

Given a per-plane row bytes, determine size to allocate for all planes.

Optionally retrieves the per-plane byte sizes in planeSizes if not null. If total size overflows will return SIZE_MAX and set all planeSizes to SIZE_MAX.

◆ dimensions()

SkISize SkYUVAInfo::dimensions ( ) const
inline

Dimensions of the full resolution image (after planes have been oriented to how the image is displayed as indicated by fOrigin).

◆ GetYUVALocations()

static YUVALocations SkYUVAInfo::GetYUVALocations ( PlaneConfig  ,
const uint32_t *  planeChannelFlags 
)
static

Given a PlaneConfig and a set of channel flags for each plane, convert to YUVALocations representation.

Fails if channel flags aren't valid for the PlaneConfig (i.e. don't have enough channels in a plane) by returning an invalid set of locations (plane indices are -1).

◆ hasAlpha()

bool SkYUVAInfo::hasAlpha ( ) const
inline

◆ HasAlpha()

static bool SkYUVAInfo::HasAlpha ( PlaneConfig  )
static

Does the PlaneConfig have alpha values?

◆ height()

int SkYUVAInfo::height ( ) const
inline

◆ isValid()

bool SkYUVAInfo::isValid ( ) const
inline

◆ makeDimensions()

SkYUVAInfo SkYUVAInfo::makeDimensions ( SkISize  ) const

Makes a SkYUVAInfo that is identical to this one but with the passed dimensions.

If the passed dimensions is empty then the result will be an invalid SkYUVAInfo.

◆ makeSubsampling()

SkYUVAInfo SkYUVAInfo::makeSubsampling ( SkYUVAInfo::Subsampling  ) const

Makes a SkYUVAInfo that is identical to this one but with the passed Subsampling.

If the passed Subsampling is not k444 and this info's PlaneConfig is not compatible with chroma subsampling (because Y is in the same plane as UV) then the result will be an invalid SkYUVAInfo.

◆ numChannelsInPlane()

int SkYUVAInfo::numChannelsInPlane ( int  i) const
inline

◆ NumChannelsInPlane()

constexpr int SkYUVAInfo::NumChannelsInPlane ( PlaneConfig  config,
int  i 
)
staticconstexpr

Number of Y, U, V, A channels in the ith plane for a given PlaneConfig (or 0 if i is invalid).

◆ numPlanes()

int SkYUVAInfo::numPlanes ( ) const
inline

◆ NumPlanes()

constexpr int SkYUVAInfo::NumPlanes ( PlaneConfig  planeConfig)
staticconstexpr

Number of planes for a given PlaneConfig.

◆ operator!=()

bool SkYUVAInfo::operator!= ( const SkYUVAInfo that) const
inline

◆ operator=()

SkYUVAInfo& SkYUVAInfo::operator= ( const SkYUVAInfo that)
default

◆ operator==()

bool SkYUVAInfo::operator== ( const SkYUVAInfo that) const

◆ origin()

SkEncodedOrigin SkYUVAInfo::origin ( ) const
inline

◆ originMatrix()

SkMatrix SkYUVAInfo::originMatrix ( ) const
inline

◆ planeConfig()

PlaneConfig SkYUVAInfo::planeConfig ( ) const
inline

◆ PlaneDimensions()

static int SkYUVAInfo::PlaneDimensions ( SkISize  imageDimensions,
PlaneConfig  ,
Subsampling  ,
SkEncodedOrigin  ,
SkISize  planeDimensions[kMaxPlanes] 
)
static

Given image dimensions, a planer configuration, subsampling, and origin, determine the expected size of each plane.

Returns the number of expected planes. planeDimensions[0] through planeDimensions[<ret>] are written. The input image dimensions are as displayed (after the planes have been transformed to the intended display orientation). The plane dimensions are output as the planes are stored in memory (may be rotated from image dimensions).

◆ planeDimensions()

int SkYUVAInfo::planeDimensions ( SkISize  planeDimensions[kMaxPlanes]) const
inline

Returns the number of planes and initializes planeDimensions[0]..planeDimensions[<ret>] to the expected dimensions for each plane.

Dimensions are as stored in memory, before transformation to image display space as indicated by origin().

◆ planeSubsamplingFactors()

std::tuple<int, int> SkYUVAInfo::planeSubsamplingFactors ( int  planeIdx) const
inline

◆ PlaneSubsamplingFactors()

static std::tuple<int, int> SkYUVAInfo::PlaneSubsamplingFactors ( PlaneConfig  ,
Subsampling  ,
int  planeIdx 
)
static

SubsamplingFactors(Subsampling) if planedIdx refers to a U/V plane and otherwise {1, 1} if inputs are valid.

Invalid inputs consist of incompatible PlaneConfig/Subsampling/planeIdx combinations. {0, 0} is returned for invalid inputs.

◆ sitingX()

Siting SkYUVAInfo::sitingX ( ) const
inline

◆ sitingY()

Siting SkYUVAInfo::sitingY ( ) const
inline

◆ subsampling()

Subsampling SkYUVAInfo::subsampling ( ) const
inline

◆ SubsamplingFactors()

static std::tuple<int, int> SkYUVAInfo::SubsamplingFactors ( Subsampling  )
static

ratio of Y/A values to U/V values in x and y.

◆ toYUVALocations()

YUVALocations SkYUVAInfo::toYUVALocations ( const uint32_t *  channelFlags) const

Given a set of channel flags for each plane, converts this->planeConfig() to YUVALocations representation.

Fails if the channel flags aren't valid for the PlaneConfig (i.e. don't have enough channels in a plane) by returning default initialized locations (all plane indices are -1).

◆ width()

int SkYUVAInfo::width ( ) const
inline

◆ yuvColorSpace()

SkYUVColorSpace SkYUVAInfo::yuvColorSpace ( ) const
inline

Member Data Documentation

◆ kMaxPlanes

constexpr int SkYUVAInfo::kMaxPlanes = 4
staticconstexpr

◆ kYUVAChannelCount

constexpr int SkYUVAInfo::kYUVAChannelCount = static_cast<int>(YUVAChannels::kLast + 1)
staticconstexpr

The documentation for this class was generated from the following file: