8#ifndef META_OCEAN_BASE_FRAME_H
9#define META_OCEAN_BASE_FRAME_H
74 static constexpr uint32_t pixelFormatBitOffsetChannels = 16u;
77 static constexpr uint32_t pixelFormatBitOffsetDatatype = pixelFormatBitOffsetChannels + 8u;
80 static constexpr uint32_t pixelFormatBitOffsetPlanes = pixelFormatBitOffsetDatatype + 8u;
83 static constexpr uint32_t pixelFormatBitOffsetWidthMultiple = pixelFormatBitOffsetPlanes + 8u;
86 static constexpr uint32_t pixelFormatBitOffsetHeightMultiple = pixelFormatBitOffsetWidthMultiple + 8u;
96 template <DataType tDataType, u
int32_t tChannels, u
int32_t tPlanes, u
int32_t tW
idthMultiple, u
int32_t tHeightMultiple>
102 static constexpr uint64_t value = (uint64_t(tHeightMultiple) << pixelFormatBitOffsetHeightMultiple) | (uint64_t(tWidthMultiple) << pixelFormatBitOffsetWidthMultiple) | (uint64_t(tPlanes) << pixelFormatBitOffsetPlanes) |(uint64_t(tDataType) << pixelFormatBitOffsetDatatype) | (uint64_t(tChannels) << pixelFormatBitOffsetChannels);
111 CV_CHANNELS_UNDEFINED = 0u,
187 FORMAT_UNDEFINED = 0ull,
244 FORMAT_BGR4444 = 5ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_16, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
249 FORMAT_BGR5551 = 6ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_16, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
264 FORMAT_BGR565 = 7ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_16, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
282 FORMAT_BGRA4444 = 9ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_16, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
302 FORMAT_BGGR10_PACKED = 10ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_4, MV_MULTIPLE_2>::value,
341 FORMAT_RGB4444 = 13ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_16, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
354 FORMAT_RGB5551 = 14ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_16, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
367 FORMAT_RGB565 = 15ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_16, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
395 FORMAT_RGBA4444 = 17ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_16, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
428 FORMAT_RGGB10_PACKED = 19ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_4, MV_MULTIPLE_2>::value,
446 FORMAT_Y_U_V12 = 20ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_3, MV_MULTIPLE_2, MV_MULTIPLE_2>::value,
495 FORMAT_Y_V_U12 = 24ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_3, MV_MULTIPLE_2, MV_MULTIPLE_2>::value,
527 FORMAT_Y_UV12 = 26ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_2, MV_MULTIPLE_2, MV_MULTIPLE_2>::value,
545 FORMAT_Y_VU12 = 27ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_2, MV_MULTIPLE_2, MV_MULTIPLE_2>::value,
563 FORMAT_YUYV16 = 28ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_2, MV_MULTIPLE_1>::value,
581 FORMAT_UYVY16 = 29ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_2, MV_MULTIPLE_1>::value,
621 FORMAT_Y10_PACKED = 32ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_1, MV_MULTIPLE_4, MV_MULTIPLE_1>::value,
693 FORMAT_Y_U_V24 = 39ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_3, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
718 FORMAT_Y_U_V24_LIMITED_RANGE = FORMAT_Y_U_V24,
743 FORMAT_Y_U_V24_FULL_RANGE = 40ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_3, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
783 FORMAT_Y8_FULL_RANGE = FORMAT_Y8,
808 FORMAT_Y_UV12_LIMITED_RANGE = FORMAT_Y_UV12,
834 FORMAT_Y_UV12_FULL_RANGE = 42ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_2, MV_MULTIPLE_2, MV_MULTIPLE_2>::value,
859 FORMAT_Y_VU12_LIMITED_RANGE = FORMAT_Y_VU12,
885 FORMAT_Y_VU12_FULL_RANGE = 43ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_2, MV_MULTIPLE_2, MV_MULTIPLE_2>::value,
910 FORMAT_Y_U_V12_LIMITED_RANGE = FORMAT_Y_U_V12,
936 FORMAT_Y_U_V12_FULL_RANGE = 44ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_3, MV_MULTIPLE_2, MV_MULTIPLE_2>::value,
961 FORMAT_Y_V_U12_LIMITED_RANGE = FORMAT_Y_V_U12,
987 FORMAT_Y_V_U12_FULL_RANGE = 45ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_3, MV_MULTIPLE_2, MV_MULTIPLE_2>::value,
1013 FORMAT_R_G_B24 = 48ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_3, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
1029 FORMAT_B_G_R24 = 49ull |
GenericPixelFormat<DT_UNSIGNED_INTEGER_8, CV_CHANNELS_UNDEFINED , PV_PLANES_3, MV_MULTIPLE_1, MV_MULTIPLE_1>::value,
1048 ORIGIN_INVALID = 0u,
1084 static_assert(
sizeof(
PixelFormatProperties) ==
sizeof(std::underlying_type<PixelFormat>::type),
"Invalid helper struct!");
1137 inline FrameType(
const FrameType& type,
const unsigned int width,
const unsigned int height);
1165 inline unsigned int width()
const;
1171 inline unsigned int height()
const;
1184 inline void setPixelFormat(
const PixelFormat pixelFormat);
1196 inline unsigned int bytesPerDataType()
const;
1203 inline unsigned int channels()
const;
1209 inline uint32_t numberPlanes()
const;
1221 inline unsigned int pixels()
const;
1242 inline bool isPixelFormatCompatible(
const PixelFormat pixelFormat)
const;
1252 inline bool isPixelFormatDataLayoutCompatible(
const PixelFormat pixelFormat)
const;
1264 inline bool isFrameTypeCompatible(
const FrameType& frameType,
const bool allowDifferentPixelOrigins)
const;
1275 inline bool isFrameTypeDataLayoutCompatible(
const FrameType& frameType,
const bool allowDifferentPixelOrigins)
const;
1289 inline bool operator!=(
const FrameType& right)
const;
1303 inline bool isValid()
const;
1317 static inline uint32_t numberPlanes(
const PixelFormat pixelFormat);
1324 template <
typename T>
1325 static constexpr DataType dataType();
1350 static constexpr inline PixelFormat genericPixelFormat(
const DataType dataType,
const uint32_t channels,
const uint32_t planes = 1u,
const uint32_t widthMultiple = 1u,
const uint32_t heightMultiple = 1u);
1362 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);
1382 template <DataType tDataType, u
int32_t tChannels, u
int32_t tPlanes = 1u, u
int32_t tW
idthMultiple = 1u, u
int32_t tHeightMultiple = 1u>
1383 constexpr static PixelFormat genericPixelFormat();
1402 template <DataType tDataType>
1403 constexpr static PixelFormat genericPixelFormat(
const uint32_t channels,
const uint32_t planes = 1u,
const uint32_t widthMultiple = 1u,
const uint32_t heightMultiple = 1u);
1424 template <
typename TDataType, u
int32_t tChannels, u
int32_t tPlanes = 1u, u
int32_t tW
idthMultiple = 1u, u
int32_t tHeightMultiple = 1u>
1445 template <
typename TDataType>
1446 constexpr static PixelFormat genericPixelFormat(uint32_t channels,
const uint32_t planes = 1u,
const uint32_t widthMultiple = 1u,
const uint32_t heightMultiple = 1u);
1466 static inline 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);
1473 static inline bool formatIsGeneric(
const PixelFormat pixelFormat);
1480 static inline bool formatIsPureGeneric(
const PixelFormat pixelFormat);
1487 static unsigned int formatGenericNumberChannels(
const PixelFormat pixelFormat);
1494 static inline unsigned int formatGenericBitsPerPixel(
const PixelFormat pixelFormat);
1599 static inline unsigned int widthMultiple(
const PixelFormat pixelFormat);
1606 static inline unsigned int heightMultiple(
const PixelFormat pixelFormat);
1623 static inline unsigned int planeBytesPerPixel(
const PixelFormat& imagePixelFormat,
const unsigned int planeIndex);
1638 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);
1651 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);
1788 template <
typename T>
1789 static inline bool dataIsAligned(
const void* data);
1809 static constexpr bool isSumInsideValueRange(
const unsigned int valueA,
const unsigned int valueB);
1817 static constexpr bool isProductInsideValueRange(
const unsigned int valueA,
const unsigned int valueB);
1822 unsigned int width_ = 0u;
1825 unsigned int height_ = 0u;
1888 CM_USE_KEEP_LAYOUT = 1u << 0u,
1890 CM_COPY_REMOVE_PADDING_LAYOUT = 1u << 1u,
1892 CM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA = 1u << 2u,
1894 CM_COPY_KEEP_LAYOUT_COPY_PADDING_DATA = 1u << 3u,
1903 ACM_USE_KEEP_LAYOUT = CM_USE_KEEP_LAYOUT,
1905 ACM_COPY_REMOVE_PADDING_LAYOUT = CM_COPY_REMOVE_PADDING_LAYOUT,
1907 ACM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA = CM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA,
1909 ACM_COPY_KEEP_LAYOUT_COPY_PADDING_DATA = CM_COPY_KEEP_LAYOUT_COPY_PADDING_DATA,
1912 ACM_USE_OR_COPY = ACM_USE_KEEP_LAYOUT | ACM_COPY_REMOVE_PADDING_LAYOUT,
1914 ACM_USE_OR_COPY_KEEP_LAYOUT = ACM_USE_KEEP_LAYOUT | ACM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA,
1975 Plane(
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int elementTypeSize,
const unsigned int paddingElements)
noexcept;
1986 template <
typename T>
1987 inline Plane(
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const T* dataToUse,
const unsigned int paddingElements)
noexcept;
1998 template <
typename T>
1999 inline Plane(
const unsigned int width,
const unsigned int height,
const unsigned int channels, T* dataToUse,
const unsigned int paddingElements)
noexcept;
2012 template <
typename T>
2013 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;
2025 template <typename T>
2026 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;
2037 inline
unsigned int width() const;
2043 inline
unsigned int height() const;
2049 inline
unsigned int channels() const;
2056 template <typename T>
2057 inline const T* constdata() const;
2064 template <typename T>
2072 inline
unsigned int paddingElements() const;
2080 inline
unsigned int paddingBytes() const;
2086 inline
unsigned int elementTypeSize() const;
2096 inline
unsigned int widthElements() const;
2106 inline
unsigned int widthBytes() const;
2113 inline
unsigned int strideElements() const;
2119 inline
unsigned int strideBytes() const;
2125 inline
unsigned int bytesPerPixel() const;
2137 template <typename T>
2138 inline
bool isCompatibleWithDataType() const;
2145 inline
unsigned int size() const;
2151 inline
bool isContinuous() const;
2157 inline
bool isOwner() const;
2163 inline
bool isReadOnly() const;
2169 inline
bool isValid() const;
2179 bool copy(const
Plane& sourcePlane, const
AdvancedCopyMode advancedCopyMode = ACM_COPY_KEEP_LAYOUT_DO_NOT_COPY_PADDING_DATA, const
bool reallocateIfNecessary = true);
2205 static
void* alignedMemory(const
size_t size, const
size_t alignment,
void*& alignedData);
2216 static constexpr
bool validateMemoryLayout(const
unsigned int planeWidth, const
unsigned int planeHeight, const
unsigned int planeChannels, const
unsigned int bytesPerElement, const
unsigned int paddingElements);
2230 inline
Plane(const
unsigned int width, const
unsigned int height, const
unsigned int channels, const
unsigned int elementTypeSize, const
void* constData,
void* data, const
unsigned int paddingElements) noexcept;
2241 Plane(const
unsigned int width, const
unsigned int height, const
unsigned int channels, const
unsigned int elementTypeSize, const
void* dataToUse, const
unsigned int paddingElements) noexcept;
2252 Plane(const
unsigned int width, const
unsigned int height, const
unsigned int channels, const
unsigned int elementTypeSize,
void* dataToUse, const
unsigned int paddingElements) noexcept;
2265 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;
2277 Plane(const
unsigned int width, const
unsigned int height, const
unsigned int channels, const
unsigned int elementTypeSize, const
void* sourceDataToCopy, const
unsigned int sourcePaddingElements, const
CopyMode copyMode) noexcept;
2286 void copy(const
void* sourceData, const
unsigned int sourceStrideBytes, const
unsigned int sourcePaddingElements, const
bool makeCopyOfPaddingData = false);
2292 inline
unsigned int calculateStrideBytes() const;
2298 unsigned int calculateBytesPerPixel() const;
2303 void* allocatedData_ =
nullptr;
2306 const
void* constData_ =
nullptr;
2309 void* data_ =
nullptr;
2312 unsigned int width_ = 0u;
2315 unsigned int height_ = 0u;
2318 unsigned int channels_ = 0u;
2321 unsigned int elementTypeSize_ = 0u;
2324 unsigned int paddingElements_ = 0u;
2327 unsigned int strideBytes_ = 0u;
2330 unsigned int bytesPerPixel_ = 0u;
2343 template <typename T>
2370 explicit inline PlaneInitializer(
const unsigned int planePaddingElements = 0u);
2379 static std::vector<PlaneInitializer<T>> createPlaneInitializersWithPaddingElements(
const Indices32& paddingElementsPerPlane);
2384 const T* constdata_ =
nullptr;
2393 unsigned int paddingElements_ = 0u;
2400 template <
typename T>
2408 template <
typename T,
unsigned int tChannels>
2478 template <
typename T>
2491 template <
typename T>
2501 template <
typename T>
2514 inline const FrameType& frameType()
const;
2520 inline const Planes& planes()
const;
2533 bool copy(
const Frame& source,
const bool copyTimestamp =
true);
2558 bool copy(
const int targetLeft,
const int targetTop,
const Frame& source,
const bool copyTimestamp =
true);
2581 template <
typename T>
2582 bool updateMemory(
const T* data,
const unsigned int planeIndex = 0u);
2593 template <
typename T>
2594 bool updateMemory(T* data,
const unsigned int planeIndex = 0u);
2603 template <
typename T>
2604 bool updateMemory(
const std::initializer_list<T*>& planeDatas);
2630 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;
2647 bool setValue(
const uint8_t value,
const unsigned int planeIndex = 0u,
const bool skipPaddingData =
true);
2669 template <
typename T, const
unsigned int tPlaneChannels>
2687 template <
typename T>
2688 bool setValue(
const T* planePixelValue,
const size_t planePixelValueSize,
const unsigned int planeIndex = 0u);
2707 template <
typename T>
2708 bool setValue(
const std::initializer_list<
typename Identity<T>::Type>& planePixelValues,
const unsigned int planeIndex = 0u);
2718 template <
typename T, const
unsigned int tPlaneChannels>
2726 inline unsigned int size(
const unsigned int planeIndex = 0u)
const;
2733 inline unsigned int paddingElements(
const unsigned int planeIndex = 0u)
const;
2740 inline unsigned int paddingBytes(
const unsigned int planeIndex = 0u)
const;
2748 inline unsigned int strideElements(
const unsigned int planeIndex = 0u)
const;
2755 inline unsigned int strideBytes(
const unsigned int planeIndex = 0u)
const;
2762 inline unsigned int planeWidth(
const unsigned int planeIndex)
const;
2769 inline unsigned int planeHeight(
const unsigned int planeIndex)
const;
2776 inline unsigned int planeChannels(
const unsigned int planeIndex)
const;
2783 inline unsigned int planeWidthElements(
const unsigned int planeIndex)
const;
2790 inline unsigned int planeWidthBytes(
const unsigned int planeIndex)
const;
2798 inline unsigned int planeBytesPerPixel(
const unsigned int planeIndex)
const;
2805 inline bool isPlaneContinuous(
const unsigned int planeIndex = 0u)
const;
2812 inline bool isPlaneOwner(
const unsigned int planeIndex = 0u)
const;
2818 inline const Timestamp& timestamp()
const;
2824 inline const Timestamp& relativeTimestamp()
const;
2831 inline void setTimestamp(
const Timestamp& timestamp);
2839 inline void setRelativeTimestamp(
const Timestamp& relative);
2854 template <
typename T>
2855 inline T* data(
const unsigned int planeIndex = 0u);
2864 template <
typename T>
2865 inline const T* constdata(
const unsigned int planeIndex = 0u)
const;
2882 template <
typename T>
2883 inline T* row(
const unsigned int y,
const unsigned int planeIndex = 0u);
2900 template <
typename T>
2901 inline const T* constrow(
const unsigned int y,
const unsigned int planeIndex = 0u)
const;
2955 template <
typename T>
2956 inline T* pixel(
const unsigned int x,
const unsigned int y,
const unsigned int planeIndex = 0u);
2980 template <
typename T>
2981 inline const T* constpixel(
const unsigned int x,
const unsigned int y,
const unsigned int planeIndex = 0u)
const;
2987 inline bool isContinuous()
const;
2996 inline bool isOwner()
const;
3005 inline bool isReadOnly()
const;
3011 inline bool hasAlphaChannel()
const;
3019 template <
typename T>
3020 bool hasTransparentPixel(
const T opaque)
const;
3027 inline bool isValid()
const;
3043 explicit inline operator bool()
const;
3073 static bool strideBytes2paddingElements(
const PixelFormat& pixelFormat,
const unsigned int imageWidth,
const unsigned int planeStrideBytes,
unsigned int& planePaddingElements,
const unsigned int planeIndex = 0u);
3137 template <
typename T>
3149 template <
typename T>
3164inline FrameType::PixelFormatUnion::PixelFormatUnion(
const PixelFormat& pixelFormat) :
3165 pixelFormat_(pixelFormat)
3180 ocean_assert(
false &&
"The configuration of this frame type is invalid - this should never happen!");
3195 pixelFormat_(type.pixelFormat_),
3196 pixelOrigin_(type.pixelOrigin_)
3202 ocean_assert(
false &&
"The configuration of this frame type is invalid - this should never happen!");
3215 width_(type.width_),
3216 height_(type.height_),
3217 pixelFormat_(pixelFormat),
3218 pixelOrigin_(type.pixelOrigin_)
3224 width_(type.width_),
3225 height_(type.height_),
3226 pixelFormat_(type.pixelFormat_),
3227 pixelOrigin_(pixelOrigin)
3233 width_(type.width_),
3234 height_(type.height_),
3235 pixelFormat_(pixelFormat),
3236 pixelOrigin_(pixelOrigin)
3320 return !(*
this == right);
3341 static_assert(
sizeof(char) == 1,
"Invalid data type!");
3349 static_assert(
sizeof(
signed char) == 1,
"Invalid data type!");
3356 static_assert(
sizeof(
unsigned char) == 1,
"Invalid data type!");
3363 static_assert(
sizeof(
unsigned short) == 2,
"Invalid data type!");
3370 static_assert(
sizeof(short) == 2,
"Invalid data type!");
3377 static_assert(
sizeof(
unsigned int) == 4,
"Invalid data type!");
3384 static_assert(
sizeof(int) == 4,
"Invalid data type!");
3391 static_assert(
sizeof(
unsigned long) == 4 ||
sizeof(
unsigned long) == 8,
"Invalid data type!");
3399 static_assert(
sizeof(
unsigned long) == 4 ||
sizeof(
unsigned long) == 8,
"Invalid data type!");
3407 static_assert(
sizeof(
unsigned long long) == 8,
"Invalid data type!");
3414 static_assert(
sizeof(
long long) == 8,
"Invalid data type!");
3421 static_assert(
sizeof(float) == 4,
"Invalid data type!");
3428 static_assert(
sizeof(double) == 8,
"Invalid data type!");
3432template <
typename T>
3454 ocean_assert(planes >= 1u && planes <= 255u);
3461template <FrameType::DataType tDataType, u
int32_t tChannels, u
int32_t tPlanes, u
int32_t tW
idthMultiple, u
int32_t tHeightMultiple>
3464 static_assert(uint8_t(tDataType) > uint8_t(
DT_UNDEFINED) && uint8_t(tDataType) <
DT_END,
"Invalid data type!");
3465 static_assert(tChannels >= 1u && tChannels < 31u,
"Invalid channel number!");
3466 static_assert(tPlanes >= 1u && tPlanes <= 255u,
"Invalid plane number!");
3467 static_assert(tWidthMultiple >= 1u && tWidthMultiple <= 255u,
"Invalid width-multiple!");
3468 static_assert(tHeightMultiple >= 1u && tHeightMultiple <= 255u,
"Invalid height-multiple!");
3470 return genericPixelFormat(tDataType, tChannels, tPlanes, tWidthMultiple, tHeightMultiple);
3473template <FrameType::DataType tDataType>
3476 static_assert(uint8_t(tDataType) > uint8_t(
DT_UNDEFINED) && uint8_t(tDataType) <
DT_END,
"Invalid data type!");
3481template <
typename TDataType, u
int32_t tChannels, u
int32_t tPlanes, u
int32_t tW
idthMultiple, u
int32_t tHeightMultiple>
3484 static_assert(tChannels >= 1u && tChannels < 31u,
"Invalid channel number!");
3485 static_assert(tPlanes >= 1u && tPlanes <= 255u,
"Invalid plane number!");
3486 static_assert(tWidthMultiple >= 1u && tWidthMultiple <= 255u,
"Invalid width-multiple!");
3487 static_assert(tHeightMultiple >= 1u && tHeightMultiple <= 255u,
"Invalid height-multiple!");
3489 constexpr DataType pixelFormatDataType = dataType<TDataType>();
3490 static_assert(uint8_t(pixelFormatDataType) > uint8_t(
DT_UNDEFINED) && uint8_t(pixelFormatDataType) <
DT_END,
"Invalid data type!");
3492 return genericPixelFormat(pixelFormatDataType, tChannels, tPlanes, tWidthMultiple, tHeightMultiple);
3495template <
typename TDataType>
3498 constexpr DataType pixelFormatDataType = dataType<TDataType>();
3499 static_assert(uint8_t(pixelFormatDataType) > uint8_t(
DT_UNDEFINED) && uint8_t(pixelFormatDataType) <
DT_END,
"Invalid data type!");
3502 ocean_assert(planes >= 1u && planes <= 255u);
3511 static_assert(std::is_same<std::underlying_type<PixelFormat>::type, uint64_t>::value,
"Invalid pixel format data type!");
3528 static_assert(std::is_same<std::underlying_type<PixelFormat>::type, uint64_t>::value,
"Invalid pixel format data type!");
3545 unsigned int planeWidthDummy;
3546 unsigned int planeHeightDummy;
3550 unsigned int planeWidthElementsMultiple;
3551 unsigned int planeHeightElementsMultiple;
3555 ocean_assert(
planeChannels >= 1u && planeWidthElementsMultiple >= 1u && planeHeightElementsMultiple >= 1u);
3557 if (planeWidthElementsMultiple != 1u || planeHeightElementsMultiple != 1u)
3567 ocean_assert(
false &&
"Invalid input!");
3572inline 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)
3574 ocean_assert(frameType.
isValid());
3579template <
typename T>
3582 ocean_assert(data !=
nullptr);
3583 return size_t(data) %
sizeof(T) ==
size_t(0);
3588 return valueA <= (
unsigned int)(-1) - valueB;
3593 return valueB == 0u || valueA <= (
unsigned int)(-1) / valueB;
3598 *
this = std::move(plane);
3601template <
typename T>
3602inline Frame::Plane::Plane(
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const T* dataToUse,
const unsigned int paddingElements) noexcept :
3603 Plane(width, height, channels,
sizeof(T), (
const void*)(dataToUse), paddingElements)
3608template <
typename T>
3609inline Frame::Plane::Plane(
const unsigned int width,
const unsigned int height,
const unsigned int channels, T* dataToUse,
const unsigned int paddingElements) noexcept :
3610 Plane(width, height, channels,
sizeof(T), (
void*)(dataToUse), paddingElements)
3615template <
typename T>
3616inline 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 :
3617 Plane(width, height, channels,
sizeof(T), (
const void*)(sourceDataToCopy), targetPaddingElements, sourcePaddingElements, makeCopyOfPaddingData)
3622template <
typename T>
3623inline Frame::Plane::Plane(
const T* sourceDataToCopy,
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int sourcePaddingElements,
const CopyMode copyMode) noexcept :
3624 Plane(width, height, channels,
sizeof(T), (
const void*)(sourceDataToCopy), sourcePaddingElements, copyMode)
3629inline Frame::Plane::Plane(
const unsigned int width,
const unsigned int height,
const unsigned int channels,
const unsigned int elementTypeSize,
const void* constData,
void* data,
const unsigned int paddingElements) noexcept :
3630 allocatedData_(
nullptr),
3631 constData_(constData),
3635 channels_(channels),
3636 elementTypeSize_(elementTypeSize),
3637 paddingElements_(paddingElements)
3639 strideBytes_ = calculateStrideBytes();
3640 bytesPerPixel_ = calculateBytesPerPixel();
3663template <
typename T>
3666 return reinterpret_cast<const T*
>(constData_);
3669template <
typename T>
3672 return reinterpret_cast<T*
>(data_);
3677 return paddingElements_;
3682 return paddingElements_ * elementTypeSize_;
3687 return elementTypeSize_;
3694 return width_ * channels_;
3701 return widthElements() * elementTypeSize_;
3708 return widthElements() + paddingElements_;
3713 ocean_assert(
width_ == 0u || strideBytes_ != 0u);
3714 ocean_assert(strideBytes_ == calculateStrideBytes());
3716 return strideBytes_;
3721 ocean_assert(bytesPerPixel_ == calculateBytesPerPixel());
3723 return bytesPerPixel_;
3726template <
typename T>
3729 return elementTypeSize_ ==
sizeof(T);
3741 return paddingElements_ == 0u;
3746 return allocatedData_ !=
nullptr;
3751 return data_ ==
nullptr;
3780 const unsigned int planeStrideBytes = planeStrideElements * bytesPerElement;
3797template <
typename T>
3801 copyMode_(copyMode),
3802 paddingElements_(dataPaddingElements)
3807template <
typename T>
3809 constdata_(nullptr),
3811 copyMode_(copyMode),
3812 paddingElements_(dataPaddingElements)
3817template <
typename T>
3819 constdata_(nullptr),
3822 paddingElements_(planePaddingElements)
3827template <
typename T>
3831 planeInitializers.reserve(paddingElementsPerPlane.size());
3838 return planeInitializers;
3851 *
this = std::move(frame);
3853 ocean_assert(planes_.size() >= 1);
3854 ocean_assert(frame.planes_.size() == 1);
3858 Frame(frameType,
PlaneInitializer<void>::createPlaneInitializersWithPaddingElements(planePaddingElements), timestamp)
3860 ocean_assert(
frameType.
numberPlanes() == planePaddingElements.size() || planePaddingElements.empty());
3881template <
typename T>
3883 Frame(frameType, (const void*)(data), copyMode, paddingElements, timestamp)
3890 ocean_assert(debugTemplateDataType ==
FrameType::DT_UNDEFINED || debugTemplateDataType == debugFrameTypeDataType);
3906template <
typename T>
3908 Frame(frameType, (void*)(data), copyMode, paddingElements, timestamp)
3915 ocean_assert(debugTemplateDataType ==
FrameType::DT_UNDEFINED || debugTemplateDataType == debugFrameTypeDataType);
3921template <
typename T>
3923 Frame(frameType, (const
PlaneInitializer<void>*)planeInitializers.data(), planeInitializers.size(), timestamp)
3930 ocean_assert(debugTemplateDataType ==
FrameType::DT_UNDEFINED || debugTemplateDataType == debugFrameTypeDataType);
3946template <
typename T>
3949 ocean_assert(
data !=
nullptr);
3950 if (
data !=
nullptr)
3957 if constexpr (!std::is_void_v<T>)
3966 plane.
data_ =
nullptr;
3976template <
typename T>
3979 ocean_assert(
data !=
nullptr);
3980 if (
data !=
nullptr)
3987 if constexpr (!std::is_void_v<T>)
4006template <
typename T>
4009 ocean_assert(planeDatas.size() != 0);
4010 ocean_assert(planeDatas.size() <=
planes_.
size());
4012 if (planeDatas.size() == 0 || planeDatas.size() >
planes_.
size())
4017 for (
unsigned int planeIndex = 0u; planeIndex < planeDatas.size(); ++planeIndex)
4019 if (!
updateMemory(planeDatas.begin()[planeIndex], planeIndex))
4028template <
typename T, const
unsigned int tPlaneChannels>
4031 static_assert(!std::is_void_v<T>,
"Value access/assignment cannot be performed with void types.");
4038 ocean_assert(plane.
isValid());
4042 ocean_assert(
false &&
"The specified data type must fit to the frame's data type!");
4046 if (plane.
channels() != tPlaneChannels)
4048 ocean_assert(
false &&
"The specified number of channels does not fit with the plane's actual channels!");
4061 for (
unsigned int n = 0u; n < plane.
width() * plane.
height(); ++n)
4063 data[n] = planePixelValue;
4068 const unsigned int planeStrideBytes = plane.
strideBytes();
4070 for (
unsigned int y = 0u; y < plane.
height(); ++y)
4074 for (
unsigned int x = 0u; x < plane.
width(); ++x)
4076 data[x] = planePixelValue;
4084template <
typename T, const
unsigned int tPlaneChannels>
4087 static_assert(!std::is_void_v<T>,
"Value access/comparison cannot be performed with void types.");
4094 ocean_assert(plane.
isValid());
4098 ocean_assert(
false &&
"The specified data type must fit to the frame's data type!");
4102 if (plane.
channels() != tPlaneChannels)
4104 ocean_assert(
false &&
"The specified number of channels does not fit with the plane's actual channels!");
4108 const unsigned int planeStrideBytes = plane.
strideBytes();
4110 for (
unsigned int y = 0u; y < plane.
height(); ++y)
4114 for (
unsigned int x = 0u; x < plane.
width(); ++x)
4116 if (
data[x] == planePixelValue)
4126template <
typename T>
4127bool Frame::setValue(
const T* planePixelValue,
const size_t planePixelValueSize,
const unsigned int planeIndex)
4129 static_assert(!std::is_void_v<T>,
"Value access/assignment cannot be performed with void types.");
4131 ocean_assert(planePixelValue !=
nullptr);
4133 ocean_assert(
planes_[planeIndex].elementTypeSize() ==
sizeof(T));
4136 switch (planePixelValueSize)
4145 return setValue<T, 1u>(value, planeIndex);
4156 return setValue<T, 2u>(value, planeIndex);
4168 return setValue<T, 3u>(value, planeIndex);
4181 return setValue<T, 4u>(value, planeIndex);
4188 ocean_assert(
false &&
"The number of channels is not supported");
4192template <
typename T>
4195 return setValue<T>(planePixelValues.begin(), planePixelValues.size(), planeIndex);
4211 return planes_[planeIndex].paddingElements();
4219 return planes_[planeIndex].paddingBytes();
4227 return planes_[planeIndex].strideElements();
4235 return planes_[planeIndex].strideBytes();
4243 return planes_[planeIndex].width();
4251 return planes_[planeIndex].height();
4259 return planes_[planeIndex].channels();
4267 return planes_[planeIndex].widthElements();
4275 return planes_[planeIndex].widthBytes();
4291 return planes_[planeIndex].isContinuous();
4299 return planes_[planeIndex].isOwner();
4322template <
typename T>
4328 return planes_[planeIndex].data<T>();
4331template <
typename T>
4337 return planes_[planeIndex].constdata<T>();
4340template <
typename T>
4341inline T*
Frame::row(
const unsigned int y,
const unsigned int planeIndex)
4344 ocean_assert(y <
height());
4350 ocean_assert(plane.
isValid());
4352 ocean_assert(y < plane.
height());
4353 return reinterpret_cast<T*
>(plane.
data<uint8_t>() + y * plane.
strideBytes());
4356template <
typename T>
4360 ocean_assert(y <
height());
4366 ocean_assert(plane.
isValid());
4368 ocean_assert(y < plane.
height());
4372template <
typename T>
4373inline T*
Frame::pixel(
const unsigned int x,
const unsigned int y,
const unsigned int planeIndex)
4383 ocean_assert(plane.
isValid());
4385 if constexpr (!std::is_void_v<T>)
4409 ocean_assert(y < plane.
height());
4410 return reinterpret_cast<T*
>(plane.
data<uint8_t>() + y * plane.
strideBytes() + xBytes);
4413template <
typename T>
4414inline const T*
Frame::constpixel(
const unsigned int x,
const unsigned int y,
const unsigned int planeIndex)
const
4424 ocean_assert(plane.
isValid());
4426 if constexpr (!std::is_void_v<T>)
4436 ocean_assert(y < plane.
height());
4437 return reinterpret_cast<const T*
>(plane.
constdata<uint8_t>() + y * plane.
strideBytes() + xBytes);
4446 if (!plane.isContinuous())
4461 if (!plane.isOwner())
4476 if (plane.isReadOnly())
4502 if (
dataType() != dataType<uint8_t>())
4504 ocean_assert(
false &&
"Data type does not fit with the frame's data type!");
4510 for (
unsigned int y = 0u; y <
height(); ++y)
4512 const uint8_t*
row = constrow<uint8_t>(y) + 1;
4514 for (
unsigned int x = 0u; x <
width(); ++x)
4531 for (
unsigned int y = 0u; y <
height(); ++y)
4533 const uint8_t*
row = constrow<uint8_t>(y) + offset;
4535 for (
unsigned int x = 0u; x <
width(); ++x)
4560 if (
dataType() != dataType<uint16_t>())
4562 ocean_assert(
false &&
"Data type does not fit with the frame's data type!");
4568 for (
unsigned int y = 0u; y <
height(); ++y)
4570 const uint16_t*
row = constrow<uint16_t>(y) + 3;
4572 for (
unsigned int x = 0u; x <
width(); ++x)
4587 for (
unsigned int y = 0u; y <
height(); ++y)
4589 const uint16_t*
row = constrow<uint16_t>(y);
4591 for (
unsigned int x = 0u; x <
width(); ++x)
4593 if ((*
row & opaque) != opaque)
4606template <
typename T>
4622 size_t debugValidPlanes = 0;
4626 if (plane.isValid())
4634 ocean_assert(debugIsValid == frameTypeIsValid);
4638 return frameTypeIsValid;
4641inline 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:1944
unsigned int width() const
Returns the width of the plane in pixel.
Definition Frame.h:3648
bool isCompatibleWithDataType() const
Returns whether this plane is compatible with a given element data type.
Definition Frame.h:3727
unsigned int paddingElements() const
Returns the number of padding elements at the end of each plane row, in elements.
Definition Frame.h:3675
void * allocatedData_
The pointer to the memory which this plane has allocated, this pointer is pointing to the memory whic...
Definition Frame.h:2303
unsigned int paddingBytes() const
Returns the number of padding bytes at the end of each plane row, in bytes.
Definition Frame.h:3680
unsigned int elementTypeSize() const
Returns the size of each element of this plane.
Definition Frame.h:3685
bool isOwner() const
Returns whether this plane is the owner of the memory.
Definition Frame.h:3744
unsigned int calculateStrideBytes() const
Calculates the number of bytes between the start positions of two consecutive rows,...
Definition Frame.h:3790
void * data_
The pointer to the writable memory of the plane (not the pointer to the allocated memory),...
Definition Frame.h:2309
unsigned int strideBytes() const
Returns the number of bytes between the start positions of two consecutive rows, in bytes.
Definition Frame.h:3711
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:3739
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:3664
bool isValid() const
Returns whether this plane holds valid data.
Definition Frame.h:3754
T * data()
Returns the writable memory pointer to this plane with a specific data type compatible with elementTy...
Definition Frame.h:3670
bool isReadOnly() const
Returns whether this plane holds read-only memory.
Definition Frame.h:3749
unsigned int size() const
Returns the number of bytes necessary for the entire plane data including optional padding elements a...
Definition Frame.h:3732
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:3759
unsigned int widthBytes() const
Returns the width of the plane in bytes, the width does not contain optional padding elements.
Definition Frame.h:3697
~Plane()
Destructs a Plane object.
Definition Frame.h:3643
Plane()=default
Creates a new invalid plane.
unsigned int channels() const
Returns the channels of the plane.
Definition Frame.h:3658
const void * constData_
The pointer to the read-only memory of the plane (not the pointer to the allocated memory),...
Definition Frame.h:2306
unsigned int bytesPerPixel() const
Returns the number of bytes which is used for each pixel.
Definition Frame.h:3719
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:3704
Plane(const Plane &plane, const AdvancedCopyMode advancedCopyMode=ACM_USE_OR_COPY_KEEP_LAYOUT) noexcept
Copy constructor.
unsigned int height() const
Returns the height of the plane in pixel.
Definition Frame.h:3653
unsigned int paddingElements_
The number of padding elements at the end of each plane row, in elements, with range [0,...
Definition Frame.h:2324
unsigned int widthElements() const
Returns the width of the plane in elements, the width does not contain optional padding elements.
Definition Frame.h:3690
This class implements a helper class which can be used to initialize a multi-plane frame in the const...
Definition Frame.h:2345
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:3798
static std::vector< PlaneInitializer< T > > createPlaneInitializersWithPaddingElements(const Indices32 &paddingElementsPerPlane)
Creates plane initializer objects with padding elements only.
Definition Frame.h:3828
This class implements Ocean's image class.
Definition Frame.h:1879
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:2409
Timestamp relativeTimestamp_
Relative timestamp of this frame.
Definition Frame.h:3161
bool isContinuous() const
Returns whether all planes of this frame have continuous memory and thus do not contain any padding a...
Definition Frame.h:4440
bool hasAlphaChannel() const
Returns whether the frame's pixel format contains an alpha channel.
Definition Frame.h:4485
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:4230
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:3158
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:4222
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:4341
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:3947
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:4332
void setRelativeTimestamp(const Timestamp &relative)
Sets the relative timestamp of this frame.
Definition Frame.h:4317
const FrameType & frameType() const
Returns the frame type of this frame.
Definition Frame.h:3936
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:4323
bool isValid() const
Returns whether this frame is valid.
Definition Frame.h:4612
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:4373
void setTimestamp(const Timestamp ×tamp)
Sets the timestamp of this frame.
Definition Frame.h:4312
bool isReadOnly() const
Returns true, if the frame allows only read access (using constdata()).
Definition Frame.h:4470
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:4302
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:4278
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:4262
std::vector< PlaneInitializer< T > > PlaneInitializers
Definition of a vector holding plane initializer objects.
Definition Frame.h:2401
const Timestamp & relativeTimestamp() const
Returns the relative timestamp of this frame.
Definition Frame.h:4307
const Planes & planes() const
Returns the individual planes of this frame.
Definition Frame.h:3941
bool isOwner() const
Returns whether the frame is the owner of the internal frame data.
Definition Frame.h:4455
CopyMode
Definition of individual copy modes.
Definition Frame.h:1886
@ CM_USE_KEEP_LAYOUT
The source memory is used only, no copy is created, the padding layout is preserved.
Definition Frame.h:1888
unsigned int planeChannels(const unsigned int planeIndex) const
Returns the channels of a plane of this frame.
Definition Frame.h:4254
unsigned int planeWidth(const unsigned int planeIndex) const
Returns the width of a plane of this frame.
Definition Frame.h:4238
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:3841
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:4414
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:1901
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:4286
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:4085
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:4294
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:4214
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:4357
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:4270
bool hasTransparentPixel(const T opaque) const
Returns whether the frame holds at least one pixel with an non opaque alpha value.
Definition Frame.h:4607
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:4246
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:4198
Planes planes_
The individual memory planes of this frame.
Definition Frame.h:3155
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:4206
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
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:3533
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:3291
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:649
@ FORMAT_BGRA4444
Pixel format with entirely 16 bits per pixel, 4 bits for each channel.
Definition Frame.h:282
@ 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:675
@ FORMAT_RGBA4444
Pixel format with entirely 16 bits per pixel, 4 bits for each channel.
Definition Frame.h:395
@ FORMAT_ARGB32
Pixel format with byte order ARGB and 32 bits per pixel.
Definition Frame.h:213
@ FORMAT_ABGR32
Pixel format with byte order ABGR and 32 bits per pixel.
Definition Frame.h:200
@ FORMAT_RGBA32
Pixel format with byte order RGBA and 32 bits per pixel.
Definition Frame.h:382
@ FORMAT_YUVA32
Pixel format with byte order YUVA and 32 bits per pixel.
Definition Frame.h:472
@ FORMAT_BGRA32
Pixel format with byte order BGRA and 32 bits per pixel.
Definition Frame.h:277
unsigned int width() const
Returns the width of the frame format in pixel.
Definition Frame.h:3241
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
bool isPixelFormatDataLayoutCompatible(const PixelFormat pixelFormat) const
Returns whether this pixel format has a compatible data layout with a given pixel format.
Definition Frame.h:3303
PixelOrigin pixelOrigin() const
Returns the pixel origin of the frame.
Definition Frame.h:3286
std::vector< PixelFormat > PixelFormats
Definition of a vector holding pixel formats.
Definition Frame.h:1040
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.
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:3445
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:3591
unsigned int height_
Frame height in pixel, with range [0, infinity)
Definition Frame.h:1825
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:3580
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:3318
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:3586
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:3281
PixelOrigin pixelOrigin_
The origin of the pixel data, either the upper left corner or the bottom left corner (if valid).
Definition Frame.h:1831
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
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:3538
PixelFormat pixelFormat() const
Returns the pixel format of the frame.
Definition Frame.h:3251
unsigned int bytesPerDataType() const
Returns the number of bytes which are necessary to store the data type of this frame.
Definition Frame.h:3266
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:1046
@ ORIGIN_INVALID
Invalid origin type.
Definition Frame.h:1048
@ ORIGIN_UPPER_LEFT
The first pixel lies in the upper left corner, the last pixel in the lower right corner.
Definition Frame.h:1050
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
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:3543
unsigned int height() const
Returns the height of the frame in pixel.
Definition Frame.h:3246
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:1822
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:3526
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:3323
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:3298
unsigned int channels() const
Returns the number of individual channels the frame has.
Definition Frame.h:3271
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:1828
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:3261
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:3509
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:3462
bool isFrameTypeCompatible(const FrameType &frameType, const bool allowDifferentPixelOrigins) const
Returns whether this frame type is compatible with a given frame type.
Definition Frame.h:3308
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:3333
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:3516
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:3256
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:3313
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
bool isEmpty() const
Returns whether this vector is empty.
Definition StackHeapVector.h:695
size_t size() const
Returns the number of elements of this vector.
Definition StackHeapVector.h:681
This class implements a timestamp.
Definition Timestamp.h:64
std::vector< Index32 > Indices32
Definition of a vector holding 32 bit index values.
Definition Base.h:96
std::vector< Frame > Frames
Definition of a vector holding padding frames.
Definition Frame.h:1842
std::vector< FrameRef > FrameRefs
Definition of a vector holding frame references.
Definition Frame.h:1854
uint32_t Index32
Definition of a 32 bit index value.
Definition Base.h:84
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Default definition of a type with tBytes bytes.
Definition DataType.h:32