[mythtv] mythmusic/libavcodec/libavformat

Mark Weaver mark-clist at npsl.co.uk
Wed Aug 17 14:23:05 UTC 2005

I recently tried running mythmusic over a large collection of WMA files, 
and it eats a lot of memory.  Root cause is probably this:

Metadata* MetaIOAVFComment::read(QString filename)
     if (av_open_input_file(&p_context, filename.local8Bit(),
                            p_inputformat, 0, p_params) < 0
         && av_open_input_file(&p_context, filename.ascii(),
                            p_inputformat, 0, p_params) < 0)
         return NULL;

     if (av_find_stream_info(p_context) < 0)
         return NULL;

if av_find_stream_info fails then the file is not closed.  This exists 
in current CVS and is easy enough to fix.

av_find_stream_info fails for some WMA files that I have (although 
mplayer munches through them without issues).  It appears that there are 
a few extra bytes on the end of some files (looks like interframe 
padding with no following frame, but I'm not familiar enough with WMA to 
be sure, perhaps someone can point me in the right direction).  This 
looks fairly common from the number of files it fails on.

I dug around and the high memory usage seems to be because 
av_find_stream_info loads the entire audio stream into memory (very 
useful?!) -- that whole lot gets leaked.

I'm looking at what the right way is to get this function to ignore the 
extra bytes.  The stream info is parsed just fine (author, title) etc so 
I'm assuming that it shouldn't be reporting an error in this case.  Not 
quite clear on why this is yet.  If anyone knows, that would be very 
helpful, otherwise I'll keep digging.



More information about the mythtv-dev mailing list