blob: 890dc3ff5a6b743324a46e0df08c229332695a26 (
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
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2021, Ideas On Board
*
* constrast.cpp - IPU3 Contrast and Gamma control
*/
#include "contrast.h"
#include <cmath>
#include <libcamera/base/log.h>
namespace libcamera {
namespace ipa::ipu3::algorithms {
LOG_DEFINE_CATEGORY(IPU3Contrast)
Contrast::Contrast()
: gamma_(1.0)
{
}
void Contrast::initialise(IPAContext &context)
{
ipu3_uapi_params ¶ms = context.params;
/* Limit the gamma effect for now */
gamma_ = 1.1;
/* Plot the gamma curve into the look up table */
for (uint32_t i = 0; i < 256; i++) {
double j = i / 255.0;
double gamma = std::pow(j, 1.0 / gamma_);
/* The maximum value 255 is represented on 13 bits in the IPU3 */
params.acc_param.gamma.gc_lut.lut[i] = gamma * 8191;
}
LOG(IPU3Contrast, Info) << "Processed Gamma Curve";
}
} /* namespace ipa::ipu3::algorithms */
} /* namespace libcamera */
|