summaryrefslogtreecommitdiff
path: root/include
AgeCommit message (Expand)Author
2019-01-08libcamera: Add a poll-based event dispatcherLaurent Pinchart
2019-01-08libcamera: Add event notification infrastructureLaurent Pinchart
2019-01-08libcamera: Add signal/slot communication mechanismLaurent Pinchart
2019-01-08libcamera: camera_manager: Make the class a singletonLaurent Pinchart
2019-01-04libcamera: camera_manager: Sort includes alphabeticallyLaurent Pinchart
2019-01-04libcamera: camera_manager: Remove put() methodLaurent Pinchart
2019-01-02libcamera: Remove libcamera classLaurent Pinchart
2018-12-31libcamera: camera_manager: add CameraManager classNiklas Söderlund
2018-12-31libcamera: Add Camera classNiklas Söderlund
2018-12-19libcamera: include: Import media.h from Linux v4.19Jacopo Mondi
2018-12-11build: Clean up file names variablesLaurent Pinchart
2018-12-06libcamera: Use the logger instead of coutLaurent Pinchart
2018-12-06Add boilerplate headers comments and include guardsLaurent Pinchart
2018-11-28meson: Replace tabs for spacesKieran Bingham
2018-11-27include: Install include filesKieran Bingham
2018-10-24build: Provide initial meson infrastructureKieran Bingham
' href='#n63'>63 64 65 66
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2019, Google Inc.
 *
 * formats.h - libcamera image formats
 */

#pragma once

#include <array>
#include <map>
#include <vector>

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

#include "libcamera/internal/v4l2_pixelformat.h"

namespace libcamera {

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

	struct Plane {
		unsigned int bytesPerGroup;
		unsigned int verticalSubSampling;
	};

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

	static const PixelFormatInfo &info(const PixelFormat &format);
	static const PixelFormatInfo &info(const V4L2PixelFormat &format);
	static const PixelFormatInfo &info(const std::string &name);

	unsigned int stride(unsigned int width, unsigned int plane,
			    unsigned int align = 1) const;
	unsigned int planeSize(const Size &size, unsigned int plane,
			       unsigned int align = 1) const;
	unsigned int planeSize(unsigned int height, unsigned int plane,
			       unsigned int stride) const;
	unsigned int frameSize(const Size &size, unsigned int align = 1) const;
	unsigned int frameSize(const Size &size,
			       const std::array<unsigned int, 3> &strides) const;

	unsigned int numPlanes() const;

	/* \todo Add support for non-contiguous memory planes */
	const char *name;
	PixelFormat format;
	std::vector<V4L2PixelFormat> v4l2Formats;
	unsigned int bitsPerPixel;
	enum ColourEncoding colourEncoding;
	bool packed;

	unsigned int pixelsPerGroup;

	std::array<Plane, 3> planes;
};

} /* namespace libcamera */