#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>



typedef unsigned char UINT8;
typedef char INT8;
typedef unsigned int UINT32;
typedef int INT32;
typedef short INT16;
typedef unsigned short UINT16;


#define OUTPUT_FILE	"AQ.bin"

#include "audioTable.cpp"


AQ_UPDATE_DATA aq_dat;


void initaqdat()
{
	memcpy(aq_dat.prescale_value,m_prescale_value,sizeof(m_prescale_value));
	printf("sizeof(m_prescale_value) =%d\n",sizeof(m_prescale_value));
	
	memcpy(aq_dat.p_cfg_avc,p_cfg_avc,sizeof(p_cfg_avc));
	printf("sizeof(p_cfg_avc) =%d\n",sizeof(p_cfg_avc));
	
	memcpy(aq_dat.g_audio_cfg_se,g_audio_cfg_se,sizeof(g_audio_cfg_se));
	printf("sizeof(g_audio_cfg_se) =%d\n",sizeof(g_audio_cfg_se));

	memcpy(aq_dat.eq_coef,m_eq_coef,sizeof(m_eq_coef));
	printf("sizeof(m_eq_coef) =%d\n",sizeof(m_eq_coef));
	
	memcpy(aq_dat.eq_value,m_eq_value,sizeof(m_eq_value));
	printf("sizeof(m_eq_value) =%d\n",sizeof(m_eq_value));
	
	memcpy(&aq_dat.bass_coef,&m_bass_coef,sizeof(m_bass_coef));
	printf("sizeof(m_bass_coef) =%d\n",sizeof(m_bass_coef));
	
	memcpy(aq_dat.bass_value,m_bass_value,sizeof(m_bass_value));
	printf("sizeof(m_bass_value) =%d\n",sizeof(m_bass_value));
	
	memcpy(aq_dat.treble_coef,m_treble_coef,sizeof(m_treble_coef));
	printf("sizeof(m_treble_coef) =%d\n",sizeof(m_treble_coef));
	
	memcpy(aq_dat.treble_value,m_treble_value,sizeof(m_treble_value));
	printf("sizeof(m_treble_value) =%d\n",sizeof(m_treble_value));

	memcpy(aq_dat.treble2_coef,m_treble2_coef,sizeof(m_treble2_coef));
	printf("sizeof(m_treble2_coef) =%d\n",sizeof(m_treble2_coef));

	memcpy(aq_dat.treble2_value,m_treble2_value,sizeof(m_treble2_value));
	printf("sizeof(m_treble2_value) =%d\n",sizeof(m_treble2_value));

	memcpy(aq_dat.VolumeTable,VolumeTable,sizeof(VolumeTable));
	printf("sizeof(VolumeTable) =%d\n",sizeof(VolumeTable));

	memcpy(aq_dat.p_cfg_avc2,p_cfg_avc2,sizeof(p_cfg_avc2));
	printf("sizeof(p_cfg_avc2) =%d\n",sizeof(p_cfg_avc2));

	memcpy(aq_dat.VolumeTSTable,VolumeTSTable,sizeof(VolumeTSTable));
	printf("sizeof(VolumeTSTable) =%d\n",sizeof(VolumeTSTable));

}

int main(int argc, char *argv[])
{
	FILE *fp = NULL;

	UINT8 comment[4]={'R','T','K','R'};
	INT8	version[4]={'0','0','0','0'};

	int i;
	// Open File
	fp = fopen(OUTPUT_FILE, "wb");
	if (fp == NULL) {
		printf("Open file failed.\n");
		return 0;
	}
	else
	{
		printf("\nOutput File Path: %s ...\n", OUTPUT_FILE);
	}

	if(argc!=2)
		{
			printf("Input parameters error !\n");
			printf("Please enter: ./main  version\n");
			printf("Example: ./main   0001 \n");
			return -1;
		}

	memcpy(version,argv[1],4); 
	
	fwrite(comment,1,4,fp);
	fwrite(&version,1,4,fp);
	
	
	initaqdat();
	
	fwrite((UINT8 *)(&aq_dat),sizeof(INT8),sizeof(aq_dat)/sizeof(INT8),fp);
	printf("\nsizeof(aq_dat) = %d ...\n", sizeof(aq_dat));


	
	fclose(fp);

	printf("ok!\n\n");

	return 0;
}











