ac4_toc
The table of contents starts every raw frame and tells a decoder everything it needs to configure itself: nothing outside it is used. Fields
are read most significant bit first; a field marked extended is a short field that, at its largest value, is followed by a
variable_bits(n) that is added to it. variable_bits(n) reads n bits and a flag bit; while the flag is set, the value is
shifted left by n bits, 2n is added and the next n bits are added.
| Field | Bits | Meaning |
|---|---|---|
| bitstream_version | 2, extended (3) | 0 and 1: presentations are ac4_presentation_info(). 2: presentations are ac4_presentation_v1_info() and the substream groups follow |
| sequence_counter | 10 | counts frames, 1 to 1020; a jump means the source changed |
| b_wait_frames | 1 | 1 when wait_frames follows |
| wait_frames | 3 | the decoding delay in frames for average bit rate streams: 0 constant bit rate, 1 to 6 as table below, 7 variable |
| br_code | 2 | only when wait_frames is above 0 (called reserved in part 1): helps estimate the long-term bit rate; 3 starts and stops a sequence |
| fs_index | 1 | 0: 44.1 kHz, 1: 48 kHz base sampling rate |
| frame_rate_index | 4 | see the frame rate table |
| b_iframe_global | 1 | 1 when every substream of every presentation is an I-frame: decoding can start here |
| b_single_presentation | 1 | 1: one presentation. 0: b_more_presentations follows |
| b_more_presentations | 1 | 1: n_presentations = variable_bits(2) + 2. 0: no presentation |
| b_payload_base | 1 | 1 when payload_base_minus1 follows |
| payload_base_minus1 | 5, extended (3) | the number of bytes between the end of the table and the first substream, minus 1 (value 31 is extended by variable_bits(3)) |
| b_program_id, short_program_id, b_program_uuid_present, program_uuid | 1, 16, 1, 128 | version 2 only: an optional 16-bit programme identifier and a 16-byte UUID |
| presentations | – | n_presentations of ac4_presentation_info() (versions 0 and 1) or ac4_presentation_v1_info() (version 2) |
| ac4_substream_group_info() | – | version 2 only: one for every substream group any presentation refers to (1 plus the highest group_index) |
| substream_index_table() | – | the number and sizes of the substreams |
| byte_align | 0 to 7 | pads the table to a whole byte |
frame_rate_index
| Index | Frame rate | Samples a frame at 48 kHz |
|---|---|---|
| 0 | 23.976 | 1,920 |
| 1 | 24 | 1,920 |
| 2 | 25 | 2,048 |
| 3 | 29.97 | 1,536 |
| 4 | 30 | 1,536 |
| 5 | 47.95 | 960 |
| 6 | 48 | 960 |
| 7 | 50 | 1,024 |
| 8 | 59.94 | 768 |
| 9 | 60 | 768 |
| 10 | 100 | 512 |
| 11 | 119.88 | 384 |
| 12 | 120 | 384 |
| 13 | 23.44 (21.53 at 44.1 kHz) | 2,048 |
| 14, 15 | reserved. At 44.1 kHz only index 13 is defined | |
wait_frames
| wait_frames | Frames to wait before output (frame_rate_index 0 to 9 and 13) | (10, 11, 12) |
|---|---|---|
| 0 | constant bit rate | |
| 1 to 6 | 0, 1, 2, 3, 4, 5 | 0, 2, 4, 6, 8, 10 |
| 7 | variable bit rate: no statement | |
Presentations
A presentation is one way to play the programme: for example the main mix, the main mix with a commentary, or music and effects with a dialogue track in another language. It is made of substreams (versions 0 and 1) or of substream groups (version 2).
ac4_presentation_info (bitstream versions 0 and 1)
| Field | Bits | Meaning |
|---|---|---|
| b_single_substream | 1 | 1: the presentation is one substream |
| presentation_config | 3, extended (2) | when there is more than one substream: 0 music and effects + dialogue; 1 main + dialogue enhancement; 2 main + associated audio; 3 music and effects + dialogue + associated audio; 4 main + dialogue enhancement + associated audio; 5 main with an HSF extension; 6 additional EMDF substreams only; above 6 reserved (presentation_config_ext_info follows) |
| presentation_version() | unary | a run of 1 bits ended by 0: the version number (0 for these streams) |
| md_compat | 3 | the decoder compatibility level: 0 two channels, 1 six (5.1), 2 nine, 3 eleven, 4 thirteen (7.1), 7 unrestricted |
| b_belongs_to_presentation_id, presentation_id | 1, extended (2) | an identifier of the presentation |
| frame_rate_multiply_info() | 0 to 2 | b_multiplier (frame rates 0 to 4 and 7 to 9) and multiplier_bit (rates 2 to 4): the number of codec frames in one transport frame, 1, 2 or 4 (frame_rate_factor) |
| emdf_info() | – | the version and key of the EMDF metadata of the presentation, and the substream that carries its payloads |
| ac4_substream_info() … | – | one for each substream in the presentation’s configuration, with b_hsf_ext (1 bit) and an ac4_hsf_ext_substream_info() after the first when it is set |
| b_pre_virtualized | 1 | 1 when the audio was rendered for headphones before encoding |
| b_add_emdf_substreams, n_add_emdf_substreams | 1, 2 extended (2, plus 4) | more emdf_info() elements for substreams that carry only EMDF payloads |
ac4_presentation_v1_info (bitstream version 2)
| Field | Bits | Meaning |
|---|---|---|
| b_single_substream_group | 1 | 1: one substream group, which is the main one |
| presentation_config | 3, extended (2) | the groups: 0 music and effects + dialogue; 1 main + dialogue enhancement; 2 main + associated audio; 3 music and effects + dialogue + associated audio; 4 main + dialogue enhancement + associated audio; 5 any number of groups, typed by their content classifier; 6 EMDF only |
| presentation_version(), md_compat, presentation_id | – | as above |
| frame_rate_multiply_info(), frame_rate_fractions_info() | – | the fractions info (frame rates 5 to 12) says whether the presentation is sent at half or a quarter of the frame rate |
| emdf_info() | – | as above |
| b_presentation_filter, b_enable_presentation | 1, 1 | whether the presentation is enabled for playback |
| ac4_sgi_specifier() | group_index: 3, extended (2) | one per group: which of the substream groups of the table this is |
| b_multi_pid | 1 | 1 when the presentation is split over more than one elementary stream |
| n_substream_groups_minus2 | 2, extended (2) | configuration 5 only: the number of groups |
| b_pre_virtualized, b_add_emdf_substreams | 1, 1 | as above |
| ac4_presentation_substream_info() | b_alternative (1), b_pres_ndot (1), substream_index (2, extended) | the substream that holds the presentation data: loudness, downmix and, for an alternative presentation, its name and targets |
presentation_config_ext_info(): n_skip_bytes (5 bits, extended with 2 more bits shifted by 5), then that many reserved bytes.
Substream groups (version 2)
ac4_substream_group_info() describes a set of substreams that are decoded together.
| Field | Bits | Meaning |
|---|---|---|
| b_substreams_present | 1 | 0 when the substreams are in another elementary stream: no substream_index follows |
| b_hsf_ext | 1 | 1 when each substream has a high sampling frequency extension substream |
| b_single_substream, n_lf_substreams_minus2 | 1, 2 (extended, 2) | the number of substreams in the group, 1 or 2 and up |
| b_channel_coded | 1 | 1: the substreams carry channels. 0: they carry objects |
| sus_ver | 1 | bitstream version 1 only: the substream version; always 1 in version 2 streams |
| ac4_substream_info_chan() | – | channel coded: one per substream (below) |
| b_oamd_substream, oamd_substream_info() | 1, 1 and an index | object coded: the optional object audio metadata substream (b_oamd_ndot says it decodes without earlier frames) |
| b_ajoc, ac4_substream_info_ajoc() or ac4_substream_info_obj() | 1 and – | object coded: for each substream, A-JOC coded objects or directly coded objects |
| b_content_type, content_type() | 1 and – | what the group is (below) |
ac4_substream_info_chan
| Field | Bits | Meaning |
|---|---|---|
| channel_mode | 1 to 9, extended | see the channel mode table |
| b_4_back_channels_present, b_centre_present, top_channels_present | 1, 1, 2 | only for 7.0.4, 7.1.4, 9.0.4 and 9.1.4: whether the original has four back channels, a centre channel, and which top channels (0 none, 1 two top channels carried in Tfl, Tfr, 2 carried in Tbl, Tbr, 3 four top channels) |
| b_sf_multiplier, sf_multiplier | 1, 1 | at a 48 kHz base rate only: the substream runs at 96 kHz (0) or 192 kHz (1) |
| b_bitrate_info, bitrate_indicator | 1, 3 or 5 | the upper limit of the average bit rate for each channel (the bit rate indicator table) |
| add_ch_base | 1 | only for the 7.x modes with wide or top front channels: whether their A-CPL coding is based on L, R (0) or Ls, Rs (1) |
| b_audio_ndot | 1 each, frame_rate_factor times | the substream decodes without earlier frames |
| substream_index | 2, extended (2) | when b_substreams_present: the entry of the substream index table |
Objects
ac4_substream_info_obj() describes directly coded objects: n_objects_code (0, 1, 2, 3, 5 or 7 objects), whether they are dynamic, whether a bed of channels is sent (bed_chan_assign_code for 2.0.0 to 7.1.4 layouts, or one flag for each channel in a set of 17 or 10 flags) and whether intermediate spatial format objects (isf_config: 4, 8, 10, 14, 15 or 30) are sent. ac4_substream_info_ajoc() describes A-JOC coded substreams: whether there is an LFE, whether the downmix is static (5 signals) or how many downmix signals (4 bits) with their bed and object assignment (bed_dyn_obj_assignment()), optional oamd_common_data(), the number of upmix signals (4 bits, extended by 3) with their assignment, then the sampling rate multiplier, the bit rate indicator and the b_audio_ndot flags.
Channel modes
| Code | ch_mode | Layout |
|---|---|---|
0 | 0 | mono |
10 | 1 | stereo |
1100 | 2 | 3.0: L, C, R (only for dialogue enhancement and dialogue substreams) |
1101 | 3 | 5.0: L, C, R, Ls, Rs |
1110 | 4 | 5.1: with LFE |
1111000 | 5 | 7.0 3/4/0: L, C, R, Ls, Rs, Lb, Rb |
1111001 | 6 | 7.1 3/4/0.1: with LFE |
1111010 | 7 | 7.0 5/2/0: L, C, R, Lw, Rw, Ls, Rs |
1111011 | 8 | 7.1 5/2/0.1: with LFE |
1111100 | 9 | 7.0 3/2/2: L, C, R, Ls, Rs, Tfl, Tfr |
1111101 | 10 | 7.1 3/2/2.1: with LFE |
1111110 | 11 | version 0 and 1 tables: reserved. Version 2 (8 bits 11111100): 7.0.4 |
11111101 | 12 | 7.1.4 (version 2 only) |
111111100, 111111101, 111111110 | 13, 14, 15 | 9.0.4, 9.1.4, 22.2 (version 2 only) |
111111111 | 16 and up | reserved, extended by variable_bits(2) |
Content type and bit rate
| content_classifier | Meaning |
|---|---|
| 0 | complete main |
| 1 | music and effects |
| 2 | visually impaired (audio description) |
| 3 | hearing impaired |
| 4 | dialogue |
| 5 | commentary |
| 6 | emergency |
| 7 | voice over |
content_type() holds the classifier (3 bits) and, if b_language_indicator is set, a language tag (IETF BCP 47, 2 to 42 bytes) either whole
(n_language_tag_bytes, 6 bits, then the bytes) or in two-byte pieces spread over several frames (b_serialized_language_tag, b_start_tag,
language_tag_chunk, 16 bits). The tags qas, qtx, qad, qax, qss, qsx,
qei and qex refine an associated audio substream (audio description, spoken subtitles, emergency information, as a decoder
mix or a premix).
| bitrate_indicator | Upper limit of the average bit rate for each channel |
|---|---|
000, 010, 100, 110 | 16, 20, 24, 28 kbit/s |
00100 to 00111 | 32, 40, 48, 56 kbit/s |
01100 to 01111 | 64, 80, 96, 112 kbit/s |
1x1xx | unlimited (eight values) |
A 3-bit code ends in 0; a code ending in 1 in its third bit has two more bits.
Substream index table
| Field | Bits | Meaning |
|---|---|---|
| n_substreams | 2, extended: variable_bits(2) + 4 | the number of substreams in the frame (0 in the 2 bits means the extended count) |
| b_size_present | 1 | read only when there is one substream; with more, the sizes are always present |
| b_more_bits, substream_size | 1, 10 (plus variable_bits(2) × 1,024) | for each substream: its size in bytes |
Substream n starts at the end of the table of contents plus payload_base plus the sizes of substreams 0 to n−1. With one substream and no sizes the substream is the rest of the frame. A substream_index in an info element is the position in this table; with a frame rate factor above 1, it is the first of that many consecutive entries.