[libcamera-devel] [PATCH 0/2] Improve BayerFormat class

Sebastian Fricke sebastian.fricke.linux at gmail.com
Wed Dec 23 13:10:53 CET 2020


This patch series adds unit-tests and the `fromV4L2PixelFormat` method
to the BayerFormat class.

I also wanted to discuss one alternative that I played around with.
We could maybe drop one of the two mapping tables and use the following
logic to get the map key from a mapped value.

```
#include <algorithm>
...
BayerFormat BayerFormat::fromV4L2PixelFormat(V4L2PixelFormat v4l2Format) const
{
    auto it = std::find_if(
        bayerToV4l2.begin(),
        bayerToV4l2.end(),
        [v4l2Format](const auto& i) { return i->second == v4l2Format; }
    );
    if (it != bayerToV4l2.end())
        return it->first;

    return BayerFormat();
}
```

Sebastian Fricke (2):
  libcamera: Add the fromV4L2PixelFormat method
  test: Add unit tests for the BayerFormat class

 include/libcamera/internal/bayer_format.h |   1 +
 src/libcamera/bayer_format.cpp            |  14 ++
 test/bayer_format.cpp                     | 154 ++++++++++++++++++++++
 test/meson.build                          |   1 +
 4 files changed, 170 insertions(+)
 create mode 100644 test/bayer_format.cpp

-- 
2.29.2



More information about the libcamera-devel mailing list