summaryrefslogtreecommitdiff
path: root/src/py/cam/helpers.py
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2023-10-13 08:48:39 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-10-18 11:01:23 +0100
commitac232470fb3182b8b6299a7d317681d540561d5d (patch)
treee341e1034bf38b840638788524b141e93d607cfd /src/py/cam/helpers.py
parent0ff20bf8c1d21ffbb3694b67756abc59151132cf (diff)
ipa: rpi: denoise: Support different denoise configurations
Some use cases may require stronger, or different, denosie settings to others. For example, the way frames are accumulated during single exposure HDR means that we may want stronger denoise. This commit adds such support for different configurations that can be defined in the tuning file. Older tuning files, or files where there is only a single configuration, load only the "normal" denoise configuration. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/py/cam/helpers.py')
0 files changed, 0 insertions, 0 deletions
ef='#n128'>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
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2020, Google Inc.
 *
 * flags.cpp - Flags tests
 */

#include <iostream>

#include <libcamera/base/flags.h>

#include "test.h"

using namespace libcamera;
using namespace std;

class FlagsTest : public Test
{
protected:
	enum class Option {
		First = (1 << 0),
		Second = (1 << 1),
		Third = (1 << 2),
	};

	using Options = Flags<Option>;

	enum class Mode {
		Alpha = (1 << 0),
		Beta = (1 << 1),
		Gamma = (1 << 2),
	};

	using Modes = Flags<Mode>;

	int run() override;
};

namespace libcamera {

LIBCAMERA_FLAGS_ENABLE_OPERATORS(FlagsTest::Option)

} /* namespace libcamera */

int FlagsTest::run()
{
	/* Commented-out constructs are expected not to compile. */

	/* Flags<int> f; */

	/*
	 * Unary operators with enum argument.
	 */

	Options options;

	if (options) {
		cerr << "Default-constructed Flags<> is not zero" << endl;
		return TestFail;
	}

	options |= Option::First;
	if (!options || options != Option::First) {
		cerr << "Unary bitwise OR with enum failed" << endl;
		return TestFail;
	}

	/* options &= Mode::Alpha; */
	/* options |= Mode::Beta;  */
	/* options ^= Mode::Gamma; */

	options &= ~Option::First;
	if (options) {
		cerr << "Unary bitwise AND with enum failed" << endl;
		return TestFail;
	}

	options ^= Option::Second;
	if (options != Option::Second) {
		cerr << "Unary bitwise XOR with enum failed" << endl;
		return TestFail;
	}

	options = Options();

	/*
	 * Unary operators with Flags argument.
	 */

	options |= Options(Option::First);
	if (options != Option::First) {
		cerr << "Unary bitwise OR with Flags<> failed" << endl;
		return TestFail;
	}

	/* options &= Options(Mode::Alpha); */
	/* options |= Options(Mode::Beta);  */
	/* options ^= Options(Mode::Gamma); */

	options &= ~Options(Option::First);
	if (options) {
		cerr << "Unary bitwise AND with Flags<> failed" << endl;
		return TestFail;
	}

	options ^= Options(Option::Second);
	if (options != Option::Second) {
		cerr << "Unary bitwise XOR with Flags<> failed" << endl;
		return TestFail;
	}

	options = Options();

	/*
	 * Binary operators with enum argument.
	 */

	options = options | Option::First;
	if (!(options & Option::First)) {
		cerr << "Binary bitwise OR with enum failed" << endl;
		return TestFail;
	}

	/* options = options & Mode::Alpha; */
	/* options = options | Mode::Beta;  */
	/* options = options ^ Mode::Gamma; */

	options = options & ~Option::First;
	if (options != (Option::First & Option::Second)) {
		cerr << "Binary bitwise AND with enum failed" << endl;
		return TestFail;
	}

	options = options ^ (Option::First ^ Option::Second);
	if (options != (Option::First | Option::Second)) {
		cerr << "Binary bitwise XOR with enum failed" << endl;
		return TestFail;
	}

	options = Options();

	/*
	 * Binary operators with Flags argument.
	 */

	options |= Options(Option::First);
	if (!(options & Option::First)) {
		cerr << "Binary bitwise OR with Flags<> failed" << endl;
		return TestFail;
	}

	/* options = options & Options(Mode::Alpha); */
	/* options = options | Options(Mode::Beta);  */
	/* options = options ^ Options(Mode::Gamma); */

	options = options & ~Options(Option::First);
	if (options) {
		cerr << "Binary bitwise AND with Flags<> failed" << endl;
		return TestFail;
	}

	options = options ^ Options(Option::Second);
	if (options != Option::Second) {
		cerr << "Binary bitwise XOR with Flags<> failed" << endl;
		return TestFail;
	}

	options = Options();

	/*
	 * Conversion operators.
	 */

	options |= Option::First | Option::Second | Option::Third;
	if (static_cast<Options::Type>(options) != 7) {
		cerr << "Cast to underlying type failed" << endl;
		return TestFail;
	}

	/*
	 * Conversion of the result of ninary operators on the underlying enum.
	 */

	/* unsigned int val1 = Option::First; */
	/* unsigned int val2 = ~Option::First; */
	/* unsigned int val3 = Option::First | Option::Second; */
	/* Option val4 = ~Option::First; */
	/* Option val5 = Option::First | Option::Second; */

	return TestPass;
}

TEST_REGISTER(FlagsTest)