# HG changeset patch # User nicodvb # Date 1176048941 0 # Node ID a60dbae6ee1d03d2d6cfc8cc996713cc5abd6a60 # Parent 09f2039f1113209ca06b8e04c6371a2d597ae7e2 added :interleaving2, a better method to determine which stream whouls be flushed at every iteration of the loop (based on the lowest percentage of buffer used - same algo as libavformat) diff -r 09f2039f1113 -r a60dbae6ee1d libmpdemux/muxer_mpeg.c --- a/libmpdemux/muxer_mpeg.c Sun Apr 08 15:30:01 2007 +0000 +++ b/libmpdemux/muxer_mpeg.c Sun Apr 08 16:15:41 2007 +0000 @@ -83,6 +83,7 @@ static int conf_vbuf_size = 0; static int conf_drop = 0; static int conf_telecine = 0; +static int conf_interleaving2 = 0; static float conf_telecine_src = 0; static float conf_telecine_dest = 0; @@ -204,6 +205,7 @@ {"drop", &conf_drop, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, 1, NULL}, {"tsaf", &conf_ts_allframes, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, 1, NULL}, {"telecine", &conf_telecine, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, PULLDOWN32, NULL}, + {"interleaving2", &conf_interleaving2, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, 1, NULL}, {"film2pal", &conf_telecine, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, TELECINE_FILM2PAL, NULL}, {"tele_src", &(conf_telecine_src), CONF_TYPE_FLOAT, M_OPT_GLOBAL, 0, 0, NULL}, {"tele_dest", &(conf_telecine_dest), CONF_TYPE_FLOAT, M_OPT_GLOBAL, 0, 0, NULL}, @@ -1286,8 +1288,10 @@ muxer_priv_t *priv = muxer->priv; muxer_headers_t *spriv; pack_stats_t p; + unsigned int perc, sperc; ndts = -1; + perc = -1; //THIS RULE MUST ALWAYS apply: dts <= SCR + 0.7 seconds for(i = 0; i < muxer->avih.dwStreams; i++) @@ -1307,6 +1311,16 @@ dts = spriv->framebuf[0].dts; ndts = i; } + + if(conf_interleaving2) + { + sperc = (spriv->track_bufsize * 1024) / spriv->max_buffer_size; + if(sperc < perc) + { + ndts = i; + perc = sperc; + } + } } return ndts;