summaryrefslogtreecommitdiff
path: root/src/ipa/rpi/controller/rpi/tonemap.cpp
blob: 5f8b2bf25aeb349d021e7cab06c2c8dbc9c7ed85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* SPDX-License-Identifier: BSD-2-Clause */
/*
 * Copyright (C) 2022 Raspberry Pi Ltd
 *
 * tonemap.cpp - Tonemap control algorithm
 */
#include "tonemap.h"

#include <libcamera/base/log.h>

#include "tonemap_status.h"

using namespace RPiController;
using namespace libcamera;

LOG_DEFINE_CATEGORY(RPiTonemap)

#define NAME "rpi.tonemap"

Tonemap::Tonemap(Controller *controller)
	: Algorithm(controller)
{
}

char const *Tonemap::name() const
{
	return NAME;
}

int Tonemap::read(const libcamera::YamlObject &params)
{
	config_.detailConstant = params["detail_constant"].get<uint16_t>(0);
	config_.detailSlope = params["detail_slope"].get<double>(0.1);
	config_.iirStrength = params["iir_strength"].get<double>(1.0);
	config_.strength = params["strength"].get<double>(1.0);
	config_.tonemap.read(params["tone_curve"]);
	return 0;
}

void Tonemap::initialise()
{
}

void Tonemap::prepare(Metadata *imageMetadata)
{
	TonemapStatus tonemapStatus;

	tonemapStatus.detailConstant = config_.detailConstant;
	tonemapStatus.detailSlope = config_.detailSlope;
	tonemapStatus.iirStrength = config_.iirStrength;
	tonemapStatus.strength = config_.strength;
	tonemapStatus.tonemap = config_.tonemap;
	imageMetadata->set("tonemap.status", tonemapStatus);
}

// Register algorithm with the system.
static Algorithm *Create(Controller *controller)
{
	return (Algorithm *)new Tonemap(controller);
}
static RegisterAlgorithm reg(NAME, &Create);