最终,我们在Live555源代码(特别是MP3Internals.cpp)中找到了答案。
基本上,你需要读取每个通道中每个颗粒的部分长度,然后计算它们。
大致上:
uint numBits = 0;
for (int channelIdx = 0; channelIdx < isMono ? 1 : 2; channelIdx ++)
{
for (int granuleIdx = 0; granuleIdx < 2; granuleIdx ++)
{
numBits += SideInfoGranules[channelIdx][granuleIdx].Part_2_3_Length;
}
}
// Now maths this number. I don't know where the magic constants 7 and 8 come from though.
var aduDataSize = (numBits + 7) / 8;
这里对part_2_3_长度的解析有点过于复杂,无法解释,但是在
getSideInfo1
和
getSideInfo2
MP3内部的方法。cpp(例如,
here
);