-
Notifications
You must be signed in to change notification settings - Fork 24
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
Writing elements with a default value if the element can be multiple #409
Comments
There's indeed an issue for the general case. I understood the issue better after reading this commit. The element is mandatory so it must be either written explicitly or omitted and then the default value is used. If it is ommited We can assume the default value is used. But if there's a second value to use we can't really tell if the default value is also assumed to be present or not. IMO this logic is not possible, a mandatory element with a default value MUST be unique (maxOccurs=1). I think it would work for |
Following the discussion in ietf-wg-cellar/ebml-specification#409 It could be assumed that English is always present because ChapLanguage is mandatory and has a default value. To avoid this interpretation we should have one language (and one IETF variant) per ChapterDisplay item. We already have to use many ones per language. The merge of different values because they have the same value is unlikely (but it may exist in the real world).
An other alternative is to specify that the default value only applies if the element is unique. In other words if you have to store 2 values and one of them is the default value, the value must be explicitly set (like the mkvmerge fix). But that's a more complex thing to handle in muxers as you need to check each sibling elements before being able to write an element, write the value of the element, or use zero-length. An extra loop was added to mkvmerge to handle this case, the same would need to be done in libebml (and possibly in various places everytime we check if an element needs to be saved or not). A similar change may be needed in libavformat and libwebm as well... That's why I think restricting |
I disagree. I find the specs pretty clear on this point: a reader has to use the default value if and only if the element isn't present in the master at all. If it is present, no matter how many times, the default value simply doesn't come into play. This in turn leads to a pretty easy-to-follow rule for writers: if you need to write more than one element of the same type in the same master, they must all be written, no matter their value. Therefore I'd prefer not to change the specs retroactively (even though I'd probably make both
Yes, it's more complex for a writer, though the algorithm itself isn't that complex at all:
This (and its implementation in I just don't like changing specs retroactively, especially as there are programs out there ( @hubblec4 's ChapterEditor) that already use multiple languages & countries per display.
If we decide to change the specs retroactively that way, we should also make And while we're at it, |
You are wrong with this in my opinion. I have also implemented this feature this night and it was very easy.
Wow, why not? |
In german and english you have so often the same word and so I don't need to insert a second ChapterDisplay with the same chapter string. |
No. This breaks a lot of files(which I have) and I have to re-write my chapterEditor. |
I don't think it's that crystal clear in RFC 8794: https://www.rfc-editor.org/rfc/rfc8794.html#section-11.1.6.8 and https://www.rfc-editor.org/rfc/rfc8794.html#name-note-on-the-use-of-default- There's even a table with all cases explaining when you should write it or not. Not a mention if the value is unique or not. However the definition of default may lead towards that interpretation:
It defines when a missing element should be interpreted as the default value present. It doesn't say when another value is present. One could assume if it's present that rule doesn't apply and so we're back to normal. One could also argue that the last sentence can be interpreted as the mandatory+default element is always present. In that interpretation the value of maxOccurs would determine if both written and unwritten values could be used or only the written one. It doesn't seem right but it fits with RFC 8794 as it is now. Most of our elements with a default value have a IMO something like what @mbunkus says should be added to the
|
Yeah, I would say the mention if the value is unique or not is missing and should be added to these table.
Only the |
In this section we find an overview about when an element is required to write.
But the attribute multiple (maxOccurs > 1) is not taken into account.
As example: the ChapLanguage element. It has a default vaule, since a while it has also a mandatory attribute and it is multiple.
If we use the ChapLanguage element multiple times within a ChapterDisplay element, and one of the element has a value of "eng" which is the default value, then this ChapLangaue element must be written.
If this element is not written there is no way to get/restore this info on reading.
Here is a link to MKVToolNix where I describ this issue and you find a sample xml for testing.
The text was updated successfully, but these errors were encountered: