mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-15 08:25:07 +03:00
To each libcamera PixelFormat two V4L2 formats are associated, the 'single' and 'multi' format variants. The two versions list plane contiguous and non-contiguous format variants, and an optional argument to V4L2PixelFormat::fromPixelFormat() was used to select which one to pick. In order to prepare to remove V4L2PixelFormat::fromPixelFormat(), and considering that no caller in the codebase uses the non-contiguous format variant, merge the two formats vectors in a single one and default the selection to the first available one, which is functionally equivalent to what is currently implemented. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com>
66 lines
1.6 KiB
C++
66 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;
|
|
std::vector<V4L2PixelFormat> v4l2Formats;
|
|
unsigned int bitsPerPixel;
|
|
enum ColourEncoding colourEncoding;
|
|
bool packed;
|
|
|
|
unsigned int pixelsPerGroup;
|
|
|
|
std::array<Plane, 3> planes;
|
|
};
|
|
|
|
} /* namespace libcamera */
|