-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RenderData does not write non-mandatory elements having a default value #73
Comments
To fix this there are (at least) two places to change: It should also check that it's mandatory with |
I also thought this method have to change, but now I'm not sure.
bWithDefault is set to false. For a non-mandatory element with a default value, the Therefore, I think BUT for the Master element the |
Mmmh... then we lose the sense of the DefaultVaule attribute. |
Background
Let's take one of our new flags,
KaxFlagHearingImpaired
. It isn't mandatory, but it has a default value of 0.Semantically there are three different states:
Bug
The various
Render
andRenderData
functions in libebml contain a parameter governing whether or not libebml should write elements whose current value equals their default value. Unfortunately this function does NOT take into account whether or not the element is mandatory. They only compare the current value with the default value, both for mandatory and for non-mandatory elements.So the situation is:
bWithDefault
is set to → element is not present in file. OK.bWithDefault = true
→ element is present in file. OK.bWithDefault = false
→ element is NOT present in file. Not OK, as the file representation is now semantically different than the representation in memory.Proposed change
EbmlElement::Render()
should take into account whether or not an element is mandatory. If it is not mandatory, its value should always be written, no matter what thebWithDefault
parameter is set to.How to reproduce
Here's an example program:
Compile with current libebml & libmatroska. Run it. Run
mkvinfo test.mkv
and observe:For both tracks the flag is explicitly set. However, libebml only writes the element if it is set to a value that is NOT its default value as is the case for track 1. For track 2 the element, even though it is present in the data structure to be written to disk, is not written as the value that was set equals the element's default value.
The text was updated successfully, but these errors were encountered: