How is 24-bit audio streamed to the graph?

This is probably a very stupid question, but after some searching, I couldn't find a direct answer.

If the original filter (such as the LAV audio codec) processes a 24-bit integral audio stream, how are individual audio samples transferred to the graph? (let's consider a mono stream for simplicity)

Are they stored separately as a 32-bit integer with the most significant bits that are not used or stored packed, with the least significant bits of the next sample taking up the spare, most significant bits of the current sample?

+3


source to share


1 answer


The format is similar to 16-bit PCM: the values ​​are signed integers, slightly endian.

With 24-bit audio, you usually specify the format with WAVEFORMATEXTENSIBLE

, as opposed to WAVEFORMATEX

(well, the latter is also possible in terms of acceptance by some filters, but in general you are expected to use the former).

The structure has two meanings: the number of bits per sample and the number of valid bits per sample. Thus, it is possible to have 24-bit data represented as 24-bit values ​​as well as 24-bit significant bits of 32-bit values. Payload data must conform to the format.

There are no bits of different samples in a byte:



However, wBitsPerSample is the size of the container and must be a multiple of 8 , whereas wValidBitsPerSample can be any value up to the size of the container. For example, if the format uses 20-bit samples, wBitsPerSample must be at least 24, but wValidBitsPerSample is 20.

As far as I know, it is typical to only have 24-bit values, i.e. three bytes per PCM sample.

Formats other than PCM can define different packing and use "unused" bits more efficiently, so that, for example, 20-bit audio samples consume 5 bytes.

+3


source







All Articles