-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADM (Audio Definition Model) and Dolby Metadata in WAV/RIFF #991
base: master
Are you sure you want to change the base?
Changes from 3 commits
7720af9
42cce66
d2c84e1
b55a837
1e0ba55
83abdda
f2a6987
04539fe
2e67911
5687b08
c009996
90adba3
202b723
351920d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package riff | ||
|
||
// Audio Definition Model | ||
// https://adm.ebu.io/background/what_is_the_adm.html | ||
// https://tech.ebu.ch/publications/tech3285s7 | ||
// https://tech.ebu.ch/publications/tech3285s5 | ||
|
||
import ( | ||
"github.com/wader/fq/pkg/decode" | ||
) | ||
|
||
func chnaDecode(d *decode.D, size int64) { | ||
d.FieldU16("num_tracks") | ||
d.FieldU16("num_uids") | ||
|
||
audioIdLen := (size - 4) / 40 | ||
d.FieldStructNArray("audio_ids", "audio_id", int64(audioIdLen), func(d *decode.D) { | ||
d.FieldU16("track_index") | ||
d.FieldUTF8("uid", 12) | ||
d.FieldUTF8("track_format_id_reference", 14) | ||
d.FieldUTF8("pack_format_id_reference", 11) | ||
// Skip padding single byte | ||
d.U8() | ||
}) | ||
} | ||
|
||
func axmlDecode(d *decode.D, size int64) { | ||
// TODO(jmarnell): this chunk is all variable xml, so leave as is? | ||
d.FieldRawLen("xml", size*8) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ func aiffDecode(d *decode.D) any { | |
} | ||
return id, size | ||
}, | ||
func(d *decode.D, id string, path path) (bool, any) { | ||
func(d *decode.D, id string, path path, size int64) (bool, any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
switch id { | ||
case "FORM": | ||
riffType = d.FieldUTF8("format", 4, d.StrAssert(aiffRiffType)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,7 +238,7 @@ func aviDecodeEx(d *decode.D, ai format.AVI_In, extendedChunk bool) { | |
size := d.FieldU32("size") | ||
return id, int64(size) | ||
}, | ||
func(d *decode.D, id string, path path) (bool, any) { | ||
func(d *decode.D, id string, path path, size int64) (bool, any) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
switch id { | ||
case "RIFF": | ||
foundRiffType = d.FieldUTF8("type", 4, d.StrAssert(requiredRiffType)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,11 @@ func (p path) topData() any { | |
return p[len(p)-1].data | ||
} | ||
|
||
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)) { | ||
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)) { | ||
id, size := headFn(d, path) | ||
|
||
d.FramedFn(size*8, func(d *decode.D) { | ||
hasChildren, data := chunkFn(d, id, path) | ||
hasChildren, data := chunkFn(d, id, path, size) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may have been doing it wrong, but that's what I tried initially, hope to get to revisit soon! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okok yeah in this case i think relying on framing should work and i think it usually ends up with nicer code, let's try that first at least |
||
if hasChildren { | ||
np := append(path, pathEntry{id: id, data: data}) | ||
d.FieldArray("chunks", func(d *decode.D) { | ||
|
@@ -58,6 +58,10 @@ var chunkIDDescriptions = scalar.StrMapDescription{ | |
|
||
"dmlh": "Extended AVI header", | ||
|
||
"chna": "<chna> Chunk, Track UIDs of Audio Definition Model", | ||
"axml": "<axml> Chunk, BWF XML Metadata, e.g. for Audio Definition Model ambisonics and elements", | ||
"dbmd": "Dolby Metadata, e.g. Atmos, AC3, Dolby Digital [Plus]", | ||
|
||
"ISMP": "SMPTE timecode", | ||
"IDIT": "Time and date digitizing commenced", | ||
"IARL": "Archival Location. Indicates where the subject of the file is archived.", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to a doly_metadata.md file in format/tiff, formats.md is autogenerated via
make doc
. Then also add something like this https://github.com/wader/fq/blob/master/format/msgpack/msgpack.go#L16-L29 and the documentation will also ge available in the clifq -h dolby_metadata
andhelp(dolby_metadata)
Same for adm above