8#ifndef META_OCEAN_BASE_FRAME_H
9#define META_OCEAN_BASE_FRAME_H
96 template <DataType tDataType, u
int32_t tChannels, u
int32_t tPlanes, u
int32_t tW
idthMultiple, u
int32_t tHeightMultiple>
1174 static_assert(
sizeof(
PixelFormatProperties) ==
sizeof(std::underlying_type<PixelFormat>::type),
"Invalid helper struct!");
1255 inline unsigned int width()
const;
1261 inline unsigned int height()
const;
1293 inline unsigned int channels()
const;
1311 inline unsigned int pixels()
const;
1414 template <
typename T>
1472 template <DataType tDataType, u
int32_t tChannels, u
int32_t tPlanes = 1u, u
int32_t tW
idthMultiple = 1u, u
int32_t tHeightMultiple = 1u>
1492 template <DataType tDataType>
1514 template <
typename TDataType, u
int32_t tChannels, u
int32_t tPlanes = 1u, u
int32_t tW
idthMultiple = 1u, u
int32_t tHeightMultiple = 1u>
1535 template <
typename TDataType>
1728 static bool planeLayout(
const PixelFormat imagePixelFormat,
const unsigned int imageWidth,
const unsigned int imageHeight,
const unsigned int planeIndex,
unsigned int& planeWidth,
unsigned int& planeHeight,
unsigned int&
planeChannels,
unsigned int* planeWidthElementsMultiple =
nullptr,
unsigned int* planeHeightElementsMultiple =
nullptr);
1741 static inline bool planeLayout(
const FrameType& frameType,
const unsigned int planeIndex,
unsigned int& planeWidth,
unsigned int& planeHeight,
unsigned int&
planeChannels,
unsigned int* planeWidthElementsMultiple =
nullptr,
unsigned int* planeHeightElementsMultiple =
nullptr);
1878 template <
typename T>
2076 template <
typename T>
2088 template <
typename T>
2102 template <
typename T>
2103 inline Plane(
const T* sourceDataToCopy,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int targetPaddingElements,
const unsigned int sourcePaddingElements,
const bool makeCopyOfPaddingData =
false) noexcept;
2115 template <typename T>
2116 inline
Plane(const T* sourceDataToCopy, const
unsigned int width, const
unsigned int height, const
unsigned int channels, const
unsigned int sourcePaddingElements, const
CopyMode copyMode) noexcept;
2127 inline
unsigned int width() const;
2133 inline
unsigned int height() const;
2139 inline
unsigned int channels() const;
2146 template <typename T>
2154 template <typename T>
2227 template <typename T>
2235 inline
unsigned int size() const;
2355 Plane(const
unsigned int width, const
unsigned int height, const
unsigned int channels, const
unsigned int elementTypeSize, const
void* sourceDataToCopy, const
unsigned int targetPaddingElements, const
unsigned int sourcePaddingElements, const
bool makeCopyOfPaddingData = false) noexcept;
2376 void copy(const
void* sourceData, const
unsigned int sourceStrideBytes, const
unsigned int sourcePaddingElements, const
bool makeCopyOfPaddingData = false);
2436 template <typename T>
2463 explicit inline PlaneInitializer(
const unsigned int planePaddingElements = 0u);
2493 template <
typename T>
2501 template <
typename T,
unsigned int tChannels>
2571 template <
typename T>
2584 template <
typename T>
2594 template <
typename T>
2626 bool copy(
const Frame& source,
const bool copyTimestamp =
true);
2651 bool copy(
const int targetLeft,
const int targetTop,
const Frame& source,
const bool copyTimestamp =
true);
2674 template <
typename T>
2686 template <
typename T>
2696 template <
typename T>
2697 bool updateMemory(
const std::initializer_list<T*>& planeDatas);
2740 bool setValue(
const uint8_t value,
const unsigned int planeIndex = 0u,
const bool skipPaddingData =
true);
2762 template <
typename T, const
unsigned int tPlaneChannels>
2780 template <
typename T>
2781 bool setValue(
const T* planePixelValue,
const size_t planePixelValueSize,
const unsigned int planeIndex = 0u);
2800 template <
typename T>
2801 bool setValue(
const std::initializer_list<
typename Identity<T>::Type>& planePixelValues,
const unsigned int planeIndex = 0u);
2811 template <
typename T, const
unsigned int tPlaneChannels>
2819 inline unsigned int size(
const unsigned int planeIndex = 0u)
const;
2826 inline unsigned int paddingElements(
const unsigned int planeIndex = 0u)
const;
2833 inline unsigned int paddingBytes(
const unsigned int planeIndex = 0u)
const;
2841 inline unsigned int strideElements(
const unsigned int planeIndex = 0u)
const;
2848 inline unsigned int strideBytes(
const unsigned int planeIndex = 0u)
const;
2855 inline unsigned int planeWidth(
const unsigned int planeIndex)
const;
2862 inline unsigned int planeHeight(
const unsigned int planeIndex)
const;
2869 inline unsigned int planeChannels(
const unsigned int planeIndex)
const;
2883 inline unsigned int planeWidthBytes(
const unsigned int planeIndex)
const;
2905 inline bool isPlaneOwner(
const unsigned int planeIndex = 0u)
const;
2947 template <
typename T>
2948 inline T*
data(
const unsigned int planeIndex = 0u);
2957 template <
typename T>
2958 inline const T*
constdata(
const unsigned int planeIndex = 0u)
const;
2975 template <
typename T>
2976 inline T*
row(
const unsigned int y,
const unsigned int planeIndex = 0u);
2993 template <
typename T>
2994 inline const T*
constrow(
const unsigned int y,
const unsigned int planeIndex = 0u)
const;
3048 template <
typename T>
3049 inline T*
pixel(
const unsigned int x,
const unsigned int y,
const unsigned int planeIndex = 0u);
3073 template <
typename T>
3074 inline const T*
constpixel(
const unsigned int x,
const unsigned int y,
const unsigned int planeIndex = 0u)
const;
3112 template <
typename T>
3136 explicit inline operator bool()
const;
3230 template <
typename T>
3242 template <
typename T>
3273 ocean_assert(
false &&
"The configuration of this frame type is invalid - this should never happen!");
3295 ocean_assert(
false &&
"The configuration of this frame type is invalid - this should never happen!");
3413 return !(*
this == right);
3434 static_assert(
sizeof(char) == 1,
"Invalid data type!");
3442 static_assert(
sizeof(
signed char) == 1,
"Invalid data type!");
3449 static_assert(
sizeof(
unsigned char) == 1,
"Invalid data type!");
3456 static_assert(
sizeof(
unsigned short) == 2,
"Invalid data type!");
3463 static_assert(
sizeof(short) == 2,
"Invalid data type!");
3470 static_assert(
sizeof(
unsigned int) == 4,
"Invalid data type!");
3477 static_assert(
sizeof(int) == 4,
"Invalid data type!");
3484 static_assert(
sizeof(
unsigned long) == 4 ||
sizeof(
unsigned long) == 8,
"Invalid data type!");
3492 static_assert(
sizeof(
unsigned long) == 4 ||
sizeof(
unsigned long) == 8,
"Invalid data type!");
3500 static_assert(
sizeof(
unsigned long long) == 8,
"Invalid data type!");
3507 static_assert(
sizeof(
long long) == 8,
"Invalid data type!");
3514 static_assert(
sizeof(float) == 4,
"Invalid data type!");
3521 static_assert(
sizeof(double) == 8,
"Invalid data type!");
3525template <
typename T>
3547 ocean_assert(planes >= 1u && planes <= 255u);
3554template <FrameType::DataType tDataType, u
int32_t tChannels, u
int32_t tPlanes, u
int32_t tW
idthMultiple, u
int32_t tHeightMultiple>
3557 static_assert(uint8_t(tDataType) > uint8_t(
DT_UNDEFINED) && uint8_t(tDataType) <
DT_END,
"Invalid data type!");
3558 static_assert(tChannels >= 1u && tChannels < 31u,
"Invalid channel number!");
3559 static_assert(tPlanes >= 1u && tPlanes <= 255u,
"Invalid plane number!");
3560 static_assert(tWidthMultiple >= 1u && tWidthMultiple <= 255u,
"Invalid width-multiple!");
3561 static_assert(tHeightMultiple >= 1u && tHeightMultiple <= 255u,
"Invalid height-multiple!");
3563 return genericPixelFormat(tDataType, tChannels, tPlanes, tWidthMultiple, tHeightMultiple);
3566template <FrameType::DataType tDataType>
3569 static_assert(uint8_t(tDataType) > uint8_t(
DT_UNDEFINED) && uint8_t(tDataType) <
DT_END,
"Invalid data type!");
3574template <
typename TDataType, u
int32_t tChannels, u
int32_t tPlanes, u
int32_t tW
idthMultiple, u
int32_t tHeightMultiple>
3577 static_assert(tChannels >= 1u && tChannels < 31u,
"Invalid channel number!");
3578 static_assert(tPlanes >= 1u && tPlanes <= 255u,
"Invalid plane number!");
3579 static_assert(tWidthMultiple >= 1u && tWidthMultiple <= 255u,
"Invalid width-multiple!");
3580 static_assert(tHeightMultiple >= 1u && tHeightMultiple <= 255u,
"Invalid height-multiple!");
3583 static_assert(uint8_t(pixelFormatDataType) > uint8_t(
DT_UNDEFINED) && uint8_t(pixelFormatDataType) <
DT_END,
"Invalid data type!");
3585 return genericPixelFormat(pixelFormatDataType, tChannels, tPlanes, tWidthMultiple, tHeightMultiple);
3588template <
typename TDataType>
3592 static_assert(uint8_t(pixelFormatDataType) > uint8_t(
DT_UNDEFINED) && uint8_t(pixelFormatDataType) <
DT_END,
"Invalid data type!");
3595 ocean_assert(planes >= 1u && planes <= 255u);
3604 static_assert(std::is_same<std::underlying_type<PixelFormat>::type, uint64_t>::value,
"Invalid pixel format data type!");
3621 static_assert(std::is_same<std::underlying_type<PixelFormat>::type, uint64_t>::value,
"Invalid pixel format data type!");
3638 unsigned int planeWidthDummy;
3639 unsigned int planeHeightDummy;
3643 unsigned int planeWidthElementsMultiple;
3644 unsigned int planeHeightElementsMultiple;
3648 ocean_assert(
planeChannels >= 1u && planeWidthElementsMultiple >= 1u && planeHeightElementsMultiple >= 1u);
3650 if (planeWidthElementsMultiple != 1u || planeHeightElementsMultiple != 1u)
3660 ocean_assert(
false &&
"Invalid input!");
3665inline bool FrameType::planeLayout(
const FrameType& frameType,
const unsigned int planeIndex,
unsigned int& planeWidth,
unsigned int& planeHeight,
unsigned int&
planeChannels,
unsigned int* planeWidthElementsMultiple,
unsigned int* planeHeightElementsMultiple)
3667 ocean_assert(frameType.
isValid());
3672template <
typename T>
3675 ocean_assert(data !=
nullptr);
3676 return size_t(data) %
sizeof(T) ==
size_t(0);
3681 return valueA <= (
unsigned int)(-1) - valueB;
3686 return valueB == 0u || valueA <= (
unsigned int)(-1) / valueB;
3691 *
this = std::move(plane);
3694template <
typename T>
3701template <
typename T>
3708template <
typename T>
3709inline Frame::Plane::Plane(
const T* sourceDataToCopy,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int targetPaddingElements,
const unsigned int sourcePaddingElements,
const bool makeCopyOfPaddingData) noexcept :
3710 Plane(
width,
height,
channels,
sizeof(T), (
const void*)(sourceDataToCopy), targetPaddingElements, sourcePaddingElements, makeCopyOfPaddingData)
3715template <
typename T>
3756template <
typename T>
3759 return reinterpret_cast<const T*
>(
constData_);
3762template <
typename T>
3765 return reinterpret_cast<T*
>(
data_);
3819template <
typename T>
3844 return data_ ==
nullptr;
3873 const unsigned int planeStrideBytes = planeStrideElements * bytesPerElement;
3890template <
typename T>
3900template <
typename T>
3910template <
typename T>
3920template <
typename T>
3924 planeInitializers.reserve(paddingElementsPerPlane.size());
3931 return planeInitializers;
3944 *
this = std::move(frame);
3946 ocean_assert(
planes_.size() >= 1);
3947 ocean_assert(frame.planes_.size() == 1);
3953 ocean_assert(
frameType.numberPlanes() == planePaddingElements.size() || planePaddingElements.empty());
3960 ocean_assert(
frameType.numberPlanes() == 1u);
3961 ocean_assert(
planes_.size() == 1);
3970 ocean_assert(
frameType.numberPlanes() == 1u);
3971 ocean_assert(
planes_.size() == 1);
3974template <
typename T>
3983 ocean_assert(debugTemplateDataType ==
FrameType::DT_UNDEFINED || debugTemplateDataType == debugFrameTypeDataType);
3986 ocean_assert(
planes_.size() == 1);
3995 ocean_assert(
frameType.numberPlanes() == 1u);
3996 ocean_assert(
planes_.size() == 1);
3999template <
typename T>
4008 ocean_assert(debugTemplateDataType ==
FrameType::DT_UNDEFINED || debugTemplateDataType == debugFrameTypeDataType);
4011 ocean_assert(
planes_.size() == 1);
4014template <
typename T>
4023 ocean_assert(debugTemplateDataType ==
FrameType::DT_UNDEFINED || debugTemplateDataType == debugFrameTypeDataType);
4039template <
typename T>
4042 ocean_assert(
data !=
nullptr);
4043 if (
data !=
nullptr)
4045 ocean_assert(planeIndex <
planes_.size());
4046 if (planeIndex <
planes_.size())
4050 if constexpr (!std::is_void_v<T>)
4059 plane.
data_ =
nullptr;
4069template <
typename T>
4072 ocean_assert(
data !=
nullptr);
4073 if (
data !=
nullptr)
4075 ocean_assert(planeIndex <
planes_.size());
4076 if (planeIndex <
planes_.size())
4080 if constexpr (!std::is_void_v<T>)
4099template <
typename T>
4102 ocean_assert(planeDatas.size() != 0);
4103 ocean_assert(planeDatas.size() <=
planes_.size());
4105 if (planeDatas.size() == 0 || planeDatas.size() >
planes_.size())
4110 for (
unsigned int planeIndex = 0u; planeIndex < planeDatas.size(); ++planeIndex)
4112 if (!
updateMemory(planeDatas.begin()[planeIndex], planeIndex))
4121template <
typename T, const
unsigned int tPlaneChannels>
4124 static_assert(!std::is_void_v<T>,
"Value access/assignment cannot be performed with void types.");
4126 ocean_assert(
planes_.size() >= 1);
4127 ocean_assert(planeIndex <
planes_.size());
4131 ocean_assert(plane.
isValid());
4135 ocean_assert(
false &&
"The specified data type must fit to the frame's data type!");
4139 if (plane.
channels() != tPlaneChannels)
4141 ocean_assert(
false &&
"The specified number of channels does not fit with the plane's actual channels!");
4154 for (
unsigned int n = 0u; n < plane.
width() * plane.
height(); ++n)
4156 data[n] = planePixelValue;
4161 const unsigned int planeStrideBytes = plane.
strideBytes();
4163 for (
unsigned int y = 0u; y < plane.
height(); ++y)
4167 for (
unsigned int x = 0u; x < plane.
width(); ++x)
4169 data[x] = planePixelValue;
4177template <
typename T, const
unsigned int tPlaneChannels>
4180 static_assert(!std::is_void_v<T>,
"Value access/comparison cannot be performed with void types.");
4182 ocean_assert(
planes_.size() >= 1);
4183 ocean_assert(planeIndex <
planes_.size());
4187 ocean_assert(plane.
isValid());
4191 ocean_assert(
false &&
"The specified data type must fit to the frame's data type!");
4195 if (plane.
channels() != tPlaneChannels)
4197 ocean_assert(
false &&
"The specified number of channels does not fit with the plane's actual channels!");
4201 const unsigned int planeStrideBytes = plane.
strideBytes();
4203 for (
unsigned int y = 0u; y < plane.
height(); ++y)
4207 for (
unsigned int x = 0u; x < plane.
width(); ++x)
4209 if (
data[x] == planePixelValue)
4219template <
typename T>
4220bool Frame::setValue(
const T* planePixelValue,
const size_t planePixelValueSize,
const unsigned int planeIndex)
4222 static_assert(!std::is_void_v<T>,
"Value access/assignment cannot be performed with void types.");
4224 ocean_assert(planePixelValue !=
nullptr);
4226 ocean_assert(
planes_[planeIndex].elementTypeSize() ==
sizeof(T));
4229 switch (planePixelValueSize)
4281 ocean_assert(
false &&
"The number of channels is not supported");
4285template <
typename T>
4288 return setValue<T>(planePixelValues.begin(), planePixelValues.size(), planeIndex);
4293 ocean_assert(
planes_.size() >= 1);
4294 ocean_assert(planeIndex <
planes_.size());
4296 return planes_[planeIndex].size();
4301 ocean_assert(
planes_.size() >= 1);
4302 ocean_assert(planeIndex <
planes_.size());
4304 return planes_[planeIndex].paddingElements();
4309 ocean_assert(
planes_.size() >= 1);
4310 ocean_assert(planeIndex <
planes_.size());
4312 return planes_[planeIndex].paddingBytes();
4317 ocean_assert(
planes_.size() >= 1);
4318 ocean_assert(planeIndex <
planes_.size());
4320 return planes_[planeIndex].strideElements();
4325 ocean_assert(
planes_.size() >= 1);
4326 ocean_assert(planeIndex <
planes_.size());
4328 return planes_[planeIndex].strideBytes();
4333 ocean_assert(
planes_.size() >= 1);
4334 ocean_assert(planeIndex <
planes_.size());
4336 return planes_[planeIndex].width();
4341 ocean_assert(
planes_.size() >= 1);
4342 ocean_assert(planeIndex <
planes_.size());
4344 return planes_[planeIndex].height();
4349 ocean_assert(
planes_.size() >= 1);
4350 ocean_assert(planeIndex <
planes_.size());
4352 return planes_[planeIndex].channels();
4357 ocean_assert(
planes_.size() >= 1);
4358 ocean_assert(planeIndex <
planes_.size());
4360 return planes_[planeIndex].widthElements();
4365 ocean_assert(
planes_.size() >= 1);
4366 ocean_assert(planeIndex <
planes_.size());
4368 return planes_[planeIndex].widthBytes();
4373 ocean_assert(
planes_.size() >= 1);
4374 ocean_assert(planeIndex <
planes_.size());
4381 ocean_assert(
planes_.size() >= 1);
4382 ocean_assert(planeIndex <
planes_.size());
4384 return planes_[planeIndex].isContinuous();
4389 ocean_assert(
planes_.size() >= 1);
4390 ocean_assert(planeIndex <
planes_.size());
4392 return planes_[planeIndex].isOwner();
4415template <
typename T>
4418 ocean_assert(
planes_.size() >= 1);
4419 ocean_assert(planeIndex <
planes_.size());
4421 return planes_[planeIndex].data<T>();
4424template <
typename T>
4427 ocean_assert(
planes_.size() >= 1);
4428 ocean_assert(planeIndex <
planes_.size());
4430 return planes_[planeIndex].constdata<T>();
4433template <
typename T>
4434inline T*
Frame::row(
const unsigned int y,
const unsigned int planeIndex)
4437 ocean_assert(y <
height());
4439 ocean_assert(
planes_.size() >= 1);
4440 ocean_assert(planeIndex <
planes_.size());
4443 ocean_assert(plane.
isValid());
4445 ocean_assert(y < plane.
height());
4446 return reinterpret_cast<T*
>(plane.
data<uint8_t>() + y * plane.
strideBytes());
4449template <
typename T>
4453 ocean_assert(y <
height());
4455 ocean_assert(
planes_.size() >= 1);
4456 ocean_assert(planeIndex <
planes_.size());
4459 ocean_assert(plane.
isValid());
4461 ocean_assert(y < plane.
height());
4465template <
typename T>
4466inline T*
Frame::pixel(
const unsigned int x,
const unsigned int y,
const unsigned int planeIndex)
4472 ocean_assert(
planes_.size() >= 1);
4473 ocean_assert(planeIndex <
planes_.size());
4476 ocean_assert(plane.
isValid());
4478 if constexpr (!std::is_void_v<T>)
4502 ocean_assert(y < plane.
height());
4503 return reinterpret_cast<T*
>(plane.
data<uint8_t>() + y * plane.
strideBytes() + xBytes);
4506template <
typename T>
4507inline const T*
Frame::constpixel(
const unsigned int x,
const unsigned int y,
const unsigned int planeIndex)
const
4513 ocean_assert(
planes_.size() >= 1);
4514 ocean_assert(planeIndex <
planes_.size());
4517 ocean_assert(plane.
isValid());
4519 if constexpr (!std::is_void_v<T>)
4529 ocean_assert(y < plane.
height());
4530 return reinterpret_cast<const T*
>(plane.
constdata<uint8_t>() + y * plane.
strideBytes() + xBytes);
4535 ocean_assert(
planes_.size() >= 1);
4539 if (!plane.isContinuous())
4550 ocean_assert(
planes_.size() >= 1);
4554 if (!plane.isOwner())
4565 ocean_assert(
planes_.size() >= 1);
4569 if (plane.isReadOnly())
4597 ocean_assert(
false &&
"Data type does not fit with the frame's data type!");
4603 for (
unsigned int y = 0u; y <
height(); ++y)
4607 for (
unsigned int x = 0u; x <
width(); ++x)
4624 for (
unsigned int y = 0u; y <
height(); ++y)
4628 for (
unsigned int x = 0u; x <
width(); ++x)
4655 ocean_assert(
false &&
"Data type does not fit with the frame's data type!");
4661 for (
unsigned int y = 0u; y <
height(); ++y)
4665 for (
unsigned int x = 0u; x <
width(); ++x)
4680 for (
unsigned int y = 0u; y <
height(); ++y)
4684 for (
unsigned int x = 0u; x <
width(); ++x)
4686 if ((*
row & opaque) != opaque)
4699template <
typename T>
4707 ocean_assert(
planes_.size() >= 1);
4715 size_t debugValidPlanes = 0;
4719 if (plane.isValid())
4725 const bool debugIsValid = !
planes_.isEmpty() && debugValidPlanes ==
planes_.size();
4727 ocean_assert(debugIsValid == frameTypeIsValid);
4731 return frameTypeIsValid;
4734inline Frame::operator bool()
const
Template class allowing to define an array of data types.
Definition DataType.h:27
Definition of an image plane, a block of memory storing pixel data with interleaved channels (or just...
Definition Frame.h:2034
unsigned int width() const
Returns the width of the plane in pixel.
Definition Frame.h:3741
bool isCompatibleWithDataType() const
Returns whether this plane is compatible with a given element data type.
Definition Frame.h:3820
unsigned int paddingElements() const
Returns the number of padding elements at the end of each plane row, in elements.
Definition Frame.h:3768
void * allocatedData_
The pointer to the memory which this plane has allocated, this pointer is pointing to the memory whic...
Definition Frame.h:2393
unsigned int paddingBytes() const
Returns the number of padding bytes at the end of each plane row, in bytes.
Definition Frame.h:3773
unsigned int allocatedCapacity_
The usable capacity of the allocated buffer in bytes, used for buffer reuse when sizes differ but the...
Definition Frame.h:2396
unsigned int elementTypeSize() const
Returns the size of each element of this plane.
Definition Frame.h:3778
unsigned int bytesPerPixel_
The number of bytes per pixel, with range [1, infinity), 0 if unknown.
Definition Frame.h:2423
bool isOwner() const
Returns whether this plane is the owner of the memory.
Definition Frame.h:3837
unsigned int height_
The height of the plane in pixel, with range [0, infinity).
Definition Frame.h:2408
unsigned int calculateStrideBytes() const
Calculates the number of bytes between the start positions of two consecutive rows,...
Definition Frame.h:3883
bool copy(const Plane &sourcePlane, const AdvancedCopyMode advancedCopyMode=ACM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA, const bool reallocateIfNecessary=true)
Copies data from another plane into this plane.
void * data_
The pointer to the writable memory of the plane (not the pointer to the allocated memory),...
Definition Frame.h:2402
unsigned int strideBytes() const
Returns the number of bytes between the start positions of two consecutive rows, in bytes.
Definition Frame.h:3804
bool isContinuous() const
Returns whether this plane is based on continuous memory and thus does not have any padding at the en...
Definition Frame.h:3832
Plane(const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int elementTypeSize, const unsigned int paddingElements) noexcept
Creates a new plane object with own allocated memory.
const T * constdata() const
Returns the read-only memory pointer to this plane with a specific data type compatible with elementT...
Definition Frame.h:3757
bool isValid() const
Returns whether this plane holds valid data.
Definition Frame.h:3847
T * data()
Returns the writable memory pointer to this plane with a specific data type compatible with elementTy...
Definition Frame.h:3763
bool isReadOnly() const
Returns whether this plane holds read-only memory.
Definition Frame.h:3842
unsigned int calculateBytesPerPixel() const
Calculates the number of bytes per pixel.
unsigned int size() const
Returns the number of bytes necessary for the entire plane data including optional padding elements a...
Definition Frame.h:3825
static constexpr bool validateMemoryLayout(const unsigned int planeWidth, const unsigned int planeHeight, const unsigned int planeChannels, const unsigned int bytesPerElement, const unsigned int paddingElements)
Returns whether the memory layout of a plane is valid (and fits into the memory).
Definition Frame.h:3852
unsigned int width_
The width of the plane in pixel, with range [0, infinity).
Definition Frame.h:2405
unsigned int widthBytes() const
Returns the width of the plane in bytes, the width does not contain optional padding elements.
Definition Frame.h:3790
~Plane()
Destructs a Plane object.
Definition Frame.h:3736
unsigned int strideBytes_
The number of bytes between the start positions of two consecutive rows, in bytes,...
Definition Frame.h:2420
Plane()=default
Creates a new invalid plane.
unsigned int channels_
The number of channels the plane has, with range [0, infinity).
Definition Frame.h:2411
unsigned int channels() const
Returns the channels of the plane.
Definition Frame.h:3751
unsigned int elementTypeSize_
The size of each element of this plane, in bytes, with range [0, infinity).
Definition Frame.h:2414
const void * constData_
The pointer to the read-only memory of the plane (not the pointer to the allocated memory),...
Definition Frame.h:2399
unsigned int bytesPerPixel() const
Returns the number of bytes which is used for each pixel.
Definition Frame.h:3812
void release()
Releases this plane and all resources of this plane.
unsigned int strideElements() const
Returns the number of elements between the start positions of two consecutive rows,...
Definition Frame.h:3797
Plane(const Plane &plane, const AdvancedCopyMode advancedCopyMode=ACM_USE_OR_COPY_KEEP_LAYOUT) noexcept
Copy constructor.
static void * alignedMemory(const size_t size, const size_t alignment, void *&alignedData)
Allocates memory with specific byte alignment.
friend class Frame
Definition Frame.h:2035
unsigned int height() const
Returns the height of the plane in pixel.
Definition Frame.h:3746
unsigned int paddingElements_
The number of padding elements at the end of each plane row, in elements, with range [0,...
Definition Frame.h:2417
unsigned int widthElements() const
Returns the width of the plane in elements, the width does not contain optional padding elements.
Definition Frame.h:3783
This class implements a helper class which can be used to initialize a multi-plane frame in the const...
Definition Frame.h:2438
T * data_
The pointer to the writable source memory, can be nullptr.
Definition Frame.h:2480
PlaneInitializer(const T *constdata, const CopyMode copyMode, const unsigned int dataPaddingElements=0u)
Creates a new initializer object for a read-only memory pointer.
Definition Frame.h:3891
static std::vector< PlaneInitializer< T > > createPlaneInitializersWithPaddingElements(const Indices32 &paddingElementsPerPlane)
Creates plane initializer objects with padding elements only.
Definition Frame.h:3921
CopyMode copyMode_
The copy mode to be applied, unused if constdata_ == nullptr and data_ == nullptr.
Definition Frame.h:2483
unsigned int paddingElements_
If a valid memory pointer is provided, the number of padding elements at the end of each source memor...
Definition Frame.h:2486
const T * constdata_
The pointer to the read-only source memory, can be nullptr.
Definition Frame.h:2477
friend class Frame
Definition Frame.h:2439
This class implements Ocean's image class.
Definition Frame.h:1969
bool copy(const int targetLeft, const int targetTop, const Frame &source, const bool copyTimestamp=true)
Copies the entire image content of a source frame into this frame.
static bool strideBytes2paddingElements(const PixelFormat &pixelFormat, const unsigned int imageWidth, const unsigned int planeStrideBytes, unsigned int &planePaddingElements, const unsigned int planeIndex=0u)
Determines the number of padding elements at the end of a row of a plane for which the pixel format,...
Frame(const FrameType &frameType, const CopyMode copyMode)=delete
Deleted constructor to prevent misuse.
typename Ocean::DataType< T, tChannels >::Type PixelType
Definition of a data type storing all channel values of one pixel in an array.
Definition Frame.h:2502
Timestamp relativeTimestamp_
Relative timestamp of this frame.
Definition Frame.h:3254
bool isContinuous() const
Returns whether all planes of this frame have continuous memory and thus do not contain any padding a...
Definition Frame.h:4533
bool hasAlphaChannel() const
Returns whether the frame's pixel format contains an alpha channel.
Definition Frame.h:4578
Frame(const FrameType &frameType, const AdvancedCopyMode advancedCopyMode)=delete
Deleted constructor to prevent misuse.
Frame(const FrameType &frameType, const PlaneInitializer< void > *planeInitializers, size_t sizePlaneInitializers, const Timestamp ×tamp=Timestamp(false))
Creates a new multi-plane frame with known frame type and given source memory for each individual pla...
unsigned int strideBytes(const unsigned int planeIndex=0u) const
Returns the number of bytes within one row, including optional padding at the end of a row for a spec...
Definition Frame.h:4323
bool haveIntersectingMemory(const Frame &frame) const
Returns whether two frame objects have any amount of intersecting memory.
Timestamp timestamp_
Timestamp of the frame.
Definition Frame.h:3251
unsigned int strideElements(const unsigned int planeIndex=0u) const
Returns the number of elements within one row, including optional padding at the end of a row for a s...
Definition Frame.h:4315
T * row(const unsigned int y, const unsigned int planeIndex=0u)
Returns the pointer to the pixel data of a specific row.
Definition Frame.h:4434
bool updateMemory(const T *data, const unsigned int planeIndex=0u)
Updates the memory pointer for a specific plane of the frame to a new read-only memory location.
Definition Frame.h:4040
Frame subFrame(const unsigned int subFrameLeft, const unsigned int subFrameTop, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const CopyMode copyMode=CM_USE_KEEP_LAYOUT) const
Returns a sub-frame of this frame.
const T * constdata(const unsigned int planeIndex=0u) const
Returns a pointer to the read-only pixel data of a specific plane.
Definition Frame.h:4425
void setRelativeTimestamp(const Timestamp &relative)
Sets the relative timestamp of this frame.
Definition Frame.h:4410
const FrameType & frameType() const
Returns the frame type of this frame.
Definition Frame.h:4029
Frame(const Frame &frame)
Creates a second version of a given frame.
T * data(const unsigned int planeIndex=0u)
Returns a pointer to the pixel data of a specific plane.
Definition Frame.h:4416
bool isValid() const
Returns whether this frame is valid.
Definition Frame.h:4705
Frame(const FrameType &frameType, const T *data, const bool copyData, const unsigned int paddingElements=0u, const Timestamp ×tamp=Timestamp(false))=delete
Deleted constructor to prevent misuse, use Frame(const FrameType& frameType, const T* data,...
T * pixel(const unsigned int x, const unsigned int y, const unsigned int planeIndex=0u)
Returns the pointer to the data of a specific pixel.
Definition Frame.h:4466
void setTimestamp(const Timestamp ×tamp)
Sets the timestamp of this frame.
Definition Frame.h:4405
bool isReadOnly() const
Returns true, if the frame allows only read access (using constdata()).
Definition Frame.h:4563
Frame(const Frame &frame, const Timestamp ×tamp)=delete
Deleted constructor to prevent misuse.
bool copy(const Frame &source, const bool copyTimestamp=true)
Deprecated.
Frame(const Frame &frame, const bool copyData)=delete
Deleted constructor to prevent misuse.
bool set(const FrameType &frameType, const bool forceOwner, const bool forceWritable=false, const Indices32 &planePaddingElements=Indices32(), const Timestamp ×tamp=Timestamp(false), bool *reallocated=nullptr)
Sets a new frame type for this frame.
Frame & operator=(Frame &&right) noexcept
Move operator.
const Timestamp & timestamp() const
Returns the timestamp of this frame.
Definition Frame.h:4395
unsigned int planeBytesPerPixel(const unsigned int planeIndex) const
Returns the number of bytes of one pixel of a plane for a pixel format.
Definition Frame.h:4371
unsigned int planeWidthElements(const unsigned int planeIndex) const
Returns the width of a plane of this frame, not in pixel, but in elements, not including padding at t...
Definition Frame.h:4355
const Timestamp & relativeTimestamp() const
Returns the relative timestamp of this frame.
Definition Frame.h:4400
const Planes & planes() const
Returns the individual planes of this frame.
Definition Frame.h:4034
bool isOwner() const
Returns whether the frame is the owner of the internal frame data.
Definition Frame.h:4548
CopyMode
Definition of individual copy modes.
Definition Frame.h:1976
@ CM_USE_KEEP_LAYOUT
The source memory is used only, no copy is created, the padding layout is preserved.
Definition Frame.h:1978
@ CM_COPY_KEEP_LAYOUT_COPY_PADDING_DATA
Makes a copy of the source memory, the padding layout is preserved, the padding data is copied as wel...
Definition Frame.h:1984
@ CM_COPY_REMOVE_PADDING_LAYOUT
Makes a copy of the source memory, but the new plane will not contain padding elements.
Definition Frame.h:1980
@ CM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA
Makes a copy of the source memory, the padding layout is preserved, but the padding data is not copie...
Definition Frame.h:1982
StackHeapVector< Plane, 4 > Planes
Definition of a vector storing planes.
Definition Frame.h:2429
unsigned int planeChannels(const unsigned int planeIndex) const
Returns the channels of a plane of this frame.
Definition Frame.h:4347
std::vector< PlaneInitializer< T > > PlaneInitializers
Definition of a vector holding plane initializer objects.
Definition Frame.h:2494
unsigned int planeWidth(const unsigned int planeIndex) const
Returns the width of a plane of this frame.
Definition Frame.h:4331
void release()
Releases this frame and the frame data if this frame is the owner.
Frame(const Frame &frame, const AdvancedCopyMode advancedCopyMode) noexcept
Creates a second version of a given frame.
Frame()
Creates an empty frame.
Definition Frame.h:3934
const T * constpixel(const unsigned int x, const unsigned int y, const unsigned int planeIndex=0u) const
Returns the pointer to the constant data of a specific pixel.
Definition Frame.h:4507
Frame(const FrameType &frameType, T *data, const bool copyData, const unsigned int paddingElements=0u, const Timestamp ×tamp=Timestamp(false))=delete
Deleted constructor to prevent misuse, use Frame(const FrameType& frameType, T* data,...
~Frame()
Destructs a frame.
void makeOwner()
Makes this frame the owner of the memory.
Frame(const FrameType &frameType, const Timestamp ×tamp)=delete
Deleted constructor to prevent misuse.
AdvancedCopyMode
Definition of advanced copy modes containing all copy modes from CopyMode but also some additional.
Definition Frame.h:1991
@ ACM_COPY_REMOVE_PADDING_LAYOUT
Same as CM_COPY_REMOVE_PADDING_LAYOUT.
Definition Frame.h:1995
@ ACM_USE_KEEP_LAYOUT
Same as CM_USE_KEEP_LAYOUT.
Definition Frame.h:1993
@ ACM_COPY_KEEP_LAYOUT_COPY_PADDING_DATA
Same as CM_COPY_KEEP_LAYOUT_COPY_PADDING_DATA.
Definition Frame.h:1999
@ ACM_USE_OR_COPY_KEEP_LAYOUT
The source memory is used if the source is not owner of the memory; The source memory is copied if th...
Definition Frame.h:2004
@ ACM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA
Same as CM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA.
Definition Frame.h:1997
@ ACM_USE_OR_COPY
The source memory is used if the source is not owner of the memory; The source memory is copied if th...
Definition Frame.h:2002
Frame(const Frame &frame, const CopyMode copyMode)=delete
Deleted constructor to prevent misuse, use AdvancedCopyMode instead.
bool isPlaneContinuous(const unsigned int planeIndex=0u) const
Returns whether a specific plane of this frame is based on continuous memory and thus does not have a...
Definition Frame.h:4379
bool containsValue(const PixelType< T, tPlaneChannels > &planePixelValue, const unsigned int planeIndex=0u) const
Returns whether the frame (one plane) contains a specified pixel value.
Definition Frame.h:4178
bool setValue(const uint8_t value, const unsigned int planeIndex=0u, const bool skipPaddingData=true)
Sets the memory of the frame to a specified byte value (the memory of one plane).
bool isPlaneOwner(const unsigned int planeIndex=0u) const
Returns whether a specific plane of this frame is the owner of the memory.
Definition Frame.h:4387
unsigned int paddingBytes(const unsigned int planeIndex=0u) const
Returns the optional number of padding bytes at the end of each row for a specific plane.
Definition Frame.h:4307
const T * constrow(const unsigned int y, const unsigned int planeIndex=0u) const
Returns the pointer to the constant data of a specific row.
Definition Frame.h:4450
void makeContinuous()
Makes the memory of this frame continuous.
unsigned int planeWidthBytes(const unsigned int planeIndex) const
Returns the width of a plane of this frame, not in pixel, but in bytes, not including padding at the ...
Definition Frame.h:4363
bool hasTransparentPixel(const T opaque) const
Returns whether the frame holds at least one pixel with an non opaque alpha value.
Definition Frame.h:4700
Frame & operator=(const Frame &right) noexcept
Assign operator.
unsigned int planeHeight(const unsigned int planeIndex) const
Returns the height of a plane of this frame.
Definition Frame.h:4339
unsigned int size(const unsigned int planeIndex=0u) const
Returns the number of bytes necessary for a specific plane including optional padding at the end of p...
Definition Frame.h:4291
Planes planes_
The individual memory planes of this frame.
Definition Frame.h:3248
unsigned int paddingElements(const unsigned int planeIndex=0u) const
Returns the optional number of padding elements at the end of each row for a specific plane.
Definition Frame.h:4299
static unsigned int widthMultiple(const PixelFormat pixelFormat)
Returns the number of pixels the width of a frame must be a multiple of.
Definition Frame.h:3626
static PixelFormat translatePixelFormat(const std::string &pixelFormat)
Translates a string containing a pixel format into the pixel format.
static PixelFormat genericPixelFormat(const unsigned int bitsPerPixelChannel, const uint32_t channels, const uint32_t planes=1u, const uint32_t widthMultiple=1u, const uint32_t heightMultiple=1u)
Returns a specific generic pixel format with specified bit per pixel per channel, channel number,...
static unsigned int bytesPerDataType(const DataType dataType)
Returns the number of bytes which are necessary to store a specified data type.
bool operator==(const FrameType &right) const
Returns whether two frame types are equal.
unsigned int pixels() const
Returns the number of pixels for the frame.
Definition Frame.h:3384
FrameType()=default
Creates a new frame type with invalid parameters.
static unsigned int formatBitsPerPixelGreenChannel(const PixelFormat pixelFormat)
Returns the number of bits of one pixel for the green channel.
static constexpr uint32_t pixelFormatBitOffsetChannels
The number of bits the channel value is shifted within the PixelFormat value.
Definition Frame.h:74
static PixelFormat findPixelFormat(const DataType dataType, const unsigned int channels)
Returns a best fitting pixel format having the given number of bits per pixels.
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
@ FORMAT_YA16
Pixel format with byte order YA and 16 bits per pixel.
Definition Frame.h:651
@ FORMAT_Y_U_V24
This pixel format is deprecated and is currently an alias for FORMAT_Y_U_V24_LIMITED_RANGE.
Definition Frame.h:695
@ FORMAT_END
The helper pixel format which can be used to identify the last defined pixel format,...
Definition Frame.h:1124
@ FORMAT_BGR24
Pixel format with byte order BGR and 24 bits per pixel.
Definition Frame.h:226
@ FORMAT_BGRA4444
Pixel format with entirely 16 bits per pixel, 4 bits for each channel.
Definition Frame.h:282
@ FORMAT_RGB565
Pixel format with entirely 16 bits per pixel, 5 bits for red, 6 bits for green and 5 bits for blue.
Definition Frame.h:367
@ FORMAT_Y_U_V24_FULL_RANGE
Pixel format with 8 bits Y frame as individual block, followed by 8 bits U frame as individual block,...
Definition Frame.h:745
@ FORMAT_YUV24_FULL_RANGE
Pixel format with byte order YUV and 24 bits per pixel.
Definition Frame.h:1075
@ FORMAT_Y16
Pixel format with 16 bits Y frame.
Definition Frame.h:636
@ FORMAT_UNDEFINED
Undefined pixel format.
Definition Frame.h:187
@ FORMAT_RGBA64
Pixel format with byte order RGBA and 64 bits per pixel, with 16 bit per component.
Definition Frame.h:677
@ FORMAT_Y64
Pixel format with 64 bits Y frame.
Definition Frame.h:646
@ FORMAT_RGBT32
Pixel format with byte order RGBT and 24 bits for the RGB channels and 8 bits for an arbitrary textur...
Definition Frame.h:408
@ FORMAT_RGBA4444
Pixel format with entirely 16 bits per pixel, 4 bits for each channel.
Definition Frame.h:395
@ FORMAT_UYVY16
Pixel format with 8 bit Y pixel values zipped (interleaved) with 8 bits 2x1 (horizontal) sub-sampled ...
Definition Frame.h:583
@ FORMAT_BGR5551
Pixel format with entirely 16 bits per pixel, 15 bits for BGR and 1 unused bit.
Definition Frame.h:249
@ FORMAT_YUV24
This pixel format is deprecated and is currently an alias for FORMAT_YUV24_LIMITED_RANGE.
Definition Frame.h:460
@ FORMAT_F32
Pixel format for a frame with one channel and 32 bit floating point precision per element.
Definition Frame.h:994
@ FORMAT_Y_U_V12
Pixel format with 8 bits Y frame as individual block, followed by 8 bits 2x2 sub-sampled U frame and ...
Definition Frame.h:446
@ FORMAT_Y_UV12_LIMITED_RANGE
Pixel format with 8 bits Y frame as entire block, followed by 8 bits 2x2 sub-sampled U and V zipped (...
Definition Frame.h:810
@ FORMAT_BGR32
Pixel format with byte order BGR and 24 bits per pixel and 8 unused bits.
Definition Frame.h:239
@ FORMAT_Y_VU12
Pixel format with 8 bits Y frame as entire block, followed by 8 bits 2x2 sub-sampled V and U zipped (...
Definition Frame.h:547
@ FORMAT_YVU24_LIMITED_RANGE
Pixel format with byte order YVU and 24 bits per pixel.
Definition Frame.h:1097
@ FORMAT_B_G_R24
Pixel format with 8 bits B frame as individual block, followed by 8 bits G frame as individual block,...
Definition Frame.h:1031
@ FORMAT_ARGB32
Pixel format with byte order ARGB and 32 bits per pixel.
Definition Frame.h:213
@ FORMAT_Y8_LIMITED_RANGE
Pixel format for grayscale images with byte order Y and 8 bits per pixel (with limited range).
Definition Frame.h:765
@ FORMAT_R_G_B24
Pixel format with 8 bits R frame as individual block, followed by 8 bits G frame as individual block,...
Definition Frame.h:1015
@ FORMAT_Y_U_V12_LIMITED_RANGE
Pixel format with 8 bits Y frame as individual block, followed by 8 bits 2x2 sub-sampled U frame and ...
Definition Frame.h:912
@ FORMAT_RGB32
Pixel format with byte order RGB and 24 bits per pixel and 8 unused bits.
Definition Frame.h:328
@ FORMAT_Y32
Pixel format with 32 bits Y frame.
Definition Frame.h:641
@ FORMAT_Y_UV12_FULL_RANGE
Pixel format with 8 bits Y frame as entire block, followed by 8 bits 2x2 sub-sampled U and V zipped (...
Definition Frame.h:836
@ FORMAT_Y10
Pixel format with byte order Y and 10 bits per pixel, the upper 6 bits are unused.
Definition Frame.h:609
@ FORMAT_ABGR32
Pixel format with byte order ABGR and 32 bits per pixel.
Definition Frame.h:200
@ FORMAT_RGB48
Pixel format with byte order RGB and 48 bits per pixel, with 16 bit per component.
Definition Frame.h:664
@ FORMAT_YUVT32
Pixel format with byte order YUVA and 24 bits for the YUV channels and 8 bit for an arbitrary texture...
Definition Frame.h:478
@ FORMAT_BGR4444
Pixel format with entirely 16 bits per pixel, 12 bits for BGR and 4 unused bits.
Definition Frame.h:244
@ FORMAT_Y_VU12_FULL_RANGE
Pixel format with 8 bits Y frame as entire block, followed by 8 bits 2x2 sub-sampled V and U zipped (...
Definition Frame.h:887
@ FORMAT_BGGR10_PACKED
The packed pixel format representing a Bayer mosaic pattern for images with blue, green,...
Definition Frame.h:302
@ FORMAT_Y_UV12
This pixel format is deprecated and is currently an alias for FORMAT_Y_UV12_LIMITED_RANGE.
Definition Frame.h:529
@ FORMAT_YUYV16
Pixel format with 8 bit Y pixel values zipped (interleaved) with 8 bits 2x1 (horizontal) sub-sampled ...
Definition Frame.h:565
@ FORMAT_YVU24_FULL_RANGE
Pixel format with byte order YVU and 24 bits per pixel.
Definition Frame.h:1119
@ FORMAT_RGB5551
Pixel format with entirely 16 bits per pixel, 15 bits for RGB and 1 unused bit.
Definition Frame.h:354
@ FORMAT_RGGB10_PACKED
The packed pixel format representing a Bayer mosaic pattern for images with red, green,...
Definition Frame.h:428
@ FORMAT_Y_V_U12
Pixel format with 8 bits Y frame as individual block, followed by 8 bits 2x2 sub-sampled V frame and ...
Definition Frame.h:496
@ FORMAT_Y_U_V24_LIMITED_RANGE
Pixel format with 8 bits Y frame as individual block, followed by 8 bits U frame as individual block,...
Definition Frame.h:720
@ FORMAT_YVU24
This pixel format is deprecated and is currently an alias for FORMAT_YVU24_LIMITED_RANGE.
Definition Frame.h:510
@ FORMAT_Y_VU12_LIMITED_RANGE
Pixel format with 8 bits Y frame as entire block, followed by 8 bits 2x2 sub-sampled V and U zipped (...
Definition Frame.h:861
@ FORMAT_BGR565
Pixel format with 16 bits per pixel, 5 bits for blue, 6 bits for green and 5 bits for red.
Definition Frame.h:264
@ FORMAT_Y_V_U12_FULL_RANGE
Pixel format with 8 bits Y frame as individual block, followed by 8 bits 2x2 sub-sampled V frame and ...
Definition Frame.h:989
@ FORMAT_F64
Pixel format for a frame with one channel and 64 bit floating point precision per element.
Definition Frame.h:999
@ FORMAT_YUV24_LIMITED_RANGE
Pixel format with byte order YUV and 24 bits per pixel.
Definition Frame.h:1053
@ FORMAT_Y_U_V12_FULL_RANGE
Pixel format with 8 bits Y frame as individual block, followed by 8 bits 2x2 sub-sampled U frame and ...
Definition Frame.h:938
@ FORMAT_RGB4444
Pixel format with entirely 16 bits per pixel, 12 bits for RGB and 4 unused bits.
Definition Frame.h:341
@ FORMAT_RGBA32
Pixel format with byte order RGBA and 32 bits per pixel.
Definition Frame.h:382
@ FORMAT_Y8_FULL_RANGE
Pixel format for grayscale images with byte order Y and 8 bits per pixel (with full range).
Definition Frame.h:785
@ FORMAT_YUVA32
Pixel format with byte order YUVA and 32 bits per pixel.
Definition Frame.h:473
@ FORMAT_Y10_PACKED
Pixel format with byte order Y and 10 bits per pixel, packed so that four consecutive pixels fit into...
Definition Frame.h:623
@ FORMAT_RGB24
Pixel format with byte order RGB and 24 bits per pixel.
Definition Frame.h:315
@ FORMAT_BGRA32
Pixel format with byte order BGRA and 32 bits per pixel.
Definition Frame.h:277
@ FORMAT_Y_V_U12_LIMITED_RANGE
Pixel format with 8 bits Y frame as individual block, followed by 8 bits 2x2 sub-sampled V frame and ...
Definition Frame.h:963
@ FORMAT_Y8
Pixel format for grayscale images with byte order Y and 8 bits per pixel.
Definition Frame.h:596
unsigned int width() const
Returns the width of the frame format in pixel.
Definition Frame.h:3334
static PixelFormat genericSinglePlanePixelFormat(const PixelFormat pixelFormat)
Returns the most suitable 1-plane pixel format for a given pixel format which may be composed of seve...
PlanesValue
Definition of a protected helper enum that simplifies to read the definition of a predefined pixel fo...
Definition Frame.h:126
@ PV_PLANES_3
Three planes.
Definition Frame.h:132
@ PV_PLANES_2
Two planes.
Definition Frame.h:130
@ PV_PLANES_1
One plane.
Definition Frame.h:128
@ PV_PLANES_4
Four planes.
Definition Frame.h:134
bool isPixelFormatDataLayoutCompatible(const PixelFormat pixelFormat) const
Returns whether this pixel format has a compatible data layout with a given pixel format.
Definition Frame.h:3396
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition Frame.h:3379
std::vector< PixelFormat > PixelFormats
Definition of a vector holding pixel formats.
Definition Frame.h:1130
static bool areFrameTypesDataLayoutCompatible(const FrameType &frameTypeA, const FrameType &frameTypeB, const bool allowDifferentPixelOrigins)
Returns whether two given frame types have compatible data layouts.
static DataType translateDataType(const std::string &dataType)
Translates a string containing a data type into the data type.
static constexpr PixelFormat genericPixelFormat(const DataType dataType, const uint32_t channels, const uint32_t planes=1u, const uint32_t widthMultiple=1u, const uint32_t heightMultiple=1u)
Returns a specific generic pixel format with a specified data type, channel number,...
Definition Frame.h:3543
unsigned int frameTypeSize() const
Returns the number of bytes necessary for the frame type, without padding at the end of frame rows.
static unsigned int formatGenericBitsPerPixel(const PixelFormat pixelFormat)
Returns the number of bits of one pixel for a given generic pixel format.
Definition Frame.h:3538
static constexpr bool isProductInsideValueRange(const unsigned int valueA, const unsigned int valueB)
Returns whether two values can be multiplied with each other without producing an overflow.
Definition Frame.h:3684
unsigned int height_
Frame height in pixel, with range [0, infinity).
Definition Frame.h:1915
static bool dataIsAligned(const void *data)
Returns whether a given pointer has the same byte alignment as the size of the data type the pointer ...
Definition Frame.h:3673
static PixelOrigin translatePixelOrigin(const std::string &pixelOrigin)
Translates a string containing the pixel origin into the pixel origin value.
bool operator!=(const FrameType &right) const
Returns whether two frame types are not equal.
Definition Frame.h:3411
static constexpr bool isSumInsideValueRange(const unsigned int valueA, const unsigned int valueB)
Returns whether two values can be added with each other without producing an overflow.
Definition Frame.h:3679
static bool planeLayout(const PixelFormat imagePixelFormat, const unsigned int imageWidth, const unsigned int imageHeight, const unsigned int planeIndex, unsigned int &planeWidth, unsigned int &planeHeight, unsigned int &planeChannels, unsigned int *planeWidthElementsMultiple=nullptr, unsigned int *planeHeightElementsMultiple=nullptr)
Returns the plane layout of a given pixel format.
static PixelFormat formatGrayscalePixelFormat(const PixelFormat pixelFormat)
Returns the best matching grayscale pixel format for a given pixel format.
static constexpr PixelFormat genericPixelFormat()
Returns a specific generic pixel format with a specified data type and channel number.
uint32_t numberPlanes() const
Returns the number of planes of the pixel format of this frame.
Definition Frame.h:3374
PixelOrigin pixelOrigin_
The origin of the pixel data, either the upper left corner or the bottom left corner (if valid).
Definition Frame.h:1921
static std::string translatePixelFormat(const PixelFormat pixelFormat)
Translates a pixel format value into a string containing the pixel format.
static bool formatIsLimitedRange(const PixelFormat pixelFormat)
Returns whether a given pixel format is using a limited value range (e.g., like Y_UV12_LIMITED_RANGE)...
static PixelFormat formatRemoveAlphaChannel(const PixelFormat pixelFormat)
Removes an alpha channel from a given pixel format.
static bool arePixelFormatsCompatible(const PixelFormat pixelFormatA, const PixelFormat pixelFormatB)
Returns whether two given pixel formats are compatible.
static unsigned int formatBitsPerPixelAlphaChannel(const PixelFormat pixelFormat)
Returns the number of bits of one pixel for the alpha channel.
MultipleValue
Definition of a protected helper enum that simplifies to read the definition of a predefined pixel fo...
Definition Frame.h:141
@ MV_MULTIPLE_2
The size must have a multiple of 2.
Definition Frame.h:145
@ MV_MULTIPLE_3
The size must have a multiple of 3.
Definition Frame.h:147
@ MV_MULTIPLE_4
The size must have a multiple of 4.
Definition Frame.h:149
@ MV_MULTIPLE_1
The size can have any value (as the value must be a multiple of 1).
Definition Frame.h:143
static bool areFrameTypesCompatible(const FrameType &frameTypeA, const FrameType &frameTypeB, const bool allowDifferentPixelOrigins)
Returns whether two given frame types are compatible.
static bool formatHasAlphaChannel(const PixelFormat pixelFormat, bool *isLastChannel=nullptr)
Returns whether a given pixel format holds an alpha channel.
static unsigned int heightMultiple(const PixelFormat pixelFormat)
Returns the number of pixels the height of a frame must be a multiple of.
Definition Frame.h:3631
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition Frame.h:3344
unsigned int bytesPerDataType() const
Returns the number of bytes which are necessary to store the data type of this frame.
Definition Frame.h:3359
static constexpr PixelFormat genericPixelFormat(uint32_t channels, const uint32_t planes=1u, const uint32_t widthMultiple=1u, const uint32_t heightMultiple=1u)
Returns a specific generic pixel format with a specified data type and channel number.
PixelOrigin
Defines different types of frame origin positions.
Definition Frame.h:1136
@ ORIGIN_INVALID
Invalid origin type.
Definition Frame.h:1138
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition Frame.h:1140
@ ORIGIN_LOWER_LEFT
The first pixel lies in the lower left corner, the last pixel in the upper right corner.
Definition Frame.h:1142
static const FrameType::DataTypes & definedDataTypes()
Returns all defined data types.
ChannelsValue
Definition of a protected helper enum that simplifies to read the definition of a predefined pixel fo...
Definition Frame.h:109
@ CV_CHANNELS_2
Two channels.
Definition Frame.h:115
@ CV_CHANNELS_4
Four channels.
Definition Frame.h:119
@ CV_CHANNELS_1
One channel.
Definition Frame.h:113
@ CV_CHANNELS_UNDEFINED
An invalid channel number, used for non-generic pixel formats.
Definition Frame.h:111
@ CV_CHANNELS_3
Three channels.
Definition Frame.h:117
DataType
Definition of individual channel data type.
Definition Frame.h:37
@ DT_UNSIGNED_INTEGER_64
Unsigned 64 bit integer data type (uint64_t).
Definition Frame.h:53
@ DT_UNSIGNED_INTEGER_16
Unsigned 16 bit integer data type (uint16_t).
Definition Frame.h:45
@ DT_SIGNED_INTEGER_16
Signed 16 bit integer data type (int16_t).
Definition Frame.h:47
@ DT_SIGNED_INTEGER_32
Signed 232 bit integer data type (int32_t).
Definition Frame.h:51
@ DT_END
The helper data type which can be used to identify the last defined data type, DT_END is exclusive.
Definition Frame.h:63
@ DT_SIGNED_INTEGER_64
Signed 64 bit integer data type (int64_t).
Definition Frame.h:55
@ DT_UNDEFINED
Undefined data type.
Definition Frame.h:39
@ DT_SIGNED_FLOAT_64
Signed 64 bit float data type (double).
Definition Frame.h:61
@ DT_UNSIGNED_INTEGER_8
Unsigned 8 bit integer data type (uint8_t).
Definition Frame.h:41
@ DT_UNSIGNED_INTEGER_32
Unsigned 32 bit integer data type (uint32_t).
Definition Frame.h:49
@ DT_SIGNED_FLOAT_16
Signed 16 bit float data type.
Definition Frame.h:57
@ DT_SIGNED_FLOAT_32
Signed 32 bit float data type (float).
Definition Frame.h:59
@ DT_SIGNED_INTEGER_8
Signed 8 bit integer data type (int8_t).
Definition Frame.h:43
static unsigned int planeBytesPerPixel(const PixelFormat &imagePixelFormat, const unsigned int planeIndex)
Returns the number of bytes of one pixel of a plane for a pixel format.
Definition Frame.h:3636
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3339
static unsigned int formatBitsPerPixelRedChannel(const PixelFormat pixelFormat)
Returns the number of bits of one pixel for the red channel.
static constexpr uint32_t pixelFormatBitOffsetDatatype
The number of bits the data type value is shifted within the PixelFormat value.
Definition Frame.h:77
static bool formatIsPacked(const PixelFormat pixelFormat)
Returns whether a given pixel format is a packed pixel format.
unsigned int width_
Frame width in pixel, with range [0, infinity).
Definition Frame.h:1912
static constexpr uint32_t pixelFormatBitOffsetWidthMultiple
The number of bits the width-multiple value is shifted within the PixelFormat value.
Definition Frame.h:83
bool operator<(const FrameType &right) const
Returns whether the left frame type is 'smaller' than the right one.
static bool formatIsPureGeneric(const PixelFormat pixelFormat)
Checks whether a given pixel format is a pure generic pixel format.
Definition Frame.h:3619
static bool isDataLayoutCompatible(const PixelFormat pixelFormatA, const PixelFormat pixelFormatB)
Returns whether two given pixel formats have compatible data layouts.
bool isValid() const
Returns whether this frame type is valid.
Definition Frame.h:3416
static const FrameType::PixelFormats & definedPixelFormats()
Returns all defined pixel formats.
bool isPixelFormatCompatible(const PixelFormat pixelFormat) const
Returns whether the pixel format of this frame type is compatible with a given pixel format.
Definition Frame.h:3391
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition Frame.h:3364
static unsigned int channels(const PixelFormat pixelFormat)
Returns the number of individual channels of a given pixel format.
PixelFormatUnion pixelFormat_
The pixel format of the frame encapsulated in a union (mainly holding PixelFormat).
Definition Frame.h:1918
static std::string translateDataType(const DataType dataType)
Translates a data type value into a string containing the data type.
std::vector< DataType > DataTypes
Definition of a vector holding data types.
Definition Frame.h:69
static unsigned int formatBitsPerPixelBlueChannel(const PixelFormat pixelFormat)
Returns the number of bits of one pixel for the blue channel.
static PixelFormat findPixelFormat(const unsigned int bitsPerPixel)
Returns a best fitting pixel format having the given number of bits per pixels.
DataType dataType() const
Returns the data type of the pixel format of this frame.
Definition Frame.h:3354
static PixelFormat makeGenericPixelFormat(const PixelFormat pixelFormat)
Converts a any pixel format into a generic one This function has no effect for input pixel formats wh...
Definition Frame.h:3602
static unsigned int planeChannels(const PixelFormat &imagePixelFormat, const unsigned int planeIndex)
Returns the channels of a plane for a pixel format.
static constexpr PixelFormat genericPixelFormat()
Returns a specific generic pixel format with a specified data type and channel number.
Definition Frame.h:3555
bool isFrameTypeCompatible(const FrameType &frameType, const bool allowDifferentPixelOrigins) const
Returns whether this frame type is compatible with a given frame type.
Definition Frame.h:3401
static constexpr uint32_t pixelFormatBitOffsetHeightMultiple
The number of bits the height-multiple value is shifted within the PixelFormat value.
Definition Frame.h:86
static unsigned int formatGenericNumberChannels(const PixelFormat pixelFormat)
Returns the number of individual channels of a given generic pixel format.
Definition Frame.h:3426
static std::string translatePixelOrigin(const PixelOrigin pixelOrigin)
Translates a pixel origin value into a string containing the pixel origin.
static bool formatIsGeneric(const PixelFormat pixelFormat, const DataType dataType, const uint32_t channels, const uint32_t planes=1u, const uint32_t widthMultiple=1u, const uint32_t heightMultiple=1u)
Checks whether a given pixel format is a specific layout regarding data channels and data type.
Definition Frame.h:3609
static constexpr uint32_t pixelFormatBitOffsetPlanes
The number of bits the planes value is shifted within the PixelFormat value.
Definition Frame.h:80
void setPixelFormat(const PixelFormat pixelFormat)
Explicitly changes the pixel format of this frame.
Definition Frame.h:3349
bool isFrameTypeDataLayoutCompatible(const FrameType &frameType, const bool allowDifferentPixelOrigins) const
Returns whether this frame type has a compatible data layout with a given frame type.
Definition Frame.h:3406
static PixelFormat formatAddAlphaChannel(const PixelFormat pixelFormat, const bool lastChannel=true)
Adds an alpha channel to a given pixel format.
T Type
The data type of 'T'.
Definition DataType.h:90
This template class implements a object reference with an internal reference counter.
Definition base/ObjectRef.h:58
Vector like data structure combining stack and heap memory.
Definition StackHeapVector.h:27
This class implements a timestamp.
Definition Timestamp.h:64
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
ObjectRef< Frame > FrameRef
Definition of an object reference for frame objects.
Definition Frame.h:1938
std::vector< Frame > Frames
Definition of a vector holding padding frames.
Definition Frame.h:1932
std::vector< FrameRef > FrameRefs
Definition of a vector holding frame references.
Definition Frame.h:1944
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Default definition of a type with tBytes bytes.
Definition DataType.h:32