From a5b51f75dc049b0713f4bb77cae4cb9e39ae8d49 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 24 Oct 2017 19:33:01 +0200 Subject: demux: get rid of demux_packet.new_segment field The new_segment field was used to track the decoder data flow handler of timeline boundaries, which are used for ordered chapters etc. (anything that sets demuxer_desc.load_timeline). This broke seeking with the demuxer cache enabled. The demuxer is expected to set the new_segment field after every seek or segment boundary switch, so the cached packets basically contained incorrect values for this, and the decoders were not initialized correctly. Fix this by getting rid of the flag completely. Let the decoders instead compare the segment information by content, which is hopefully enough. (In theory, two segments with same information could perhaps appear in broken-ish corner cases, or in an attempt to simulate looping, and such. I preferred the simple solution over others, such as generating unique and stable segment IDs.) We still add a "segmented" field to make it explicit whether segments are used, instead of doing something silly like testing arbitrary other segment fields for validity. Cached seeking with timeline stuff is still slightly broken even with this commit: the seek logic is not aware of the overlap that segments can have, and the timestamp clamping that needs to be performed in theory to account for the fact that a packet might contain a frame that is always clipped off by segment handling. This can be fixed later. --- demux/demux_timeline.c | 7 +------ demux/packet.c | 2 +- demux/packet.h | 6 +++--- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'demux') diff --git a/demux/demux_timeline.c b/demux/demux_timeline.c index 76bb106a7d..87cc1ce6d6 100644 --- a/demux/demux_timeline.c +++ b/demux/demux_timeline.c @@ -46,7 +46,6 @@ struct segment { struct virtual_stream { struct sh_stream *sh; // stream exported by demux_timeline bool selected; // ==demux_stream_is_selected(sh) - bool new_segment; // whether a new segment needs to be signaled int eos_packets; // deal with b-frame delay }; @@ -196,7 +195,6 @@ static void switch_segment(struct demuxer *demuxer, struct segment *new, for (int n = 0; n < p->num_streams; n++) { struct virtual_stream *vs = p->streams[n]; - vs->new_segment = true; vs->eos_packets = 0; } @@ -307,10 +305,7 @@ static int d_fill_buffer(struct demuxer *demuxer) } } - if (!p->dash) - pkt->new_segment |= vs->new_segment; - vs->new_segment = false; - + pkt->segmented = true; demux_add_packet(vs->sh, pkt); return 1; diff --git a/demux/packet.c b/demux/packet.c index ee49bd2acb..0a13b0e6a5 100644 --- a/demux/packet.c +++ b/demux/packet.c @@ -109,9 +109,9 @@ void demux_packet_copy_attribs(struct demux_packet *dst, struct demux_packet *sr dst->dts = src->dts; dst->duration = src->duration; dst->pos = src->pos; + dst->segmented = src->segmented; dst->start = src->start; dst->end = src->end; - dst->new_segment = src->new_segment; dst->codec = src->codec; dst->keyframe = src->keyframe; dst->stream = src->stream; diff --git a/demux/packet.h b/demux/packet.h index 884a7d8eab..866a27dfb5 100644 --- a/demux/packet.h +++ b/demux/packet.h @@ -36,9 +36,9 @@ typedef struct demux_packet { int stream; // source stream index // segmentation (ordered chapters, EDL) - struct mp_codec_params *codec; - double start, end; - bool new_segment; + bool segmented; + struct mp_codec_params *codec; // set to non-NULL iff segmented is set + double start, end; // set to non-NOPTS iff segmented is set // private struct demux_packet *next; -- cgit v1.2.3