📄 synth.c
字号:
t136 = t106 + t107;
t137 = t108 + t109;
t110 = t136 + t137;
t87 = (t110 << 1) - t67;
t77 = (t87 << 1) - t68;
/* 7 */ hi[ 8][slot] = SHIFT(t77);
t141 = MUL(t69 - t70, costab8);
t142 = MUL(t71 - t72, costab24);
t143 = t141 + t142;
/* 8 */ hi[ 7][slot] = SHIFT(t143);
/* 24 */ lo[ 8][slot] =
SHIFT((MUL(t141 - t142, costab16) << 1) - t143);
t144 = MUL(t73 - t74, costab8);
t145 = MUL(t75 - t76, costab24);
t146 = t144 + t145;
t88 = (t146 << 1) - t77;
/* 9 */ hi[ 6][slot] = SHIFT(t88);
t148 = MUL(t78 - t79, costab8);
t149 = MUL(t80 - t81, costab24);
t150 = t148 + t149;
t105 = (t150 << 1) - t82;
/* 10 */ hi[ 5][slot] = SHIFT(t105);
t152 = MUL(t83 - t84, costab8);
t153 = MUL(t85 - t86, costab24);
t154 = t152 + t153;
t111 = (t154 << 1) - t87;
t99 = (t111 << 1) - t88;
/* 11 */ hi[ 4][slot] = SHIFT(t99);
t157 = MUL(t89 - t90, costab8);
t158 = MUL(t91 - t92, costab24);
t159 = t157 + t158;
t127 = (t159 << 1) - t93;
/* 12 */ hi[ 3][slot] = SHIFT(t127);
t160 = (MUL(t125 - t126, costab16) << 1) - t127;
/* 20 */ lo[ 4][slot] = SHIFT(t160);
/* 28 */ lo[12][slot] =
SHIFT((((MUL(t157 - t158, costab16) << 1) - t159) << 1) - t160);
t161 = MUL(t94 - t95, costab8);
t162 = MUL(t96 - t97, costab24);
t163 = t161 + t162;
t130 = (t163 << 1) - t98;
t112 = (t130 << 1) - t99;
/* 13 */ hi[ 2][slot] = SHIFT(t112);
t164 = (MUL(t128 - t129, costab16) << 1) - t130;
t166 = MUL(t100 - t101, costab8);
t167 = MUL(t102 - t103, costab24);
t168 = t166 + t167;
t134 = (t168 << 1) - t104;
t120 = (t134 << 1) - t105;
/* 14 */ hi[ 1][slot] = SHIFT(t120);
t135 = (MUL(t118 - t119, costab16) << 1) - t120;
/* 18 */ lo[ 2][slot] = SHIFT(t135);
t169 = (MUL(t132 - t133, costab16) << 1) - t134;
t151 = (t169 << 1) - t135;
/* 22 */ lo[ 6][slot] = SHIFT(t151);
t170 = (((MUL(t148 - t149, costab16) << 1) - t150) << 1) - t151;
/* 26 */ lo[10][slot] = SHIFT(t170);
/* 30 */ lo[14][slot] =
SHIFT((((((MUL(t166 - t167, costab16) << 1) -
t168) << 1) - t169) << 1) - t170);
t171 = MUL(t106 - t107, costab8);
t172 = MUL(t108 - t109, costab24);
t173 = t171 + t172;
t138 = (t173 << 1) - t110;
t123 = (t138 << 1) - t111;
t139 = (MUL(t121 - t122, costab16) << 1) - t123;
t117 = (t123 << 1) - t112;
/* 15 */ hi[ 0][slot] = SHIFT(t117);
t124 = (MUL(t115 - t116, costab16) << 1) - t117;
/* 17 */ lo[ 1][slot] = SHIFT(t124);
t131 = (t139 << 1) - t124;
/* 19 */ lo[ 3][slot] = SHIFT(t131);
t140 = (t164 << 1) - t131;
/* 21 */ lo[ 5][slot] = SHIFT(t140);
t174 = (MUL(t136 - t137, costab16) << 1) - t138;
t155 = (t174 << 1) - t139;
t147 = (t155 << 1) - t140;
/* 23 */ lo[ 7][slot] = SHIFT(t147);
t156 = (((MUL(t144 - t145, costab16) << 1) - t146) << 1) - t147;
/* 25 */ lo[ 9][slot] = SHIFT(t156);
t175 = (((MUL(t152 - t153, costab16) << 1) - t154) << 1) - t155;
t165 = (t175 << 1) - t156;
/* 27 */ lo[11][slot] = SHIFT(t165);
t176 = (((((MUL(t161 - t162, costab16) << 1) -
t163) << 1) - t164) << 1) - t165;
/* 29 */ lo[13][slot] = SHIFT(t176);
/* 31 */ lo[15][slot] =
SHIFT((((((((MUL(t171 - t172, costab16) << 1) -
t173) << 1) - t174) << 1) - t175) << 1) - t176);
/*
* Totals:
* 80 multiplies
* 80 additions
* 119 subtractions
* 49 shifts (not counting SSO)
*/
}
# undef MUL
# undef SHIFT
/* third SSO shift and/or D[] optimization preshift */
# if defined(OPT_SSO)
# if MAD_F_FRACBITS != 28
# error "MAD_F_FRACBITS must be 28 to use OPT_SSO"
# endif
# define ML0(hi, lo, x, y) ((lo) = (x) * (y))
# define MLA(hi, lo, x, y) ((lo) += (x) * (y))
# define MLZ(hi, lo) ((void) (hi), (mad_fixed_t) (lo))
# define SHIFT(x) ((x) >> 2)
# define PRESHIFT(x) ((MAD_F(x) + (1L << 13)) >> 14)
# else
# define ML0(hi, lo, x, y) MAD_F_ML0((hi), (lo), (x), (y))
# define MLA(hi, lo, x, y) MAD_F_MLA((hi), (lo), (x), (y))
# define MLZ(hi, lo) MAD_F_MLZ((hi), (lo))
# define SHIFT(x) (x)
# if defined(MAD_F_SCALEBITS)
# undef MAD_F_SCALEBITS
# define MAD_F_SCALEBITS (MAD_F_FRACBITS - 12)
# define PRESHIFT(x) (MAD_F(x) >> 12)
# else
# define PRESHIFT(x) MAD_F(x)
# endif
# endif
static
mad_fixed_t const D[17][32] = {
# include "D.dat"
};
# if defined(ASO_SYNTH)
void synth_full(struct mad_synth *, struct mad_frame const *,
unsigned int, unsigned int);
# else
/*
* NAME: synth->full()
* DESCRIPTION: perform full frequency PCM synthesis
*/
static
void synth_full(struct mad_synth *synth, struct mad_frame const *frame,
unsigned int nch, unsigned int ns)
{
unsigned int phase, ch, s, sb, pe, po;
mad_fixed_t *pcm1, *pcm2, (*filter)[2][2][16][8];
mad_fixed_t const (*sbsample)[36][32];
register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
register mad_fixed_t const (*Dptr)[32], *ptr;
register mad_fixed64hi_t hi;
register mad_fixed64lo_t lo;
for (ch = 0; ch < nch; ++ch) {
sbsample = &frame->sbsample[ch];
filter = &synth->filter[ch];
phase = synth->phase;
pcm1 = synth->pcm.samples[ch];
for (s = 0; s < ns; ++s) {
dct32((*sbsample)[s], phase >> 1,
(*filter)[0][phase & 1], (*filter)[1][phase & 1]);
pe = phase & ~1;
po = ((phase - 1) & 0xf) | 1;
/* calculate 32 samples */
fe = &(*filter)[0][ phase & 1][0];
fx = &(*filter)[0][~phase & 1][0];
fo = &(*filter)[1][~phase & 1][0];
Dptr = &D[0];
ptr = *Dptr + pe;
ML0(hi, lo, (*fe)[0], ptr[ 0]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[7], ptr[ 2]);
ptr = *Dptr + po;
MLA(hi, lo, (*fx)[0], -ptr[ 0]);
MLA(hi, lo, (*fx)[1], -ptr[14]);
MLA(hi, lo, (*fx)[2], -ptr[12]);
MLA(hi, lo, (*fx)[3], -ptr[10]);
MLA(hi, lo, (*fx)[4], -ptr[ 8]);
MLA(hi, lo, (*fx)[5], -ptr[ 6]);
MLA(hi, lo, (*fx)[6], -ptr[ 4]);
MLA(hi, lo, (*fx)[7], -ptr[ 2]);
*pcm1++ = SHIFT(MLZ(hi, lo));
pcm2 = pcm1 + 30;
for (sb = 1; sb < 16; ++sb) {
++fe;
++Dptr;
/* D[32 - sb][i] == -D[sb][31 - i] */
ptr = *Dptr + pe;
ML0(hi, lo, (*fe)[7], ptr[ 2]);
MLA(hi, lo, (*fe)[6], ptr[ 4]);
MLA(hi, lo, (*fe)[5], ptr[ 6]);
MLA(hi, lo, (*fe)[4], ptr[ 8]);
MLA(hi, lo, (*fe)[3], ptr[10]);
MLA(hi, lo, (*fe)[2], ptr[12]);
MLA(hi, lo, (*fe)[1], ptr[14]);
MLA(hi, lo, (*fe)[0], ptr[ 0]);
ptr = *Dptr + po;
MLA(hi, lo, (*fo)[0], -ptr[ 0]);
MLA(hi, lo, (*fo)[1], -ptr[14]);
MLA(hi, lo, (*fo)[2], -ptr[12]);
MLA(hi, lo, (*fo)[3], -ptr[10]);
MLA(hi, lo, (*fo)[4], -ptr[ 8]);
MLA(hi, lo, (*fo)[5], -ptr[ 6]);
MLA(hi, lo, (*fo)[6], -ptr[ 4]);
MLA(hi, lo, (*fo)[7], -ptr[ 2]);
*pcm1++ = SHIFT(MLZ(hi, lo));
ptr = *Dptr - po;
ML0(hi, lo, (*fo)[7], ptr[31 - 2]);
MLA(hi, lo, (*fo)[6], ptr[31 - 4]);
MLA(hi, lo, (*fo)[5], ptr[31 - 6]);
MLA(hi, lo, (*fo)[4], ptr[31 - 8]);
MLA(hi, lo, (*fo)[3], ptr[31 - 10]);
MLA(hi, lo, (*fo)[2], ptr[31 - 12]);
MLA(hi, lo, (*fo)[1], ptr[31 - 14]);
MLA(hi, lo, (*fo)[0], ptr[31 - 16]);
ptr = *Dptr - pe;
MLA(hi, lo, (*fe)[0], ptr[31 - 16]);
MLA(hi, lo, (*fe)[1], ptr[31 - 14]);
MLA(hi, lo, (*fe)[2], ptr[31 - 12]);
MLA(hi, lo, (*fe)[3], ptr[31 - 10]);
MLA(hi, lo, (*fe)[4], ptr[31 - 8]);
MLA(hi, lo, (*fe)[5], ptr[31 - 6]);
MLA(hi, lo, (*fe)[6], ptr[31 - 4]);
MLA(hi, lo, (*fe)[7], ptr[31 - 2]);
*pcm2-- = SHIFT(MLZ(hi, lo));
++fo;
}
++Dptr;
ptr = *Dptr + po;
ML0(hi, lo, (*fo)[0], ptr[ 0]);
MLA(hi, lo, (*fo)[1], ptr[14]);
MLA(hi, lo, (*fo)[2], ptr[12]);
MLA(hi, lo, (*fo)[3], ptr[10]);
MLA(hi, lo, (*fo)[4], ptr[ 8]);
MLA(hi, lo, (*fo)[5], ptr[ 6]);
MLA(hi, lo, (*fo)[6], ptr[ 4]);
MLA(hi, lo, (*fo)[7], ptr[ 2]);
*pcm1 = SHIFT(-MLZ(hi, lo));
pcm1 += 16;
phase = (phase + 1) % 16;
}
}
}
# endif
/*
* NAME: synth->frame()
* DESCRIPTION: perform PCM synthesis of frame subband samples
*/
void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame)
{
unsigned int nch, ns;
void (*synth_frame)(struct mad_synth *, struct mad_frame const *,
unsigned int, unsigned int);
nch = MAD_NCHANNELS(&frame->header);
ns = MAD_NSBSAMPLES(&frame->header);
synth->pcm.samplerate = frame->header.samplerate;
synth->pcm.channels = nch;
synth->pcm.length = 32 * ns;
synth_frame = synth_full;
synth_frame(synth, frame, nch, ns);
synth->phase = (synth->phase + ns) % 16;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -