]> git.sesse.net Git - ffmpeg/commit
avformat/webm_chunk: Use API functions for child muxer
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 29 Feb 2020 21:47:26 +0000 (22:47 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 26 Mar 2020 00:54:56 +0000 (01:54 +0100)
commite70c2d02fc5c12b82628c6f6eda4dfd357685e8c
tree84e2aa9afa35875abc32506daa47d233edfc738a
parenta9004ffe0f46617ab2a4725f329758a05b3ed185
avformat/webm_chunk: Use API functions for child muxer

instead of calling the write_header/packet/trailer functions directly
via the function pointers. Also, use distinct AVStreams for the child
AVFormatContext (up until now the two AVFormatContexts shared their
AVStreams because allocating their own was deemed too onerous).

Using the function pointers directly meant that the Matroska muxer's
init-function was never called, because init-functions were only
introduced a few months after webm_chunk has been added and no one
thought of/bothered to adapt webm_chunk for this (when the init-function
was added in b287d7ea, the code setting the timebase was moved to it,
so that the timebases were no longer set to ms-precision when using
the webm_chunk muxer; this has been fixed after some time in 42a635dd
by setting the timebases direcly (instead of calling the init-function)).

And when 982a98a0 added a deinit-function for the Matroska muxer, it
introduced memleaks in webm_chunk, because the child muxer's internal
structures were no longer freed when calling write_trailer directly.
(Given that the init function has never ever been called, the child
muxer has never ever been properly initialized, so that the
deinit-function was not called when freeing the child context.)

This commit stops calling the function pointers directly and instead
uses the standard API functions for muxers. This fixes the above
mentioned memleaks. (Memleaks are still possible on error. This will be
fixed in a future commit that adds a deinit-function to webm_chunk
itself.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/webm_chunk.c