
#ifndef MODES_H
#define MODES_H

#include "config.h"

#define SUN_OK                0
#define SUN_BAD_ARG          -1
#define SUN_BUFFER_TOO_SMALL -2
#define SUN_INTERNAL_ERROR   -3
#define SUN_INVALID_PACKET   -4
#define SUN_UNIMPLEMENTED    -5
#define SUN_INVALID_STATE    -6
#define SUN_ALLOC_FAIL       -7

typedef struct
{
	short Fs;
	short overlap;
	short nbEBands;
	const short *eBands;   /**< Definition for each "pseudo-critical band" */
	short nbAllocVectors;

#ifndef OPT_KHW_20191106
#ifndef compute_allocation_opt_hifi3_ZH
	const unsigned char *allocVectors;   /**< Number of bits in each band for several rates */
#else
	const unsigned short *allocVectors;
#endif
#endif
	const short *logN;
	const short *trig;
}SpeechMode;



#ifndef HW_DATA_SIZE_STATIC_MODES
static const short eband5ms[] =
//const short eband5ms[] =
{
	0,1,2,3,4,5,6,7,8,9,10,12,14,16,20,24,30,
};

#ifndef compute_allocation_opt_hifi3_ZH
static const unsigned char band_allocation[] =
{
	0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
	90, 80, 75, 69, 63, 56, 49, 40, 34, 29, 20, 18, 10,  0,  0,  0,
	110,100, 90, 84, 78, 71, 65, 58, 51, 45, 39, 32, 26, 20, 12,  0,
	118,110,103, 93, 86, 80, 75, 70, 65, 59, 53, 47, 40, 31, 23, 15,
	126,119,112,104, 95, 89, 83, 78, 72, 66, 60, 54, 47, 39, 32, 25,
	134,127,120,114,103, 97, 91, 85, 78, 72, 66, 60, 54, 47, 41, 35,
	144,137,130,124,113,107,101, 95, 88, 82, 76, 70, 64, 57, 51, 45,
	152,145,138,132,123,117,111,105, 98, 92, 86, 80, 74, 67, 61, 55,
	162,155,148,142,133,127,121,115,108,102, 96, 90, 84, 77, 71, 65,
	172,165,158,152,143,137,131,125,118,112,106,100, 94, 87, 81, 75,
	200,200,200,200,200,200,200,200,198,193,188,183,178,173,168,163,
};
#else
static const unsigned short band_allocation[] =
//const unsigned short band_allocation[] =
{
	0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
	90, 80, 75, 69, 63, 56, 49, 40, 34, 29, 20, 18, 10,  0,  0,  0,
	110,100, 90, 84, 78, 71, 65, 58, 51, 45, 39, 32, 26, 20, 12,  0,
	118,110,103, 93, 86, 80, 75, 70, 65, 59, 53, 47, 40, 31, 23, 15,
	126,119,112,104, 95, 89, 83, 78, 72, 66, 60, 54, 47, 39, 32, 25,
	134,127,120,114,103, 97, 91, 85, 78, 72, 66, 60, 54, 47, 41, 35,
	144,137,130,124,113,107,101, 95, 88, 82, 76, 70, 64, 57, 51, 45,
	152,145,138,132,123,117,111,105, 98, 92, 86, 80, 74, 67, 61, 55,
	162,155,148,142,133,127,121,115,108,102, 96, 90, 84, 77, 71, 65,
	172,165,158,152,143,137,131,125,118,112,106,100, 94, 87, 81, 75,
	200,200,200,200,200,200,200,200,198,193,188,183,178,173,168,163,
};
#endif


static const short logN400[4] = {0, 8, 16,21, };
// const short logN400[4] = {0, 8, 16,21, };
// short logN400[4];


static const short mdct_twiddles120[122] =
//const short mdct_twiddles120[122] =
{
	32767, 32754, 32717, 32658, 32577, 32473, 32348, 32200, 32029, 31837, 31624, 31388, 31131, 30853, 30553, 30232,
	29891, 29530, 29148, 28746, 28324, 27883, 27423, 26944, 26447, 25931, 25398, 24847, 24279, 23695, 23095, 22478,
	21846, 21199, 20538, 19863, 19174, 18472, 17757, 17030, 16291, 15541, 14781, 14010, 13230, 12441, 11643, 10837,
	10024, 9204, 8377, 7545, 6708, 5866, 5020, 4171, 3319, 2464, 1608, 751, -107,
	107, 965, 1822, 2678, 3532, 4383, 5232, 6077, 6918, 7754, 8585, 9409, 10228, 11039, 11843, 12639,
	13426, 14204, 14972, 15730, 16477, 17213, 17937, 18648, 19347, 20033, 20705, 21363, 22006, 22634, 23246, 23843,
	24423, 24986, 25533, 26062, 26573, 27066, 27540, 27995, 28431, 28848, 29245, 29622, 29979, 30315, 30630, 30924,
	31197, 31449, 31679, 31887, 32074, 32239, 32381, 32501, 32600, 32675, 32729, 32759, 32767,
};

static const SpeechMode mode16000_160_40 =
{
	16000,  /* Fs */
	120,
	16,     /* nbEBands */
	eband5ms,       /* eBands */
	11,     /* nbAllocVectors */
	band_allocation,        /* allocVectors */
	logN400,        /* logN */
	mdct_twiddles120,
};
#else
SpeechMode *ssc_custom_mode_create();

#endif


//SpeechMode *sun_custom_mode_create();

#endif
