summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-06-10 03:44:50 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:05 +0200
commit628abf53d1e8b9d2161620bdb81c41bf369adb03 (patch)
treea1889134491202d033e1f3d6c625ae22d0b6d98d /demux/demux.c
parentaa03ee73003404dd1a2b5199c87ad7dcfba30ce5 (diff)
downloadmpv-628abf53d1e8b9d2161620bdb81c41bf369adb03.tar.bz2
mpv-628abf53d1e8b9d2161620bdb81c41bf369adb03.tar.xz
demux: cache a value
Just for readability purposes. Although the field is mutable, it never changes within the function.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/demux/demux.c b/demux/demux.c
index 017f6c3cf7..70a72662c5 100644
--- a/demux/demux.c
+++ b/demux/demux.c
@@ -1551,18 +1551,19 @@ static void add_index_entry(struct demux_queue *queue, struct demux_packet *dp)
// try joining it into a single range.
static void attempt_range_joining(struct demux_internal *in)
{
+ struct demux_cached_range *current = in->current_range;
struct demux_cached_range *next = NULL;
double next_dist = INFINITY;
- assert(in->current_range && in->num_ranges > 0);
- assert(in->current_range == in->ranges[in->num_ranges - 1]);
+ assert(current && in->num_ranges > 0);
+ assert(current == in->ranges[in->num_ranges - 1]);
for (int n = 0; n < in->num_ranges - 1; n++) {
struct demux_cached_range *range = in->ranges[n];
- if (in->current_range->seek_start <= range->seek_start) {
+ if (current->seek_start <= range->seek_start) {
// This uses ">" to get some non-0 overlap.
- double dist = in->current_range->seek_end - range->seek_start;
+ double dist = current->seek_end - range->seek_start;
if (dist > 0 && dist < next_dist) {
next = range;
next_dist = dist;
@@ -1574,7 +1575,7 @@ static void attempt_range_joining(struct demux_internal *in)
return;
MP_VERBOSE(in, "going to join ranges %f-%f + %f-%f\n",
- in->current_range->seek_start, in->current_range->seek_end,
+ current->seek_start, current->seek_end,
next->seek_start, next->seek_end);
// Try to find a join point, where packets obviously overlap. (It would be
@@ -1586,7 +1587,7 @@ static void attempt_range_joining(struct demux_internal *in)
for (int n = 0; n < in->num_streams; n++) {
struct demux_stream *ds = in->streams[n]->ds;
- struct demux_queue *q1 = in->current_range->streams[n];
+ struct demux_queue *q1 = current->streams[n];
struct demux_queue *q2 = next->streams[n];
if (!ds->global_correct_pos && !ds->global_correct_dts) {
@@ -1658,7 +1659,7 @@ static void attempt_range_joining(struct demux_internal *in)
// data associated with the current range.
for (int n = 0; n < in->num_streams; n++) {
- struct demux_queue *q1 = in->current_range->streams[n];
+ struct demux_queue *q1 = current->streams[n];
struct demux_queue *q2 = next->streams[n];
struct demux_stream *ds = in->streams[n]->ds;
@@ -1712,15 +1713,13 @@ static void attempt_range_joining(struct demux_internal *in)
ds->refreshing = ds->selected;
}
- struct demux_cached_range *current = in->current_range;
-
for (int n = 0; n < next->num_metadata; n++) {
MP_TARRAY_APPEND(current, current->metadata, current->num_metadata,
next->metadata[n]);
}
next->num_metadata = 0;
- update_seek_ranges(in->current_range);
+ update_seek_ranges(current);
// Move demuxing position to after the current range.
in->seeking = true;