changeset 7417:c477dae38383

Fix support for negative "delay:" directive in .idx file.
author kmkaplan
date Mon, 16 Sep 2002 15:31:34 +0000
parents de28a4cb3d9d
children 2f6fd8f05bc8
files vobsub.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/vobsub.c	Mon Sep 16 13:59:54 2002 +0000
+++ b/vobsub.c	Mon Sep 16 15:31:34 2002 +0000
@@ -5,6 +5,7 @@
 /* #define HAVE_GETLINE */
 #include <ctype.h>
 #include <errno.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -470,7 +471,7 @@
 }
 
 static int
-vobsub_add_timestamp(vobsub_t *vob, off_t filepos, unsigned int ms)
+vobsub_add_timestamp(vobsub_t *vob, off_t filepos, int ms)
 {
     packet_queue_t *queue;
     packet_t *pkt;
@@ -482,7 +483,7 @@
     if (packet_queue_grow(queue) >= 0) {
 	pkt = queue->packets + (queue->packets_size - 1);
 	pkt->filepos = filepos;
-	pkt->pts100 = ms * 90;
+	pkt->pts100 = ms < 0 ? UINT_MAX : (unsigned int)ms * 90;
 	return 0;
     }
     return -1;
@@ -711,7 +712,7 @@
     mp_msg(MSGT_VOBSUB,MSGL_V, "s=%d,", s);
     ms = atoi(line + 16);
     mp_msg(MSGT_VOBSUB,MSGL_V, "ms=%d", ms);
-    vob->delay = ms + 1000 * (s + 60 * (m + 60 * h)) * forward;
+    vob->delay = (ms + 1000 * (s + 60 * (m + 60 * h))) * forward;
     return 0;
 }
 
@@ -930,6 +931,7 @@
 					    mpg->pts + last_pts_diff;
 				    }
 				    pkt = queue->packets + queue->current_index;
+				    if (pkt->pts100 != UINT_MAX) {
 				    if (queue->packets_size > 1)
 					last_pts_diff = pkt->pts100 - mpg->pts;
 				    else
@@ -940,6 +942,7 @@
 				    mpg->packet = NULL;
 				    mpg->packet_reserve = 0;
 				    mpg->packet_size = 0;
+				    }
 				}
 			    }
 			    else
@@ -978,12 +981,15 @@
     packet_queue_t *queue = vob->spu_streams + vobsub_id;
     while (queue->current_index < queue->packets_size) {
       packet_t *pkt = queue->packets + queue->current_index;
+      if (pkt->pts100 != UINT_MAX)
       if (pkt->pts100 <= pts100) {
 	++queue->current_index;
 	*data = pkt->data;
 	*timestamp = pkt->pts100;
 	return pkt->size;
       } else break;
+      else
+	  ++queue->current_index;
     }
   }
   return -1;