Skip to content

Commit 04539fe

Browse files
committed
dolby_metadata: Add as own format and more cleanup
1 parent f2a6987 commit 04539fe

File tree

11 files changed

+134
-109
lines changed

11 files changed

+134
-109
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ It was originally designed to query, inspect and debug media codecs and containe
3535
[aac_frame](doc/formats.md#aac_frame),
3636
adts,
3737
adts_frame,
38-
[adm](doc/formats.md#adm),
3938
aiff,
4039
amf0,
4140
apev2,
@@ -54,7 +53,6 @@ avc_sei,
5453
avc_sps,
5554
[avi](doc/formats.md#avi),
5655
[avro_ocf](doc/formats.md#avro_ocf),
57-
[axml](doc/formats.md#adm),
5856
[bencode](doc/formats.md#bencode),
5957
bitcoin_blkdat,
6058
[bitcoin_block](doc/formats.md#bitcoin_block),
@@ -68,11 +66,10 @@ bsd_loopback_frame,
6866
bzip2,
6967
[caff](doc/formats.md#caff),
7068
[cbor](doc/formats.md#cbor),
71-
[chna](doc/formats.md#adm),
7269
[csv](doc/formats.md#csv),
73-
[dolby_metadata](doc/formats.md#dolby_metadata),
7470
dns,
7571
dns_tcp,
72+
[dolby_metadata](doc/formats.md#dolby_metadata),
7673
elf,
7774
ether8023_frame,
7875
exif,

doc/formats.md

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
|[`aac_frame`](#aac_frame) |Advanced&nbsp;Audio&nbsp;Coding&nbsp;frame |<sub></sub>|
88
|`adts` |Audio&nbsp;Data&nbsp;Transport&nbsp;Stream |<sub>`adts_frame`</sub>|
99
|`adts_frame` |Audio&nbsp;Data&nbsp;Transport&nbsp;Stream&nbsp;frame |<sub>`aac_frame`</sub>|
10-
|[`adm`](#adm) |Audio&nbsp;Definition&nbsp;Model |<sub>`riff`</sub>|
1110
|`aiff` |Audio&nbsp;Interchange&nbsp;File&nbsp;Format |<sub></sub>|
1211
|`amf0` |Action&nbsp;Message&nbsp;Format&nbsp;0 |<sub></sub>|
1312
|`apev2` |APEv2&nbsp;metadata&nbsp;tag |<sub>`image`</sub>|
@@ -26,7 +25,6 @@
2625
|`avc_sps` |H.264/AVC&nbsp;Sequence&nbsp;Parameter&nbsp;Set |<sub></sub>|
2726
|[`avi`](#avi) |Audio&nbsp;Video&nbsp;Interleaved |<sub>`avc_au` `hevc_au` `mp3_frame` `flac_frame`</sub>|
2827
|[`avro_ocf`](#avro_ocf) |Avro&nbsp;object&nbsp;container&nbsp;file |<sub></sub>|
29-
|[`axml`](#adm) |Audio&nbsp;Definition&nbsp;Model&nbsp;<axml>&nbsp;Chunk |<sub>`riff`</sub>|
3028
|[`bencode`](#bencode) |BitTorrent&nbsp;bencoding |<sub></sub>|
3129
|`bitcoin_blkdat` |Bitcoin&nbsp;blk.dat |<sub>`bitcoin_block`</sub>|
3230
|[`bitcoin_block`](#bitcoin_block) |Bitcoin&nbsp;block |<sub>`bitcoin_transaction`</sub>|
@@ -40,11 +38,10 @@
4038
|`bzip2` |bzip2&nbsp;compression |<sub>`probe`</sub>|
4139
|[`caff`](#caff) |Live2D&nbsp;Cubism&nbsp;archive |<sub>`probe`</sub>|
4240
|[`cbor`](#cbor) |Concise&nbsp;Binary&nbsp;Object&nbsp;Representation |<sub></sub>|
43-
|[`chna`](#adm) |Audio&nbsp;Definition&nbsp;Model&nbsp;<chna>&nbsp;Chunk |<sub>`riff`</sub>|
4441
|[`csv`](#csv) |Comma&nbsp;separated&nbsp;values |<sub></sub>|
45-
|[`dolby_metadata`](#dolby_metadata) |Dolby&nbsp;Metadata&nbsp;(Atmos,&nbsp;AC3,&nbsp;Digital&nbspPlus) |<sub>`riff`</sub>|
4642
|`dns` |DNS&nbsp;packet |<sub></sub>|
4743
|`dns_tcp` |DNS&nbsp;packet&nbsp;(TCP) |<sub></sub>|
44+
|[`dolby_metadata`](#dolby_metadata) |Dolby&nbsp;Metadata&nbsp;(Atmos,&nbsp;AC3,&nbsp;Dolby&nbsp;Digital) |<sub></sub>|
4845
|`elf` |Executable&nbsp;and&nbsp;Linkable&nbsp;Format |<sub></sub>|
4946
|`ether8023_frame` |Ethernet&nbsp;802.3&nbsp;frame |<sub>`inet_packet`</sub>|
5047
|`exif` |Exchangeable&nbsp;Image&nbsp;File&nbsp;Format |<sub></sub>|
@@ -133,7 +130,7 @@
133130
|`vp9_frame` |VP9&nbsp;frame |<sub></sub>|
134131
|`vpx_ccr` |VPX&nbsp;Codec&nbsp;Configuration&nbsp;Record |<sub></sub>|
135132
|[`wasm`](#wasm) |WebAssembly&nbsp;Binary&nbsp;Format |<sub></sub>|
136-
|`wav` |WAV&nbsp;file |<sub>`id3v2` `id3v1` `id3v11`</sub>|
133+
|`wav` |WAV&nbsp;file |<sub>`id3v2` `id3v1` `id3v11` `dolby_metadata`</sub>|
137134
|`webp` |WebP&nbsp;image |<sub>`exif` `vp8_frame` `icc_profile` `xml`</sub>|
138135
|[`xml`](#xml) |Extensible&nbsp;Markup&nbsp;Language |<sub></sub>|
139136
|`yaml` |YAML&nbsp;Ain't&nbsp;Markup&nbsp;Language |<sub></sub>|
@@ -183,27 +180,6 @@ Decode value as aac_frame
183180
... | aac_frame({object_type:1})
184181
```
185182

186-
## adm
187-
[Audio Definition Model](https://adm.ebu.io/background/what_is_the_adm.html) including 3D Audio.
188-
189-
RIFF / WAV / Broadcast Wave Format (BWF) chunks:
190-
- `<chna>` Chunk, Track UIDs of Audio Definition Model
191-
- `<axml>` Chunk, BWF XML Metadata, e.g. for Audio Definition Model ambisonics and elements
192-
193-
### Examples
194-
Decode ADM configuration from `<chna>` and `<axml>` chunks:
195-
```
196-
$ fq -d wav '.chunks[] | select(.id | IN("chna", "axml")) | tovalue' bwf.wav
197-
```
198-
199-
### Authors
200-
- [@johnnymarnell](https://johnnymarnell.github.io), original author
201-
202-
### References
203-
- https://adm.ebu.io/background/what_is_the_adm.html
204-
- https://tech.ebu.ch/publications/tech3285s7
205-
- https://tech.ebu.ch/publications/tech3285s5
206-
207183
## apple_bookmark
208184
Apple BookmarkData.
209185

@@ -616,6 +592,8 @@ $ fq -d csv '.[0] as $t | .[1:] | map(with_entries(.key = $t[.key]))' file.csv
616592
```
617593

618594
## dolby_metadata
595+
Dolby Metadata (Atmos, AC3, Dolby Digital).
596+
619597
Dolby Metadata from `<dbmd>` chunk of RIFF / WAV / Broadcast Wave Format (BWF),
620598
including Dolby Atmos, AC3, Dolby Digital \[Plus\], and Dolby Audio Info (e.g. LUFS, True Peak).
621599

@@ -625,13 +603,20 @@ Decode Dolby metadata from `<dbmd>` chunk:
625603
$ fq -d wav '.chunks[] | select(.id | IN("dbmd")) | tovalue' bwf.wav
626604
```
627605

628-
### References
629-
- https://tech.ebu.ch/files/live/sites/tech/files/shared/tech/tech3285s6.pdf
630-
- https://github.com/DolbyLaboratories/dbmd-atmos-parser
606+
RIFF / WAV / Broadcast Wave Format (BWF) chunks:
607+
- `<chna>` Track UIDs of Audio Definition Model
608+
- `<axml>` BWF XML Metadata, e.g. for Audio Definition Model ambisonics and elements
631609

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

613+
### References
614+
- https://adm.ebu.io/background/what_is_the_adm.html
615+
- https://tech.ebu.ch/publications/tech3285s7
616+
- https://tech.ebu.ch/publications/tech3285s5
617+
- https://tech.ebu.ch/files/live/sites/tech/files/shared/tech/tech3285s6.pdf
618+
- https://github.com/DolbyLaboratories/dbmd-atmos-parser
619+
635620
## fit
636621
Garmin Flexible and Interoperable Data Transfer.
637622

@@ -824,6 +809,7 @@ LevelDB Table.
824809
- Zstandard uncompression is not implemented yet.
825810

826811
### Authors
812+
827813
- [@mikez](https://github.com/mikez), original author
828814

829815
### References

format/format.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ var (
9292
CSV = &decode.Group{Name: "csv"}
9393
DNS = &decode.Group{Name: "dns"}
9494
DNS_TCP = &decode.Group{Name: "dns_tcp"}
95+
Dolby_Metadata = &decode.Group{Name: "dolby_metadata"}
9596
ELF = &decode.Group{Name: "elf"}
9697
Ether_8023_Frame = &decode.Group{Name: "ether8023_frame"}
9798
Exif = &decode.Group{Name: "exif"}

format/riff/adm.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@ import (
99
"github.com/wader/fq/pkg/decode"
1010
)
1111

12-
func chnaDecode(d *decode.D, size int64) {
12+
func chnaDecode(d *decode.D) {
1313
d.FieldU16("num_tracks")
1414
d.FieldU16("num_uids")
15-
16-
audioIdLen := (size - 4) / 40
17-
d.FieldStructNArray("audio_ids", "audio_id", int64(audioIdLen), func(d *decode.D) {
18-
d.FieldU16("track_index")
19-
d.FieldUTF8("uid", 12)
20-
d.FieldUTF8("track_format_id_reference", 14)
21-
d.FieldUTF8("pack_format_id_reference", 11)
22-
d.FieldRawLen("padding", 8)
15+
d.FieldArray("audio_ids", func(d *decode.D) {
16+
for !d.End() {
17+
d.FieldStruct("audio_id", func(d *decode.D) {
18+
d.FieldU16("track_index")
19+
d.FieldUTF8("uid", 12)
20+
d.FieldUTF8("track_format_id_reference", 14)
21+
d.FieldUTF8("pack_format_id_reference", 11)
22+
d.FieldRawLen("padding", 8)
23+
})
24+
}
2325
})
2426
}
2527

26-
func axmlDecode(d *decode.D, size int64) {
27-
// TODO(jmarnell): this chunk is all variable xml, so leave as is?
28-
d.FieldUTF8("xml", int(size))
28+
func axmlDecode(d *decode.D) {
29+
d.FieldUTF8("xml", int(d.BitsLeft())/8)
2930
}

format/riff/aiff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func aiffDecode(d *decode.D) any {
5454
}
5555
return id, size
5656
},
57-
func(d *decode.D, id string, path path, size int64) (bool, any) {
57+
func(d *decode.D, id string, path path) (bool, any) {
5858
switch id {
5959
case "FORM":
6060
riffType = d.FieldUTF8("format", 4, d.StrAssert(aiffRiffType))

format/riff/avi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func aviDecodeEx(d *decode.D, ai format.AVI_In, extendedChunk bool) {
238238
size := d.FieldU32("size")
239239
return id, int64(size)
240240
},
241-
func(d *decode.D, id string, path path, size int64) (bool, any) {
241+
func(d *decode.D, id string, path path) (bool, any) {
242242
switch id {
243243
case "RIFF":
244244
foundRiffType = d.FieldUTF8("type", 4, d.StrAssert(requiredRiffType))

format/riff/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func (p path) topData() any {
1919
return p[len(p)-1].data
2020
}
2121

22-
func riffDecode(d *decode.D, path path, headFn func(d *decode.D, path path) (string, int64), chunkFn func(d *decode.D, id string, path path, size int64) (bool, any)) {
22+
func riffDecode(d *decode.D, path path, headFn func(d *decode.D, path path) (string, int64), chunkFn func(d *decode.D, id string, path path) (bool, any)) {
2323
id, size := headFn(d, path)
2424

2525
d.FramedFn(size*8, func(d *decode.D) {
26-
hasChildren, data := chunkFn(d, id, path, size)
26+
hasChildren, data := chunkFn(d, id, path)
2727
if hasChildren {
2828
np := append(path, pathEntry{id: id, data: data})
2929
d.FieldArray("chunks", func(d *decode.D) {

0 commit comments

Comments
 (0)