Album Art using Taglib

pranay prateek pranay.iitm at gmail.com
Thu Nov 26 06:59:57 CET 2009


Hi all
I am trying to use TagLib to extract album art from audio files. I am
building this app for WINCE 6.0 using c++ and Visual Studio 2005 IDE.
As of now, i am just trying to test it on  mp3 files. If i include all the
files from mpeg, toolkit and ape folders, i am able to compile my project.
But, at runtime  it gives an unhandled exception error for some mp3 files,
while it runs fine for other mp3 files.

The unhandled exception occurs at

ref() function in RefCounter class

called by

ByteVector::ByteVector(const ByteVector &v) : d(v.d)
{
   d->ref();
}

It seems the *this* pointer in the ref function called is NULL which is
seemingly causing the problem.

My main issue is how is this working for some MP3 files while not working
for others? Does it depend upon some parameter present in MP3
files which may not be present in other MP3 files?
Also, i searched the documentation but couldn't find out what actually is
the RefCounter class doing. Why is it being called so many times?

Can somebody give me pointers on how this issue could be resolved?
Thanks.

Regards
Pranay



My code is something like this:

int main()
{

static const char *IdPicture = "APIC" ;

TagLib::MPEG::File mpegFile("\\Storage Card\\YeDooriyan.mp3");
TagLib::ID3v2::Tag *id3v2tag = mpegFile.ID3v2Tag();
TagLib::ID3v2::FrameList Frame ;
TagLib::ID3v2::AttachedPictureFrame *PicFrame ;
void *RetImage = NULL, *SrcImage ;
unsigned long Size ;

FILE *jpegFile;
fopen_s(&jpegFile,"FromId3.jpg","wb");


  if ( id3v2tag )
  {
    // picture frame
    Frame = id3v2tag->frameListMap()[IdPicture] ;

    if (!Frame.isEmpty() )
    {
      // find cover art
for(TagLib::ID3v2::FrameList::ConstIterator it = Frame.begin(); it !=
Frame.end(); ++it)
      {
  PicFrame = (TagLib::ID3v2::AttachedPictureFrame *)(*it) ;
        if ( PicFrame->type() ==
TagLib::ID3v2::AttachedPictureFrame::FrontCover)
        {
          // extract image (in it's compressed form)
          Size = PicFrame->picture().size() ;
          SrcImage = malloc ( Size ) ;
          if ( SrcImage )
          {
            memcpy ( SrcImage, PicFrame->picture().data(), Size ) ;
fwrite(SrcImage,Size,1, jpegFile);
fclose(jpegFile);

            free( SrcImage ) ;
          }
          if ( RetImage )
            break ;
        }
      }
    }
  }
return(0);

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/taglib-devel/attachments/20091126/e1f7650e/attachment.htm 


More information about the taglib-devel mailing list