diff options
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux.c | 9 | ||||
-rw-r--r-- | demux/demux_edl.c | 4 | ||||
-rw-r--r-- | demux/demux_lavf.c | 33 |
3 files changed, 32 insertions, 14 deletions
diff --git a/demux/demux.c b/demux/demux.c index 4e1fb57c72..45a2ad65b6 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -1715,8 +1715,6 @@ static void prune_old_packets(struct demux_internal *in) } prev = prev->next; } - - update_seek_ranges(range); } bool done = false; @@ -1725,6 +1723,8 @@ static void prune_old_packets(struct demux_internal *in) remove_head_packet(queue); } + update_seek_ranges(range); + if (range != in->current_range && range->seek_start == MP_NOPTS_VALUE) free_empty_cached_ranges(in); } @@ -2100,12 +2100,17 @@ static struct replaygain_data *decode_rgain(struct mp_log *log, { struct replaygain_data rg = {0}; + // Set values in *rg, using track gain as a fallback for album gain if the + // latter is not present. This behavior matches that in demux/demux_lavf.c's + // export_replaygain; if you change this, please make equivalent changes + // there too. if (decode_gain(log, tags, "REPLAYGAIN_TRACK_GAIN", &rg.track_gain) >= 0 && decode_peak(log, tags, "REPLAYGAIN_TRACK_PEAK", &rg.track_peak) >= 0) { if (decode_gain(log, tags, "REPLAYGAIN_ALBUM_GAIN", &rg.album_gain) < 0 || decode_peak(log, tags, "REPLAYGAIN_ALBUM_PEAK", &rg.album_peak) < 0) { + // Album gain is undefined; fall back to track gain. rg.album_gain = rg.track_gain; rg.album_peak = rg.track_peak; } diff --git a/demux/demux_edl.c b/demux/demux_edl.c index b724ffa592..7f85568eae 100644 --- a/demux/demux_edl.c +++ b/demux/demux_edl.c @@ -80,8 +80,10 @@ static struct tl_parts *parse_edl(bstr str) { struct tl_parts *tl = talloc_zero(NULL, struct tl_parts); while (str.len) { - if (bstr_eatstart0(&str, "#")) + if (bstr_eatstart0(&str, "#")) { bstr_split_tok(str, "\n", &(bstr){0}, &str); + continue; + } if (bstr_eatstart0(&str, "\n") || bstr_eatstart0(&str, ";")) continue; bool is_header = bstr_eatstart0(&str, "!"); diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index ad71937580..8ec856d0c8 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2004 Michael Niedermayer <michaelni@gmx.at> + * Copyright (C) 2018 Google LLC * * This file is part of mpv. * @@ -588,17 +589,27 @@ static void export_replaygain(demuxer_t *demuxer, struct sh_stream *sh, av_rgain = (AVReplayGain*)src_sd->data; rgain = talloc_ptrtype(demuxer, rgain); - rgain->track_gain = (av_rgain->track_gain != INT32_MIN) ? - av_rgain->track_gain / 100000.0f : 0.0; - - rgain->track_peak = (av_rgain->track_peak != 0.0) ? - av_rgain->track_peak / 100000.0f : 1.0; - - rgain->album_gain = (av_rgain->album_gain != INT32_MIN) ? - av_rgain->album_gain / 100000.0f : 0.0; - - rgain->album_peak = (av_rgain->album_peak != 0.0) ? - av_rgain->album_peak / 100000.0f : 1.0; + // Set values in *rgain, using track gain as a fallback for album gain + // if the latter is not present. This behavior matches that in + // demux/demux.c's decode_rgain; if you change this, please make + // equivalent changes there too. + if (av_rgain->track_gain != INT32_MIN && av_rgain->track_peak != 0.0) { + // Track gain is defined. + rgain->track_gain = av_rgain->track_gain / 100000.0f; + rgain->track_peak = av_rgain->track_peak / 100000.0f; + + if (av_rgain->album_gain != INT32_MIN && + av_rgain->album_peak != 0.0) + { + // Album gain is also defined. + rgain->album_gain = av_rgain->album_gain / 100000.0f; + rgain->album_peak = av_rgain->album_peak / 100000.0f; + } else { + // Album gain is undefined; fall back to track gain. + rgain->album_gain = rgain->track_gain; + rgain->album_peak = rgain->track_peak; + } + } // This must be run only before the stream was added, otherwise there // will be race conditions with accesses from the user thread. |