Skip to content

Commit

Permalink
Run make doc, try to reconcile Dolby lack of spec, its code, and Medi…
Browse files Browse the repository at this point in the history
…aInfo
  • Loading branch information
JohnnyMarnell committed Oct 29, 2024
1 parent 5687b08 commit c009996
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ It was originally designed to query, inspect and debug media codecs and containe
[aac_frame](doc/formats.md#aac_frame),
adts,
adts_frame,
[adm](doc/formats.md#adm),
aiff,
amf0,
apev2,
Expand All @@ -54,7 +53,6 @@ avc_sei,
avc_sps,
[avi](doc/formats.md#avi),
[avro_ocf](doc/formats.md#avro_ocf),
[axml](doc/formats.md#adm),
[bencode](doc/formats.md#bencode),
bitcoin_blkdat,
[bitcoin_block](doc/formats.md#bitcoin_block),
Expand All @@ -68,9 +66,7 @@ bsd_loopback_frame,
bzip2,
[caff](doc/formats.md#caff),
[cbor](doc/formats.md#cbor),
[chna](doc/formats.md#adm),
[csv](doc/formats.md#csv),
[dolby_metadata](doc/formats.md#dolby_metadata),
dns,
dns_tcp,
[dolby_metadata](doc/formats.md#dolby_metadata),
Expand Down
29 changes: 3 additions & 26 deletions doc/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
|[`aac_frame`](#aac_frame) |Advanced&nbsp;Audio&nbsp;Coding&nbsp;frame |<sub></sub>|
|`adts` |Audio&nbsp;Data&nbsp;Transport&nbsp;Stream |<sub>`adts_frame`</sub>|
|`adts_frame` |Audio&nbsp;Data&nbsp;Transport&nbsp;Stream&nbsp;frame |<sub>`aac_frame`</sub>|
|[`adm`](#adm) |Audio&nbsp;Definition&nbsp;Model |<sub>`riff`</sub>|
|`aiff` |Audio&nbsp;Interchange&nbsp;File&nbsp;Format |<sub></sub>|
|`amf0` |Action&nbsp;Message&nbsp;Format&nbsp;0 |<sub></sub>|
|`apev2` |APEv2&nbsp;metadata&nbsp;tag |<sub>`image`</sub>|
Expand All @@ -26,7 +25,6 @@
|`avc_sps` |H.264/AVC&nbsp;Sequence&nbsp;Parameter&nbsp;Set |<sub></sub>|
|[`avi`](#avi) |Audio&nbsp;Video&nbsp;Interleaved |<sub>`avc_au` `hevc_au` `mp3_frame` `flac_frame`</sub>|
|[`avro_ocf`](#avro_ocf) |Avro&nbsp;object&nbsp;container&nbsp;file |<sub></sub>|
|[`axml`](#adm) |Audio&nbsp;Definition&nbsp;Model&nbsp;<axml>&nbsp;Chunk |<sub>`riff`</sub>|
|[`bencode`](#bencode) |BitTorrent&nbsp;bencoding |<sub></sub>|
|`bitcoin_blkdat` |Bitcoin&nbsp;blk.dat |<sub>`bitcoin_block`</sub>|
|[`bitcoin_block`](#bitcoin_block) |Bitcoin&nbsp;block |<sub>`bitcoin_transaction`</sub>|
Expand All @@ -40,9 +38,7 @@
|`bzip2` |bzip2&nbsp;compression |<sub>`probe`</sub>|
|[`caff`](#caff) |Live2D&nbsp;Cubism&nbsp;archive |<sub>`probe`</sub>|
|[`cbor`](#cbor) |Concise&nbsp;Binary&nbsp;Object&nbsp;Representation |<sub></sub>|
|[`chna`](#adm) |Audio&nbsp;Definition&nbsp;Model&nbsp;<chna>&nbsp;Chunk |<sub>`riff`</sub>|
|[`csv`](#csv) |Comma&nbsp;separated&nbsp;values |<sub></sub>|
|[`dolby_metadata`](#dolby_metadata) |Dolby&nbsp;Metadata&nbsp;(Atmos,&nbsp;AC3,&nbsp;Digital&nbspPlus) |<sub>`riff`</sub>|
|`dns` |DNS&nbsp;packet |<sub></sub>|
|`dns_tcp` |DNS&nbsp;packet&nbsp;(TCP) |<sub></sub>|
|[`dolby_metadata`](#dolby_metadata) |Dolby&nbsp;Metadata&nbsp;(Atmos,&nbsp;AC3,&nbsp;Dolby&nbsp;Digital) |<sub></sub>|
Expand Down Expand Up @@ -184,27 +180,6 @@ Decode value as aac_frame
... | aac_frame({object_type:1})
```

## adm
[Audio Definition Model](https://adm.ebu.io/background/what_is_the_adm.html) including 3D Audio.

RIFF / WAV / Broadcast Wave Format (BWF) chunks:
- `<chna>` Chunk, Track UIDs of Audio Definition Model
- `<axml>` Chunk, BWF XML Metadata, e.g. for Audio Definition Model ambisonics and elements

### Examples
Decode ADM configuration from `<chna>` and `<axml>` chunks:
```
$ fq -d wav '.chunks[] | select(.id | IN("chna", "axml")) | tovalue' bwf.wav
```

### Authors
- [@johnnymarnell](https://johnnymarnell.github.io), original author

### References
- https://adm.ebu.io/background/what_is_the_adm.html
- https://tech.ebu.ch/publications/tech3285s7
- https://tech.ebu.ch/publications/tech3285s5

## apple_bookmark
Apple BookmarkData.

Expand Down Expand Up @@ -625,7 +600,7 @@ including Dolby Atmos, AC3, Dolby Digital \[Plus\], and Dolby Audio Info (e.g. L
### Examples
Decode Dolby metadata from `<dbmd>` chunk:
```
$ fq -d wav '.chunks[] | select(.id | IN("dbmd")) | tovalue' bwf.wav
$ fq -d wav '.chunks[] | select(.id | IN("dbmd")) | tovalue' adm-bwf.wav
```

RIFF / WAV / Broadcast Wave Format (BWF) chunks:
Expand All @@ -641,6 +616,7 @@ RIFF / WAV / Broadcast Wave Format (BWF) chunks:
- https://tech.ebu.ch/publications/tech3285s5
- https://tech.ebu.ch/files/live/sites/tech/files/shared/tech/tech3285s6.pdf
- https://github.com/DolbyLaboratories/dbmd-atmos-parser
- https://github.com/MediaArea/MediaInfoLib/tree/Source/MediaInfo/Audio/File_DolbyAudioMetadata.cpp

## fit
Garmin Flexible and Interoperable Data Transfer.
Expand Down Expand Up @@ -834,6 +810,7 @@ LevelDB Table.
- Zstandard uncompression is not implemented yet.

### Authors

- [@mikez](https://github.com/mikez), original author

### References
Expand Down
45 changes: 32 additions & 13 deletions format/riff/dolby_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ var compressionDescMap = scalar.UintMapSymStr{
5: "speech",
}

var downmix5to2DescMap = scalar.UintMap{
0: {Sym: "not_indicated", Description: "Not indicated (Lo/Ro)"},
1: {Sym: "loro", Description: "Lo/Ro"},
2: {Sym: "ltrt_dpl", Description: "Lt/Rt (Dolby Pro Logic)"},
3: {Sym: "ltrt_dpl2", Description: "Lt/Rt (Dolby Pro Logic II)"},
4: {Sym: "direct_stereo_render", Description: "Direct stereo render"},
}

var phaseShift5to2DescMap = scalar.UintMap{
0: {Sym: "no_shift", Description: "Without Phase 90"},
1: {Sym: "shift_90", Description: "With Phase 90"},
}

var bitstreamModeMap = scalar.UintMapDescription{
0b000: "main audio service: complete main (CM)",
0b001: "main audio service: music and effects (ME)",
Expand All @@ -105,10 +118,10 @@ var binauralRenderModeMap = scalar.UintMapSymStr{
}

var warpModeMap = scalar.UintMap{
0: {Sym: "normal"},
1: {Sym: "warping"},
2: {Sym: "downmix_dolby_pro_logic_iix"},
3: {Sym: "downmix_loro"},
0: {Sym: "normal", Description: "possibly: Direct render"},
1: {Sym: "warping", Description: "possibly: Direct render with room balance"},
2: {Sym: "downmix_dolby_pro_logic_iix", Description: "Dolby Pro Logic IIx"},
3: {Sym: "downmix_loro", Description: "possibly: Standard (Lo/Ro)"},
4: {Sym: "not_indicated", Description: "Default warping will be applied"},
}

Expand Down Expand Up @@ -236,29 +249,35 @@ func parseAudioInfo(d *decode.D) {
}

func parseDolbyAtmos(d *decode.D) {
// TODO: both these are fixed size null terminated strings?
d.FieldUTF8NullFixedLen("atmos_dbmd_content_creation_preamble", 32)
d.FieldUTF8NullFixedLen("atmos_dbmd_content_creation_tool", 64)
d.FieldStruct("version", func(d *decode.D) {
d.FieldU8("major")
d.FieldU8("minor")
d.FieldU8("micro")
d.FieldU8("patch")
})
// TODO: All these unknowns? (mostly from MediaInfoLib, also Dolby repo)

d.FieldRawLen("unknown0", 21*8)

d.FieldRawLen("unknown1", 1)
d.FieldU3("downmix_5to2", scalar.UintSym("unknown"), downmix5to2DescMap)
d.FieldRawLen("unknown2", 2)
d.FieldU2("phaseshift_90deg_5to2", scalar.UintSym("unknown"), phaseShift5to2DescMap)

// TODO: what is this?
d.FieldRawLen("unknown0", 53*8)
d.FieldRawLen("unknown3", 12*8)

d.FieldU8("warp_mode", warpModeMap)
d.FieldRawLen("bed_distribution", 2)
d.FieldRawLen("reserved0", 3)
d.FieldU3("warp_mode", warpModeMap)

// TODO: what is this?
d.FieldRawLen("unknown1", 15*8)
d.FieldRawLen("unknown2", 80*8)
d.FieldRawLen("unknown4", 15*8)
d.FieldRawLen("unknown5", 80*8)
}

func parseDolbyAtmosSupplemental(d *decode.D) {
d.FieldU32("dasms_sync", d.UintAssert(0xf8726fbd), scalar.UintHex)

// TODO: wav.go sets LE default i think?
objectCount := int64(d.FieldU16("object_count"))
d.FieldU8("reserved")

Expand Down
1 change: 1 addition & 0 deletions format/riff/dolby_metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ RIFF / WAV / Broadcast Wave Format (BWF) chunks:
- https://tech.ebu.ch/publications/tech3285s5
- https://tech.ebu.ch/files/live/sites/tech/files/shared/tech/tech3285s6.pdf
- https://github.com/DolbyLaboratories/dbmd-atmos-parser
- https://github.com/MediaArea/MediaInfoLib/tree/Source/MediaInfo/Audio/File_DolbyAudioMetadata.cpp

0 comments on commit c009996

Please sign in to comment.