diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-02-05 12:13:36 +0200 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-03-26 15:44:00 +0200 |
| commit | d08ecb56e9779d5190bc6423a1cad596756881ef (patch) | |
| tree | 176bad270f9a57c2de0885818c99489ea2afb2fd /kms++/src/pixelformats.cpp | |
| parent | a35d57fa9088fbccd468ad095c89aba096b2494e (diff) | |
PixelFormats: Switch to non-fourcc PixelFormat enum
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Diffstat (limited to 'kms++/src/pixelformats.cpp')
| -rw-r--r-- | kms++/src/pixelformats.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp index 8e3a120..cdd742c 100644 --- a/kms++/src/pixelformats.cpp +++ b/kms++/src/pixelformats.cpp @@ -235,6 +235,30 @@ const struct PixelFormatInfo& get_pixel_format_info(PixelFormat format) return format_info_array.at(format); } +PixelFormat fourcc_to_pixel_format(uint32_t fourcc) +{ + for (const auto& [fmt, pfi] : format_info_array) { + if (pfi.drm_fourcc == fourcc) + return fmt; + } + + throw invalid_argument("FourCC not supported"); +} + +uint32_t pixel_format_to_fourcc(PixelFormat f) +{ + return format_info_array.at(f).drm_fourcc; +} + +PixelFormat fourcc_str_to_pixel_format(const std::string& fourcc) +{ + return fourcc_to_pixel_format(str_to_fourcc(fourcc)); +} + +std::string pixel_format_to_fourcc_str(PixelFormat f) +{ + return fourcc_to_str(format_info_array.at(f).drm_fourcc); +} static constexpr uint32_t _div_round_up(uint32_t a, uint32_t b) { |
