libcamera: v4l2PixelFormat: Replace hex with fourCC
Print fourCC characters instead of the hex value in toString() as they are more informative. Also, write the tests for this in formats.cpp Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
committed by
Kieran Bingham
parent
6f553040fd
commit
2fbab8b077
@@ -336,9 +336,23 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const
|
||||
*/
|
||||
std::string V4L2PixelFormat::toString() const
|
||||
{
|
||||
char str[11];
|
||||
snprintf(str, 11, "0x%08x", fourcc_);
|
||||
return str;
|
||||
if (fourcc_ == 0)
|
||||
return "<INVALID>";
|
||||
|
||||
char ss[8] = { static_cast<char>(fourcc_ & 0x7f),
|
||||
static_cast<char>((fourcc_ >> 8) & 0x7f),
|
||||
static_cast<char>((fourcc_ >> 16) & 0x7f),
|
||||
static_cast<char>((fourcc_ >> 24) & 0x7f) };
|
||||
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
if (!isprint(ss[i]))
|
||||
ss[i] = '.';
|
||||
}
|
||||
|
||||
if (fourcc_ & (1 << 31))
|
||||
strcat(ss, "-BE");
|
||||
|
||||
return ss;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user