From 157531d91e9c5fbff33c4357beba5af31623f35c Mon Sep 17 00:00:00 2001 From: René Stadler Date: Sat, 28 Feb 2009 15:26:00 +0200 Subject: rgvolume: Improve log message for peak values >1.0 by clamping explicitly. --- gst/replaygain/gstrgvolume.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'gst/replaygain') diff --git a/gst/replaygain/gstrgvolume.c b/gst/replaygain/gstrgvolume.c index d569b4bb..cf5a914a 100644 --- a/gst/replaygain/gstrgvolume.c +++ b/gst/replaygain/gstrgvolume.c @@ -92,7 +92,7 @@ enum #define PEAK_FORMAT ".06f" #define VALID_GAIN(x) ((x) > -60.00 && (x) < 60.00) -#define VALID_PEAK(x) ((x) > 0. && (x) < 1.) +#define VALID_PEAK(x) ((x) > 0.) /* Same template caps as GstVolume, for I don't like having just ANY caps. */ @@ -563,6 +563,20 @@ gst_rg_volume_tag_event (GstRgVolume * self, GstEvent * event) has_album_peak = FALSE; } + /* Clamp peaks >1.0. Float based decoders can produce spurious samples >1.0, + * cutting these files back to 1.0 should not cause any audible distortion. + * This is most often seen with Vorbis files. */ + if (has_track_peak && self->track_peak > 1.) { + GST_DEBUG_OBJECT (self, + "clamping track peak %" PEAK_FORMAT " to 1.0", self->track_peak); + self->track_peak = 1.0; + } + if (has_album_peak && self->album_peak > 1.) { + GST_DEBUG_OBJECT (self, + "clamping album peak %" PEAK_FORMAT " to 1.0", self->album_peak); + self->album_peak = 1.0; + } + self->has_track_gain |= has_track_gain; self->has_track_peak |= has_track_peak; self->has_album_gain |= has_album_gain; -- cgit