Message ID | 20211221051023.2628625-2-paul.elder@ideasonboard.com |
---|---|
State | New |
Delegated to: | Paul Elder |
Headers | show |
Series |
|
Related | show |
Quoting Paul Elder (2021-12-21 05:10:21) > Promote NoiseReductionMode to a non-draft control. Upgrade the value > descriptions. Update the raspberrypi IPA accordingly, as it is the only > current user of this control. I wonder if we should have some means to map the old types to the new types with a deprecated attribute somehow, but I had a go in the past and it was painful so I gave up. Bonus points for anyone else who can do it ;-) > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> > > --- > No change in v2 > - I think that the framerate guarantees should stay. If the application > wants no framerate drop at all costs, it should be able to get it, or I must finish investigating my frame drop series that allows requests to return without a completed frame if it was dropped... > at least be notified that it's not possible to be guaranteed. The lack > of mechanism to do this communication I think is not a good idea. > - the paragraph about ZSL has been left in > --- > include/libcamera/ipa/raspberrypi.h | 2 +- > src/android/camera_capabilities.cpp | 2 +- > src/ipa/raspberrypi/raspberrypi.cpp | 12 ++--- > src/libcamera/control_ids.yaml | 73 +++++++++++++++++------------ > 4 files changed, 52 insertions(+), 37 deletions(-) > > diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h > index 672b85a5..548bfba0 100644 > --- a/include/libcamera/ipa/raspberrypi.h > +++ b/include/libcamera/ipa/raspberrypi.h > @@ -46,7 +46,7 @@ static const ControlInfoMap Controls({ > { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, > { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, > { &controls::FrameDurationLimits, ControlInfo(INT64_C(1000), INT64_C(1000000000)) }, > - { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } > + { &controls::NoiseReductionMode, ControlInfo(controls::NoiseReductionModeValues) } > }, controls::controls); > > } /* namespace RPi */ > diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp > index fa5f3b8d..d6a1589e 100644 > --- a/src/android/camera_capabilities.cpp > +++ b/src/android/camera_capabilities.cpp > @@ -1398,7 +1398,7 @@ int CameraCapabilities::initializeStaticMetadata() > { > std::vector<uint8_t> data; > data.reserve(5); > - const auto &infoMap = controlsInfo.find(&controls::draft::NoiseReductionMode); > + const auto &infoMap = controlsInfo.find(&controls::NoiseReductionMode); > if (infoMap != controlsInfo.end()) { > for (const auto &value : infoMap->second.values()) > data.push_back(value.get<int32_t>()); > diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp > index 9bea16e7..3f497be1 100644 > --- a/src/ipa/raspberrypi/raspberrypi.cpp > +++ b/src/ipa/raspberrypi/raspberrypi.cpp > @@ -615,11 +615,11 @@ static const std::map<int32_t, std::string> AwbModeTable = { > }; > > static const std::map<int32_t, RPiController::DenoiseMode> DenoiseModeTable = { > - { controls::draft::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, > - { controls::draft::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, > - { controls::draft::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, > - { controls::draft::NoiseReductionModeMinimal, RPiController::DenoiseMode::ColourOff }, > - { controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, > + { controls::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, > + { controls::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, > + { controls::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, > + { controls::NoiseReductionModeRaw, RPiController::DenoiseMode::ColourOff }, > + { controls::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, > }; > > void IPARPi::queueRequest(const ControlList &controls) > @@ -929,7 +929,7 @@ void IPARPi::queueRequest(const ControlList &controls) > * analysis image resolution or format mismatch, we should > * report the status correctly in the metadata. > */ > - libcameraMetadata_.set(controls::draft::NoiseReductionMode, idx); > + libcameraMetadata_.set(controls::NoiseReductionMode, idx); > } else { > LOG(IPARPI, Error) << "Noise reduction mode " << idx > << " not recognised"; > diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml > index 84679317..84e843b1 100644 > --- a/src/libcamera/control_ids.yaml > +++ b/src/libcamera/control_ids.yaml > @@ -526,6 +526,50 @@ controls: > \todo Define how the sensor timestamp has to be used in the reprocessing > use case. > > + - NoiseReductionMode: > + type: int32_t > + description: | > + Mode of operation for the noise reduction algorithm. > + > + The noise reduction algorithm attempts to improve image quality by > + removing excessive noise added by the capture process, especially in > + dark conditions. It sounds like the modes below can be optionally implemented and exposed, so can we express/state that here somehow? "Only modes supported by the platform will be available to set on the control." What happens if someone tries to set an unsupported mode? Will it be ignored (warning)? Rejected (error)? Do we need to state that here too? > + enum: > + - name: NoiseReductionModeOff > + value: 0 > + description: | > + No noise reduction will be applied by the camera device, for > + both the raw and YUV domains. s/raw/Raw/ ? You've capitalised it five lines below .. But do we even need to be this explicit? No noise reduction processing will be applied by the Camera. > + - name: NoiseReductionModeFast > + value: 1 > + description: | > + Noise reduction is applied without reducing the frame rate. > + This may be the same as Raw if it is listed, or the same as Off if If it is listed? Where? It doesn't sound clear. I presume it means if the mode is exposed by the camera somehow ? Perhaps it should be "This may be the same level as NoiseReductionModeRaw if it is available, or the same as NoiseReductionModeOff if any noise reduction would slow down the frame rate." > + any noise reduction will slow down the frame rate. > + - name: NoiseReductionModeHighQuality > + value: 2 > + description: | > + High quality noise reduction at the expense of frame rate. > + - name: NoiseReductionModeRaw > + value: 3 > + description: | > + Only sensor raw domain basic noise reduction is enabled, to remove > + demosaicing or other processing artifacts. Frame rate will not be > + reduced. > + - name: NoiseReductionModeZSL > + value: 4 > + description: | > + Noise reduction is applied at different levels to different streams. > + > + ZSL is meant to be used by applications that maintain a continuous > + circular buffer of high-resolution images during preview and > + reprocess image(s) from that buffer into a final capture when > + triggered by the user. In this mode, the camera device applies > + noise reduction to low-resolution streams (below maximum recording > + resolution) to maximize preview quality, but does not apply noise > + reduction to high-resolution streams, since those will be > + reprocessed later if necessary. > + > # ---------------------------------------------------------------------------- > # Draft controls section > > @@ -572,35 +616,6 @@ controls: > The camera will cancel any active trigger and the AF routine is > reset to its initial state. > > - - NoiseReductionMode: > - type: int32_t > - draft: true > - description: | > - Control to select the noise reduction algorithm mode. Currently > - identical to ANDROID_NOISE_REDUCTION_MODE. > - > - Mode of operation for the noise reduction algorithm. > - enum: > - - name: NoiseReductionModeOff > - value: 0 > - description: No noise reduction is applied > - - name: NoiseReductionModeFast > - value: 1 > - description: | > - Noise reduction is applied without reducing the frame rate. > - - name: NoiseReductionModeHighQuality > - value: 2 > - description: | > - High quality noise reduction at the expense of frame rate. > - - name: NoiseReductionModeMinimal > - value: 3 > - description: | > - Minimal noise reduction is applied without reducing the frame rate. > - - name: NoiseReductionModeZSL > - value: 4 > - description: | > - Noise reduction is applied at different levels to different streams. > - > - ColorCorrectionAberrationMode: > type: int32_t > draft: true > -- > 2.27.0 >
diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index 672b85a5..548bfba0 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -46,7 +46,7 @@ static const ControlInfoMap Controls({ { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, { &controls::FrameDurationLimits, ControlInfo(INT64_C(1000), INT64_C(1000000000)) }, - { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } + { &controls::NoiseReductionMode, ControlInfo(controls::NoiseReductionModeValues) } }, controls::controls); } /* namespace RPi */ diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index fa5f3b8d..d6a1589e 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1398,7 +1398,7 @@ int CameraCapabilities::initializeStaticMetadata() { std::vector<uint8_t> data; data.reserve(5); - const auto &infoMap = controlsInfo.find(&controls::draft::NoiseReductionMode); + const auto &infoMap = controlsInfo.find(&controls::NoiseReductionMode); if (infoMap != controlsInfo.end()) { for (const auto &value : infoMap->second.values()) data.push_back(value.get<int32_t>()); diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 9bea16e7..3f497be1 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -615,11 +615,11 @@ static const std::map<int32_t, std::string> AwbModeTable = { }; static const std::map<int32_t, RPiController::DenoiseMode> DenoiseModeTable = { - { controls::draft::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, - { controls::draft::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, - { controls::draft::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, - { controls::draft::NoiseReductionModeMinimal, RPiController::DenoiseMode::ColourOff }, - { controls::draft::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, + { controls::NoiseReductionModeOff, RPiController::DenoiseMode::Off }, + { controls::NoiseReductionModeFast, RPiController::DenoiseMode::ColourFast }, + { controls::NoiseReductionModeHighQuality, RPiController::DenoiseMode::ColourHighQuality }, + { controls::NoiseReductionModeRaw, RPiController::DenoiseMode::ColourOff }, + { controls::NoiseReductionModeZSL, RPiController::DenoiseMode::ColourHighQuality }, }; void IPARPi::queueRequest(const ControlList &controls) @@ -929,7 +929,7 @@ void IPARPi::queueRequest(const ControlList &controls) * analysis image resolution or format mismatch, we should * report the status correctly in the metadata. */ - libcameraMetadata_.set(controls::draft::NoiseReductionMode, idx); + libcameraMetadata_.set(controls::NoiseReductionMode, idx); } else { LOG(IPARPI, Error) << "Noise reduction mode " << idx << " not recognised"; diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 84679317..84e843b1 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -526,6 +526,50 @@ controls: \todo Define how the sensor timestamp has to be used in the reprocessing use case. + - NoiseReductionMode: + type: int32_t + description: | + Mode of operation for the noise reduction algorithm. + + The noise reduction algorithm attempts to improve image quality by + removing excessive noise added by the capture process, especially in + dark conditions. + enum: + - name: NoiseReductionModeOff + value: 0 + description: | + No noise reduction will be applied by the camera device, for + both the raw and YUV domains. + - name: NoiseReductionModeFast + value: 1 + description: | + Noise reduction is applied without reducing the frame rate. + This may be the same as Raw if it is listed, or the same as Off if + any noise reduction will slow down the frame rate. + - name: NoiseReductionModeHighQuality + value: 2 + description: | + High quality noise reduction at the expense of frame rate. + - name: NoiseReductionModeRaw + value: 3 + description: | + Only sensor raw domain basic noise reduction is enabled, to remove + demosaicing or other processing artifacts. Frame rate will not be + reduced. + - name: NoiseReductionModeZSL + value: 4 + description: | + Noise reduction is applied at different levels to different streams. + + ZSL is meant to be used by applications that maintain a continuous + circular buffer of high-resolution images during preview and + reprocess image(s) from that buffer into a final capture when + triggered by the user. In this mode, the camera device applies + noise reduction to low-resolution streams (below maximum recording + resolution) to maximize preview quality, but does not apply noise + reduction to high-resolution streams, since those will be + reprocessed later if necessary. + # ---------------------------------------------------------------------------- # Draft controls section @@ -572,35 +616,6 @@ controls: The camera will cancel any active trigger and the AF routine is reset to its initial state. - - NoiseReductionMode: - type: int32_t - draft: true - description: | - Control to select the noise reduction algorithm mode. Currently - identical to ANDROID_NOISE_REDUCTION_MODE. - - Mode of operation for the noise reduction algorithm. - enum: - - name: NoiseReductionModeOff - value: 0 - description: No noise reduction is applied - - name: NoiseReductionModeFast - value: 1 - description: | - Noise reduction is applied without reducing the frame rate. - - name: NoiseReductionModeHighQuality - value: 2 - description: | - High quality noise reduction at the expense of frame rate. - - name: NoiseReductionModeMinimal - value: 3 - description: | - Minimal noise reduction is applied without reducing the frame rate. - - name: NoiseReductionModeZSL - value: 4 - description: | - Noise reduction is applied at different levels to different streams. - - ColorCorrectionAberrationMode: type: int32_t draft: true
Promote NoiseReductionMode to a non-draft control. Upgrade the value descriptions. Update the raspberrypi IPA accordingly, as it is the only current user of this control. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> --- No change in v2 - I think that the framerate guarantees should stay. If the application wants no framerate drop at all costs, it should be able to get it, or at least be notified that it's not possible to be guaranteed. The lack of mechanism to do this communication I think is not a good idea. - the paragraph about ZSL has been left in --- include/libcamera/ipa/raspberrypi.h | 2 +- src/android/camera_capabilities.cpp | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 12 ++--- src/libcamera/control_ids.yaml | 73 +++++++++++++++++------------ 4 files changed, 52 insertions(+), 37 deletions(-)