summaryrefslogtreecommitdiff
path: root/kms++
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2019-04-09 10:20:15 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2019-04-09 10:21:47 +0300
commit626edbe2fc845803ffdd25936e21202e4f123b63 (patch)
treeca438f77a5f1bdd2057c0769d4886ac9a534ca5b /kms++
parent521a8cdc9f34cc4707731b0640e72615cc89d9cb (diff)
add support for more pixel formats
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'kms++')
-rw-r--r--kms++/inc/kms++/pixelformats.h22
-rw-r--r--kms++/src/pixelformats.cpp50
2 files changed, 56 insertions, 16 deletions
diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h
index 1e273ef..15fee7f 100644
--- a/kms++/inc/kms++/pixelformats.h
+++ b/kms++/inc/kms++/pixelformats.h
@@ -24,8 +24,13 @@ enum class PixelFormat : uint32_t
XRGB8888 = MakeFourCC("XR24"),
XBGR8888 = MakeFourCC("XB24"),
+ RGBX8888 = MakeFourCC("RX24"),
+ BGRX8888 = MakeFourCC("BX24"),
+
ARGB8888 = MakeFourCC("AR24"),
ABGR8888 = MakeFourCC("AB24"),
+ RGBA8888 = MakeFourCC("RA24"),
+ BGRA8888 = MakeFourCC("BA24"),
RGB888 = MakeFourCC("RG24"),
BGR888 = MakeFourCC("BG24"),
@@ -35,6 +40,16 @@ enum class PixelFormat : uint32_t
ARGB4444 = MakeFourCC("AR12"),
ARGB1555 = MakeFourCC("AR15"),
+
+ XRGB2101010 = MakeFourCC("XR30"),
+ XBGR2101010 = MakeFourCC("XB30"),
+ RGBX1010102 = MakeFourCC("RX30"),
+ BGRX1010102 = MakeFourCC("BX30"),
+
+ ARGB2101010 = MakeFourCC("AR30"),
+ ABGR2101010 = MakeFourCC("AB30"),
+ RGBA1010102 = MakeFourCC("RA30"),
+ BGRA1010102 = MakeFourCC("BA30"),
};
static inline PixelFormat FourCCToPixelFormat(const std::string& fourcc)
@@ -52,6 +67,12 @@ static inline std::string PixelFormatToFourCC(PixelFormat f)
return std::string(buf);
}
+enum class PixelColorType
+{
+ RGB,
+ YUV,
+};
+
struct PixelFormatPlaneInfo
{
uint8_t bitspp;
@@ -61,6 +82,7 @@ struct PixelFormatPlaneInfo
struct PixelFormatInfo
{
+ PixelColorType type;
uint8_t num_planes;
struct PixelFormatPlaneInfo planes[4];
};
diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp
index 819853b..ecca41d 100644
--- a/kms++/src/pixelformats.cpp
+++ b/kms++/src/pixelformats.cpp
@@ -8,31 +8,49 @@ namespace kms
{
static const map<PixelFormat, PixelFormatInfo> format_info_array = {
/* YUV packed */
- { PixelFormat::UYVY, { 1, { { 16, 2, 1 } }, } },
- { PixelFormat::YUYV, { 1, { { 16, 2, 1 } }, } },
- { PixelFormat::YVYU, { 1, { { 16, 2, 1 } }, } },
- { PixelFormat::VYUY, { 1, { { 16, 2, 1 } }, } },
+ { PixelFormat::UYVY, { PixelColorType::YUV, 1, { { 16, 2, 1 } }, } },
+ { PixelFormat::YUYV, { PixelColorType::YUV, 1, { { 16, 2, 1 } }, } },
+ { PixelFormat::YVYU, { PixelColorType::YUV, 1, { { 16, 2, 1 } }, } },
+ { PixelFormat::VYUY, { PixelColorType::YUV, 1, { { 16, 2, 1 } }, } },
/* YUV semi-planar */
- { PixelFormat::NV12, { 2, { { 8, 1, 1, }, { 8, 2, 2 } }, } },
- { PixelFormat::NV21, { 2, { { 8, 1, 1, }, { 8, 2, 2 } }, } },
+ { PixelFormat::NV12, { PixelColorType::YUV, 2, { { 8, 1, 1, }, { 8, 2, 2 } }, } },
+ { PixelFormat::NV21, { PixelColorType::YUV, 2, { { 8, 1, 1, }, { 8, 2, 2 } }, } },
/* RGB16 */
- { PixelFormat::RGB565, { 1, { { 16, 1, 1 } }, } },
- { PixelFormat::BGR565, { 1, { { 16, 1, 1 } }, } },
+ { PixelFormat::RGB565, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
+ { PixelFormat::BGR565, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
/* RGB24 */
- { PixelFormat::RGB888, { 1, { { 24, 1, 1 } }, } },
- { PixelFormat::BGR888, { 1, { { 24, 1, 1 } }, } },
+ { PixelFormat::RGB888, { PixelColorType::RGB, 1, { { 24, 1, 1 } }, } },
+ { PixelFormat::BGR888, { PixelColorType::RGB, 1, { { 24, 1, 1 } }, } },
/* RGB32 */
- { PixelFormat::XRGB8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::XBGR8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::ARGB8888, { 1, { { 32, 1, 1 } }, } },
- { PixelFormat::ABGR8888, { 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::XRGB8888, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::XBGR8888, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::RGBX8888, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::BGRX8888, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
- { PixelFormat::ARGB4444, { 1, { { 16, 1, 1 } }, } },
- { PixelFormat::ARGB1555, { 1, { { 16, 1, 1 } }, } },
+ { PixelFormat::ARGB8888, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::ABGR8888, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::RGBA8888, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::BGRA8888, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+
+ { PixelFormat::XRGB2101010, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::XBGR2101010, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::RGBX1010102, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::BGRX1010102, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+
+ { PixelFormat::ARGB2101010, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::ABGR2101010, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::RGBA1010102, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+ { PixelFormat::BGRA1010102, { PixelColorType::RGB, 1, { { 32, 1, 1 } }, } },
+
+ { PixelFormat::ARGB4444, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
+ { PixelFormat::ARGB1555, { PixelColorType::RGB, 1, { { 16, 1, 1 } }, } },
};
const struct PixelFormatInfo& get_pixel_format_info(PixelFormat format)
{
+ if (!format_info_array.count(format))
+ throw invalid_argument("get_pixel_format_info: Unsupported pixelformat");
+
return format_info_array.at(format);
}