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: Assigned and unassigned speaker channels (Read 643 times) previous topic - next topic - Topic derived from Lossless Compression ...
0 Members and 1 Guest are viewing this topic.

Assigned and unassigned speaker channels

So, channel decorrelation. WavPack:

As you can see, when matching the channel pairing and frame size, the reference WavPack encoder falls in between FFmpeg compression levels 5 and 6, which is pretty typical, so I think that mystery is pretty much solved (pairing may help more in other samples).
Of course (assuming file format 5 supports it) one can try both to pair or not to pair, at least for x4 up where the user has actively chosen to spend time and effort. Both unassigned and "assigned but not paired in 5.70".
But pairing did only improve 0.03%, sooo ... of course there is a mileage-may-vary and it could be bigger here and there, but

Block size matters more, but I guess there are good reasons to limit that to a quarter of a second (which also is TAK's max, by the way!) over half a second. Hunch, if someone sets up a streamserver over a dubious line or something?
If so, it makes sense for WavPack to be careful (compared to the heavier formats that cannot be streamed this way anyway), and a quarter of a second is also much more data for multichannel.
It’s funny because I just assumed that the WavPack decoders would not allow or would somehow barf on files that switched the channel assignment mid-stream like that. However, I created a file that switched back and forth and it decoded fine, both with the reference decoder and with FFmpeg.

That surprise aside, the potential gain from taking advantage of this is very small, and it’s definitely weird to consider mixing center and LFE in lossy mode.

Interestingly FFmpeg will not tolerate WavPack files with any unassigned speakers, which strikes me as overly pedantic, especially since it has no problem with WAV files with unassigned speakers (which FLAC rejects, presumably because its multichannel configurations are fixed?)

As for the samples per frame limit, the primary concern for large frames in multichannel was the memory required for decoding because the frames for every channel must all be in memory before [interleaved] decoding can begin. This is not true for mono/stereo streams which can (in theory) be read and decoded incrementally. The libwavpack library doesn’t actually do that (it allocates memory for and reads the whole frame), but the Tiny Decoder does, which was developed for Rockbox and limited memory, and this is why on Rockbox only the first stream of a multichannel file plays, and the rest are skipped afterward.

This memory limitation is probably not as important as it once was, but again, we’re talking less than a tenth of a percent in compression improvement. If someone really wants to they can specify longer frames on the command-line. Specifying --blocksize=96000 alone saves 1447928 bytes (0.163%) on the file I used above, but would require over 1 MB of buffered data to decode and might not be so snappy seeking (think Monkey's Audio "insane").

Re: Assigned and unassigned speaker channels

Reply #1
Interestingly FFmpeg will not tolerate WavPack files with any unassigned speakers, which strikes me as overly pedantic, especially since it has no problem with WAV files with unassigned speakers (which FLAC rejects, presumably because its multichannel configurations are fixed?)
Could you check for me which version of FLAC you tested, because that was supposed to be fixed with the last release.
Music: sounds arranged such that they construct feelings.

Re: Assigned and unassigned speaker channels

Reply #2
The wavpack encoder/decoder in recent FFmpeg works just fine with unasigned speakers, or you mean whan some channels are unassigned and others are assigned, thus mixed?
Please remove my account from this forum.

Re: Assigned and unassigned speaker channels

Reply #3
Interestingly FFmpeg will not tolerate WavPack files with any unassigned speakers, which strikes me as overly pedantic, especially since it has no problem with WAV files with unassigned speakers (which FLAC rejects, presumably because its multichannel configurations are fixed?)
Could you check for me which version of FLAC you tested, because that was supposed to be fixed with the last release.
Yeah, it was 1.3.3 just because that’s what my distro provides.

I tried with a recent build (git-d2b24410 20240309) and all is fine.

Sorry for the false alarm!

The wavpack encoder/decoder in recent FFmpeg works just fine with unasigned speakers, or you mean whan some channels are unassigned and others are assigned, thus mixed?

It doesn’t seem to work with either. If all channels are unassigned it complains:

Code: [Select]
[wv @ 0x5874cfe09000] Insufficient channel information

If some channels are unassigned (e.g., 6 channel file with channel mask == 0x3):

Code: [Select]
[wavpack @ 0x57fbda900240] Channel mask does not match the channel count

These files were created with the WavPack CLI. I could not create such files with FFmpeg because when I supply a WAV file with a channel mask (via WAVEFORMATEXTENSIBLE) that doesn’t have all the channels defined, FFmpeg says:

Code: [Select]
[aist#0:0/pcm_s24le @ 0x60aa64ed5780] Guessed Channel Layout: 5.1

and always generates the same exact WavPack (or FLAC) file (obviously discarding the channel mask).

The version is from April Git (N-114844-g376b3d53c5)
 

Re: Assigned and unassigned speaker channels

Reply #4
This is the decoder? where are such .wv files ? how it can be created?
Please remove my account from this forum.

Re: Assigned and unassigned speaker channels

Reply #5
This is the decoder? where are such .wv files ? how it can be created?

There are two easy ways to create such files using the WavPack command-line program. The first would be to use the raw-pcm mode:
Code: [Select]
$ wavpack surround.raw --raw-pcm=48000,24,6 --channel-order=... (or --channel-order=FL,FR,...) 

The other would be to simply encode a multichannel WAV file that has the channel mask in WAVEFORMATEXTENSIBLE set to the desired value.

Attached are three 6-channel files. One is full 5.1, one is just the front two channels assigned, and one is completely unassigned. Only surround.wv decodes/plays in FFmpeg.

You can verify the channel configuration with wvunpack:

Code: [Select]
david@pop-os-hp15:~/Projects/WavPack/cli$ wvunpack -ss surround.wv all-unassigned.wv front-only.wv

 WVUNPACK  Hybrid Lossless Audio Decompressor  linux-gnu Version 5.7.0
 Copyright (c) 1998 - 2024 David Bryant.  All Rights Reserved.


surround.wv:

file name:         surround.wv
file size:         2056838 bytes
source:            24-bit ints at 48000 Hz
channels:          6 (5.1 surround)
duration:          0:00:09.10
modalities:        hybrid lossy, high, extra-6, dns
compression:       73.84%
ave bitrate:       1808 kbps
encoder version:   5
original md5:      88f981e653a6580825ab1ea46f31c468
source format:     Microsoft RIFF with 'wav' extension
file wrapper:      104 byte RIFF header

all-unassigned.wv:

file name:         all-unassigned.wv
file size:         2039996 bytes
source:            24-bit ints at 48000 Hz
channels:          6 (unassigned speakers)
duration:          0:00:09.10
modalities:        hybrid lossy, high, extra-6, dns
compression:       74.05%
ave bitrate:       1793 kbps
encoder version:   5
original md5:      88f981e653a6580825ab1ea46f31c468
source format:     Microsoft RIFF with 'wav' extension
file wrapper:      104 byte RIFF header

front-only.wv:

file name:         front-only.wv
file size:         2047360 bytes
source:            24-bit ints at 48000 Hz
channels:          6 (FL,FR,...)
duration:          0:00:09.10
modalities:        hybrid lossy, high, extra-6, dns
compression:       73.96%
ave bitrate:       1800 kbps
encoder version:   5
original md5:      88f981e653a6580825ab1ea46f31c468
source format:     Microsoft RIFF with 'wav' extension
file wrapper:      104 byte RIFF header

 **** 3 files successfully processed ****

 

Re: Assigned and unassigned speaker channels

Reply #6
Interestingly FFmpeg will not tolerate WavPack files with any unassigned speakers, which strikes me as overly pedantic, especially since it has no problem with WAV files with unassigned speakers (which FLAC rejects, presumably because its multichannel configurations are fixed?)
Could you check for me which version of FLAC you tested, because that was supposed to be fixed with the last release.
Yeah, it was 1.3.3 just because that’s what my distro provides.

I tried with a recent build (git-d2b24410 20240309) and all is fine.

Sorry for the false alarm!
Thanks for checking. I often run into similar problems: on one system I use a rolling release, another is an LTS, and I often don't think about it until I notice some feature is absent. It is funny to see how long it takes for certain features to trickle down there.
Music: sounds arranged such that they construct feelings.

Re: Assigned and unassigned speaker channels

Reply #7
Attached are three 6-channel files. One is full 5.1, one is just the front two channels assigned, and one is completely unassigned. Only surround.wv decodes/plays in FFmpeg.

I tried to remux with ffmpeg. .wv to .wv and to .mka (there are no other formats to reasonably try?)
Slightly surprising results:
 * all-unassigned.wv fails all over, surround.wv works all over. No surprises there.
 * front-only.wv remuxes .wv to .wv without problem. But    ffmpeg -i front-only.wv -codec copy front-only.wv.mka     outputs a file which MediaInfo claims to be 2 channels. Remuxing to .wv.mka.wv again solves the problem and outputs a file bit-identical to the one obtained by remuxing .wv to .wv
 * However, using MKVToolNIX (mkvmerge v76.0 ('Celebration') 64-bit) to encapsulate front-only.wv into front-only.mkvtoolnix.mka , outputs a file which MediaInfo claims to be 6 channels as should. (MKVToolNIX only gives the warning that there is no .wvc.)

I don't know Matroska internals and cannot vouch for MediaInfo being correct.

Re: Assigned and unassigned speaker channels

Reply #8
I don't know Matroska internals and cannot vouch for MediaInfo being correct.
I’m sort of sorry I mentioned this can of worms (and it certainly should not have hijacked this thread). A lot of applications (and, presumably, a lot of devs) think that all the channels in a WAV file need to be represented in the channel mask or it’s invalid. But this makes little sense because some channels may not represent one of the 18 defined speaker locations. Obvious examples are raw Ambisonics feeds, individual instrument stems for a DAW, mixdowns, etc. And this is explained by Microsoft:
Quote
Typically, the count in nChannels equals the number of bits set in dwChannelMask, but this is not necessarily so. If nChannels is less than the number of bits set in dwChannelMask, the extra (most significant) bits in dwChannelMask are ignored. If nChannels exceeds the number of bits set in dwChannelMask, the channels that have no corresponding mask bits are not assigned to any physical speaker position. In any speaker configuration other than KSAUDIO_SPEAKER_DIRECTOUT, an audio sink like KMixer (see KMixer System Driver) simply ignores these excess channels and mixes only the channels that have corresponding mask bits.
Some applications may try to handle these in a reasonable way, but without being exercised regularly this code is likely to be buggy and do unpredictable things (hence these results).

WavPack has it easy. All it has to do is store and report this info to anyone who asks (although it can be complicated by the things CAF files specify).

And I can verify that at least for WavPack files, MediaInfo does show the right thing (I recently supplied a patch to MediaInfo to fix some multichannel related issues).