Bug 130626

Summary: Calculation of MPEG frame length is wrong
Product: [Frameworks and Libraries] taglib Reporter: Dirk E. Wagner <taglib>
Component: generalAssignee: Scott Wheeler <wheeler>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Dirk E. Wagner 2006-07-11 16:37:55 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 3.2.3 
OS:                Linux

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.
Comment 1 Rex Dieter 2006-07-11 16:44:19 UTC

*** This bug has been marked as a duplicate of 130625 ***