📄 mpeglayer2.cc
字号:
X(-8.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(0.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(2.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(4.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(6.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(-8.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(0.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(2.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(4.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(6.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(-8.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(0.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(2.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(4.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(6.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(-8.0 / 9.0), X(0.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(0.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(0.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(0.0), X(8.0 / 9.0), X(0.0), X(0.0), X(8.0 / 9.0), X(2.0 / 9.0), X(0.0), X(8.0 / 9.0), X(4.0 / 9.0), X(0.0), X(8.0 / 9.0), X(6.0 / 9.0), X(0.0), X(8.0 / 9.0), X(8.0 / 9.0), X(0.0), X(8.0 / 9.0), X(-8.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(0.0), X(2.0 / 9.0), X(8.0 / 9.0), X(2.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(4.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(6.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(-8.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(0.0), X(4.0 / 9.0), X(8.0 / 9.0), X(2.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(4.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(6.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(-8.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(0.0), X(6.0 / 9.0), X(8.0 / 9.0), X(2.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(4.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(6.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(-8.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(-6.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(-4.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(-2.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(0.0), X(8.0 / 9.0), X(8.0 / 9.0), X(2.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(4.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(6.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0), X(8.0 / 9.0)};static const REAL *grouptableA[16] = { 0, group5bits, group7bits, group10bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0 };static const REAL *grouptableB1[16] = { 0, group5bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };static const REAL *grouptableB234[16] = { 0, group5bits, group7bits, 0, group10bits, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0 };static const int codelengthtableA[16] = { 0, 5, 7, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };static const int codelengthtableB1[16] = { 0, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };static const int codelengthtableB2[16] = { 0, 5, 7, 3, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 16 };static const int codelengthtableB3[8] = { 0, 5, 7, 3, 10, 4, 5, 16 };static const int codelengthtableB4[4] = { 0, 5, 7, 16 };static const int codelengthtableIIa[16] = { 0, 5, 7, 3, 10, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };static const int codelengthtableIIb[8] = { 0, 5, 7, 10, 4, 5, 6, 7 };static const REAL factortableA[16] = { X(0.0), X(1.0 / 2.0), X(1.0 / 4.0), X(1.0 / 8.0), X(1.0 / 8.0), X(1.0 / 16.0), X(1.0 / 32.0), X(1.0 / 64.0), X(1.0 / 128.0), X(1.0 / 256.0), X(1.0 / 512.0), X(1.0 / 1024.0), X(1.0 / 2048.0), X(1.0 / 4096.0), X(1.0 / 8192.0), X(1.0 / 16384.0)};static const REAL factortableB1[16] = { X(0.0), X(1.0 / 2.0), X(1.0 / 4.0), X(1.0 / 8.0), X(1.0 / 16.0), X(1.0 / 32.0), X(1.0 / 64.0), X(1.0 / 128.0), X(1.0 / 256.0), X(1.0 / 512.0), X(1.0 / 1024.0), X(1.0 / 2048.0), X(1.0 / 4096.0), X(1.0 / 8192.0), X(1.0 / 16384.0), X(1.0 / 32768.0)};static const REAL factortableB2[16] = { X(0.0), X(1.0 / 2.0), X(1.0 / 4.0), X(1.0 / 4.0), X(1.0 / 8.0), X(1.0 / 8.0), X(1.0 / 16.0), X(1.0 / 32.0), X(1.0 / 64.0), X(1.0 / 128.0), X(1.0 / 256.0), X(1.0 / 512.0), X(1.0 / 1024.0), X(1.0 / 2048.0), X(1.0 / 4096.0), X(1.0 / 32768.0)};static const REAL factortableB3[8] = { X(0.0), X(1.0 / 2.0), X(1.0 / 4.0), X(1.0 / 4.0), X(1.0 / 8.0), X(1.0 / 8.0), X(1.0 / 16.0), X(1.0 / 32768.0)};static const REAL factortableB4[4] = { X(0.0), X(1.0 / 2.0), X(1.0 / 4.0), X(1.0 / 32768.0) };static const REAL factortableIIa[16] = { X(0.0), X(1.0 / 2.0), X(1.0 / 4.0), X(1.0 / 4.0), X(1.0 / 8.0), X(1.0 / 8.0), X(1.0 / 16.0), X(1.0 / 32.0), X(1.0 / 64.0), X(1.0 / 128.0), X(1.0 / 256.0), X(1.0 / 512.0), X(1.0 / 1024.0), X(1.0 / 2048.0), X(1.0 / 4096.0), X(1.0 / 8192.0)};static const REAL factortableIIb[8] = { X(0.0), X(1.0 / 2.0), X(1.0 / 4.0), X(1.0 / 8.0), X(1.0 / 8.0), X(1.0 / 16.0), X(1.0 / 32.0), X(1.0 / 64.0)};static const REAL ctableA[16] = { X(0.0), X(1.33333333333), X(1.60000000000), X(1.77777777777), X(1.06666666666), X(1.03225806452), X(1.01587301587), X(1.00787401575), X(1.00392156863), X(1.00195694716), X(1.00097751711), X(1.00048851979), X(1.00024420024), X(1.00012208522), X(1.00006103888), X(1.00003051851)};static const REAL ctableB1[16] = { X(0.0), X(1.33333333333), X(1.14285714286), X(1.06666666666), X(1.03225806452), X(1.01587301587), X(1.00787401575), X(1.00392156863), X(1.00195694716), X(1.00097751711), X(1.00048851979), X(1.00024420024), X(1.00012208522), X(1.00006103888), X(1.00003051851), X(1.00001525902)};static const REAL ctableB2[16] = { X(0.0), X(1.33333333333), X(1.60000000000), X(1.14285714286), X(1.77777777777), X(1.06666666666), X(1.03225806452), X(1.01587301587), X(1.00787401575), X(1.00392156863), X(1.00195694716), X(1.00097751711), X(1.00048851979), X(1.00024420024), X(1.00012208522), X(1.00001525902)};static const REAL ctableB3[8] = { X(0.0), X(1.33333333333), X(1.60000000000), X(1.14285714286), X(1.77777777777), X(1.06666666666), X(1.03225806452), X(1.00001525902)};static const REAL ctableB4[4] = { X(0.0), X(1.33333333333), X(1.60000000000), X(1.00001525902)};static const REAL ctableIIa[16] = { X(0.0), X(1.33333333333), X(1.60000000000), X(1.14285714286), X(1.77777777777), X(1.06666666666), X(1.03225806452), X(1.01587301587), X(1.00787401575), X(1.00392156863), X(1.00195694716), X(1.00097751711), X(1.00048851979), X(1.00024420024), X(1.00012208522), X(1.00006103888)};static const REAL ctableIIb[8] = { X(0.0), X(1.33333333333), X(1.60000000000), X(1.77777777777), X(1.06666666666), X(1.03225806452), X(1.01587301587), X(1.00787401575)};static const REAL dtableA[16] = { X(0.0), X(0.50000000000), X(0.50000000000), X(0.50000000000), X(0.12500000000), X(0.06250000000), X(0.03125000000), X(0.01562500000), X(0.00781250000), X(0.00390625000), X(0.00195312500), X(0.00097656250), X(0.00048828125), X(0.00024414063), X(0.00012207031), X(0.00006103516)};static const REAL dtableB1[16] = { X(0.0), X(0.50000000000), X(0.25000000000), X(0.12500000000), X(0.06250000000), X(0.03125000000), X(0.01562500000), X(0.00781250000), X(0.00390625000), X(0.00195312500), X(0.00097656250), X(0.00048828125), X(0.00024414063), X(0.00012207031), X(0.00006103516), X(0.00003051758)};static const REAL dtableB2[16] = { X(0.0), X(0.50000000000), X(0.50000000000), X(0.25000000000), X(0.50000000000), X(0.12500000000), X(0.06250000000), X(0.03125000000), X(0.01562500000), X(0.00781250000), X(0.00390625000), X(0.00195312500), X(0.00097656250), X(0.00048828125), X(0.00024414063), X(0.00003051758)};static const REAL dtableB3[8] = { X(0.0), X(0.50000000000), X(0.50000000000), X(0.25000000000), X(0.50000000000), X(0.12500000000), X(0.06250000000), X(0.00003051758)};static const REAL dtableB4[4] = { X(0.0), X(0.50000000000), X(0.50000000000), X(0.00003051758)};static const REAL dtableIIa[16] = { X(0.0), X(0.50000000000), X(0.50000000000), X(0.25000000000), X(0.50000000000), X(0.12500000000), X(0.06250000000), X(0.03125000000), X(0.01562500000), X(0.00781250000), X(0.00390625000), X(0.00195312500), X(0.00097656250), X(0.00048828125), X(0.00024414063), X(0.00012207031)};static const REAL dtableIIb[8] = { X(0.0), X(0.50000000000), X(0.50000000000), X(0.50000000000), X(0.12500000000), X(0.06250000000), X(0.03125000000), X(0.01562500000)};// Mpeg layer 2voidMpegtoraw::extractlayer2(void){ REAL fraction[MAXCHANNEL][3][MAXSUBBAND]; unsigned int bitalloc[MAXCHANNEL][MAXSUBBAND], scaleselector[MAXCHANNEL][MAXSUBBAND]; REAL scalefactor[2][3][MAXSUBBAND]; const REAL *group[MAXCHANNEL][MAXSUBBAND]; unsigned int codelength[MAXCHANNEL][MAXSUBBAND]; REAL factor[MAXCHANNEL][MAXSUBBAND]; REAL c[MAXCHANNEL][MAXSUBBAND], d[MAXCHANNEL][MAXSUBBAND]; int s = stereobound, n = subbandnumber;// Bitalloc { register int i; register const int *t = bitalloclengthtable[tableindex]; for (i = 0; i < s; i++, t++) { bitalloc[LS][i] = getbits(*t); bitalloc[RS][i] = getbits(*t); } for (; i < n; i++, t++) bitalloc[LS][i] = bitalloc[RS][i] = getbits(*t); } // Scale selector if (inputstereo) for (register int i = 0; i < n; i++) { if (bitalloc[LS][i]) scaleselector[LS][i] = getbits(2); if (bitalloc[RS][i]) scaleselector[RS][i] = getbits(2); } else for (register int i = 0; i < n; i++) if (bitalloc[LS][i]) scaleselector[LS][i] = getbits(2); // Scale index { register int i, j; for (i = 0; i < n; i++) { if ((j = bitalloc[LS][i])) { if (tableindex == 0) { group[LS][i] = grouptableA[j]; codelength[LS][i] = codelengthtableA[j]; factor[LS][i] = factortableA[j]; c[LS][i] = ctableA[j]; d[LS][i] = dtableA[j]; } else if (tableindex == 1) { if (i <= 2) { group[LS][i] = grouptableB1[j]; codelength[LS][i] = codelengthtableB1[j]; factor[LS][i] = factortableB1[j]; c[LS][i] = ctableB1[j]; d[LS][i] = dtableB1[j]; } else { group[LS][i] = grouptableB234[j]; if (i <= 10) { codelength[LS][i] = codelengthtableB2[j]; factor[LS][i] = factortableB2[j];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -