diff options
Diffstat (limited to 'src/ipa/rkisp1/ipa_context.cpp')
-rw-r--r-- | src/ipa/rkisp1/ipa_context.cpp | 314 |
1 files changed, 261 insertions, 53 deletions
diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 1559d3ff..070834fa 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -15,6 +15,25 @@ namespace libcamera::ipa::rkisp1 { /** + * \struct IPAHwSettings + * \brief RkISP1 version-specific hardware parameters + */ + +/** + * \var IPAHwSettings::numAeCells + * \brief Number of cells in the AE exposure means grid + * + * \var IPAHwSettings::numHistogramBins + * \brief Number of bins in the histogram + * + * \var IPAHwSettings::numHistogramWeights + * \brief Number of weights in the histogram grid + * + * \var IPAHwSettings::numGammaOutSamples + * \brief Number of samples in the gamma out table + */ + +/** * \struct IPASessionConfiguration * \brief Session configuration for the IPA module * @@ -25,84 +44,217 @@ namespace libcamera::ipa::rkisp1 { */ /** - * \struct IPAFrameContext - * \brief Per-frame context for algorithms + * \var IPASessionConfiguration::agc + * \brief AGC parameters configuration of the IPA + * + * \var IPASessionConfiguration::agc.measureWindow + * \brief AGC measure window + */ + +/** + * \var IPASessionConfiguration::awb + * \brief AWB parameters configuration of the IPA * - * The frame context stores data specific to a single frame processed by the - * IPA. Each frame processed by the IPA has a context associated with it, - * accessible through the IPAContext structure. + * \var IPASessionConfiguration::awb.measureWindow + * \brief AWB measure window * - * \todo Detail how to access contexts for a particular frame + * \var IPASessionConfiguration::awb.enabled + * \brief Indicates if the AWB hardware is enabled and applies colour gains * - * Each of the fields in the frame context belongs to either a specific - * algorithm, or to the top-level IPA module. A field may be read by any - * algorithm, but should only be written by its owner. + * The AWB module of the ISP applies colour gains and computes statistics. It is + * enabled when the AWB algorithm is loaded, regardless of whether the algorithm + * operates in manual or automatic mode. */ /** - * \struct IPAContext - * \brief Global IPA context data shared between all algorithms + * \var IPASessionConfiguration::lsc + * \brief Lens Shading Correction configuration of the IPA * - * \var IPAContext::configuration - * \brief The IPA session configuration, immutable during the session + * \var IPASessionConfiguration::lsc.enabled + * \brief Indicates if the LSC hardware is enabled + */ + +/** + * \var IPASessionConfiguration::sensor + * \brief Sensor-specific configuration of the IPA + * + * \var IPASessionConfiguration::sensor.minShutterSpeed + * \brief Minimum shutter speed supported with the sensor + * + * \var IPASessionConfiguration::sensor.maxShutterSpeed + * \brief Maximum shutter speed supported with the sensor * - * \var IPAContext::frameContext - * \brief The frame context for the frame being processed + * \var IPASessionConfiguration::sensor.minAnalogueGain + * \brief Minimum analogue gain supported with the sensor * - * \todo While the frame context is supposed to be per-frame, this - * single frame context stores data related to both the current frame - * and the previous frames, with fields being updated as the algorithms - * are run. This needs to be turned into real per-frame data storage. + * \var IPASessionConfiguration::sensor.maxAnalogueGain + * \brief Maximum analogue gain supported with the sensor + * + * \var IPASessionConfiguration::sensor.defVBlank + * \brief The default vblank value of the sensor + * + * \var IPASessionConfiguration::sensor.lineDuration + * \brief Line duration in microseconds + * + * \var IPASessionConfiguration::sensor.size + * \brief Sensor output resolution */ /** - * \var IPASessionConfiguration::agc - * \brief AGC parameters configuration of the IPA + * \var IPASessionConfiguration::raw + * \brief Indicates if the camera is configured to capture raw frames + */ + +/** + * \struct IPAActiveState + * \brief Active state for algorithms * - * \var IPASessionConfiguration::agc.minShutterSpeed - * \brief Minimum shutter speed supported with the configured sensor + * The active state contains all algorithm-specific data that needs to be + * maintained by algorithms across frames. Unlike the session configuration, + * the active state is mutable and constantly updated by algorithms. The active + * state is accessible through the IPAContext structure. * - * \var IPASessionConfiguration::agc.maxShutterSpeed - * \brief Maximum shutter speed supported with the configured sensor + * The active state stores two distinct categories of information: * - * \var IPASessionConfiguration::agc.minAnalogueGain - * \brief Minimum analogue gain supported with the configured sensor + * - The consolidated value of all algorithm controls. Requests passed to + * the queueRequest() function store values for controls that the + * application wants to modify for that particular frame, and the + * queueRequest() function updates the active state with those values. + * The active state thus contains a consolidated view of the value of all + * controls handled by the algorithm. * - * \var IPASessionConfiguration::agc.maxAnalogueGain - * \brief Maximum analogue gain supported with the configured sensor + * - The value of parameters computed by the algorithm when running in auto + * mode. Algorithms running in auto mode compute new parameters every + * time statistics buffers are received (either synchronously, or + * possibly in a background thread). The latest computed value of those + * parameters is stored in the active state in the process() function. * - * \var IPASessionConfiguration::agc.measureWindow - * \brief AGC measure window + * Each of the members in the active state belongs to a specific algorithm. A + * member may be read by any algorithm, but shall only be written by its owner. + */ + +/** + * \var IPAActiveState::agc + * \brief State for the Automatic Gain Control algorithm * - * \var IPASessionConfiguration::hw - * \brief RkISP1-specific hardware information + * The exposure and gain are the latest values computed by the AGC algorithm. * - * \var IPASessionConfiguration::hw.revision - * \brief Hardware revision of the ISP + * \var IPAActiveState::agc.exposure + * \brief Exposure time expressed as a number of lines + * + * \var IPAActiveState::agc.gain + * \brief Analogue gain multiplier */ /** - * \var IPASessionConfiguration::awb - * \brief AWB parameters configuration of the IPA + * \var IPAActiveState::awb + * \brief State for the Automatic White Balance algorithm * - * \var IPASessionConfiguration::awb.measureWindow - * \brief AWB measure window + * \struct IPAActiveState::awb.gains + * \brief White balance gains + * + * \struct IPAActiveState::awb.gains.manual + * \brief Manual white balance gains (set through requests) + * + * \var IPAActiveState::awb.gains.manual.red + * \brief Manual white balance gain for R channel + * + * \var IPAActiveState::awb.gains.manual.green + * \brief Manual white balance gain for G channel + * + * \var IPAActiveState::awb.gains.manual.blue + * \brief Manual white balance gain for B channel + * + * \struct IPAActiveState::awb.gains.automatic + * \brief Automatic white balance gains (computed by the algorithm) + * + * \var IPAActiveState::awb.gains.automatic.red + * \brief Automatic white balance gain for R channel + * + * \var IPAActiveState::awb.gains.automatic.green + * \brief Automatic white balance gain for G channel + * + * \var IPAActiveState::awb.gains.automatic.blue + * \brief Automatic white balance gain for B channel + * + * \var IPAActiveState::awb.temperatureK + * \brief Estimated color temperature + * + * \var IPAActiveState::awb.autoEnabled + * \brief Whether the Auto White Balance algorithm is enabled */ /** - * \var IPASessionConfiguration::sensor - * \brief Sensor-specific configuration of the IPA + * \var IPAActiveState::cproc + * \brief State for the Color Processing algorithm * - * \var IPASessionConfiguration::sensor.lineDuration - * \brief Line duration in microseconds + * \struct IPAActiveState::cproc.brightness + * \brief Brightness level + * + * \var IPAActiveState::cproc.contrast + * \brief Contrast level + * + * \var IPAActiveState::cproc.saturation + * \brief Saturation level + */ + +/** + * \var IPAActiveState::dpf + * \brief State for the Denoise Pre-Filter algorithm + * + * \var IPAActiveState::dpf.denoise + * \brief Indicates if denoise is activated + */ + +/** + * \var IPAActiveState::filter + * \brief State for the Filter algorithm + * + * \struct IPAActiveState::filter.denoise + * \brief Denoising level + * + * \var IPAActiveState::filter.sharpness + * \brief Sharpness level + */ + +/** + * \struct IPAFrameContext + * \brief Per-frame context for algorithms + * + * The frame context stores two distinct categories of information: + * + * - The value of the controls to be applied to the frame. These values are + * typically set in the queueRequest() function, from the consolidated + * control values stored in the active state. The frame context thus stores + * values for all controls related to the algorithm, not limited to the + * controls specified in the corresponding request, but consolidated from all + * requests that have been queued so far. + * + * For controls that can be set manually or computed by an algorithm + * (depending on the algorithm operation mode), such as for instance the + * colour gains for the AWB algorithm, the control value will be stored in + * the frame context in the queueRequest() function only when operating in + * manual mode. When operating in auto mode, the values are computed by the + * algorithm in process(), stored in the active state, and copied to the + * frame context in prepare(), just before being stored in the ISP parameters + * buffer. + * + * The queueRequest() function can also store ancillary data in the frame + * context, such as flags to indicate if (and what) control values have + * changed compared to the previous request. + * + * - Status information computed by the algorithm for a frame. For instance, + * the colour temperature estimated by the AWB algorithm from ISP statistics + * calculated on a frame is stored in the frame context for that frame in + * the process() function. */ /** * \var IPAFrameContext::agc - * \brief Context for the Automatic Gain Control algorithm + * \brief Automatic Gain Control parameters for this frame * - * The exposure and gain determined are expected to be applied to the sensor - * at the earliest opportunity. + * The exposure and gain are provided by the AGC algorithm, and are to be + * applied to the sensor in order to take effect for this frame. * * \var IPAFrameContext::agc.exposure * \brief Exposure time expressed as a number of lines @@ -115,7 +267,7 @@ namespace libcamera::ipa::rkisp1 { /** * \var IPAFrameContext::awb - * \brief Context for the Automatic White Balance algorithm + * \brief Automatic White Balance parameters for this frame * * \struct IPAFrameContext::awb.gains * \brief White balance gains @@ -131,11 +283,59 @@ namespace libcamera::ipa::rkisp1 { * * \var IPAFrameContext::awb.temperatureK * \brief Estimated color temperature + * + * \var IPAFrameContext::awb.autoEnabled + * \brief Whether the Auto White Balance algorithm is enabled + */ + +/** + * \var IPAFrameContext::cproc + * \brief Color Processing parameters for this frame + * + * \struct IPAFrameContext::cproc.brightness + * \brief Brightness level + * + * \var IPAFrameContext::cproc.contrast + * \brief Contrast level + * + * \var IPAFrameContext::cproc.saturation + * \brief Saturation level + * + * \var IPAFrameContext::cproc.update + * \brief Indicates if the color processing parameters have been updated + * compared to the previous frame + */ + +/** + * \var IPAFrameContext::dpf + * \brief Denoise Pre-Filter parameters for this frame + * + * \var IPAFrameContext::dpf.denoise + * \brief Indicates if denoise is activated + * + * \var IPAFrameContext::dpf.update + * \brief Indicates if the denoise pre-filter parameters have been updated + * compared to the previous frame + */ + +/** + * \var IPAFrameContext::filter + * \brief Filter parameters for this frame + * + * \struct IPAFrameContext::filter.denoise + * \brief Denoising level + * + * \var IPAFrameContext::filter.sharpness + * \brief Sharpness level + * + * \var IPAFrameContext::filter.updateParams + * \brief Indicates if the filter parameters have been updated compared to the + * previous frame */ /** * \var IPAFrameContext::sensor - * \brief Effective sensor values + * \brief Sensor configuration that used been used for this frame * * \var IPAFrameContext::sensor.exposure * \brief Exposure time expressed as a number of lines @@ -145,12 +345,20 @@ namespace libcamera::ipa::rkisp1 { */ /** - * \var IPAFrameContext::frameCount - * \brief Counter of requests queued to the IPA module + * \struct IPAContext + * \brief Global IPA context data shared between all algorithms + * + * \var IPAContext::hw + * \brief RkISP1 version-specific hardware parameters + * + * \var IPAContext::configuration + * \brief The IPA session configuration, immutable during the session + * + * \var IPAContext::activeState + * \brief The IPA active state, storing the latest state for all algorithms * - * The counter is reset to 0 when the IPA module is configured, and is - * incremented for each request being queued, after calling the - * Algorithm::prepare() function of all algorithms. + * \var IPAContext::frameContexts + * \brief Ring buffer of per-frame contexts */ } /* namespace libcamera::ipa::rkisp1 */ |