>
> I'm writing a little code snippet to read MPEG headers and report
> the info contained in them. After eliminating invalid headers by excluding
> bad/invalid bits and combinations, it still recognizes a lot of
> headers that aren't actually headers. Are there any other methods
> for eliminating invalid headers?
>
There are 4 other checks you can do: see the function
head_check, in mpglib/common.c. You can also look for multiple
headers and make sure the samplerate and number of channels
dont change within the file. (although technically I think
this is allowed!)
int head_check(unsigned long head)
{
if( (head & 0xffe00000) != 0xffe00000) {
/* syncword */
return FALSE;
}
if (3 != 4-((head>>17)&3)) {
/* bits 13-14 = layer 3 */
return FALSE;
}
if( ((head>>12)&0xf) == 0xf) {
/* bits 16,17,18,19 = 1111 invalid bitrate */
return FALSE;
}
if( ((head>>10)&0x3) == 0x3 ) {
/* bits 20,21 = 11 invalid sampling freq */
return FALSE;
}
return TRUE;
}
--
MP3 ENCODER mailing list ( http://geek.rcc.se/mp3encoder/ )