[MPlayer-dev-eng] [PATCH] Ignore 0-len packets for muxer prebuffering

Tobias Diedrich ranma at tdiedrich.de
Thu Jun 23 23:26:13 CEST 2011


Reimar Döffinger wrote:
> The thing that is unclear is why we should change mencoder when it is
> libavformat that crashes with a division by 0.
> Also the description if "ignore packets of len 0" doesn't quite
> match what it does, it seems _all_ code is actually being run for
> them, only the muxbuf_seen flag (whatever that may do) is not set.
> In particular I suspect this means there's only a change of behaviour
> for initial 0-len packets.

I updated the patch description.
Even if the crash is fixed the muxer will still be missing necessary
information to write a useful header.
The problem was investigated because of the crashing problem, but
the fix is for the rootcause.  We shouldn't try to write the header
before we really have seen data for all the streams.

-- 
Tobias						PGP: http://8ef7ddba.uguu.de
-------------- next part --------------
We should ignore packets of len 0 for 'we have seen this stream' accounting
while prebuffering, otherwise the muxer may have seen all streams but not have
enough data to properly write the header.

This fixes an issue where the libavformat muxer could not determine the
image dimensions while writing the header and subsequently crash with
a divison by zero, which is caused by calling muxer_write_header too early.

Index: mplayer-vanilla/libmpdemux/muxer.c
===================================================================
--- mplayer-vanilla.orig/libmpdemux/muxer.c	2011-06-23 23:20:12.088356913 +0200
+++ mplayer-vanilla/libmpdemux/muxer.c	2011-06-23 23:21:24.446023857 +0200
@@ -121,7 +121,7 @@
 }
 
 /* buffer frames until we either:
- * (a) have at least one frame from each stream
+ * (a) have at least one non-empty frame from each stream
  * (b) run out of memory */
 void muxer_write_chunk(muxer_stream_t *s, size_t len, unsigned int flags, double dts, double pts) {
     if(dts == MP_NOPTS_VALUE) dts= s->timer;
@@ -154,7 +154,12 @@
         return;
       }
       memcpy(buf->buffer, s->buffer, buf->len);
-      s->muxbuf_seen = 1;
+
+      /* broken files can begin with len == 0 "repeat last frame" chunks,
+       * which don't contain useful headers for the muxer, wait until the
+       * first real frame is seen. */
+      if (len > 0)
+          s->muxbuf_seen = 1;
 
       /* see if we need to keep buffering */
       s->muxer->muxbuf_skip_buffer = 1;


More information about the MPlayer-dev-eng mailing list