idnits 2.17.1 draft-ietf-cellar-ebml-11.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (September 24, 2019) is 1676 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Looks like a reference, but probably isn't: '1' on line 2253 == Missing Reference: 'EBMLParentPath' is mentioned on line 939, but not defined == Missing Reference: 'EBMLMinOccurrence' is mentioned on line 950, but not defined == Missing Reference: 'EBMLMaxOccurrence' is mentioned on line 950, but not defined == Missing Reference: 'PathMinOccurrence' is mentioned on line 953, but not defined == Missing Reference: 'PathMaxOccurrence' is mentioned on line 953, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'IEEE.754.1985' -- Possible downref: Non-RFC (?) normative reference: ref. 'ITU.V42.1994' Summary: 0 errors (**), 0 flaws (~~), 6 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 cellar S. Lhomme 3 Internet-Draft 4 Intended status: Standards Track D. Rice 5 Expires: March 27, 2020 6 M. Bunkus 7 September 24, 2019 9 Extensible Binary Meta Language 10 draft-ietf-cellar-ebml-11 12 Abstract 14 This document defines the Extensible Binary Meta Language (EBML) 15 format as a generalized file format for any type of data in a 16 hierarchical form. EBML is designed as a binary equivalent to XML 17 and uses a storage-efficient approach to build nested Elements with 18 identifiers, lengths, and values. Similar to how an XML Schema 19 defines the structure and semantics of an XML Document, this document 20 defines how EBML Schemas are created to convey the semantics of an 21 EBML Document. 23 Status of This Memo 25 This Internet-Draft is submitted in full conformance with the 26 provisions of BCP 78 and BCP 79. 28 Internet-Drafts are working documents of the Internet Engineering 29 Task Force (IETF). Note that other groups may also distribute 30 working documents as Internet-Drafts. The list of current Internet- 31 Drafts is at https://datatracker.ietf.org/drafts/current/. 33 Internet-Drafts are draft documents valid for a maximum of six months 34 and may be updated, replaced, or obsoleted by other documents at any 35 time. It is inappropriate to use Internet-Drafts as reference 36 material or to cite them other than as "work in progress." 38 This Internet-Draft will expire on March 27, 2020. 40 Copyright Notice 42 Copyright (c) 2019 IETF Trust and the persons identified as the 43 document authors. All rights reserved. 45 This document is subject to BCP 78 and the IETF Trust's Legal 46 Provisions Relating to IETF Documents 47 (https://trustee.ietf.org/license-info) in effect on the date of 48 publication of this document. Please review these documents 49 carefully, as they describe your rights and restrictions with respect 50 to this document. Code Components extracted from this document must 51 include Simplified BSD License text as described in Section 4.e of 52 the Trust Legal Provisions and are provided without warranty as 53 described in the Simplified BSD License. 55 Table of Contents 57 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 58 2. Notation and Conventions . . . . . . . . . . . . . . . . . . 4 59 3. Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 7 60 4. Variable Size Integer . . . . . . . . . . . . . . . . . . . . 7 61 4.1. VINT_WIDTH . . . . . . . . . . . . . . . . . . . . . . . 7 62 4.2. VINT_MARKER . . . . . . . . . . . . . . . . . . . . . . . 7 63 4.3. VINT_DATA . . . . . . . . . . . . . . . . . . . . . . . . 8 64 4.4. VINT Examples . . . . . . . . . . . . . . . . . . . . . . 8 65 5. Element ID . . . . . . . . . . . . . . . . . . . . . . . . . 9 66 6. Element Data Size . . . . . . . . . . . . . . . . . . . . . . 10 67 6.1. Data Size Format . . . . . . . . . . . . . . . . . . . . 10 68 6.2. Unknown Data Size . . . . . . . . . . . . . . . . . . . . 11 69 6.3. Data Size Values . . . . . . . . . . . . . . . . . . . . 12 70 7. EBML Element Types . . . . . . . . . . . . . . . . . . . . . 13 71 7.1. Signed Integer Element . . . . . . . . . . . . . . . . . 14 72 7.2. Unsigned Integer Element . . . . . . . . . . . . . . . . 14 73 7.3. Float Element . . . . . . . . . . . . . . . . . . . . . . 14 74 7.4. String Element . . . . . . . . . . . . . . . . . . . . . 15 75 7.5. UTF-8 Element . . . . . . . . . . . . . . . . . . . . . . 15 76 7.6. Date Element . . . . . . . . . . . . . . . . . . . . . . 15 77 7.7. Master Element . . . . . . . . . . . . . . . . . . . . . 15 78 7.8. Binary Element . . . . . . . . . . . . . . . . . . . . . 16 79 8. EBML Document . . . . . . . . . . . . . . . . . . . . . . . . 16 80 8.1. EBML Header . . . . . . . . . . . . . . . . . . . . . . . 16 81 8.2. EBML Body . . . . . . . . . . . . . . . . . . . . . . . . 16 82 9. EBML Stream . . . . . . . . . . . . . . . . . . . . . . . . . 17 83 10. EBML Versioning . . . . . . . . . . . . . . . . . . . . . . . 17 84 10.1. EBML Header Version . . . . . . . . . . . . . . . . . . 17 85 10.2. EBML Document Version . . . . . . . . . . . . . . . . . 17 86 11. Elements semantic . . . . . . . . . . . . . . . . . . . . . . 17 87 11.1. EBML Schema . . . . . . . . . . . . . . . . . . . . . . 17 88 11.1.1. EBML Schema Example . . . . . . . . . . . . . . . . 18 89 11.1.2. Element . . . . . . . . . . . . . . . . 19 90 11.1.3. Attributes . . . . . . . . . . . . . . 19 91 11.1.4. Element . . . . . . . . . . . . . . . . . 20 92 11.1.5. Attributes . . . . . . . . . . . . . . . . 20 93 11.1.6. Element . . . . . . . . . . . . . . 26 94 11.1.7. Attributes . . . . . . . . . . . . . 26 95 11.1.8. Element . . . . . . . . . . . 26 96 11.1.9. Attributes . . . . . . . . . . 27 97 11.1.10. Element . . . . . . . . . . . . . . . 27 98 11.1.11. Element . . . . . . . . . . . . . . . . . . . 27 99 11.1.12. Attributes . . . . . . . . . . . . . . . . . 27 100 11.1.13. Element . . . . . . . . . . . . . . . . 28 101 11.1.14. Attributes . . . . . . . . . . . . . . . 28 102 11.1.15. XML Schema for EBML Schema . . . . . . . . . . . . . 28 103 11.1.16. Identically Recurring Elements . . . . . . . . . . . 31 104 11.1.17. Textual expression of floats . . . . . . . . . . . . 31 105 11.1.18. Note on the use of default attributes to define 106 Mandatory EBML Elements . . . . . . . . . . . . . . 32 107 11.2. EBML Header Elements . . . . . . . . . . . . . . . . . . 33 108 11.2.1. EBML Element . . . . . . . . . . . . . . . . . . . . 33 109 11.2.2. EBMLVersion Element . . . . . . . . . . . . . . . . 33 110 11.2.3. EBMLReadVersion Element . . . . . . . . . . . . . . 34 111 11.2.4. EBMLMaxIDLength Element . . . . . . . . . . . . . . 34 112 11.2.5. EBMLMaxSizeLength Element . . . . . . . . . . . . . 35 113 11.2.6. DocType Element . . . . . . . . . . . . . . . . . . 35 114 11.2.7. DocTypeVersion Element . . . . . . . . . . . . . . . 36 115 11.2.8. DocTypeReadVersion Element . . . . . . . . . . . . . 36 116 11.2.9. DocTypeExtension Element . . . . . . . . . . . . . . 37 117 11.2.10. DocTypeExtensionName Element . . . . . . . . . . . . 37 118 11.2.11. DocTypeExtensionVersion Element . . . . . . . . . . 37 119 11.3. Global Elements . . . . . . . . . . . . . . . . . . . . 38 120 11.3.1. CRC-32 Element . . . . . . . . . . . . . . . . . . . 38 121 11.3.2. Void Element . . . . . . . . . . . . . . . . . . . . 39 122 12. Considerations for Reading EBML Data . . . . . . . . . . . . 39 123 13. Terminating Elements . . . . . . . . . . . . . . . . . . . . 39 124 14. Guidelines for Updating Elements . . . . . . . . . . . . . . 40 125 14.1. Reducing a Element Data in Size . . . . . . . . . . . . 40 126 14.1.1. Adding a Void Element . . . . . . . . . . . . . . . 40 127 14.1.2. Extending the Element Data Size . . . . . . . . . . 40 128 14.1.3. Terminating Element Data . . . . . . . . . . . . . . 41 129 14.2. Considerations when Updating Elements with Cyclic 130 Redundancy Check (CRC) . . . . . . . . . . . . . . . . . 42 131 15. Backward and Forward Compatibility . . . . . . . . . . . . . 42 132 15.1. Backward Compatibility . . . . . . . . . . . . . . . . . 42 133 15.2. Forward Compatibility . . . . . . . . . . . . . . . . . 42 134 16. Security Considerations . . . . . . . . . . . . . . . . . . . 43 135 17. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 44 136 17.1. CELLAR EBML Element ID Registry . . . . . . . . . . . . 44 137 17.2. CELLAR EBML DocType Registry . . . . . . . . . . . . . . 46 138 18. References . . . . . . . . . . . . . . . . . . . . . . . . . 47 139 18.1. Normative References . . . . . . . . . . . . . . . . . . 47 140 18.2. Informative References . . . . . . . . . . . . . . . . . 48 141 18.3. URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 48 142 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 48 144 1. Introduction 146 EBML, short for Extensible Binary Meta Language, specifies a binary 147 and octet (byte) aligned format inspired by the principle of XML (a 148 framework for structuring data). 150 The goal of this document is to define a generic, binary, space- 151 efficient format that can be used to define more complex formats 152 using an EBML Schema. EBML is used by the multimedia container 153 Matroska [1]. The applicability of EBML for other use cases is 154 beyond the scope of this document. 156 The definition of the EBML format recognizes the idea behind HTML and 157 XML as a good one: separate structure and semantics allowing the same 158 structural layer to be used with multiple, possibly widely differing 159 semantic layers. Except for the EBML Header and a few Global 160 Elements this specification does not define particular EBML format 161 semantics; however this specification is intended to define how other 162 EBML-based formats can be defined, such as the audio-video container 163 formats Matroska and WebM. 165 EBML uses a simple approach of building Elements upon three pieces of 166 data (tag, length, and value) as this approach is well known, easy to 167 parse, and allows selective data parsing. The EBML structure 168 additionally allows for hierarchical arrangement to support complex 169 structural formats in an efficient manner. 171 A typical EBML file has the following structure: 173 EBML Header (master) 174 + DocType (string) 175 + DocTypeVersion (unsigned integer) 176 EBML Body Root (master) 177 + ElementA (utf-8) 178 + Parent (master) 179 + ElementB (integer) 180 + Parent (master) 181 + ElementB (integer) 183 2. Notation and Conventions 185 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 186 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 187 "OPTIONAL" in this document are to be interpreted as described in BCP 188 14 [RFC2119] [RFC8174] when, and only when, they appear in all 189 capitals, as shown here. 191 This document defines specific terms in order to define the format 192 and application of "EBML". Specific terms are defined below: 194 "EBML": Extensible Binary Meta Language 196 "EBML Document Type": A name provided by an "EBML Schema" to 197 designate a particular implementation of "EBML" for a data format 198 (e.g.: matroska and webm). 200 "EBML Schema": A standardized definition for the structure of an 201 "EBML Document Type". 203 "EBML Document": A datastream comprised of only two components, an 204 "EBML Header" and an "EBML Body". 206 "EBML Reader": A data parser that interprets the semantics of an 207 "EBML Document" and creates a way for programs to use "EBML". 209 "EBML Stream": A file that consists of one or more "EBML Documents" 210 that are concatenated together. 212 "EBML Header": A declaration that provides processing instructions 213 and identification of the "EBML Body". The "EBML Header" is 214 analogous to an XML Declaration [W3C.REC-xml-20081126] (see section 215 2.8 on Prolog and Document Type Declaration). 217 "EBML Body": All data of an "EBML Document" following the "EBML 218 Header". 220 "Variable Size Integer": A compact variable-length binary value which 221 defines its own length. 223 "VINT": Also known as "Variable Size Integer". 225 "EBML Element": A foundation block of data that contains three parts: 226 an "Element ID", an "Element Data Size", and "Element Data". 228 "Element ID": The "Element ID" is a binary value, encoded as a 229 "Variable Size Integer", used to uniquely identify a defined "EBML 230 Element" within a specific "EBML Schema". 232 "EBML Class": A representation of the octet length of an "Element 233 ID". 235 "Element Data Size": An expression, encoded as a "Variable Size 236 Integer", of the length in octets of "Element Data". 238 "VINTMAX": The maximum possible value that can be stored as "Element 239 Data Size". 241 "Unknown-Sized Element": An "Element" with an unknown "Element Data 242 Size". 244 "Element Data": The value(s) of the "EBML Element" which is 245 identified by its "Element ID" and "Element Data Size". The form of 246 the "Element Data" is defined by this document and the corresponding 247 "EBML Schema" of the Element's "EBML Document Type". 249 "Root Level": The starting level in the hierarchy of an "EBML 250 Document". 252 "Root Element": A mandatory, non-repeating "EBML Element" which 253 occurs at the top level of the path hierarchy within an "EBML Body" 254 and contains all other "EBML Elements" of the "EBML Body", excepting 255 optional "Void Elements". 257 "Top-Level Element": An "EBML Element" defined to only occur as a 258 "Child Element" of the "Root Element". 260 "Master Element": The "Master Element" contains zero, one, or many 261 other "EBML Elements". 263 "Child Element": A "Child Element" is a relative term to describe the 264 "EBML Elements" immediately contained within a "Master Element". 266 "Parent Element": A relative term to describe the "Master Element" 267 which contains a specified element. For any specified "EBML Element" 268 that is not at "Root Level", the "Parent Element" refers to the 269 "Master Element" in which that "EBML Element" is contained. 271 "Descendant Element": A relative term to describe any "EBML Elements" 272 contained within a "Master Element", including any of the "Child 273 Elements" of its "Child Elements", and so on. 275 "Void Element": A "Void Element" is an "Element" used to overwrite 276 data or reserve space within a "Master Element" for later use. 278 "Element Name": The human-readable name of the "EBML Element". 280 "Element Path": The hierarchy of "Parent Element" where the "EBML 281 Element" is expected to be found in the "EBML Body". 283 "Empty Element": An "EBML Element" that has an "Element Data Size" 284 with all "VINT_DATA" bits set to zero, which indicates that the 285 "Element Data" of the "Element" is zero octets in length. 287 3. Structure 289 EBML uses a system of Elements to compose an EBML Document. EBML 290 Elements incorporate three parts: an Element ID, an Element Data 291 Size, and Element Data. The Element Data, which is described by the 292 Element ID, includes either binary data, one or more other EBML 293 Elements, or both. 295 4. Variable Size Integer 297 The Element ID and Element Data Size are both encoded as a Variable 298 Size Integer. The Variable Size Integer is composed of a VINT_WIDTH, 299 VINT_MARKER, and VINT_DATA, in that order. Variable Size Integers 300 MUST left-pad the VINT_DATA value with zero bits so that the whole 301 Variable Size Integer is octet-aligned. Variable Size Integer will 302 be referred to as VINT for shorthand. 304 4.1. VINT_WIDTH 306 Each Variable Size Integer begins with a VINT_WIDTH which consists of 307 zero or many zero-value bits. The count of consecutive zero-values 308 of the VINT_WIDTH plus one equals the length in octets of the 309 Variable Size Integer. For example, a Variable Size Integer that 310 starts with a VINT_WIDTH which contains zero consecutive zero-value 311 bits is one octet in length and a Variable Size Integer that starts 312 with one consecutive zero-value bit is two octets in length. The 313 VINT_WIDTH MUST only contain zero-value bits or be empty. 315 Within the EBML Header the VINT_WIDTH of a VINT MUST NOT exceed three 316 bits in length (meaning that the Variable Size Integer MUST NOT 317 exceed four octets in length) except if said VINT is used to express 318 the Element Data Size of an EBML Element with Element Name EBML and 319 Element ID "0x1A45DFA3" (see Section 11.2.1) in which case the 320 VINT_WIDTH MUST NOT exceed seven bits in length. Within the EBML 321 Body, when a VINT is used to express an Element ID, the maximum 322 length allowed for the VINT_WIDTH is one less than the value set in 323 the EBMLMaxIDLength Element. Within the EBML Body, when a VINT is 324 used to express an Element Data Size, the maximum length allowed for 325 the VINT_WIDTH is one less than the value set in the 326 EBMLMaxSizeLength Element. 328 4.2. VINT_MARKER 330 The VINT_MARKER serves as a separator between the VINT_WIDTH and 331 VINT_DATA. Each Variable Size Integer MUST contain exactly one 332 VINT_MARKER. The VINT_MARKER is one bit in length and contain a bit 333 with a value of one. The first bit with a value of one within the 334 Variable Size Integer is the VINT_MARKER. 336 4.3. VINT_DATA 338 The VINT_DATA portion of the Variable Size Integer includes all data 339 that follows (but not including) the VINT_MARKER until end of the 340 Variable Size Integer whose length is derived from the VINT_WIDTH. 341 The bits required for the VINT_WIDTH and the VINT_MARKER use one out 342 of every eight bits of the total length of the Variable Size Integer. 343 Thus a Variable Size Integer of 1 octet length supplies 7 bits for 344 VINT_DATA, a 2 octet length supplies 14 bits for VINT_DATA, and a 3 345 octet length supplies 21 bits for VINT_DATA. If the number of bits 346 required for VINT_DATA are less than the bit size of VINT_DATA, then 347 VINT_DATA MUST be zero-padded to the left to a size that fits. The 348 VINT_DATA value MUST be expressed as a big-endian unsigned integer. 350 4.4. VINT Examples 352 This table shows examples of Variable Size Integers with lengths from 353 1 to 5 octets. The Usable Bits column refers to the number of bits 354 that can be used in the VINT_DATA. The Representation column depicts 355 a binary expression of Variable Size Integers where VINT_WIDTH is 356 depicted by "0", the VINT_MARKER as "1", and the VINT_DATA as "x". 358 +------------+------------+-----------------------------------------+ 359 | Octet | Usable | Representation | 360 | Length | Bits | | 361 +------------+------------+-----------------------------------------+ 362 | 1 | 7 | 1xxx xxxx | 363 | 2 | 14 | 01xx xxxx xxxx xxxx | 364 | 3 | 21 | 001x xxxx xxxx xxxx xxxx xxxx | 365 | 4 | 28 | 0001 xxxx xxxx xxxx xxxx xxxx xxxx xxxx | 366 | 5 | 35 | 0000 1xxx xxxx xxxx xxxx xxxx xxxx xxxx | 367 | | | xxxx xxxx | 368 +------------+------------+-----------------------------------------+ 370 Data encoded as a Variable Size Integer may be rendered at octet 371 lengths larger than needed to store the data in order to facilitate 372 overwriting it at a later date, e.g. when its final size isn't known 373 in advance. In this table a binary value of 0b10 is shown encoded as 374 different Variable Size Integers with lengths from one octet to four 375 octets. All four encoded examples have identical semantic meaning 376 though the VINT_WIDTH and the padding of the VINT_DATA vary. 378 +--------------+--------------+-------------------------------------+ 379 | Binary Value | Octet Length | As Represented in Variable Size | 380 | | | Integer | 381 +--------------+--------------+-------------------------------------+ 382 | 10 | 1 | 1000 0010 | 383 | 10 | 2 | 0100 0000 0000 0010 | 384 | 10 | 3 | 0010 0000 0000 0000 0000 0010 | 385 | 10 | 4 | 0001 0000 0000 0000 0000 0000 0000 | 386 | | | 0010 | 387 +--------------+--------------+-------------------------------------+ 389 5. Element ID 391 The Element ID is encoded as a Variable Size Integer. By default, 392 Element IDs are encoded in lengths from one octet to four octets, 393 although Element IDs of greater lengths MAY be used if the 394 EBMLMaxIDLength Element of the EBML Header is set to a value greater 395 than four (see Section 11.2.4). The VINT_DATA component of the 396 Element ID MUST NOT be either defined or written as either all zero 397 values or all one values. Any Element ID with the VINT_DATA 398 component set as all zero values or all one values MUST be ignored. 399 The VINT_DATA component of the Element ID MUST be encoded at the 400 shortest valid length. For example, an Element ID with binary 401 encoding of "1011 1111" is valid, whereas an Element ID with binary 402 encoding of "0100 0000 0011 1111" stores a semantically equal 403 VINT_DATA but is invalid because a shorter VINT encoding is possible. 404 Additionally, an Element ID with binary encoding of "1111 1111" is 405 invalid since the VINT_DATA section is set to all one values, whereas 406 an Element ID with binary encoding of "0100 0000 0111 1111" stores a 407 semantically equal VINT_DATA and is the shortest possible VINT 408 encoding. 410 The following table details these specific examples further: 412 +------------+-------------+----------------+-----------------------+ 413 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element ID Status | 414 +------------+-------------+----------------+-----------------------+ 415 | | 1 | 0000000 | Invalid: VINT_DATA | 416 | | | | MUST NOT be set to | 417 | | | | all 0 | 418 | 0 | 1 | 00000000000000 | Invalid: VINT_DATA | 419 | | | | MUST NOT be set to | 420 | | | | all 0 | 421 | | 1 | 0000001 | Valid | 422 | 0 | 1 | 00000000000001 | Invalid: A shorter | 423 | | | | VINT_DATA encoding is | 424 | | | | available. | 425 | | 1 | 0111111 | Valid | 426 | 0 | 1 | 00000000111111 | Invalid: A shorter | 427 | | | | VINT_DATA encoding is | 428 | | | | available. | 429 | | 1 | 1111111 | Invalid: VINT_DATA | 430 | | | | MUST NOT be set to | 431 | | | | all 1 | 432 | 0 | 1 | 00000001111111 | Valid | 433 +------------+-------------+----------------+-----------------------+ 435 The octet length of an Element ID determines its EBML Class. 437 +------------+--------+-------------------------+---------------+ 438 | EBML Class | Length | Possible IDs | Number of IDs | 439 +------------+--------+-------------------------+---------------+ 440 | Class A | 1 | 0x81 - 0xFE | 126 | 441 | Class B | 2 | 0x407F - 0x7FFE | 16,256 | 442 | Class C | 3 | 0x203FFF - 0x3FFFFE | 2,080,768 | 443 | Class D | 4 | 0x101FFFFF - 0x1FFFFFFE | 268,338,304 | 444 +------------+--------+-------------------------+---------------+ 446 6. Element Data Size 448 6.1. Data Size Format 450 The Element Data Size expresses the length in octets of Element Data. 451 The Element Data Size itself is encoded as a Variable Size Integer. 452 By default, Element Data Sizes can be encoded in lengths from one 453 octet to eight octets, although Element Data Sizes of greater lengths 454 MAY be used if the octet length of the longest Element Data Size of 455 the EBML Document is declared in the EBMLMaxSizeLength Element of the 456 EBML Header (see Section 11.2.5). Unlike the VINT_DATA of the 457 Element ID, the VINT_DATA component of the Element Data Size is not 458 mandated to be encoded at the shortest valid length. For example, an 459 Element Data Size with binary encoding of 1011 1111 or a binary 460 encoding of 0100 0000 0011 1111 are both valid Element Data Sizes and 461 both store a semantically equal value (both 0b00000000111111 and 462 0b0111111, the VINT_DATA sections of the examples, represent the 463 integer 63). 465 Although an Element ID with all VINT_DATA bits set to zero is 466 invalid, an Element Data Size with all VINT_DATA bits set to zero is 467 allowed for EBML Element Types which do not mandate a non-zero length 468 (see Section 7). An Element Data Size with all VINT_DATA bits set to 469 zero indicates that the Element Data is zero octets in length. Such 470 an EBML Element is referred to as an Empty Element. If an Empty 471 Element has a default value declared then the EBML Reader MUST 472 interpret the value of the Empty Element as the default value. If an 473 Empty Element has no default value declared then the EBML Reader MUST 474 use the value of the Empty Element for the corresponding EBML Element 475 Type of the Element ID, 0 for numbers and an empty string for 476 strings. 478 6.2. Unknown Data Size 480 An Element Data Size with all VINT_DATA bits set to one is reserved 481 as an indicator that the size of the EBML Element is unknown. The 482 only reserved value for the VINT_DATA of Element Data Size is all 483 bits set to one. An EBML Element with an unknown Element Data Size 484 is referred to as an Unknown-Sized Element. A Master Element MAY be 485 an Unknown-Sized Element; however an EBML Element that is not a 486 Master Element MUST NOT be an Unknown-Sized Element. Master Elements 487 MUST NOT use an unknown size unless the unknownsizeallowed attribute 488 of their EBML Schema is set to true (see Section 11.1.5.10). 490 The use of Unknown-Sized Elements allows for an EBML Element to be 491 written and read before the size of the EBML Element is known. 492 Unknown-Sized Element MUST NOT be used or defined unnecessarily; 493 however if the Element Data Size is not known before the Element Data 494 is written, such as in some cases of data streaming, then Unknown- 495 Sized Elements MAY be used. The end of an Unknown-Sized Element is 496 determined by whichever comes first: 498 o Any EBML Element that is a valid Parent Element of the Unknown- 499 Sized Element according to the EBML Schema, Section 11.3 excluded. 501 o Any valid EBML Element according to the EBML Schema, Section 11.3 502 excluded, that is not a Descendant Element of the Unknown-Sized 503 Element but share a common direct parent, such as a Top-Level 504 Element. 506 o Any EBML Element that is a valid Root Element according to the 507 EBML Schema, Section 11.3 excluded. 509 o The end of the Parent Element with a known size has been reached. 511 o The end of the EBML Document, either when reaching the end of the 512 file or because a new EBML Header started. 514 Consider an Unknown-Sized Element which EBML path is 515 "\root\level1\level2\elt". When reading a new Element ID, assuming 516 the EBML Path of that new Element is valid, here are some possible 517 and impossible ways that this new Element is ending "elt": 519 +------------------------------------+------------------------------+ 520 | EBML Path of new element | Status | 521 +------------------------------------+------------------------------+ 522 | "\root\level1\level2" | Ends the Unknown-Sized | 523 | | Element, as it is a new | 524 | | Parent Element | 525 | "\root\level1" | Ends the Unknown-Sized | 526 | | Element, as it is a new | 527 | | Parent Element | 528 | "\root" | Ends the Unknown-Sized | 529 | | Element, as it is a new Root | 530 | | Element | 531 | "\root2" | Ends the Unknown-Sized | 532 | | Element, as it is a new Root | 533 | | Element | 534 | "\root\level1\level2\other" | Ends the Unknown-Sized | 535 | | Element, as they share the | 536 | | same parent | 537 | "\root\level1\level2\elt" | Ends the Unknown-Sized | 538 | | Element, as they share the | 539 | | same parent | 540 | "\root\level1\level2\elt\inside" | Doesn't end the Unknown- | 541 | | Sized Element, it's a child | 542 | | of "elt" | 543 | "\root\level1\level2\elt\" | Global Element is valid, | 544 | | it's a child of "elt" | 545 | "\root\level1\level2\" | Global Element cannot be | 546 | | assumed to have this path, | 547 | | while parsing "elt" it can | 548 | | only be a child of "elt" | 549 +------------------------------------+------------------------------+ 551 6.3. Data Size Values 553 For Element Data Sizes encoded at octet lengths from one to eight, 554 this table depicts the range of possible values that can be encoded 555 as an Element Data Size. An Element Data Size with an octet length 556 of 8 is able to express a size of 2^56-2 or 72,057,594,037,927,934 557 octets (or about 72 petabytes). The maximum possible value that can 558 be stored as Element Data Size is referred to as VINTMAX. 560 +--------------+----------------------+ 561 | Octet Length | Possible Value Range | 562 +--------------+----------------------+ 563 | 1 | 0 to 2^7-2 | 564 | 2 | 0 to 2^14-2 | 565 | 3 | 0 to 2^21-2 | 566 | 4 | 0 to 2^28-2 | 567 | 5 | 0 to 2^35-2 | 568 | 6 | 0 to 2^42-2 | 569 | 7 | 0 to 2^49-2 | 570 | 8 | 0 to 2^56-2 | 571 +--------------+----------------------+ 573 If the length of Element Data equals 2^(n*7)-1 then the octet length 574 of the Element Data Size MUST be at least n+1. This rule prevents an 575 Element Data Size from being expressed as the unknown size value. 576 The following table clarifies this rule by showing a valid and 577 invalid expression of an Element Data Size with a VINT_DATA of 127 578 (which is equal to 2^(1*7)-1) and 16,383 (which is equal to 2^(2*7)- 579 1). 581 +------------+-------------+-----------------------+----------------+ 582 | VINT_WIDTH | VINT_MARKER | VINT_DATA | Element Data | 583 | | | | Size Status | 584 +------------+-------------+-----------------------+----------------+ 585 | | 1 | 1111111 | Reserved | 586 | | | | (meaning | 587 | | | | Unknown) | 588 | 0 | 1 | 00000001111111 | Valid (meaning | 589 | | | | 127 octets) | 590 | 00 | 1 | 000000000000001111111 | Valid (meaning | 591 | | | | 127 octets) | 592 | 0 | 1 | 11111111111111 | Reserved | 593 | | | | (meaning | 594 | | | | Unknown) | 595 | 00 | 1 | 000000011111111111111 | Valid (16,383 | 596 | | | | octets) | 597 +------------+-------------+-----------------------+----------------+ 599 7. EBML Element Types 601 EBML Elements are defined by an EBML Schema (see Section 11.1) which 602 MUST declare one of the following EBML Element Types for each EBML 603 Element. An EBML Element Type defines a concept of storing data 604 within an EBML Element that describes such characteristics as length, 605 endianness, and definition. 607 EBML Elements which are defined as a Signed Integer Element, Unsigned 608 Integer Element, Float Element, or Date Element use big endian 609 storage. 611 7.1. Signed Integer Element 613 A Signed Integer Element MUST declare a length from zero to eight 614 octets. If the EBML Element is not defined to have a default value, 615 then a Signed Integer Element with a zero-octet length represents an 616 integer value of zero. 618 A Signed Integer Element stores an integer (meaning that it can be 619 written without a fractional component) which could be negative, 620 positive, or zero. Signed Integers are stored with two's complement 621 notation with the leftmost bit being the sign bit. Because EBML 622 limits Signed Integers to 8 octets in length a Signed Integer Element 623 stores a number from -9,223,372,036,854,775,808 to 624 +9,223,372,036,854,775,807. 626 7.2. Unsigned Integer Element 628 An Unsigned Integer Element MUST declare a length from zero to eight 629 octets. If the EBML Element is not defined to have a default value, 630 then an Unsigned Integer Element with a zero-octet length represents 631 an integer value of zero. 633 An Unsigned Integer Element stores an integer (meaning that it can be 634 written without a fractional component) which could be positive or 635 zero. Because EBML limits Unsigned Integers to 8 octets in length an 636 Unsigned Integer Element stores a number from 0 to 637 18,446,744,073,709,551,615. 639 7.3. Float Element 641 A Float Element MUST declare a length of either zero octet (0 bit), 642 four octets (32 bit) or eight octets (64 bit). If the EBML Element 643 is not defined to have a default value, then a Float Element with a 644 zero-octet length represents a numerical value of zero. 646 A Float Element stores a floating-point number as defined in 647 [IEEE.754.1985]. 649 7.4. String Element 651 A String Element MUST declare a length in octets from zero to 652 VINTMAX. If the EBML Element is not defined to have a default value, 653 then a String Element with a zero-octet length represents an empty 654 string. 656 A String Element MUST either be empty (zero-length) or contain 657 printable ASCII characters [RFC0020] in the range of 0x20 to 0x7E, 658 with an exception made for termination (see Section 13). 660 7.5. UTF-8 Element 662 A UTF-8 Element MUST declare a length in octets from zero to VINTMAX. 663 If the EBML Element is not defined to have a default value, then a 664 UTF-8 Element with a zero-octet length represents an empty string. 666 A UTF-8 Element contains only a valid Unicode string as defined in 667 [RFC3629], with an exception made for termination (see Section 13). 669 7.6. Date Element 671 A Date Element MUST declare a length of either zero octets or eight 672 octets. If the EBML Element is not defined to have a default value, 673 then a Date Element with a zero-octet length represents a timestamp 674 of 2001-01-01T00:00:00.000000000 UTC [RFC3339]. 676 The Date Element stores an integer in the same format as the Signed 677 Integer Element that expresses a point in time referenced in 678 nanoseconds from the precise beginning of the third millennium of the 679 Gregorian Calendar in Coordinated Universal Time (also known as 680 2001-01-01T00:00:00.000000000 UTC). This provides a possible 681 expression of time from 1708-09-11T00:12:44.854775808 UTC to 682 2293-04-11T11:47:16.854775807 UTC. 684 7.7. Master Element 686 A Master Element MUST declare a length in octets from zero to 687 VINTMAX. The Master Element MAY also use an unknown length. See 688 Section 6 for rules that apply to elements of unknown length. 690 The Master Element contains zero, one, or many other elements. EBML 691 Elements contained within a Master Element MUST have the 692 EBMLParentPath of their Element Path equal to the EBMLMasterPath of 693 the Master Element Element Path (see Section 11.1.5.2). Element Data 694 stored within Master Elements SHOULD only consist of EBML Elements 695 and SHOULD NOT contain any data that is not part of an EBML Element. 696 The EBML Schema identifies what Element IDs are valid within the 697 Master Elements for that version of the EBML Document Type. Any data 698 contained within a Master Element that is not part of a Child Element 699 MUST be ignored. 701 7.8. Binary Element 703 A Binary Element MUST declare a length in octets from zero to 704 VINTMAX. 706 The contents of a Binary Element should not be interpreted by the 707 EBML Reader. 709 8. EBML Document 711 An EBML Document is comprised of only two components, an EBML Header 712 and an EBML Body. An EBML Document MUST start with an EBML Header 713 that declares significant characteristics of the entire EBML Body. 714 An EBML Document consists of EBML Elements and MUST NOT contain any 715 data that is not part of an EBML Element. 717 8.1. EBML Header 719 The EBML Header is a declaration that provides processing 720 instructions and identification of the EBML Body. The EBML Header of 721 an EBML Document is analogous to the XML Declaration of an XML 722 Document. 724 The EBML Header documents the EBML Schema (also known as the EBML 725 DocType) that is used to semantically interpret the structure and 726 meaning of the EBML Document. Additionally the EBML Header documents 727 the versions of both EBML and the EBML Schema that were used to write 728 the EBML Document and the versions required to read the EBML 729 Document. 731 The EBML Header MUST contain a single Master Element with an Element 732 Name of EBML and Element ID of 0x1A45DFA3 (see Section 11.2.1) and 733 any number of additional EBML Elements within it. The EBML Header of 734 an EBML Document that uses an EBMLVersion of 1 MUST only contain EBML 735 Elements that are defined as part of this document. 737 8.2. EBML Body 739 All data of an EBML Document following the EBML Header is the EBML 740 Body. The end of the EBML Body, as well as the end of the EBML 741 Document that contains the EBML Body, is reached at whichever comes 742 first: the beginning of a new EBML Header at the Root Level or the 743 end of the file. The EBML Body MUST NOT contain any data that is not 744 part of an EBML Element. This document defines precisely which EBML 745 Elements are to be used within the EBML Header, but does not name or 746 define which EBML Elements are to be used within the EBML Body. The 747 definition of which EBML Elements are to be used within the EBML Body 748 is defined by an EBML Schema. 750 9. EBML Stream 752 An EBML Stream is a file that consists of one or more EBML Documents 753 that are concatenated together. An occurrence of a EBML Header at 754 the Root Level marks the beginning of an EBML Document. 756 10. EBML Versioning 758 An EBML Document handles 2 different versions: the version of the 759 EBML Header and the version of the EBML Body. Both versions are 760 meant to be backward compatible. 762 10.1. EBML Header Version 764 The version of the EBML Header is found in EBMLVersion. An EBML 765 parser can read an EBML Header if it can read either the EBMLVersion 766 version or a version equal or higher than the one found in 767 EBMLReadVersion. 769 10.2. EBML Document Version 771 The version of the EBML Body is found in EBMLDocTypeVersion. A 772 parser for the particular DocType format can read the EBML Document 773 if it can read either the EBMLDocTypeVersion version of that format 774 or a version equal or higher than the one found in 775 EBMLDocTypeReadVersion. 777 11. Elements semantic 779 11.1. EBML Schema 781 An EBML Schema is a well-formed XML Document [W3C.REC-xml-20081126] 782 that defines the properties, arrangement, and usage of EBML Elements 783 that compose a specific EBML Document Type. The relationship of an 784 EBML Schema to an EBML Document is analogous to the relationship of 785 an XML Schema [W3C.REC-xmlschema-0-20041028] to an XML Document 786 [W3C.REC-xml-20081126]. An EBML Schema MUST be clearly associated 787 with one or more EBML Document Types. An EBML Document Type is 788 identified by a string stored within the EBML Header in the DocType 789 Element; for example matroska or webm (see Section 11.2.6). The 790 DocType value for an EBML Document Type MUST be unique and 791 persistent. 793 An EBML Schema MUST declare exactly one EBML Element at Root Level 794 (referred to as the Root Element) that occurs exactly once within an 795 EBML Document. The Void Element MAY also occur at Root Level but is 796 not a Root Element (see Section 11.3.2). 798 The EBML Schema MUST document all Elements of the EBML Body. The 799 EBML Schema does not document Global Elements that are defined by 800 this document (namely the Void Element and the CRC-32 Element). 802 The EBML Schema MUST NOT use the Element ID "0x1A45DFA3" which is 803 reserved for the EBML Header for resynchronization purpose. 805 An EBML Schema MAY constrain the use of EBML Header Elements (see 806 Section 11.2) by adding or constraining that Element's "range" 807 attribute. For example, an EBML Schema MAY constrain the 808 EBMLMaxSizeLength to a maximum value of "8" or MAY constrain the 809 EBMLVersion to only support a value of "1". If an EBML Schema adopts 810 the EBML Header Element as-is, then it is not required to document 811 that Element within the EBML Schema. If an EBML Schema constrains 812 the range of an EBML Header Element, then that Element MUST be 813 documented within an "" node of the EBML Schema. This 814 document provides an example of an EBML Schema, see Section 11.1.1. 816 11.1.1. EBML Schema Example 818 819 821 822 825 828 829 830 Container of data and 831 attributes representing one or many files. 832 833 835 836 An attached file. 837 838 839 842 843 Filename of the attached file. 844 845 846 849 850 MIME type of the file. 851 852 853 856 857 Modification timestamp of the file. 858 859 860 862 863 The data of the file. 864 865 866 868 11.1.2. Element 870 As an XML Document, the EBML Schema MUST use "" as the 871 top level element. The "" element can contain 872 "" sub-elements. 874 11.1.3. Attributes 876 Within an EBML Schema the "" element uses the following 877 attributes: 879 11.1.3.1. docType 881 The docType lists the official name of the EBML Document Type that is 882 defined by the EBML Schema; for example, "". 885 The docType attribute is REQUIRED within the "" Element. 887 11.1.3.2. version 889 The version lists a non-negative integer that specifies the version 890 of the docType documented by the EBML Schema. Unlike XML Schemas, an 891 EBML Schema documents all versions of a docType's definition rather 892 than using separate EBML Schemas for each version of a docType. EBML 893 Elements may be introduced and deprecated by using the minver and 894 maxver attributes of "". 896 The version attribute is REQUIRED within the "" Element. 898 11.1.4. Element 900 Each "" defines one EBML Element through the use of several 901 attributes that are defined in Section 11.1.3. EBML Schemas MAY 902 contain additional attributes to extend the semantics but MUST NOT 903 conflict with the definitions of the "" attributes defined 904 within this document. 906 The "" nodes contain a description of the meaning and use of 907 the EBML Element stored within one or more "" sub- 908 elements, followed by optional "" sub-elements, 909 followed by zero or one "" sub-element, followed by 910 optional "" sub-elements. All "" nodes MUST be 911 sub-elements of the "". 913 11.1.5. Attributes 915 Within an EBML Schema the "" uses the following attributes 916 to define an EBML Element: 918 11.1.5.1. name 920 The name provides the human-readable name of the EBML Element. The 921 value of the name MUST be in the form of characters "A" to "Z", "a" 922 to "z", "0" to "9", "-" and ".". 924 The name attribute is REQUIRED. 926 11.1.5.2. path 928 The path defines the allowed storage locations of the EBML Element 929 within an EBML Document. This path MUST be defined with the full 930 hierarchy of EBML Elements separated with a "\". The top EBML 931 Element in the path hierarchy being the first in the value. The 932 syntax of the path attribute is defined using this Augmented Backus- 933 Naur Form (ABNF) [RFC5234] with the case sensitive update [RFC7405] 934 notation: 936 The path attribute is REQUIRED. 938 EBMLFullPath = EBMLElementOccurrence "(" EBMLMasterPath ")" 939 EBMLMasterPath = [EBMLParentPath] EBMLElementPath 940 EBMLParentPath = EBMLFixedParent EBMLLastParent 941 EBMLFixedParent = *(EBMLPathAtom) 942 EBMLElementPath = EBMLPathAtom / EBMLPathAtomRecursive 943 EBMLPathAtom = PathDelimiter EBMLAtomName 944 EBMLPathAtomRecursive = "(1*(" EBMLPathAtom "))" 945 EBMLLastParent = EBMLPathAtom / EBMLVariableParent 946 EBMLVariableParent = "(" VariableParentOccurrence "\)" 947 EBMLAtomName = 1*(EBMLNameChar) 948 EBMLNameChar = ALPHA / DIGIT / "-" / "." 949 PathDelimiter = "\" 950 EBMLElementOccurrence = [EBMLMinOccurrence] "*" [EBMLMaxOccurrence] 951 EBMLMinOccurrence = 1*DIGIT ; no upper limit 952 EBMLMaxOccurrence = 1*DIGIT ; no upper limit 953 VariableParentOccurrence = [PathMinOccurrence] "*" [PathMaxOccurrence] 954 PathMinOccurrence = 1*DIGIT ; no upper limit 955 PathMaxOccurrence = 1*DIGIT ; no upper limit 957 The "*", "(" and ")" symbols are interpreted as defined in [RFC5234]. 959 The EBMLPathAtom part of the EBMLElementPath MUST be equal to the 960 name attribute of the EBML Schema. 962 The starting PathDelimiter of the path corresponds to the root of the 963 EBML Document. 965 The EBMLElementOccurrence part is interpreted as an ABNF Variable 966 Repetition. The repetition amounts correspond to how many times the 967 EBML Element can be found in its Parent Element. 969 The EBMLMinOccurrence represents the minimum permitted number of 970 occurrences of this EBML Element within its Parent Element. Each 971 instance of the Parent Element MUST contain at least this many 972 instances of this EBML Element. If the EBML Element has an empty 973 EBMLParentPath then EBMLMinOccurrence refers to constraints on the 974 occurrence of the EBML Element within the EBML Document. If 975 EBMLMinOccurrence is not present then that EBML Element has an 976 EBMLMinOccurrence value of 0. The semantic meaning of 977 EBMLMinOccurrence within an EBML Schema is analogous to the meaning 978 of minOccurs within an XML Schema. EBML Elements with 979 EBMLMinOccurrence set to "1" that also have a default value (see 980 Section 11.1.5.8) declared are not REQUIRED to be stored but are 981 REQUIRED to be interpreted, see Section 11.1.18. An EBML Element 982 defined with a EBMLMinOccurrence value greater than zero is called a 983 Mandatory EBML Element. 985 The EBMLMaxOccurrence represents the maximum permitted number of 986 occurrences of this EBML Element within its Parent Element. Each 987 instance of the Parent Element MUST contain at most this many 988 instances of this EBML Element. If the EBML Element has an empty 989 EBMLParentPath then EBMLMaxOccurrence refers to constraints on the 990 occurrence of the EBML Element within the EBML Document. If 991 EBMLMaxOccurrence is not present then there is no upper bound for the 992 permitted number of occurrences of this EBML Element within its 993 Parent Element resp. within the EBML Document depending on whether 994 the EBMLParentPath of the EBML Element is empty or not. The semantic 995 meaning of EBMLMaxOccurrence within an EBML Schema path is analogous 996 to the meaning of maxOccurs within an XML Schema. 998 The VariableParentOccurrence part is interpreted as an ABNF Variable 999 Repetition. The repetition amounts correspond to the amount of 1000 unspecified Parent Element levels there can be between the 1001 EBMLFixedParent and the actual EBMLElementPath. 1003 If the path contains an EBMLPathAtomRecursive part, the EBML Element 1004 can occur within itself recursively (see the Section 11.1.5.11). 1006 As an example, a "path" of "1*(\Segment\Info)" means the element Info 1007 is found inside the Segment elements at least once and with no 1008 maximum iteration. An element SeekHead with path 1009 "0*2(\Segment\SeekHead)" may not be found at all in its Segment 1010 parent, once or twice but no more than that. 1012 11.1.5.3. id 1014 The Element ID encoded as a Variable Size Integer expressed in 1015 hexadecimal notation prefixed by a 0x that is read and stored in big- 1016 endian order. To reduce the risk of false positives while parsing 1017 EBML Streams, the Element IDs of the Root Element and Top-Level 1018 Elements SHOULD be at least 4 octets in length. Element IDs defined 1019 for use at Root Level or directly under the Root Level MAY use 1020 shorter octet lengths to facilitate padding and optimize edits to 1021 EBML Documents; for instance, the Void Element uses an Element ID 1022 with a one octet length to allow its usage in more writing and 1023 editing scenarios. 1025 The id attribute is REQUIRED. 1027 11.1.5.4. minOccurs 1029 An integer expressing the minimum permitted number of occurrences of 1030 this EBML Element within its Parent Element. The minOccurs value 1031 MUST be equal to the EBMLMinOccurrence value of the path. 1033 The minOccurs attribute is OPTIONAL. If the minOccurs attribute is 1034 not present then that EBML Element has a minOccurs value of 0. 1036 11.1.5.5. maxOccurs 1038 An integer expressing the maximum permitted number of occurrences of 1039 this EBML Element within its Parent Element. The maxOccurs value 1040 MUST be equal to the EBMLMaxOccurrence value of the path. 1042 The maxOccurs attribute is OPTIONAL. If the maxOccurs attribute is 1043 not present then that EBML Element has no maximum occurrence, similar 1044 to unbounded in the XML world. 1046 11.1.5.6. range 1048 A numerical range for EBML Elements which are of numerical types 1049 (Unsigned Integer, Signed Integer, Float, and Date). If specified 1050 the value of the EBML Element MUST be within the defined range. See 1051 Section 11.1.5.6.1 for rules applied to expression of range values. 1053 The range attribute is OPTIONAL. If the range attribute is not 1054 present then any value legal for the type attribute is valid. 1056 11.1.5.6.1. Expression of range 1058 The range attribute MUST only be used with EBML Elements that are 1059 either signed integer, unsigned integer, float, or date. The 1060 expression defines the upper, lower, exact or excluded value of the 1061 EBML Element and optionally an upper boundary value combined with a 1062 lower boundary. The range expression may contain whitespace (using 1063 the ASCII 0x20 character) for readability but whitespace within a 1064 range expression MUST NOT convey meaning. 1066 To set a fixed value for the range, the value is used as the 1067 attribute value. For example "1234" means the EBML element always 1068 has the value 1234. The value can be prefixed with "not" to indicate 1069 that the fixed value MUST NOT be used for that Element. For example 1070 "not 1234" means the Element can use all values of its type except 1071 1234. 1073 For an exclusive lower boundary the ">" sign is used and the ">=" 1074 sign is used for an inclusive lower boundary. For example ">3" 1075 meaning the Element value MUST be greater than 3 or ">=0x1p+0" 1076 meaning the Element value MUST be greater than or equal to the 1077 floating value 1.0, see Section 11.1.17. 1079 For an exclusive upper boundary the "<" sign is used and the "<=" 1080 sign is used for an inclusive upper boundary. For example "<-2" 1081 meaning the Element value MUST be less than -2 or "<=10" meaning the 1082 Element value MUST be less than or equal to the 10. 1084 The lower and upper bounds can be combined into an expression to form 1085 a closed boundary. The lower boundary coming first followed by the 1086 upper boundary, separated by a comma. For example ">3,<= 20" means 1087 the Element value MUST be greater than 3 and less than or equal to 1088 20. 1090 A special form of lower and upper bounds using the "-" separator is 1091 possible, meaning the Element value MUST be greater than or to the 1092 first value and MUST be less than or equal to the second value. For 1093 example "1-10" is equivalent to ">=1,<=10". If the upper boundary is 1094 negative, only the latter form MUST be used. 1096 11.1.5.7. length 1098 A value to express the valid length of the Element Data as written 1099 measured in octets. The length provides a constraint in addition to 1100 the Length value of the definition of the corresponding EBML Element 1101 Type. This length MUST be expressed as either a non-negative integer 1102 or a range (see Section 11.1.5.6.1) that consists of only non- 1103 negative integers and valid operators. 1105 The length attribute is OPTIONAL. If the length attribute is not 1106 present for that EBML Element then that EBML Element is only limited 1107 in length by the definition of the associated EBML Element Type. 1109 11.1.5.8. default 1111 If an Element is mandatory (has a EBMLMinOccurrence value greater 1112 than zero) but not written within its Parent Element or stored as an 1113 Empty Element, then the EBML Reader of the EBML Document MUST 1114 semantically interpret the EBML Element as present with this 1115 specified default value for the EBML Element. EBML Elements that are 1116 Master Elements MUST NOT declare a default value. EBML Elements with 1117 a minOccurs value greater than 1 MUST NOT declare a default value. 1119 The default attribute is OPTIONAL. 1121 11.1.5.9. type 1123 The type MUST be set to one of the following values: "integer" 1124 (signed integer), "uinteger" (unsigned integer), "float", "string", 1125 "date", "utf-8", "master", or "binary". The content of each type is 1126 defined within Section 7. 1128 The type attribute is REQUIRED. 1130 11.1.5.10. unknownsizeallowed 1132 A boolean to express if an EBML Element is permitted to be Unknown- 1133 Sized Element (having all VINT_DATA bits of Element Data Size set to 1134 1). EBML Elements that are not Master Elements MUST NOT set 1135 unknownsizeallowed to true. An EBML Element that is defined with an 1136 unknownsizeallowed attribute set to 1 MUST also have the 1137 unknownsizeallowed attribute of its Parent Element set to 1. 1139 An EBML Element with the unknownsizeallowed attribute set to 1 MUST 1140 NOT have its recursive attribute set to 1. 1142 The unknownsizeallowed attribute is OPTIONAL. If the 1143 unknownsizeallowed attribute is not used then that EBML Element is 1144 not allowed to use an unknown Element Data Size. 1146 11.1.5.11. recursive 1148 A boolean to express if an EBML Element is permitted to be stored 1149 recursively. In this case the EBML Element MAY be stored within 1150 another EBML Element that has the same Element ID. Which itself can 1151 be stored in an EBML Element that has the same Element ID, and so on. 1152 EBML Elements that are not Master Elements MUST NOT set recursive to 1153 true. 1155 If the path contains an EBMLPathAtomRecursive part then the recursive 1156 value MUST be true and false otherwise. 1158 An EBML Element with the recursive attribute set to 1 MUST NOT have 1159 its unknownsizeallowed attribute set to 1. 1161 The recursive attribute is OPTIONAL. If the recursive attribute is 1162 not present then the EBML Element MUST NOT be used recursively. 1164 11.1.5.12. recurring 1166 A boolean to express if an EBML Element is defined as an Identically 1167 Recurring Element or not. 1169 The recurring attribute is OPTIONAL. If the recurring attribute is 1170 not present then the EBML Element is not an Identically Recurring 1171 Element. 1173 11.1.5.13. minver 1175 The minver (minimum version) attribute stores a non-negative integer 1176 that represents the first version of the docType to support the EBML 1177 Element. 1179 The minver attribute is OPTIONAL. If the minver attribute is not 1180 present, then the EBML Element has a minimum version of "1". 1182 11.1.5.14. maxver 1184 The maxver (maximum version) attribute stores a non-negative integer 1185 that represents the last or most recent version of the docType to 1186 support the element. maxver MUST be greater than or equal to minver. 1188 The maxver attribute is OPTIONAL. If the maxver attribute is not 1189 present then the EBML Element has a maximum version equal to the 1190 value stored in the version attribute of "". 1192 11.1.6. Element 1194 The "" element provides additional information about 1195 the EBML Element. Within the "" element the following 1196 XHTML [W3C.SPSD-xhtml-basic-20180327] elements MAY be used: "", 1197 "
", "". 1199 11.1.7. Attributes 1201 11.1.7.1. lang 1203 A lang attribute which is set to the [RFC5646] value of the language 1204 of the element's documentation. 1206 The lang attribute is OPTIONAL. 1208 11.1.7.2. purpose 1210 A purpose attribute distinguishes the meaning of the documentation. 1211 Values for the "" sub-element's purpose attribute MUST 1212 include one of the following: "definition", "rationale", "usage 1213 notes", and "references". 1215 The purpose attribute is REQUIRED. 1217 11.1.8. Element 1219 In some cases within an EBML Document Type, the attributes of the 1220 "" element are not sufficient to clearly communicate how the 1221 defined EBML Element is intended to be implemented. For instance, 1222 one EBML Element might only be mandatory if another EBML Element is 1223 present, or as another example, the default value of an EBML Element 1224 might derive from a related Element's content. In these cases where 1225 the Element's definition is conditional or advanced implementation 1226 notes are needed, one or many "" elements can be 1227 used to store that information. The "" refer to 1228 a specific attribute of the parent "" as expressed by the 1229 "note_type" attribute Section 11.1.9.1. 1231 11.1.9. Attributes 1233 11.1.9.1. note_type 1235 The note_type attribute references which of the ""'s 1236 attributes that the implementation_note is in regards to. The 1237 note_type attribute MUST be set to one of the following values 1238 (corresponding to that attribute of the parent ""): 1239 "minOccurs", "maxOccurs", "range", "length", "default", "minver", or 1240 "maxver". The "" SHALL supersede the parent 1241 ""'s attribute that is named in the "note_type" attribute. 1242 An "" SHALL NOT have more than one "" 1243 of the same "note_type". 1245 The note_type attribute is REQUIRED. 1247 11.1.10. Element 1249 The "" element provides information about restrictions 1250 to the allowable values for the EBML Element which are listed in 1251 "" elements. 1253 11.1.11. Element 1255 The "" element stores a list of values allowed for storage in 1256 the EBML Element. The values MUST match the type of the EBML Element 1257 (for example "" cannot be a valid value for a EBML 1258 Element that is defined as an unsigned integer). An "" element 1259 MAY also store "" elements to further describe the 1260 "". 1262 11.1.12. Attributes 1264 11.1.12.1. label 1266 The label provides a concise expression for human consumption that 1267 describes what the value of the "" represents. 1269 The label attribute is OPTIONAL. 1271 11.1.12.2. value 1273 The value represents data that MAY be stored within the EBML Element. 1275 The value attribute is REQUIRED. 1277 11.1.13. Element 1279 The "" element provides an unconstrained element to 1280 contain information about the associated EBML "" which is 1281 undefined by this document but MAY be defined by the associated EBML 1282 Document Type. The "" element MUST contain a "type" 1283 attribute and also MAY contain any other attribute or sub-element as 1284 long as the EBML Schema remains as a well-formed XML Document. All 1285 "" elements MUST be sub-elements of the "". 1287 11.1.14. Attributes 1289 11.1.14.1. type 1291 The type attribute should reference a name or identifier of the 1292 project or authority associated with the contents of the 1293 "" element. 1295 The type attribute is REQUIRED. 1297 11.1.15. XML Schema for EBML Schema 1299 This following provides an XML Schema [W3C.REC-xmlschema-0-20041028] 1300 for facilitating verification of an EBML Schema to the definition 1301 described in Section 8.1. 1303 1304 1310 1311 1314 1316 1317 1318 1320 1321 1322 1323 1325 1326 1327 1329 1331 1333 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1351 1352 1353 1355 1356 1358 1359 1360 1362 1363 1364 1365 1366 1367 1368 1370 1371 1372 1373 1375 1376 1377 1379 1381 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1415 1416 1417 1419 11.1.16. Identically Recurring Elements 1421 An Identically Recurring Element is an EBML Element that MAY occur 1422 within its Parent Element more than once but that each recurrence 1423 within that Parent Element MUST be identical both in storage and 1424 semantics. Identically Recurring Elements are permitted to be stored 1425 multiple times within the same Parent Element in order to increase 1426 data resilience and optimize the use of EBML in transmission. For 1427 instance a pertinent Top-Level Element could be periodically resent 1428 within a data stream so that an EBML Reader which starts reading the 1429 stream from the middle could better interpret the contents. 1430 Identically Recurring Elements SHOULD include a CRC-32 Element as a 1431 Child Element; this is especially recommended when EBML is used for 1432 long-term storage or transmission. If a Parent Element contains more 1433 than one copy of an Identically Recurring Element which includes a 1434 CRC-32 Element as a Child Element then the first instance of the 1435 Identically Recurring Element with a valid CRC-32 value should be 1436 used for interpretation. If a Parent Element contains more than one 1437 copy of an Identically Recurring Element which does not contain a 1438 CRC-32 Element or if CRC-32 Elements are present but none are valid 1439 then the first instance of the Identically Recurring Element should 1440 be used for interpretation. 1442 11.1.17. Textual expression of floats 1444 When a float value is represented textually in an EBML Schema, such 1445 as within a default or range value, the float values MUST be 1446 expressed as Hexadecimal Floating-Point Constants as defined in the 1447 C11 standard [ISO.9899.2011] (see section 6.4.4.2 on Floating 1448 Constants). The following table provides examples of expressions of 1449 float ranges. 1451 +-------------------+-----------------------------------------+ 1452 | as decimal | as Hexadecimal Floating-Point Constants | 1453 +-------------------+-----------------------------------------+ 1454 | 0.0 | "0x0p+1" | 1455 | 0.0-1.0 | "0x0p+1-0x1p+0" | 1456 | 1.0-256.0 | "0x1p+0-0x1p+8" | 1457 | 0.857421875 | "0x1.b7p-1" | 1458 | -1.0--0.857421875 | "-0x1p+0--0x1.b7p-1" | 1459 +-------------------+-----------------------------------------+ 1461 Within an expression of a float range, as in an integer range, the - 1462 (hyphen) character is the separator between the minimal and maximum 1463 value permitted by the range. Hexadecimal Floating-Point Constants 1464 also use a - (hyphen) when indicating a negative binary power. 1465 Within a float range, when a - (hyphen) is immediately preceded by a 1466 letter p, then the - (hyphen) is a part of the Hexadecimal Floating- 1467 Point Constant which notes negative binary power. Within a float 1468 range, when a - (hyphen) is not immediately preceded by a letter p, 1469 then the - (hyphen) represents the separator between the minimal and 1470 maximum value permitted by the range. 1472 11.1.18. Note on the use of default attributes to define Mandatory EBML 1473 Elements 1475 If a Mandatory EBML Element has a default value declared by an EBML 1476 Schema and the value of the EBML Element is equal to the declared 1477 default value then that EBML Element is not required to be present 1478 within the EBML Document if its Parent Element is present. In this 1479 case, the default value of the Mandatory EBML Element MUST be read by 1480 the EBML Reader although the EBML Element is not present within its 1481 Parent Element. 1483 If a Mandatory EBML Element has no default value declared by an EBML 1484 Schema and its Parent Element is present then the EBML Element MUST 1485 be present as well. If a Mandatory EBML Element has a default value 1486 declared by an EBML Schema and its Parent Element is present and the 1487 value of the EBML Element is NOT equal to the declared default value 1488 then the EBML Element MUST be present. 1490 This table clarifies if a Mandatory EBML Element MUST be written, 1491 according to if the default value is declared, if the value of the 1492 EBML Element is equal to the declared default value, and if the 1493 Parent Element is used. 1495 +---------------+---------------+---------------+-------------------+ 1496 | Is the | Is the value | Is the Parent | Then is storing | 1497 | default value | equal to | Element | the EBML Element | 1498 | declared? | default? | present? | REQUIRED? | 1499 +---------------+---------------+---------------+-------------------+ 1500 | Yes | Yes | Yes | No | 1501 | Yes | Yes | No | No | 1502 | Yes | No | Yes | Yes | 1503 | Yes | No | No | No | 1504 | No | n/a | Yes | Yes | 1505 | No | n/a | No | No | 1506 +---------------+---------------+---------------+-------------------+ 1508 11.2. EBML Header Elements 1510 This document contains definitions of all EBML Elements of the EBML 1511 Header. 1513 11.2.1. EBML Element 1515 name: EBML 1517 path: "1*1(\EBML)" 1519 id: 0x1A45DFA3 1521 minOccurs: 1 1523 maxOccurs: 1 1525 type: Master Element 1527 description: Set the EBML characteristics of the data to follow. 1528 Each EBML Document has to start with this. 1530 11.2.2. EBMLVersion Element 1532 name: EBMLVersion 1534 path: "1*1(\EBML\EBMLVersion)" 1536 id 0x4286 1538 minOccurs: 1 1540 maxOccurs: 1 1542 range: not 0 1544 default: 1 1546 type: Unsigned Integer 1548 description: The version of EBML specifications used to create the 1549 EBML Document. The version of EBML defined in this document is 1, so 1550 EBMLVersion SHOULD be 1. 1552 11.2.3. EBMLReadVersion Element 1554 name: EBMLReadVersion 1556 path: "1*1(\EBML\EBMLReadVersion)" 1558 id: 0x42F7 1560 minOccurs: 1 1562 maxOccurs: 1 1564 range: 1 1566 default: 1 1568 type: Unsigned Integer 1570 description: The minimum EBML version an EBML Reader has to support 1571 to read this EBML Document. The EBMLReadVersion Element MUST be less 1572 than or equal to EBMLVersion. 1574 11.2.4. EBMLMaxIDLength Element 1576 name: EBMLMaxIDLength 1578 path: "1*1(\EBML\EBMLMaxIDLength)" 1580 id 0x42F2 1582 minOccurs: 1 1584 maxOccurs: 1 1586 range: >=4 1588 default: 4 1590 type: Unsigned Integer 1592 description: The EBMLMaxIDLength Element stores the maximum permitted 1593 length in octets of the Element IDs to be found within the EBML Body. 1594 An EBMLMaxIDLength Element value of four is RECOMMENDED, though 1595 larger values are allowed. 1597 11.2.5. EBMLMaxSizeLength Element 1599 name: EBMLMaxSizeLength 1601 path: "1*1(\EBML\EBMLMaxSizeLength)" 1603 id 0x42F3 1605 minOccurs: 1 1607 maxOccurs: 1 1609 range: not 0 1611 default: 8 1613 type: Unsigned Integer 1615 description: The EBMLMaxSizeLength Element stores the maximum 1616 permitted length in octets of the expressions of all Element Data 1617 Sizes to be found within the EBML Body. The EBMLMaxSizeLength 1618 Element documents an upper bound for the "length" of all Element Data 1619 Size expressions within the EBML Body and not an upper bound for the 1620 "value" of all Element Data Size expressions within the EBML Body. 1621 EBML Elements that have an Element Data Size expression which is 1622 larger in octets than what is expressed by EBMLMaxSizeLength Element 1623 are invalid. 1625 11.2.6. DocType Element 1627 name: DocType 1629 path: "1*1(\EBML\DocType)" 1631 id 0x4282 1633 minOccurs: 1 1635 maxOccurs: 1 1637 length: >0 1639 type: String 1641 description: A string that describes and identifies the content of 1642 the EBML Body that follows this EBML Header. 1644 11.2.7. DocTypeVersion Element 1646 name: DocTypeVersion 1648 path: "1*1(\EBML\DocTypeVersion)" 1650 id 0x4287 1652 minOccurs: 1 1654 maxOccurs: 1 1656 range: not 0 1658 default: 1 1660 type: Unsigned Integer 1662 description: The version of DocType interpreter used to create the 1663 EBML Document. 1665 11.2.8. DocTypeReadVersion Element 1667 name: DocTypeReadVersion 1669 path: "1*1(\EBML\DocTypeReadVersion)" 1671 id 0x4285 1673 minOccurs: 1 1675 maxOccurs: 1 1677 range: not 0 1679 default: 1 1681 type: Unsigned Integer 1683 description: The minimum DocType version an EBML Reader has to 1684 support to read this EBML Document. The value of the 1685 DocTypeReadVersion Element MUST be less than or equal to the value of 1686 the DocTypeVersion Element. 1688 11.2.9. DocTypeExtension Element 1690 name: DocTypeExtension 1692 path: "0*(\EBML\DocTypeExtension)" 1694 id 0x4281 1696 minOccurs: 0 1698 type: Master Element 1700 description: A DocTypeExtension adds extra Elements to the main 1701 DocType+DocTypeVersion tuple it's attached to. An EBML Reader MAY 1702 know these extra Elements and how to use them. A DocTypeExtension 1703 MAY be used to iterate between experimental Elements before they are 1704 integrated in a regular DocTypeVersion. Reading one DocTypeExtension 1705 version of a DocType+DocTypeVersion tuple doesn't imply one should be 1706 able to read upper versions of this DocTypeExtension. 1708 11.2.10. DocTypeExtensionName Element 1710 name: DocTypeExtensionName 1712 path: "1*1(\EBML\DocTypeExtension\Name)" 1714 id 0x4283 1716 minOccurs: 1 1718 maxOccurs: 1 1720 length: >0 1722 type: String 1724 description: The name of the DocTypeExtension to differentiate it 1725 from other DocTypeExtension of the same DocType+DocTypeVersion tuple. 1726 A DocTypeExtensionName value MUST be unique within the EBML Header. 1728 11.2.11. DocTypeExtensionVersion Element 1730 name: DocTypeExtensionVersion 1732 path: "1*1(\EBML\DocTypeExtension\Version)" 1734 id 0x4284 1735 minOccurs: 1 1737 maxOccurs: 1 1739 range: not 0 1741 type: Unsigned Integer 1743 description: The version of the DocTypeExtension. Different 1744 DocTypeExtensionVersion values of the same 1745 DocType+DocTypeVersion+DocTypeExtensionName tuple MAY contain 1746 completely different sets of extra Elements. An EBML Reader MAY 1747 support multiple versions of the same DocTypeExtension, only one or 1748 none. 1750 11.3. Global Elements 1752 EBML defines these Global Elements which MAY be stored within any 1753 Master Element of an EBML Document as defined by their Element Path. 1755 11.3.1. CRC-32 Element 1757 name: CRC-32 1759 path: "*1((1*\)\CRC-32)" 1761 id: 0xBF 1763 minOccurs: 0 1765 maxOccurs: 1 1767 length: 4 1769 type: Binary 1771 description: The CRC-32 Element contains a 32-bit Cyclic Redundancy 1772 Check value of all the Element Data of the Parent Element as stored 1773 except for the CRC-32 Element itself. When the CRC-32 Element is 1774 present, the CRC-32 Element MUST be the first ordered EBML Element 1775 within its Parent Element for easier reading. All Top-Level Elements 1776 of an EBML Document that are Master Elements SHOULD include a CRC-32 1777 Element as a Child Element. The CRC in use is the IEEE-CRC-32 1778 algorithm as used in the [ISO.3309.1979] standard and in section 1779 8.1.1.6.2 of [ITU.V42.1994], with initial value of 0xFFFFFFFF. The 1780 CRC value MUST be computed on a little endian bitstream and MUST use 1781 little endian storage. 1783 11.3.2. Void Element 1785 name: Void 1787 path: "*((*\)\Void)" 1789 id: 0xEC 1791 minOccurs: 0 1793 type: Binary 1795 description: Used to void data or to avoid unexpected behaviors when 1796 using damaged data. The content is discarded. Also used to reserve 1797 space in a sub-element for later use. 1799 12. Considerations for Reading EBML Data 1801 The following scenarios describe events to consider when reading EBML 1802 Documents and the recommended design of an EBML Reader. 1804 If a Master Element contains a CRC-32 Element that doesn't validate, 1805 then the EBML Reader MAY ignore all contained data except for 1806 Descendant Elements that contain their own valid CRC-32 Element. 1808 If a Master Element contains more occurrences of a Child Master 1809 Element than permitted according to the maxOccurs and recurring 1810 attributes of the definition of that Element then the occurrences in 1811 addition to maxOccurs MAY be ignored. 1813 If a Master Element contains more occurrences of a Child Element than 1814 permitted according to the maxOccurs attribute of the definition of 1815 that Element then all instances of that Element after the first 1816 maxOccur occurrences from the beginning of its Parent Element SHOULD 1817 be ignored. 1819 13. Terminating Elements 1821 Null Octets, which are octets with all bits set to zero, MAY follow 1822 the value of a String Element or UTF-8 Element to serve as a 1823 terminator. An EBML Writer MAY terminate a String Element or UTF-8 1824 Element with Null Octets in order to overwrite a stored value with a 1825 new value of lesser length while maintaining the same Element Data 1826 Size (this can prevent the need to rewrite large portions of an EBML 1827 Document); otherwise the use of Null Octets within a String Element 1828 or UTF-8 Element is NOT RECOMMENDED. An EBML Reader MUST consider 1829 the value of the String Element or UTF-8 Element to be terminated 1830 upon the first read Null Octet and MUST ignore any data following the 1831 first Null Octet within that Element. A string value and a copy of 1832 that string value terminated by one or more Null Octets are 1833 semantically equal. 1835 The following table shows examples of semantics and validation for 1836 the use of Null Octets. Values to represent Stored Values and the 1837 Semantic Meaning as represented as hexadecimal values. 1839 +---------------------+---------------------+ 1840 | Stored Value | Semantic Meaning | 1841 +---------------------+---------------------+ 1842 | 0x65 0x62 0x6D 0x6C | 0x65 0x62 0x6D 0x6C | 1843 | 0x65 0x62 0x00 0x6C | 0x65 0x62 | 1844 | 0x65 0x62 0x00 0x00 | 0x65 0x62 | 1845 | 0x65 0x62 | 0x65 0x62 | 1846 +---------------------+---------------------+ 1848 14. Guidelines for Updating Elements 1850 An EBML Document can be updated without requiring that the entire 1851 EBML Document be rewritten. These recommendations describe 1852 strategies to change the Element Data of a written EBML Element with 1853 minimal disruption to the rest of the EBML Document. 1855 14.1. Reducing a Element Data in Size 1857 There are three methods to reduce the size of Element Data of a 1858 written EBML Element. 1860 14.1.1. Adding a Void Element 1862 When an EBML Element is changed to reduce its total length by more 1863 than one octet, an EBML Writer SHOULD fill the freed space with a 1864 Void Element. 1866 14.1.2. Extending the Element Data Size 1868 The same value for Element Data Size MAY be written in variable 1869 lengths, so for minor reductions in octet length the Element Data 1870 Size MAY be written to a longer octet length to fill the freed space. 1872 For example, the first row of the following table depicts a String 1873 Element that stores an Element ID (3 octets), Element Data Size (1 1874 octet), and Element Data (4 octets). If the Element Data is changed 1875 to reduce the length by one octet and if the current length of the 1876 Element Data Size is less than its maximum permitted length, then the 1877 Element Data Size of that Element MAY be rewritten to increase its 1878 length by one octet. Thus before and after the change the EBML 1879 Element maintains the same length of 8 octets and data around the 1880 Element does not need to be moved. 1882 +-------------+------------+-------------------+--------------+ 1883 | Status | Element ID | Element Data Size | Element Data | 1884 +-------------+------------+-------------------+--------------+ 1885 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 1886 | After edit | 0x3B4040 | 0x4003 | 0x6D6B76 | 1887 +-------------+------------+-------------------+--------------+ 1889 This method is RECOMMENDED when the Element Data is reduced by a 1890 single octet; for reductions by two or more octets it is RECOMMENDED 1891 to fill the freed space with a Void Element. 1893 Note that if the Element Data length needs to be rewritten as 1894 shortened by one octet and the Element Data Size could be rewritten 1895 as a shorter VINT then it is RECOMMENDED to rewrite the Element Data 1896 Size as one octet shorter, shorten the Element Data by one octet, and 1897 follow that Element with a Void Element. For example, the following 1898 table depicts a String Element that stores an Element ID (3 octets), 1899 Element Data Size (2 octets, but could be rewritten in one octet), 1900 and Element Data (3 octets). If the Element Data is to be rewritten 1901 to a two octet length, then another octet can be taken from Element 1902 Data Size so that there is enough space to add a two octet Void 1903 Element. 1905 +--------+------------+-----------------+-------------+-------------+ 1906 | Status | Element ID | Element Data | Element | Void | 1907 | | | Size | Data | Element | 1908 +--------+------------+-----------------+-------------+-------------+ 1909 | Before | 0x3B4040 | 0x4003 | 0x6D6B76 | | 1910 | After | 0x3B4040 | 0x82 | 0x6869 | 0xEC80 | 1911 +--------+------------+-----------------+-------------+-------------+ 1913 14.1.3. Terminating Element Data 1915 For String Elements and UTF-8 Elements the length of Element Data MAY 1916 be reduced by adding Null Octets to terminate the Element Data (see 1917 Section 13). 1919 In the following table, a four octets long Element Data is changed to 1920 a three octet long value followed by a Null Octet; the Element Data 1921 Size includes any Null Octets used to terminate Element Data so 1922 remains unchanged. 1924 +-------------+------------+-------------------+--------------+ 1925 | Status | Element ID | Element Data Size | Element Data | 1926 +-------------+------------+-------------------+--------------+ 1927 | Before edit | 0x3B4040 | 0x84 | 0x65626D6C | 1928 | After edit | 0x3B4040 | 0x84 | 0x6D6B7600 | 1929 +-------------+------------+-------------------+--------------+ 1931 Note that this method is NOT RECOMMENDED. For reductions of one 1932 octet, the method for Extending the Element Data Size SHOULD be used. 1933 For reduction by more than one octet, the method for Adding a Void 1934 Element SHOULD be used. 1936 14.2. Considerations when Updating Elements with Cyclic Redundancy 1937 Check (CRC) 1939 If the Element to be changed is a Descendant Element of any Master 1940 Element that contains a CRC-32 Element (see Section 11.3.1) then the 1941 CRC-32 Element MUST be verified before permitting the change. 1942 Additionally the CRC-32 Element value MUST be subsequently updated to 1943 reflect the changed data. 1945 15. Backward and Forward Compatibility 1947 Elements of an EBML format SHOULD be designed with backward and 1948 forward compatibility in mind. 1950 15.1. Backward Compatibility 1952 Backward compatibility of new EBML Elements can be achieved by using 1953 default values for mandatory elements. The default value MUST 1954 represent the state that was assumed for previous versions of the 1955 EBML Schema, without this new EBML Element. If such a state doesn't 1956 make sense for previous versions, then the new EBML Element SHOULD 1957 NOT be mandatory. 1959 Non mandatory EBML Elements can be added in a new EBMLDocTypeVersion. 1960 Since they are not mandatory they won't be found in older versions of 1961 the EBMLDocTypeVersion, just as they might not be found in newer 1962 versions. This causes no compatibility issue. 1964 15.2. Forward Compatibility 1966 EBML Elements MAY be marked as deprecated in a new EBMLDocTypeVersion 1967 using the maxver attribute of the EBML Schema. If such an Element is 1968 found in an EBML Document with newer version of the 1969 EBMLDocTypeVersion it SHOULD be discarded. 1971 16. Security Considerations 1973 EBML itself does not offer any kind of security and does not provide 1974 confidentiality. EBML does not provide any kind of authorization. 1975 EBML only offers marginally useful and effective data integrity 1976 options, such as CRC elements. 1978 Even if the semantic layer offers any kind of encryption, EBML itself 1979 could leak information at both the semantic layer (as declared via 1980 the DocType Element) and within the EBML structure (the presence of 1981 EBML Elements can be derived even with an unknown semantic layer 1982 using a heuristic approach; not without errors, of course, but with a 1983 certain degree of confidence). 1985 An EBML Document that has the following issues may still be handled 1986 by the EBML Reader and the data accepted as such, depending on how 1987 strict the EBML Reader wants to be: 1989 o Invalid Element IDs that are longer than the limit stated in the 1990 EBMLMaxIDLength Element of the EBML Header. 1992 o Invalid Element IDs that are not encoded in the shortest-possible 1993 way. 1995 o Invalid Element Data Size values that are longer than the limit 1996 stated in the EBMLMaxSizeLength Element of the EBML Header. 1998 Element IDs that are unknown to the EBML Reader MAY be accepted as 1999 valid EBML IDs in order to skip such elements. 2001 EBML Elements with a string type may contain extra data after the 2002 first 0x00. These data MUST be discarded according to the Section 13 2003 rules. 2005 An EBML Reader may discard some or all data if the following errors 2006 are found in the EBML Document: 2008 o Invalid Element Data Size values (e.g. extending the length of the 2009 EBML Element beyond the scope of the Parent Element; possibly 2010 triggering access-out-of-bounds issues). 2012 o Very high lengths in order to force out-of-memory situations 2013 resulting in a denial of service, access-out-of-bounds issues etc. 2015 o Missing EBML Elements that are mandatory in a Master Element and 2016 have no declared default value, making the semantic invalid at 2017 that Master Element level. 2019 o Usage of invalid UTF-8 encoding in EBML Elements of UTF-8 type 2020 (e.g. in order to trigger access-out-of-bounds or buffer overflow 2021 issues). 2023 o Usage of invalid data in EBML Elements with a date type, 2024 triggering bogus date accesses. 2026 Side channel attacks could exploit: 2028 o The semantic equivalence of the same string stored in a String 2029 Element or UTF-8 Element with and without zero-bit padding, making 2030 comparison at the semantic level invalid. 2032 o The semantic equivalence of VINT_DATA within Element Data Size 2033 with two different lengths due to left-padding zero bits, making 2034 comparison at the semantic level invalid. 2036 o Data contained within a Master Element which is not itself part of 2037 a Child Element can trigger incorrect parsing behavior in EBML 2038 Readers. 2040 o Extraneous copies of Identically Recurring Element, making parsing 2041 unnecessarily slow to the point of not being usable. 2043 o Copies of Identically Recurring Element within a Parent Element 2044 that contain invalid CRC-32 Elements. EBML Readers not checking 2045 the CRC-32 might use the version of the element with mismatching 2046 CRC-32. 2048 o Use of Void Elements which could be used to hide content or create 2049 bogus resynchronization points seen by some EBML Reader and not 2050 others. 2052 17. IANA Considerations 2054 17.1. CELLAR EBML Element ID Registry 2056 This document creates a new IANA Registry called "CELLAR EBML Element 2057 ID Registry". 2059 Element IDs are described in section Element ID. Element IDs are 2060 encoded using the VINT mechanism described in section Section 4 can 2061 be between one and five octets long. Five octet long Element IDs are 2062 possible only if declared in the header. 2064 This IANA Registry only applies to Elements that can be contained in 2065 the EBML Header, thus including Global Elements. Elements only found 2066 in the EBML Body have their own set of independent Element IDs and 2067 are not part of this IANA Registry. 2069 The VINT Data value of one-octet Element IDs MUST be between 0x01 and 2070 0x7E. These items are valuable because they are short, and need to 2071 be used for commonly repeated elements. Values from 1 to 126 are to 2072 be allocated according to the "RFC Required" policy [RFC8126]. 2074 The VINT Data value of two-octet Element IDs MUST be between 0x007F 2075 and 0x3FFE. Numbers are to be allocated within this range according 2076 to the "Specification Required" policy [RFC8126]. 2078 The numbers 0x3FFF and 0x4000 are RESERVED. 2080 The VINT Data value of three-octet Element IDs MUST be between 0x4001 2081 and 0x1FFFFE. Numbers may be allocated within this range according 2082 to the "First Come First Served" policy [RFC8126]. 2084 The numbers 0x1FFFFF and 0x200000 are RESERVED. 2086 Four-octet Element IDs are numbers between 0x101FFFFF and 0x1FFFFFFE. 2087 Four-octet Element IDs are somewhat special in that they are useful 2088 for resynchronizing to major structures in the event of data 2089 corruption or loss. As such four-octet Element IDs are split into 2090 two categories. Four-octet Element IDs whose lower three octets (as 2091 encoded) would make printable 7-bit ASCII values (0x20 to 0x7E, 2092 inclusive) MUST be allocated by the "Specification Required" policy. 2093 Sequential allocation of values is not required: specifications 2094 SHOULD include a specific request, and are encouraged to do early 2095 allocations. 2097 To be clear about the above category: four-octet Element IDs always 2098 start with hex 0x10 to 0x1F, and that octet may be chosen so that the 2099 entire number has some desirable property, such as a specific CRC. 2100 The other three octets, when ALL having values between 0x21 (33, 2101 ASCII !) and 0x7E (126, ASCII ~), fall into this category. 2103 Other four-octet Element IDs may be allocated by the "First Come 2104 First Served" policy. 2106 The numbers 0xFFFFFFF and 0x1000000 are RESERVED. 2108 Five octet Element IDs (values from 0x10000001 upwards) are RESERVED 2109 according to the "Experimental Use" policy [RFC8126]: they may be 2110 used by anyone at any time, but there is no coordination. 2112 ID Values found in this document are assigned as initial values as 2113 follows: 2115 +------------+-------------------------+----------------------------+ 2116 | ID | Element Name | Reference | 2117 +------------+-------------------------+----------------------------+ 2118 | 0x1A45DFA3 | EBML | Described in Section | 2119 | | | 11.2.1 | 2120 | 0x4286 | EBMLVersion | Described in Section | 2121 | | | 11.2.2 | 2122 | 0x42F7 | EBMLReadVersion | Described in Section | 2123 | | | 11.2.3 | 2124 | 0x42F2 | EBMLMaxIDLength | Described in Section | 2125 | | | 11.2.4 | 2126 | 0x42F3 | EBMLMaxSizeLength | Described in Section | 2127 | | | 11.2.5 | 2128 | 0x4282 | DocType | Described in Section | 2129 | | | 11.2.6 | 2130 | 0x4287 | DocTypeVersion | Described in Section | 2131 | | | 11.2.7 | 2132 | 0x4285 | DocTypeReadVersion | Described in Section | 2133 | | | 11.2.8 | 2134 | 0x4281 | DocTypeExtension | Described in Section | 2135 | | | 11.2.9 | 2136 | 0x4283 | DocTypeExtensionName | Described in Section | 2137 | | | 11.2.10 | 2138 | 0x4284 | DocTypeExtensionVersion | Described in Section | 2139 | | | 11.2.11 | 2140 | 0xBF | CRC-32 | Described in Section | 2141 | | | 11.3.1 | 2142 | 0xEC | Void | Described in Section | 2143 | | | 11.3.2 | 2144 +------------+-------------------------+----------------------------+ 2146 17.2. CELLAR EBML DocType Registry 2148 This document creates a new IANA Registry called "CELLAR EBML DocType 2149 Registry". 2151 To register a new DocType in this registry one needs a DocType name, 2152 a Description of the DocType, a Change Controller (IESG or email of 2153 registrant) and an optional Reference to a document describing the 2154 DocType. 2156 DocType values are described in Section 11.1.3.1. DocTypes are ASCII 2157 strings, defined in Section 7.4, which label the official name of the 2158 EBML Document Type. The strings may be allocated according to the 2159 "First Come First Served" policy. 2161 The use of ASCII corresponds to the types and code already in use, 2162 the value is not meant to be visible to the user. 2164 DocType string values of "matroska" and "webm" are RESERVED to the 2165 IETF for future use. These can be assigned via the "IESG Approval" 2166 or "RFC Required" policies [RFC8126]. 2168 18. References 2170 18.1. Normative References 2172 [IEEE.754.1985] 2173 Institute of Electrical and Electronics Engineers, 2174 "Standard for Binary Floating-Point Arithmetic", 2175 IEEE Standard 754, August 1985. 2177 [ISO.3309.1979] 2178 International Organization for Standardization, "Data 2179 communication - High-level data link control procedures - 2180 Frame structure", ISO Standard 3309, 1979. 2182 [ISO.9899.2011] 2183 International Organization for Standardization, 2184 "Programming languages - C", ISO Standard 9899, 2011. 2186 [ITU.V42.1994] 2187 International Telecommunications Union, "Error-correcting 2188 Procedures for DCEs Using Asynchronous-to-Synchronous 2189 Conversion", ITU-T Recommendation V.42, 1994. 2191 [RFC0020] Cerf, V., "ASCII format for network interchange", STD 80, 2192 RFC 20, DOI 10.17487/RFC0020, October 1969, 2193 . 2195 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2196 Requirement Levels", BCP 14, RFC 2119, 2197 DOI 10.17487/RFC2119, March 1997, 2198 . 2200 [RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: 2201 Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002, 2202 . 2204 [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 2205 10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November 2206 2003, . 2208 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 2209 Specifications: ABNF", STD 68, RFC 5234, 2210 DOI 10.17487/RFC5234, January 2008, 2211 . 2213 [RFC5646] Phillips, A., Ed. and M. Davis, Ed., "Tags for Identifying 2214 Languages", BCP 47, RFC 5646, DOI 10.17487/RFC5646, 2215 September 2009, . 2217 [RFC7405] Kyzivat, P., "Case-Sensitive String Support in ABNF", 2218 RFC 7405, DOI 10.17487/RFC7405, December 2014, 2219 . 2221 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 2222 Writing an IANA Considerations Section in RFCs", BCP 26, 2223 RFC 8126, DOI 10.17487/RFC8126, June 2017, 2224 . 2226 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2227 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2228 May 2017, . 2230 [W3C.REC-xml-20081126] 2231 Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and 2232 F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth 2233 Edition)", World Wide Web Consortium Recommendation REC- 2234 xml-20081126, November 2008, 2235 . 2237 [W3C.SPSD-xhtml-basic-20180327] 2238 McCarron, S., "XHTMLa„[cents] Basic 1.1 - Second 2239 Edition", World Wide Web Consortium Recommendation SPSD- 2240 xhtml-basic-20180327, March 2018, 2241 . 2243 18.2. Informative References 2245 [W3C.REC-xmlschema-0-20041028] 2246 Fallside, D. and P. Walmsley, "XML Schema Part 0: Primer 2247 Second Edition", World Wide Web Consortium Recommendation 2248 REC-xmlschema-0-20041028, October 2004, 2249 . 2251 18.3. URIs 2253 [1] https://github.com/Matroska-Org/matroska-specification/ 2255 Authors' Addresses 2257 Steve Lhomme 2259 Email: slhomme@matroska.org 2260 Dave Rice 2262 Email: dave@dericed.com 2264 Moritz Bunkus 2266 Email: moritz@bunkus.org