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: Does FLAC do any 5.1 channel decorrelation? (Read 3101 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Does FLAC do any 5.1 channel decorrelation?

I'm unclear on whether it's possible to make FLAC do any interchannel decorrelation for 5.1 audio. The FAQ seems to suggest that it does:

"FLAC supports from 1 to 8 channels per stream. Channels are only grouped in FLAC to take advantage of interchannel correlation and to define common channel assignments (like stereo L/R, 5.1 surround, et cetera)."

Although in other places it seems to hint that this only works for stereo audio.

I've been testing on a directory of 5.1 audio files (a film soundtrack, split into reels, with 6 mono wav files per reel, 5 reels). On one hand, I've compressed all the mono wav files to FLAC individually, and on the other hand, I've used ffmpeg to merge each set of 6 mono wavs into a 6-channel 5.1 wav file, and then used FLAC to compress that. I simply use flac --best *.wav to compress each set of files.

However, there's practically no difference in total file size at all, except for a miniscule difference which I suspect is due to not having redundant headers. On the other hand, I know for a fact that 5.1 film soundtracks have a huge amount of interchannel correlation, so this result seems counterintuitive to me.

What am I doing wrong? Does FLAC simply not do this? Or are there options to do it? If it doesn't do it, would encoding the front and back channels as two stereo pairs and using the stereo correlation options be an alternative?

Re: Does FLAC do any 5.1 channel decorrelation?

Reply #1
Why not repeat the experiment with six identical mono tracks? That should be the ultimate test.

Re: Does FLAC do any 5.1 channel decorrelation?

Reply #2
I could certainly do that. What I have done, however, is what I suggested earlier, I combined the front left and right tracks into a stereo track,and did the same with the surround left and right tracks, then encoded them using flac --best -m (I encoded the center and LFE channels as mono, since I don't expect them to have much correlation). This did in fact give me somewhat better compression than the mono tracks individually, so it seems decorrelation for stereo pairs does work, while there seems to be no way to induce decorrelation for 5.1...

Since the documentation seems a bit ambiguous, I'm wondering who I should talk to (maybe one of the developers?) to get a definitive answer.

Re: Does FLAC do any 5.1 channel decorrelation?

Reply #3
Tested this with a 5.1 file made from 6 identical mono tracks. Compression ratio is the same as if I compressed the 6 mono tracks separately, no decorrelation is apparent.

So the question becomes, is this just not possible at all, or is there just no switch in the flac commandline utility to do it, but it's maybe possible to do through the API?

Re: Does FLAC do any 5.1 channel decorrelation?

Reply #4
The FLAC format only supports channel decorrelation for 2 channel audio, as shown in the frame header channel assignment bits.

Re: Does FLAC do any 5.1 channel decorrelation?

Reply #5
That's what I thought, and it's a bit disappointing. This may be off topic for this particular forum, but does anyone know whether Apple Lossless Audio does channel decorrelation between all channels in 5.1 audio, or indeed other arbitrary channel configurations?

Re: Does FLAC do any 5.1 channel decorrelation?

Reply #6
That's what I thought, and it's a bit disappointing. This may be off topic for this particular forum, but does anyone know whether Apple Lossless Audio does channel decorrelation between all channels in 5.1 audio, or indeed other arbitrary channel configurations?

https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/alac.c#L366

Assuming the ffmpeg decoder is correct, it looks like decorrelation is stereo only.  Probably not too surprising, I don't even think it can do stereo decorrelation of 24 bit samples, so the odds of 5.1 decorrelation were pretty long. 

Re: Does FLAC do any 5.1 channel decorrelation?

Reply #7
It would be fantastic to have 5.1 or 7.1 decorrelation, especially for streaming video and even digital purchases. I guess that will need to happen in the next generation of codecs.