[libcamera-devel] [PATCH] libcamera: stream_option: use fourcc values to set cam/qcam formats
Kaaira Gupta
kgupta at es.iitr.ac.in
Fri May 29 16:04:33 CEST 2020
Replace hex input for pixelformats with their fourcc values,
in cam and qcam.
Signed-off-by: Kaaira Gupta <kgupta at es.iitr.ac.in>
---
src/cam/stream_options.cpp | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp
index bd12c8f..9f9536e 100644
--- a/src/cam/stream_options.cpp
+++ b/src/cam/stream_options.cpp
@@ -6,6 +6,7 @@
*/
#include "stream_options.h"
+#include <bits/stdc++.h>
#include <iostream>
using namespace libcamera;
@@ -19,7 +20,7 @@ StreamKeyValueParser::StreamKeyValueParser()
ArgumentRequired);
addOption("height", OptionInteger, "Height in pixels",
ArgumentRequired);
- addOption("pixelformat", OptionInteger, "Pixel format",
+ addOption("pixelformat", OptionString, "Pixel format fourcc",
ArgumentRequired);
}
@@ -96,8 +97,14 @@ int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config,
}
/* \todo Translate 4CC string to pixelformat with modifier. */
- if (opts.isSet("pixelformat"))
- cfg.pixelFormat = PixelFormat(opts["pixelformat"]);
+ if (opts.isSet("pixelformat")) {
+ std::string fourcc = opts["pixelformat"];
+ transform(fourcc.begin(), fourcc.end(), fourcc.begin(), ::toupper);
+ char char_array[5];
+ strcpy(char_array, fourcc.c_str());
+ cfg.pixelFormat = PixelFormat((__u32)(char_array[0]) | ((__u32)(char_array[1]) << 8) |
+ ((__u32)(char_array[2]) << 16) | ((__u32)(char_array[3]) << 24));
+ }
}
return 0;
--
2.17.1
More information about the libcamera-devel
mailing list