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: WavPack seems to compress upsampled or upscaled audio much better than FLAC (Read 1536 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

WavPack seems to compress upsampled or upscaled audio much better than FLAC

I did a quick internet search but I've been unable to locate any information on the subject, so I figured I'd just quickly share my finding here.

Basically, if you're dealing with upsampled or upscaled lossless audio for whatever reason, it seems that WavPack (at least when set to the absolute maximum non-hybrid lossless compression in foobar2000) can produce substantially smaller file sizes than FLAC (e.g. 20MB WavPack vs 30MB FLAC).


First off, yes, I know that upsampling or upscaling does not increase audio quality - the main reason I'm upsampling at all in the first place is because a lot of retro video games can have some really weird non-standard sampling rates (Mario Kart 64 and Donkey Kong 64 both come to mind as using rates that aren't even just slightly off from more standard rates like many other N64 games do where you can instead just slightly change the playback sample rate to a more standard one without resampling).

But the jist is that, regardless of whether just the sampling rate is upsampled or just the bit depth is upscaled, you're pretty much always going to see double-digit gains with WavPack vs FLAC - I've seen upwards of a 50% gain with WavPack when both upsampling and upscaling are involved at identical fidelity (e.g. 20MB WavPack vs 30MB FLAC).

This can also be especially useful for archiving certain audio editing/mixing projects in that 32float WavPack seems to take up roughly the same size as 24bit FLAC at a given sampling rate.


So yeah, I just wanted to "let the internet know" this protip that I discovered on my own in the last year or so.


EDIT: On a somewhat related note, I think multi-channel surround audio also compresses substantially better as WavPack vs FLAC? I have much less experience with this however, so don't go quoting me on that, but it could be something that people more experienced with such things could look into if they care.

Re: WavPack seems to compress upsampled or upscaled audio much better than FLAC

Reply #1
I did a quick internet search but I've been unable to locate any information on the subject, so I figured I'd just quickly share my finding here.

Basically, if you're dealing with upsampled or upscaled lossless audio for whatever reason, it seems that WavPack (at least when set to the absolute maximum non-hybrid lossless compression in foobar2000) can produce substantially smaller file sizes than FLAC (e.g. 20MB WavPack vs 30MB FLAC).

Yes, this will be "fixed" in the next release of FLAC. There has been some discussion here. Long story short: upsampled material has no high-frequency content, and FLACs analysis method had problems producing a good predictor because of rounding errors. The next release will use higher precision in LPC analysis and this specifically improves performance *a lot* on upsampled material. On normal audio (CDDA) improvement is small and dependent on what kind of audio it is, between 0 and 0.5%. For material of which the higher frequencies are 'missing', gains of over 30% have been seen.

Quote
EDIT: On a somewhat related note, I think multi-channel surround audio also compresses substantially better as WavPack vs FLAC? I have much less experience with this however, so don't go quoting me on that, but it could be something that people more experienced with such things could look into if they care.
See a multichannel performance comparison of lossless audio codecs here. The WavPack formats provides for interchannel decorrelation for multichannel audio while FLAC only does that only for stereo audio, which means WavPack can indeed perform much better there.
Music: sounds arranged such that they construct feelings.

Re: WavPack seems to compress upsampled or upscaled audio much better than FLAC

Reply #2
WavPack (at least when set to the absolute maximum non-hybrid lossless compression in foobar2000)

(That is -hhx6. And it takes looong time encoding.)

I did some preliminary testing at https://hydrogenaud.io/index.php?topic=120454.0 . If you consider -x4 and compare the improvement it does on high resolution material compared to the improvement it does to CDDA, then an educated guess is that the following has been going on - and not only with WavPack:
* Codecs have a basic algorithm, and then each of them have been tested by feeding it real music and tuned according to what actually improved.
* ... this in a time where there wasn't much high resolution audio. So they have effectively been developed for CDDA and well maybe 48 kHz signals.
* To the extent that high resolution audio works different, you might have luck that the codec tweakings work with it, or you might be out of luck ...
* ... but more "brute force" is more likely to catch what "clever engineering on CDDA" misses.

Now WavPack -x4, -x5, -x6 build their filters from scratch without "pre-conceived notions on what music is alike" - the developer explains that in a slightly different context at https://hydrogenaud.io/index.php/topic,121770.msg1005432.html#msg1005432 .  So -x4 to -x6 are "gloves off, torture the signal until it confesses its secrets".
-x4 was included in ktf's lossless testing this year. He has linked to the multi-channel results, but also have a look at the high resolution results; -x4 does very well (compared to how it does to CDDA), but it is costly. That supports the idea that FLAC, Monkey's and WavPack without high x-es have done "clever engineering on CDDA".
Note in particular Monkey's: It has five settings, and for each the encoded data stream is the same as fifteen years ago. Different compiles and versions of FLAC will - at the same parameters! - produce different encoded data (that decode to the same, that's losslessness); if you take a Monkey's "High" file from 3.99 and a Monkey's "High" file from a 2022 build, they are bit by bit the same except metadata. That is why the high resolution material fools Monkey's into producing larger "High" than normal and larger "Insane" than "Extra High" - it is frozen in time to what was developed on CDDA. FLAC works different. WavPack "something in between", it seems.


By the way, I tested something else than the usual high-resolution material: https://hydrogenaud.io/index.php/topic,122056.0.html
What I did was to just hack a PCM stream into specifying a higher sampling rate - effectively just transposing octaves up, rather than resampling. Then the PCM bits are the same as the original. That means they could be compressed to the same size, right? Monkey's and OptimFROG do precisely that. Reference flac.exe does nearly measure to same size - but ffmpeg's flac encoder and CUETools.Flake do produce different sizes.
But this is "weird" high-rez.

Re: WavPack seems to compress upsampled or upscaled audio much better than FLAC

Reply #3
What I did was to just hack a PCM stream into specifying a higher sampling rate - effectively just transposing octaves up, rather than resampling.

My previous thread covering that very subject could have possibly helped make that processes a bit more streamlined:
https://hydrogenaud.io/index.php?topic=119735

(a minor protip I wanted to add to that thread but without grave-digging it - one can also use the Linux program "KCalc" set to 'Numeral System mode' to find out the hexidecimal value of a number... which shouldn't be all that surprising since KCalc as a whole appears to be an intentional clone of the classic Windows calculator)