[PATCH] cam: Convert RGB variations to BGR
Pavel Machek
pavel at ucw.cz
Fri May 2 22:12:42 CEST 2025
Hi!
> > swIsp with libcamera produces ARGB data by default, which needs
> > conversion during write. Implement it and similar conversions.
> > Signed-off-by: Pavel Machek <pavel at ucw.cz>
> >
> > diff --git a/src/apps/common/ppm_writer.cpp b/src/apps/common/ppm_writer.cpp
> > index 368de8bf..ddbd3263 100644
> > --- a/src/apps/common/ppm_writer.cpp
> > +++ b/src/apps/common/ppm_writer.cpp
> > @@ -20,8 +20,56 @@ int PPMWriter::write(const char *filename,
> > const StreamConfiguration &config,
> > const Span<uint8_t> &data)
> > {
> > - if (config.pixelFormat != formats::BGR888) {
> > - std::cerr << "Only BGR888 output pixel format is supported ("
> > + int r_pos, g_pos, b_pos, bpp;
>
> I think the "pos" variables should probably be camelCase.
> And please add an empty line after them.
...thanks for comments, I can fix the style. Laurent, is there still
interest in this patch? swIsp does not really need it, but some
hardware might and tiff writer has similar conversions.
> As for performance, I have briefly taken a look at the x86 assembly of the inner
> loop, it looks pretty acceptable to me. Apart from the fact that the vector's
> operator[] adds three branches because meson sets `_GLIBCXX_ASSERTIONS=1` unless
> `b_ndebug=true`. So that is not too good, but it is probably not too significant.
Well, I strongly suspect reducing ammount of write syscalls (writev)
would help significantly. But that's already problem with existing
code and would make code more complex.
> But whether or not the soft ISP will support other formats, I think it's useful to
> support multiple formats here, even at the cost of conversion. Especially since PPM
> is not a container or such, so if the user explicitly selects it, I think they
> expect that anything coming out of the camera will be converted appropriately.
>
> In addition, it appears to me that qcam already has a sizable set of format
> conversions implemented. I wonder if those could be used somehow.
Ok, someone let me know if I should clean this up and retry.
Best regards,
Pavel
--
I don't work for Nazis and criminals, and neither should you.
Boycott Putin, Trump, and Musk!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20250502/fd61fd97/attachment.sig>
More information about the libcamera-devel
mailing list