Skip to content

Commit

Permalink
Try to fix docs, add latest, add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyMarnell committed Oct 28, 2024
1 parent 2e67911 commit 5687b08
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 17 deletions.
9 changes: 6 additions & 3 deletions doc/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,19 @@ Flags can be struct with bit-fields.
- Use commit messages with a context prefix to make it easier to find and understand, ex:<br>
`mp3: Validate sync correctly`
- Tests:
- If possible use a pair of `testdata/file` and `testdata/file.fqtest` where `file.fqtest` is `$ fq dv file` or `$ fq 'dv,torepr' file` if there is `torepr` support.
- If possible, add one or more pairs of example input file and expected CLI output, with naming like:
- `./format/<format_name>/testdata/<name>.<ext>`, e.g. [`./format/mp4/testdata/aac.mp4`](../format/mp4/testdata/aac.mp4)
- and `./format/<format_name>/testdata/<name>.fqtest`, e.g. [`./format/mp4/testdata/aac.fqtest`](../format/mp4/testdata/aac.fqtest)
- The latter contents should be `$ go run . dv <file_path>` or `$ go run . 'dv,torepr' <file_path>` if there is `torepr` support.
- If `dv` produces a lof of output maybe use `dv({array_truncate: 50})` etc
- Run `go test ./format -run TestFormats/<name>` to test expected output.
- Run `go test ./format -run TestFormats/<name> -update` to update current output as expected output.
- If you have format specific documentation:
- Put it in `format/*/<name>.md` and use `//go:embed <name>.md`/`interp.RegisterFS(..)` to embed/register it.
- Use simple markdown, just sections (depth starts at 3, `### Section`), paragraphs, lists and links.
- No heading section is needs with format name, will be added by `make doc` and fq cli help system.
- No heading section is needed with format name, will be added by `make doc` and fq cli help system.
- Add a `testdata/<name>_help.fqtest` with just `$ fq -h <name>` to test CLI help.
- If in doubt look at `mp4.md`/`mp4.go` etc.
- If in doubt look at [`mp4.md`](../format/mp4/mp4.md)/[`mp4.go`](../format/mp4/mp4.go) etc.
- Run `make README.md doc/formats.md` to update md files.
- Run linter `make lint`
- Run fuzzer `make fuzz GROUP=<name>`, see usage in Makefile
Expand Down
22 changes: 22 additions & 0 deletions format/riff/adm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[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:
```bash
$ fq -d wav '.chunks[] | select(.id | IN("chna", "axml")) | tovalue' amd-bwf.wav

# Extract ADM <axml> chunk objects definitions xml content
$ fq -r -d wav '.chunks[] | select(.id | IN("axml")) | .xml | tovalue' amd-bwf.wav | tee axml-content.xml
```

### 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
6 changes: 3 additions & 3 deletions format/riff/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func riffDecode(d *decode.D, path path, headFn func(d *decode.D, path path) (str
}
})

wordAlgin := d.AlignBits(16)
if wordAlgin != 0 {
d.FieldRawLen("align", int64(wordAlgin))
wordAlign := d.AlignBits(16)
if wordAlign != 0 {
d.FieldRawLen("align", int64(wordAlign))
}
}

Expand Down
20 changes: 10 additions & 10 deletions format/riff/dolby.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/wader/fq/pkg/scalar"
)

func dbmdDecode(d *decode.D, size int64) any {
func tmp_dbmdDecode(d *decode.D, size int64) any {

Check failure on line 15 in format/riff/dolby.go

View workflow job for this annotation

GitHub Actions / lint

`tmp_dbmdDecode` - `size` is unused (unparam)
version := d.U32()
major := (version >> 24) & 0xFF
minor := (version >> 16) & 0xFF
Expand Down Expand Up @@ -47,9 +47,9 @@ func dbmdDecode(d *decode.D, size int64) any {
case 8:
parseAudioInfo(d)
case 9:
parseDolbyAtmos(d, segmentSize)
parseDolbyAtmos(d)
case 10:
parseDolbyAtmosSupplemental(d, segmentSize)
parseDolbyAtmosSupplemental(d)
default:
d.FieldRawLen("unknown_segment_raw", int64(segmentSize*8))
}
Expand Down Expand Up @@ -117,7 +117,7 @@ var warpMode = scalar.UintMapDescription{
4: "not indicated (Default warping will be applied.)",
}

var trimConfigName = scalar.UintMapDescription{
var tmp_trimConfigName = scalar.UintMapDescription{

Check failure on line 120 in format/riff/dolby.go

View workflow job for this annotation

GitHub Actions / lint

var `tmp_trimConfigName` is unused (unused)
0: "2.0",
1: "5.1",
2: "7.1",
Expand All @@ -134,7 +134,7 @@ var trimType = scalar.UintMapDescription{
1: "automatic",
}

func parseDolbyE(d *decode.D) {
func tmp_parseDolbyE(d *decode.D) {
d.FieldValueStr("metadata_segment_type", "dolby_e")

d.FieldU8("program_config")
Expand All @@ -145,7 +145,7 @@ func parseDolbyE(d *decode.D) {
d.FieldRawLen("reserved_for_future_use", 80*8)
}

func parseDolbyDigital(d *decode.D) {
func tmp_parseDolbyDigital(d *decode.D) {
d.FieldValueStr("metadata_segment_type", "dolby_digital")

d.FieldU8("ac3_program_id")
Expand All @@ -166,7 +166,7 @@ func parseDolbyDigital(d *decode.D) {
d.FieldRawLen("program_description_text", 32*8)
}

func parseDolbyDigitalPlus(d *decode.D) {
func tmp_parseDolbyDigitalPlus(d *decode.D) {
d.FieldValueStr("metadata_segment_type", "dolby_digital_plus")

d.FieldU8("program_id")
Expand Down Expand Up @@ -205,7 +205,7 @@ func parseDolbyDigitalPlus(d *decode.D) {
d.FieldRawLen("reserved_for_future_use", 69*8)
}

func parseAudioInfo(d *decode.D) {
func tmp_parseAudioInfo(d *decode.D) {
d.FieldValueStr("metadata_segment_type", "audio_info")

d.FieldU8("program_id")
Expand All @@ -224,7 +224,7 @@ func parseAudioInfo(d *decode.D) {
d.FieldUTF8("segment_modified_date", 32)
}

func parseDolbyAtmos(d *decode.D, size uint64) {
func tmp_parseDolbyAtmos(d *decode.D, size uint64) {

Check failure on line 227 in format/riff/dolby.go

View workflow job for this annotation

GitHub Actions / lint

`tmp_parseDolbyAtmos` - `size` is unused (unparam)
d.FieldValueStr("metadata_segment_type", "dolby_atmos")

// d.SeekRel(32 * 8)
Expand All @@ -248,7 +248,7 @@ func parseDolbyAtmos(d *decode.D, size uint64) {
d.SeekRel(80 * 8)
}

func parseDolbyAtmosSupplemental(d *decode.D, size uint64) {
func tmp_parseDolbyAtmosSupplemental(d *decode.D, size uint64) {

Check failure on line 251 in format/riff/dolby.go

View workflow job for this annotation

GitHub Actions / lint

`tmp_parseDolbyAtmosSupplemental` - `size` is unused (unparam)
d.FieldValueStr("metadata_segment_type", "dolby_atmos_supplemental")

sync := d.FieldU32LE("dasms_sync")
Expand Down
2 changes: 1 addition & 1 deletion format/riff/dolby_metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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 Down
Loading

0 comments on commit 5687b08

Please sign in to comment.