Kinds of substream
The substream index table gives the position and size of each substream; the info element that carries its substream_index says which kind it is. Every substream is byte aligned.
| Referred to by | Substream | Holds |
|---|---|---|
| ac4_substream_info(), ac4_substream_info_chan(), _obj(), _ajoc() | ac4_substream() | coded audio and its metadata |
| ac4_hsf_ext_substream_info() | ac4_hsf_ext_substream() | the part above 24 kHz of a 96 or 192 kHz substream |
| emdf_payloads_substream_info() | emdf_payloads_substream() | EMDF payloads |
| ac4_presentation_substream_info() | ac4_presentation_substream() | presentation data (bitstream version 2) |
| oamd_substream_info() | oamd_substream() | object audio metadata (bitstream version 2) |
ac4_substream
| Field | Bits | Meaning |
|---|---|---|
| audio_size_value | 15 | the size in bytes of audio_data, the fill bits after it and the padding to a byte |
| b_more_bits | 1 | 1: audio_size also adds variable_bits(7) × 32,768 |
| byte_align | 0 to 7 | |
| audio_data() | – | the coded audio: the channel element for the channel mode (single channel, channel pair, 3.0, 5.X, 7.X, immersive, 22.2 or variable channel elements) or the object and A-JOC data |
| fill_bits, byte_align | variable | padding, so that audio_data and what follows it fill audio_size bytes |
| metadata() | – | see metadata |
| byte_align | 0 to 7 |
audio_size is what lets a reader reach the metadata without decoding the audio: it starts audio_size bytes after the (aligned) end of the size field. The audio inside audio_data is entropy coded, and its layout depends on the channel mode and on the coding tools the frame uses. The explorer shows it as one block of bytes in the frame tree; the sound itself is decoded for mono and stereo streams, see the audio decoder.
ac4_hsf_ext_substream
For a substream coded at 96 or 192 kHz the part of the spectrum above 24 kHz is sent separately, so that a 48 kHz decoder can skip it. The substream starts with max_sfb_ext_hsf[0] (6 bits: the number of scale factor bands added to those of the core), a second 6-bit value when the channels have different framing, and the scale factor and spectral data for each channel, then byte alignment. The explorer reads the first field and shows the rest as raw bytes.
emdf_payloads_substream
EMDF (Extensible Metadata Delivery Format) carries metadata that is not part of the codec itself. The substream is a list of payloads ended by a payload with identifier 0, then byte alignment.
| Field | Bits | Meaning |
|---|---|---|
| emdf_payload_id | 5, extended (5) | the payload type; 0 ends the list. Types above 0 are registered in the AC-4 EMDF registry, outside the standard |
| emdf_payload_config() | – | b_smpoffst (+ smpoffst, variable_bits(11)), b_duration (+ duration, variable_bits(11)), b_groupid (+ groupid, variable_bits(2)), b_codecdata (+ 8 bits), b_discard_unknown_payload (1: drop the payload if its type is not known when transcoding); when that is 0: b_payload_frame_aligned (with b_create_duplicate and b_remove_duplicate) when there is no sample offset, and priority (5 bits) and proc_allowed (2 bits) when there is an offset or the payload is frame aligned |
| emdf_payload_size | 8, extended (8) | the size in bytes of the payload |
| emdf_payload_byte[] | 8 each | the payload. Payloads are packed bit by bit, with no padding between them |
An emdf_info() in the table of contents names the substream that holds the payloads of its presentation. Each emdf_info ends with emdf_reserved(): two 2-bit fields n_skip_bytes_length_primary and _secondary that give, as 1, 4 or 16 bytes each (for the values 1, 2 and 3), how many reserved bytes follow.
ac4_presentation_substream
A bitstream version 2 presentation has one substream of its own, referred to by ac4_presentation_substream_info(). It holds data about the presentation as a whole.
| Field | Bits | Meaning |
|---|---|---|
| presentation names and targets | – | only for an alternative presentation: b_name_present, b_length, name_len and the name in UTF-8; n_targets and, for each target, target_level (3), target_device_category (4: stereo speakers, 5.1 speakers, height speakers, portable speakers), b_tdc_extension, max_ducking_depth (6, 63 is −inf), loud_corr_target (5) and, for every audio substream, b_active and alt_data_set_index |
| b_additional_data, add_data_bytes | 1, 4 (extended 2) | additional data: immersive_audio_indicator, b_oamd_common_timing (when the presentation has objects), b_advanced_de_data_present with advanced_de_data() (compressor attack, release, ratio, threshold and gain for dialogue enhancement), then the rest as reserved bits |
| dialnorm_bits | 7 | the dialogue level of the presentation: −0.25 dB per step |
| b_further_loudness_info | 1 | further_loudness_info(): see metadata |
| drc_metadata_size_value, b_more_bits | 5, 1 (extended 3) | the size in bits of the dynamic range control data that follows (kept raw by the explorer) |
| b_substream_group_gains_present, b_keep, sg_gain[] | 1, 1, 6 each | with more than one group: a gain for each group, −0.25 dB per step, 63 is −inf; b_keep repeats the last frame’s gains |
| b_associated and the scale fields | – | for associated audio: scale_main, scale_main_centre, scale_main_front (8 bits each, optional), b_associate_is_mono and pan_associated (8) |
| custom_dmx_data() | – | downmix data chosen by the encoder: for immersive presentations a set of gain codes for converting top and back channels (cdmx_parameters and the tool_* elements, 3 bits each), and for presentations with surround channels the stereo downmix gains (loro and ltrt centre and surround mix gains, LFE mix gain, preferred downmix method) |
| loud_corr() | – | loudness corrections for downmixes: flags and 5-bit values for Lo/Ro and Lt/Rt downmix, 5.X, 7.X, the immersive layouts and the core decoding mode |
The layout of custom_dmx_data() and loud_corr() depends on the presentation’s channel mode, worked out from the substream groups (the highest channel mode of all the channel-coded substreams in the presentation, or −1 when the presentation has objects), and on the core mode of presentations that can be decoded to 5.X.
oamd_substream
Object audio metadata says where each object is, how loud, how wide and how it is rendered. It is referred to from a substream group of objects and read here with the objects of that group.
| Element | Meaning |
|---|---|
| oamd_common_data() | b_default_screen_size_ratio (else a 5-bit ratio code), b_bed_object_chan_distribute, optional additional data: trim() (warp mode, global trim mode, nine trim configurations with trim and balance values), bed_render_info() (stereo downmix coefficients and the downmix gains of wide, back and top channels) and headphone() (operation mode, head tracking) |
| oamd_timing_data() | oa_sample_offset_type (a prefix code: none, a coded 16, 8 or 24 samples, or 5 bits), num_obj_info_blocks (3 bits), and for each block block_offset_factor (6 bits) and ramp_duration_code (2 bits, with a table index or an 11-bit duration) |
| oamd_dyndata_multi() | for every object that is not A-JOC coded, an object_info_block() for each block |
| object_info_block() | b_object_not_active, then object_basic_info() (gain code or value, priority), object_render_info() (3-D position, or a difference from the last one; zone, width, depth, screen factor, distance, divergence) and add_per_object_md() (trim disable, extended precision position, headphone rendering) |