summaryrefslogtreecommitdiff
path: root/src/cam/main.h
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-05-22 03:13:06 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-06-06 00:25:04 +0300
commitf3f1807a1f88136e3159a1399dfd6ed9d30b0085 (patch)
tree467562ac0c7b06d591f7ed78dc9028baa63dc4d3 /src/cam/main.h
parent08a75925d86605d63f115e76ad7644ba194812a4 (diff)
libcamera: Replace C++ comments with C comments
The control_ids.h.in and property_ids.h.in headers use C++-style comments, when the coding style mandates C-style comments. Fix them. While at it, adjust three minor typos in comments. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'src/cam/main.h')
0 files changed, 0 insertions, 0 deletions
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2020, Sebastian Fricke
 *
 * bayer_format.cpp - BayerFormat class tests
 */

#include <iostream>

#include <libcamera/transform.h>

#include "libcamera/internal/bayer_format.h"

#include "test.h"

using namespace std;
using namespace libcamera;

class BayerFormatTest : public Test
{
protected:
	int run()
	{
		/* An empty Bayer format has to be invalid. */
		BayerFormat bayerFmt;
		if (bayerFmt.isValid()) {
			cerr << "An empty BayerFormat has to be invalid."
			     << endl;
			return TestFail;
		}

		/* A correct Bayer format has to be valid. */
		bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None);
		if (!bayerFmt.isValid()) {
			cerr << "A correct BayerFormat has to be valid."
			     << endl;
			return TestFail;
		}

		/*
		 * Two bayer formats created with the same order and bit depth
		 * have to be equal.
		 */
		bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None);
		BayerFormat bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8,
							 BayerFormat::Packing::None);
		if (bayerFmt != bayerFmtExpect) {
			cerr << "Comparison of identical formats failed."
			     << endl;
			return TestFail;
		}

		/*
		 * Two Bayer formats created with the same order but with a
		 * different bitDepth are not equal.
		 */
		bayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::Packing::None);
		bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 12,
					     BayerFormat::Packing::None);
		if (bayerFmt == bayerFmtExpect) {
			cerr << "Comparison of different formats failed."
			     << endl;
			return TestFail;
		}

		/*
		 * Create a Bayer format with a V4L2PixelFormat and check if we
		 * get the same format after converting back to the V4L2 Format.
		 */
		V4L2PixelFormat v4l2FmtExpect = V4L2PixelFormat(
			V4L2_PIX_FMT_SBGGR8);
		bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtExpect);
		V4L2PixelFormat v4l2Fmt = bayerFmt.toV4L2PixelFormat();
		if (v4l2Fmt != v4l2FmtExpect) {
			cerr << "Expected: '" << v4l2FmtExpect
			     << "' got: '" << v4l2Fmt << "'" << endl;
			return TestFail;
		}

		/*
		 * Use an empty Bayer format and verify that no matching
		 * V4L2PixelFormat is found.
		 */
		v4l2FmtExpect = V4L2PixelFormat();
		bayerFmt = BayerFormat();
		v4l2Fmt = bayerFmt.toV4L2PixelFormat();
		if (v4l2Fmt != v4l2FmtExpect) {
			cerr << "Expected: empty V4L2PixelFormat got: '"
			     << v4l2Fmt << "'" << endl;
			return TestFail;
		}

		/*
		 * Check if we get the expected Bayer format BGGR8
		 * when we convert the V4L2PixelFormat (V4L2_PIX_FMT_SBGGR8)
		 * to a Bayer format.
		 */
		bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8,
					     BayerFormat::Packing::None);
		v4l2Fmt = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);
		bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2Fmt);
		if (bayerFmt != bayerFmtExpect) {
			cerr << "Expected BayerFormat '"
			     << bayerFmtExpect << "', got: '"
			     << bayerFmt << "'" << endl;
			return TestFail;
		}

		/*
		 * Confirm that a V4L2PixelFormat that is not found in
		 * the conversion table, doesn't yield a Bayer format.
		 */
		V4L2PixelFormat v4l2FmtUnknown = V4L2PixelFormat(
			V4L2_PIX_FMT_BGRA444);
		bayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtUnknown);