📄 layer2.c
字号:
0.049067674327418272, 0.146730474455365439, 0.242980179903257071, 0.336889853392216665,
0.427555093430281974, 0.514102744193224548, 0.595699304492438797, 0.671558954847025991,
0.740951125354968321, 0.803207531480638170, 0.857728610000268121, 0.903989293123441451,
0.941544065183020473, 0.970031253194544640, 0.989176509964781903, 0.998795456205172849,
},{
-1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000,
-1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000,
-1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000,
-1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000,
-1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000,
-1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000,
-1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000,
-1.000000000000000000, -1.000000000000000000, -1.000000000000000000, -1.000000000000000000,
},{
-0.998795456205172405, -0.989176509964781125, -0.970031253194543863, -0.941544065183020917,
-0.903989293123443671, -0.857728610000271008, -0.803207531480646053, -0.740951125354958440,
-0.671558954847020773, -0.595699304492433468, -0.514102744193225436, -0.427555093430283306,
-0.336889853392218552, -0.242980179903259458, -0.146730474455368326, -0.049067674327421699,
0.049067674327417300, 0.146730474455363968, 0.242980179903268950, 0.336889853392214389,
0.427555093430279365, 0.514102744193233874, 0.595699304492435688, 0.671558954847012224,
0.740951125354964990, 0.803207531480643500, 0.857728610000265013, 0.903989293123444892,
0.941544065183018142, 0.970031253194546306, 0.989176509964780681, 0.998795456205171739,
},{
-0.995184726672196929, -0.956940335732208713, -0.881921264348354383, -0.773010453362736771,
-0.634393284163645932, -0.471396736825995866, -0.290284677254461276, -0.098017140329560382,
0.098017140329559896, 0.290284677254460832, 0.471396736826001694, 0.634393284163648263,
0.773010453362738659, 0.881921264348355827, 0.956940335732209157, 0.995184726672196929,
0.995184726672196929, 0.956940335732209380, 0.881921264348356382, 0.773010453362739325,
0.634393284163638049, 0.471396736825989982, 0.290284677254454948, 0.098017140329553804,
-0.098017140329566488, -0.290284677254467161, -0.471396736826001250, -0.634393284163647930,
-0.773010453362738326, -0.881921264348355605, -0.956940335732208935, -0.995184726672196818,
},{
-0.989176509964781014, -0.903989293123443338, -0.740951125354959994, -0.514102744193220884,
-0.242980179903264204, 0.049067674327419986, 0.336889853392217387, 0.595699304492432913,
0.803207531480645942, 0.941544065183019807, 0.998795456205172405, 0.970031253194545306,
0.857728610000270120, 0.671558954847019107, 0.427555093430287303, 0.146730474455358167,
-0.146730474455360582, -0.427555093430276700, -0.671558954847020884, -0.857728610000278668,
-0.970031253194542531, -0.998795456205172183, -0.941544065183016476, -0.803207531480648718,
-0.595699304492430914, -0.336889853392208394, -0.049067674327424635, 0.242980179903266591,
0.514102744193232208, 0.740951125354954443, 0.903989293123444448, 0.989176509964782680,
},{
-0.980785280403230431, -0.831469612302545569, -0.555570233019602622, -0.195090322016126777,
0.195090322016128220, 0.555570233019603843, 0.831469612302545458, 0.980785280403230209,
0.980785280403230986, 0.831469612302543792, 0.555570233019607285, 0.195090322016128803,
-0.195090322016133133, -0.555570233019599069, -0.831469612302546235, -0.980785280403229098,
-0.980785280403230764, -0.831469612302542904, -0.555570233019606063, -0.195090322016141293,
0.195090322016134576, 0.555570233019600290, 0.831469612302539129, 0.980785280403232207,
0.980785280403230431, 0.831469612302550010, 0.555570233019592963, 0.195090322016125917,
-0.195090322016122086, -0.555570233019613391, -0.831469612302547900, -0.980785280403229653,
},{
-0.970031253194543974, -0.740951125354958662, -0.336889853392219552, 0.146730474455360332,
0.595699304492433468, 0.903989293123444115, 0.998795456205172183, 0.857728610000273117,
0.514102744193222105, 0.049067674327416808, -0.427555093430284638, -0.803207531480647607,
-0.989176509964781903, -0.941544065183022916, -0.671558954847021994, -0.242980179903267063,
0.242980179903262289, 0.671558954847018441, 0.941544065183021361, 0.989176509964782569,
0.803207531480650494, 0.427555093430289079, -0.049067674327411916, -0.514102744193217887,
-0.857728610000270564, -0.998795456205172294, -0.903989293123443116, -0.595699304492431692,
-0.146730474455358167, 0.336889853392224992, 0.740951125354963658, 0.970031253194546084,
},{
-0.956940335732208824, -0.634393284163645377, -0.098017140329559174, 0.471396736825996920,
0.881921264348355272, 0.995184726672196707, 0.773010453362737326, 0.290284677254465051,
-0.290284677254464329, -0.773010453362736771, -0.995184726672196596, -0.881921264348357270,
-0.471396736826003859, 0.098017140329565516, 0.634393284163647597, 0.956940335732208935,
0.956940335732209380, 0.634393284163648707, 0.098017140329566974, -0.471396736825989982,
-0.881921264348356604, -0.995184726672198150, -0.773010453362737771, -0.290284677254452117,
0.290284677254456835, 0.773010453362740879, 0.995184726672195930, 0.881921264348354272,
0.471396736825985707, -0.098017140329557703, -0.634393284163652482, -0.956940335732206715,
},{
-0.941544065183020806, -0.514102744193221994, 0.146730474455360582, 0.740951125354958884,
0.998795456205172405, 0.803207531480643944, 0.242980179903261345, -0.427555093430278921,
-0.903989293123442228, -0.970031253194544418, -0.595699304492428139, 0.049067674327418279,
0.671558954847014000, 0.989176509964781236, 0.857728610000274116, 0.336889853392216221,
-0.336889853392218053, -0.857728610000275116, -0.989176509964781014, -0.671558954847023104,
-0.049067674327430505, 0.595699304492441128, 0.970031253194544862, 0.903989293123444448,
0.427555093430289968, -0.242980179903277027, -0.803207531480649273, -0.998795456205172294,
-0.740951125354962437, -0.146730474455372711, 0.514102744193231320, 0.941544065183022472,
},{
-0.923879532511286850, -0.382683432365090559, 0.382683432365089560, 0.923879532511286850,
0.923879532511286405, 0.382683432365088283, -0.382683432365088505, -0.923879532511287849,
-0.923879532511286850, -0.382683432365092613, 0.382683432365090781, 0.923879532511288737,
0.923879532511288626, 0.382683432365090337, -0.382683432365093057, -0.923879532511284296,
-0.923879532511287627, -0.382683432365088061, 0.382683432365082177, 0.923879532511285184,
0.923879532511286738, 0.382683432365085785, -0.382683432365097609, -0.923879532511291623,
-0.923879532511291179, -0.382683432365096665, 0.382683432365086729, 0.923879532511287072,
0.923879532511284851, 0.382683432365081289, -0.382683432365102105, -0.923879532511282631,
},{
-0.903989293123443227, -0.242980179903263482, 0.595699304492433912, 0.998795456205172405,
0.671558954847017442, -0.146730474455363247, -0.857728610000273006, -0.941544065183020029,
-0.336889853392217831, 0.514102744193217887, 0.989176509964780348, 0.740951125354961770,
-0.049067674327414358, -0.803207531480642944, -0.970031253194544751, -0.427555093430284638,
0.427555093430279809, 0.970031253194543419, 0.803207531480637615, 0.049067674327419743,
-0.740951125354967655, -0.989176509964781125, -0.514102744193210337, 0.336889853392219440,
0.941544065183025469, 0.857728610000272118, 0.146730474455375598, -0.671558954847018774,
-0.998795456205173071, -0.595699304492432469, 0.242980179903251381, 0.903989293123444004,
},{
-0.881921264348355050, -0.098017140329560687, 0.773010453362737993, 0.956940335732208380,
0.290284677254464329, -0.634393284163646598, -0.995184726672197151, -0.471396736825996476,
0.471396736825995644, 0.995184726672196263, 0.634393284163641824, -0.290284677254463386,
-0.956940335732208158, -0.773010453362740879, 0.098017140329565017, 0.881921264348355383,
0.881921264348356382, 0.098017140329566974, -0.773010453362739658, -0.956940335732208713,
-0.290284677254465273, 0.634393284163640381, 0.995184726672197928, 0.471396736826009854,
-0.471396736826007301, -0.995184726672197595, -0.634393284163642601, 0.290284677254462442,
0.956940335732207825, 0.773010453362741434, -0.098017140329549904, -0.881921264348361711,
},{
-0.857728610000272118, 0.049067674327417418, 0.903989293123442894, 0.803207531480645720,
-0.146730474455363497, -0.941544065183021250, -0.740951125354958440, 0.242980179903264454,
0.970031253194544085, 0.671558954847013334, -0.336889853392219440, -0.989176509964781903,
-0.595699304492434467, 0.427555093430286859, 0.998795456205172294, 0.514102744193217887,
-0.514102744193219108, -0.998795456205172960, -0.427555093430285527, 0.595699304492435688,
0.989176509964779571, 0.336889853392231431, -0.671558954847014444, -0.970031253194543641,
-0.242980179903256127, 0.740951125354949891, 0.941544065183023138, 0.146730474455362025,
-0.803207531480648718, -0.903989293123437676, -0.049067674327426591, 0.857728610000271119,
},{
-0.831469612302545236, 0.195090322016128942, 0.980785280403230431, 0.555570233019602844,
-0.555570233019600956, -0.980785280403230209, -0.195090322016131218, 0.831469612302545125,
0.831469612302543792, -0.195090322016133605, -0.980785280403229320, -0.555570233019604842,
0.555570233019601956, 0.980785280403229986, 0.195090322016123030, -0.831469612302541905,
-0.831469612302547012, 0.195090322016127860, 0.980785280403228099, 0.555570233019597848,
-0.555570233019597071, -0.980785280403228321, -0.195090322016128803, 0.831469612302538574,
0.831469612302542460, -0.195090322016122086, -0.980785280403232540, -0.555570233019602733,
0.555570233019592186, 0.980785280403229431, 0.195090322016134576, -0.831469612302551120,
},{
-0.803207531480644943, 0.336889853392220218, 0.998795456205172405, 0.242980179903264093,
-0.857728610000273228, -0.740951125354958329, 0.427555093430282196, 0.989176509964781125,
0.146730474455356696, -0.903989293123445004, -0.671558954847016221, 0.514102744193223327,
0.970031253194543752, 0.049067674327418272, -0.941544065183020362, -0.595699304492435244,
0.595699304492430581, 0.941544065183017476, -0.049067674327426598, -0.970031253194545862,
-0.514102744193216221, 0.671558954847022438, 0.903989293123441451, -0.146730474455364940,
-0.989176509964781236, -0.427555093430281086, 0.740951125354959106, 0.857728610000272562,
-0.242980179903261817, -0.998795456205172183, -0.336889853392224048, 0.803207531480641723,
},{
-0.773010453362736882, 0.471396736825997364, 0.956940335732209380, -0.098017140329560992,
-0.995184726672196818, -0.290284677254461276, 0.881921264348356604, 0.634393284163646820,
-0.634393284163640381, -0.881921264348353828, 0.290284677254460111, 0.995184726672196263,
0.098017140329558675, -0.956940335732207936, -0.471396736825992146, 0.773010453362737771,
0.773010453362739325, -0.471396736825989982, -0.956940335732208713, 0.098017140329570387,
0.995184726672195930, 0.290284677254462442, -0.881921264348359379, -0.634393284163653259,
0.634393284163644933, 0.881921264348351053, -0.290284677254452117, -0.995184726672197040,
-0.098017140329552832, 0.956940335732205605, 0.471396736825999529, -0.773010453362741545,
},{
-0.740951125354959106, 0.595699304492432691, 0.857728610000272451, -0.427555093430282973,
-0.941544065183019807, 0.242980179903264926, 0.989176509964781125, -0.049067674327415586,
-0.998795456205172183, -0.146730474455360582, 0.970031253194545529, 0.336889853392222216,
-0.903989293123444670, -0.514102744193226657, 0.803207531480644610, 0.671558954847014777,
-0.671558954847015444, -0.803207531480644055, 0.514102744193215333, 0.903989293123438120,
-0.336889853392223160, -0.970031253194545306, 0.146730474455375626, 0.998795456205172183,
0.049067674327421699, -0.989176509964779127, -0.242980179903257071, 0.941544065183020140,
0.427555093430291744, -0.857728610000276670, -0.595699304492433357, 0.740951125354953222,
}
};
int decode_layer2(LAYER2_HEADER *head, unsigned char *buffer, LAYER2_WORK *work, short *pcm)
{
if(head->channel == 2){
return decode_layer2_stereo(head, buffer, work, pcm);
}else{
return decode_layer2_monaural(head, buffer, work, pcm);
}
}
static int decode_layer2_stereo(LAYER2_HEADER *head, unsigned char *buffer, LAYER2_WORK *work, short *pcm)
{
int i,k,n,m;
int step;
int bits;
int o1,o2;
unsigned int code;
int sb,ch,gr;
int allocation[32][2];
int scfsi[32][2];
int scalefactor[32][2][3];
double sample[12][3][32][2];
double U[1024];
double W[1024];
double s[2];
int ss[2];
MEMORY_STREAM ms;
const int *table_b2_nbal;
const int **table_b2;
ms_set_buffer(&ms, buffer, head->framesize);
if(head->has_crc){
ms_get_bits(&ms, 16);
}
if(head->sblimit > 20){
table_b2_nbal = table_b2ab_nbal;
table_b2 = table_b2ab;
}else{
table_b2_nbal = table_b2cd_nbal;
table_b2 = table_b2cd;
}
/* read allocation */
for(sb=0;sb<head->bound;sb++){
for(ch=0;ch<2;ch++){
n = ms_get_bits(&ms, table_b2_nbal[sb]);
allocation[sb][ch] = table_b2[sb][n];
}
}
for(sb=head->bound;sb<head->sblimit;sb++){
n =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -