Calculation of MPEG frame length is wrong

Dirk E. Wagner taglib at wagner-budenheim.de
Mon Jul 10 11:37:00 CEST 2006


In the file mpegheader.cpp line 249 of taglib-1.4 the calculation of  
the frame length is wrong. At this time it is implemented as follows:

if(d->layer == 1)
   d->frameLength = 24000 * 2 * d->bitrate / d->sampleRate + int(d->isPadded);
else
   d->frameLength = 72000 * d->bitrate / d->sampleRate + int(d->isPadded);

This must be replaced by:

if(d->layer == 1)
   d->frameLength = 24000 * 2 * d->bitrate / d->sampleRate +  
(int(d->isPadded) * 4);
else
   d->frameLength = 72000 * 2 * d->bitrate / d->sampleRate + int(d->isPadded);

See http://www.dv.co.yu/mpgscript/mpeghdr.htm section 'How to  
calculate frame length' for details.

Ciao,
Dirk


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.




More information about the taglib-devel mailing list