/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2021, Ideas On Board
 *
 * algorithm.cpp - IPA control algorithm interface
 */

#include "algorithm.h"

/**
 * \file algorithm.h
 * \brief Algorithm common interface
 */

namespace libcamera {

namespace ipa {

/**
 * \class Algorithm
 * \brief The base class for all IPA algorithms
 * \tparam Module The IPA module type for this class of algorithms
 *
 * The Algorithm class defines a standard interface for IPA algorithms
 * compatible with the \a Module. By abstracting algorithms, it makes possible
 * the implementation of generic code to manage algorithms regardless of their
 * specific type.
 *
 * To specialize the Algorithm class template, an IPA module shall specialize
 * the Module class template with module-specific context and configuration
 * types, and pass the specialized Module class as the \a Module template
 * argument.
 */

/**
 * \typedef Algorithm::Module
 * \brief The IPA module type for this class of algorithms
 */

/**
 * \fn Algorithm::init()
 * \brief Initialize the Algorithm with tuning data
 * \param[in] context The shared IPA context
 * \param[in] tuningData The tuning data for the algorithm
 *
 * This function is called once, when the IPA module is initialized, to
 * initialize the algorithm. The \a tuningData YamlObject contains the tuning
 * data for algorithm.
 *
 * \return 0 if successful, an error code otherwise
 */

/**
 * \fn Algorithm::configure()
 * \brief Configure the Algorithm given an IPAConfigInfo
 * \param[in] context The shared IPA context
 * \param[in] configInfo The IPA configuration data, received from the pipeline
 * handler
 *
 * Algorithms may implement a configure operation to pre-calculate
 * parameters prior to commencing streaming.
 *
 * Configuration state may be stored in the IPASessionConfiguration structure of
 * the IPAContext.
 *
 * \return 0 if successful, an error code otherwise
 */

/**
 * \fn Algorithm::queueRequest()
 * \brief Provide control values to the algorithm
 * \param[in] context The shared IPA context
 * \param[in] frame The frame number to apply the control values
 * \param[in] frameContext The current frame's context
 * \param[in] controls The list of user controls
 *
 * This function is called for each request queued to the camera. It provides
 * the controls stored in the request to the algorithm. The \a frame number
 * is the Request sequence number and identifies the desired corresponding
 * frame to target for the controls to take effect.
 *
 * Algorithms shall read the applicable controls and store their value for later
 * use during frame processing.
 */

/**
 * \fn Algorithm::prepare()
 * \brief Fill the \a params buffer with ISP processing parameters for a frame
 * \param[in] context The shared IPA context
 * \param[in] frame The frame context sequence number
 * \param[in] frameContext The FrameContext for this frame
 * \param[out] params The ISP specific parameters
 *
 * This function is called for every frame when the camera is running before it
 * is processed by the ISP to prepare the ISP processing parameters for that
 * frame.
 *
 * Algorithms shall fill in the parameter structure fields appropriately to
 * configure the ISP processing blocks that they are responsible for. This
 * includes setting fields and flags that enable those processing blocks.
 */

/**
 * \fn Algorithm::process()
 * \brief Process ISP statistics, and run algorithm operations
 * \param[in] context The shared IPA context
 * \param[in] frame The frame context sequence number
 * \param[in] frameContext The current frame's context
 * \param[in] stats The IPA statistics and ISP results
 * \param[out] metadata Metadata for the frame, to be filled by the algorithm
 *
 * This function is called while camera is running for every frame pro<span class="hl kwa">&lt;svg</span> <span class="hl kwb">xmlns</span>=<span class="hl str">&quot;http://www.w3.org/2000/svg&quot;</span> <span class="hl kwb">width</span>=<span class="hl str">&quot;24&quot;</span> <span class="hl kwb">height</span>=<span class="hl str">&quot;24&quot;</span> <span class="hl kwb">viewBox</span>=<span class="hl str">&quot;0 0 24 24&quot;</span> <span class="hl kwb">fill</span>=<span class="hl str">&quot;none&quot;</span> <span class="hl kwb">stroke</span>=<span class="hl str">&quot;currentColor&quot;</span> <span class="hl kwb">stroke-width</span>=<span class="hl str">&quot;2&quot;</span> <span class="hl kwb">stroke-linecap</span>=<span class="hl str">&quot;round&quot;</span> <span class="hl kwb">stroke-linejoin</span>=<span class="hl str">&quot;round&quot;</span> <span class="hl kwb">class</span>=<span class="hl str">&quot;feather feather-edit&quot;</span><span class="hl kwa">&gt;&lt;path</span> <span class="hl kwb">d</span>=<span class="hl str">&quot;M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7&quot;</span><span class="hl kwa">&gt;&lt;/path&gt;&lt;path</span> <span class="hl kwb">d</span>=<span class="hl str">&quot;M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z&quot;</span><span class="hl kwa">&gt;&lt;/path&gt;&lt;/svg&gt;</span>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.1</a> (<a href='https://git-scm.com/'>git 2.18.0</a>) at 2025-03-04 00:26:45 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
ding instance of an AlgorithmFactory and
 * register it with the IPA Module.
 */

/**
 * \fn AlgorithmFactory::AlgorithmFactory()
 * \brief Construct an algorithm factory
 * \param[in] name Name of the algorithm class
 *
 * Creating an instance of the factory automatically registers is with the IPA
 * Module class, enabling creation of algorithm instances through
 * Module::createAlgorithm().
 *
 * The factory \a name identifies the algorithm and shall be unique.
 */

/**
 * \fn AlgorithmFactory::create()
 * \brief Create an instance of the Algorithm corresponding to the factory
 * \return A pointer to a newly constructed instance of the Algorithm subclass
 * corresponding to the factory
 */

/**
 * \def REGISTER_IPA_ALGORITHM
 * \brief Register an algorithm with the IPA module
 * \param[in] algorithm Class name of Algorithm derived class to register
 * \param[in] name Name of the algorithm
 *
 * Register an Algorithm subclass with the IPA module to make it available for
 * instantiation through Module::createAlgorithm(). The \a name identifies the
 * algorithm and must be unique across all algorithms registered for the IPA
 * module.
 */

} /* namespace ipa */

} /* namespace libcamera */