changeset 29768:fa5a020677d6

Unbreak the demuxer-specific code in video.c with e.g. -audiofile by moving the code to manually interleave subtitles to mp_common.c. video.c should still be changed to not be demuxer-specific anymore, it is bad practice but fully fixing it is non-trivial.
author reimar
date Sun, 01 Nov 2009 09:48:34 +0000
parents 4ef0bfc7c0a9
children 3fd86d75ee46
files libmpdemux/demux_demuxers.c libmpdemux/demuxer.h mpcommon.c
diffstat 3 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_demuxers.c	Sat Oct 31 15:34:18 2009 +0000
+++ b/libmpdemux/demux_demuxers.c	Sun Nov 01 09:48:34 2009 +0000
@@ -54,9 +54,15 @@
   ret->video = vd->video;
   ret->audio = ad->audio;
   ret->sub = sd->sub;
+  if (sd && sd != vd && sd != ad) sd->sub->non_interleaved = 1;
+
+  // without these, demux_demuxers_fill_buffer will never be called,
+  // but they break the demuxer-specific code in video.c
+#if 0
   if (vd) vd->video->demuxer = ret;
   if (ad) ad->audio->demuxer = ret;
   if (sd) sd->sub->demuxer = ret;
+#endif
 
   // HACK?, necessary for subtitle (and audio and video when implemented) switching
   memcpy(ret->v_streams, vd->v_streams, sizeof(ret->v_streams));
--- a/libmpdemux/demuxer.h	Sat Oct 31 15:34:18 2009 +0000
+++ b/libmpdemux/demuxer.h	Sun Nov 01 09:48:34 2009 +0000
@@ -142,6 +142,8 @@
   off_t dpos;                // position in the demuxed stream
   int pack_no;		   // serial number of packet
   int flags;               // flags of current packet (keyframe etc)
+  int non_interleaved;     // 1 if this stream is not properly interleaved,
+                           // so e.g. subtitle handling must do explicit reads.
 //---------------
   int packs;              // number of packets in buffer
   int bytes;              // total bytes of packets in buffer
--- a/mpcommon.c	Sat Oct 31 15:34:18 2009 +0000
+++ b/mpcommon.c	Sun Nov 01 09:48:34 2009 +0000
@@ -145,6 +145,8 @@
     } else if (dvdsub_id >= 0 && (type == 't' || type == 'm' || type == 'a')) {
         double curpts = refpts + sub_delay;
         double endpts;
+        if (d_dvdsub->non_interleaved)
+            ds_get_next_pts(d_dvdsub);
         while (d_dvdsub->first) {
             double subpts = ds_get_next_pts(d_dvdsub);
             if (subpts > curpts)
@@ -195,6 +197,8 @@
                 sub_add_text(&subs, packet, len, endpts);
                 set_osd_subtitle(&subs);
             }
+            if (d_dvdsub->non_interleaved)
+                ds_get_next_pts(d_dvdsub);
         }
         if (sub_clear_text(&subs, curpts))
             set_osd_subtitle(&subs);