|
12 | 12 |
|
13 | 13 | #include <libcamera/base/log.h> |
14 | 14 | #include <libcamera/base/span.h> |
| 15 | + |
15 | 16 | #include <libcamera/control_ids.h> |
16 | 17 | #include <libcamera/property_ids.h> |
17 | 18 |
|
18 | 19 | #include "controller/af_algorithm.h" |
19 | 20 | #include "controller/af_status.h" |
20 | 21 | #include "controller/agc_algorithm.h" |
| 22 | +#include "controller/alsc_status.h" |
21 | 23 | #include "controller/awb_algorithm.h" |
22 | 24 | #include "controller/awb_status.h" |
23 | 25 | #include "controller/black_level_status.h" |
24 | 26 | #include "controller/ccm_algorithm.h" |
25 | 27 | #include "controller/ccm_status.h" |
26 | 28 | #include "controller/contrast_algorithm.h" |
| 29 | +#include "controller/contrast_status.h" |
27 | 30 | #include "controller/denoise_algorithm.h" |
28 | 31 | #include "controller/hdr_algorithm.h" |
29 | 32 | #include "controller/lux_status.h" |
| 33 | +#include "controller/noise_status.h" |
30 | 34 | #include "controller/sharpen_algorithm.h" |
31 | 35 | #include "controller/statistics.h" |
32 | 36 | #include "controller/sync_algorithm.h" |
@@ -82,6 +86,7 @@ const ControlInfoMap::Map ipaControls{ |
82 | 86 | static_cast<int64_t>(defaultMaxFrameDuration.get<std::micro>()), |
83 | 87 | Span<const int64_t, 2>{ { static_cast<int64_t>(defaultMinFrameDuration.get<std::micro>()), |
84 | 88 | static_cast<int64_t>(defaultMinFrameDuration.get<std::micro>()) } }) }, |
| 89 | + { &controls::EnableLensShadingCorrectionMapOutput, ControlInfo(false, true, false) }, |
85 | 90 | { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }, |
86 | 91 | { &controls::rpi::StatsOutputEnable, ControlInfo(false, true, false) }, |
87 | 92 | { &controls::rpi::CnnEnableInputTensor, ControlInfo(false, true, false) }, |
@@ -129,7 +134,7 @@ LOG_DEFINE_CATEGORY(IPARPI) |
129 | 134 | namespace ipa::RPi { |
130 | 135 |
|
131 | 136 | IpaBase::IpaBase() |
132 | | - : controller_(), frameLengths_(FrameLengthsQueueSize, 0s), statsMetadataOutput_(false), |
| 137 | + : controller_(), frameLengths_(FrameLengthsQueueSize, 0s), lscMapsOutput_(false), statsMetadataOutput_(false), |
133 | 138 | stitchSwapBuffers_(false), frameCount_(0), mistrustCount_(0), lastRunTimestamp_(0), |
134 | 139 | firstStart_(true), flickerState_({ 0, 0s }), cnnEnableInputTensor_(false), awbEnabled_(true) |
135 | 140 | { |
@@ -245,7 +250,6 @@ int32_t IpaBase::configure(const IPACameraSensorInfo &sensorInfo, const ConfigPa |
245 | 250 | agcStatus.exposureTime = defaultExposureTime; |
246 | 251 | agcStatus.analogueGain = defaultAnalogueGain; |
247 | 252 | applyAGC(&agcStatus, ctrls); |
248 | | - |
249 | 253 | } |
250 | 254 |
|
251 | 255 | result->sensorControls = std::move(ctrls); |
@@ -795,8 +799,8 @@ static const std::map<int32_t, std::string> HdrModeTable = { |
795 | 799 |
|
796 | 800 | void IpaBase::applyControls(const ControlList &controls) |
797 | 801 | { |
798 | | - using RPiController::AgcAlgorithm; |
799 | 802 | using RPiController::AfAlgorithm; |
| 803 | + using RPiController::AgcAlgorithm; |
800 | 804 | using RPiController::ContrastAlgorithm; |
801 | 805 | using RPiController::DenoiseAlgorithm; |
802 | 806 | using RPiController::HdrAlgorithm; |
@@ -1478,6 +1482,10 @@ void IpaBase::applyControls(const ControlList &controls) |
1478 | 1482 | break; |
1479 | 1483 | } |
1480 | 1484 |
|
| 1485 | + case controls::ENABLE_LENS_SHADING_CORRECTION_MAP_OUTPUT: |
| 1486 | + lscMapsOutput_ = ctrl.second.get<bool>(); |
| 1487 | + break; |
| 1488 | + |
1481 | 1489 | case controls::rpi::STATS_OUTPUT_ENABLE: |
1482 | 1490 | statsMetadataOutput_ = ctrl.second.get<bool>(); |
1483 | 1491 | break; |
@@ -1762,6 +1770,43 @@ void IpaBase::reportMetadata(unsigned int ipaContext) |
1762 | 1770 | static_cast<int32_t>(kpiInfo->dspRuntime) }); |
1763 | 1771 | } |
1764 | 1772 |
|
| 1773 | + NoiseStatus *noiseStatus = rpiMetadata.getLocked<NoiseStatus>("noise.status"); |
| 1774 | + if (noiseStatus) { |
| 1775 | + float noiseProfile[] = { static_cast<float>(noiseStatus->noiseSlope), |
| 1776 | + static_cast<float>(noiseStatus->noiseConstant) }; |
| 1777 | + |
| 1778 | + libcameraMetadata_.set(controls::NoiseProfile, noiseProfile); |
| 1779 | + } |
| 1780 | + |
| 1781 | + ContrastStatus *contrastStatus = rpiMetadata.getLocked<ContrastStatus>("contrast.status"); |
| 1782 | + if (contrastStatus && contrastStatus->gammaCurve.size() > 0) { |
| 1783 | + std::vector<float> contrast; |
| 1784 | + contrast.reserve(contrastStatus->gammaCurve.size() * 2); |
| 1785 | + |
| 1786 | + contrastStatus->gammaCurve.map([&](double x, double y) { |
| 1787 | + contrast.emplace_back(static_cast<float>(x)); |
| 1788 | + contrast.emplace_back(static_cast<float>(y)); |
| 1789 | + }); |
| 1790 | + libcameraMetadata_.set(controls::ToneCurve, contrast); |
| 1791 | + } |
| 1792 | + |
| 1793 | + if (lscMapsOutput_) { |
| 1794 | + AlscStatus *alscStatus = rpiMetadata.getLocked<AlscStatus>("alsc.status"); |
| 1795 | + if (alscStatus) { |
| 1796 | + uint32_t elements = alscStatus->cols * alscStatus->rows; |
| 1797 | + std::vector<float> map(3 * elements); |
| 1798 | + |
| 1799 | + std::copy(alscStatus->r.begin(), alscStatus->r.end(), map.begin() + 0 * elements); |
| 1800 | + std::copy(alscStatus->g.begin(), alscStatus->g.end(), map.begin() + 1 * elements); |
| 1801 | + std::copy(alscStatus->b.begin(), alscStatus->b.end(), map.begin() + 2 * elements); |
| 1802 | + |
| 1803 | + uint32_t sizeTable[] = { 3, alscStatus->cols, alscStatus->rows }; |
| 1804 | + libcameraMetadata_.set(controls::LensShadingCorrectionMaps, map); |
| 1805 | + libcameraMetadata_.set(controls::LensShadingCorrectionMapSize, sizeTable); |
| 1806 | + libcameraMetadata_.set(controls::EnableLensShadingCorrectionMapOutput, true); |
| 1807 | + } |
| 1808 | + } |
| 1809 | + |
1765 | 1810 | metadataReady.emit(libcameraMetadata_); |
1766 | 1811 | } |
1767 | 1812 |
|
|
0 commit comments