summaryrefslogtreecommitdiff
path: root/include/libcamera/internal/formats.h
blob: 4b172efc6588d374845bd0b8eb15e75f0138a26a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * formats.h - libcamera image formats
 */

#ifndef __LIBCAMERA_INTERNAL_FORMATS_H__
#define __LIBCAMERA_INTERNAL_FORMATS_H__

#include <map>
#include <vector>

#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>

#include "libcamera/internal/v4l2_pixelformat.h"

namespace libcamera {

class ImageFormats
{
public:
	int addFormat(unsigned int format, const std::vector<SizeRange> &sizes);

	bool isEmpty() const;
	std::vector<unsigned int> formats() const;
	const std::vector<SizeRange> &sizes(unsigned int format) const;
	const std::map<unsigned int, std::vector<SizeRange>> &data() const;

private:
	std::map<unsigned int, std::vector<SizeRange>> data_;
};

class PixelFormatInfo
{
public:
	enum ColourEncoding {
		ColourEncodingRGB,
		ColourEncodingYUV,
		ColourEncodingRAW,
	};

	bool isValid() const { return format.isValid(); }

	static const PixelFormatInfo &info(const PixelFormat &format);

	/* \todo Add support for non-contiguous memory planes */
	PixelFormat format;
	V4L2PixelFormat v4l2Format;
	unsigned int bitsPerPixel;
	enum ColourEncoding colourEncoding;
	bool packed;
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_INTERNAL_FORMATS_H__ */