8 #ifndef SkYUVAInfo_DEFINED
9 #define SkYUVAInfo_DEFINED
11 #include "include/codec/SkEncodedOrigin.h"
29 static constexpr
int kYUVAChannelCount =
static_cast<int>(YUVAChannels::kLast + 1);
98 static constexpr
int kMaxPlanes = 4;
122 SkISize planeDimensions[kMaxPlanes]);
131 static constexpr
int NumChannelsInPlane(
PlaneConfig,
int i);
154 SkEncodedOrigin origin = kTopLeft_SkEncodedOrigin,
155 Siting sitingX = Siting::kCentered,
156 Siting sitingY = Siting::kCentered);
164 return PlaneSubsamplingFactors(fPlaneConfig, fSubsampling, planeIdx);
172 int width()
const {
return fDimensions.width(); }
173 int height()
const {
return fDimensions.height(); }
179 SkEncodedOrigin
origin()
const {
return fOrigin; }
182 return SkEncodedOriginToMatrix(fOrigin, this->width(), this->height());
185 bool hasAlpha()
const {
return HasAlpha(fPlaneConfig); }
193 return PlaneDimensions(fDimensions, fPlaneConfig, fSubsampling, fOrigin, planeDimensions);
202 size_t planeSizes[kMaxPlanes] =
nullptr)
const;
204 int numPlanes()
const {
return NumPlanes(fPlaneConfig); }
233 bool isValid()
const {
return fPlaneConfig != PlaneConfig::kUnknown; }
238 PlaneConfig fPlaneConfig = PlaneConfig::kUnknown;
239 Subsampling fSubsampling = Subsampling::kUnknown;
247 SkEncodedOrigin fOrigin = kTopLeft_SkEncodedOrigin;
249 Siting fSitingX = Siting::kCentered;
250 Siting fSitingY = Siting::kCentered;
279 return i >= 0 && i < 3 ? 1 : 0;
289 return i == 0 ? 3 : 0;
292 return i >= 0 && i < 4 ? 1 : 0;
303 return i == 0 ? 4 : 0;
SkYUVColorSpace
Definition: SkImageInfo.h:68
@ kIdentity_SkYUVColorSpace
maps Y->R, U->G, V->B
Definition: SkImageInfo.h:79
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
Specifies the structure of planes for a YUV image with optional alpha.
Definition: SkYUVAInfo.h:26
SkYUVAInfo(const SkYUVAInfo &)=default
int width() const
Definition: SkYUVAInfo.h:172
Siting sitingY() const
Definition: SkYUVAInfo.h:177
Siting
Describes how subsampled chroma values are sited relative to luma values.
Definition: SkYUVAInfo.h:91
SkMatrix originMatrix() const
Definition: SkYUVAInfo.h:181
SkYUVAInfo & operator=(const SkYUVAInfo &that)=default
SkYUVColorSpace yuvColorSpace() const
Definition: SkYUVAInfo.h:175
int numPlanes() const
Definition: SkYUVAInfo.h:204
YUVALocations toYUVALocations(const uint32_t *channelFlags) const
Given a set of channel flags for each plane, converts this->planeConfig() to YUVALocations representa...
PlaneConfig
Specifies how YUV (and optionally A) are divided among planes.
Definition: SkYUVAInfo.h:47
@ kY_U_V_A
Plane 0: Y, Plane 1: U, Plane 2: V, Plane 3: A.
@ kY_U_V
Plane 0: Y, Plane 1: U, Plane 2: V.
@ kY_V_U_A
Plane 0: Y, Plane 1: V, Plane 2: U, Plane 3: A.
@ kY_VU
Plane 0: Y, Plane 1: VU.
@ kY_UV
Plane 0: Y, Plane 1: UV.
@ kY_VU_A
Plane 0: Y, Plane 1: VU, Plane 2: A.
@ kY_V_U
Plane 0: Y, Plane 1: V, Plane 2: U.
@ kY_UV_A
Plane 0: Y, Plane 1: UV, Plane 2: A.
std::tuple< int, int > planeSubsamplingFactors(int planeIdx) const
Definition: SkYUVAInfo.h:163
bool hasAlpha() const
Definition: SkYUVAInfo.h:185
YUVAChannels
Definition: SkYUVAInfo.h:28
@ kA
Definition: SkYUVAInfo.h:28
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).
Definition: SkYUVAInfo.h:272
Subsampling
UV subsampling is also specified in the enum value names using J:a:b notation (e.g.
Definition: SkYUVAInfo.h:73
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.
SkYUVAInfo makeDimensions(SkISize) const
Makes a SkYUVAInfo that is identical to this one but with the passed dimensions.
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...
int height() const
Definition: SkYUVAInfo.h:173
static constexpr int NumPlanes(PlaneConfig)
Number of planes for a given PlaneConfig.
Definition: SkYUVAInfo.h:253
SkYUVAInfo makeSubsampling(SkYUVAInfo::Subsampling) const
Makes a SkYUVAInfo that is identical to this one but with the passed Subsampling.
static YUVALocations GetYUVALocations(PlaneConfig, const uint32_t *planeChannelFlags)
Given a PlaneConfig and a set of channel flags for each plane, convert to YUVALocations representatio...
PlaneConfig planeConfig() const
Definition: SkYUVAInfo.h:160
int planeDimensions(SkISize planeDimensions[kMaxPlanes]) const
Returns the number of planes and initializes planeDimensions[0]..planeDimensions[<ret>] to the expect...
Definition: SkYUVAInfo.h:192
std::array< YUVALocation, kYUVAChannelCount > YUVALocations
Definition: SkYUVAInfo.h:32
static bool HasAlpha(PlaneConfig)
Does the PlaneConfig have alpha values?
SkEncodedOrigin origin() const
Definition: SkYUVAInfo.h:179
static std::tuple< int, int > PlaneSubsamplingFactors(PlaneConfig, Subsampling, int planeIdx)
SubsamplingFactors(Subsampling) if planedIdx refers to a U/V plane and otherwise {1,...
bool isValid() const
Definition: SkYUVAInfo.h:233
Subsampling subsampling() const
Definition: SkYUVAInfo.h:161
bool operator!=(const SkYUVAInfo &that) const
Definition: SkYUVAInfo.h:231
SkISize dimensions() const
Dimensions of the full resolution image (after planes have been oriented to how the image is displaye...
Definition: SkYUVAInfo.h:171
static int PlaneDimensions(SkISize imageDimensions, PlaneConfig, Subsampling, SkEncodedOrigin, SkISize planeDimensions[kMaxPlanes])
Given image dimensions, a planer configuration, subsampling, and origin, determine the expected size ...
static std::tuple< int, int > SubsamplingFactors(Subsampling)
ratio of Y/A values to U/V values in x and y.
int numChannelsInPlane(int i) const
Definition: SkYUVAInfo.h:206
Siting sitingX() const
Definition: SkYUVAInfo.h:176
bool operator==(const SkYUVAInfo &that) const