Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Can LAME encoding cause clipping that isn't present in FLAC source (Read 11005 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Can LAME encoding cause clipping that isn't present in FLAC source

On another forum a member made the claim that LAME encoded MP3s can create clipping where non-exists in the FLAC. This seemed pretty dubious to me, but he was able to back it up with some evidence. I was curious if this was common knowledge, or if anyone else had replicated this before. This was in a metal discussion forum, so we're talking about recordings that are pretty badly brickwalled to begin with, but according to DR don't clip. Here's his post:

Quote
Depending on the mastering of course modern recordings will sound better on LP than a lossy format; they preserve the soundstage and don't clip. A record like the FDR reissue of Bolt Thrower's Realm of Chaos which sounds great on CD and LP (same mastering) is way worse on MP3 as it causes clipping in every track. It's not completely clipped but it's still there and you can still tell if you know the record like the back of your hand. Not even going to get into soundstage and instrument separation. The quantization noise (distortion) caused by any codec randomly changes the peaks which can cause clipping if they are close to the limit. Thus you can master a release that sounds excellent lossless and like shit lossy. Modern recordings are much worse.

Here is an experiment I did this afternoon:

Bolt Thrower's Realm of Chaos, 2012 FDR CD
Not the best recorded album but decently mixed and mastered. The remastered 2012 CD is the best sounding version.
CD/FLAC DR meter results:
Code: [Select]
foobar2000 1.3.7 / Dynamic Range Meter 1.1.1
   log date: 2015-03-25 01:02:08
  
   --------------------------------------------------------------------------------
   Analyzed: Bolt Thrower / Realm of Chaos
   --------------------------------------------------------------------------------
  
   DR Peak RMS Duration Track
   --------------------------------------------------------------------------------
   DR9 -2.27 dB -15.03 dB 1:18 01-Intro
   DR10 -0.10 dB -11.31 dB 2:07 02-Eternal War
   DR11 -0.10 dB -12.28 dB 4:21 03-Through The Eye Of Terror
   DR10 -0.10 dB -10.68 dB 2:58 04-Dark Millenium
   DR10 -0.10 dB -10.92 dB 4:36 05-All That Remains
   DR11 -0.10 dB -11.66 dB 4:11 06-Lost Souls Domain
   DR10 -0.10 dB -11.20 dB 2:52 07-Plague Bearer
   DR11 -0.10 dB -11.71 dB 4:55 08-World Eater
   DR10 -0.10 dB -11.40 dB 3:03 09-Drowned In Torment
   DR9 -0.10 dB -10.64 dB 2:49 10-Realm Of Chaos
   DR9 -0.10 dB -10.57 dB 3:52 11-Prophet Of Hatred
   DR9 -2.56 dB -18.25 dB 1:00 12-Outro
   --------------------------------------------------------------------------------
  
   Number of tracks: 12
   Official DR value: DR10
  
   Samplerate: 44100 Hz
   Channels: 2
   Bits per sample: 16
   Bitrate: 457 kbps
   Codec: FLAC
   ================================================================================


V0:
Code: [Select]
foobar2000 1.3.8 / Dynamic Range Meter 1.1.1
   log date: 2015-04-04 13:47:44
  
   --------------------------------------------------------------------------------
   Analyzed: Bolt Thrower / Realm of Chaos
   --------------------------------------------------------------------------------
  
   DR Peak RMS Duration Track
   --------------------------------------------------------------------------------
   DR9 -2.29 dB -15.03 dB 1:18 01-Intro
   DR10 0.00 dB -11.30 dB 2:07 02-Eternal War
   DR11 0.00 dB -12.28 dB 4:21 03-Through The Eye Of Terror
   DR10 0.00 dB -10.68 dB 2:58 04-Dark Millenium
   DR10 0.00 dB -10.92 dB 4:36 05-All That Remains
   DR11 0.00 dB -11.66 dB 4:11 06-Lost Souls Domain
   DR10 0.00 dB -11.20 dB 2:52 07-Plague Bearer
   DR11 0.00 dB -11.71 dB 4:55 08-World Eater
   DR10 0.00 dB -11.40 dB 3:03 09-Drowned In Torment
   DR9 0.00 dB -10.63 dB 2:49 10-Realm Of Chaos
   DR9 0.00 dB -10.57 dB 3:52 11-Prophet Of Hatred
   DR9 -2.56 dB -18.25 dB 1:00 12-Outro
   --------------------------------------------------------------------------------
  
   Number of tracks: 12
   Official DR value: DR10
  
   Samplerate: 44100 Hz
   Channels: 2
   Bitrate: 213 kbps
   Codec: MP3
   ================================================================================


As we can see the codec clips every track but lets take a look at the waveform.

CD/FLAC lossless waveform of Plague Bearer

MP3 V0


Some clipped samples and it sounds worse of course but not the complete end of the world.

Now lets look at a more modern recording, Dead Congregation's Promulgation of the Fall. It was well recorded but undermixed and poorly mastered but thankfully not clipped. This isn't even close to the worst for modern metal; it's no Death Magnetic or The Flesh Prevails.

FLAC DR meter results:
Code: [Select]
foobar2000 1.3.8 / Dynamic Range Meter 1.1.1
   log date: 2015-04-04 14:36:10
  
   --------------------------------------------------------------------------------
   Analyzed: Dead Congregation / Promulgation of the Fall
   --------------------------------------------------------------------------------
  
   DR Peak RMS Duration Track
   --------------------------------------------------------------------------------
   DR5 -0.10 dB -6.12 dB 5:13 01-Only Ashes Remain
   DR6 -0.10 dB -7.32 dB 3:40 02-Promulgation of the Fall
   DR6 -0.10 dB -6.25 dB 5:33 03-Serpentskin
   DR6 -0.10 dB -6.65 dB 4:15 04-Quintessence Maligned
   DR5 -0.10 dB -6.17 dB 5:08 05-Immaculate Poison
   DR5 -0.10 dB -6.15 dB 5:00 06-Nigredo
   DR5 -0.10 dB -6.40 dB 7:18 07-Schisma
   DR5 -0.10 dB -6.28 dB 3:57 08-From a Wretched Womb
   --------------------------------------------------------------------------------
  
   Number of tracks: 8
   Official DR value: DR5
  
   Samplerate: 44100 Hz
   Channels: 2
   Bits per sample: 16
   Bitrate: 975 kbps
   Codec: FLAC
   ================================================================================



MP3 V0:
Code: [Select]
foobar2000 1.3.8 / Dynamic Range Meter 1.1.1
   log date: 2015-04-04 15:13:13
  
   --------------------------------------------------------------------------------
   Analyzed: Dead Congregation / Promulgation of the Fall
   --------------------------------------------------------------------------------
  
   DR Peak RMS Duration Track
   --------------------------------------------------------------------------------
   DR6 0.00 dB -6.12 dB 5:13 01-Only Ashes Remain
   DR6 0.00 dB -7.32 dB 3:40 02-Promulgation of the Fall
   DR6 0.00 dB -6.19 dB 5:33 03-Serpentskin
   DR6 0.00 dB -6.65 dB 4:15 04-Quintessence Maligned
   DR6 0.00 dB -6.17 dB 5:08 05-Immaculate Poison
   DR5 0.00 dB -6.14 dB 5:00 06-Nigredo
   DR5 0.00 dB -6.40 dB 7:18 07-Schisma
   DR6 0.00 dB -6.28 dB 3:57 08-From a Wretched Womb
   --------------------------------------------------------------------------------
  
   Number of tracks: 8
   Official DR value: DR6
  
   Samplerate: 44100 Hz
   Channels: 2
   Bitrate: 265 kbps
   Codec: MP3
   ================================================================================



Once again the codec clips every track. Onto an example waveform.

CD/FLAC lossless waveform of Only Ashes Remain

MP3 V0 lossy


LAME TOOK A DUMP ALL OVER THE RECORDING'S FACE.

[a href="http://imgur.com/a/tknik" rel="nofollow"]Link to imgur album.[/a]


Now, to me that seems like pretty compelling evidence but it's possible I'm missing something. The only piece of information I'm really curious about is what LAME encoder he's using, but I'm pretty sure it's going to be at least 3.98r.

Has anyone seen anything like this before? What would account for the massive clipping that's going on and the changes in Dynamic Range peaks? If the peak changes, why wouldn't the RMS as well?

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #1
On another forum a member made the claim that LAME encoded MP3s can create clipping where non-exists in the FLAC. This seemed pretty dubious to me, but he was able to back it up with some evidence. I was curious if this was common knowledge

It's decoding that can create clipping.

To summarize the important points...

When converting to mp3 or aac, the encoder won't change the volume of the files unless specifically instructed to do so (Lame has the --scale command, for instance).  However, it is possible for aac and mp3 to go beyond full-scale as it relates back to the lossless source and is a perfectly normal part of the lossy encoding process.  Internal to these lossy files, the data going beyond full-scale isn't actually clipped; it occurs upon decoding.  Whether or not this clipping is audible really depends on the samples being encoded.

In order to keep these lossy files from clipping, it is possible to lower their gain using a program like mp3gain (works with aac files as well).



It's quite easy to have clipping which is measurably present, but inaudible to most (sometimes all) people.

Of course, it's safer to avoid clipping at all - but if the original is basically clipped (as in much modern pop music) a little additional clipping is going to be very hard to detect.


Can LAME encoding cause clipping that isn't present in FLAC source

Reply #2
Ah, good to know... and I assumed something similar (I'm pretty skeptical of any audio encoding claim that doesn't come from this forum).

After reading those threads, would you assume that those tracks posted here (particularly the second one) were actually clipped at the source, and then scaled down to 0.1dB below peak so that the CD itself doesn't clip?

From greynol's post it sounds like using replayGain will prevent the tracks from clipping on playback. Is that correct?

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #3
Just to be sure:

Does decoding on a program like foobar2000 and enabling 24-bit output avoid the clipping?

AFAIK, the extra bits in the processing and output allow room for the "clipped" bits

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #4
Just to be sure:

Does decoding on a program like foobar2000 and enabling 24-bit output avoid the clipping?

AFAIK, the extra bits in the processing and output allow room for the "clipped" bits

No, the extra bits are added at the wrong end. Full scale is unchanged.

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #5
You need to decode to 32-bit float (and apply negative gain) to recover clipped parts.

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #6
would you assume that those tracks posted here (particularly the second one) were actually clipped at the source, and then scaled down to 0.1dB below peak so that the CD itself doesn't clip?

Can't tell at this zoom level. Zoom in and if you see some truly flat-topped mesas, then yes. If they're just really shallowly rounded, then it's just the result of a compressor/limiter with aggressive settings.

From greynol's post it sounds like using replayGain will prevent the tracks from clipping on playback. Is that correct?

If you apply ReplayGain to the MP3s, rather than just tag them with the volume info for a player to use, then yes. (Unless, of course, as greynol points out below, the ReplayGain adjustment insufficiently reduces the volume, or adds too much volume and thus induces clipping. ReplayGain implementations often have a clipping prevention option to handle the latter case.)

If you just tag the files, then it depends on the player. Ideally, the player will decode and apply ReplayGain and any other changes in the 32-bit floating-point domain, then convert to 16-bit or 24-bit integer at the output stage. foobar2000 does this, but Winamp does not (unless you use a custom input plugin that handles ReplayGain itself). Winamp's normal input plugins decode to 24-bit integer, so the ReplayGain-specified volume changes are applied to already-clipped material. I don't know what other ReplayGain-supporting players do.

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #7
From greynol's post it sounds like using replayGain will prevent the tracks from clipping on playback. Is that correct?

As was already mentioned, it depends on how the volume adjustment is implemented.

However, it also depends on how the player is configured, assuming there is a configuration option that prevents clipping.  This is also true when using a program to make changes to the gain within the file itself.

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #8
[a href="http://imgur.com/a/tknik" rel="nofollow"]http://imgur.com/a/tknik[/a]
Quote
The quantization noise (distortion) caused by LAME has altered some  peaks and clipped some samples near the limit as seen in red. The track  will sound noticeably worse

I see no evidence to support this assumption.

In fact, I'll just go a step farther and tell you it's bullshit.

and more cluelessness:
Quote
LAME has taken an ever flowing diarrhea dump all over the track's face.

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #9
he was able to back it up with some evidence.

If the something being backed up with evidence is that clipping can be introduced when decoding lossy, then yes.

If he is backing up the idea that there is audible degradation, then he is an idiot and you should simply ignore that page.

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #10
Most PC-based players will use floating point, so replaygain on playback will likely do the correct thing.  Integer-based decoders (such as the old libmad) may not however.

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #11
As was already mentioned in a quote from David, when we're dealing with compressed music, this is a non-issue.

The primary reason to use clipping prevention is to keep tracks that are too dynamic for the 89dB reference from clipping.  The original reference was 83dB which is more appropriate for things like classical music, acoustic jazz and other dramatic content.  Even then there is bound to be content for which even 83dB doesn't provide enough headroom.

Assuming that RG scaling is done in float, a metal album with even a somewhat reasonable correction value of -8dB relative to 89dB is never going to clip, even without the use of a clipping prevention feature.  Even if scaling isn't done in float, you'll have a very difficult time proving clipping upon decoding this album is audible, let alone objectionable, in light of exactly which portions of the audio are clipping.

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #12
I did not mean to imply that its audible.  In my experience, it is not, or at least, I have not succeeded in finding a good sample in my testing.  What I mean is that it is fairly difficult to have a replaygain implementation on PC that will not completely remove MP3 clipping during decode (audible or otherwise).

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #13
If the something being backed up with evidence is that clipping can be introduced when decoding lossy, then yes.

If he is backing up the idea that there is audible degradation, then "he" is an idiot and you should simply ignore that page.
I assumed the 2nd part was true (that it wouldn't be audible), but I didn't realize where that clipping was coming from... and it was obviously coming from somewhere. Even without RG I'd assume that it wouldn't be ABX-able from the original FLAC.


I did not mean to imply that its audible.  In my experience, it is not, or at least, I have not succeeded in finding a good sample in my testing.  What I mean is that it is fairly difficult to have a replaygain implementation on PC that will not completely remove MP3 clipping during decode (audible or otherwise).
I don't completely understand why this would be the case. Is it that the RG values are too "conservative?"

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #14
I did not mean to imply that its audible.  In my experience, it is not, or at least, I have not succeeded in finding a good sample in my testing.  What I mean is that it is fairly difficult to have a replaygain implementation on PC that will not completely remove MP3 clipping during decode (audible or otherwise).
I don't completely understand why this would be the case. Is it that the RG values are too "conservative?"


Because they use floating point math anyway, so clipping won't happen.  This has nothing to do with being conservative, I'm not sure what that is even referring to?

Can LAME encoding cause clipping that isn't present in FLAC source

Reply #15
Because they use floating point math anyway, so clipping won't happen.  This has nothing to do with being conservative, I'm not sure what that is even referring to?

Sorry, I missed the "not" in your sentence. I thought you were saying it was hard to have a RG implementation that completely removed clipping... and I was asking if it was because the RMS leveling didn't lower the level enough to completely prevent clipping. I was asking if RMS was too conservative compared to peak based leveling. But obviously none of that matters because that's not what you were saying at all.

Thanks for explaining this all to me guys.