Is there any support for VBR headers in MAD?
There's no support for reading Xing/LAME VBR header tags in libmad, but the code to do it can be found in madplay (see tag.c).
I'm trying to calculate the length of files and for CBR fileSize/(header.bitrate/8) works fine. For VBR, this obviously gives an incorrect answer.
If reading VBR headers is fiddly, I was also thinking of checking the bitrate in say 10 or so frames at the start, take their average bit rate and use that in the calculation above. Would that be even remotely accurate for VBR?
Probably not, considering the first 10 frames are likely to be pretty quiet compared to the rest of the stream. (10 frames is about 1/4 second of audio in Layer III at 44100 Hz.)
The only other option guaranteed to obtain correct results is to scan the entire file, decoding headers only, to calculate the total playing time.