////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
// All rights reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file chistatspropertydefines.h
/// @brief Define Qualcomm Technologies, Inc. statistics proprietary data for defining internal properties/events
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef CHISTATSPROPERTYDEFINES_H
#define CHISTATSPROPERTYDEFINES_H

#include "camxcdktypes.h"
#include "chicommontypes.h"
#include "chifdproperty.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_prop
@{ */

static const UINT8  MaxCCMs              = 4;    ///< Maximum number of supported CCMs.

// Common statistics static definitions
static const UINT8  ChannelIndexR        = 0;    ///< Index for channel type R.
static const UINT8  ChannelIndexB        = 1;    ///< Index for channel type B.
static const UINT8  ChannelIndexGR       = 2;    ///< Index for channel type GR.
static const UINT8  ChannelIndexGB       = 3;    ///< Index for channel type GB.

// Hardware statistics capabilities Supported capabilities.
static const UINT32 HWStatsCapabilityQuadSync         = (1 << 0);  ///< Indicates whether the hardware supports pixel quad
                                                                   ///  synchronization.
static const UINT32 HWStatsCapabilitySaturationStats  = (1 << 1);  ///< Indicates whether the hardware supports saturation
                                                                   ///  statistics.
static const UINT32 HWStatsCapabilityYStats           = (1 << 2);  ///< Indicates whether the hardware supports Y statistics.
static const UINT32 HWStatsCapabilityMinLumaThreshold = (1 << 3);  ///< Indicates whether the hardware supports setting
                                                                   ///  minimum luma thresholds.

// Channel GR and GB are mutually exclusive with Y statistics out mode used channel G and Y.
static const UINT8  ChannelIndexG        = 2;    ///< Index for channel type G.
static const UINT8  ChannelIndexY        = 3;    ///< Index for channel type Y.
static const UINT8  ChannelIndexCount    = 4;    ///< Maximum index for a channel type.
static const UINT32 RGBChannelCount      = 4;    ///< Total Number of channels(RGB & IR).

// Bhist config counts
static const UINT8 SegmentBaseConfigCount     = 8;      ///< Input base value of segments.
static const UINT8 SegmentSlopeConfigCount    = 8;      ///< Slope value of segments.
static const UINT8 SegmentStartBinConfigCount = 7;      ///< Start bin position of segments.
static const UINT8 HorizontalRegionCount      = 3;      ///< Number of horizontal region.
static const UINT8 VerticalRegionCount        = 3;      ///< Number of vertical regions.
static const UINT8 MaxSpatialRegionCount      = 4;      ///< Number of ROIs.
static const UINT8 RegionWeightCount          = 3;      ///< Number of ROI boundary weights.

static const UINT8  LEDSetting1           = 0;    ///< Index for LED setting 1.
static const UINT8  LEDSetting2           = 1;    ///< Index for LED setting 2.
static const UINT8  LEDSettingCount       = 2;    ///< Maximum number of LED settings.

// RS16 Stats counts
static const UINT8 RSSegmentBaseConfigCount     = 8;         ///< Input base value of segments.
static const UINT8 RSSegmentSlopeConfigCount    = 8;         ///< Slope value of segments.
static const UINT8 RSSegmentStartBinConfigCount = 8;         ///< Start bin position of segments.

// FCG Stats Counts
static const UINT32 GainLUTMaxCount             = 128;      ///< Maximum number of GainLUT
static const UINT32 DarkThreshold1MaxCount      = 4;        ///< Max number of Dark Threshold1
static const UINT32 DarkThreshold2MaxCount      = 4;        ///< Max number of Dark Threshold2
static const UINT32 BrightThreshold1MaxCount    = 4;        ///< Max number of Bright Threshold1
static const UINT32 BrightThreshold2MaxCount    = 4;        ///< Max number of Bright Threshold2

// AWB static definitions
static const UINT8  AWBNumCCMRows               = 3;     ///< Number of rows for the color correction matrix.
static const UINT8  AWBNumCCMCols               = 3;     ///< Number of columns for color correction matrix.
static const UINT8  AWBMaxCoefficientSize       = 6;     ///< Maximum size of the coefficient.
static const UINT8  AWBMaxFIRCoefficientSize    = 11;    ///< Maximum size of the FIR coefficient.
static const UINT32 AWBAlgoDecisionMax          = 3;     ///< Maximum number of AWB decision outputs.
static const UINT8  AWBAlgoSAOutputConfSize     = 10;    ///< Maximum number of AWB scene analyzer confidence
                                                         ///  outputs.

// Bayer Autofocus static definitions
static const UINT8  MaxNumOfSteps               = 47;    ///< Maximum number of steps for lens move.
static const UINT8  MaxHPFBufSize               = 22;    ///< Maximum size of high pass filter.
static const UINT8  MaxBFFilterCoringIndex      = 17;    ///< Maximum of rows for the color matrix.
static const UINT8  MaxYConfig                  = 3;     ///< Maximum array size of Y configuration.
static const UINT8  MaxBFGammaEntries           = 32;    ///< Maximum number of gamma entries.
static const UINT8  MaxBFFIRFilterSize          = 13;    ///< Maximum FIR filter size.
static const UINT32 BFMaxROIRegions             = 180;   ///< Maximum window configurations for Bayer focus
                                                         ///  statistics.
static const UINT32 BF27MaxROIRegions           = 768;   ///< Maximum window configurations for Bayer focus
                                                         ///  2.7 statistics.
static const UINT32 BAFMaxGridHorizontalRegions = 32;    ///< Maximum number of horizontal grid regions.
static const UINT32 BAFMinGridHorizontalRegions = 1;     ///< Minimum number of horizontal grid regions.
static const UINT32 BAFMaxGridVerticalRegions   = 24;    ///< Maximum number of vertical grid regions.
static const UINT32 BAFMinGridVerticalRegions   = 1;     ///< Minimum number of vertical grid regions.

// Contrast Autofocus static definitions
static const UINT8  MaxCAFFilterCoringIndex     = 17;    ///< Maximum number of rows for the color matrix.
static const UINT32 CAFMaxROIRegions            = 36;    ///< Maximum number of window configurations for contrast focus
                                                         ///  statistics.
static const UINT8  MaxCAFFIRFilterSize         = 13;    ///< Maximum size of the FIR filter for contrast focus.
static const UINT8  MaxCAFYConfig               = 3;     ///< Maximum array size of Y configurations.
static const UINT8  MaxCAFGammaEntries          = 32;    ///< Maximum number of gamma entries.
static const UINT32 CAFMaxGridRegions           = 2304;  ///< Maximum number of grid regions (48*48).
static const UINT32 CAFMaxGridHorizontalRegions = 48;    ///< Maximum number of horizontal grid regions.
static const UINT32 CAFMaxGridVerticalRegions   = 48;    ///< Maximum number of vertical grid regions.

static const UINT8  FocusDistanceNearIndex       = 0;    ///< Index for near focus distance.
static const UINT8  FocusDistanceOptimalIndex    = 1;    ///< Index for optimal focus distance.
static const UINT8  FocusDistanceFarIndex        = 2;    ///< Index for far focus distance.
static const UINT8  FocusDistanceMaxIndex        = 3;    ///< Maximum index for focus distances.

static const UINT8  BFFilterTypeHorizontal1    = 0;    ///< Index for the Bayer focus horizontal 1 filter.
static const UINT8  BFFilterTypeHorizontal2    = 1;    ///< Index for the Bayer focus horizontal 2 filter.
static const UINT8  BFFilterTypeVertical       = 2;    ///< Index for the Bayer focus vertical filter.
static const UINT8  BFFilterTypeCount          = 3;    ///< Maximum index for Bayer focus filter types.

static const UINT32 MaxSoftwareFilterCoefficientsA      = 15;    ///< Maximum number of A filter coefficients.
static const UINT32 MaxSoftwareFilterCoefficientsB      = 15;    ///< Maximum number of B filter coefficients.
static const UINT32 MaxSoftwareFIRFilterCoefficients    = 15;    ///< Maximum number of FIR filter coefficients.

// ASD static declaration
static const UINT8  ASDPortrait             = 0;     ///< Index for Portrait mode.
static const UINT8  ASDLandscape            = 1;     ///< Index for Landscape mode.
static const UINT8  ASDCount                = 2;     ///< Maximum index for scene detection types.
static const UINT32 MotionVectorMaskMaxSize = 3072;  ///< Maxinum size for the motion mask.

// Face Detection static declaration
static const UINT8  MaxFaceROIs     = 10;   ///< Maximum index for face ROIs.

// Object Detection static declaration
static const UINT8  MaxTrackerROIs  = 1;    ///< Maximum index for tracker ROIs.

// PD static declaration
static const UINT8  PDMaxWindowSize         = 200;          ///< Maximum number PD windows.
static const UINT32 PDLibMaxMapGridCount    = (48 * 48);    ///< Maximum number of PD grids.
static const UINT32 StatsNNSaliencyOut      = 4800;         ///< Maximum number of saliency mapping outputs.
static const UINT8  StatsNNSalientROIMAX    = 5;            ///< Maximum number of ROIs being considered for saliency.

// FOVC static declaration
static const UINT8 MaxFOVCSize  = 10;    ///< Maximum size of the FOV compensation output.

// BE statistics constants
static const UINT32 BETemplateMatrixSize  = 4;      ///< Size of BE template matching matrix.

// BFW statistics constants
static const UINT32 BFWChannelCount       = 5;      ///< Number of Bayer floating window color channels (see #ColorChannel).
static const UINT32 BFWMaxRoiRgnCount     = 16;     ///< Maximum number of Bayer floating window ROI regions.

// SAT Matrix size
static const UINT32 SATMatrixSize  = 9;  ///< Size of the 3x3 spatial alignment transform matrix

// Multi-frame depth-of-field <MFDOF>
static const UINT32 MFDOFMaxFocusTargetCount = 3;   ///< Maximum number of MFDOF focus targets (same as
                                                    ///  FocusDistanceMaxIndex).
static const UINT32 MFDOFMaxDetectableScenes = 32;  ///< Maximum number of MFDOF detectable scenes. (See the Chromatix
                                                    ///  TriggerConditionListType.)

static const UINT MaxNumOfInputExposures      = 4;  ///< Maximum number of input statistics that can be passed to the
                                                    ///  algorithms.
                                                    ///  @newpage

static const UINT32 AFCMaxTemporalHistorySize           = 10;     ///< Max History size for AFD AFC Temporal Context
static const UINT32 AFCNumFutureFrameData               = 3;      ///< Number of Future Frame Data provided by AFC in case of frame drops

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Common statistics data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// @brief Contains the ROI rectangle dimensions.
typedef struct
{
    UINT32    left;      ///< X coordinate of the rectangle.
    UINT32    top;       ///< Y coordinate of the rectangle.
    UINT32    width;     ///< Width of the rectangle.
    UINT32    height;    ///< Height of the rectangle.
} RectangleCoordinate;

/// @brief Contains the dimensions of a normalized ROI rectangle.
typedef struct
{
    FLOAT    left;      ///< X coordinate of the rectangle.
    FLOAT    top;       ///< Y coordinate of the rectangle.
    FLOAT    width;     ///< Width of the rectangle.
    FLOAT    height;    ///< Height of the rectangle.
} NormRectangleCoordinate;

// 3A static definitions

/// @brief Defines the hardware capability of the Bayer Exposure statistics.
struct AECBEStatsCapability
{
    UINT32 regionMinWidth;      ///< Minimum region width.
    UINT32 regionMaxWidth;      ///< Maximum region width.
    UINT32 regionMinHeight;     ///< Minimum region height.
    UINT32 regionMaxHeight;     ///< Maximum region height.
    UINT32 maxHorizRegions;     ///< Maximum number of horizontal regions.
    UINT32 maxVertRegions;      ///< Maximum number of vertical regions.
    UINT32 maxChannelThreshold; ///< Threshold for the maximum number of channels.

    BOOL   isUpdated;           ///< Indicates that the hardware capability has been updated.
                                ///
                                ///  @valuesbul
                                ///  - 0 -- FALSE
                                ///  - 1 -- TRUE @tablebulletend
};

/// @brief Valid exposure setting indices.
typedef enum /** @cond */ statsExposureIndex /** @endcond */
{
    ExposureIndexShort = 0,
    ExposureIndexLong,
    ExposureIndexSafe,
    ExposureIndexSafe2,
    ExposureIndexCount,
}statsExposureIndex;

/// @brief Bayer grid and Bayer exposure configuration output modes.
typedef enum /** @cond */ BGBEOutputMode /** @endcond */
{
    BGBERegular,
    BGBESaturationEnabled,
    BGBEYStatsEnabled,
} BGBEOutputMode;

/// @brief Green data types for a Y statistics use case.
typedef enum /** @cond */ GreenDataType /** @endcond */
{
    Gr,
    Gb,
    GAverage,
} GreenDataType;

/// @brief Describes which channel information is for which channel.
typedef enum
{
    ColorChannelInvalid,
    ColorChannelR,
    ColorChannelGR,
    ColorChannelGB,
    ColorChannelB,
    ColorChannelG,
    ColorChannelY,
    ColorChannelGrGb,
    ColorChannelRGrGbB
} ColorChannel;

/// @brief Bayer floating window statistics to describe which channel information is for which channel.
typedef enum
{
    BFWColorChannelR,
    BFWColorChannelGR,
    BFWColorChannelGB,
    BFWColorChannelB,
    BFWColorChannelY
} BFWColorChannel;

/// @brief Bayer Row Sum statistics used to describe which channel information is for which channel.
typedef enum
{
    BayerRSChannelY,
    BayerRSChannelR,
    BayerRSChannelGr,
    BayerRSChannelGb,
    BayerRSChannelB,
    BayerRSChannelGrGb,       ///< (Gr + Gb) / 2
    BayerRSChannelAverage     ///< (R + Gr + Gb + B) / 4
} BayerRSChannelType;

/// @brief Contains configuration parameters for a Bayer histogram.
typedef struct
{
    RectangleCoordinate  ROI;                                                ///< ROI rectangle from which to get statistics.
    ColorChannel         channel;                                            ///< Selected channel from which to collect
                                                                             ///  statistics.

    BOOL                 uniform;                                            ///< Indicates whether the statistics are uniform.
                                                                             ///
                                                                             ///  @valuesbul
                                                                             ///  - 0 -- FALSE
                                                                             ///  - 1 -- TRUE @tablebulletend

    BOOL                 enable;                                             ///< Indicates whether the Bayer Histogram v16
                                                                             ///  hardware module is enbled.
                                                                             ///
                                                                             ///  @valuesbul
                                                                             ///  - 0 -- FALSE
                                                                             ///  - 1 -- TRUE @tablebulletend
    UINT32               activeROICount;                                     ///< Maximum number of active spatial regions.
    FLOAT                yStatsWeights[RGBChannelCount];                     ///< Array of Y coefficient configurations. Each
                                                                             ///  2x2 pixel has a corresponding Y value.
    UINT32               segmentBaseConfig[SegmentBaseConfigCount];          ///< Array of base values for segments.
    UINT32               segmentSlopeConfig[SegmentSlopeConfigCount];        ///< Array of slope values for segments.
    UINT32               segmentStartBinConfig[SegmentStartBinConfigCount];  ///< Array of start bin positions.
    RectangleCoordinate  spatialROIs[MaxSpatialRegionCount];                 ///< Array of spatial ROI rectangles from which
                                                                             ///  to get statistics.
    FLOAT                spatialROIWeights[RegionWeightCount];               ///< Array region boundary weights for
                                                                             ///  regions 0, 1, 2.
    FLOAT                BLStretchFactor;                                    ///< Stretch factor for IFE statistics before
                                                                             ///  black level subtraction.
} BHistConfig;

/// @brief Contains configuration parameters for Bayer grid and Bayer exposure statistics.
typedef struct
{
    INT32                  horizontalNum;                              ///< Number of horizontal regions.
    INT32                  verticalNum;                                ///< Number of vertical regions.
    RectangleCoordinate    ROI;                                        ///< ROI coordinates to configure.
    UINT32                 channelGainThreshold[ChannelIndexCount];    ///< Maximum gain threshold for each channel.

    UINT32                 outputBitDepth;                             ///< Output bit depths of the statistics.
                                                                       ///
                                                                       ///  This parameter is an option for the statistics
                                                                       ///  algorithm (third-party algorithm) to specify that
                                                                       ///  the statistics passed to it are to have a certain
                                                                       ///  bit depth.

    BGBEOutputMode         outputMode;                                 ///< Statistics output mode: Regular, Saturation
                                                                       ///  Enabled, or Statistics Enabled.

    FLOAT                  YStatsWeights[RGBChannelCount];             ///< Y statistics channel weights indexed by one of
                                                                       ///  the ChannelIndex values.
                                                                       ///
                                                                       ///  This parameter is used when outputMode is set to
                                                                       ///  #BGBEYStatsEnabled.

    GreenDataType          greenType;                                  ///< Option to pick the GR, GB, or G average
                                                                       /// (GR + GB >> 1).
    UINT32                 regionHeight;                               ///< Height of each statistics subgrid region.
    UINT32                 regionWidth;                                ///< Width of each statistics subgrid region.

    BOOL                   isStripeValid;                              ///< For Dual IFE, indicates whether the left or right
                                                                       ///  stripe is valid,based on the calculated output from
                                                                       ///  the striping library.
                                                                       ///
                                                                       ///  @valuesbul
                                                                       ///  - 0 -- FALSE
                                                                       ///  - 1 -- TRUE @tablebulletend

    BOOL                   enableQuadSync;                             ///< Indicates whether quad synchronization is enabled.
                                                                       ///
                                                                       ///  @valuesbul
                                                                       ///  - 0 -- FALSE
                                                                       ///  - 1 -- TRUE @tablebulletend

    UINT32                 channelGainThresholdMAXY;                   ///< Maximum gain threshold for the Y channel.

    FLOAT                  BLStretchFactor;                            ///< Stretch factor for IFE statistics before black
                                                                       ///  level subtraction.
    UINT64                 requestID;                                  ///< Unique Request ID of the frame being processed.
    AECBEStatsCapability   capability;                                 ///< Hardware capability of the AEC Bayer Exposure.
    BOOL                   updated;                                    ///< Indicate if the BEBGConfig was updated in this frame
} BGBEConfig;

/// @brief Image histogram options for selecting the input of the green channel.
typedef enum /** @cond */ IHistChannelSelection /** @endcond */
{
    IHistYCCChannelY,
    IHistYCCChannelCb,
    IHistYCCChannelCr,
} IHistChannelSelection;

/// @brief Configuration parameters for an image histogram.
typedef struct
{
    RectangleCoordinate     ROI;                ///< ROI rectangle from which to get statistics.

    IHistChannelSelection   channelYCC;         ///< Selected YCC channel.
                                                ///
                                                ///  @valuesbul
                                                ///  - 0 -- Luma (Y)
                                                ///  - 1 -- Chroma blue (Cb)
                                                ///  - 2 -- Chroma red (Cr) @tablebulletend

    UINT32                  maxPixelSumPerBin;  ///< Maximum number of histogram pixels represented per bin.
                                                ///
                                                ///  Histogram pixels are the pixels considered by the histogram. If the image
                                                ///  data is concentrated in only a few bins, the output can be saturated.
                                                ///
                                                ///  To obtain more meaningful values and limit or avoid saturation, this
                                                ///  parameter shifts the output data to determine the number of bits that
                                                ///  will fit into the output bin size. If this parameter is set to 0, the
                                                ///  Image Histogram module default value is used.
} IHistStatsConfig;

/// @brief Configuration for programming IFE column sum statistics.
typedef struct
{
    UINT32  statsHNum;                      ///< Total number of horizontal rows.
    UINT32  statsVNum;                      ///< Total number of vertical columns.
    UINT32  statsRgnWidth;                  ///< Width of the region.
    UINT32  statsRgnHeight;                 ///< Height of the region.
    UINT32  statsHOffset;                   ///< ROI horizontal offset for the region.
    UINT32  statsVOffset;                   ///< ROI vertical offset for the region.
} CSStatsConfig;

/// @brief Options for selecting the input of the green channel
typedef enum /** @cond */ HDRBHistGreenChannelSelection /** @endcond */
{
    HDRBHistSelectGR,
    HDRBHistSelectGB,
} HDRBHistGreenChannelSelection;

/// @brief Options for selecting the input pixels.
typedef enum /** @cond */ HDRBHistInputFieldSelect /** @endcond */
{
    HDRBHistInputAll,            ///< All lines: use in non-HDR mode.
    HDRBHistInputLongExposure,   ///< Use in HDR mode: T1, long exposure pixels.
    HDRBHistInputShortExposure,  ///< Use in HDR mode: T2, short exposure pixels.
} HDRBHistInputFieldSelect;

/// @brief HDR Bayer histogram configuration.
typedef struct
{
    RectangleCoordinate             ROI;                   ///< ROI rectangle from which to get statistics.
    HDRBHistGreenChannelSelection   greenChannelInput;     ///< Selected input of the green channel.
    HDRBHistInputFieldSelect        inputFieldSelect;      ///< Input field selection: non-HDR (All) and HDR (T1 or T2) mode.
    FLOAT                           BLStretchFactor;       ///< Stretch factor for IFE stats prior to BLS.
} HDRBHistConfig;

/// @brief Contains the frame rate range.
typedef struct
{
    INT32    minimum;   ///< Minimum FPS value; units are frames per second.
    INT32    maximum;   ///< Maximum FPS value; units are frames per second.
} FPSRange;

/// @brief Preflash states as specified by the AEC algorithm.
typedef enum
{
    PreFlashStateInactive,        ///< Preflash is off or inactive.
    PreFlashStateStart,           ///< Given to the Sensor node to start preflash estimation.
    PreFlashStateTriggerFD,       ///< Given to the Face Detection node to start face detection under preflash.
    PreFlashStateTriggerAF,       ///< Given to the Autofocus node to start autofocus under preflash.
    PreFlashStateTriggerAWB,      ///< Given to the Auto White Balance node to start automatic white balance under preflash.
    PreFlashStateCompleteLED,     ///< Estimation is done with LED. The Sensor node turns off preflash.
    PreFlashStateCompleteNoLED,   ///< Estimation is done but no LED is required. The Sensor node turns off preflash.
    PreFlashStateRER              ///< Red-eye reduction has started.
} PreFlashState;

/// @brief Contains dimension information for the Bayer floating window ROI.
typedef struct
{
    RectangleCoordinate ROI;          ///< ROI coordinates to configure.
    UINT32              regionID;     ///< Identifier for the region.

    BOOL                isValid;      ///< Indicates with the ROI is valid.
                                      ///
                                      ///  @valuesbul
                                      ///  - 0 -- FALSE
                                      ///  - 1 -- TRUE @tablebulletend

    UINT32              outputID;     ///< Identifier of the output used in the BFW Index mode. The software must control the
                                      ///  output order.

    BOOL                needMerge;    ///< Indicates whether this region is to be merged due to a split in dual IFE.
                                      ///
                                      ///  @valuesbul
                                      ///  - 0 -- FALSE
                                      ///  - 1 -- TRUE @tablebulletend
} BFWStatsROIDimensionParams;

/// @brief Contains configuration data for the Bayer floating window ROI.
typedef struct
{
    BFWStatsROIDimensionParams  BFWStatsROIDimension[BFWMaxRoiRgnCount];  ///< Array of BFW ROI configurations.
    UINT32                      numBFWStatsROI;                           ///< Number of regions in the array.
    FLOAT                       BLStretchFactor;                          ///< Stretch factor for IFE statistics before black
                                                                          ///  level subtraction.
    UINT64                      requestID;                                ///< Unique request ID of the frame being processed.
}BFWStatsROIConfigType;

/// @brief Contains configuration data for the black level.
typedef struct
{
    BOOL        enable;                ///< Indicates whether black level configuration is enabled.
                                       ///
                                       ///  @valuesbul
                                       ///  - 0 -- FALSE
                                       ///  - 1 -- TRUE @tablebulletend

    INT32       blackLevelSub;         ///< Black level offset to be subtracted.
} BFWStatsBlackLevelConfig;

/// @brief Contains configuration parameters for the Bayer floating window.
typedef struct
{
    UINT32                   channelGainHiThreshold[BFWChannelCount];  ///< Maximum gain threshold for each channel.
    INT32                    channelGainLoThreshold[BFWChannelCount];  ///< Minimum gain threshold for each channel.
    FLOAT                    YStatsWeights[RGBChannelCount];           ///< Array of Y channel weights indexed by one of.
    BFWStatsROIConfigType    BFWStatsROIConfig;                        ///< Configuration of the BFW ROI.
    BFWStatsBlackLevelConfig BFWBlackLevelConfig;                      ///< Configuration of the BFW black level.

    BOOL                     enableQuadSync;                           ///< Indicates whether quad synchronization is enabled.
                                                                       ///
                                                                       ///  @valuesbul
                                                                       ///  - 0 -- FALSE
                                                                       ///  - 1 -- TRUE @tablebulletend
} BFWStatsConfigParams;

/// @brief Calibration flash states as decided by the AEC algorithm.
typedef enum
{
    CalibrationFlashReady,               ///< Calibration flash is off or inactive.
    CalibrationFlashCollecting,          ///< Given to the Sensor node to start the flash calibration sequence.
    CalibrationPartialComplete,          ///< One of the measurements is done; the Sensor node turns off the flash calibration.
    CalibrationFlashComplete             ///< Estimation is done, and the Sensor node turns off the flash calibration.
} CalibrationFlashState;

/// @brief Types of snapshots.
typedef enum
{
    SnapshotTypeNormal,
    SnapshotTypeFlash,
    SnapshotTypeLLS,
    SnapshotTypeQLL
} SnapshotTypes;

/// @brief AEC state on a touch EV event.
typedef enum
{
    AECTouchEVTypeInactive,
    AECTouchEVTypeConverging,
    AECTouchEVTypeSettled,
    AECTouchEVTypeSceneChange
} AECTouchEVType;

/// @brief Precapture trigger states as determined by the AEC algorithm.
typedef enum
{
    PrecapTriggerIdle,     ///< Trigger is idle.
    PrecapTriggerStart,    ///< Precapture metering sequence will be started by the camera device.
    PrecapTriggerCancel    ///< Camera device will cancel any currently active or computed precapture metering sequence.
} PrecapTriggers;

/// @brief Types of input statistics exposures.
enum AlgoInputExposureType
{
    AlgoInputExposureInvalid = -1,                          ///< Exposure statistics are invalid.
    AlgoInputExposureDefault,                               ///< Indicates that the default exposure is the same as the short
                                                            ///  exposure in a non-HDR use case.
    AlgoInputExposureShort   = AlgoInputExposureDefault,    ///< Represents the short exposure statistics. The default exposure
                                                            ///  is the same as short.
    AlgoInputExposureLong,                                  ///< Represents the long exposure statistics.
    AlgoInputExposureSafe,                                  ///< Represents the safe exposure statistics.
    AlgoInputExposureMerged,                                ///< Represents the merged exposure statistics from the IFE when
                                                            ///  the SFE is enabled.
};

/// @brief Types of exposures the AEC outputs to program the sensor.
enum  AlgoOutputExposureType
{
    AlgoOutputShortExposure = ExposureIndexShort,
    AlgoOutputLongExposure  = ExposureIndexLong,
    AlgoOutputSafeExposure  = ExposureIndexSafe,
    AlgoOutputSafeExposure2 = ExposureIndexSafe2,
    AlgoOutputExposureCount = ExposureIndexCount,
};

/// @brief Scene analyzer types as determined by the AEC algorithm.
typedef enum
{
    AECAlgoSAOutoutMTF = 0,
    AECAlgoSAOutoutFlat,
    AECAlgoSAOutoutFileScanMode,
    AECAlgoSAOutoutMultipleDepth,
    AECAlgoSAOutoutISO12233,
    AECAlgoSAOutputCount,
    AECAlgoSAOutoutMax           = 0x7FFFFFFF
} AECSceneAnalyzer;

/// @brief Contains the AEC weighted regions.
typedef struct
{
    INT32  left;      ///< Left coordinate of the region.
    INT32  top;       ///< Top coordinate of the region.
    INT32  width;     ///< Width of the region, where [left + width - 1] points to the right-most pixel in the region.
    INT32  height;    ///< Height of the region, where[top + height - 1] points to the bottom-most pixel in the region.
    INT32  weight;    ///< Region weight. This value must be between 0 and 1000, where 0 is ignored.
} AECRegion;

/// @brief Configuration parameters for top-level AEC statistics.
typedef struct
{
    BGBEConfig            BGConfig;                            ///< Configure programming of Bayer grid statistics.
    BGBEConfig            BEConfig;                            ///< Configure programming of Bayer grid Bayer exposure
                                                               ///  statistics.
    BHistConfig           AECBHistogramConfig;                 ///< Configure programming of AEC Bayer histogram statistics.
    HDRBHistConfig        HDRBHistConfig;                      ///< Configure programming of HDR Bayer histogram statistics.
    BGBEConfig            TintlessBGConfig;                    ///< Configure programming of tintless Bayer grid statistics.
    BGBEConfig            ALSCBGConfig;                        ///< Configure programming of ALSC Bayer grid statistics.
    BHistConfig           SFEBHistConfig[ExposureIndexCount];  ///< Array of Bayer histogram configurations for the Sensor
                                                               ///  Front End.
    BGBEConfig            SFEBEConfig[ExposureIndexCount];     ///< Array of tintless Bayer grid configurations for the Sensor
                                                               ///  Front End.
    BFWStatsConfigParams  BFWConfig;                           ///< Configure programming of the Bayer floating window.
    BHistConfig           GTMBHistogramConfig;                 ///< Configure programming of Bayer histogram statistics for
                                                               ///  Global Tone Mapping.
} AECConfig;

/// @brief Parameters used to control the frame exposure setting for the sensor and ISP.
typedef struct
{
    UINT64  exposureTime;         ///< Exposure time (in nanoseconds) used by the sensor.
    FLOAT   linearGain;           ///< Total gain consumed by the sensor only.
    FLOAT   sensitivity;          ///< Total exposure including exposure time and gain.
    FLOAT   deltaEVFromTarget;    ///< Current exposure delta compared with the specified target.
    FLOAT   predictiveGain;       ///< Digital gain from the predictive convergence algorithm.
    FLOAT   predictiveGainSFE;    ///< Digital gain from the predictive convergence algorithm for
                                  ///  the Sensor Front End.
} AECExposureData;

/// @brief Possible states of the aperture control feature.
typedef enum /** @cond */ ApertureSwitchStateType /** @endcond */
{
    ApertureSwitchIdle          = 0,
    ApertureSwitchStart         = 1,
    ApertureSwitchInProgress    = 2,
    ApertureSwitchCompleted     = 3,
    ApertureSwitchReserved      = 4,
    ApertureSwitchMax           = 0x7FFFFFFF,
} ApertureSwitchStateType;

/// @brief Defines the AEC output with respect to the aperture control feature.
typedef struct
{
    ApertureSwitchStateType apertureStatus;     ///< State of the aperture switch.
                                                ///
                                                ///  @valuesbul
                                                ///  - #ApertureSwitchIdle
                                                ///  - #ApertureSwitchStart
                                                ///  - #ApertureSwitchInProgress
                                                ///  - #ApertureSwitchCompleted @tablebulletend

    FLOAT                   currentFNumber;     ///< Requested F number (aperture).
} AECAlgoApertureData;

/// @brief Valid AEC flash types.
typedef enum
{
    FlashInfoTypeOff,                   ///< Flash is in the off state.
    FlashInfoTypePre,                   ///< Flash is in the preflash state.
    FlashInfoTypeMain,                  ///< Flash in in the mainflash state.
    FlashInfoTypeCalibration,           ///< Flash in the dual-led calibration state.
    FlashInfoTypeMax = 0x7FFFFFFF       ///< Indicates the last item in the defines.
} AECFlashInfoType;

/// @brief Defines the flags for skipping statistics parsing.
struct AECSkipStatsParser
{
    BOOL isSkipHDRBEStatsParse;    ///< Indicates whether to skip HDR Bayer exposure statistics parsing.
                                   ///
                                   ///  @valuesbul
                                   ///  - 0 -- FALSE
                                   ///  - 1 -- TRUE @tablebulletend

    BOOL isSkipHDRBHistStatsParse; ///< Indicates whether to skip HDR Bayer histogram statistics parsing.
                                   ///
                                   ///  @valuesbul
                                   ///  - 0 -- FALSE
                                   ///  - 1 -- TRUE @tablebulletend

    BOOL isSkipBHistStatsParse;    ///< Indicates whether to skip Bayer histogram statistics parsing.
                                   ///
                                   ///  @valuesbul
                                   ///  - 0 -- FALSE
                                   ///  - 1 -- TRUE @tablebulletend

    BOOL isSkipIHistStatsParse;    ///< Indicates whether to skip image histogram statistics parsing.
                                   ///
                                   ///  @valuesbul
                                   ///  - 0 -- FALSE
                                   ///  - 1 -- TRUE @tablebulletend
};

/// @brief Contains AEC output data for the current frame.
typedef struct
{
    // Internal Member Variables
    PrecapTriggers  AECPrecaptureTrigger;                   ///< Precapture trigger state consumed by the HAL.
    PreFlashState   AECPreFlashState;                       ///< Preflash state from the AEC.
    BOOL            AECSettled;                             ///< Indicates whether the AEC is settled.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    VOID*           pCustomData;                            ///< Pointer to the custom data passed from the algorithm.
    VOID*           pDebugData;                             ///< Pointer to the debug data passed from the algorithm.
    AECExposureData exposureInfo[AlgoOutputExposureCount];  ///< Array of exposure information consumed by the sensor, ISP, and
                                                            ///  HAL.
    UINT32          ISOValue;                               ///< Exposure value in ISO standard format.
    BOOL            LEDAFRequired;                          ///< Indicates whether the LED is required to assist with
                                                            ///  autofocus.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    UINT32          LEDCurrents[LEDSettingCount];           ///< LED currents for the flash driver.
    FLOAT           luxIndex;                               ///< Indicates the scene brightness.
    SnapshotTypes   snapshotIndicator;                      ///< Type of snapshot.
    AECTouchEVType  touchEVIndicator;                       ///< Status of touch EV.
    UINT64          frameDuration;                          ///< Indicates the length of the frame (in milliseconds).

    // Fields mainly required for EXIF here
    UINT16          meteringMode;                           ///< Indicates how the exposure was determined: center weighted or
                                                            ///  spot metering.

#ifndef DOXYGEN_SHOULD_SKIP_THIS
    /* ??NOTE - check with Vidya whether this is to be deleted */
    UINT16          exposureProgram;                        ///< Exposure Program
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

    FLOAT           brightnessValue;                        ///< Indicates the darkness or brightness of the scene.
    UINT16          sceneType;                              ///< Scene type or mode (see Section @xref{AwbSceneModes}).
    UINT16          exposureMode;                           ///< Indicates whether the exposure is manual or automatic.
    FLOAT           frameLuma;                              ///< Average brightness of the frame.
    FLOAT           ADRCGain;                               ///< Gain compensation when ADRC is enabled.
                                                            ///  @newpagetable
} AECFrameInformation;

/// @brief Configuration parameters for Y histogram stretch.
typedef struct
{
    BOOL                        enable;             ///< Indicates whether the ISP is enabled. This flag is set by the
                                                    ///  algorithm.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend

    FLOAT                       clamp;              ///< Dark clamp value for the histogram stretch.
    FLOAT                       scaling;            ///< Scaling value for the histogram stretch.
} AECYHistStretchData;

/// @brief Contains the hardware capabilities for a Bayer Floating Window.
typedef struct
{
    BOOL                        isBFWHwAvailable;   ///< Indicates whether the BFW hardware is available on the current target.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend
} BFWHWCapability;

///< @brief Contains the IFE stats hardware capabilities.
typedef struct
{
    UINT32 AECBEStatsWidth;                           ///< AEC BE stats width
    UINT32 AECBEStatsHeight;                          ///< AEC BE stats height
    UINT32 AWBBGStatsWidth;                           ///< AWB BG stats width
    UINT32 AWBBGStatsHeight;                          ///< AWB BG stats height
    UINT32 BayerRS16StatsWidth;                       ///< Bayer RS16 stats width
    UINT32 BayerRS16StatsHeight;                      ///< Bayer RS16 stats height
    UINT32 BFHistStatsWidth;                          ///< BF stats width
    UINT32 BFHistStatsHeight;                         ///< BF stats height
    UINT32 BFWStatsWidth;                             ///< BFW stats width
    UINT32 BFWStatsRegion;                            ///< BFW stats height
    UINT32 BFStats25Width;                            ///< BFW 25 stats Width
    UINT32 BFStats25Height;                           ///< BFW 25 stats height
    UINT32 BHistStatsWidth;                           ///< BHist stats width
    UINT32 BHistStatsHeight;                          ///< BHist stats height
    UINT32 CAFStatsWidth;                             ///< CFA stats width
    UINT32 CAFStatsHeight;                            ///< CFA stats height
    UINT32 CSStatsWidth;                              ///< CS stats width
    UINT32 CSStatsHeight;                             ///< CS stats height
    UINT32 HDRBEStatsWidth;                           ///< HDR BE stats width
    UINT32 HDRBEStatsHeight;                          ///< HDR BE stats height
    UINT32 HDRBHistStatsWidth;                        ///< HDR BHist stats width
    UINT32 HDRBHistStatsHeight;                       ///< HDR BHist stats height
    UINT32 IHistStatsWidth;                           ///< IHist stats width
    UINT32 IHistStatsHeight;                          ///< IHist stats height
    UINT32 TintlessBGStatsWidth;                      ///< Tintless BG stats width
    UINT32 TintlessBGStatsHeight;                     ///< Tintless BG stats height
    UINT32 RSStatsWidth;                              ///< RS stats width
    UINT32 RSStatsHeight;                             ///< RS stats height
    UINT32 LTMDCStatsWidth;                           ///< LTMDC stats width
    UINT32 LTMDCStatsHeight;                          ///< LTMDC stats height
    UINT32 IFELiteBG16StatsWidth;                     ///< IFE Lite BG stats width
    UINT32 IFELiteBG16StatsHeight;                    ///< IFE Lite BG stats height
    UINT32 ALSCBGStatsWidth;                          ///< ALSC BG stats width
    UINT32 ALSCBGStatsHeight;                         ///< ALSC BG stats height
} IFEStatsHWCapability;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AWB output data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// @brief Contains gains for the AWB algorithm.
typedef struct
{
    FLOAT   rGain;    ///< Red gains.
    FLOAT   gGain;    ///< Green gains.
    FLOAT   bGain;    ///< Blue gains.
} AWBGainParams;

/// @brief Contains Bayer grid and Bayer exposure statistics for the AWB algorithm.
typedef struct
{
    BGBEConfig            BGConfig;                 ///< Bayer grid configuration parameters
} AWBConfig;

/// @brief Format of the color correction matrix.
typedef struct
{
    BOOL        isCCMOverrideEnabled;               ///< Indicates whether the CCM override is enabled.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - 0 -- FALSE
                                                    ///  - 1 -- TRUE @tablebulletend

    FLOAT       CCM[AWBNumCCMRows][AWBNumCCMCols];  ///< Color correction matrix.
    FLOAT       CCMOffset[AWBNumCCMRows];           ///< Offsets for the color correction matrix.
}AWBCCMParams;

/// @brief Format of the decision data for the AWB algorithm.
typedef struct
{
    FLOAT   rg;              ///< Red-green coordinate for an AWB decision point.
    FLOAT   bg;              ///< Blue-green coordinate for an AWB decision point.
} AWBDecisionPoint;

/// @brief AWB color temperature decision for an area in the field of view.
typedef struct
{
    AWBDecisionPoint    point[AWBAlgoDecisionMax];                      ///< AWB decision point in the RG and Bayer grid
                                                                        ///  coordinates.
    FLOAT               correlatedColorTemperature[AWBAlgoDecisionMax]; ///< Correlated color temperature (in degrees Kelvin).
    UINT32              decisionCount;                                  ///< Number of AWB decisions.
} AWBAlgoDecisionInformation;

/// @brief AWB face orientation types.
typedef enum
{
    StatsFaceOrientationInvalid,
    StatsFaceOrientationUp,
    StatsFaceOrientationRight,
    StatsFaceOrientationDown,
    StatsFaceOrientationLeft,
    StatsFaceOrientationTypeMax
} StatsFaceOrientation;

/// @brief AWB-adjusted face ROI when a blocking case is detected.
typedef struct
{
    BOOL                  isFaceBlocked;    ///< Indicates whether the face is blocked.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE
                                            ///  - 1 -- TRUE @tablebulletend

    StatsFaceOrientation  faceOrientation;  ///< Orientation of the adjusted face ROI.
} AWBFaceSAAdjustedROI;

/// @brief Contains information about an AWB frame.
typedef struct
{
    AWBGainParams        AWBGains;           ///< Per-channel gains (red, green, blue).
    UINT32               colorTemperature;   ///< Warmth or coolness of the light source in a scene (in degrees Kelvin).
    AWBFaceSAAdjustedROI faceSAAdjustedROI;  ///< Face ROI when a blocking case is detected.
} AWBFrameInfo;

/// @brief Output confidence parameters for the AWB Scene Analyzer module.
typedef struct
{
    FLOAT SAConf;            ///< Output confidence value.
    CHAR* pSADescription;    ///< Pointer to the description of the Scene Analyzer module.
} AWBSAConfInfo;

/// @brief AWB face color tone decision.
typedef struct
{
    UINT32 faceNum;                ///< Num of faces that have valid face tone decisions.
    INT32  faceID[MaxFaceROIs];    ///< Face ID.
    FLOAT  faceTone[MaxFaceROIs];  ///< Face tone decision.
} AWBFaceToneInfo;

/// @brief Output confidence parameters for the AEC Scene Analyzer module.
typedef struct
{
    FLOAT            SAConf;  ///< Output confidence value.
    AECSceneAnalyzer SAType;  ///< Type of Scene Analyzer for Autofocus bracketing.
} AECSAConfInfo;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AF output data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// @brief Autofocus status types.
typedef enum
{
    AFStatusInvalid     = -1,
    AFStatusInitialized = 0,
    AFStatusFocusing,
    AFStatusFocused,
    AFStatusNotFocused,
    AFStatusTypeMax     = 0x7FFFFFFF
} AFStatus;

/// @brief Information parameters for an autofocus status.
typedef struct
{
    BOOL        focusDone;                               ///< Indicates whether autofocus is done.
                                                         ///
                                                         ///  @valuesbul
                                                         ///  - 0 -- FALSE
                                                         ///  - 1 -- TRUE @tablebulletend

    AFStatus    status;                                  ///< Current focusing status.
    FLOAT       focusDistance[FocusDistanceMaxIndex];    ///< Distances where an object appears to be in focus (in meters).
} AFStatusParams;

/// @brief Types of Bayer focus channel gains.
typedef enum
{
    BFChannelInvalid    = -1,
    BFChannelSelectG,
    BFChannelSelectY,
    BFChannelSelectMax  = 0x7FFFFFFF,
} BFChannelSelectType;

/// @brief Types of Bayer focus input channels.
typedef enum
{
    BFInputInvalid      = -1,
    BFInputSelectGr,
    BFInputSelectGb,
    BFInputSelectMax    = 0x7FFFFFFF,
} BFInputGSelectType;

/// @brief Bayer focus input configuration parameters.
typedef struct
{
    BOOL                isValid;                 ///< Indicates whether the input configuration is valid.
                                                 ///
                                                 ///  @valuesbul
                                                 ///  - 0 -- FALSE
                                                 ///  - 1 -- TRUE @tablebulletend

    BFChannelSelectType BFChannelSel;            ///< Channel selection configuration.
    BFInputGSelectType  BFInputGSel;             ///< G channel selection configuration.
    FLOAT               YAConfig[MaxYConfig];    ///< Y channel configuration.
} BFInputConfigParams;


#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Type for channel select.
typedef BFChannelSelectType CAFChannelSelectType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

/// @brief Input configuration parameters for contrast autofocus.
typedef struct
{
    CAFChannelSelectType    CAFChannelSel;          ///< Configure channel selection.
    FLOAT                   YAConfig[MaxYConfig];   ///< Array of Y channel configurations.
} CAFInputConfigParams;

/// @brief Configuration parameters for the lookup table.
typedef struct
{
    BOOL    isValid;                        ///< Indicates whether the gamma lookup table is valid or enabled.
                                            ///
                                            ///  @valuesbul
                                            ///  - 0 -- FALSE (disabled)
                                            ///  - 1 -- TRUE (enabled) @tablebulletend

    UINT32  gammaLUT[MaxBFGammaEntries];    ///< Lookup table of gamma entries.
    UINT32  numGammaLUT;                    ///< Number of entries in the gamma lookup table.
} BFGammaLUTConfigType;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Configuration parameters for the gamma lookup table.
typedef BFGammaLUTConfigType CAFGammaLUTConfigType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

/// @brief Configuration parameters for the Bayer focus scalar.
typedef struct
{
    BOOL    isValid;                 ///< Indicates whether the Bayer focus scalar configuration is valid.
                                     ///
                                     ///  @valuesbul
                                     ///  - 0 -- FALSE
                                     ///  - 1 -- TRUE @tablebulletend

    BOOL    BFScaleEnable;           ///< Indicates whether the Bayer focus scalar is enabled.
                                     ///
                                     ///  @valuesbul
                                     ///  - 0 -- FALSE
                                     ///  - 1 -- TRUE @tablebulletend

    INT32   scaleM;                  ///< M scalar value.
    INT32   scaleN;                  ///< N scalar value.
    INT32   pixelOffset;             ///< Pixel offset (see the hardware programming guide).
    INT32   mnInit;                  ///< Initial M and N scaling values (see the hardware programming guide).
    INT32   interpolationResolution; ///< Interpolation resolution (see the hardware programming guide).
    INT32   phaseInit;               ///< Phase initialization (see the hardware programming guide).
    INT32   phaseStep;               ///< Phase step (see the hardware programming guide).
    INT32   inputImageWidth;         ///< Input image width (see the hardware programming guide).
} BFScaleConfigType;

/// @brief Down scaler configuration applied to the input of a vertical FV filter.
typedef struct
{
    UINT    downScaleRatioPower;    ///< Sets the value of the DS input binning factor.
                                    ///
                                    ///  @valuesbul
                                    ///  - 0 -- Bypassed
                                    ///  - 1 -- Binning factor of 2
                                    ///  - 2 -- Binning factor of 4
                                    ///  - 3 -- Binning factor of 8 @tablebulletend
} CAFDownScalerConfig;

/// @brief Defines the intra-frame FOV compensation parameter.
typedef struct
{
    UINT64         timestamp;            ///< Timestamp for the FOVC factor to apply.
    FLOAT          FOVCFactor;           ///< FOV compensation factor.
    FLOAT          focusPosition;        ///< Lens position when focusing.
} FOVCData;

/// @brief Configuration parameters for the FIR filter.
typedef struct
{
    BOOL     enable;                                    ///< Indicates whether FIR filter configuration is enabled.
                                                        ///
                                                        ///  @valuesbul
                                                        ///  - 0 -- FALSE
                                                        ///  - 1 -- TRUE @tablebulletend

    INT32    FIRFilterCoefficients[MaxBFFIRFilterSize]; ///< Array of FIR filter coefficients.
    UINT32   numOfFIRCoefficients;                      ///< Number of filter coefficients in the array.
} BFFIRFilterConfigType;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Configuration parameters for the FIR filter.
typedef  BFFIRFilterConfigType CAFFIRFilterConfigType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

/// @brief Configuration parameters for the BF IIR filter.
typedef struct
{
    BOOL     enable;    ///< Indicates whether the IIR filter is enabled.
                        ///
                        ///  @valuesbul
                        ///  - 0 -- FALSE
                        ///  - 1 -- TRUE @tablebulletend

    FLOAT    b10;       ///< IIR filter coefficient b10 in Q14 format.
    FLOAT    b11;       ///< IIR filter coefficient b11 in Q14 format.
    FLOAT    b12;       ///< IIR filter coefficient b12 in Q14 format.
    FLOAT    a11;       ///< IIR filter coefficient a11 in Q14 format.
    FLOAT    a12;       ///< IIR filter coefficient a12 in Q14 format.
    FLOAT    b20;       ///< IIR filter coefficient b20 in Q14 format.
    FLOAT    b21;       ///< IIR filter coefficient b21 in Q14 format.
    FLOAT    b22;       ///< IIR filter coefficient b22 in Q14 format.
    FLOAT    a21;       ///< IIR filter coefficient a21 in Q14 format.
    FLOAT    a22;       ///< IIR filter coefficient a22 in Q14 format.
    FLOAT    init10;    ///< Initial state 10.
    FLOAT    init11;    ///< Initial state 11.
    FLOAT    init20;    ///< Initial state 20.
    FLOAT    init21;    ///< Initial state 21.
} BFIIRFilterConfigType;

/// @brief Configuration parameters for the CAF IIR filter.
typedef struct
{
    BOOL     enable;    ///< Indicates whether the IIR filter is enabled.
                        ///
                        ///  @valuesbul
                        ///  - 0 -- FALSE
                        ///  - 1 -- TRUE @tablebulletend

    FLOAT    b10;       ///< IIR filter coefficient b10 in Q14 format.
    FLOAT    b11;       ///< IIR filter coefficient b11 in Q14 format.
    FLOAT    a11;       ///< IIR filter coefficient a11 in Q14 format.
    FLOAT    b12;       ///< IIR filter coefficient b12 in Q14 format.
    FLOAT    b20;       ///< IIR filter coefficient b20 in Q14 format.
    FLOAT    a12;       ///< IIR filter coefficient a12 in Q14 format.
    FLOAT    b22;       ///< IIR filter coefficient b22 in Q14 format.
    FLOAT    b21;       ///< IIR filter coefficient b21 in Q14 format.
    FLOAT    a22;       ///< IIR filter coefficient a22 in Q14 format.
    FLOAT    a21;       ///< IIR filter coefficient a21 in Q14 format.
    UINT8    init0;     ///< Initial state 0.
    UINT8    init1;     ///< Initial state 1.
} CAFIIRFilterConfigType;

/// @brief Types of configuration windows.
typedef enum
{
    BFStatsInvalidRegion    = -1,
    BFStatsPrimaryRegion,
    BFStatsSecondaryRegion,
    BFStatsMaxRegion        = 0x7FFFFFFF,
} BFStatsRegionType;

/// @brief Types of region of interest.
typedef enum
{
    BFStatsInvalidROI    = -1,
    BFStatsDefaultROI,
    BFStatsCustomROI,
    BFStatsMaxROI        = 0x7FFFFFFF
} BFStatsROIType;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Types of region of interest.
typedef BFStatsROIType CAFStatsROIType;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

/// @brief Contains Bayer focus ROI dimensions.
typedef struct
{
    BFStatsRegionType   region;       ///< Type of Bayer focus region.
    RectangleCoordinate ROI;          ///< ROI coordinates to configure.
    UINT32              regionNum;    ///< Number of regions.

    BOOL                isValid;      ///< Indicates whether the ROI is valid.
                                      ///
                                      ///  @valuesbul
                                      ///  - 0 -- FALSE
                                      ///  - 1 -- TRUE @tablebulletend

    UINT32              outputID;     ///< Output ID used in Bayer focus v2.5 index mode. The software must be programmed
                                      ///  to control the output order.

    BOOL                needMerge;    ///< Indicates whether this region must be merged due to a split in dual IFE.
                                      ///
                                      ///  @valuesbul
                                      ///  - 0 -- FALSE
                                      ///  - 1 -- TRUE @tablebulletend
} BFStatsROIDimensionParams;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// CAF floating ROI configuration.
typedef BFStatsROIDimensionParams CAFStatsFloatingWindowParams;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

/// @brief Configuration parameters for the Bayer focus fixed window ROI.
typedef struct
{
    UINT32    left;         ///< Left coordinate of the ROI.
    UINT32    top;          ///< Top coordinate of the ROI.
    UINT32    width;        ///< Width of the grid.
    UINT32    height;       ///< Height of the grid.
    UINT32    hGridCount;   ///< Number of horizontal regions.
    UINT32    vGridCount;   ///< Number of vertical regions.
} BFStatsFixedWindowParams;

/// @brief Configuration parameters for the CAF flexible grid ROI.
typedef struct
{
    UINT32    left;                                ///< Left coordinate of the region.
    UINT32    top;                                 ///< Top coordinate of the region.
    UINT32    width[CAFMaxGridHorizontalRegions];  ///< Array of horizontal regions that define the width of the grid.
    UINT32    height[CAFMaxGridVerticalRegions];   ///< Array of vertical regions that define the height of the grid.
    UINT32    hGridCount;                          ///< Number of horizontal regions.
    UINT32    vGridCount;                          ///< Number of vertical regions.
} CAFStatsFlexiGridWindowParams;

/// @brief Configuration parameters for the BAF flexible grid ROI.
typedef struct
{
    UINT32    left;                                ///< Left coordinate of the region.
    UINT32    top;                                 ///< Top coordinate of the region.
    UINT32    width[BAFMaxGridHorizontalRegions];  ///< Array of horizontal regions that define the width of the grid.
    UINT32    height[BAFMaxGridVerticalRegions];   ///< Array of vertical regions that define the height of the grid.
    UINT32    hGridCount;                          ///< Number of horizontal regions.
    UINT32    vGridCount;                          ///< Number of vertical regions.
    UINT32    rgnInd[BAFMaxGridHorizontalRegions]; ///< Array of region indication for grid(applicalbe only for dualTFE).
} BFStatsFlexiWindowParams;

/// @brief Types of supported windows.
typedef enum
{
    BFInvalidWindowConfig     = -1,
    BFFloatingWindow,
    BFFixedWindow,
    BFFlexibleGridWindow,
    BFMaxWindowConfig         = 0x7FFFFFFF
} BFROIWindowConfigType;

/// @brief Types of supported CAF windows.
typedef enum
{
    CAFInvalidWindowConfig     = -1,
    CAFFlexibleGridWindow,
    CAFFloatingWindow,
    CAFMaxWindowConfig         = 0x7FFFFFFF
} CAFROIWindowConfigType;

/// @brief Configuration parameters for the Bayer focus ROI.
typedef struct
{
    BFStatsROIDimensionParams  BFStatsROIDimension[BFMaxROIRegions];    ///< Dimensions of the ROI.
    UINT32                     numBFStatsROIDimension;                  ///< Number of regions.
    BFStatsROIType             BFROIType;                               ///< Type of region.
    UINT32                     lastPrimaryRegion;                       ///< Last primary region.
    BFStatsFixedWindowParams   BFStatsFixedWindowConfig;                ///< Configuration of the fixed window.
    BFROIWindowConfigType      BFWindowConfigType;                      ///< Configuration of the ROI window type.
    BFStatsFlexiWindowParams   BFStatsFlexiWindowConfig;                ///< Configuration of the flexible window.
} BFStatsROIConfigType;

/// @brief Configuration parameters for the contrast focus ROI.
typedef struct
{
    CAFStatsFloatingWindowParams    CAFStatsFloatingWindowConfig[CAFMaxROIRegions]; ///< Array of floating window
                                                                                    ///  configurations.
    UINT32                          numCAFStatsROIDimension;                        ///< Number of regions.
    CAFStatsROIType                 CAFROIType;                                     ///< Type of region.
    UINT32                          lastPrimaryRegion;                              ///< Last primary region.
    CAFStatsFlexiGridWindowParams   CAFStatsFlexiGridWindowConfig;                  ///< Configuration of the flexible grid
                                                                                    ///  window.
    CAFROIWindowConfigType          CAFWindowConfigType;                            ///< Type of CAF window.
} CAFStatsROIConfigType;

/// @brief Configuration parameters for Bayer focus filter cores.
typedef struct
{
    INT32     threshold;                       ///< Threshold for the filter.
    UINT32    core[MaxBFFilterCoringIndex];    ///< Index of filter cores.
    UINT32    gain;                            ///< Bayer focus filter gain.
} BFFilterCoringConfigParams;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Configuration parameters for Bayer focus filter cores.
typedef BFFilterCoringConfigParams CAFFilterCoringConfigParams;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

/// @brief Configuration parameters for the Bayer focus filter.
typedef struct
{
    BOOL                          isValid;                  ///< Indicates whether the filter configuration is valid.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    BOOL                          horizontalScaleEnable;    ///< Indicates whether the horizontal scale is enabled.
                                                            ///
                                                            ///  @valuesbul
                                                            ///  - 0 -- FALSE
                                                            ///  - 1 -- TRUE @tablebulletend

    BFFIRFilterConfigType         BFFIRFilterConfig;        ///< Configuration of the FIR filter.
    BFIIRFilterConfigType         BFIIRFilterConfig;        ///< Configuration of the IIR filter.
    INT32                         shiftBits;                ///< Number of bits to shift (see the hardware programming guide).
    BFFilterCoringConfigParams    BFFilterCoringConfig;     ///< Configuration of Bayer focus coring.
} BFFilterConfigParams;

/// @brief Configuration parameters for a CAF filter's shift.
typedef struct
{
    INT16   postSumShift;   ///< Shift bits after a AF_V/AF_H_1 sum.
    INT16   postFIRShift;   ///< Shift bits after the AF_V/AF_H_1 FIR filter.
                            ///  - A negative value means shift right
                            ///  - A positive value means shift left
} CAFFilterShiftConfigParams;

/// @brief Common configuration for CAF horizontal and vertical filters.
typedef struct
{
    CAFFIRFilterConfigType      CAFFIRFilterConfig;     ///< Configuration of the FIR filter
    CAFIIRFilterConfigType      CAFIIRFilterConfig;     ///< Configuration of the IIR filter.
    CAFFilterShiftConfigParams  CAFFilterShiftConfig;   ///< Number of bits to shift (see the hardware programming guide).
    CAFFilterCoringConfigParams CAFFilterCoringConfig;  ///< Configuration of contrast focus coring.
} CAFFilterConfigParams;

/// @brief Configuration parameters for the black level filter.
typedef struct
{
    BOOL        isValid;                ///< Indicates whether the filter configuration is valid.
                                        ///
                                        ///  @valuesbul
                                        ///  - 0 -- FALSE
                                        ///  - 1 -- TRUE @tablebulletend

    INT32       blackLevelSub;          ///< Threshold to subtract from the pixel value.
    FLOAT       blackLevelMultiplier;   ///< Post subtraction, the multiplication factor to apply to the pixel value.
} BFStatsBlackLevelConfig;

/// @brief Configuration parameters for the black level filter.
typedef struct
{
    BOOL        enable;                 ///< Indicates whether to enable the black level filter.
                                        ///
                                        ///  @valuesbul
                                        ///  - 0 -- FALSE (Disable)
                                        ///  - 1 -- TRUE (Enable) @tablebulletend

    INT32       blackLevelThreshold;    ///< Threshold to subtract from the pixel value.
    FLOAT       blackLevelMultiplier;   ///< Post subtraction, the multiplication factor to apply to the pixel value.
} CAFStatsBlackLevelConfig;

/// @brief Configuration parameters for the floating window.
typedef struct
{
    BFInputConfigParams     BFInputConfig;                        ///< Configure the Bayer focus input.
    BFGammaLUTConfigType    BFGammaLUTConfig;                     ///< Configure the Bayer focus gamma lookup table.
    BFScaleConfigType       BFScaleConfig;                        ///< Configure the Bayer focus scalar.
    BFFilterConfigParams    BFFilterConfig[BFFilterTypeCount];    ///< Array of Bayer focus filter configuration types.
    BFStatsROIConfigType    BFStatsROIConfig;                     ///< Configure the Bayer focus ROI.
    BFStatsBlackLevelConfig BFBlackLevelConfig;                   ///< Configure the black level filter.
} BFStatsConfigParams;

/// @brief Valid filters for contrast focus.
typedef enum
{
    CAFFilterIndexInvalid = -1,
    CAFFilterIndexHorizontal,
    CAFFilterIndexVertical,
    CAFFilterIndexMax,
} CAFFilterIndex;

/// @brief Parameters used to configure the starting point of the active window for initiating AF_H_1 and AF_V kernels in
///        low-power mode.
typedef struct
{
    UINT32  xMin;   ///< First pixel from the left (per line) where the enabled AF_H_1 and AF_V kernels are triggered.
    UINT32  xMax;   ///< Last pixel from the left (per line) where the enabled AF_H_1 and AF_V kernels are stopped.
    UINT32  yMin;   ///< First line from the top where the enabled AF_H_1 and AF_V kernels are triggered.
    UINT32  yMax;   ///< Last line from the top where the enabled AF_H_1 and AF_V kernels are stopped.
} CAFActiveWindow;

/// @brief Configuration parameters for the floating window.
typedef struct
{
    BOOL                        enable;                             ///< Indicates whether CAF is enabled.
                                                                    ///
                                                                    ///  @valuesbul
                                                                    ///  - 0 -- Disabled
                                                                    ///  - 1 -- Enabled @tablebulletend

    CAFInputConfigParams        CAFInputConfig;                     ///< Configure the contrast focus input.
    CAFStatsBlackLevelConfig    CAFBlackLevelConfig;                ///< Configure the contrast level filter.
    CAFGammaLUTConfigType       CAFGammaLUTConfig;                  ///< Configure the contrast focus gamma lookup table.
    CAFDownScalerConfig         CAFDownScalerConfig;                ///< Configure the contrast focus down scalar used for the
                                                                    ///  vertical filter.
    CAFFilterConfigParams       CAFFilterConfig[CAFFilterIndexMax]; ///< Array of configuration types for the contrast focus
                                                                    ///  filter.
    CAFStatsROIConfigType       CAFStatsROIConfig;                  ///< Configure the contrast focus region.
    CAFActiveWindow             CAFActiveWin;                       ///< Configure the starting point of the active window.
} CAFConfig;

/// @brief Configuration parameters for the CAF hardware block.
typedef struct
{
    /// @brief Configuration parameters for the floating window
    union
    {
        CAFConfig V1;
    };
} CAFConfigParams;

/// @brief Valid Bayer focus statistic types.
typedef enum
{
    BFStats = (1 << 0),    ///< Single Bayer focus statistic.
    AFMax   = (1 << 1),    ///< Maximum number of autofocus configuration enumerations.
} AFConfigMask;

/// @brief Configuration parameters for the top-level autofocus statistics.
typedef struct
{
    AFConfigMask           mask;       ///< Configuration mask for autofocus statistics.
    BFStatsConfigParams    BFStats;    ///< Bayer focus statistics for configuration of a floating window.
} AFConfigParams;

/// @brief Valid PDAF window types.
typedef enum
{
    DefaultWindow,
    FixedGridWindow,
    WindowModeMax,
} PDAFSwWindowType;

/// @brief Configuration parameters for a fixed window.
typedef struct
{
    UINT32                 horizontalNum;    ///< Number of horizontal regions.
    UINT32                 verticalNum;      ///< Number of vertical regions.
    RectangleCoordinate    AFFixedWindow;    ///< Fixed window coordinates.
} FixedGridWindowParams;

/// @brief Configuration parameters for the top-level PDAF ROI.
typedef struct
{
    PDAFSwWindowType         PDAFSwWindowMode;            ///< Default or fixed window mode.
    FixedGridWindowParams    fixedGridWindowConfigure;    ///< Fixed grid configuration.
} PDAFConfigureParams;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Lens movement output data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// @brief Contains lens movement information.
typedef struct
{
    UINT32    targetLensPosition;       ///< Target lens position in a step.

    BOOL      useDACValue;              ///< Indicates whether the digital-to-analog convertor is to be used.
                                        ///
                                        ///  @valuesbul
                                        ///  - 0 -- FALSE
                                        ///  - 1 -- TRUE @tablebulletend

    INT32     position[MaxNumOfSteps];  ///< DAC position values.
    UINT8     delay[MaxNumOfSteps];     ///< DAC delay to be applied.
    UINT8     numIntervals;             ///< Number of intervals.
} MoveLensOutput;

/// @brief Types for FOV compensation.
typedef enum
{
    FOVC_disable = 0,                   ///< No FOV compensation is used.
    FOVC,                               ///< Use IPE FOVC.
    IFOVC,                              ///< Use Intra-frame FOVC.
} FOVCType;


/// @brief Compensation factor for the field of view.
typedef struct
{
    UINT8     fieldOfViewCompensationType;     ///< Type of FOView compensation.
    FLOAT     fieldOfViewCompensationFactor;   ///< FOV crop factor that is computed based on the lens position.
    UINT32    numFOVCFactorList;               ///< Number of FOVC factors sent for iFOVC.
    FOVCData  FOVCFactorList[MaxFOVCSize];     ///< Array of iFOVC samples.
} FOVCOutput;

/// @brief Defines the MFDOF capability types.
typedef enum
{
    MFDOFCapInactive = 0,
    MFDOFCap2FrameFusion,
    MFDOFCap3FrameFusion,
    MFDOFCapMaxLimit
} MFDOFCapability;

/// @brief Defines the scene flags for MFDOF.
typedef enum
{
    MFDOFSceneMTFChart            = 0,
    MFDOFSceneFlatPlane           = 1,
    MFDOFSceneFileScan            = 2,
    MFDOFSceneMultiDepth          = 3,
    MFDOFSceneISO12233Chart       = 4,
    MFDOFSceneSkipAecSaDebug      = 5,
    MFDOFSceneDualFace            = 6,
    MFDOFSceneNo07Reserved        = 7,
    MFDOFSceneNo08Reserved        = 8,
    MFDOFSceneNo09Reserved        = 9,
    MFDOFSceneNo10Reserved        = 10,
    MFDOFSceneNo11Reserved        = 11,
    MFDOFSceneNumberOfKnownScenes = 12,
    MFDOFSceneInvalid             = MFDOFMaxDetectableScenes
} MFDOFSceneFlag;

/// @brief Contains information about the MFDOF for a dual-face scene.
typedef struct
{
    UINT32              frameWidth;                                    ///< Size of the ROI-based frame.
    UINT32              frameHeight;                                   ///< Height of the ROI-based frame.
    RectangleCoordinate frontFaceRegion;                               ///< Front face ROI.
    RectangleCoordinate rearFaceRegion;                                ///< Rear face ROI.
    INT32               focusLensPositions[MFDOFMaxFocusTargetCount];  ///< Array of dual face focus positions.
} MFDOFDualFace;

/// @brief Contains information about the MFDOF output.
typedef struct
{
    UINT32        capability;                                        ///< Type of MFDOF capability.
    UINT32        sceneFlag;                                         ///< Type of MFDOF scene flag.
    FLOAT         focusDiopterDistances[MFDOFMaxFocusTargetCount];   ///< Array of focus diopters for a snapshot.
    MFDOFDualFace dualFace;                                          ///< Information for an MFDOF dual-face scene.
} MFDOFOutput;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Software statistics configuration filter data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// @brief Contains software statistic configuration filters.
typedef struct
{
    BOOL                   enable;                                             ///< Indicates whether software statistics are enabled.
                                                                               ///
                                                                               ///  @valuesbul
                                                                               ///  - 0 -- FALSE
                                                                               ///  - 1 -- TRUE @tablebulletend

    RectangleCoordinate    ROI;                                                ///< Region of interest coordinates.
    UINT32                 numCoefficientsA;                                   ///< Number of A coefficients.
    FLOAT                  coefficientsA[MaxSoftwareFilterCoefficientsA];      ///< Array of A coefficient values.
    FLOAT                  numCoefficientsB;                                   ///< Number of B coefficients.
    FLOAT                  coefficientsB[MaxSoftwareFilterCoefficientsB];      ///< Array of B coefficient values.
    FLOAT                  numCoefficientsFIR;                                 ///< Number of FIR coefficients.
    FLOAT                  coefficientsFIR[MaxSoftwareFIRFilterCoefficients];  ///< Array of FIR coefficients values.
    DOUBLE                 minFocusValue;                                      ///< Threshold below which the values are
                                                                               ///  ignored.
} SoftwareStatsFilterConfig;

/// @brief Contains message to AEC for adaptive luma control for AF
typedef struct
{
    BOOL                enabled;                 ///< Whether this feature is enabled
    BOOL                raised;                  ///< Whether roi luma is under AF threshold
    FLOAT               roiLuma;                 ///< Reported ROI luma for this frame (used in AEC convergence)
    FLOAT               roiMinTolerableLuma;     ///< Minimum tolerable ROI luma (tunable, used in AEC convergence)
    UINT32              roiType;                 ///< Current AF roi type
    BOOL                afSettled;               ///< Whether is AF settled (not searching)
} AFLumaAlert;

/// @brief Contains autofocus external output data for frame N.
typedef struct
{
    // Internal Member Variables
    AFStatusParams         focusStatus;                ///< Autofocus status data.
    FLOAT                  focusValue;                 ///< Aggregated focus value computed from the Bayer focus statistics.

    BOOL                   spotLightDetected;          ///< Indicates whether the spotlight is detected.
                                                       ///
                                                       ///  @valuesbul
                                                       ///  - 0 -- FALSE
                                                       ///  - 1 -- TRUE @tablebulletend

    FLOAT                  cropMagnificationFactor;    ///< Factor used to compensate a field of view change due to actuator
                                                       ///  motion during autofocus.
    RectangleCoordinate    ROICoordinate;              ///< Region on interest to use for Bayer focus configuration.
    MoveLensOutput         moveLensOutput;             ///< Lens movement information for the actuator.
    FOVCOutput             fovcOutput;                 ///< Information about the FOV compensation factor.

    BOOL                   isDepthFocus;               ///< In cases where PDAF is used, indicates whether the depth was used
                                                       ///  to focus.
                                                       ///
                                                       ///  @valuesbul
                                                       ///  - 0 -- FALSE
                                                       ///  - 1 -- TRUE @tablebulletend

    UINT64                 requestID;                  ///< Identifier for the processed frame request.
    MFDOFOutput            mfdofOutput;                ///< Output information for the MFDOF snapshot.
    BOOL                   isTouchFocusAssistEnabled;  ///< Indicates whether the touch focus assist is enabled.
    AFLumaAlert            lumaAlert;                  ///< message to AEC for adaptive luma control for AF
} AFFrameInformation;

/// @brief Information about the autofocus output data.
typedef struct
{
    AFStatusParams         status;         ///< Autofocus status data.
    AFConfigParams         statsConfig;    ///< Bayer focus configuration data.
    PDAFConfigureParams    PDAFConfig;     ///< PDAF configuration data.
    AFLumaAlert            lumaAlert;      ///< message to AEC for adaptive luma control for AF
} AFOutput;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PDLib output data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/// @brief Information about the phase detection output data unit.
struct PDDefocusInfo
{
    UINT32  numberOfDefocus;                    ///< Number of defocus values.
    INT32   defocus[PDMaxWindowSize];           ///< Defocus value of the grid.

    UINT32  confidenceLevel[PDMaxWindowSize];   ///< Confidence level of the PD grid.
                                                ///
                                                ///  @values 0 through 1024

    FLOAT   phaseDifference[PDMaxWindowSize];   ///< Phase difference of the grid.
};

/// @brief Information about the PD focus map.
struct PDFocusMapInfo
{
    FLOAT   PDMap[PDLibMaxMapGridCount];                ///< Array of PD mapping values.
    UINT    ConfidenceMap[PDLibMaxMapGridCount];        ///< Array of confidence mapping values.
    INT16   DefocusRangeNearMap[PDLibMaxMapGridCount];  ///< Array of near end values of the defocus range map.
    INT16   DefocusRangeFarMap[PDLibMaxMapGridCount];   ///< Array of far end values of the defocus range map.
    INT32   DefocusMap[PDLibMaxMapGridCount];           ///< Array of defocus mapping values.
    UINT32  horiNumOfRegion;                            ///< Number of horizontal grids.
    UINT32  vertNumOfRegion;                            ///< Number of vertical grids.
    UINT32  widthOfRegion;                              ///< Width of each grid cell.
    UINT32  heightOfRegion;                             ///< Height of each grid cell.
    UINT32  horiRegionOffset;                           ///< Horizontal offset for a grid.
    UINT32  vertRegionOffset;                           ///< Vertical offset for a grid.
};

/// @brief Dynamic ROI extension from the PD Library.
struct PDDynamicROIInfo
{
    BOOL  valid;       ///< Indicates whether this dynamic extension is valid.
                       ///
                       ///  @valuesbul
                       ///  - 0 -- FALSE
                       ///  - 1 -- TRUE @tablebulletend

    FLOAT startX;      ///< Percentage of the starting X coordinate in terms of the image width (0 through 1).
    FLOAT startY;      ///< Percentage of the starting Y coordinate in terms of the image height (0 through 1).
    FLOAT endX;        ///< Percentage of the ending X coordinate in terms of the image width (0 through 1).
    FLOAT endY;        ///< Percentage of the ending Y coordinate in terms of the image height (0 through 1).
};

/// @brief Information about the high-level PD output data.
struct PDOutput
{
    PDDefocusInfo       defocus;            ///< Defocus data of the main grids.
    PDDefocusInfo       peripheralDefocus;  ///< Defocus data of the peripheral grids.
    PDFocusMapInfo      focusMapInfo;       ///< Focus map information from the PD library.
    PDDynamicROIInfo    dynamicROI;         ///< Dynamic ROI extension from the PD library.
};

// @brief Information about the scene types
typedef enum
{
       PANNING_0        = (1 << 30),    /**< Panning is done in 1st axis direction */
       PANNING_1        = (1 << 29),    /**< Panning is done in 2nd axis direction */
       PANNING_2        = (1 << 28),    /**< Panning is done in 3rd axis direction */

       TRIPOD           = 0,            /**< Device is mounted on tripod, without user is touching the device at all */
       HANDHELD         = 1,            /**< Device is hand held, while user is trying to be as steady is possible */
       WALKING          = 2,            /**< Device is held while the person is walking in normal phase*/
       RUNNING          = 3,            /**< Device is held while the person is running (light running)*/

       PANNING          = 4,            /**< Panning is done in at least on one direction */
       STRONG_PANNING   = 5,            /**< Strong panning is done at least on one direction  */

       OTHER            = 6,            /**< All other use-cases */
       GLOBAL_MOTION    = 7,

       NUM_OF_SCENE_TYPES,              /**< Invalid value, must be the last member */
       INVALID = NUM_OF_SCENE_TYPES,

       SCENE_TYPES_MASK = 0x0000FFFF,
       PANNING_MASK     = 0xF0000000
}SceneTypes;

/// @brief Describes the motion vector information.
typedef struct
{
    UINT32    width;                                            ///< Motion vector width.
    UINT32    height;                                           ///< Motion vector height.
    UINT32    MV_mask[MotionVectorMaskMaxSize];                 ///< Array of motion detection results.
    float     MV_level;                                         ///< Motion detection level.
    SceneTypes   motionStatus;                                  ///< Information about motion status
    BOOL         isGlobalMotion;                                ///< Information about global motionstatus
} StatsMotionVectorInfo;

/// @brief Describes the ASD output data.
typedef struct
{
    UINT32                  severity[ASDCount];     ///< Array of severity data.
                                                    ///
                                                    /// @values 0 through 255

    BOOL                    detected[ASDCount];     ///< Indicates whether any scenes are detected.
                                                    ///
                                                    ///  @valuesbul
                                                    ///  - ASDPortrait
                                                    ///  - ASDLandscape @tablebulletend

    StatsMotionVectorInfo   motionVectorInfo;       ///< Information about the motion vector.
    SceneTypes              motionStatus;           ///< Information about motion status.
    BOOL                    isGlobalMotion;         ///< Information about global motion status.
} ASDOutput;

#ifndef DOXYGEN_SHOULD_SKIP_THIS
/* ??NOTE - Check with Vidya about deleting this struct */
typedef struct
{
    UINT32 JpegThumbnailSize_0;
    UINT32 JpegThumbnailSize_1;
} JPEGThumbnailSize;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


/// @brief Contains face ROI data. This structure is used with #FaceROIInformation.
typedef struct
{
    UINT32                 id;           ///< Unique identifier used to track a face in a scene.
    UINT32                 confidence;   ///< Confidence of this face.
    RectangleCoordinate    faceRect;     ///< Detected face rectangle.
    INT32                  rollAngle;    ///< Roll angle of the face.
    INT32                  pose;         ///< Pose angle of the face.
    INT32                  pitch;        ///< Pitch angle of the face.
} FaceROIData;

/// @brief Contains mask ROI data. This structure is used with #MaskROIInformation.
typedef struct
{
    UINT32                 id;           ///< Unique identifier used to track a mask in a scene.
    UINT32                 confidence;   ///< Confidence of this mask.
    RectangleCoordinate    maskRect;     ///< Detected mask rectangle.
} MaskROIData;

/// @brief Information for sparse landmark points.
struct FaceLandmarkData
{
    FDPoint sparseLMPoint[FDFaceSparseLMPointMax]; ///< Array of sparse landmark points.
};

/// @brief Contains face ROI information.
typedef struct
{
    UINT64           requestId;                        ///< Identifier for the processed frame request.
    UINT64           frameNumber;                      ///< Number of the frame that is associated with requestId.
    UINT32           ROICount;                         ///< Total number of regions.
    FaceROIData      unstabilizedROI[MaxFaceROIs];     ///< Array of unstabilized face ROI data.
    FaceROIData      stabilizedROI[MaxFaceROIs];       ///< Array of stabilized face ROI data.
    BOOL             maskValid[MaxFaceROIs];           ///< Indicators of whether a mask is detected.
    MaskROIData      unstabilizedMaskROI[MaxFaceROIs]; ///< Array of unstabilized mask ROI data.
    MaskROIData      stabilizedMaskROI[MaxFaceROIs];   ///< Array of stabilized mask ROI data.
    BOOL             landmarkValid[MaxFaceROIs];       ///< Indicators of whether a sparse landmark is detected.
    FaceLandmarkData faceLandmark[MaxFaceROIs];        ///< Array of landmark information for detected faces.
} FaceROIInformation;

/// @brief Contains upper body ROI data. This structure is used with upper body ROI information.
typedef struct
{
    UINT32                 id;            ///< Unique identifier used to track a head/body in a scene.
    UINT32                 confidence;    ///< Confidence of this head/body.
    RectangleCoordinate    upperBodyRect; ///< Detected head/body rectangle.
    INT32                  rollAngle;     ///< Roll angle of the head/body.
} UpperBodyROIData;

/// @brief Contains upper body ROI information.
typedef struct
{
    UINT64           requestId;                        ///< Identifier for the processed frame request.
    UINT64           frameNumber;                      ///< Number of the frame that is associated with requestId.
    UINT32           ROICount;                         ///< Total number of heads.
    UpperBodyROIData headROI[MaxFaceROIs];             ///< Array of unstabilized head ROI data.
    BOOL             torsoValid[MaxFaceROIs];          ///< Indicators of whether a torso is valid or not.
    UpperBodyROIData torsoROI[MaxFaceROIs];            ///< Array of stabilized torso ROI data.
} UpperBodyROIInformation;

/// @brief Describes the tracker ROI data. This struct is used as part of #TrackerROIInformation.
typedef struct
{
    UINT32                 id;           ///< ID used to track an object in a scene.
    UINT32                 confidence;   ///< Confidence of this object tracker.
    RectangleCoordinate    rect;         ///< Detected object rectangle.
    INT32                  type;         ///< register ROI type
    BOOL                   poseValid;    ///< valid flag for pose
    INT32                  roll;         ///< Roll angle of the roi
    INT32                  yaw;          ///< Pose angle of the roi
    INT32                  pitch;        ///< Pitch angle of the roi
} TrackerROIData;

/// @brief Contains tracker ROI information.
typedef struct
{
    UINT64         requestId;            ///< Identifier for the processed frame request.
    UINT32         ROICount;             ///< Number of ROIs.
    TrackerROIData ROI[MaxTrackerROIs];  ///< Array of tracker ROI data.
} TrackerROIInformation;

/// @brief Parameters that describe the saliency mapping data.
typedef struct
{
    UINT64              requestId;                            ///< Identifier for the processed frame request.
    UINT8               width;                                ///< Width of the saliency map.
    UINT8               height;                               ///< Height of the saliency map.
    UINT8               saliencyMap[StatsNNSaliencyOut];      ///< Array of saliency mapping data.
    UINT8               numROI;                               ///< Number of ROIs in the saliencyROI array.
    RectangleCoordinate saliencyROI[StatsNNSalientROIMAX];    ///< Array of saliency ROIs.
    UINT32              weightROI[StatsNNSalientROIMAX];      ///< Array of priority weights for the ROIs.
} SaliencyMapData;

/// @brief Row sum configuration parameters for AFD statistics.
typedef struct
{
    UINT32             statsHNum;                                              ///< Total number of horizontal rows.
    UINT32             statsVNum;                                              ///< Total number of vertical columns.
    BayerRSChannelType channelSelect;                                          ///< Selected channel for row sum configuration.
    FLOAT              yCoefficient[RGBChannelCount];                          ///< Array of Y statistics channel weights
                                                                               ///  indexed by one of the channel index values.
    UINT32             darkPixelThreshold;                                     ///< Threshold value for dark pixels.
    UINT32             brightPixelThreshold;                                   ///< Threshold value for bright pixels.
    UINT32             segmentBaseConfig[RSSegmentBaseConfigCount];            ///< Array of segment base values.
    UINT32             segmentSlopeConfig[RSSegmentSlopeConfigCount];          ///< Array of segment slope values.
    UINT32             segmentStartBinConfig[RSSegmentStartBinConfigCount];    ///< Array of starting bin positions.

    BOOL               statsRSCSColorConversionEnable;                         ///< Indicates whether conversion from RGB to Y
                                                                               ///  is enabled for the RS/CS input color
                                                                               ///  format.
                                                                               ///
                                                                               ///  @valuesbul
                                                                               ///  - 0 -- Disabled
                                                                               ///  - 1 -- Enabled @tablebulletend
    BOOL              bShiftBitsEnable;                                        ///< Dynamic Shift Bit is enabled
    UINT8             shiftBits;                                               ///< shift bits
} AFDStatsRSConfig;

/// @brief Structure for FCG configuration parameters provided by 3A
typedef struct
{
    BOOL                enable;                                         ///< Enable Flag for Module
    UINT8               gainTableSize;                                  ///< Size of the Gain Table
    FLOAT               gainLUT[GainLUTMaxCount];                       ///< LUT Table
    FLOAT               LUTSampleRate;                                  ///< Sample rate for LUT
    FLOAT               phaseIdxR;                                      ///< Phase Index R
    FLOAT               phaseIdxG;                                      ///< Phase Index G
    FLOAT               phaseIdxB;                                      ///< Phase Index B
    FLOAT               scaleR;                                         ///< Scale for Color R
    FLOAT               scaleG;                                         ///< Scale for Color G
    FLOAT               scaleB;                                         ///< Scale for Color B
    FLOAT               offsetR;                                        ///< Offset for Color R
    FLOAT               offsetG;                                        ///< Offset for Color G
    FLOAT               offsetB;                                        ///< Offset for Color B
    UINT8               interpolationType;                              ///< Type of Interpolation
    UINT8               pixelScreeningEnable;                           ///< Enable flag for Pixel Screening
    UINT8               quadSyncEnable;                                 ///< Enable flag for Quad Sync
    UINT32              darkThreshold1[DarkThreshold1MaxCount];         ///< Lower Threshold 1 for Pixel Screening
    UINT32              darkThreshold2[DarkThreshold2MaxCount];         ///< Lower Threshold 2 for Pixel Screening
    UINT32              brightThreshold1[BrightThreshold1MaxCount];     ///< Upper Threshold 1 for Pixel Screening
    UINT32              brightThreshold2[BrightThreshold2MaxCount];     ///< Upper Threshold 2 for Pixel Screening
    FLOAT               nextFramesPhaseIdxR[AFCNumFutureFrameData];     ///< Phase Index R for Future Frames
    FLOAT               nextFramesPhaseIdxG[AFCNumFutureFrameData];     ///< Phase Index G for Future Frames
    FLOAT               nextFramesPhaseIdxB[AFCNumFutureFrameData];     ///< Phase Index B for Future Frames
    FLOAT               FCGGain;                                        ///< FCG Gain used for Exp Compensation adjustment
} StatsFCGConfig;

/// @brief Structure for Complex Coefficients
typedef struct
{
    FLOAT real;         //<
    FLOAT img;          //<
} StatsComplexCoef;

/// @brief AFC Temporal Parameters
typedef struct
{
    BOOL                        isCorrectionNeeded;                     ///< Is correction Needed
    INT32                       detectedFreq;                           ///< Detected Frequency
    DOUBLE                      timeStamp;                              ///< Time Stamp
    FLOAT                       normalizedCorrelation;                  ///< Normalized Correlation
    FLOAT                       phase;                                  ///< Phase
    FLOAT                       strength;                               ///< Strength
    FLOAT                       exposureTime;                           ///< AEC Exposure Time
    FLOAT                       gain;                                   ///< AEC Gain
} AFCTemporalContext;

/// @brief AFC Temporal Context published by AFD.
typedef struct
{
    BOOL                        isValid;                                      ///< Is Data Valid
    AFCTemporalContext          temporalContext[AFCMaxTemporalHistorySize];   ///< Estimated Paramters and meta data
    UINT16                      historySize;                                  ///< Number of past frames
    FLOAT                       fps;                                          ///< FPS
    UINT32                      frameLengthLines;                             ///< Number of lines per frame (FLL)
    UINT16                      sensorWidth;                                  ///< Sensor Width
    UINT16                      sensorHeight;                                 ///< Sensor Height
} StatsTemporalContext;

/// @brief Defines the FCG State
enum class FCGStateType
{
    FCGDisabled,               ///< FCG HW is disabled.
    FCGEnabledCorrectionON,    ///< FCG HW Enabled and Correction is On
    FCGEnabledCorrectionOFF    ///< FCG HW Enabled but Correction is Off
};

/// @brief Contains information about an AFD frame.
typedef struct
{
    // Internal Member Variables
    UINT32                  detectedAFDMode;        ///< Detected anti-banding mode.
    BOOL                    isFlickerDetected;      ///< Indicates whether flicker detected.
    INT32                   flickerFreq;            ///< Frequency of the flicker detected by the algorithm.
    StatsTemporalContext    statsTemporalContext;   ///< AFC Temporal Context Published by AFD
    FCGStateType            FCGState;               ///< Current FCG State
    UINT64                  minExpTimeToCorrect;    ///< Min exposure time required to correct banding
} AFDFrameInfo;

/// @brief Defines the HDR types.
enum class HDRTypeValues
{
    HDRDisabled,               ///< HDR mode is disabled.
    ISPHDR,                    ///< HDR mode is synthesized by the ISP.
    SensorHDR,                 ///< HDR mode is synthesized by the sensor.
    StaggeredHDR,              ///< HDR mode is staggered HDR.
    MultiframeHDR,             ///< HDR mode is MFHDR.
    QuadCFAHDR,                ///< HDR mode is Quad CFA.
};

/// @brief Defines the Sensor Mode and the number of exposures.
struct SensorHDRConfig
{
    HDRTypeValues   hdrMode;            ///< Type of HDR mode.
    UINT            numOfExposures;     ///< Number of exposures in the sensor mode.
    BOOL            AEBMode;            ///< Indicates whether AEB mode is ON or OFF.
                                        ///
                                        ///  @valuesbul
                                        ///  - 0 -- OFF
                                        ///  - 1 -- ON @tablebulletend
};

/// @brief Contains spatial alignment transfor matrix data.
typedef struct
{
    UINT32 requestID;                       ///< Identifier for the processed frame request.
    UINT32 refCameraId;                     ///< Identifier for the reference camera.
    UINT32 targetCameraId;                  ///< Identifier for the target camera.
    INT32  scale;                           ///< Scale factor.
    INT32  confidence;                      ///< SAT alignment confidence.
    INT32  coarseTransform[SATMatrixSize];  ///< Array of final 3x3 transforms in Q16 format.
}  SATData;

/// @brief Describes the AEC exposure output for other algorithms.
typedef struct
{
    AlgoInputExposureType   exposureType;   ///< Current type of input statistics exposure.
    AECExposureData         exposureData;   ///< AEC exposure output for a specific exposure type.
} AECExposureOutputData;

/// @brief Describes the AEC exposure output based on different exposure types.
typedef struct
{
    UINT8                   exposureCount;                               ///< Number of valid elements in the array.
    AECExposureOutputData   exposureOutputData[MaxNumOfInputExposures];  ///< Array of AEC exposure data based on the exposure
                                                                         ///  types.
} AECExposureOutput;

/// @brief Contains information about autofocus bracketing.
typedef struct
{
    BOOL    isAFBracketingMode;                   ///< Indicates whether AF Bracketing mode is enabled.
                                                  ///
                                                  ///  @valuesbul
                                                  ///  - 0 -- Disabled
                                                  ///  - 1 -- Enabled @tablebulletend

    BOOL    isTilted;                             ///< Indicates whether three-frame fusion is enabled.
                                                  ///
                                                  ///  @valuesbul
                                                  ///  - 0 -- Disabled
                                                  ///  - 1 -- Enabled @tablebulletend

    FLOAT   centerFocusDistance;                  ///< Focus distance from the center.
    FLOAT   cornerFocusDistance1;                 ///< Focus distance from the first corner.
    FLOAT   cornerFocusDistance2;                 ///< Focus distance from the second corner.

    UINT32        sceneFlag;                      ///< Flag that indicates an MFDOF scene (enumeration from XSD).
    MFDOFDualFace dualFace;                       ///< MFDOF dual-face data.
} AFBracketingData;  // } MFDOFData; // to-do: rename to MFDOF

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Describes AFD frame information Data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma pack(pop) // CDK_PACK_SIZE


//  Data structures to help writing to files need specific packing
#pragma pack(push, 1) // File writing helpers

/// @brief Contains information about the 3A and tuning metadata header.
struct DebugDataStartHeader
{
    UINT32  dataSize;               ///< Size of the data (in bytes), including the string marker that precedes this structure.
    // Debug data version information
    UINT8   majorRevision;          ///< Major revision number for debug data.
    UINT8   minorRevision;          ///< Minor revision number for debug data.
    UINT16  patchRevision;          ///< Patch revision number for debug data.

    // software version information
    UINT16  SWMajorRevision;        ///< Major revision number for the software.
    UINT16  SWMinorRevision;        ///< Minor revision number for the software.
    UINT32  SWPatchRevision;        ///< Patch revision number for the software.
    CHAR    featureDesignator[2];   ///< Designator for the software-specific feature that was added.
                                    ///  @newpagetable
};

#pragma pack(pop) // File writing helpers: 1

/** @} */ /* end_addtogroup chi_stats_prop */

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // CHISTATSPROPERTYDEFINES_H
