[FFmpeg-devel] [PATCH 00/10] avformat/matroskadec: Various patches

Andreas Rheinhardt andreas.rheinhardt at googlemail.com
Fri Mar 8 11:25:54 EET 2019


The check introduced in 9326117bf63b04a466d9e787224e56ba8cdbb215 had
the unintended consequence of introducing an error message after one
has reached the end of the last cluster if there is another element
after the last cluster (and if the last cluster was not an unknown-size
encoded cluster). This happens only when using incremental parsing
(i.e. currently when there are no SSA subtitles in the input) and it
happens because incremental parsing takes a lot of liberties wrt levels:

matroska_cluster_incremental_parsing includes elements that actually
exist at different levels, namely several level 1 elements (declared
to be EBML_NONE and EBML_STOP) and also the elements typically found
in clusters. There is no check via ebml_level_end before every call to
ebml_parse like in ebml_parse_nest (that is used implicitly by the
non-incremental parser); instead, when a new cluster is found (detected
via the return value), ebml_level_end is called and that's it. If the
check introduced in 9326117bf63b04a466d9e787224e56ba8cdbb215 were to
be applied to every EBML_STOP element, every cluster whose preceding
cluster was not unknown-sized would cause the error. But the way things
are, the cues and tags at the end of most files (which are not of type
EBML_STOP in matroska_cluster_incremental_parsing) trigger this error.

I am working on a fix, but in the course of reading and understanding
the Matroska demuxer I have also found several other things to improve;
I want to share them with you so that the review process for them doesn't
need to wait unnecessarily. Besides no-brainers like removing a variable
that is unused for more than ten years the most important things are the
elimination of the list containing all the blocks from a cluster (The
blocks are now directly parsed and freed. There is no need at all to keep
them (which also means that no longer does a list have to be dynamically
reallocated for them).) and of the special status of the SimpleBlock
(the only element of type EBML_PASS). It is now a simple EBML_BIN.

Andreas Rheinhardt (10):
  avformat/matroskadec: Remove an unused variable
  avformat/matroskadec: Don't zero unnecessarily
  avformat/matroskadec: Don't make unnecessary assumptions
  avformat/matroskadec: Use generic size check for signed integers
  avformat/matroskadec: Remove non-incremental parsing of clusters
  avformat/matroskadec: Don't keep old blocks
  avformat/matroskadec: Treat SimpleBlock as EBML_BIN
  avformat/matroskadec: Remove redundant variable declaration
  avformat/matroskadec: Improve length check
  avformat/matroskadec: Typos and cosmetics

 libavformat/matroskadec.c | 205 +++++++++++++-------------------------
 1 file changed, 72 insertions(+), 133 deletions(-)

-- 
2.19.2



More information about the ffmpeg-devel mailing list