decoder/opus: fix track/album ReplayGain fallback
Fixes regression by commit 23d5a2b862
-
that commit always pretended that any Opus file has both track and
album gain, and thus disabled the fallback to the other if one is not
set.
This patch changes the logic to only submit ReplayGain if at least one
value is set, and apply the offset only to that value. If none is
available, then the new check in HandleAudio() will submit only the
output gain.
Closes https://github.com/MusicPlayerDaemon/MPD/issues/977
This commit is contained in:
parent
a0d43dd87f
commit
31268ad7cd
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
|||||||
ver 0.22.1 (not yet released)
|
ver 0.22.1 (not yet released)
|
||||||
* decoder
|
* decoder
|
||||||
- opus: apply the OpusHead output gain even if there is no EBU R128 tag
|
- opus: apply the OpusHead output gain even if there is no EBU R128 tag
|
||||||
|
- opus: fix track/album ReplayGain fallback
|
||||||
* output
|
* output
|
||||||
- alsa: don't deadlock when the ALSA driver is buggy
|
- alsa: don't deadlock when the ALSA driver is buggy
|
||||||
- jack, pulse: reduce the delay when stopping or pausing playback
|
- jack, pulse: reduce the delay when stopping or pausing playback
|
||||||
|
@ -268,7 +268,6 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
|
|||||||
{
|
{
|
||||||
ReplayGainInfo rgi;
|
ReplayGainInfo rgi;
|
||||||
rgi.Clear();
|
rgi.Clear();
|
||||||
rgi.track.gain = rgi.album.gain = EbuR128ToReplayGain(output_gain);
|
|
||||||
|
|
||||||
TagBuilder tag_builder;
|
TagBuilder tag_builder;
|
||||||
AddTagHandler h(tag_builder);
|
AddTagHandler h(tag_builder);
|
||||||
@ -276,8 +275,16 @@ MPDOpusDecoder::HandleTags(const ogg_packet &packet)
|
|||||||
if (!ScanOpusTags(packet.packet, packet.bytes, &rgi, h))
|
if (!ScanOpusTags(packet.packet, packet.bytes, &rgi, h))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
client.SubmitReplayGain(&rgi);
|
if (rgi.IsDefined()) {
|
||||||
submitted_replay_gain = true;
|
/* submit all valid EBU R128 values with output_gain
|
||||||
|
applied */
|
||||||
|
if (rgi.track.IsDefined())
|
||||||
|
rgi.track.gain += EbuR128ToReplayGain(output_gain);
|
||||||
|
if (rgi.album.IsDefined())
|
||||||
|
rgi.album.gain += EbuR128ToReplayGain(output_gain);
|
||||||
|
client.SubmitReplayGain(&rgi);
|
||||||
|
submitted_replay_gain = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tag_builder.empty()) {
|
if (!tag_builder.empty()) {
|
||||||
Tag tag = tag_builder.Commit();
|
Tag tag = tag_builder.Commit();
|
||||||
|
@ -61,7 +61,7 @@ ScanOneOpusTag(StringView name, StringView value,
|
|||||||
const char *endptr;
|
const char *endptr;
|
||||||
const auto l = ParseInt64(value, &endptr, 10);
|
const auto l = ParseInt64(value, &endptr, 10);
|
||||||
if (endptr > value.begin() && endptr == value.end())
|
if (endptr > value.begin() && endptr == value.end())
|
||||||
rgi->track.gain += float(l) / 256.0f;
|
rgi->track.gain = float(l) / 256.0f;
|
||||||
} else if (rgi != nullptr &&
|
} else if (rgi != nullptr &&
|
||||||
name.EqualsIgnoreCase("R128_ALBUM_GAIN")) {
|
name.EqualsIgnoreCase("R128_ALBUM_GAIN")) {
|
||||||
/* R128_ALBUM_GAIN is a Q7.8 fixed point number in
|
/* R128_ALBUM_GAIN is a Q7.8 fixed point number in
|
||||||
@ -70,7 +70,7 @@ ScanOneOpusTag(StringView name, StringView value,
|
|||||||
const char *endptr;
|
const char *endptr;
|
||||||
const auto l = ParseInt64(value, &endptr, 10);
|
const auto l = ParseInt64(value, &endptr, 10);
|
||||||
if (endptr > value.begin() && endptr == value.end())
|
if (endptr > value.begin() && endptr == value.end())
|
||||||
rgi->album.gain += float(l) / 256.0f;
|
rgi->album.gain = float(l) / 256.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.OnPair(name, value);
|
handler.OnPair(name, value);
|
||||||
|
Loading…
Reference in New Issue
Block a user