rust-av / matroska

Matroska format support
MIT License
95 stars 20 forks source link

interspersed simple blocks and block groups #137

Open dvc94ch opened 1 year ago

dvc94ch commented 1 year ago

seems like it's valid to intersperse these, but the parser tries to parse simple blocks and then block groups. also wondering why the parser was built using so many macros. seems hard to understand/maintain.

lu-zero commented 1 year ago

Because it was originally written when nom itself was only a set of very clever and convoluted macros. If you want to convert some to functions you are very welcome to contribute :)

Do you have a sample file? @robUx4 is it valid to intersperse?

robUx4 commented 1 year ago

You can mix SimpleBlock and BlockGroup, yes. Even for the same track. One common case is to use SimpleBlock for the whole (audio) track, except for the last frame when you want to set the duration and so you need a BlockGroup.

dvc94ch commented 1 year ago

I think the muxer/demuxer traits might just get in my way more than they help, as I'm mainly interested in handling webm files. I built a prototype derive macro for reading/writing webm files using webm-iterable to handle the ebml, but that will likely change in the future as the iterator api doesn't really help when it comes to determining cluster or segment offsets for cues/seek-heads.

I'm still considering if the codec traits are a potentially useful abstraction for software encoders/decoders, but if I have a pipeline (pipewire -> vaapi -> webm) for example, instead of sending packets I probably want to send a linux dmabuf fd instead. I'm guessing there is an equivalent on other platforms.

lu-zero commented 1 year ago

In theory you may wrap a dmabuf in a FrameBuffer, but Packet as it is assumes you are copying to its own storage, Ideally one could extend it similarly.

dvc94ch commented 1 year ago

I'm thinking I'll build a fixed function pipeline first, which will hopefully produce high quality components for pipewire, vaapi, webm, dash and then see later if/how they can be integrated into rust-av if I ever get around to adding support for more platforms.