Odd APIC frame
Brian Kerrick Nickel
brian.nickel at gmail.com
Fri Jul 14 03:55:55 CEST 2006
I ran into this problem recently with some podcasts. The problem is that
APIC (2.3+) and PIC (2.2) handle file type differently. APIC uses a Latin-1
string followed by a nul byte to represent file types. Say, "image/png\0".
PIC, on the other hand, uses just three bytes, so "PNG" (no termination). As
the parser currently searches for the next nul byte, and 2.2 doesn't have
one in the traditional place, the parsing goes haywire and the frame
The TagLib# AttachedPictureFrame
does the following:
int pos = 0;
text_encoding = (StringType) data [pos];
pos += 1;
if (Header.Version > 2)
offset = data.Find (TextDelimiter (StringType.Latin1), pos);
if(offset < pos)
mime_type = data.Mid (pos, offset - pos).ToString
pos = offset + 1;
ByteVector ext = data.Mid (pos, 3);
if (ext == "JPG")
mime_type = "image/jpeg";
else if (ext == "PNG")
mime_type = "image/png";
mime_type = "image/unknown";
pos += 3;
- Brian Nickel
On 7/13/06, Scott Wheeler <wheeler at kde.org> wrote:
> On Jul 13, 2006, at 11:13 PM, Norman Palardy wrote:
> > On Jul 13, 2006, at 2:51 PM, Scott Wheeler wrote:
> >> On Jul 13, 2006, at 10:19 PM, Norman Palardy wrote:
> >>> I'm working with a few mp3 files from various sources.
> >>> There seems to be a couple that have very odd attached pictures that
> >>> taglib gets just slightly wrong.
> >>> Apple's iTunes and MS' Windows Media seem to handle these though.
> >> Just a guess, but this may be the fact that iTunes has a bug in its
> >> synch safe integer implementation (it doesn't use them, basically),
> >> so it ends up writing invalid lengths for images which messes things
> >> up in some cases. WMP may have a work around for the iTunes bug.
> >> What are the sizes of the images that aren't being read properly?
> > Manually I copied the data based on the values in the frame (what
> > appears to me to be a a PIC frame) into a new file, saved it and
> > then opened it in a image editor. So the value seems to be correct.
> > It was only 49974 bytes.
> > The first 512 bytes of the file are (a snapshot from the hex editor
> > I use)
> > <Picture 1.png>
> > When I retrieve the apic frame and iterate over the bytes I see
> > that the first 11 bytes of the picture data are not part of the
> > returned data
> Ah, it's ID3v2.2 -- indeed I haven't really tested APIC (or rather
> "PIC" in ID3v2.2 terms). It would be useful if you could file a bug
> report (and ideally send me the file with the filename as [bug report
> number].mp3 since I won't be able to seriously look at the issue for
> a few days and things less often get lost in the bug system.
> taglib-devel mailing list
> taglib-devel at kde.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the taglib-devel