Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/ipa/rpi/controller/decompand_status.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "libipa/pwl.h"

struct DecompandStatus {
uint32_t bitdepth;
libcamera::ipa::Pwl decompandCurve;
};
1 change: 1 addition & 0 deletions src/ipa/rpi/controller/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rpi_ipa_controller_sources = files([
'rpi/cac.cpp',
'rpi/ccm.cpp',
'rpi/contrast.cpp',
'rpi/decompand.cpp',
'rpi/denoise.cpp',
'rpi/dpc.cpp',
'rpi/geq.cpp',
Expand Down
58 changes: 58 additions & 0 deletions src/ipa/rpi/controller/rpi/decompand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include "decompand.h"

#include <libcamera/base/log.h>

#include "../decompand_status.h"
#include "../histogram.h"

using namespace RPiController;
using namespace libcamera;

LOG_DEFINE_CATEGORY(RPiDecompand)

#define NAME "rpi.decompand"

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

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

int Decompand::read(const libcamera::YamlObject &params)
{
config_.bitdepth = params["bitdepth"].get<uint32_t>(0);
config_.decompandCurve = params["decompand_curve"].get<ipa::Pwl>(ipa::Pwl{});
return config_.decompandCurve.empty() ? -EINVAL : 0;
}

void Decompand::initialise()
{
}

void Decompand::switchMode([[maybe_unused]] CameraMode const &cameraMode,
[[maybe_unused]] Metadata *metadata)
{
mode_ = cameraMode;
}

void Decompand::prepare(Metadata *imageMetadata)
{
DecompandStatus decompandStatus;

if (config_.bitdepth == 0 || mode_.bitdepth == config_.bitdepth) {
decompandStatus.decompandCurve = config_.decompandCurve;
imageMetadata->set("decompand.status", decompandStatus);
}
}

/* Register algorithm with the system. */
static Algorithm *create(Controller *controller)
{
return (Algorithm *)new Decompand(controller);
}

static RegisterAlgorithm reg(NAME, &create);
30 changes: 30 additions & 0 deletions src/ipa/rpi/controller/rpi/decompand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <libipa/pwl.h>
#include "algorithm.h"

#include "../decompand_status.h"

namespace RPiController {

struct DecompandConfig {
uint32_t bitdepth;
libcamera::ipa::Pwl decompandCurve;
};

class Decompand : public Algorithm
{
public:
Decompand(Controller *controller = NULL);
char const *name() const override;
int read(const libcamera::YamlObject &params) override;
void initialise() override;
void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;
void prepare(Metadata *imageMetadata) override;

private:
CameraMode mode_;
DecompandConfig config_;
};

} /* namespace RPiController */
Loading