|
32 | 32 | #include "controller/cac_status.h" |
33 | 33 | #include "controller/ccm_status.h" |
34 | 34 | #include "controller/contrast_status.h" |
| 35 | +#include "controller/decompand_status.h" |
35 | 36 | #include "controller/denoise_algorithm.h" |
36 | 37 | #include "controller/denoise_status.h" |
37 | 38 | #include "controller/dpc_status.h" |
@@ -113,6 +114,25 @@ int generateLut(const ipa::Pwl &pwl, uint32_t *lut, std::size_t lutSize, |
113 | 114 | return 0; |
114 | 115 | } |
115 | 116 |
|
| 117 | +int generateDecompandLut(const ipa::Pwl &pwl, uint16_t *lut, std::size_t lutSize = 65) |
| 118 | +{ |
| 119 | + if (pwl.empty()) |
| 120 | + return -EINVAL; |
| 121 | + |
| 122 | + constexpr int step = 1024; |
| 123 | + for (std::size_t i = 0; i < lutSize; ++i) { |
| 124 | + int x = i * step; |
| 125 | + |
| 126 | + int y = pwl.eval(x); |
| 127 | + if (y < 0) |
| 128 | + return -1; |
| 129 | + |
| 130 | + lut[i] = static_cast<uint16_t>(std::min(y, 65535)); |
| 131 | + } |
| 132 | + |
| 133 | + return 0; |
| 134 | +} |
| 135 | + |
116 | 136 | void packLscLut(uint32_t packed[NumLscVertexes][NumLscVertexes], |
117 | 137 | double const rgb[3][NumLscVertexes][NumLscVertexes]) |
118 | 138 | { |
@@ -236,6 +256,7 @@ class IpaPiSP final : public IpaBase |
236 | 256 | void applyLensShading(const AlscStatus *alscStatus, |
237 | 257 | pisp_be_global_config &global); |
238 | 258 | void applyDPC(const DpcStatus *dpcStatus, pisp_be_global_config &global); |
| 259 | + void applyDecompand(const DecompandStatus *decompandStatus); |
239 | 260 | void applySdn(const SdnStatus *sdnStatus, pisp_be_global_config &global); |
240 | 261 | void applyTdn(const TdnStatus *tdnStatus, const DeviceStatus *deviceStatus, |
241 | 262 | pisp_be_global_config &global); |
@@ -351,6 +372,11 @@ void IpaPiSP::platformPrepareIsp([[maybe_unused]] const PrepareParams ¶ms, |
351 | 372 | if (noiseStatus) |
352 | 373 | applyFocusStats(noiseStatus); |
353 | 374 |
|
| 375 | + DecompandStatus *decompandStatus = |
| 376 | + rpiMetadata.getLocked<DecompandStatus>("decompand.status"); |
| 377 | + if (decompandStatus) |
| 378 | + applyDecompand(decompandStatus); |
| 379 | + |
354 | 380 | BlackLevelStatus *blackLevelStatus = |
355 | 381 | rpiMetadata.getLocked<BlackLevelStatus>("black_level.status"); |
356 | 382 | if (blackLevelStatus) |
@@ -702,6 +728,20 @@ void IpaPiSP::applyDPC(const DpcStatus *dpcStatus, pisp_be_global_config &global |
702 | 728 | be_->SetDpc(dpc); |
703 | 729 | } |
704 | 730 |
|
| 731 | +void IpaPiSP::applyDecompand(const DecompandStatus *decompandStatus) |
| 732 | +{ |
| 733 | + pisp_fe_global_config feGlobal; |
| 734 | + pisp_fe_decompand_config decompand = {}; |
| 735 | + |
| 736 | + fe_->GetGlobal(feGlobal); |
| 737 | + |
| 738 | + if (!generateDecompandLut(decompandStatus->decompandCurve, decompand.lut, PISP_FE_DECOMPAND_LUT_SIZE)) { |
| 739 | + fe_->SetDecompand(decompand); |
| 740 | + feGlobal.enables |= PISP_FE_ENABLE_DECOMPAND; |
| 741 | + fe_->SetGlobal(feGlobal); |
| 742 | + } |
| 743 | +} |
| 744 | + |
705 | 745 | void IpaPiSP::applySdn(const SdnStatus *sdnStatus, pisp_be_global_config &global) |
706 | 746 | { |
707 | 747 | pisp_be_sdn_config sdn = {}; |
|
0 commit comments