mpeg framesize
D Bera
dbera.web at gmail.com
Fri Oct 6 04:35:18 CEST 2006
Hi
I was having some problem with the duration of a vbr mpeg file and
then i ran into the problem of a faulty Xing header. That lead me to
the source of taglib and lame (mpglib) to figure out how they compute
framesize. Now, I dont have much expertise in these things so I
compared the framesize calculation in lame and taglib. And I found
some differences!!!
In taglib/taglib/mpeg/mpegheader.cpp :
if(d->layer == 1)
- d->frameLength = 24000 * 2 * d->bitrate / d->sampleRate +
int(d->isPadded);
+ d->frameLength = (12000 * d->bitrate / d->sampleRate +
int(d->isPadded))*4;
else if (d->layer == 2)
- d->frameLength = 72000 * d->bitrate / d->sampleRate + int(d->isPadded);
+ d->frameLength = 144000 * d->bitrate / d->sampleRate + int(d->isPadded);
else if (d->layer == 3)
- d->frameLength = 72000 * d->bitrate / d->sampleRate + int(d->isPadded);
+ d->frameLength = 144000 * d->bitrate / d->sampleRate /
(d->version == Version1 ? 1 : 2) + int(d->isPadded);
Diff computed against the logic used in
http://lame.cvs.sourceforge.net/lame/lame/mpglib/common.c
Maybe someone here can tell me which is the correct logic ? (I couldnt
find any 'free' reliable source of MPEG standard :P). I am writing a
simple tool to fix faulty xing headers in some of my vbr mp3 files and
it will be helpful to know the correct way to compute framelength.
Thanks,
- dBera
--
-----------------------------------------------------
Debajyoti Bera @ http://dtecht.blogspot.com
beagle / KDE fan
Mandriva / Inspiron-1100 user
More information about the taglib-devel
mailing list