libcamera  v0.0.0+3695-a2c715d8
Supporting cameras in Linux since 2019
v4l2_pixelformat.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2019, Google Inc.
4  * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
5  *
6  * v4l2_pixelformat.h - V4L2 Pixel Format
7  */
8 
9 #pragma once
10 
11 #include <ostream>
12 #include <stdint.h>
13 #include <string>
14 
15 #include <linux/videodev2.h>
16 
17 #include <libcamera/pixel_format.h>
18 
19 namespace libcamera {
20 
22 {
23 public:
24  struct Info {
26  const char *description;
27  };
28 
30  : fourcc_(0)
31  {
32  }
33 
34  explicit V4L2PixelFormat(uint32_t fourcc)
35  : fourcc_(fourcc)
36  {
37  }
38 
39  bool isValid() const { return fourcc_ != 0; }
40  uint32_t fourcc() const { return fourcc_; }
41  operator uint32_t() const { return fourcc_; }
42 
43  std::string toString() const;
44  const char *description() const;
45 
46  PixelFormat toPixelFormat() const;
47  static V4L2PixelFormat fromPixelFormat(const PixelFormat &pixelFormat,
48  bool multiplanar = false);
49 
50 private:
51  uint32_t fourcc_;
52 };
53 
54 std::ostream &operator<<(std::ostream &out, const V4L2PixelFormat &f);
55 
56 } /* namespace libcamera */
libcamera image pixel format
Definition: pixel_format.h:17
V4L2 pixel format FourCC wrapper.
Definition: v4l2_pixelformat.h:21
Top-level libcamera namespace.
Definition: backtrace.h:17
PixelFormat format
The corresponding libcamera PixelFormat.
Definition: v4l2_pixelformat.h:25
PixelFormat toPixelFormat() const
Convert the V4L2 pixel format to the corresponding PixelFormat.
Definition: v4l2_pixelformat.cpp:293
std::string toString() const
Assemble and return a string describing the pixel format.
Definition: v4l2_pixelformat.cpp:246
uint32_t fourcc() const
Retrieve the pixel format FourCC numerical value.
Definition: v4l2_pixelformat.h:40
const char * description
The human-readable description of the V4L2 pixel format.
Definition: v4l2_pixelformat.h:26
std::ostream & operator<<(std::ostream &out, const Point &p)
Insert a text representation of a Point into an output stream.
Definition: geometry.cpp:91
bool isValid() const
Check if the pixel format is valid.
Definition: v4l2_pixelformat.h:39
static V4L2PixelFormat fromPixelFormat(const PixelFormat &pixelFormat, bool multiplanar=false)
Convert pixelFormat to its corresponding V4L2PixelFormat.
Definition: v4l2_pixelformat.cpp:319
Information about a V4L2 pixel format.
Definition: v4l2_pixelformat.h:24
V4L2PixelFormat()
Construct a V4L2PixelFormat with an invalid format.
Definition: v4l2_pixelformat.h:29
V4L2PixelFormat(uint32_t fourcc)
Construct a V4L2PixelFormat from a FourCC value.
Definition: v4l2_pixelformat.h:34
libcamera pixel format