#ifndef __OMX_COMMON_DEC_COMP_INTF_H__
#define __OMX_COMMON_DEC_COMP_INTF_H__

#include "OMX_Types.h"
#include "x_aud_dec.h"

typedef enum
{
    PCM         = 0,
    ATMOS,
    DTSX,
    FLAC_MQA,
    ALAC_MQA,
    WAV_MQA,
    CDDA_MQA,
}AUD_CODEC_TYPE;

typedef struct _S_WAV
{
    UINT8   wav_decoder_state;
    UINT32  wav_err_type;
    UINT32  wav_frame_numL24;     // for mw time show
    UINT32  wav_frame_numH12;     // for mw time show
    UINT32  wav_samplerate;
    UINT32  wav_bitdepth;
    UINT32  wav_ch_count;
}S_WAV;

typedef struct _S_FLAC
{
    UINT8   flac_decoder_state;
    UINT32  flac_err_type;
    UINT32  flac_frame_numL24;     // for mw time show
    UINT32  flac_frame_numH12;     // for mw time show
    UINT32  flac_samplerate;
    UINT32  flac_bitdepth;
    UINT32  flac_ch_count;
}S_FLAC;

typedef struct _S_ALAC
{
    UINT8   alac_decoder_state;
    UINT32  alac_err_type;
    UINT32  alac_frame_numL24;     // for mw time show
    UINT32  alac_frame_numH12;     // for mw time show
    UINT32  alac_samplerate;
    UINT32  alac_bitdepth;
    UINT32  alac_ch_count;
}S_ALAC;

typedef struct _S_MQA
{
    UINT8   mqa_decoder_state;     //provide info for UI showing MQA flag
    UINT32  mqa_err_type;
    UINT32  mqa_frame_numL24;      //for mw time show
    UINT32  mqa_frame_numH12;      //for mw time show
    UINT32  mqa_orgi_samplerate;   //bitstream orginal sample rate
}S_MQA;

typedef struct _S_FLAC_MQA
{
    S_FLAC  flac_info;
    S_MQA   mqa_info;
}S_FLAC_MQA;

typedef struct _S_ALAC_MQA
{
    S_ALAC  alac_info;
    S_MQA   mqa_info;
}S_ALAC_MQA;

typedef struct _S_WAV_MQA
{
    S_WAV  wav_info;
    S_MQA  mqa_info;
}S_WAV_MQA;


typedef enum
{
    ATMOS_AUDIO_STREAM_TYPE_DD,
    ATMOS_AUDIO_STREAM_TYPE_DDP,
    ATMOS_AUDIO_STREAM_TYPE_DTHD,
    ATMOS_AUDIO_STREAM_TYPE_MAT,
    ATMOS_AUDIO_STREAM_TYPE_NONE
} atmos_stream_type;

typedef struct _S_ATMOS
{
    atmos_stream_type stream_type; /**< Input stream type */
    int object_audio; /**< TRUE if object audio content is decoded, FALSE otherwise */
    int dsurexmod;      /*!< Surround EX mode flag */	
}S_ATMOS;

typedef enum
{
    DTSX_BITSTREAMTYPE_UNKNOWN              = 0x00000000, /**< Unknown Stream type */
    DTSX_BITSTREAMTYPE_DTS_LEGACY           = 0x00000001, /**< 48Khz 5.1 bitstream */
    DTSX_BITSTREAMTYPE_DTS_ES_MATRIX        = 0x00000002, /**< 48Khz 5.1 bitstream with ES */
    DTSX_BITSTREAMTYPE_DTS_ES_DISCRETE      = 0x00000004, /**< 48Khz 6.1 bitstream with or without ES */
    DTSX_BITSTREAMTYPE_DTS_9624             = 0x00000008, /**< 96Khz 5.1 bitstream */
    DTSX_BITSTREAMTYPE_DTS_ES_8CH_DISCRETE  = 0x00000010, /**< 48Khz bitstream with more than 5.1 channels */
    DTSX_BITSTREAMTYPE_DTS_HIRES            = 0x00000020, /**< DTS HD lossy bitstream that has upto 7.1 channels at sampling rates upto 96Khz */
    DTSX_BITSTREAMTYPE_DTS_MA               = 0x00000040, /**< DTS HD bitstream with lossless extensions, that has upto 7.1 channels at sampling rates upto 192Khz */
    DTSX_BITSTREAMTYPE_DTS_LBR              = 0x00000080, /**< DTS LBR ( Low BitRate ) bitstream */
    DTSX_BITSTREAMTYPE_DTS_LOSSLESS         = 0x00000100, /**< Pure lossless DTS HD bitstream */
    DTSX_BITSTREAMTYPE_DTS_UHD              = 0x00000200, /**< DTS UHD lossy-encoded bitstream */
    DTSX_BITSTREAMTYPE_DTS_UHD_MA           = 0x00000400, /**< DTS UHD bitstream with lossless extensions */
    DTSX_BITSTREAMTYPE_DTS_UHD_LOSSLESS     = 0x00000800, /**< Pure lossless DTS UHD bitstream */
    DTSX_BITSTREAMTYPE_DTS_UHD_GAME         = 0x00001000  /**< Standalone DTS UHD bitstream */
} DTSX_BITSTREAMTYPE;

typedef struct _S_DTSX
{
    DTSX_BITSTREAMTYPE stream_type;
    INT32  object_audio;
    INT32   dts_comp_gain;     //provide info for UI showing MQA flag
    UINT32  dts_detail_type;
    UINT32  dts_sample_rate;      //for mw time show
    UINT32  dts_stream_layout;      //for mw time show
    UINT32  dts_bitrate;   //bitstream orginal sample rate

    INT32 dts_dialog_avail;
    INT32 dts_dialog_min;
    INT32 dts_dialog_max;
    INT32 dts_dialog_resolution;
    INT32 dts_analog_compgain;
}S_DTSX;

typedef union _AUD_CODEC_SPECIAL_INFO
{
    S_FLAC_MQA rFlacMQA;
    S_ALAC_MQA rAlacMQA;
    S_WAV_MQA  rWavMQA;
    S_ATMOS    rAtmos;
    S_DTSX     rDTSX;
}AUD_CODEC_SPECIAL_INFO;

#include "u_pbinf.h"

typedef struct _AUD_CH_CFG
{
    UINT32 u4ChannelConfig0;
    UINT32 u4ChannelConfig1;
    UINT32 u4ChannelConfig2;
}AUD_CH_CFG_T;

typedef struct _AUD_DEC_UPDATE_INFO
{
    //AUD_CODEC_TYPE  u1CodecType;
    AUD_DEC_FMT_T u1CodecType;
    UINT32 u4out_sample_Rate;
    UINT8  u1out_bit_depth;
    UINT8  u1out_ch_num;
    UINT8  u1stream_ch_num;
    UINT8  u1stream_ch_mask;
    AUD_CH_CFG_T tDecout_ch_cfg;
    PBINF_A * ptPbInfo;
    AUD_CODEC_SPECIAL_INFO  rCodecInfo;
}AUD_DEC_UPDATE_INFO;

typedef struct _COMMON_DEC_UPDATE_INFO_PARAM
{
    AUD_CODEC_TYPE  u1CodecType;
    UINT32 u4out_sample_Rate;
    UINT8  u1out_bit_depth;
    UINT8  u1out_ch_num;
    AUD_CODEC_SPECIAL_INFO  rCodecInfo;
}COMMON_DEC_UPDATE_INFO_PARAM;

typedef struct _AUD_NOTIFY_INFO
{
    OMX_BOOL            fgDecNotify;
    AUD_DEC_UPDATE_INFO rAudUpdateInfo;
}AUD_NOTIFY_INFO;

typedef enum
{
    FULL_INTERLEAVED_ACCESS_MODE = 0,
    PAIR_INTERLEAVED_ACCESS_MODE,
    BLOCK_ACCESS_MODE,
    UNKNOWN_ACCESS_MODE = 0xFFFFFFFF,
}pcm_access_mode;

typedef enum COMMON_DEC_PARAM_TYPE
{
    CommonDecParam_StartUnused = 0x01000000,
    CommonDecParam_DecActionIntfErrorReason,
    CommonDecParam_DecFrameByteSize,
    CommonDecParam_DecSpeedSupportCapability,
    CommonDecParam_DecBitrate,
    CommonDecParam_DecSamplerate,
    CommonDecParam_DecededFramesNum,
    CommonDecParam_DecededSamplesNum,
    CommonDecParam_ErrorFrameStatistics,
    CommonDecParam_DecChannelLayout,
    CommonDecParam_DecPcmOutputInfo,
    CommonDecParam_QueryDecInfo,
    CommonDecParam_DecOmxInputBufByteSize,
    CommonDecParam_DecOmxOutputBufByteSize,
    CommonDecParam_RawOutputSupportCapability,

    CommonDecParam_SpkConfig,
    CommonDecParam_EOS,
    CommonDecParam_RawOutputSet,
    CommonDecParam_DownSampleSet,
    CommonDecParam_DropSampleSet,
    CommonDecParam_UpSampleSet,
    CommonDecParam_SideinfoSet,

    CommonDecParam_DumpDecInput,
    CommonDecParam_DumpDecOutput,

    CommonDecParam_ParamStrSet,

    CommonDecParam_VendorStartUnused = 0x7F000000,
    CommonDecParam_Max = 0x7FFFFFFF
}COMMON_DEC_PARAM_TYPE;

typedef enum COMMON_DEC_SPEED_TYPE
{
    DROP_FRAME_SPEED_TYPE = 0,
    DROP_SAMPLE_SPEED_TYPE,
    UNKNOWN_SPEED_TYPE = 0xFFFFFFFF,
}COMMON_DEC_SPEED_TYPE;

typedef struct COMMON_DEC_ACTIONINTF_ERROR_REASON_PARAM
{
    OMX_BOOL eErrNeedAbort;
    char ai1ErrReasonStr[128];
}COMMON_DEC_ACTIONINTF_ERROR_REASON_PARAM;

typedef struct COMMON_DEC_FRAME_BYTE_SIZE_PARAM
{
    OMX_BOOL eIsKnownMaxFrameSize;
    OMX_U32 u4DecFrameByteSizeMin;
    OMX_U32 u4DecFrameByteSizeMax;
    OMX_U32 u4DecFrameSizeMinMustDividedBy;
}COMMON_DEC_FRAME_BYTE_SIZE_PARAM;

typedef struct COMMON_DEC_SPEED_CAPABILITY_PARAM
{
    OMX_BOOL eIsDecSupportSpeed;
    COMMON_DEC_SPEED_TYPE eDecSpeedType;
}COMMON_DEC_SPEED_CAPABILITY_PARAM;

typedef struct COMMON_DEC_BIT_RATE_PARAM
{
    OMX_U32 u4DecBitrate;
}COMMON_DEC_BIT_RATE_PARAM;

typedef struct COMMON_DEC_SAMPLE_RATE_PARAM
{
    OMX_U32 u4DecSampleRate;
}COMMON_DEC_SAMPLE_RATE_PARAM;

typedef struct COMMON_DEC_DECODED_FRAMES_NUM_PARAM
{
    OMX_U32 u4DecodedFramesNum;
}COMMON_DEC_DECODED_FRAMES_NUM_PARAM;

typedef struct COMMON_DEC_DECODED_SAMPLES_NUM_PARAM
{
    OMX_U32 u4DecodedSamplesNum;
}COMMON_DEC_DECODED_SAMPLES_NUM_PARAM;

typedef struct COMMON_DEC_ERROR_FRAME_STATISTICS_PARAM
{
    OMX_U32 u4SkipErrFramesNum;
    OMX_U32 u4OutputZeroErrFramesNum;
}COMMON_DEC_ERROR_FRAME_STATISTICS_PARAM;

typedef struct COMMON_DEC_SPK_CONFIG_PARAM
{
    OMX_U32 u4MaxSpkConfig;
    OMX_U32 u4AnalogSpkConfig1;
    OMX_U32 u4AnalogSpkConfig2;
    OMX_U32 u4HdmiSpkConfig1;
    OMX_U32 u4HdmiSpkConfig2;
}COMMON_DEC_SPK_CONFIG_PARAM;

typedef struct COMMON_DEC_RAW_OUTPUT_CAPABILITY_PARAM
{
    OMX_BOOL eIsSupportSdRawOutput;
    OMX_BOOL eIsSupportIEC61937SdRawOutput;
    OMX_BOOL eIsSupportHdRawOutput;
    OMX_BOOL eIsSupportIEC61937HdRawOutput;
}COMMON_DEC_RAW_OUTPUT_CAPABILITY_PARAM;

typedef struct COMMON_DEC_RAW_OUTPUT_PARAM
{
    OMX_BOOL eIsNeedSdRawOutput;
    OMX_BOOL eIsNeedIEC61937SdRawOutput;
    OMX_BOOL eIsNeedHdRawOutput;
    OMX_BOOL eIsNeedIEC61937HdRawOutput;
}COMMON_DEC_RAW_OUTPUT_PARAM;

typedef struct COMMON_DEC_CHANNEL_LAYOUT_PARAM
{
    OMX_U32 u4DecChNum;
    char acDecChLayout[256];    // for example: "L\nR\n"  "L\nR\nLs\nRs\nLFE\n"
    OMX_U32 u4DecChConfig0;    //[15:12/Lsr][11:8/C][7:4/R][3:0/L]
    OMX_U32 u4DecChConfig1;    //[15:12/Rsr][11:8/LFE][7:4/Rs][3:0/Ls]
    OMX_U32 u4DecChConfig2;    //[15:12/Ch12][11:8/Ch11][7:4/Ch10][3:0/Ch9]
    OMX_U32 u4DecChConfig3;    //[15:12/Ch16][11:8/Ch15][7:4/Ch14][3:0/Ch13]
}COMMON_DEC_CHANNEL_LAYOUT_PARAM;

typedef struct COMMON_DEC_PCM_OUTPUT_INFO_PARAM
{
    OMX_U32 u4SampleNumPerChannel;
    OMX_U32 u4BitsPerSample;
    OMX_U32 u4NeedBytesPerSample;
    OMX_U32 u4SampleIsLittleEnd;
    pcm_access_mode eAccessMode;
    OMX_U32 u4ChannelConfig0;    //[15:12/Lsr][11:8/C][7:4/R][3:0/L]
    OMX_U32 u4ChannelConfig1;    //[15:12/Rsr][11:8/LFE][7:4/Rs][3:0/Ls]
    OMX_U32 u4ChannelConfig2;    //[15:12/Ch12][11:8/Ch11][7:4/Ch10][3:0/Ch9]
    OMX_U32 u4ChannelConfig3;    //[15:12/Ch16][11:8/Ch15][7:4/Ch14][3:0/Ch13]
    OMX_U32 u4ChannelNum;
    OMX_U32 u4SampleRate;
}COMMON_DEC_PCM_OUTPUT_INFO_PARAM;

typedef struct COMMON_DEC_INPUT_BUF_SIZE_PARAM    // the omx output buffer size which the decoder needed
{
    OMX_U32 u4DecOmxInputBufByteSize;
}COMMON_DEC_INPUT_BUF_SIZE_PARAM;

typedef struct COMMON_DEC_OUTPUT_BUF_SIZE_PARAM    // the omx output buffer size which the decoder needed
{
    OMX_U32 u4DecOmxOutputBufByteSize;
}COMMON_DEC_OUTPUT_BUF_SIZE_PARAM;

typedef struct COMMON_DEC_DUMP_DECODER_INPUT_PARAM
{
    OMX_STRING pDumpDecInputFileName;
}COMMON_DEC_DUMP_DECODER_INPUT_PARAM;

typedef struct COMMON_DEC_DUMP_DECODER_OUTPUT_PARAM
{
    OMX_STRING pDumpDecOutputFileName;
}COMMON_DEC_DUMP_DECODER_OUTPUT_PARAM;

typedef struct COMMON_DEC_DOWNSAMPLE_PARAM
{
    OMX_U32 u4DecDownSampleRatio;
}COMMON_DEC_DOWNSAMPLE_PARAM;

typedef struct COMMON_DEC_DROPSAMPLE_PARAM
{
    OMX_U32 u4DecDropSampleRatio;
}COMMON_DEC_DROPSAMPLE_PARAM;

typedef struct COMMON_DEC_UPSAMPLE_PARAM
{
    OMX_U32 u4DecUpSampleRatio;
}COMMON_DEC_UPSAMPLE_PARAM;

typedef struct COMMON_DEC_SIDEINFO_PARAM
{
    OMX_U32 u4DecSideinfoCfg;
}COMMON_DEC_SIDEINFO_PARAM;

typedef struct COMMON_DEC_PARAM_STR
{
    INT32 i4Argc;
    CHAR  szArgv[32][100];
}   COMMON_DEC_PARAM_STR_T;

#endif

