- 打卡等级:常住居民III
- 打卡总天数:165
- 最近打卡:2026-03-07 00:57:19
金牌会员
- 积分
- 2033
|
发表于 2026-2-5 14:19:42
|
显示全部楼层
static float L3_ldexp_q2(float y, int exp_q2)
{
static const float g_expfrac[4] = { 9.31322575e-10f, 7.83145814e-10f, 6.58544508e-10f, 5.53767716e-10f };
int e;
do
{
e = MINIMP3_MIN(30*4, exp_q2);
y *= g_expfrac[e & 3] * tab[e >> 2];
} while ((exp_q2 -= e) > 0);
return y;
}
修改为
static float L3_ldexp_q2(float y, int exp_q2)
{
static const float g_expfrac[4] = { 9.31322575e-10f, 7.83145814e-10f, 6.58544508e-10f, 5.53767716e-10f };
static const float tab[31] = {0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000, 0x02000000, 0x01000000, 0x00800000,
0x00400000, 0x00200000, 0x00100000, 0x00080000, 0x00040000, 0x00020000, 0x00010000, 0x00008000,
0x00004000, 0x00002000, 0x00001000, 0x00000800, 0x00000400, 0x00000200, 0x00000100, 0x00000080,
0x00000040, 0x00000020, 0x00000010, 0x00000008, 0x00000004, 0x00000002, 0x00000001};
int e;
do
{
e = MINIMP3_MIN(30*4, exp_q2);
//y *= g_expfrac[e & 3] * (1UL << 30 >> (e >> 2));
y *= g_expfrac[e & 3] * tab[e >> 2];
} while ((exp_q2 -= e) > 0);
return y;
}
32位整数移位,以及32位整数转float,统一使用查表获得,代价是代码多占用31*4字节。 |
|