diff options
-rw-r--r-- | core/mplayer.c | 19 | ||||
-rw-r--r-- | demux/demux.c | 18 | ||||
-rw-r--r-- | demux/demux.h | 2 |
3 files changed, 18 insertions, 21 deletions
diff --git a/core/mplayer.c b/core/mplayer.c index 353723930c..80ddd43f95 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -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); } } 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) diff --git a/demux/demux.h b/demux/demux.h index e58c56141f..9ec6d0c6f0 100644 --- a/demux/demux.h +++ b/demux/demux.h @@ -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, |