The following code is simple, compact and can be easily ported into small critical apps.
I wonder if there are such simple algorithms for other versions of MP3 files.
/*
Decode id3v2-3.0 tags
I don't use the header length to determine loop end, it is unreliable
ip is the input pointer which starts at file_start + 10
The requested entries are copied via strcpyn
which converts any string nicely to a null terminated ascii string
this cleanup is done for file management purposes, since
AlbumArtist, Album and Title are used for file/path naming
*/
char tag[36]="TIT2TPE1TALBTPE2TCONTYER",*ip,c,*list,pTAG[7][256];
int i,len,curtag,cnt=sizeof(tag)/4+1;
// decode tags until non alpha tag reached
while(*ip>='A'&&*ip<='Z'){
// scan current tag against list
for(i=0,curtag=*((int *)ip),list=tag;i<cnt;i++,list=list+4)
if(curtag==*((int*)list))break ;
// reverse int length to small endian
c=*(ip+7);*(ip+7)=*(ip+4);*(ip+4)=c;c=*(ip+5);*(ip+5)=*(ip+6);*(ip+6)=c;
// start of next tag is data length plus 11, but data len is 1 out
len=*((int*)(ip+4))+10;
// if tag is on list then remember else skip
if (i<cnt) strcpyn(pTAG[i],ip+11,len-11);