summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-03 01:28:14 +0200
committerwm4 <wm4@nowhere>2013-06-03 22:40:07 +0200
commit13a1ce16f9581871cf7ac0d06ece407534a98f89 (patch)
treed6fd8ec1b24476af2473fc6bde57590ea6dfe6d6 /demux/demux.c
parent5d517184f5c294e6aba8e2d729fad7caa5db75b4 (diff)
downloadmpv-13a1ce16f9581871cf7ac0d06ece407534a98f89.tar.bz2
mpv-13a1ce16f9581871cf7ac0d06ece407534a98f89.tar.xz
sub: pass subtitle packets directly
Before this, subtitle packets were returned as data ptr/len pairs, and mplayer.c got the rest (pts and duration) directly from the demuxer data structures. Then mplayer.c reassembled the packet data structure again. Pass packets directly instead. The mplayer.c side stays a bit awkward, because the (now by default unused) DVD path keeps getting in the way. In demux.c there's lots of weird stuff (3 functions that read packets, really?), but we want to keep the code equivalent for now to avoid hitting weird issues and corner cases.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 12e0d9083a..25f31a3f60 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -801,20 +801,20 @@ int ds_get_packet_pts(demux_stream_t *ds, unsigned char **start, double *pts)
return len;
}
-int ds_get_packet_sub(demux_stream_t *ds, unsigned char **start)
+struct demux_packet *ds_get_packet_sub(demux_stream_t *ds)
{
- int len;
if (ds->buffer_pos >= ds->buffer_size) {
- *start = NULL;
if (!ds->packs)
- return -1; // no sub
+ return NULL; // no sub
if (!ds_fill_buffer(ds))
- return -1; // EOF
+ return NULL; // EOF
}
- len = ds->buffer_size - ds->buffer_pos;
- *start = &ds->buffer[ds->buffer_pos];
- ds->buffer_pos += len;
- return len;
+ if (ds->buffer_pos < ds->buffer_size) {
+ ds->current->buffer += ds->buffer_pos;
+ ds->buffer_size -= ds->buffer_pos;
+ }
+ ds->buffer_pos = ds->buffer_size;
+ return ds->current;
}
struct demux_packet *ds_get_packet2(struct demux_stream *ds, bool repeat_last)