Supermodel/Src/Sound/MPEG/layer2.h
Bart Trzynadlowski ddd6fa92ef - Improved 68K interface. Now supports context switching.
- CSoundBoard is not derived from CBus.
- Optimized sound board memory handlers (now using switch statements).
- Added DSB emulation (based on R. Belmont's M1 source code).
- Improved ROM loading: only unique ROMs (those not shared amongst games) are used to identify games. The ROM loader will no longer get confused as easily.
- General cleanup here and there, removed unused Render.h file.
2011-07-31 02:37:31 +00:00

191 lines
6.1 KiB
C

/* this file is a part of amp software, (C) tomislav uzelac 1996,1997
*/
/* layer2.h
* Tomislav Uzelac - cca. Feb 1996
*/
extern int layer2_frame(struct AUDIO_HEADER *header,int cnt);
#ifdef LAYER2
int layer2_frame(struct AUDIO_HEADER *header,int cnt);
float requantize_sample(unsigned short s4,unsigned short nlevels,float c,float d,float factor);
void convert_samplecode(unsigned int samplecode,unsigned int nlevels,unsigned short* sb_sample_buf);
char t_nbal0[27]={4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2};
char t_nbal1[30]={4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2};
char t_nbal2[8] ={4,4,3,3,3,3,3,3};
char t_nbal3[12]={4,4,3,3,3,3,3,3,3,3,3,3};
char t_nbalMPG2[30]={4,4,4,4,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
char t_alloc0[27][16] = { /* table B.2a ISO/IEC 11172-3 */
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,17},
{0,1,2,17},
{0,1,2,17},
{0,1,2,17}};
char t_alloc1[30][16] = { /* table B.2b ISO/IEC 11172-3 */
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
{0,1,3,5,6,7,8,9,10,11,12,13,14,15,16,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,3,4,5,6,17},
{0,1,2,17},
{0,1,2,17},
{0,1,2,17},
{0,1,2,17},
{0,1,2,17},
{0,1,2,17},
{0,1,2,17}};
char t_alloc2[8][16] = { /* table B.2c ISO/IEC 11172-3 */
{0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
{0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127}};
char t_alloc3[12][16] = { /* table B.2d ISO/IEC 11172-3 */
{0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
{0,1,2,4,5,6,7,8,9,10,11,12,13,14,15,16},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127},
{0,1,2,4,5,6,7,127}};
char t_allocMPG2[30][16] = { /* table B.1. ISO/IEC 13818-3 */
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
{0,1,2,4,5,6,7,8},
{0,1,2,4,5,6,7,8},
{0,1,2,4,5,6,7,8},
{0,1,2,4,5,6,7,8},
{0,1,2,4,5,6,7,8},
{0,1,2,4,5,6,7,8},
{0,1,2,4,5,6,7,8},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4},
{0,1,2,4}};
double t_scalefactor[64] = {
2.00000000000000, 1.58740105196820, 1.25992104989487,
1.00000000000000, 0.79370052598410, 0.62996052494744, 0.50000000000000,
0.39685026299205, 0.31498026247372, 0.25000000000000, 0.19842513149602,
0.15749013123686, 0.12500000000000, 0.09921256574801, 0.07874506561843,
0.06250000000000, 0.04960628287401, 0.03937253280921, 0.03125000000000,
0.02480314143700, 0.01968626640461, 0.01562500000000, 0.01240157071850,
0.00984313320230, 0.00781250000000, 0.00620078535925, 0.00492156660115,
0.00390625000000, 0.00310039267963, 0.00246078330058, 0.00195312500000,
0.00155019633981, 0.00123039165029, 0.00097656250000, 0.00077509816991,
0.00061519582514, 0.00048828125000, 0.00038754908495, 0.00030759791257,
0.00024414062500, 0.00019377454248, 0.00015379895629, 0.00012207031250,
0.00009688727124, 0.00007689947814, 0.00006103515625, 0.00004844363562,
0.00003844973907, 0.00003051757813, 0.00002422181781, 0.00001922486954,
0.00001525878906, 0.00001211090890, 0.00000961243477, 0.00000762939453,
0.00000605545445, 0.00000480621738, 0.00000381469727, 0.00000302772723,
0.00000240310869, 0.00000190734863, 0.00000151386361, 0.00000120155435,
1E-20};
double t_c[18] = { 0,
1.33333333333, 1.60000000000, 1.14285714286,
1.77777777777, 1.06666666666, 1.03225806452,
1.01587301587, 1.00787401575, 1.00392156863,
1.00195694716, 1.00097751711, 1.00048851979,
1.00024420024, 1.00012208522, 1.00006103888,
1.00003051851, 1.00001525902 };
double t_d[18] = {0,
0.500000000, 0.500000000, 0.250000000, 0.500000000,
0.125000000, 0.062500000, 0.031250000, 0.015625000,
0.007812500, 0.003906250, 0.001953125, 0.0009765625,
0.00048828125,0.00024414063,0.00012207031,
0.00006103516,0.00003051758 };
float t_dd[18]={ -1.0f, -0.5f, -0.5f, -0.75f, -0.5f, -0.875f, -0.9375f, -0.96875f, -0.984375f,
-0.992188f, -0.996094f, -0.998047f, -0.999023f, -0.999512f, -0.999756f, -0.999878f, -0.999939f,
-0.999969f};
char t_grouping[18]={0,3,5,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0};
/*
int t_nlevels[18] = {0,3,5,7,9,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
*/
int t_nlevels[18] = {0,3,7,7,15,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535};
float t_nli[18]={ 0.0f, 0.5f, 0.25f, 0.25f, 0.125f, 0.125f, 0.0625f, 0.03125f, 0.015625f, 0.0078125f, 0.00390625f,
0.00195313f, 0.000976563f, 0.000488281f, 0.000244141f, 0.00012207f, 6.10352e-05f, 3.05176e-05f};
int t_bpc[18] = {0,5,7,3,10,4,5,6,7,8,9,10,11,12,13,14,15,16};
#endif /* LAYER2 */