Skip to content

Commit

Permalink
Split and implement dolby metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMarnell committed Aug 16, 2024
1 parent 7720af9 commit 42cce66
Show file tree
Hide file tree
Showing 8 changed files with 351 additions and 119 deletions.
31 changes: 31 additions & 0 deletions format/riff/adm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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) {
// fmt.Println("test axml")
// TODO(jmarnell): this chunk is all variable xml, so leave as is?
d.FieldRawLen("xml", size*8)
}
2 changes: 1 addition & 1 deletion format/riff/aiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
switch id {
case "FORM":
riffType = d.FieldUTF8("format", 4, d.StrAssert(aiffRiffType))
Expand Down
2 changes: 1 addition & 1 deletion format/riff/avi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
switch id {
case "RIFF":
foundRiffType = d.FieldUTF8("type", 4, d.StrAssert(requiredRiffType))
Expand Down
8 changes: 6 additions & 2 deletions format/riff/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
if hasChildren {
np := append(path, pathEntry{id: id, data: data})
d.FieldArray("chunks", func(d *decode.D) {
Expand Down Expand Up @@ -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",

"ISMP": "SMPTE timecode",
"IDIT": "Time and date digitizing commenced",
"IARL": "Archival Location. Indicates where the subject of the file is archived.",
Expand Down
112 changes: 0 additions & 112 deletions format/riff/dbmd.go

This file was deleted.

Loading

0 comments on commit 42cce66

Please sign in to comment.