[openal] AL_SOFT_block_alignment proposal
Chris Robinson
chris.kcat at gmail.com
Fri Mar 7 02:44:09 EST 2014
Here's an extension to specify the block alignment, intended for ADPCM
formats though not strictly requiring it.
If there's anything that needs changing, let me know. I can still change
things if there's any problems with it.
-------------- next part --------------
Name
AL_SOFT_block_alignment
Contributors
Chris Robinson
Contact
Chris Robinson (chris.kcat 'at' gmail.com)
Status
In progress
Dependencies
This extension is for OpenAL 1.1.
This extension interacts with AL_SOFT_buffer_samples.
This extension interacts with AL_SOFT_buffer_sub_data.
This extension interacts with AL_EXT_IMA4.
This extension interacts with AL_SOFT_MSADPCM.
Overview
This extension provides a mechanism for specifying block alignment
properties for sample data. This is useful for, though not strictly
limited to, ADPCM compression where the block alignment is specified in
the media file header instead of the data stream, and controls the
decoding process.
Issues
Q: How should the block alignment be specified?
A: As the number of sample frames per block. Although certain formats,
like .wav, store the block alignment in bytes, sample frames is easier
to manage.
Q: How does changing the block alignment affect sample data that's already
loaded?
A: It doesn't. The block alignment is used when unpacking (reading) and
packing (writing) samples when the application calls, but does not
affect how stored data is interpreted.
New Procedures and Functions
None.
New Tokens
Accepted by the <paramName> parameter of alBufferi, alBufferiv,
alGetBufferi, and alGetBufferiv:
AL_UNPACK_BLOCK_ALIGNMENT_SOFT 0x200C
AL_PACK_BLOCK_ALIGNMENT_SOFT 0x200D
Additions to Specification
Sample Data Block Alignment
Sample data is read and written as a collection of one or more blocks. A
block is a collection of one or more sample frames, which in turn contain
one sample for each channel.
Table x.0. Buffer AL_UNPACK_BLOCK_ALIGNMENT_SOFT Attribute
Name Signature Values Default
-------------------------------- --------- -------------- -------
AL_UNPACK_BLOCK_ALIGNMENT_SOFT i, iv [0, MAX_INT] 0
Table x.1. Buffer AL_PACK_BLOCK_ALIGNMENT_SOFT Attribute
Name Signature Values Default
------------------------------ --------- -------------- -------
AL_PACK_BLOCK_ALIGNMENT_SOFT i, iv [0, MAX_INT] 0
The buffer's block alignment attributes specify the number of sample
frames in each block when unpacking and packing sample data. Unpacking
occurs during calls to alBufferData, and alBufferSubDataSOFT if
AL_SOFT_buffer_sub_data is supported, and alBufferSamplesSOFT and
alBufferSubSamplesSOFT if AL_SOFT_buffer_samples is supported, Packing
occurs during calls to alGetBufferSamplesSOFT if AL_SOFT_buffer_samples is
supported.
By default, the block alignment for unpacking and packing samples is set
to 0. This indicates the minimum alignment (1) is used for PCM sample
formats.
If the AL_EXT_IMA4 extension is supported, the block alignment controls
the number of sample frames encoded per IMA ADPCM block, and so also
affects the bitrate. The block alignment must be a multiple of 8, plus 1
(i.e. alignment = n*8 + 1), or an AL_INVALID_VALUE error will occur during
unpacking or packing IMA4 samples. A block alignment of 0 indicates a
default of 65 sample frames per block for IMA4 sample formats.
If the AL_SOFT_MSADPCM extension is supported, the block alignment
controls the number of sample frames encoded per MSADPCM block, and so
also affects the bitrate. The block alignment must be a multiple of 2, or
an AL_INVALID_VALUE error will occur during unpacking or packing MSADPCM
samples. A block alignment of 0 indicates a default of 64 sample frames
per block for MSADPCM sample formats.
Errors
An AL_INVALID_VALUE error is generating during unpacking or packing
operations if the unpack block alignment or pack block alignment isn't an
appropriate value for the format.
More information about the openal
mailing list