aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/rangecoder.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-16 14:33:51 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-02-22 03:57:16 +0100
commit5b9a0e6031eee5df2e0d6a35862908c6a017f490 (patch)
tree7e545ca8f641e547b62cccf996709cad5c84e3b7 /libavcodec/rangecoder.c
parent37b069e361fd2313b9c07c1e7be94adcad619ce2 (diff)
downloadffmpeg-5b9a0e6031eee5df2e0d6a35862908c6a017f490.tar.gz
avformat/matroskadec: Allow to count the number of element occurences
Up until now, the generic EBML reader used by the Matroska demuxer did not have the capability to record whether an element was actually present or not; instead, in cases where it mattered one typically added an invalid default value and checked whether the value is valid (in which case it is guaranteed to be present). This worked pretty well so far, yet the EBML specifications have evolved: It is now legal to use zero-length elements for floats, ints, uints and strings (both ASCII and UTF-8); the value of these elements is the default value of the element (if it has one) or zero for scalar types and an empty string for strings. Furthermore, having a default value does no longer imply that the element may be presumed to be present (with its default value) if it is absent; this is only true if the element is mandatory, too. These rules are designed to allow size savings as follows: Consider the newly added FlagOriginal: It being zero means the track is not in its original language, it being one means it is. For backward compatibility reasons, neither of the two values may be inferred automatically in the absence of the element. But one can still save a byte when one wants to write the element with a value of zero, as one can write the integer with a length of zero: 0x55AE 80 instead of 0x55AE 81 00. In the former case, a parser has to infer the value of the element to be zero (which is the element's default value). When encountering an element with length zero, our parser always infers a value of zero (or an empty string); this is wrong for values with a different default value. It needs to infer the default value (or zero in its absence) and this precludes using an invalid default value for elements like FlagOriginal. Ergo one needs to be able to record whether an element is present or not by other means. This patch allows to use a simple counter for this. While just at it, some invalid and unnecessary default values have been removed (mastering metadata elements used default values of -1.0, despite these elements only being used if they are > 0). Reviewed-by: Ridley Combs <rcombs@rcombs.me> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/rangecoder.c')
0 files changed, 0 insertions, 0 deletions