[mythtv] mythmusic/libavcodec/libavformat (patches to fix)

Mark Weaver mark-clist at npsl.co.uk
Thu Aug 18 21:28:08 UTC 2005


Mark Weaver wrote:
> I recently tried running mythmusic over a large collection of WMA files, 
> and it eats a lot of memory.  Root cause is probably this:
 >
> if av_find_stream_info fails then the file is not closed.  This exists 
> in current CVS and is easy enough to fix.
> 
The attached mythmusic.patch corrects this.

> 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 
This was wrong, you don't get an error if it stops munching the file 
because a prefined byte limit (5e6 bytes) has been hit.  In fact, this 
function just looks plain broken: it is trying to determine a stream 
length, and will report failure unless it does so, but all of the code 
that actually looks for a stream length only works if it is dealing with 
a video.

I have dealt with this by taking the stream length from the header 
information if available which seemed like a sensible approach -- see 
libavformat.patch.  (WMA files have the stream length in the header so 
this works for me).  Hopefully it doesn't break anything else.

Finally I have attached a patch against libavcodec that has already been 
applied to ffpmeg's main tree which corrects an audio glitch in certain 
WMA files -- I would be most happy if this gets into mythtv's copy to 
save me building from source!

Thanks,

Mark
-------------- next part --------------
diff -ur -x '*.o' -x Makefile -x 'moc_*' -x 'config.*' -x '*.so' /usr/src/mythplugins-0.18.1/mythmusic/mythmusic/avfdecoder.cpp mythmusic/avfdecoder.cpp
--- /usr/src/mythplugins-0.18.1/mythmusic/mythmusic/avfdecoder.cpp	2005-02-23 20:41:07.000000000 +0000
+++ mythmusic/avfdecoder.cpp	2005-08-17 16:33:01.000000000 +0100
@@ -142,8 +142,10 @@
 
     // determine the stream format
     // this also populates information needed for metadata
-    if (av_find_stream_info(ic) < 0) 
+    if (av_find_stream_info(ic) < 0) {
+        av_close_input_file(ic);
         return FALSE;
+    }
 
     // Store the audio codec of the stream
     audio_dec = &ic->streams[0]->codec;
diff -ur -x '*.o' -x Makefile -x 'moc_*' -x 'config.*' -x '*.so' /usr/src/mythplugins-0.18.1/mythmusic/mythmusic/metaioavfcomment.cpp mythmusic/metaioavfcomment.cpp
--- /usr/src/mythplugins-0.18.1/mythmusic/mythmusic/metaioavfcomment.cpp	2005-02-06 18:27:45.000000000 +0000
+++ mythmusic/metaioavfcomment.cpp	2005-08-17 16:33:31.000000000 +0100
@@ -64,8 +64,10 @@
                            p_inputformat, 0, p_params) < 0)
         return NULL;
         
-    if (av_find_stream_info(p_context) < 0)
+    if (av_find_stream_info(p_context) < 0) {
+        av_close_input_file(p_context);
         return NULL;
+    }
 
     
     title += (char *)p_context->title;
@@ -116,8 +118,10 @@
                            p_inputformat, 0, p_params) < 0)
         return 0;
         
-    if (av_find_stream_info(p_context) < 0)
+    if (av_find_stream_info(p_context) < 0) {
+        av_close_input_file(p_context);
         return 0;
+    }
 
     int rv = getTrackLength(p_context);
     
-------------- next part --------------
diff -ur -x '*.o' -x Makefile -x 'libmythavformat-0.18*' /usr/src/mythtv-0.18.1/libs/libavformat/utils.c libavformat/utils.c
--- /usr/src/mythtv-0.18.1/libs/libavformat/utils.c	2005-05-15 00:46:45.000000000 +0100
+++ libavformat/utils.c	2005-08-17 16:23:34.000000000 +0100
@@ -1769,7 +1769,10 @@
 
     for(i=0;i<MAX_STREAMS;i++){
         last_dts[i]= AV_NOPTS_VALUE;
-        best_duration[i]= INT64_MAX;
+	if (i < ic->nb_streams && st->duration != AV_NOPTS_VALUE)
+	  best_duration[i] = st->duration;
+	else
+	  best_duration[i] = INT64_MAX;
     }
 
     count = 0;
Only in libavformat/: utils_orig.c
-------------- next part --------------
diff -ur -x '*.o' -x Makefile -x 'libmythavcodec-0.18*' /usr/src/mythtv-0.18.1/libs/libavcodec/wmadec.c libavcodec/wmadec.c
--- /usr/src/mythtv-0.18.1/libs/libavcodec/wmadec.c	2005-01-08 06:32:42.000000000 +0000
+++ libavcodec/wmadec.c	2005-08-17 16:21:34.000000000 +0100
@@ -48,7 +48,7 @@
 #define NB_LSP_COEFS 10
 
 /* XXX: is it a suitable value ? */
-#define MAX_CODED_SUPERFRAME_SIZE 4096
+#define MAX_CODED_SUPERFRAME_SIZE 16384
 
 #define MAX_CHANNELS 2
 
Only in libavcodec/: wmadec_orig.c


More information about the mythtv-dev mailing list