diff options
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/sharpen.cpp')
-rw-r--r-- | src/ipa/raspberrypi/controller/rpi/sharpen.cpp | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp index 3fe62bc8..9b7f903a 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp @@ -33,7 +33,7 @@ char const *Sharpen::name() const void Sharpen::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) { - // can't be less than one, right? + /* can't be less than one, right? */ modeFactor_ = std::max(1.0, cameraMode.noiseFactor); } @@ -50,24 +50,30 @@ void Sharpen::read(boost::property_tree::ptree const ¶ms) void Sharpen::setStrength(double strength) { - // Note that this function is how an application sets the overall - // sharpening "strength". We call this the "user strength" field - // as there already is a strength_ field - being an internal gain - // parameter that gets passed to the ISP control code. Negative - // values are not allowed - coerce them to zero (no sharpening). + /* + * Note that this function is how an application sets the overall + * sharpening "strength". We call this the "user strength" field + * as there already is a strength_ field - being an internal gain + * parameter that gets passed to the ISP control code. Negative + * values are not allowed - coerce them to zero (no sharpening). + */ userStrength_ = std::max(0.0, strength); } void Sharpen::prepare(Metadata *imageMetadata) { - // The userStrength_ affects the algorithm's internal gain directly, but - // we adjust the limit and threshold less aggressively. Using a sqrt - // function is an arbitrary but gentle way of accomplishing this. + /* + * The userStrength_ affects the algorithm's internal gain directly, but + * we adjust the limit and threshold less aggressively. Using a sqrt + * function is an arbitrary but gentle way of accomplishing this. + */ double userStrengthSqrt = sqrt(userStrength_); struct SharpenStatus status; - // Binned modes seem to need the sharpening toned down with this - // pipeline, thus we use the modeFactor_ here. Also avoid - // divide-by-zero with the userStrengthSqrt. + /* + * Binned modes seem to need the sharpening toned down with this + * pipeline, thus we use the modeFactor_ here. Also avoid + * divide-by-zero with the userStrengthSqrt. + */ status.threshold = threshold_ * modeFactor_ / std::max(0.01, userStrengthSqrt); status.strength = strength_ / modeFactor_ * userStrength_; @@ -77,7 +83,7 @@ void Sharpen::prepare(Metadata *imageMetadata) imageMetadata->set("sharpen.status", status); } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return new Sharpen(controller); |