libcamera/include/libcamera/internal/formats.h
Kieran Bingham df131ad088 libcamera: internal: Convert to pragma once
Remove the verbose #ifndef/#define/#endif pattern for maintaining
header idempotency, and replace it with a simple #pragma once.

This simplifies the headers, and prevents redundant changes when
header files get moved.

Tracepoints.h.in is not modified to use the pragma as it requires
self-inclusion.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
2021-11-24 12:18:17 +00:00

69 lines
1.6 KiB
C++

/* 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;
struct {
V4L2PixelFormat single;
V4L2PixelFormat multi;
} v4l2Formats;
unsigned int bitsPerPixel;
enum ColourEncoding colourEncoding;
bool packed;
unsigned int pixelsPerGroup;
std::array<Plane, 3> planes;
};
} /* namespace libcamera */