1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-27 01:22:30 +00:00

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.
This commit is contained in:
wm4 2013-06-03 01:28:14 +02:00
parent 5d517184f5
commit 13a1ce16f9
3 changed files with 18 additions and 21 deletions

View File

@ -1885,18 +1885,15 @@ static void update_subtitles(struct MPContext *mpctx, double refpts_tl)
if (non_interleaved && subpts_s > curpts_s + 1)
break;
}
double duration = d_sub->first->duration;
unsigned char *packet = NULL;
int len = ds_get_packet_sub(d_sub, &packet);
struct demux_packet pkt;
struct demux_packet *orig = ds_get_packet_sub(d_sub);
if (!orig)
break;
pkt = *orig;
pkt.pts = subpts_s;
mp_dbg(MSGT_CPLAYER, MSGL_V, "Sub: c_pts=%5.3f s_pts=%5.3f "
"duration=%5.3f len=%d\n", curpts_s, subpts_s, duration,
len);
struct demux_packet pkt = {
.buffer = packet,
.len = len,
.pts = subpts_s,
.duration = duration,
};
"duration=%5.3f len=%d\n", curpts_s, pkt.pts, pkt.duration,
pkt.len);
sub_decode(dec_sub, &pkt);
}
}

View File

@ -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)

View File

@ -344,7 +344,7 @@ void ds_free_packs(struct demux_stream *ds);
int ds_get_packet(struct demux_stream *ds, unsigned char **start);
int ds_get_packet_pts(struct demux_stream *ds, unsigned char **start,
double *pts);
int ds_get_packet_sub(struct demux_stream *ds, unsigned char **start);
struct demux_packet *ds_get_packet_sub(demux_stream_t *ds);
struct demux_packet *ds_get_packet2(struct demux_stream *ds, bool repeat_last);
double ds_get_next_pts(struct demux_stream *ds);
int ds_parse(struct demux_stream *sh, uint8_t **buffer, int *len, double pts,