/*****************************************************************************
 * Copyright (c) 2018, Broadcom Inc.                                         *
 *                                                                           *
 * All Rights Reserved.                                                      *
 *                                                                           *
 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Inc.;             *
 * the contents of this file may not be disclosed to third parties, copied   *
 * or duplicated in any form, in whole or in part, without the prior         *
 * written permission of Broadcom Inc.                                       *
 *****************************************************************************/
/**
 * @file vend_au.h
 * @brief Header file for overlay
 * @Note
 */
#ifndef __VEND_AU_H__
#define __VEND_AU_H__

#ifndef ENABLE_SDK
#include "dsp_sdk_types.h"
#endif

/**
 * Definitions.
 */

/* Memory sizes. Should be tuned according to really need */
#define SS_AUDIO_SCRATCH_MEM_SIZE  (40*1024)  /* SS_AUDIO: 40KB */
#define SS_AUDIO_SCRATCH_MEM_SIZE_INT32 ((SS_AUDIO_SCRATCH_MEM_SIZE+3)>>2)

#define AMBIENT_SCRATCH_MEM_SIZE   (60*1024)  /* AMBIENT: 60KB */
#define AMBIENT_SCRATCH_MEM_SIZE_INT32 ((AMBIENT_SCRATCH_MEM_SIZE+3)>>2)

/* SS_AUDIO definitions */
#define SS_AUDIO_FRAME_SIZE 864
#define SS_AUDIO_CHANNELS 2     /* It must be 2 according to BT_Audio_Decoder_SimpleAPI_simple_profile.pdf */
#define SS_AUDIO_SAMPLING_FREQ_44_KHZ 44100
#define SS_AUDIO_MAX_BITSTREAM_SIZE 484

/* Ambient noise definitions */
#define AMBIENT_BITWIDTH 0     //0:16bit, 1:24bit
#define AMBIENT_PCM_N 256
#define AMBIENT_WARN_DETECT 0

#define SS_LEFT_CHANNEL    0
#define SS_RIGHT_CHANNEL   1
#define SS_JOINT_CHANNEL   2


/**
 *  Scalable codec external parameters
 */
typedef struct
{
    UINT32  *dram_dec_base_addr;   /* pointer to decoder memory in dRAM        */   /* Updated by wrapper        */
    UINT32  dram_dec_size;         /* The maximum size of decoder memory       */   /* Updated by wrapper        */
    INT32   sampling_rate;         /* sampling rate                            */   /* Updated by wrapper        */
    INT16   plc_frame;             /* 1: lost frame, 0: good frame             */   /* Updated by wrapper        */

    void    *dec_inst;              /* decoder instance                         */   /* Updated by entry function */
    UINT8   *in_buf;                /* input buffer                             */   /* Updated by entry function */
    UINT8   *out_buf;               /* output buffer                            */   /* Updated by entry function */
    INT32   frame_cnt;             /* frame counter                            */   /* Updated by entry function */
    INT16   frame_size;            /* number of output samples                 */   /* Updated by entry function */
    INT16   output_samples;        /* number of output samples of latest frame */   /* Updated by entry function */
    INT32   mem_offset;            /* runtime memory size                      */   /* Updated by entry function */
    INT16   channel ;              /* channel information, L(0)/R(1)/Joint(2)  */

    UINT16  trigger_SBM;           /* 1: trigger SBM. It should be cleared after triggered */
    UINT16  target_buffer_depth;   /* target buffer depth of SBM. It should be cleared with trigger_SBM */
    UINT16  current_buffer_depth;  /* current buffer depth of SBM. It should be cleared with trigger_SBM */
}SS_AUDIO_EXT_ST_t;


/**
 *  Ambient noise external parameters
 */
typedef struct
{
    INT32  sampling_rate;    /* sampling rate              */   /* Updated by wrapper        */


    UINT8  *in_buf;           /* input buffer               */   /* Updated by entry function */
    UINT8  *out_buf;          /* output buffer              */   /* Updated by entry function */
    INT32  mem_offset;        /* runtime memory size        */   /* Updated by entry function */
    INT32  frame_cnt;         /* frame counter              */   /* Updated by entry function */
    INT16  ambient_mode;      /* ambient mode               */   /* Updated by entry function */
    INT16  ambient_volume;    /* music volume               */   /* Updated by entry function */
}AMBIENT_EXT_ST_t;




#endif //__VEND_AU_H__
