📄 newmdct.c
字号:
xr = a[29] - xr; a[29] = xr; xr = a[ 1] - a[ 0]; a[ 1] = xr; xr = a[16] - xr; a[16] = xr; xr = a[17] - xr; a[17] = xr; xr = a[ 8] - xr; a[ 8] = xr; xr = a[ 9] - xr; a[ 9] = xr; xr = a[24] - xr; a[24] = xr; xr = a[25] - xr; a[25] = xr; xr = a[ 4] - xr; a[ 4] = xr; xr = a[ 5] - xr; a[ 5] = xr; xr = a[20] - xr; a[20] = xr; xr = a[21] - xr; a[21] = xr; xr = a[12] - xr; a[12] = xr; xr = a[13] - xr; a[13] = xr; xr = a[28] - xr; a[28] = xr; xr = a[29] - xr; a[29] = xr; xr = a[ 0]; a[ 0] += a[31]; a[31] -= xr; xr = a[ 1]; a[ 1] += a[30]; a[30] -= xr; xr = a[16]; a[16] += a[15]; a[15] -= xr; xr = a[17]; a[17] += a[14]; a[14] -= xr; xr = a[ 8]; a[ 8] += a[23]; a[23] -= xr; xr = a[ 9]; a[ 9] += a[22]; a[22] -= xr; xr = a[24]; a[24] += a[ 7]; a[ 7] -= xr; xr = a[25]; a[25] += a[ 6]; a[ 6] -= xr; xr = a[ 4]; a[ 4] += a[27]; a[27] -= xr; xr = a[ 5]; a[ 5] += a[26]; a[26] -= xr; xr = a[20]; a[20] += a[11]; a[11] -= xr; xr = a[21]; a[21] += a[10]; a[10] -= xr; xr = a[12]; a[12] += a[19]; a[19] -= xr; xr = a[13]; a[13] += a[18]; a[18] -= xr; xr = a[28]; a[28] += a[ 3]; a[ 3] -= xr; xr = a[29]; a[29] += a[ 2]; a[ 2] -= xr;}}/*-------------------------------------------------------------------*//* *//* Function: Calculation of the MDCT *//* In the case of long blocks (type 0,1,3) there are *//* 36 coefficents in the time domain and 18 in the frequency *//* domain. *//* In the case of short blocks (type 2) there are 3 *//* transformations with short length. This leads to 12 coefficents *//* in the time and 6 in the frequency domain. In this case the *//* results are stored side by side in the vector out[]. *//* *//* New layer3 *//* *//*-------------------------------------------------------------------*/inline static void mdct_short(FLOAT *inout){ int l; for ( l = 0; l < 3; l++ ) { FLOAT tc0,tc1,tc2,ts0,ts1,ts2; ts0 = inout[2*3] * win[SHORT_TYPE][0] - inout[5*3]; tc0 = inout[0*3] * win[SHORT_TYPE][2] - inout[3*3]; tc1 = ts0 + tc0; tc2 = ts0 - tc0; ts0 = inout[5*3] * win[SHORT_TYPE][0] + inout[2*3]; tc0 = inout[3*3] * win[SHORT_TYPE][2] + inout[0*3]; ts1 = ts0 + tc0; ts2 = -ts0 + tc0; tc0 = (inout[1*3] * win[SHORT_TYPE][1] - inout[4*3]) * 2.069978111953089e-11; /* tritab_s[1] */ ts0 = (inout[4*3] * win[SHORT_TYPE][1] + inout[1*3]) * 2.069978111953089e-11; /* tritab_s[1] */ inout[3*0] = tc1 * 1.907525191737280e-11 /* tritab_s[2] */ + tc0; inout[3*5] = -ts1 * 1.907525191737280e-11 /* tritab_s[0] */ + ts0; tc2 = tc2 * 0.86602540378443870761 * 1.907525191737281e-11 /* tritab_s[2] */; ts1 = ts1 * 0.5 * 1.907525191737281e-11 + ts0; inout[3*1] = tc2-ts1; inout[3*2] = tc2+ts1; tc1 = tc1 * 0.5 * 1.907525191737281e-11 - tc0; ts2 = ts2 * 0.86602540378443870761 * 1.907525191737281e-11 /* tritab_s[0] */; inout[3*3] = tc1+ts2; inout[3*4] = tc1-ts2; inout++; }}inline static void mdct_long(FLOAT *out, FLOAT *in){ FLOAT ct,st; { FLOAT tc1, tc2, tc3, tc4, ts5, ts6, ts7, ts8; /* 1,2, 5,6, 9,10, 13,14, 17 */ tc1 = in[17]-in[ 9]; tc3 = in[15]-in[11]; tc4 = in[14]-in[12]; ts5 = in[ 0]+in[ 8]; ts6 = in[ 1]+in[ 7]; ts7 = in[ 2]+in[ 6]; ts8 = in[ 3]+in[ 5]; out[17] = (ts5+ts7-ts8)-(ts6-in[4]); st = (ts5+ts7-ts8)*cx[7]+(ts6-in[4]); ct = (tc1-tc3-tc4)*cx[6]; out[5] = ct+st; out[6] = ct-st; tc2 = (in[16]-in[10])*cx[6]; ts6 = ts6*cx[7] + in[4]; ct = tc1*cx[0] + tc2 + tc3*cx[1] + tc4*cx[2]; st = -ts5*cx[4] + ts6 - ts7*cx[5] + ts8*cx[3]; out[1] = ct+st; out[2] = ct-st; ct = tc1*cx[1] - tc2 - tc3*cx[2] + tc4*cx[0]; st = -ts5*cx[5] + ts6 - ts7*cx[3] + ts8*cx[4]; out[ 9] = ct+st; out[10] = ct-st; ct = tc1*cx[2] - tc2 + tc3*cx[0] - tc4*cx[1]; st = ts5*cx[3] - ts6 + ts7*cx[4] - ts8*cx[5]; out[13] = ct+st; out[14] = ct-st; } { FLOAT ts1, ts2, ts3, ts4, tc5, tc6, tc7, tc8; ts1 = in[ 8]-in[ 0]; ts3 = in[ 6]-in[ 2]; ts4 = in[ 5]-in[ 3]; tc5 = in[17]+in[ 9]; tc6 = in[16]+in[10]; tc7 = in[15]+in[11]; tc8 = in[14]+in[12]; out[0] = (tc5+tc7+tc8)+(tc6+in[13]); ct = (tc5+tc7+tc8)*cx[7]-(tc6+in[13]); st = (ts1-ts3+ts4)*cx[6]; out[11] = ct+st; out[12] = ct-st; ts2 = (in[7]-in[1])*cx[6]; tc6 = in[13] - tc6*cx[7]; ct = tc5*cx[3] - tc6 + tc7*cx[4] + tc8*cx[5]; st = ts1*cx[2] + ts2 + ts3*cx[0] + ts4*cx[1]; out[3] = ct+st; out[4] = ct-st; ct = -tc5*cx[5] + tc6 - tc7*cx[3] - tc8*cx[4]; st = ts1*cx[1] + ts2 - ts3*cx[2] - ts4*cx[0]; out[7] = ct+st; out[8] = ct-st; ct = -tc5*cx[4] + tc6 - tc7*cx[5] - tc8*cx[3]; st = ts1*cx[0] - ts2 + ts3*cx[1] - ts4*cx[2]; out[15] = ct+st; out[16] = ct-st; }}void mdct_sub48( lame_internal_flags *gfc, const sample_t *w0, const sample_t *w1 ){ int gr, k, ch; const sample_t *wk; wk = w0 + 286; /* thinking cache performance, ch->gr loop is better than gr->ch loop */ for (ch = 0; ch < gfc->channels_out; ch++) { for (gr = 0; gr < gfc->mode_gr; gr++) { int band; gr_info *gi = &(gfc->l3_side.tt[gr][ch]); FLOAT *mdct_enc = gi->xr; FLOAT *samp = gfc->sb_sample[ch][1 - gr][0]; for (k = 0; k < 18 / 2; k++) { window_subband(wk, samp); window_subband(wk + 32, samp + 32); samp += 64; wk += 64; /* * Compensate for inversion in the analysis filter */ for (band = 1; band < 32; band+=2) { samp[band-32] *= -1; } } /* * Perform imdct of 18 previous subband samples * + 18 current subband samples */ for (band = 0; band < 32; band++, mdct_enc += 18) { int type = gi->block_type; FLOAT *band0, *band1; band0 = gfc->sb_sample[ch][ gr][0] + order[band]; band1 = gfc->sb_sample[ch][1-gr][0] + order[band]; if (gi->mixed_block_flag && band < 2) type = 0; if (gfc->amp_filter[band] == 0.0) { memset(mdct_enc, 0, 18*sizeof(FLOAT)); } else { if (gfc->amp_filter[band] != 1.0) { for (k=0; k<18; k++) band1[k*32] *= gfc->amp_filter[band]; } if (type == SHORT_TYPE) { for (k = -NS/4; k < 0; k++) { FLOAT w = win[SHORT_TYPE][k+3]; mdct_enc[k*3+ 9] = band0[( 9+k)*32] * w - band0[( 8-k)*32]; mdct_enc[k*3+18] = band0[(14-k)*32] * w + band0[(15+k)*32]; mdct_enc[k*3+10] = band0[(15+k)*32] * w - band0[(14-k)*32]; mdct_enc[k*3+19] = band1[( 2-k)*32] * w + band1[( 3+k)*32]; mdct_enc[k*3+11] = band1[( 3+k)*32] * w - band1[( 2-k)*32]; mdct_enc[k*3+20] = band1[( 8-k)*32] * w + band1[( 9+k)*32]; } mdct_short(mdct_enc); } else { FLOAT work[18]; for (k = -NL/4; k < 0; k++) { FLOAT a, b; a = win[type][k+27] * band1[(k+9)*32] + win[type][k+36] * band1[(8-k)*32]; b = win[type][k+ 9] * band0[(k+9)*32] - win[type][k+18] * band0[(8-k)*32]; work[k+ 9] = a - b*tantab_l[k+9]; work[k+18] = a*tantab_l[k+9] + b; } mdct_long(mdct_enc, work); } } /* * Perform aliasing reduction butterfly */ if (type != SHORT_TYPE && band != 0) { for (k = 7; k >= 0; --k) { FLOAT bu,bd; bu = mdct_enc[k] * ca[k] + mdct_enc[-1-k] * cs[k]; bd = mdct_enc[k] * cs[k] - mdct_enc[-1-k] * ca[k]; mdct_enc[-1-k] = bu; mdct_enc[k] = bd; } } } } wk = w1 + 286; if (gfc->mode_gr == 1) { memcpy(gfc->sb_sample[ch][0], gfc->sb_sample[ch][1], 576 * sizeof(FLOAT)); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -