Some time has passed and I am happily busy with rewriting MP3::Mplib
.
I was hoping to get away rather cheaply with this well written, cosy and cute mplib. But I wouldn't be me if I weren't bloating the whole thing quite severely. The thing is that the mplib is still not quite complete. Some id3v2 frames that I would like to support haven't get their own parsing and assemble functions so I decided to add them. This is a finger-snap for simple frames but left me rather baffled when trying to implement support for the APIC-frame (attached picture). The problem is that these data appear to be zlib-compressed when stored in an id3v2 tag. I didn't know that so naturally my functions returned garbage since they expected uncompressed data.
I had a look into zlib.h
and was rather compelled till I saw the compress()
function that simply takes two buffers and two integers (one being the length of the compressed input-data and the other the size of the uncompressed data which fortunately happens to be stored in the APIC-frame). So now MP3::Mplib
can extract whole pictures out of mp3-files which makes me quite excited.
The downside of it is that the depency list grows and now requires to have zlib installed (but this is probably not so uncommon on today's machines). But it worries me with respect to Windows machines. I have to add some means to check for the existence of zlib I think so that I can no-op the APIC-handling functions if they are not installed. Perhaps ExtUtils::MakeMaker
can help me.
I had a look into zlib.h and was rather compelled till I saw the compress() function
Any reason why you're not using Compress::Zlib rather than zlib directly? Are you currently doing the work in XS, rather than in perl?
Re:Compress::Zlib?
ethan on 2003-02-10T18:46:37
Any reason why you're not using Compress::Zlib [cpan.org] rather than zlib directly? Are you currently doing the work in XS, rather than in perl?
Yes, this module is pure XS and doesn't contain any Perl-code save for the stuff created by h2xs. I would have probably skipped to Compress::Zlib if doing it within the XS part hadn't worked. But fortunately it was rather painless.:-)