[FFmpeg-devel] [PATCH 10/15] avformat/matroskaenc: Avoid seeking when writing level 1 elements
h.leppkes at gmail.com
Tue Apr 2 17:30:50 EEST 2019
On Tue, Apr 2, 2019 at 3:36 PM Andreas Rheinhardt via ffmpeg-devel
<ffmpeg-devel at ffmpeg.org> wrote:
> Up until now, the writing process for level 1 elements (those elements
> for which CRC-32 elements are written by default) was this in case the
> output was seekable: Write the EBML ID, write an "unkown length" EBML
> number of the desired length, then write the element into a dynamic
> buffer, then write the dynamic buffer (after possible calculation and
> writing of the CRC-element), then seek back to the size element and
> overwrite the unknown-size element with the real size. The seeking and
> overwriting part has been eliminated by not writing the size initially.
I'm not particularly happy that it stops using start_ebml_master and
basically duplicates its functionality. This adds possible maintenance
in the future, or hidden bugs.
Additionally, before this change, the position of the current writer
points to the position where the dynamic block is actually going to be
written - after this, it'll write the size inbetween.
Especially considering this behavior is different between seek and
non-seek, I feel a bit uneasy if something might want to reference the
position - there is a specific warning about that in the CRC case,
which would apply here equally.
Maybe the last point can be improved if the size is being included in
the dynamic buffer and overwritten therein, as such making relative
positions valid again, even if different to the non-seek case?
More information about the ffmpeg-devel