[MPlayer-dev-eng] [PATCH] Maintain subtitles in pts order in spudec.c

Wolfram Gloger wmglo at dent.med.uni-muenchen.de
Sat Sep 24 21:28:40 CEST 2005


Hi!

I think subtitles in spudec.c should be maintained in start_pts order.

E.g. when detecting timestamps and substreams in demux_mpg_open(), a
subtitle from near the end of the input file can be read, which
subsequently "blocks" the list -- the first packet is never taken in
spudec_heartbeat().

Alternatively, demux_mpg_open() could at its end flush the queue with
spudec_reset(), but I think the following is also very simple and
preferable, because it is also tolerant against subtitles in the wrong
order in a broken input file.

Regards,
Wolfram.

diff -urb MPlayer-1.0pre7/spudec.c MPlayer-1.0pre7-wg/spudec.c
--- MPlayer-1.0pre7/spudec.c	Sat Jan  8 22:06:04 2005
+++ MPlayer-1.0pre7-wg/spudec.c	Fri Sep 23 14:19:29 2005
@@ -95,11 +95,22 @@
 
 static void spudec_queue_packet(spudec_handle_t *this, packet_t *packet)
 {
-  if (this->queue_head == NULL)
+  packet_t *last = 0, *p = this->queue_head;
+  while (p && p->start_pts<packet->start_pts) {
+    last = p;
+    p = p->next;
+  }
+  if (last) {
+    packet->next = last->next;
+    last->next = packet;
+    if (last == this->queue_tail)
+      this->queue_tail = packet;
+  } else {
+    packet->next = p;
     this->queue_head = packet;
-  else
-    this->queue_tail->next = packet;
+    if (!p)
   this->queue_tail = packet;
+  }
 }
 
 static packet_t *spudec_dequeue_packet(spudec_handle_t *this)




More information about the MPlayer-dev-eng mailing list