Skip to content

Separate EBML from Matroska, add another EBML-based format: MOSAIC - #1375

Merged
wader merged 6 commits into
wader:masterfrom
martinkirch:add-mosaic
Aug 27, 2026
Merged

Separate EBML from Matroska, add another EBML-based format: MOSAIC#1375
wader merged 6 commits into
wader:masterfrom
martinkirch:add-mosaic

Conversation

@martinkirch

Copy link
Copy Markdown

as discussed in #1371

the only modification to the Matroska parser is a check of the doctype field; without this, Matroska would probe positively any EBML file.

Martin Kirchgessner added 3 commits August 24, 2026 11:52
This will ease the parsing of other EBML-based formats. It also checks
the EBML doctype, so matroska will not probe positively on any EBML
file.
This flags elements that don't need to be decoded to an array because,
according to the schema, they should appear only once in their parent
element.

@wader wader left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good i think 👍 had some comments and thoughts

Comment thread format/matroska/ebml_matroska/ebml_matroska_gen.go Outdated
Comment thread format/mosaic/mosaic.md
Comment thread format/mosaic/mosaic.md Outdated
Comment thread format/mosaic/mosaic.go
interp.RegisterFS(mosaicFS)
}

func decodeMaster(d *decode.D, bitsLimit int64, elm *ebml.Master) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much nicer and produces much nicer decode tree than the matroska code. I'm not sure why i didn't opt for a similar structure, maybe was a bit unsure about uniqueness restrictions in ebml (or was spooked by https://www.rfc-editor.org/rfc/rfc8794.html#name-identically-recurring-eleme, but not sure i've even seen it in practice?). Will probably convert matroska later to something similar, i did a quick hack using your code it seems to work.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed matroska has a few elements having maxOccurs="1" and recurring="1", so those could not be rendered that way - maybe they should not be flagged "singleton" by the current code generator?

also that works nicely (espacially for arrays) as long as elements are coherent, maybe that happens less in matroska?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah didn't notice the recurring attribute in the schema, that is good to know. Not sure how often it happens in matroska, will do some research later on. But yes sound reasonable it should not be a singleton in those cases, maybe could replace singleton with maxOccurs and recurring and let format decoder code decide what is a singleton etc?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good idea, the code generator should just copy such XML attributes. Changing this.

Comment thread format/mosaic/mosaic.go
Comment thread format/mosaic/mosaic.go

@wader wader left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks mergable to me! had one comment about singleton but that can be done later if it make sense. Anything else you want to add or change?

@wader

wader commented Aug 27, 2026

Copy link
Copy Markdown
Owner

If you have asciidoctor installed you could do a make doc/fq.1.adoc doc/fq.1 doc/fq.1.html and verify/commit fq.1 and fq.1.adoc. No need to add fq.1.html, it will get generated and deployed in a CI job

This avoids relying on a mosaic-specific isSingleton().

By the way: complete elements and attributes' coverage, fix a documentation string.
@martinkirch

Copy link
Copy Markdown
Author

I've completed and fix and few EBML elements by the way. It required a minor modification of Matroska's tests. I think we're good !

Comment thread format/ebml/gen/main.go
}
if c.MaxVer != "" {
fmt.Printf(" MaxVer: %s,\n", c.MaxVer)
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugg the code for this tool is getting quite ugly 😬 but not sure it's worth tidying up, maybe later :)

@wader
wader merged commit 429edc0 into wader:master Aug 27, 2026
5 checks passed
@wader

wader commented Aug 27, 2026

Copy link
Copy Markdown
Owner

Very nice, thanks and hope fq will be useful! what are the main use cases? used while developing or debugging corruption etc?

@martinkirch

Copy link
Copy Markdown
Author

Debugging corruption while developing, at least.

We also care to be readable outside of the archive's infrastructure, so a CLI tool with a query language is an interesting alternative to our python/rust API. Although that supposes fq scales to our typical files' size: in the order of 100GB. I'll test that next week.

@wader

wader commented Aug 29, 2026

Copy link
Copy Markdown
Owner

👍

About file size: fq's resource usage should mostly scale by number of decode values and how much memory their actual/symbolic and descriptions uses. The bits "backing" a decode value is only keept track of as a range and are read on-demand if needed. Also maybe good to know that "raw" fields (ex d.FieldRawLen) will have an actual value that is on-demand read, usually used for large blobs etc. I've used fq with 60gb mp4 files without much issues, the memory usage and decode time depend mostly on number of packets/samples.

But note that i haven't spend that much time trying to optimize memory usage so ideas are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants