[Mplayer-cvslog] CVS: main vobsub.c,1.1,1.2
Kim Minh Kaplan CVS
kmkaplan at mplayer.dev.hu
Thu Jan 10 21:12:14 CET 2002
- Previous message: [Mplayer-cvslog] CVS: main/libvo vo_fbdev.c,1.50,1.51
- Next message: [Mplayer-cvslog] CVS: main/libmp1e Makefile,1.1,1.2 b_mp1e.c,1.1,1.2 global_data.c,1.2,1.3 libmp1e.h,1.2,1.3 main.h,1.1,1.2 options.h,1.1,1.2 rte.c,1.2,1.3 rtepriv.h,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv20321
Modified Files:
vobsub.c
Log Message:
Support vobsub without index files.
Fix off by one bug.
Index: vobsub.c
===================================================================
RCS file: /cvsroot/mplayer/main/vobsub.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- vobsub.c 10 Jan 2002 17:14:55 -0000 1.1
+++ vobsub.c 10 Jan 2002 20:12:12 -0000 1.2
@@ -379,7 +379,7 @@
/* XXX packet_size does not reflect the real thing here, it will be updated a bit later */
memmove(queue->packets + queue->current_index + 2,
queue->packets + queue->current_index + 1,
- sizeof(packet_t) * (queue->packets_size - queue->current_index));
+ sizeof(packet_t) * (queue->packets_size - queue->current_index - 1));
pkts = queue->packets + queue->current_index;
++queue->packets_size;
++queue->current_index;
@@ -402,15 +402,16 @@
unsigned int spu_streams_current;
} vobsub_t;
+/* Make sure that the spu stream idx exists. */
static int
-vobsub_add_id(vobsub_t *vob, const char *id, size_t idlen, const unsigned int index)
+vobsub_ensure_spu_stream(vobsub_t *vob, unsigned int index)
{
if (index >= vob->spu_streams_size) {
/* This is a new stream */
if (vob->spu_streams) {
packet_queue_t *tmp = realloc(vob->spu_streams, (index + 1) * sizeof(packet_queue_t));
if (tmp == NULL) {
- perror("vobsub_add_id: realloc failure");
+ perror("vobsub_ensure_spu_stream: realloc failure");
return -1;
}
vob->spu_streams = tmp;
@@ -418,7 +419,7 @@
else {
vob->spu_streams = malloc((index + 1) * sizeof(packet_queue_t));
if (vob->spu_streams == NULL) {
- perror("vobsub_add_id: malloc failure");
+ perror("vobsub_ensure_spu_stream: malloc failure");
return -1;
}
}
@@ -427,6 +428,14 @@
++vob->spu_streams_size;
}
}
+ return 0;
+}
+
+static int
+vobsub_add_id(vobsub_t *vob, const char *id, size_t idlen, const unsigned int index)
+{
+ if (vobsub_ensure_spu_stream(vob, index) < 0)
+ return -1;
if (id && idlen) {
if (vob->spu_streams[index].id)
free(vob->spu_streams[index].id);
@@ -667,8 +676,6 @@
perror("Can't open SUB file");
else {
long last_pts_diff = 0;
- if (vob->spu_streams == NULL)
- abort();
while (!mpeg_eof(mpg)) {
off_t pos = mpeg_tell(mpg);
if (mpeg_run(mpg) < 0) {
@@ -679,9 +686,11 @@
if (mpg->packet_size) {
if ((mpg->aid & 0xe0) == 0x20) {
unsigned int sid = mpg->aid & 0x1f;
- if (vob->spu_streams_size > sid) {
+ if (vobsub_ensure_spu_stream(vob, sid) >= 0) {
packet_queue_t *queue = vob->spu_streams + sid;
/* get the packet to fill */
+ if (queue->packets_size == 0 && packet_queue_grow(queue) < 0)
+ abort();
while (queue->current_index + 1 < queue->packets_size
&& queue->packets[queue->current_index + 1].filepos <= pos)
++queue->current_index;
- Previous message: [Mplayer-cvslog] CVS: main/libvo vo_fbdev.c,1.50,1.51
- Next message: [Mplayer-cvslog] CVS: main/libmp1e Makefile,1.1,1.2 b_mp1e.c,1.1,1.2 global_data.c,1.2,1.3 libmp1e.h,1.2,1.3 main.h,1.1,1.2 options.h,1.1,1.2 rte.c,1.2,1.3 rtepriv.h,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the MPlayer-cvslog
mailing list