Patch: ASF picture parser

Anton Sergunov setosha at
Fri Aug 27 17:13:47 CEST 2010

Adds ASF::Picture class.
Fix: ASF long (size >= 0x8000) Attribute in extended content descriptor.

Technical details.

class Picture
To reach best performance all accessors is inline and Attribute
returned a picture by const refference.
Don't know is it correct on other build enviroments?

When Attribute is binary and named "WM/Picture" attribute::parse() try
to parse data as Picture.
If successed data stored as picture only.
When attribute requested as binaryVector it renders from stored Picture.

If Picture::parse() fails parser calls debug("..."), performs
File::seek() to begining of data, stores it as usual (ByteArray) and
sets picture.isValid() to false;

So Attribute::toPicture().isValid() should be true when name ==
"WM/Picture". attribute.type() should be BytesType;
User can Attribute::toPicture().isValid() on any attribute without
risk of failure.

But if user reads picture and then sets attribute as binary data then
attribute.asPicture().isValid() will return false even if it was
correct picture buffer. After write - read operations picture will be

Attribute a(Picture);
assert(a.toPicture().isValid() == true);

Attribute b(a.toPicture());
assert(b.toPicture().isValid() == true);

Attribute c(a.toBinaryByteVector());
assert(c.toPicture().isValid() == false);

About fix.
File stores data as WORD (unsigned int32)
WORD fileStoredData;
int oldSize = (short)(unsigned short)fileStoredData; // gives negative
values when fileStoredData >= 0x8000
uint newSize = (unsigned short)fileStoredData; // correct

Tested on WinVista/Qt 4.6.3(mingw) dll

Before apply path to HEAD revision please check my spelling in doxygen comments.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: asfpics.patch
Type: application/octet-stream
Size: 14483 bytes
Desc: not available
Url : 

More information about the taglib-devel mailing list