mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 00:07:33 +00:00
demux: fix tracking of forward/backward cache size
Which parts of the queue are considered forward or backward cache
depends on ds->reader_header. The packet at ds->reader_head, as well as
all packets following it (via the ->next field) are considered forward.
The fw_packs/fw_bytes/bw_bytes must be updated accordingly.
This broke in demux_add_packet(), when ds->reader_head was _not_ set on
the first packet (or before). This could happen since commit
05ae571241
, which can require skipping packets (so they immediately end
up in the backbuffer).
This commit is contained in:
parent
56d9dafbbb
commit
3d71651523
@ -619,8 +619,21 @@ void demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
|
|||||||
dp->stream = stream->index;
|
dp->stream = stream->index;
|
||||||
dp->next = NULL;
|
dp->next = NULL;
|
||||||
|
|
||||||
|
// (keep in mind that even if the reader went out of data, the queue is not
|
||||||
|
// necessarily empty due to the backbuffer)
|
||||||
|
if (!ds->reader_head && (!ds->skip_to_keyframe || dp->keyframe)) {
|
||||||
|
ds->reader_head = dp;
|
||||||
|
ds->skip_to_keyframe = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t bytes = demux_packet_estimate_total_size(dp);
|
||||||
|
if (ds->reader_head) {
|
||||||
ds->fw_packs++;
|
ds->fw_packs++;
|
||||||
ds->fw_bytes += demux_packet_estimate_total_size(dp);
|
ds->fw_bytes += bytes;
|
||||||
|
} else {
|
||||||
|
ds->bw_bytes += bytes;
|
||||||
|
}
|
||||||
|
|
||||||
if (ds->queue_tail) {
|
if (ds->queue_tail) {
|
||||||
// next packet in stream
|
// next packet in stream
|
||||||
ds->queue_tail->next = dp;
|
ds->queue_tail->next = dp;
|
||||||
@ -629,12 +642,6 @@ void demux_add_packet(struct sh_stream *stream, demux_packet_t *dp)
|
|||||||
// first packet in stream
|
// first packet in stream
|
||||||
ds->queue_head = ds->queue_tail = dp;
|
ds->queue_head = ds->queue_tail = dp;
|
||||||
}
|
}
|
||||||
// (keep in mind that even if the reader went out of data, the queue is not
|
|
||||||
// necessarily empty due to the backbuffer)
|
|
||||||
if (!ds->reader_head && (!ds->skip_to_keyframe || dp->keyframe)) {
|
|
||||||
ds->reader_head = dp;
|
|
||||||
ds->skip_to_keyframe = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// (In theory it'd be more efficient to make this incremental.)
|
// (In theory it'd be more efficient to make this incremental.)
|
||||||
if (ds->back_pts == MP_NOPTS_VALUE && dp->keyframe)
|
if (ds->back_pts == MP_NOPTS_VALUE && dp->keyframe)
|
||||||
|
Loading…
Reference in New Issue
Block a user