

//#ifdef HAVE_CONFIG_H
#include "config.h"
//#endif

#include "audio.h"
#include "ssc_mode.h"
#include "ssc_pulsealloc.h"
#include "ssc_quant.h"

static const short eband5ms[] = {
	/*0  200 400 600 800  1k 1.2 1.4 1.6  2k 2.4 2.8 3.2  4k 4.8 5.6 6.8  8k 9.6 12k 15.6                   */
	0,  1,  2,  3,  4,  5,  6,  7,  8, 10, 12, 14, 16, 20, 24, 28, 34, 40, 48, 60, 72, 84, 102,
};

/* Alternate tuning (partially derived from Vorbis) */
#define BITALLOC_SIZE 11

static const unsigned char band_allocation[] = 
{
	0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0		,0,
	118		,110	,103	,93		,86		,79		,74		,69		,65		,58		,52		,46		,43		,35		,26		,18		,6		,1		,0		,0		,0		,0,
	126		,119	,112	,103	,95		,88		,82		,77		,72		,65		,59		,53		,50		,42		,35		,27		,19		,13		,2		,0		,0		,0,
	134		,127	,120	,113	,103	,96		,90		,84		,78		,71		,65		,60		,57		,50		,43		,37		,30		,24		,17		,10		,4		,0,
	144		,137	,130	,123	,113	,106	,100	,94		,88		,81		,75		,70		,67		,60		,53		,47		,40		,34		,27		,16		,6		,0,
	152		,145	,138	,131	,123	,116	,110	,104	,98		,91		,85		,80		,77		,70		,63		,57		,50		,44		,37		,21		,8		,0,
	162		,155	,148	,141	,133	,126	,120	,114	,111	,108	,101	,95		,90		,87		,80		,73		,67		,60		,54		,47		,11		,0,
	172		,165	,158	,151	,143	,136	,130	,124	,121	,118	,111	,105	,100	,97		,96		,95		,90		,80		,70		,60		,20		,0,
	177		,170	,163	,156	,148	,141	,135	,129	,128	,125	,118	,112	,110	,107	,116	,105	,100	,87		,75		,65		,23		,0,
	182		,180	,173	,166	,158	,151	,145	,139	,138	,135	,132	,130	,130	,130	,130	,128	,120	,110	,98		,85		,28		,0,
	200		,200	,200	,200	,200	,200	,200	,200	,200	,200	,200	,200	,196	,192	,188	,184	,180	,175	,160	,145	,113	,1
};

#include "ssc_tables.h"

#ifndef M_PI
#define M_PI 3.141592653
#endif

AUDIOMode *ssc_custom_mode_create(int Fs, int frame_size, int *error)
{
	if (error)
		*error = SSC_OK;
#if 0
	if(Fs == 44100)
#else
	if(Fs == 44100 || Fs == 48000)
#endif
	{
		return (AUDIOMode*)static_mode_list[0];
	}
	else
	{
		if (error)
			*error = SSC_BAD_ARG;
	}
  
	 return NULL;
}

