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

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  chistatsparser.h
/// @brief Stats Parser external header
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// NOWHINE FILE GR016: Typedefs must not be used for structs, classes, and enumerations

#ifndef CHISTATSPARSER_H
#define CHISTATSPARSER_H

#include "chiispstatsdefs.h"
#include "chistatsinterfacedefs.h"

#include "camxcdktypes.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_parser
@{ */

/// @brief Supported camera architecture families.
typedef enum
{
    CameraFamilyTitan,    ///< Titan camera architecture.
} CHICameraFamily;


/// @brief Function wrapper for the Statistics Parser.
typedef struct /** @cond */ CHIStatsParser /** @endcond */
{
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ParseBFStats @endcond
    ///
    /// @brief Gets the Bayer focus statistics from the buffer.
    ///
    /// @datatypes
    /// #BFStatsROIConfigType \n
    /// ParsedBFStatsOutput
    ///
    /// @param[in] pStatsParser  Pointer to the instance of the Statistics Parser.
    /// @param[in] pBuffer       Pointer to the buffer.
    /// @param[in] pBFConfig     Pointer to the configuration of the Bayer focus statistics.
    /// @param[in] ppStats       Double pointer to the statistics buffer.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*ParseBFStats)(
        const CHIStatsParser*          pStatsParser,
        VOID*                          pBuffer,
        const BFStatsROIConfigType*    pBFConfig,
        ParsedBFStatsOutput**          ppStats);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ParseHDRBEStats @endcond
    ///
    /// @brief Gets the HDR Bayer exposure statistics from the buffer.
    ///
    /// @datatypes
    /// #BGBEConfig \n
    /// ParsedHDRBEStatsOutput
    ///
    /// @param[in] pStatsParser  Pointer to the instance of the Statistics Parser.
    /// @param[in] pBuffer       Pointer to the buffer.
    /// @param[in] pHDRBEConfig  Pointer to the configuration of the Bayer exposure statistics.
    /// @param[in] ppStats       Double pointer to the statistics buffer.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*ParseHDRBEStats)(
        const CHIStatsParser*       pStatsParser,
        VOID*                       pBuffer,
        const BGBEConfig*           pHDRBEConfig,
        ParsedHDRBEStatsOutput**    ppStats);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ParseAWBBGStats @endcond
    ///
    /// @brief Gets the AWB Bayer grid statistics from the buffer.
    ///
    /// @datatypes
    /// #BGBEConfig \n
    /// ParsedAWBBGStatsOutput
    ///
    /// @param[in] pStatsParser  Pointer to the Statistics Parser instance
    /// @param[in] pBuffer       Pointer to the buffer.
    /// @param[in] pBGConfig     Pointer to the configuration of the Bayer grid statistics.
    /// @param[in] ppStats       Double pointer to the statistics buffer.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*ParseAWBBGStats)(
        const CHIStatsParser*       pStatsParser,
        VOID*                       pBuffer,
        const BGBEConfig*           pAWBBGConfig,
        ParsedAWBBGStatsOutput**    ppStats);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ParseTintlessBGStats @endcond
    ///
    /// @brief Gets the tintless Bayer grid statistics from the buffer.
    ///
    /// @datatypes
    /// #BGBEConfig \n
    /// ParsedTintlessBGStatsOutput
    ///
    /// @param[in] pStatsParser       Pointer to the Statistics Parser instance
    /// @param[in] pBuffer            Pointer to the buffer.
    /// @param[in] pTintlessBGConfig  Pointer to the configuration of the Bayer grid statistics.
    /// @param[in] ppStats            Double pointer to the statistics buffer.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult(*ParseTintlessBGStats)(
        const CHIStatsParser*         pStatsParser,
        VOID*                         pBuffer,
        const BGBEConfig*             pTintlessBGConfig,
        ParsedTintlessBGStatsOutput** ppStats);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ParseCSStats @endcond
    ///
    /// @brief Gets the column sum statistics from the buffer.
    ///
    /// @datatypes
    /// ISPCSStatsConfig \n
    /// ParsedCSStatsOutput
    ///
    /// @param[in] pStatsParser  Pointer to the instance of the Statistics Parser.
    /// @param[in] pBuffer       Pointer to the buffer.
    /// @param[in] pCSConfig     Pointer to the configuration of the column sum statistics.
    /// @param[in] ppStats       Double pointer to the statistics buffer.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*ParseCSStats)(
        const CHIStatsParser*      pStatsParser,
        VOID*                      pBuffer,
        const ISPCSStatsConfig*    pCSConfig,
        ParsedCSStatsOutput**      ppStats);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ParseRSStats @endcond
    ///
    /// @brief Gets the row sum statistics from the buffer.
    ///
    /// @datatypes
    /// ISPRSStatsConfig \n
    /// ParsedRSStatsOutput
    ///
    /// @param[in] pStatsParser  Pointer to the instance of the Statistics Parser.
    /// @param[in] pBuffer       Pointer to the buffer.
    /// @param[in] pRSConfig     Pointer to the configuration of the row sum statistics.
    /// @param[in] ppStats       Double pointer to the statistics buffer.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*ParseRSStats)(
        const CHIStatsParser*      pStatsParser,
        VOID*                      pBuffer,
        const ISPRSStatsConfig*    pRSConfig,
        ParsedRSStatsOutput**      ppStats);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ParseIHistStats @endcond
    ///
    /// @brief Gets the image histogram statistics from the buffer.
    ///
    /// @datatypes
    /// ISPIHistStatsConfig \n
    /// ParsedIHistStatsOutput
    ///
    /// @param[in] pStatsParser  Pointer to the instance of the Statistics Parser.
    /// @param[in] pBuffer       Pointer to the buffer.
    /// @param[in] pIHistConfig  Pointer to the configuration of the image histogram statistics.
    /// @param[in] ppStats       Double pointer to the statistics buffer.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*ParseIHistStats)(
        const CHIStatsParser*         pStatsParser,
        VOID*                         pBuffer,
        const ISPIHistStatsConfig*    pIHistConfig,
        ParsedIHistStatsOutput**      ppStats);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond ParseLTMDCStats @endcond
    ///
    /// @brief Gets the Local Tone Map Data Collection (LTMDC) statistics from the buffer.
    ///
    /// @datatypes
    /// ISPLTMDCStatsConfig \n
    /// LTMDCStatsOutput
    ///
    /// @param[in] pStatsParser  Pointer to the Statistics Parser instance.
    /// @param[in] pBuffer       Pointer to the buffer.
    /// @param[in] pIHistConfig  Pointer to the configuration of the LTMDC statistics.
    /// @param[in] ppStats       Double pointer to the statistics buffer.
    ///
    /// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}). @newpage
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    CDKResult (*ParseLTMDCStats)(
        const CHIStatsParser*         pStatsParser,
        VOID*                         pBuffer,
        const ISPLTMDCStatsConfig*    pLTMDCConfig,
        LTMDCStatsOutput**      ppStats);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond GetMaxStatsBufferSize @endcond
    ///
    /// @brief Gets the maximum size of the parsed and unparsed statistics.
    ///
    /// @datatypes
    /// ISPStatsType
    ///
    /// @param[in] pStatsParser  Pointer to the instance of the Statistics Parser.
    /// @param[in] statsType     Type of statistics.
    ///
    /// @return Size in bytes.
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    INT32 (*GetMaxStatsBufferSize)(
        const CHIStatsParser*    pStatsParser,
        ISPStatsType             statsType);

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// @cond StatsParserDestroy @endcond
    ///
    /// @brief Destroys a derived instance of the interface.
    ///
    /// @param[in] pStatsParser  Pointer to the instance of the Statistics Parser.
    ///
    /// @return None.
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    VOID (*StatsParserDestroy)(
        const CHIStatsParser*    pStatsParser);

    /// Pointer to the actual instance of the Statistics Parser.
    /// @newpage
    VOID *pContext;

} CHIStatsParser; // CHIStatsParser interface

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond CreateStatsParser @endcond
///
/// @brief Creates a derived instance of the interface.
///
/// @datatypes
/// #CHICameraFamily \n
/// #CHIStatsParser
///
/// @param[in] cameraFamily   Allows the Statistics Parser to know which camera family it must parse.
/// @param[in] ppStatsParser  Double pointer to the Statistics Parser instance.
///
/// @return #CDKResultSuccess or an error code (see Section @xref{hdr:resultMessages}).
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CDKResult CreateStatsParser(
    CHICameraFamily     cameraFamily,
    CHIStatsParser**    ppStatsParser);

/** @} */ /* end_addtogroup chi_stats_parser */

#pragma pack(pop)

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHISTATSPARSER_H
