[libcamera-devel,0/3] Fix colour spaces on Raspberry Pi
mbox series

Message ID 20221216143344.8177-1-david.plowman@raspberrypi.com
Headers show
Series
  • Fix colour spaces on Raspberry Pi
Related show

Message

David Plowman Dec. 16, 2022, 2:33 p.m. UTC
Hi everyone

I'm guessing that not too many of you are aware that mainline
libcamera has been broken on the Raspberry Pi since the
summer. Specifically, changes to the way colour spaces work were
responsible, and since then we've been living off our own fork of the
tree with enough of those changes reverted.

But clearly this is not a good situation so this patch set makes
libcamera work on the Raspberry Pi again.

There are 3 patches. I sense some of them may provoke a fair bit of
discussion.

1. I think the first patch will be uncontroversial, it merely fixes a
bug in validateColorSpaces that has been there since the dawn of time,
but no one ever noticed!

2. Again in validateColorSpaces, we note that "streams sharing a
colour space" is quite broken because RGB streams have no YCbCr
information in them, and would therefore destroy any YUV streams they
get "shared" on top of! We fix that by choosing not only a "principal"
stream, but also a "principal" YUV stream.

This has all become annoyingly complicated and I wonder whether we
should just remove this whole "colour space sharing" thing. I thought
I was doing the world a favour but honestly, it might be easier to
deal with in the Raspberry Pi PH where the options are considerably
more constrained. Opinions sought on that, please!

3. The last patch is the worst. It does some massaging on colour
spaces so that the "right" conversions happen downstream, the "right"
things get passed to the Raspberry Pi hardware drivers (that only care
about the V4L2_COLORSPACE) and it also knows how to check more
carefully whether what gets returned is really what it expected.

There is obviously a degree of trade-off between what is happening
here and the behaviour of the underlying layers of software, which is
something one might want to look at. Though I wouldn't want people to
forget that things are broken for us right now!

Having said all that, and in spite of the general angst, these patches
do actually work.

Thanks!
David

David Plowman (3):
  libcamera: camera: fix validateColorSpaces to choose the correct
    "main" colour space
  libcamera: camera: Fix validateColorSpaces not to loose YCbCr
    encodings
  pipeline: raspberrypi: Fix colour spaces by handling missing YCbCr
    information

 src/libcamera/camera.cpp                      | 51 +++++++++++++++--
 .../pipeline/raspberrypi/raspberrypi.cpp      | 56 ++++++++++++++++++-
 2 files changed, 99 insertions(+), 8 deletions(-)