mirror of https://github.com/mpv-player/mpv
Fix support for negative "delay:" directive in .idx file.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7418 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
9f35f61133
commit
14b3eae4b1
12
vobsub.c
12
vobsub.c
|
@ -5,6 +5,7 @@
|
||||||
/* #define HAVE_GETLINE */
|
/* #define HAVE_GETLINE */
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -470,7 +471,7 @@ vobsub_add_id(vobsub_t *vob, const char *id, size_t idlen, const unsigned int in
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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_queue_t *queue;
|
||||||
packet_t *pkt;
|
packet_t *pkt;
|
||||||
|
@ -482,7 +483,7 @@ vobsub_add_timestamp(vobsub_t *vob, off_t filepos, unsigned int ms)
|
||||||
if (packet_queue_grow(queue) >= 0) {
|
if (packet_queue_grow(queue) >= 0) {
|
||||||
pkt = queue->packets + (queue->packets_size - 1);
|
pkt = queue->packets + (queue->packets_size - 1);
|
||||||
pkt->filepos = filepos;
|
pkt->filepos = filepos;
|
||||||
pkt->pts100 = ms * 90;
|
pkt->pts100 = ms < 0 ? UINT_MAX : (unsigned int)ms * 90;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -711,7 +712,7 @@ vobsub_parse_delay(vobsub_t *vob, const char *line)
|
||||||
mp_msg(MSGT_VOBSUB,MSGL_V, "s=%d,", s);
|
mp_msg(MSGT_VOBSUB,MSGL_V, "s=%d,", s);
|
||||||
ms = atoi(line + 16);
|
ms = atoi(line + 16);
|
||||||
mp_msg(MSGT_VOBSUB,MSGL_V, "ms=%d", ms);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,6 +931,7 @@ vobsub_open(const char *const name,const char *const ifo,const int force,void**
|
||||||
mpg->pts + last_pts_diff;
|
mpg->pts + last_pts_diff;
|
||||||
}
|
}
|
||||||
pkt = queue->packets + queue->current_index;
|
pkt = queue->packets + queue->current_index;
|
||||||
|
if (pkt->pts100 != UINT_MAX) {
|
||||||
if (queue->packets_size > 1)
|
if (queue->packets_size > 1)
|
||||||
last_pts_diff = pkt->pts100 - mpg->pts;
|
last_pts_diff = pkt->pts100 - mpg->pts;
|
||||||
else
|
else
|
||||||
|
@ -942,6 +944,7 @@ vobsub_open(const char *const name,const char *const ifo,const int force,void**
|
||||||
mpg->packet_size = 0;
|
mpg->packet_size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
mp_msg(MSGT_VOBSUB,MSGL_WARN, "don't know what to do with subtitle #%u\n", sid);
|
mp_msg(MSGT_VOBSUB,MSGL_WARN, "don't know what to do with subtitle #%u\n", sid);
|
||||||
}
|
}
|
||||||
|
@ -978,12 +981,15 @@ vobsub_get_packet(void *vobhandle, float pts,void** data, int* timestamp) {
|
||||||
packet_queue_t *queue = vob->spu_streams + vobsub_id;
|
packet_queue_t *queue = vob->spu_streams + vobsub_id;
|
||||||
while (queue->current_index < queue->packets_size) {
|
while (queue->current_index < queue->packets_size) {
|
||||||
packet_t *pkt = queue->packets + queue->current_index;
|
packet_t *pkt = queue->packets + queue->current_index;
|
||||||
|
if (pkt->pts100 != UINT_MAX)
|
||||||
if (pkt->pts100 <= pts100) {
|
if (pkt->pts100 <= pts100) {
|
||||||
++queue->current_index;
|
++queue->current_index;
|
||||||
*data = pkt->data;
|
*data = pkt->data;
|
||||||
*timestamp = pkt->pts100;
|
*timestamp = pkt->pts100;
|
||||||
return pkt->size;
|
return pkt->size;
|
||||||
} else break;
|
} else break;
|
||||||
|
else
|
||||||
|
++queue->current_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue