Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SkYUVAInfo Class Reference

#include <SkYUVAInfo.h>

Classes

struct  YUVALocation
 

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
}
 
enum class  Subsampling {
  kUnknown , k444 , k422 , k420 ,
  k440 , k411 , k410 , kLast = k410
}
 
enum class  Siting { kCentered }
 
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)
 
SkYUVAInfooperator= (const SkYUVAInfo &that)=default
 
PlaneConfig planeConfig () const
 
Subsampling subsampling () const
 
std::tuple< int, intplaneSubsamplingFactors (int planeIdx) const
 
SkISize dimensions () const
 
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
 
size_t computeTotalBytes (const size_t rowBytes[kMaxPlanes], size_t planeSizes[kMaxPlanes]=nullptr) const
 
int numPlanes () const
 
int numChannelsInPlane (int i) const
 
YUVALocations toYUVALocations (const uint32_t *channelFlags) const
 
SkYUVAInfo makeSubsampling (SkYUVAInfo::Subsampling) const
 
SkYUVAInfo makeDimensions (SkISize) const
 
bool operator== (const SkYUVAInfo &that) const
 
bool operator!= (const SkYUVAInfo &that) const
 
bool isValid () const
 

Static Public Member Functions

static std::tuple< int, intSubsamplingFactors (Subsampling)
 
static std::tuple< int, intPlaneSubsamplingFactors (PlaneConfig, Subsampling, int planeIdx)
 
static int PlaneDimensions (SkISize imageDimensions, PlaneConfig, Subsampling, SkEncodedOrigin, SkISize planeDimensions[kMaxPlanes])
 
static constexpr int NumPlanes (PlaneConfig)
 
static constexpr int NumChannelsInPlane (PlaneConfig, int i)
 
static YUVALocations GetYUVALocations (PlaneConfig, const uint32_t *planeChannelFlags)
 
static bool HasAlpha (PlaneConfig)
 

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.

Definition at line 26 of file SkYUVAInfo.h.

Member Typedef Documentation

◆ YUVALocations

Definition at line 32 of file SkYUVAInfo.h.

Member Enumeration Documentation

◆ PlaneConfig

enum class SkYUVAInfo::PlaneConfig
strong

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 

Definition at line 47 of file SkYUVAInfo.h.

47 {
49
50 kY_U_V, ///< Plane 0: Y, Plane 1: U, Plane 2: V
51 kY_V_U, ///< Plane 0: Y, Plane 1: V, Plane 2: U
52 kY_UV, ///< Plane 0: Y, Plane 1: UV
53 kY_VU, ///< Plane 0: Y, Plane 1: VU
54 kYUV, ///< Plane 0: YUV
55 kUYV, ///< Plane 0: UYV
56
57 kY_U_V_A, ///< Plane 0: Y, Plane 1: U, Plane 2: V, Plane 3: A
58 kY_V_U_A, ///< Plane 0: Y, Plane 1: V, Plane 2: U, Plane 3: A
59 kY_UV_A, ///< Plane 0: Y, Plane 1: UV, Plane 2: A
60 kY_VU_A, ///< Plane 0: Y, Plane 1: VU, Plane 2: A
61 kYUVA, ///< Plane 0: YUVA
62 kUYVA, ///< Plane 0: UYVA
63
64 kLast = kUYVA
65 };
@ kYUVA
Definition: embedder.h:606

◆ Siting

enum class 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.

Definition at line 91 of file SkYUVAInfo.h.

91 {
92 /**
93 * Subsampled chroma value is sited at the center of the block of corresponding luma values.
94 */
96 };
@ kCentered

◆ Subsampling

enum class SkYUVAInfo::Subsampling
strong

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 

Definition at line 73 of file SkYUVAInfo.h.

73 {
75
76 k444, ///< No subsampling. UV values for each Y.
77 k422, ///< 1 set of UV values for each 2x1 block of Y values.
78 k420, ///< 1 set of UV values for each 2x2 block of Y values.
79 k440, ///< 1 set of UV values for each 1x2 block of Y values.
80 k411, ///< 1 set of UV values for each 4x1 block of Y values.
81 k410, ///< 1 set of UV values for each 4x2 block of Y values.
82
83 kLast = k410
84 };

◆ YUVAChannels

Enumerator
kY 
kU 
kV 
kA 
kLast 

Definition at line 28 of file SkYUVAInfo.h.

28{ kY, kU, kV, kA, kLast = kA };

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  planeConfig,
Subsampling  subsampling,
SkYUVColorSpace  yuvColorSpace,
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').

Definition at line 302 of file SkYUVAInfo.cpp.

309 : fDimensions(dimensions)
310 , fPlaneConfig(planeConfig)
311 , fSubsampling(subsampling)
312 , fYUVColorSpace(yuvColorSpace)
313 , fOrigin(origin)
314 , fSitingX(sitingX)
315 , fSitingY(sitingY) {
316 if (fDimensions.isEmpty() ||
318 *this = {};
319 SkASSERT(!this->isValid());
320 return;
321 }
322 SkASSERT(this->isValid());
323}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static bool is_plane_config_compatible_with_subsampling(SkYUVAInfo::PlaneConfig config, SkYUVAInfo::Subsampling subsampling)
Definition: SkYUVAInfo.cpp:16
Siting sitingY() const
Definition: SkYUVAInfo.h:177
SkYUVColorSpace yuvColorSpace() const
Definition: SkYUVAInfo.h:175
PlaneConfig planeConfig() const
Definition: SkYUVAInfo.h:160
SkEncodedOrigin origin() const
Definition: SkYUVAInfo.h:179
bool isValid() const
Definition: SkYUVAInfo.h:233
Subsampling subsampling() const
Definition: SkYUVAInfo.h:161
SkISize dimensions() const
Definition: SkYUVAInfo.h:171
Siting sitingX() const
Definition: SkYUVAInfo.h:176
bool isEmpty() const
Definition: SkSize.h:31

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.

Definition at line 325 of file SkYUVAInfo.cpp.

326 {
327 if (!this->isValid()) {
328 return 0;
329 }
330 SkSafeMath safe;
331 size_t totalBytes = 0;
333 int n = this->planeDimensions(planeDimensions);
334 for (int i = 0; i < n; ++i) {
335 SkASSERT(!planeDimensions[i].isEmpty());
336 SkASSERT(rowBytes[i]);
337 size_t size = safe.mul(rowBytes[i], planeDimensions[i].height());
338 if (planeSizes) {
339 planeSizes[i] = size;
340 }
341 totalBytes = safe.add(totalBytes, size);
342 }
343 if (planeSizes) {
344 if (safe.ok()) {
345 for (int i = n; i < kMaxPlanes; ++i) {
346 planeSizes[i] = 0;
347 }
348 } else {
349 for (int i = 0; n < kMaxPlanes; ++i) {
350 planeSizes[i] = SIZE_MAX;
351 }
352 }
353 }
354
355 return safe.ok() ? totalBytes : SIZE_MAX;
356}
size_t add(size_t x, size_t y)
Definition: SkSafeMath.h:33
bool ok() const
Definition: SkSafeMath.h:26
size_t mul(size_t x, size_t y)
Definition: SkSafeMath.h:29
static constexpr int kMaxPlanes
Definition: SkYUVAInfo.h:98
int height() const
Definition: SkYUVAInfo.h:173
int planeDimensions(SkISize planeDimensions[kMaxPlanes]) const
Definition: SkYUVAInfo.h:192
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
Definition: SkSize.h:16

◆ 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).

Definition at line 171 of file SkYUVAInfo.h.

171{ return fDimensions; }

◆ GetYUVALocations()

SkYUVAInfo::YUVALocations SkYUVAInfo::GetYUVALocations ( PlaneConfig  config,
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).

Definition at line 191 of file SkYUVAInfo.cpp.

192 {
193 // Like YUVALocation but chanIdx refers to channels by index rather than absolute channel, e.g.
194 // A is the 0th channel of an alpha-only texture. We'll use this plus planeChannelFlags to get
195 // the actual channel.
196 struct PlaneAndIndex {int plane, chanIdx;};
197 const PlaneAndIndex* planesAndIndices = nullptr;
198 switch (config) {
200 return {};
201
202 case PlaneConfig::kY_U_V: {
203 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {1, 0}, {2, 0}, {-1, -1}};
204 planesAndIndices = kPlanesAndIndices;
205 break;
206 }
207 case PlaneConfig::kY_V_U: {
208 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {2, 0}, {1, 0}, {-1, -1}};
209 planesAndIndices = kPlanesAndIndices;
210 break;
211 }
212 case PlaneConfig::kY_UV: {
213 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {1, 0}, {1, 1}, {-1, -1}};
214 planesAndIndices = kPlanesAndIndices;
215 break;
216 }
217 case PlaneConfig::kY_VU: {
218 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {1, 1}, {1, 0}, {-1, -1}};
219 planesAndIndices = kPlanesAndIndices;
220 break;
221 }
222 case PlaneConfig::kYUV: {
223 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {0, 1}, {0, 2}, {-1, -1}};
224 planesAndIndices = kPlanesAndIndices;
225 break;
226 }
227 case PlaneConfig::kUYV: {
228 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 1}, {0, 0}, {0, 2}, {-1, -1}};
229 planesAndIndices = kPlanesAndIndices;
230 break;
231 }
233 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {1, 0}, {2, 0}, {3, 0}};
234 planesAndIndices = kPlanesAndIndices;
235 break;
236 }
238 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {2, 0}, {1, 0}, {3, 0}};
239 planesAndIndices = kPlanesAndIndices;
240 break;
241 }
243 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {1, 0}, {1, 1}, {2, 0}};
244 planesAndIndices = kPlanesAndIndices;
245 break;
246 }
248 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {1, 1}, {1, 0}, {2, 0}};
249 planesAndIndices = kPlanesAndIndices;
250 break;
251 }
252 case PlaneConfig::kYUVA: {
253 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 0}, {0, 1}, {0, 2}, {0, 3}};
254 planesAndIndices = kPlanesAndIndices;
255 break;
256 }
257 case PlaneConfig::kUYVA: {
258 static constexpr PlaneAndIndex kPlanesAndIndices[] = {{0, 1}, {0, 0}, {0, 2}, {0, 3}};
259 planesAndIndices = kPlanesAndIndices;
260 break;
261 }
262 }
263 SkASSERT(planesAndIndices);
264 YUVALocations yuvaLocations;
265 for (int i = 0; i < SkYUVAInfo::kYUVAChannelCount; ++i) {
266 auto [plane, chanIdx] = planesAndIndices[i];
267 SkColorChannel channel;
268 if (plane >= 0) {
269 if (!channel_index_to_channel(planeChannelFlags[plane], chanIdx, &channel)) {
270 return {};
271 }
272 yuvaLocations[i] = {plane, channel};
273 } else {
274 SkASSERT(i == 3);
275 yuvaLocations[i] = {-1, SkColorChannel::kR};
276 }
277 }
278 return yuvaLocations;
279}
SkColorChannel
Definition: SkColor.h:228
static bool channel_index_to_channel(uint32_t channelFlags, int channelIdx, SkColorChannel *channel)
Definition: SkYUVAInfo.cpp:144
@ 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.
@ kYUVA
Plane 0: YUVA.
@ kY_V_U_A
Plane 0: Y, Plane 1: V, Plane 2: U, Plane 3: A.
@ kUYVA
Plane 0: UYVA.
@ 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::array< YUVALocation, kYUVAChannelCount > YUVALocations
Definition: SkYUVAInfo.h:32
static constexpr int kYUVAChannelCount
Definition: SkYUVAInfo.h:29

◆ hasAlpha()

bool SkYUVAInfo::hasAlpha ( ) const
inline

Definition at line 185 of file SkYUVAInfo.h.

185{ return HasAlpha(fPlaneConfig); }
static bool HasAlpha(PlaneConfig)
Definition: SkYUVAInfo.cpp:281

◆ HasAlpha()

bool SkYUVAInfo::HasAlpha ( PlaneConfig  planeConfig)
static

Does the PlaneConfig have alpha values?

Definition at line 281 of file SkYUVAInfo.cpp.

281 {
282 switch (planeConfig) {
283 case PlaneConfig::kUnknown: return false;
284
285 case PlaneConfig::kY_U_V: return false;
286 case PlaneConfig::kY_V_U: return false;
287 case PlaneConfig::kY_UV: return false;
288 case PlaneConfig::kY_VU: return false;
289 case PlaneConfig::kYUV: return false;
290 case PlaneConfig::kUYV: return false;
291
292 case PlaneConfig::kY_U_V_A: return true;
293 case PlaneConfig::kY_V_U_A: return true;
294 case PlaneConfig::kY_UV_A: return true;
295 case PlaneConfig::kY_VU_A: return true;
296 case PlaneConfig::kYUVA: return true;
297 case PlaneConfig::kUYVA: return true;
298 }
300}
#define SkUNREACHABLE
Definition: SkAssert.h:135

◆ height()

int SkYUVAInfo::height ( ) const
inline

Definition at line 173 of file SkYUVAInfo.h.

173{ return fDimensions.height(); }
constexpr int32_t height() const
Definition: SkSize.h:37

◆ isValid()

bool SkYUVAInfo::isValid ( ) const
inline

Definition at line 233 of file SkYUVAInfo.h.

233{ return fPlaneConfig != PlaneConfig::kUnknown; }

◆ makeDimensions()

SkYUVAInfo SkYUVAInfo::makeDimensions ( SkISize  dimensions) 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.

Definition at line 366 of file SkYUVAInfo.cpp.

366 {
367 return {dimensions, fPlaneConfig, fSubsampling, fYUVColorSpace, fOrigin, fSitingX, fSitingY};
368}

◆ makeSubsampling()

SkYUVAInfo SkYUVAInfo::makeSubsampling ( SkYUVAInfo::Subsampling  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.

Definition at line 362 of file SkYUVAInfo.cpp.

362 {
363 return {fDimensions, fPlaneConfig, subsampling, fYUVColorSpace, fOrigin, fSitingX, fSitingY};
364}

◆ numChannelsInPlane()

int SkYUVAInfo::numChannelsInPlane ( int  i) const
inline

Definition at line 206 of file SkYUVAInfo.h.

206{ return NumChannelsInPlane(fPlaneConfig, i); }
static constexpr int NumChannelsInPlane(PlaneConfig, int i)
Definition: SkYUVAInfo.h:272

◆ 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).

Definition at line 272 of file SkYUVAInfo.h.

272 {
273 switch (config) {
275 return 0;
276
279 return i >= 0 && i < 3 ? 1 : 0;
282 switch (i) {
283 case 0: return 1;
284 case 1: return 2;
285 default: return 0;
286 }
289 return i == 0 ? 3 : 0;
292 return i >= 0 && i < 4 ? 1 : 0;
295 switch (i) {
296 case 0: return 1;
297 case 1: return 2;
298 case 2: return 1;
299 default: return 0;
300 }
303 return i == 0 ? 4 : 0;
304 }
305 return 0;
306}

◆ numPlanes()

int SkYUVAInfo::numPlanes ( ) const
inline

Definition at line 204 of file SkYUVAInfo.h.

204{ return NumPlanes(fPlaneConfig); }
static constexpr int NumPlanes(PlaneConfig)
Definition: SkYUVAInfo.h:253

◆ NumPlanes()

constexpr int SkYUVAInfo::NumPlanes ( PlaneConfig  planeConfig)
staticconstexpr

Number of planes for a given PlaneConfig.

Definition at line 253 of file SkYUVAInfo.h.

253 {
254 switch (planeConfig) {
255 case PlaneConfig::kUnknown: return 0;
256 case PlaneConfig::kY_U_V: return 3;
257 case PlaneConfig::kY_V_U: return 3;
258 case PlaneConfig::kY_UV: return 2;
259 case PlaneConfig::kY_VU: return 2;
260 case PlaneConfig::kYUV: return 1;
261 case PlaneConfig::kUYV: return 1;
262 case PlaneConfig::kY_U_V_A: return 4;
263 case PlaneConfig::kY_V_U_A: return 4;
264 case PlaneConfig::kY_UV_A: return 3;
265 case PlaneConfig::kY_VU_A: return 3;
266 case PlaneConfig::kYUVA: return 1;
267 case PlaneConfig::kUYVA: return 1;
268 }
270}

◆ operator!=()

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

Definition at line 231 of file SkYUVAInfo.h.

231{ return !(*this == that); }

◆ operator=()

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

◆ operator==()

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

Definition at line 370 of file SkYUVAInfo.cpp.

370 {
371 return fPlaneConfig == that.fPlaneConfig &&
372 fSubsampling == that.fSubsampling &&
373 fYUVColorSpace == that.fYUVColorSpace &&
374 fDimensions == that.fDimensions &&
375 fSitingX == that.fSitingX &&
376 fSitingY == that.fSitingY &&
377 fOrigin == that.fOrigin;
378}

◆ origin()

SkEncodedOrigin SkYUVAInfo::origin ( ) const
inline

Definition at line 179 of file SkYUVAInfo.h.

179{ return fOrigin; }

◆ originMatrix()

SkMatrix SkYUVAInfo::originMatrix ( ) const
inline

Definition at line 181 of file SkYUVAInfo.h.

181 {
182 return SkEncodedOriginToMatrix(fOrigin, this->width(), this->height());
183 }
static SkMatrix SkEncodedOriginToMatrix(SkEncodedOrigin origin, int w, int h)
int width() const
Definition: SkYUVAInfo.h:172

◆ planeConfig()

PlaneConfig SkYUVAInfo::planeConfig ( ) const
inline

Definition at line 160 of file SkYUVAInfo.h.

160{ return fPlaneConfig; }

◆ PlaneDimensions()

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).

Definition at line 77 of file SkYUVAInfo.cpp.

81 {
84 return 0;
85 }
86
87 int w = imageDimensions.width();
88 int h = imageDimensions.height();
90 using std::swap;
91 swap(w, h);
92 }
93 auto down2 = [](int x) { return (x + 1)/2; };
94 auto down4 = [](int x) { return (x + 3)/4; };
95 SkISize uvSize;
96 switch (subsampling) {
98
99 case Subsampling::k444: uvSize = { w , h }; break;
100 case Subsampling::k422: uvSize = {down2(w), h }; break;
101 case Subsampling::k420: uvSize = {down2(w), down2(h)}; break;
102 case Subsampling::k440: uvSize = { w , down2(h)}; break;
103 case Subsampling::k411: uvSize = {down4(w), h }; break;
104 case Subsampling::k410: uvSize = {down4(w), down2(h)}; break;
105 }
106 switch (planeConfig) {
108
111 planeDimensions[0] = {w, h};
112 planeDimensions[1] = planeDimensions[2] = uvSize;
113 return 3;
114
117 planeDimensions[0] = {w, h};
118 planeDimensions[1] = uvSize;
119 return 2;
120
123 planeDimensions[0] = planeDimensions[3] = {w, h};
124 planeDimensions[1] = planeDimensions[2] = uvSize;
125 return 4;
126
129 planeDimensions[0] = planeDimensions[2] = {w, h};
130 planeDimensions[1] = uvSize;
131 return 3;
132
137 planeDimensions[0] = {w, h};
138 SkASSERT(planeDimensions[0] == uvSize);
139 return 1;
140 }
142}
@ kLeftTop_SkEncodedOrigin
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
@ k440
1 set of UV values for each 1x2 block of Y values.
@ k420
1 set of UV values for each 2x2 block of Y values.
@ k410
1 set of UV values for each 4x2 block of Y values.
@ k411
1 set of UV values for each 4x1 block of Y values.
@ k422
1 set of UV values for each 2x1 block of Y values.
@ k444
No subsampling. UV values for each Y.
double x
SkScalar w
SkScalar h
constexpr int32_t width() const
Definition: SkSize.h:36

◆ 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().

Definition at line 192 of file SkYUVAInfo.h.

192 {
193 return PlaneDimensions(fDimensions, fPlaneConfig, fSubsampling, fOrigin, planeDimensions);
194 }
static int PlaneDimensions(SkISize imageDimensions, PlaneConfig, Subsampling, SkEncodedOrigin, SkISize planeDimensions[kMaxPlanes])
Definition: SkYUVAInfo.cpp:77

◆ planeSubsamplingFactors()

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

Definition at line 163 of file SkYUVAInfo.h.

163 {
164 return PlaneSubsamplingFactors(fPlaneConfig, fSubsampling, planeIdx);
165 }
static std::tuple< int, int > PlaneSubsamplingFactors(PlaneConfig, Subsampling, int planeIdx)
Definition: SkYUVAInfo.cpp:42

◆ PlaneSubsamplingFactors()

std::tuple< int, int > SkYUVAInfo::PlaneSubsamplingFactors ( PlaneConfig  planeConfig,
Subsampling  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.

Definition at line 42 of file SkYUVAInfo.cpp.

44 {
46 planeIdx < 0 ||
47 planeIdx > NumPlanes(planeConfig)) {
48 return {0, 0};
49 }
50 bool isSubsampledPlane = false;
51 switch (planeConfig) {
53
58 isSubsampledPlane = planeIdx == 1 || planeIdx == 2;
59 break;
60
65 isSubsampledPlane = planeIdx == 1;
66 break;
67
72 break;
73 }
74 return isSubsampledPlane ? SubsamplingFactors(subsampling) : std::make_tuple(1, 1);
75}
static std::tuple< int, int > SubsamplingFactors(Subsampling)
Definition: SkYUVAInfo.cpp:29
Definition: ref_ptr.h:256

◆ sitingX()

Siting SkYUVAInfo::sitingX ( ) const
inline

Definition at line 176 of file SkYUVAInfo.h.

176{ return fSitingX; }

◆ sitingY()

Siting SkYUVAInfo::sitingY ( ) const
inline

Definition at line 177 of file SkYUVAInfo.h.

177{ return fSitingY; }

◆ subsampling()

Subsampling SkYUVAInfo::subsampling ( ) const
inline

Definition at line 161 of file SkYUVAInfo.h.

161{ return fSubsampling; }

◆ SubsamplingFactors()

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

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

Definition at line 29 of file SkYUVAInfo.cpp.

29 {
30 switch (subsampling) {
31 case Subsampling::kUnknown: return {0, 0};
32 case Subsampling::k444: return {1, 1};
33 case Subsampling::k422: return {2, 1};
34 case Subsampling::k420: return {2, 2};
35 case Subsampling::k440: return {1, 2};
36 case Subsampling::k411: return {4, 1};
37 case Subsampling::k410: return {4, 2};
38 }
40}

◆ toYUVALocations()

SkYUVAInfo::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).

Definition at line 358 of file SkYUVAInfo.cpp.

358 {
359 return GetYUVALocations(fPlaneConfig, channelFlags);
360}
static YUVALocations GetYUVALocations(PlaneConfig, const uint32_t *planeChannelFlags)
Definition: SkYUVAInfo.cpp:191

◆ width()

int SkYUVAInfo::width ( ) const
inline

Definition at line 172 of file SkYUVAInfo.h.

172{ return fDimensions.width(); }

◆ yuvColorSpace()

SkYUVColorSpace SkYUVAInfo::yuvColorSpace ( ) const
inline

Definition at line 175 of file SkYUVAInfo.h.

175{ return fYUVColorSpace; }

Member Data Documentation

◆ kMaxPlanes

constexpr int SkYUVAInfo::kMaxPlanes = 4
staticconstexpr

Definition at line 98 of file SkYUVAInfo.h.

◆ kYUVAChannelCount

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

Definition at line 29 of file SkYUVAInfo.h.


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