libcamera/include/libcamera/internal/formats.h
Kaaira Gupta 2129117df9 libcamera: pixel_format: Replace hex with format names
Print format names defined in formats namespace instead of the hex
values in toString() as they are easier to comprehend. For this add
a property of 'name' in PixelFormatInfo' so as to map the formats
with their names. Print fourcc for formats which are not used in
libcamera.

Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2020-06-25 06:47:48 +03:00

59 lines
1.3 KiB
C++

/* 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 */
const char *name;
PixelFormat format;
V4L2PixelFormat v4l2Format;
unsigned int bitsPerPixel;
enum ColourEncoding colourEncoding;
bool packed;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_FORMATS_H__ */