///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2023 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  chiafdinterface.h
/// @brief AFD algorithm interfaces
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHIAFDINTERFACE_H
#define CHIAFDINTERFACE_H

#include "chistatsinterfacedefs.h"
#include "chistatsdebug.h"
#include "chiafcommon.h"

#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus

// Data structures that are exposed to OEM must be packed to have the expected layout.
#pragma pack(push, CDK_PACK_SIZE)

/** @addtogroup chi_stats_afd
@{ */

// @brief Valid flash modes.
enum InputFlashMode
{
    FlashModeOff,         ///< Flash is OFF.
    FlashModeSingle,      ///< Single flash capture.
    FlashModeTorch,       ///< Continuous flash mode.
    FlashModeEnd          ///< End of the enumeration.
};

// @brief Defines the flicker frequency and amplitude in the frequency domain for the spectral sensor.
struct SpectralComponent
{
    FLOAT amplitude;     ///< Amplitude value.
    FLOAT frequency;     ///< Frequency value.
};

/// @brief Spectral sensor information consumed by the AFD.
typedef struct
{
    BOOL                  isValid;                      ///< Indicates whether the data is valid.
                                                        ///
                                                        ///  @valuesbul
                                                        ///  - 0 -- FALSE
                                                        ///  - 1 -- TRUE @tablebulletend

    UINT64                configSamplingFreq;           ///< Sampling frequency for the flicker channel.
    SpectralComponent     firstMaximaPeak;              ///< First maximum frequency amplitude in the frequency domain.
    SpectralComponent     secondMaximaPeak;             ///< Second maximum frequency amplitude in the frequency domain.
    UINT16                avgRawFlickerData;            ///< Average value for the Raw of flicker channel.
    UINT16                maxRawFlickerData;            ///< Maximum value for the Raw of flicker channel.
    UINT16                minRawFlickerData;            ///< Minimum value for the Raw of flicker channel.
    UINT16                avgFlickerFreqAmp;            ///< Average of five different flicker frequency amplitudes calculated
                                                        ///  by the FFT.
    FLOAT                 expGainOfFlickerChnl;         ///< Exposure gain of the flicker channel.
    FLOAT                 expTimeOfFlickerChnl;         ///< Exposure time of the flicker channel if available.
                                                        ///  Otherwise, -1.0.
    FLOAT                 luxValue;                     ///< Scene brightness value from the spectral sensor.
} AFDSpectralSensorInfo;

/// @brief Configuration information output by the AFD algorithm.
typedef struct
{
    UINT64      flickerSamplingFreq;            ///< Sampling frequency of the flicker channel.
} AFDAlgoSpectralSensorConfig;

/// @brief AEC information consumed by the AFD algorithm.
typedef struct
{
    BOOL             isAECsettled;                           ///< Indicates whether the AEC is settled.
                                                             ///
                                                             ///  @valuesbul
                                                             ///  - 0 -- FALSE
                                                             ///  - 1 -- TRUE @tablebulletend

    FLOAT            luxIDx;                                 ///< Current index of the lux value.
    FLOAT            realGain[MaxNumOfInputExposures];       ///< Current gain from the AEC.
    FLOAT            currentExpTime[MaxNumOfInputExposures]; ///< Current exposure time from the AEC.
    AECFlashInfoType flashInfo;                              ///< Type of flash: main or preflash.
    FLOAT            compenADRCGain;                         ///< DRC value from AEC.
    FLOAT            compensationDarkBoostGain;              ///< Compensation for dark boost gain.
    FLOAT            LEDInfluenceRatio;                      ///< LED Influence ratio
} AFDAECInfo;

/// @brief Sensor information that the AFD algorithm consumes.
typedef struct
{
    FLOAT  maxFPS;                              ///< Maximum number of frames per second from the sensor for this mode.
    UINT64 outPixelClock;                       ///< Clock frequency for the pixel value output.
    UINT   binningTypeH;                        ///< Horizontal binning.
    UINT   binningTypeV;                        ///< Vertical binning.
    UINT   numPixelsPerLine;                    ///< Number of pixels per line (lineLengthPclk).
    UINT   numLinesPerFrame;                    ///< Number of lines per frame (frameLengthLines).
    UINT   maxLineCount;                        ///< Maximum number of lines per frame.
    UINT32 minHorizontalBlanking;               ///< Minimum horizontal blanking interval (in pixels).
    UINT32 minVerticalBlanking;                 ///< Minimum horizontal blanking interval (in lines).
    FLOAT  rowSumTime[MaxNumOfInputExposures];  ///< Time taken to generate from the first pixel of the first line to the
                                                ///  last pixel of the last line.
    FLOAT  curFPS;                              ///< Number of frames per second in the current use case.
    UINT32 sensorHeight;                        ///< Height of the sensor.
    UINT32 sensorWidth;                         ///< Width of the sensor.
    SensorHDRConfig sensorConfig;               ///< HDR mode and number of exposures.
    FLOAT  rollingShutterSkew;                  ///< Rolling shutter skew (in nanoseconds).
} AFDSensorInfo;

/// @brief Autofocus output information consumed by the AFD.
typedef struct
{
    BOOL                isAFSearching;       ///< Indicates whether autofocus is actively searching.
                                             ///
                                             ///  @valuesbul
                                             ///  - 0 -- FALSE
                                             ///  - 1 -- TRUE @tablebulletend

    AFLensPositionInfo  lensPositionInfo;    ///< Information about the lens position and movement type.
} AFDAFInfo;

/// @brief Types of Process input parameters for the AFD algorithm.
typedef enum
{
    AFDAlgoInputInvalid        = -1,        ///< Type is unknown or invalid.
    AFDAlgoInputBayerGrid,                  ///< Payload: #StatsBayerGrid
    AFDAlgoInputRowSum,                     ///< Payload: #StatsRowSum
    AFDAlgoInputVendorTag,                  ///< Vendor tags the AFD algorithm depends on. \n
                                            ///  Payload: #StatsVendorTagList
    AFDAlgoInputStatsChiHandle,             ///< Handle of the create session. See #CHISTATSHANDLE.
    AFDAlgoInputTypeDebugData,              ///< Debug data buffer. \n
                                            ///  Payload: Pointer to the buffer
    AFDAlgoInputBayerRowSum,                ///< Bayer row sum statistics.
    AFDAlgoInputCameraInfo,                 ///< Stats camera info
    AFDInputTypeLastIndex,                  ///< Last valid index of the enumeration.
    AFDAlgoInputMax         = 0x7FFFFFFF    ///< Indicates the last item in the definition.
} AFDAlgoInputType;

/// @brief Base structure of a Process input parameter for an AFD algorithm instance. This structure is used with
///        #AFDAlgoInputList.
typedef struct
{
    VOID*                   pAFDInput;          ///< Pointer to the parameter payload.
    UINT32                  sizeOfAFDInput;     ///< Size of the payload data (in bytes).
    AFDAlgoInputType        inputType;          ///< Type of input payload.
} AFDAlgoInput;

/// @brief List of Process input parameters that are passed to #CHIAFDAlgorithm::AFDProcess().
typedef struct
{
    AFDAlgoInput*       pAFDInputList;          ///< Pointer to the array of parameters.
    SIZE_T              inputCount;             ///< Number of elements in the array.
} AFDAlgoInputList;

/// @brief Frame information the AFD algorithm outputs after it processes the statistics.
typedef struct
{
    StatisticsAntibanding   currentAFDMode;            ///< Algorithm detected the AFD mode.

    BOOL                    isSkipRSStatsParser;       ///< Indicates whether to skip Row Sum statistics parsing.
                                                       ///
                                                       ///  @valuesbul
                                                       ///  - 0 -- FALSE
                                                       ///  - 1 -- TRUE @tablebulletend
    BOOL                    isFlickerDetected;         ///< Indicates whether flicker is detected.
                                                       ///
                                                       ///  @valuesbul
                                                       ///  - 0 -- FALSE
                                                       ///  - 1 -- TRUE @tablebulletend

    INT32                   flickerFreq;               ///< Flicker frequency detected by the algorithm.
    StatsTemporalContext    afdAfcTemporalContext;     ///< AFC Temporal Context
    FCGStateType            FCGState;               ///< Current FCG State
    UINT64                  minExpTimeToCorrect;    ///< Min exposure time required to correct banding
} AFDAlgoFrameSetting;

/// @brief Types of Process output parameters for the AFD algorithm.
typedef enum
{
    AFDAlgoOutputInvalid       = -1,                                ///< Type is unknown or invalid.
    AFDAlgoOutputFrameSetting  = 0,                                 ///< Frame setting after statistics are processed. \n
                                                                    ///  Payload: #AFDAlgoFrameSetting.
    AFDAlgoOutputRowSumConfig,                                      ///< Payload: #AFDAlgoRowSumConfig.
    AFDAlgoOutputBayerRowSumConfig = AFDAlgoOutputRowSumConfig,     ///< Bayer row sum configuration.
    AFDAlgoOutputSkipRSStatsFlag,                                   ///< Flag used to skip row sum statistics.
    AFDAlgoOutputVendorTag,                                         ///< Vendor tags the algorithm is to publish. \n
                                                                    ///  Payload: #StatsVendorTagList
    AFDAlgoLastDetectedMode,                                        ///< Last detected AFD Frame Settings
    AFDAlgoSpectralSensorConfiguration,                             ///< Get spectral sensor config based on AFD decision
                                                                    ///  Output payload: AFDAlgoSpectralSensorConfig
    AFDAlgoNumberOfVisibleBands,                                    ///< Number of visible bands
                                                                    ///< Payload: FLOAT
    AFDAlgoAvgRollingEnergyRatio,                                   ///< Average Rolling Energy Ratio
                                                                    ///< Payload: FLOAT
    AFDAlgoAvgRollingConfidenceScore,                               ///< Average Rolling Confidence Score
                                                                    ///< Payload: FLOAT
    AFDAlgoAvgStaticEnergyRatio,                                    ///< Average Static Energy Ratio
                                                                    ///< Payload: FLOAT
    AFDAlgoAvgStaticConfidenceScore,                                ///< Average Static Confidence Score
                                                                    ///< Payload: FLOAT
    AFDAlgoOutputSFEBayerRowSumConfig,                              ///< SFE Bayer Row Sum Config based on exposures
                                                                    ///  Payload: #AFDAlgoRowSumConfig * Max Input Exp.
    AFDAlgoOutputFCGConfig,                                         ///< Config for FCG
                                                                    ///< Payload: #AFDAlgoFCGConfig
    AFDOutputTypeLastIndex,                                         ///< Last OutputType Index
    AFDAlgoOutputMax           = 0x7FFFFFFF                         ///< Anchor to indicate the last item in the defines
} AFDAlgoOutputType;

/// @brief Base structure of a Process output parameter for an AFD algorithm instance. This structure is used with
///        #AFDAlgoOutputList.
typedef struct
{
    VOID*               pAFDOutput;                 ///< Pointer to the payload that is the result of the query.
                                                    ///  The type of data depends on the value of outputType.
                                                    ///  The algorithm implementer must do a deep copy.
    UINT32              sizeOfAFDOutput;            ///< Size of the payload data (in bytes).
    UINT32              sizeOfWrittenAFDOutput;     ///< Size of the payload (in bytes) that is written back.
                                                    ///  If there is no output, set this parameter to 0.
    AFDAlgoOutputType   outputType;                 ///< Type of output payload.
} AFDAlgoOutput;

/// @brief List of Process output parameters that are passed to #CHIAFDAlgorithm::AFDProcess().
typedef struct
{
    AFDAlgoOutput*  pAFDOutputList; ///< Pointer to the array of parameters.
    UINT32          outputCount;    ///< Number of elements in the array.
} AFDAlgoOutputList;

/// @brief Types of Set parameters for the AFD algorithm.
typedef enum
{
    AFDAlgoSetParamInvalid            = -1,         ///< Type is unknown or invalid.
    AFDAlgoSetParamChromatixData,                   ///< Chromatix tuning header for the AFD algorithm. \n
                                                    ///  Payload: #StatsTuningData
    AFDAlgoSetParamAECInfo,                         ///< AEC updates shared with the AFD algorithm. \n
                                                    ///  Payload: #AFDAECInfo
    AFDAlgoSetParamAFInfo,                          ///< AF updates shared with the AFD algorithm. \n
                                                    ///  Payload: #AFDAFInfo
    AFDAlgoSetParamSensorInfo,                      ///< Sensor update information shared with the AFD algorithm. \n
                                                    ///  Payload: #AFDSensorInfo
    AFDAlgoSetParamAFDMode,                         ///< Indicates whether to disable (0) or enable (1) AFD modes. \n
                                                    ///  Payload: #StatisticsAntibanding
    AFDAlgoSetParamDumpRowSum,                      ///< Specifies whether to dump (1) row sum statistics.
    AFDAlgoSetParamOverrideSettings,                ///< Payload: #StatisticsAntibanding
    AFDAlgoSetParamFrameId,                         ///< Identifier of the frame.
    AFDAlgoSetParamBPSCamera,                       ///< Specifies whether a BPS real-time use case is selected (1).
    AFDAlgoSetParamPipelineDelay,                   ///< Pipeline delay / system latency
    AFDAlgoSetParamCameraInfo,                      ///< Payload: #StatsCameraInfo
    AFDAlgoSetParamGyroInfo,                        ///< Gyro Information update shared with the AFD algorithm. \n
                                                    ///  Payload: #AFGyroData
    AFDAlgoSetParamFlashMode,                       ///< Payload: #InputFlashMode
    AFDAlgoSetParamSpectralSensorInfo,              ///< Payload: #AFDSpectralSensorInfo
    AFDAlgoSetParamTimestampInfo,                   ///< Timestamp Info
                                                    ///  Payload Type: UINT64
    AFDAlgoSetParamWarmStart,                       ///< Set AFD Warm start information
                                                    ///  Payload: #AFDWarmStart
    AFDAlgoSetParamAFCDumpData,                     ///< AFC Dump info flag
                                                    ///< Payload Type: BOOL
    AFDSetParamLastIndex,                           ///< Last valid index of the enumeration.
    AFDAlgoSetParamMax                = 0x7FFFFFFF  ///< Indicates the last item in the definition.
} AFDAlgoSetParamType;

/// @brief Base structure of a Set parameter for an AFD algorithm instance. This structure is used with #AFDAlgoSetParamList.
typedef struct
{
    VOID*               pAFDSetParam;      ///< Pointer to the parameter payload.
    UINT32              sizeOfAFDSetParam; ///< Size of the payload data (in bytes).
    AFDAlgoSetParamType setParamType;      ///< Type of parameter that is passed to the algorithm.
} AFDAlgoSetParam;

/// @brief List of Set parameters that are passed to #CHIAFDAlgorithm::AFDSetParam().
typedef struct
{
    AFDAlgoSetParam*    pAFDSetParamList;    ///< Pointer to the array of parameters.
    SIZE_T              numberOfSetParam;    ///< Number of elements in the array.
} AFDAlgoSetParamList;

/// @brief Statistics configuration required from the AFD algorithm.
typedef struct
{
    UINT32             statsHnum;                                              ///< Total number of horizontal rows.
    UINT32             statsVnum;                                              ///< Total number of vertical columns.
    BayerRSChannelType channelSelect;                                          ///< Selected Bayer channel.
    FLOAT              yCoefficient[RGBChannelCount];                          ///< Array of Y statistics channel weights
                                                                               ///  indexed by one of the channel index values.
    UINT32             darkPixelThreshold;                                     ///< Threshold value for dark pixel.
    UINT32             brightPixelThreshold;                                   ///< Threshold value for bright pixels.
    UINT32             segmentBaseConfig[RSSegmentBaseConfigCount];            ///< Array of base values of segments.
    UINT32             segmentSlopeConfig[RSSegmentSlopeConfigCount];          ///< Array of slope values of segments.
    UINT32             segmentStartBinConfig[RSSegmentStartBinConfigCount];    ///< Array of start bin positions.
    BOOL               bShiftBitsEnable;                                       ///< Dynamic Shift Bit is enabled
    UINT8              shiftBits;                                              ///< shift bits
} AFDAlgoRowSumConfig;

/// @brief Types of Get parameters for the AFD algorithm.
typedef enum
{
    AFDAlgoGetParamInvalid                   = -1,                           ///< Type is unknown or invalid.
    AFDAlgoGetParamRSStatsConfig,                                            ///< Get the row sum statistics configuration
                                                                             ///  from the algorithm. \n
    AFDAlgoGetParamBayerRSStatsConfig        = AFDAlgoGetParamRSStatsConfig, ///< Get the Bayer row sum statistics
                                                                             ///  configuration from the algorithm.
                                                                             ///  Payload: AFDAlgoRowSumConfig
    AFDAlgoGetParamPublishingVendorTagsInfo,                                 ///< Vendor tags published by the algorithm. \n
                                                                             ///  Payload: #AFDAlgoGetParamOutput plus
                                                                             ///  AFDAlgoGetParamOutputVendorTagInfoList
    AFDAlgoGetParamDependentVendorTags,                                      ///< Vendor tags the algorithm depends on. \n
                                                                             ///  Payload: #AFDAlgoGetParamOutput plus
                                                                             ///  #AFDAlgoGetParamOutputVendorTagInfoList
    AFDAlgoGetParamOutputVendorTagInfoList,                                  ///< Payload: #StatsVendorTagInfoList
    AFDAlgoGetParamLastDetectedAFDSettings,                                  ///< Get the last detected AFD mode from the
                                                                             ///  algorithm. \n
                                                                             ///  Payload: #AFDAlgoFrameSetting
    AFDAlgoGetParamSFEBayerRSStatsConfig,                                    ///< Get the Bayer row sum statistics
                                                                             ///  configuration from the algorithm. \n
                                                                             ///  Payload: AFDAlgoStatsConfig * Maximum
                                                                             ///  exposure
    AFDAlgoGetParamMax                       = 0x7FFFFFFF                    ///< Indicates the last item in the definition.
} AFDAlgoGetParamType;

/// @brief Base structure of a Get input parameter for an AEC algorithm instance. This structure is used with #AFDAlgoGetParam.
typedef struct
{
    VOID*   pInputData;         ///< Pointer to the parameter payload, which contains input metadata and
                                ///  supporting information required for generating the output.
    UINT32  sizeOfInputData;    ///< Size of the payload data (in bytes).
} AFDAlgoGetParamInput;

/// @brief Base structure of a Get output parameter for an AEC algorithm instance.
///        This structure is used with #AFDAlgoGetParam.
typedef struct
{
    VOID*   pOutputData;        ///< Pointer to the parameter payload that is the result of the query.
    UINT32  sizeOfOutputData;   ///< Size of the payload data (in bytes).
} AFDAlgoGetParamOutput;

/// @brief List of Get parameters for a query from an Autofocus algorithm instance.
///        This list is passed to #AFDAlgoGetParamList.
typedef struct
{
    AFDAlgoGetParamType    type;   ///< Type of information to get from the algorithm. This type describes the
                                   ///  metadata for the caller.
    AFDAlgoGetParamInput   input;  ///< Input data that is necessary to support the query.
    AFDAlgoGetParamOutput  output; ///< Output metadata that is returned as a result of the query.
} AFDAlgoGetParam;

/// @brief List of parameters that are passed to #CHIAFDAlgorithm::AFDGetParam().
typedef struct
{
    AFDAlgoGetParam*    pAFDGetParamList;       ///< Pointer to the array of parameters.
    UINT32              numberOfAFDGetParams;   ///< Number of elements in the array.
} AFDAlgoGetParamList;

/// @brief Features supported by the AFD algorithm.
typedef enum
{
    AFDAlgoFeatureBasic        = 1 << 0,        ///< AFD features with basic functionalities.
    AFDAlgoFeatureMax          = 1 << 31,       ///< Indicates the last item in the definition.
} AFDAlgoFeatureType;

/// @brief Parameter types used when creating an AFD algorithm instance.
typedef enum
{
    AFDAlgoCreateParamsInvalid              = -1,        ///< Type is unknown or invalid.
    AFDAlgoCreateParamsLoggerFunctionPtr,                ///< Pointer to the statistics logger function. \n
                                                         ///  Payload: StatsLoggerFunction
    AFDAlgoCreateParamsCameraInfo,                       ///< Information about the logging camera. \n
                                                         ///  Payload: #StatsCameraInfo
    AFDCreateParamTypeCount,                             ///< Total number of parameters.
    AFDAlgoCreateParamsMax                  = 0x7FFFFFFF ///< Indicates the last item in the definition.
} AFDAlgoCreateParamsType;

/// @brief Base structure of a Create parameter for an AFD algorithm instance.
///        This structure is used with #AFDAlgoCreateParamList.
typedef struct
{
    VOID*                        pCreateParam;       ///< Pointer to the parameter payload.
    UINT32                       sizeOfCreateParam;  ///< Size of the payload data (in bytes).
    AFDAlgoCreateParamsType      createParamType;    ///< Type of parameter.
} AFDAlgoCreateParam;

/// @brief List of parameters that are passed to CREATEAFD().
typedef struct
{
    AFDAlgoCreateParam*          pCreateParamList;      ///< Pointer to the array of parameters.
    SIZE_T                       paramCount;            ///< Number of elements in the array.
} AFDAlgoCreateParamList;

/// @brief Defines manual override settings that are set to the AFD algorithm.
typedef struct
{
    // All the override flags will be added here
    // These setting will be used to override tuning settings
    UINT32 profile3A;                       ///< 3A profiling value.
    BOOL   enable3ADebugData;               ///< Flag to enable or disable 3A debug data.
    BOOL   enable3ADebugDataCustomFilter;   ///< Flag to enable or disable customized tag filter
} AFDAlgoOverrideSettingParam;

/// @brief Types of Destroy parameters for the AFD algorithm.
enum AFDAlgoDestroyParamType
{
    AFDDestroyParamTypeInvalid               = -1,           ///< Type is unknown or invalid.
    AFDDestroyParamTypeCameraCloseIndicator,                 ///< Indicates whether the camera is closed (0) or open (1).
    AFDDestroyParamTypeCameraInfo,                           ///< Information about the camera. \n
                                                             ///  Payload: #StatsCameraInfo
    AFDDestroyParamTypeCount,                                ///< Total number of parameters.
    AFDDestroyParamTypeMax                   = 0x7FFFFFFF    ///< Indicates the last item in the definition.
};

/// @brief Base structure of a Destroy parameter for an AFD algorithm instance.
///        This structure is used with #AFDAlgoDestroyParamList.
struct AFDAlgoDestroyParam
{
    AFDAlgoDestroyParamType  destroyParamType;       ///< Type of parameter.
    VOID*                    pParam;                 ///< Pointer to the parameter payload.
    UINT32                   sizeOfParam;            ///< Size of the payload data (in bytes).
};

/// @brief List of Destroy parameters that are passed to CREATEAFD().
struct AFDAlgoDestroyParamList
{
    AFDAlgoDestroyParam* pParamList;     ///< Pointer to the array of parameters.
    UINT32               paramCount;     ///< Number of elements in the array.
                                         ///  @newpagetable
};

///Structure required for AFD Warm Start
typedef struct
{
    UINT32          AFDFrequency;        ///<That will define the AFD Frequency 50/60 Hz
    UINT8           IsFlickerDetected;   ///<Check if flicker is detected or not
} AFDWarmStart;



/// @brief Function wrapper for the AFD algorithm.
typedef struct /** @cond */ CHIAFDAlgorithm /** @endcond */
{
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond AFDDestroy @endcond
    ///
    /// @brief Destroys a derived instance of the AFD algorithm interface.
    ///
    /// @datatypes
    /// #AFDAlgoDestroyParamList
    ///
    /// @param[in] pCHIAFDAlgorithm  Pointer to the algorithm instance.
    /// @param[in] pDestroyParams    Pointer to the list of parameters.
    ///
    /// @return None. @newpage
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    VOID (*AFDDestroy)(
        CHIAFDAlgorithm*                 pCHIAFDAlgorithm,
        const AFDAlgoDestroyParamList*   pDestroyParams);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond AFDProcess @endcond
    ///
    /// @brief Runs the statistic algorithm on the given inputs. This method
    ///        must only be called after the algorithm is initialized.
    ///
    /// @param[in] pCHIAFDAlgorithm  Pointer to the algorithm instance.
    /// @param[in] pInputList        Pointer to the statistics inputs interface.
    /// @param[in] pOutputList       Pointer to the statistics data that the algorithm outputs.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*AFDProcess)(
        CHIAFDAlgorithm*             pCHIAFDAlgorithm,
        const AFDAlgoInputList*      pInputList,
        AFDAlgoOutputList*           pOutputList);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond AFDGetParam @endcond
    ///
    /// @brief Retrieves the most up-to-date AFD algorithm metadata. The output is updated after calling AFDProcess().
    ///
    /// @datatypes
    /// #AFDAlgoGetParamList
    ///
    /// @param[in]  pCHIAFDAlgorithm  Pointer to the algorithm instance.
    /// @param[out] pGetParam         Pointer to the list of parameters and associated data that are necessary to support the
    ///                               query.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*AFDGetParam)(
        CHIAFDAlgorithm*          pCHIAFDAlgorithm,
        AFDAlgoGetParamList*      pGetParamList);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond AFDSetParam @endcond
    ///
    /// @brief Sets configuration parameters to the AFD algorithm.
    ///
    /// @datatypes
    /// #AFDAlgoSetParamList
    ///
    /// @param[in] pCHIAFDAlgorithm  Pointer to the algorithm instance.
    /// @param[in] pSetParamList     Pointer to the statistics configuration parameters to set.
    ///                              Each element of the list is of type #AFDAlgoSetParam.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*AFDSetParam)(
        CHIAFDAlgorithm*                pCHIAFDAlgorithm,
        const AFDAlgoSetParamList*      pSetParamList);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond AFDGetFeatureCapability @endcond
    ///
    /// @brief Gets the supported algorithm features.
    ///
    /// @param[in] pCHIAFDAlgorithm  Pointer to the algorithm instance.
    /// @param[in] pFeatures         Pointer to the features returned from the AFD algorithm. It is a bitmask of
    ///                              supported #AFDAlgoFeatureType values.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*AFDGetFeatureCapability)(
        CHIAFDAlgorithm*   pCHIAFDAlgorithm,
        UINT64*            pFeatures);

} CHIAFDAlgorithm; // CHIAFDAlgorithm interface

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond CreateAFD @endcond
///
/// @brief Creates an instance to the CHIAFDAlgorithm.
///
/// @datatypes
/// #AFDAlgoCreateParamList \n
/// #CHIAFDAlgorithm
///
/// @param[in] pCreateParamList   Pointer to the list of parameters.
/// @param[in] ppCHIAFDAlgorithm  Double pointer to the created AFD algorithm instance.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
typedef CDKResult (*CREATEAFD)(
    const AFDAlgoCreateParamList*      pCreateParamList,
    CHIAFDAlgorithm**                  ppCHIAFDAlgorithm);

/** @} */ /* end_addtogroup chi_stats_afd */


#pragma pack(pop)

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHIAFDINTERFACE_H
